From: Stefan Behnel Date: Tue, 28 Apr 2009 20:38:19 +0000 (+0200) Subject: extended closure test cases X-Git-Tag: 0.13.beta0~2^2~154 X-Git-Url: http://git.tremily.us/?a=commitdiff_plain;h=8eaf0970d5e28d5c8bbff102c9b889a3183c650e;p=cython.git extended closure test cases --- diff --git a/tests/run/closures_T82.pyx b/tests/run/closures_T82.pyx index 9b89f1a9..a78daf7c 100644 --- a/tests/run/closures_T82.pyx +++ b/tests/run/closures_T82.pyx @@ -5,6 +5,36 @@ __doc__ = u""" >>> a(5)() 8 + +# this currently segfaults: +#>>> x(1)(2)(4) +#15 + +>>> inner_override(2,4)() +5 + +>>> reassign(4)(2) +3 + +>>> reassign_int(4)(2) +3 + +>>> reassign_int_int(4)(2) +3 + +>>> def py_twofuncs(x): +... def f(a): +... return g(x) + a +... def g(b): +... return x + b +... return f + +# this currently segfaults: +#>>> py_twofuncs(1)(2) == cy_twofuncs(1)(2) +#True +#>>> py_twofuncs(3)(5) == cy_twofuncs(3)(5) +#True + """ def add_n(int n): @@ -18,3 +48,47 @@ def a(int x): return 3+x return c() return b + + +def x(int x): + # currently segfaults + def y(y): + def z(long z): + return 8+z+y+x + return z + return y + + +def inner_override(a,b): + def f(): + a = 1 + return a+b + return f + + +def reassign(x): + def f(a): + return a+x + x = 1 # currently lacks a GIVEREF() + return f + +def reassign_int(x): + def f(int a): + return a+x + x = 1 # currently lacks a GIVEREF() + return f + +def reassign_int_int(int x): + def f(int a): + return a+x + x = 1 + return f + + +def cy_twofuncs(x): + # pretty ugly segfault + def f(a): + return g(x) + a + def g(b): + return x + b + return f