Skip to content

Commit

Permalink
Add a test
Browse files Browse the repository at this point in the history
  • Loading branch information
tekknolagi committed Dec 13, 2023
1 parent 90b2e9e commit 075dbe0
Showing 1 changed file with 20 additions and 0 deletions.
20 changes: 20 additions & 0 deletions library/_compile_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -1706,6 +1706,26 @@ def foo():
""")
self.assertEqual(func(), {"x": 123})

def test_store_self_removes_last_store(self):
# TODO(max): See if we can remove the first store too
source = """
def foo():
x = 123
x = x
"""
func = compile_function(source, "foo")
self.assertEqual(
dis(func.__code__),
"""\
LOAD_CONST 123
STORE_FAST_REVERSE x
LOAD_FAST_REVERSE_UNCHECKED x
POP_TOP
LOAD_CONST None
RETURN_VALUE
""")
self.assertEqual(func(), None)

# TODO(max): Test loops


Expand Down

0 comments on commit 075dbe0

Please sign in to comment.