Commit 30bb06be authored by Travis Hance's avatar Travis Hance

uncommented more eval tests

parent 1f55b52d
# lots of eval functionality not implemented # TODO lots of eval functionality not implemented
print eval("3 + 4") print eval("3 + 4")
...@@ -48,13 +48,13 @@ def func(): ...@@ -48,13 +48,13 @@ def func():
eval("[h for h in range(5)]") eval("[h for h in range(5)]")
print h print h
# h2 = 2 h2 = 2
# print eval("h2 + sum([h2 for h2 in range(5)])") print eval("h2 + sum([h2 for h2 in range(5)])")
# print 'h2', h2 print 'h2', h2
# h3 = 2 h3 = 2
# print eval("sum([h3 for h3 in range(5)]) + h3") print eval("sum([h3 for h3 in range(5)]) + h3")
# print 'h3', h3 print 'h3', h3
eval("[i for i in range(5)]") eval("[i for i in range(5)]")
...@@ -86,7 +86,6 @@ print 'eval eval o', eval("eval('o')") ...@@ -86,7 +86,6 @@ print 'eval eval o', eval("eval('o')")
#print eval("[(lambda p : p + o)(5) for o in range(5)]") #print eval("[(lambda p : p + o)(5) for o in range(5)]")
"""
shadow1 = 1000 shadow1 = 1000
shadow2 = 1000 shadow2 = 1000
shadow3 = 1000 shadow3 = 1000
...@@ -100,22 +99,35 @@ def func2(): ...@@ -100,22 +99,35 @@ def func2():
print 'shadow3', eval("shadow3 + sum([2 for shadow3 in range(5)]) + shadow3") print 'shadow3', eval("shadow3 + sum([2 for shadow3 in range(5)]) + shadow3")
func2() func2()
print 'shadow1', shadow2 #print 'shadow1', shadow2
print 'shadow2', shadow2 #print 'shadow2', shadow2
print 'shadow3', shadow3 #print 'shadow3', shadow3
def func3(): def func3():
loc = 1234 loc = 1234
print eval("(lambda arg : arg + loc)(12)") try:
print eval("(lambda arg : arg + loc)(12)")
except NameError as e:
print 'NameError', e.message
try:
print eval("loc + (lambda arg : arg + loc)(12)")
except NameError as e:
print 'NameError', e.message
func3() func3()
"""
changing_global = -1 changing_global = -1
def print_changing_global(): def print_changing_global():
print 'changing_global is', changing_global print 'changing_global is', changing_global
return 0 return 0
eval("[print_changing_global() for changing_global in range(5)]") eval("[print_changing_global() for changing_global in range(5)]")
"""
def do_changing_local(): def do_changing_local():
# this won't get modified:
changing_local = -1 changing_local = -1
def print_changing_local(): def print_changing_local():
print 'changing_local is', changing_local print 'changing_local is', changing_local
...@@ -123,8 +135,6 @@ def do_changing_local(): ...@@ -123,8 +135,6 @@ def do_changing_local():
eval("[print_changing_local() for changing_local in range(5)]") eval("[print_changing_local() for changing_local in range(5)]")
do_changing_local() do_changing_local()
"""
x = 2 x = 2
def wrap(): def wrap():
x = 1 x = 1
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment