From 2789351e6638d3ca69aec102504b092e74205c05 Mon Sep 17 00:00:00 2001 From: Stefan Behnel Date: Thu, 25 Nov 2010 19:18:06 +0100 Subject: [PATCH] extended test cases for tickets #600 and #598 --- tests/run/genexpr_iterable_lookup_T600.pyx | 15 +++++++++++++++ tests/run/list_comp_in_closure_T598.pyx | 14 ++++++++++++++ 2 files changed, 29 insertions(+) diff --git a/tests/run/genexpr_iterable_lookup_T600.pyx b/tests/run/genexpr_iterable_lookup_T600.pyx index 37d6c9f5..e41148fa 100644 --- a/tests/run/genexpr_iterable_lookup_T600.pyx +++ b/tests/run/genexpr_iterable_lookup_T600.pyx @@ -16,3 +16,18 @@ def list_genexpr_iterable_lookup(): result = list( x*2 for x in x if x % 2 == 0 ) assert x == (0,1,2,3,4,5) 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 diff --git a/tests/run/list_comp_in_closure_T598.pyx b/tests/run/list_comp_in_closure_T598.pyx index 5246df27..3f39c9aa 100644 --- a/tests/run/list_comp_in_closure_T598.pyx +++ b/tests/run/list_comp_in_closure_T598.pyx @@ -25,3 +25,17 @@ def genexpr_in_closure(): assert x == 'abc' # don't leak in Py3 code assert f() == 'abc' # don't leak in Py3 code 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 -- 2.26.2