From 9447ca3e6a0f39aa95efc62108410ac4bc40436e Mon Sep 17 00:00:00 2001 From: Stefan Behnel Date: Tue, 30 Nov 2010 14:08:50 +0100 Subject: [PATCH] additional tests --- tests/run/list_comp_in_closure_T598.pyx | 58 +++++++++++++++++++++++++ 1 file changed, 58 insertions(+) diff --git a/tests/run/list_comp_in_closure_T598.pyx b/tests/run/list_comp_in_closure_T598.pyx index a1a42af7..3e833601 100644 --- a/tests/run/list_comp_in_closure_T598.pyx +++ b/tests/run/list_comp_in_closure_T598.pyx @@ -13,6 +13,35 @@ def list_comp_in_closure(): assert f() == 'abc' # don't leak in Py3 code return result +def pytyped_list_comp_in_closure(): + """ + >>> pytyped_list_comp_in_closure() + [0, 4, 8] + """ + cdef object x + x = 'abc' + def f(): + return x + result = [x*2 for x in range(5) if x % 2 == 0] + assert x == 'abc' # don't leak in Py3 code + assert f() == 'abc' # don't leak in Py3 code + return result + +def pytyped_list_comp_in_closure_repeated(): + """ + >>> pytyped_list_comp_in_closure_repeated() + [0, 4, 8] + """ + cdef object x + x = 'abc' + def f(): + return x + for i in range(3): + result = [x*2 for x in range(5) if x % 2 == 0] + assert x == 'abc' # don't leak in Py3 code + assert f() == 'abc' # don't leak in Py3 code + return result + def genexpr_in_closure(): """ >>> genexpr_in_closure() @@ -26,6 +55,35 @@ def genexpr_in_closure(): assert f() == 'abc' # don't leak in Py3 code return result +def pytyped_genexpr_in_closure(): + """ + >>> pytyped_genexpr_in_closure() + [0, 4, 8] + """ + cdef object x + x = 'abc' + def f(): + return x + result = list( x*2 for x in range(5) if x % 2 == 0 ) + assert x == 'abc' # don't leak in Py3 code + assert f() == 'abc' # don't leak in Py3 code + return result + +def pytyped_genexpr_in_closure_repeated(): + """ + >>> pytyped_genexpr_in_closure_repeated() + [0, 4, 8] + """ + cdef object x + x = 'abc' + def f(): + return x + for i in range(3): + result = list( x*2 for x in range(5) if x % 2 == 0 ) + 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() -- 2.26.2