summaryrefslogtreecommitdiffstats
path: root/Lib/test/test_grammar.py
diff options
context:
space:
mode:
authorGuido van Rossum <guido@python.org>1993-10-22 14:24:22 (GMT)
committerGuido van Rossum <guido@python.org>1993-10-22 14:24:22 (GMT)
commitb3b09c97ce0b40a282553b0366addc879a115eb4 (patch)
tree2645072ddae2aadfab339dcc6578de459bda6ddc /Lib/test/test_grammar.py
parentb37954f91771735e8595918f6e43f46438db7397 (diff)
downloadcpython-b3b09c97ce0b40a282553b0366addc879a115eb4.zip
cpython-b3b09c97ce0b40a282553b0366addc879a115eb4.tar.gz
cpython-b3b09c97ce0b40a282553b0366addc879a115eb4.tar.bz2
added builtin b/w compat module.
changed testing of exec.
Diffstat (limited to 'Lib/test/test_grammar.py')
-rw-r--r--Lib/test/test_grammar.py21
1 files changed, 20 insertions, 1 deletions
diff --git a/Lib/test/test_grammar.py b/Lib/test/test_grammar.py
index 56fb14f..f07f75b 100644
--- a/Lib/test/test_grammar.py
+++ b/Lib/test/test_grammar.py
@@ -97,7 +97,7 @@ def v3(a, (b, c), *rest): pass
print 'simple_stmt'
x = 1; pass; del x
-### small_stmt: expr_stmt | print_stmt | pass_stmt | del_stmt | flow_stmt | import_stmt
+### small_stmt: expr_stmt | print_stmt | pass_stmt | del_stmt | flow_stmt | import_stmt | global_stmt | access_stmt | exec_stmt
# Tested below
print 'expr_stmt' # (exprlist '=')* exprlist
@@ -165,6 +165,25 @@ def f():
global a, b
global one, two, three, four, five, six, seven, eight, nine, ten
+print 'exec_stmt' # 'exec' expr ['in' expr [',' expr]]
+def f():
+ z = None
+ del z
+ exec 'z=1+1\n'
+ if z <> 2: raise TestFailed, 'exec \'z=1+1\'\\n'
+ del z
+ exec 'z=1+1'
+ if z <> 2: raise TestFailed, 'exec \'z=1+1\''
+f()
+g = {}
+exec 'z = 1' in g
+if g <> {'z': 1}: raise TestFailed, 'exec \'z = 1\' in g'
+g = {}
+l = {}
+exec 'global a; a = 1; b = 2' in g, l
+if (g, l) <> ({'a':1}, {'b':2}): raise TestFailed, 'exec ... in g, l'
+
+
### compound_stmt: if_stmt | while_stmt | for_stmt | try_stmt | funcdef | classdef
# Tested below