Commit 2789351e authored by Stefan Behnel's avatar Stefan Behnel

extended test cases for tickets #600 and #598

parent c758cc37
...@@ -16,3 +16,18 @@ def list_genexpr_iterable_lookup(): ...@@ -16,3 +16,18 @@ def list_genexpr_iterable_lookup():
result = list( x*2 for x in x if x % 2 == 0 ) result = list( x*2 for x in x if x % 2 == 0 )
assert x == (0,1,2,3,4,5) assert x == (0,1,2,3,4,5)
return result return result
@cython.test_assert_path_exists('//ComprehensionNode')
@cython.test_fail_if_path_exists('//SimpleCallNode')
def genexpr_iterable_in_closure():
"""
>>> genexpr_iterable_in_closure()
[0, 4, 8]
"""
x = 'abc'
def f():
return x
result = list( x*2 for x in x if x % 2 == 0 )
assert x == 'abc' # don't leak in Py3 code
assert f() == 'abc' # don't leak in Py3 code
return result
...@@ -25,3 +25,17 @@ def genexpr_in_closure(): ...@@ -25,3 +25,17 @@ def genexpr_in_closure():
assert x == 'abc' # don't leak in Py3 code assert x == 'abc' # don't leak in Py3 code
assert f() == 'abc' # don't leak in Py3 code assert f() == 'abc' # don't leak in Py3 code
return result return result
def genexpr_scope_in_closure():
"""
>>> genexpr_scope_in_closure()
[0, 4, 8]
"""
i = 2
x = 'abc'
def f():
return i, x
result = list( x*i for x in range(5) if x % 2 == 0 )
assert x == 'abc' # don't leak in Py3 code
assert f() == 2,'abc' # don't leak in Py3 code
return result
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