mirror of
https://github.com/RustPython/RustPython.git
synced 2026-10-28 10:44:36 +08:00
Update test_compiler_codegen and test_compiler_assemble
This commit is contained in:
1 parent
7cc4f43779
commit
253414f168
2 files changed
+20
-14
No files matched your search
Vendored
+8
-6
@@ -84,7 +84,7 @@ class IsolatedAssembleTests(AssemblerTestCase):
|
||||
return x
|
||||
return inner() % 2
|
||||
|
||||
inner_code = mod_two.__code__.co_consts[1]
|
||||
inner_code = mod_two.__code__.co_consts[0]
|
||||
assert isinstance(inner_code, types.CodeType)
|
||||
|
||||
metadata = {
|
||||
@@ -125,13 +125,15 @@ class IsolatedAssembleTests(AssemblerTestCase):
|
||||
# code for "try: pass\n except: pass"
|
||||
insts = [
|
||||
('RESUME', 0),
|
||||
('SETUP_FINALLY', 3),
|
||||
('RETURN_CONST', 0),
|
||||
('SETUP_CLEANUP', 8),
|
||||
('SETUP_FINALLY', 4),
|
||||
('LOAD_CONST', 0),
|
||||
('RETURN_VALUE', None),
|
||||
('SETUP_CLEANUP', 10),
|
||||
('PUSH_EXC_INFO', None),
|
||||
('POP_TOP', None),
|
||||
('POP_EXCEPT', None),
|
||||
('RETURN_CONST', 0),
|
||||
('LOAD_CONST', 0),
|
||||
('RETURN_VALUE', None),
|
||||
('COPY', 3),
|
||||
('POP_EXCEPT', None),
|
||||
('RERAISE', 1),
|
||||
@@ -144,4 +146,4 @@ class IsolatedAssembleTests(AssemblerTestCase):
|
||||
L1 to L2 -> L2 [0]
|
||||
L2 to L3 -> L3 [1] lasti
|
||||
""")
|
||||
self.assertTrue(output.getvalue().endswith(exc_table))
|
||||
self.assertEndsWith(output.getvalue(), exc_table)
|
||||
Vendored
+12
-8
@@ -26,16 +26,17 @@ class IsolatedCodeGenTests(CodegenTestCase):
|
||||
false_lbl = self.Label()
|
||||
expected = [
|
||||
('RESUME', 0, 0),
|
||||
('ANNOTATIONS_PLACEHOLDER', None),
|
||||
('LOAD_CONST', 0, 1),
|
||||
('TO_BOOL', 0, 1),
|
||||
('POP_JUMP_IF_FALSE', false_lbl := self.Label(), 1),
|
||||
('LOAD_CONST', 1, 1),
|
||||
('LOAD_CONST', 1, 1), # 42
|
||||
('JUMP_NO_INTERRUPT', exit_lbl := self.Label()),
|
||||
false_lbl,
|
||||
('LOAD_CONST', 2, 1),
|
||||
('LOAD_CONST', 2, 1), # 24
|
||||
exit_lbl,
|
||||
('POP_TOP', None),
|
||||
('LOAD_CONST', 3),
|
||||
('LOAD_CONST', 1),
|
||||
('RETURN_VALUE', None),
|
||||
]
|
||||
self.codegen_test(snippet, expected)
|
||||
@@ -45,6 +46,7 @@ class IsolatedCodeGenTests(CodegenTestCase):
|
||||
false_lbl = self.Label()
|
||||
expected = [
|
||||
('RESUME', 0, 0),
|
||||
('ANNOTATIONS_PLACEHOLDER', None),
|
||||
('LOAD_NAME', 0, 1),
|
||||
('GET_ITER', None, 1),
|
||||
loop_lbl := self.Label(),
|
||||
@@ -59,7 +61,7 @@ class IsolatedCodeGenTests(CodegenTestCase):
|
||||
('JUMP', loop_lbl),
|
||||
exit_lbl,
|
||||
('END_FOR', None),
|
||||
('POP_TOP', None),
|
||||
('POP_ITER', None),
|
||||
('LOAD_CONST', 0),
|
||||
('RETURN_VALUE', None),
|
||||
]
|
||||
@@ -73,6 +75,7 @@ class IsolatedCodeGenTests(CodegenTestCase):
|
||||
expected = [
|
||||
# Function definition
|
||||
('RESUME', 0),
|
||||
('ANNOTATIONS_PLACEHOLDER', None),
|
||||
('LOAD_CONST', 0),
|
||||
('MAKE_FUNCTION', None),
|
||||
('STORE_NAME', 0),
|
||||
@@ -82,7 +85,7 @@ class IsolatedCodeGenTests(CodegenTestCase):
|
||||
# Function body
|
||||
('RESUME', 0),
|
||||
('LOAD_FAST', 0),
|
||||
('LOAD_CONST', 1),
|
||||
('LOAD_CONST', 42),
|
||||
('BINARY_OP', 0),
|
||||
('RETURN_VALUE', None),
|
||||
('LOAD_CONST', 0),
|
||||
@@ -106,6 +109,7 @@ class IsolatedCodeGenTests(CodegenTestCase):
|
||||
expected = [
|
||||
# Function definition
|
||||
('RESUME', 0),
|
||||
('ANNOTATIONS_PLACEHOLDER', None),
|
||||
('LOAD_CONST', 0),
|
||||
('MAKE_FUNCTION', None),
|
||||
('STORE_NAME', 0),
|
||||
@@ -125,9 +129,9 @@ class IsolatedCodeGenTests(CodegenTestCase):
|
||||
[
|
||||
('RESUME', 0),
|
||||
('NOP', None),
|
||||
('LOAD_CONST', 1),
|
||||
('LOAD_CONST', 12),
|
||||
('RETURN_VALUE', None),
|
||||
('LOAD_CONST', 0),
|
||||
('LOAD_CONST', 1),
|
||||
('RETURN_VALUE', None),
|
||||
],
|
||||
[
|
||||
@@ -141,7 +145,7 @@ class IsolatedCodeGenTests(CodegenTestCase):
|
||||
('LOAD_CONST', 4),
|
||||
('STORE_FAST', 3),
|
||||
('NOP', None),
|
||||
('LOAD_CONST', 5),
|
||||
('LOAD_CONST', 42),
|
||||
('RETURN_VALUE', None),
|
||||
('LOAD_CONST', 0),
|
||||
('RETURN_VALUE', None),
|
||||
|
||||
Reference in new issue
Block a user