FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

Update test_peepholer test_compiler_codegen test_compiler_assemble from 3.14.2 by ShaharNaveh · Pull Request #6870 · RustPython/RustPython · GitHub

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension .py  (3) All 1 file type selected
Viewed files
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Unified
Split
Hide whitespace
Diff view
Unified
Split
Hide whitespace
14 changes: 8 additions & 6 deletions Lib/test/test_compiler_assemble.py
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ def inner():
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 = {
Expand Down Expand Up @@ -125,13 +125,15 @@ def test_exception_table(self):
# 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),
Expand All @@ -144,4 +146,4 @@ def test_exception_table(self):
L1 to L2 -> L2 [0]
L2 to L3 -> L3 [1] lasti
""")
self.assertTrue(output.getvalue().endswith(exc_table))
self.assertEndsWith(output.getvalue(), exc_table)
20 changes: 12 additions & 8 deletions Lib/test/test_compiler_codegen.py
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Original file line number Diff line number Diff line change
Expand Up @@ -26,16 +26,17 @@ def test_if_expression(self):
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)
Expand All @@ -45,6 +46,7 @@ def test_for_loop(self):
false_lbl = self.Label()
expected = [
('RESUME', 0, 0),
('ANNOTATIONS_PLACEHOLDER', None),
('LOAD_NAME', 0, 1),
('GET_ITER', None, 1),
loop_lbl := self.Label(),
Expand All @@ -59,7 +61,7 @@ def test_for_loop(self):
('JUMP', loop_lbl),
exit_lbl,
('END_FOR', None),
('POP_TOP', None),
('POP_ITER', None),
('LOAD_CONST', 0),
('RETURN_VALUE', None),
]
Expand All @@ -73,6 +75,7 @@ def f(x):
expected = [
# Function definition
('RESUME', 0),
('ANNOTATIONS_PLACEHOLDER', None),
('LOAD_CONST', 0),
('MAKE_FUNCTION', None),
('STORE_NAME', 0),
Expand All @@ -82,7 +85,7 @@ def f(x):
# Function body
('RESUME', 0),
('LOAD_FAST', 0),
('LOAD_CONST', 1),
('LOAD_CONST', 42),
('BINARY_OP', 0),
('RETURN_VALUE', None),
('LOAD_CONST', 0),
Expand All @@ -106,6 +109,7 @@ def g():
expected = [
# Function definition
('RESUME', 0),
('ANNOTATIONS_PLACEHOLDER', None),
('LOAD_CONST', 0),
('MAKE_FUNCTION', None),
('STORE_NAME', 0),
Expand All @@ -125,9 +129,9 @@ def g():
[
('RESUME', 0),
('NOP', None),
('LOAD_CONST', 1),
('LOAD_CONST', 12),
('RETURN_VALUE', None),
('LOAD_CONST', 0),
('LOAD_CONST', 1),
('RETURN_VALUE', None),
],
[
Expand All @@ -141,7 +145,7 @@ def g():
('LOAD_CONST', 4),
('STORE_FAST', 3),
('NOP', None),
('LOAD_CONST', 5),
('LOAD_CONST', 42),
('RETURN_VALUE', None),
('LOAD_CONST', 0),
('RETURN_VALUE', None),
Expand Down
Loading
Loading

Back | FazBrowse Home | New Git URL