Skip to content

Commit e7fc901

Browse files
committed
Add a bytecode test.
1 parent ed49167 commit e7fc901

1 file changed

Lines changed: 29 additions & 0 deletions

File tree

Lib/test/test_compiler_codegen.py

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -161,3 +161,32 @@ def test_syntax_error__return_not_in_function(self):
161161
self.assertIsNone(cm.exception.text)
162162
self.assertEqual(cm.exception.offset, 1)
163163
self.assertEqual(cm.exception.end_offset, 10)
164+
165+
def test_frozenset_optimization(self):
166+
snippet = "frozenset({1, 2, 3})"
167+
expected = [
168+
('RESUME', 0),
169+
('ANNOTATIONS_PLACEHOLDER', None),
170+
('LOAD_NAME', 0),
171+
('COPY', 1),
172+
('LOAD_COMMON_CONSTANT', 12),
173+
('IS_OP', 0),
174+
('POP_JUMP_IF_FALSE', 9),
175+
('POP_TOP', None),
176+
('LOAD_CONST', 1),
177+
('LOAD_CONST', 2),
178+
('LOAD_CONST', 3),
179+
('BUILD_SET', 3),
180+
('CALL_INTRINSIC_1', 12),
181+
('JUMP', 0),
182+
('PUSH_NULL', None),
183+
('LOAD_CONST', 1),
184+
('LOAD_CONST', 2),
185+
('LOAD_CONST', 3),
186+
('BUILD_SET', 3),
187+
('CALL', 1),
188+
('POP_TOP', None),
189+
('LOAD_CONST', 0),
190+
('RETURN_VALUE', None)
191+
]
192+
self.codegen_test(snippet, expected)

0 commit comments

Comments
 (0)