summaryrefslogtreecommitdiff
path: root/Lib/test/test_grammar.py
diff options
context:
space:
mode:
authorJeremy Hylton <jeremy@alum.mit.edu>2005-10-20 19:59:25 +0000
committerJeremy Hylton <jeremy@alum.mit.edu>2005-10-20 19:59:25 +0000
commit0d45400bf5d6dc0f310a12d6e9d8d99395895c0b (patch)
tree39a310a36e115aafcf9fa5052440f9c0f9a7e201 /Lib/test/test_grammar.py
parenta778b23cb1c7c0ecede0c6821ffd5ed9e4d9f346 (diff)
downloadcpython-0d45400bf5d6dc0f310a12d6e9d8d99395895c0b.tar.gz
Merge ast-branch to head
This change implements a new bytecode compiler, based on a transformation of the parse tree to an abstract syntax defined in Parser/Python.asdl. The compiler implementation is not complete, but it is in stable enough shape to run the entire test suite excepting two disabled tests.
Diffstat (limited to 'Lib/test/test_grammar.py')
-rw-r--r--Lib/test/test_grammar.py25
1 files changed, 16 insertions, 9 deletions
diff --git a/Lib/test/test_grammar.py b/Lib/test/test_grammar.py
index 1b4a506844..820fab58cb 100644
--- a/Lib/test/test_grammar.py
+++ b/Lib/test/test_grammar.py
@@ -8,7 +8,7 @@
# regression test, the filterwarnings() call has been added to
# regrtest.py.
-from test.test_support import TestFailed, verify, check_syntax
+from test.test_support import TestFailed, verify, vereq, check_syntax
import sys
print '1. Parser'
@@ -157,28 +157,31 @@ def f2(one_argument): pass
def f3(two, arguments): pass
def f4(two, (compound, (argument, list))): pass
def f5((compound, first), two): pass
-verify(f2.func_code.co_varnames == ('one_argument',))
-verify(f3.func_code.co_varnames == ('two', 'arguments'))
+vereq(f2.func_code.co_varnames, ('one_argument',))
+vereq(f3.func_code.co_varnames, ('two', 'arguments'))
if sys.platform.startswith('java'):
- verify(f4.func_code.co_varnames ==
+ vereq(f4.func_code.co_varnames,
('two', '(compound, (argument, list))', 'compound', 'argument',
'list',))
- verify(f5.func_code.co_varnames ==
+ vereq(f5.func_code.co_varnames,
('(compound, first)', 'two', 'compound', 'first'))
else:
- verify(f4.func_code.co_varnames == ('two', '.2', 'compound',
- 'argument', 'list'))
- verify(f5.func_code.co_varnames == ('.0', 'two', 'compound', 'first'))
+ vereq(f4.func_code.co_varnames,
+ ('two', '.1', 'compound', 'argument', 'list'))
+ vereq(f5.func_code.co_varnames,
+ ('.0', 'two', 'compound', 'first'))
def a1(one_arg,): pass
def a2(two, args,): pass
def v0(*rest): pass
def v1(a, *rest): pass
def v2(a, b, *rest): pass
def v3(a, (b, c), *rest): return a, b, c, rest
+# ceval unpacks the formal arguments into the first argcount names;
+# thus, the names nested inside tuples must appear after these names.
if sys.platform.startswith('java'):
verify(v3.func_code.co_varnames == ('a', '(b, c)', 'rest', 'b', 'c'))
else:
- verify(v3.func_code.co_varnames == ('a', '.2', 'rest', 'b', 'c'))
+ vereq(v3.func_code.co_varnames, ('a', '.1', 'rest', 'b', 'c'))
verify(v3(1, (2, 3), 4) == (1, 2, 3, (4,)))
def d01(a=1): pass
d01()
@@ -410,6 +413,10 @@ def g1(): return
def g2(): return 1
g1()
x = g2()
+check_syntax("class foo:return 1")
+
+print 'yield_stmt'
+check_syntax("class foo:yield 1")
print 'raise_stmt' # 'raise' test [',' test]
try: raise RuntimeError, 'just testing'