1.1 --- a/tests/nested.py Thu Sep 08 21:36:58 2016 +0200
1.2 +++ b/tests/nested.py Thu Sep 08 21:56:20 2016 +0200
1.3 @@ -1,8 +1,8 @@
1.4 a = 4
1.5
1.6 def f(x):
1.7 - def g(y):
1.8 - def h(z):
1.9 + def g(y, x=x):
1.10 + def h(z, x=x, y=y):
1.11 return x, y, z, a
1.12 return h
1.13 return g
2.1 --- a/tests/nested_bad.py Thu Sep 08 21:36:58 2016 +0200
2.2 +++ b/tests/nested_bad.py Thu Sep 08 21:56:20 2016 +0200
2.3 @@ -1,7 +1,7 @@
2.4 def f(x):
2.5 - def g(y):
2.6 + def g(y, x=x):
2.7 while 1:
2.8 - def h(z):
2.9 + def h(z, x=x, y=y):
2.10 return x, y, z, a
2.11 a = 4 # not available for h, available in Python
2.12 return h
3.1 --- a/tests/nested_bad_python.py Thu Sep 08 21:36:58 2016 +0200
3.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
3.3 @@ -1,13 +0,0 @@
3.4 -a = 4
3.5 -
3.6 -def f(x):
3.7 - def g():
3.8 - def h(z):
3.9 - return x, y, z, a
3.10 - h(3) # NameError in Python
3.11 - y = 2 # not available for h, detected during inspection
3.12 - return h
3.13 - return g
3.14 -
3.15 -result = f(1)()(3)
3.16 -assert result == (1, 2, 3, 4)
4.1 --- a/tests/nested_lambda.py Thu Sep 08 21:36:58 2016 +0200
4.2 +++ b/tests/nested_lambda.py Thu Sep 08 21:56:20 2016 +0200
4.3 @@ -1,7 +1,7 @@
4.4 a = 4
4.5
4.6 def f(x):
4.7 - g = lambda y: lambda z: (x, y, z, a)
4.8 + g = lambda y, x=x: lambda z, x=x, y=y: (x, y, z, a)
4.9 return g
4.10
4.11 result = f(1)(2)(3)
5.1 --- a/tests/nested_mixed.py Thu Sep 08 21:36:58 2016 +0200
5.2 +++ b/tests/nested_mixed.py Thu Sep 08 21:56:20 2016 +0200
5.3 @@ -1,11 +1,11 @@
5.4 a = 4
5.5
5.6 def f(x):
5.7 - def g(y):
5.8 - def h(y, z):
5.9 - return x, y, z, a # parameter y overrides outer scope
5.10 + def g(y, x=x):
5.11 + def h(a, z, x=x, y=y):
5.12 + return x, y, z, a # parameter a overrides global scope
5.13 return h
5.14 return g
5.15
5.16 result = f(1)(2)(5, 3)
5.17 -assert result == (1, 5, 3, 4)
5.18 +assert result == (1, 2, 3, 5)
6.1 --- a/tests/nested_mixed_names.py Thu Sep 08 21:36:58 2016 +0200
6.2 +++ b/tests/nested_mixed_names.py Thu Sep 08 21:56:20 2016 +0200
6.3 @@ -10,7 +10,7 @@
6.4
6.5 def f(x):
6.6 x.c()
6.7 - def g(y): # x introduced as default here
6.8 + def g(y, x=x): # x must be introduced as default here
6.9 if y:
6.10 x = D()
6.11 return x.d(), y, a # UnboundLocalError in Python (if y is a false value)
7.1 --- a/tests/nested_value_changed.py Thu Sep 08 21:36:58 2016 +0200
7.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
7.3 @@ -1,13 +0,0 @@
7.4 -a = 4
7.5 -
7.6 -def f(x):
7.7 - def g():
7.8 - y = 2 # used to initialise h
7.9 - def h(z):
7.10 - return x, y, z, a
7.11 - y = 5 # Python uses this value directly from g in h
7.12 - return h
7.13 - return g
7.14 -
7.15 -result = f(1)()(3)
7.16 -assert result == (1, 2, 3, 4) # (1, 5, 3, 4) in Python