Skip to content

Commit f29330d

Browse files
committed
Pyrona: Proper LRC decs and incs
1 parent 926b568 commit f29330d

File tree

1 file changed

+26
-0
lines changed

1 file changed

+26
-0
lines changed

Lib/test/test_veronapy_writebarrier.py

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import unittest
2+
import dis
23

34
class TestCellWriteBarrier(unittest.TestCase):
45
class A:
@@ -75,5 +76,30 @@ def test_cell_replace_same_bridge(self):
7576
# since this writes replaces the previous owning reference
7677
c.cell_contents = child
7778

79+
class TestBytecodeWriteBarrier(unittest.TestCase):
80+
def test_delete_deref(self):
81+
r = Region()
82+
r.field = {}
83+
x = r.field
84+
85+
# Make sure the region knows about local reference from x
86+
self.assertFalse(r.try_close())
87+
88+
def del_x():
89+
nonlocal x
90+
del x # This triggers the DELETE_DEREF opcode
91+
92+
# Create the function and disassemble to confirm DELETE_DEREF is present
93+
bytecode = dis.Bytecode(del_x)
94+
self.assertIn("DELETE_DEREF", [instr.opname for instr in bytecode])
95+
96+
self.assertTrue(r.is_open())
97+
98+
# Call the function forcing the deletion of x which should
99+
# close the region.
100+
del_x()
101+
102+
self.assertFalse(r.is_open())
103+
78104
if __name__ == "__main__":
79105
unittest.main()

0 commit comments

Comments
 (0)