Commit 31149c7e authored by Xavier Thompson's avatar Xavier Thompson

Add unit test for refcount of cypclass loop variables

parent a2406827
...@@ -91,4 +91,27 @@ def test_stack_refcount(): ...@@ -91,4 +91,27 @@ def test_stack_refcount():
if Cy_GETREF(s) != 2: if Cy_GETREF(s) != 2:
return -3 return -3
return 0 return 0
\ No newline at end of file
def test_loop_variable_refcount():
"""
>>> test_loop_variable_refcount()
Value destroyed
0
"""
s = Stack()
s.push(Value())
for val in s:
refcnt = Cy_GETREF(val)
if refcnt != 3:
print(refcnt)
return -1
for val in s:
refcnt = Cy_GETREF(val)
if refcnt != 3:
print(refcnt)
return -1
return 0
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment