From 3fbf66f42c52a621e0036f688b88d03affbb481f Mon Sep 17 00:00:00 2001 From: David Halter Date: Sat, 22 Dec 2012 18:59:55 +0100 Subject: [PATCH] 14 lambda tests --- test/completion/functions.py | 55 ++++++++++++++++++++++++++++++++++++ 1 file changed, 55 insertions(+) diff --git a/test/completion/functions.py b/test/completion/functions.py index 2d9a4512..cc6df344 100644 --- a/test/completion/functions.py +++ b/test/completion/functions.py @@ -354,3 +354,58 @@ annot_ret('') def a(): pass #? ['__closure__'] a.__closure__ + + +# ----------------- +# lambdas +# ----------------- +a = lambda: 3 +#? int() +a() + +x = [] +a = lambda x: x +int() +a(0) + +#? float() +(lambda x: x)(3.0) + +arg_l = lambda x, y: y, x +#? float() +argl[0]('', 1.0) +#? list() +arg_l[1] + +arg_l = lambda x, y: y, x +args = 1,"" +result = arg_l(*args) +#? tuple() +result +#? str() +result[0] +#? int() +result[1] + +def with_lambda(callable_lambda, *args, **kwargs): + return callable_lambda(1, *args, **kwargs) + +#? int() +with_lambda(arg_l, 1.0)[1] +#? float() +with_lambda(arg_l, 1.0)[0] +#? float() +with_lambda(arg_l, x=1.0)[0] +#? float() +with_lambda(lambda x: x, x=1.0)[0] + +arg_func = lambda *args, **kwargs: args[0], kwargs['a'] +#? int() +arg_func(1, 2, a='', b=10)[0] +#? list() +arg_func(1, 2, a=[], b=10)[1] + +# magic method +a = lambda: 3 +#? ['__closure__'] +a.__closure__