[pypy-svn] r54908 - pypy/branch/2.5-features/pypy/interpreter/pyparser/test
bgola at codespeak.net
bgola at codespeak.net
Sun May 18 22:51:28 CEST 2008
Author: bgola
Date: Sun May 18 22:51:27 2008
New Revision: 54908
Modified:
pypy/branch/2.5-features/pypy/interpreter/pyparser/test/expressions.py
pypy/branch/2.5-features/pypy/interpreter/pyparser/test/test_astbuilder.py
Log:
fixing tests for astbuilder (empty base classes list can be empty)
Modified: pypy/branch/2.5-features/pypy/interpreter/pyparser/test/expressions.py
==============================================================================
--- pypy/branch/2.5-features/pypy/interpreter/pyparser/test/expressions.py (original)
+++ pypy/branch/2.5-features/pypy/interpreter/pyparser/test/expressions.py Sun May 18 22:51:27 2008
@@ -361,9 +361,7 @@
one_stmt_classdefs = [
"class Pdb(bdb.Bdb, cmd.Cmd): pass",
- "class A(): pass",
"class A: pass",
- "class A)(: x",
]
docstrings = [
@@ -484,6 +482,10 @@
## ["l = [i for i in range(10) if i%2 == 0 or i%2 == 1]"],
## ]
+CHANGES_25_INPUTS = [
+ ["class A(): pass"],
+ ]
+
EXEC_INPUTS = [
one_stmt_classdefs,
one_stmt_funcdefs,
Modified: pypy/branch/2.5-features/pypy/interpreter/pyparser/test/test_astbuilder.py
==============================================================================
--- pypy/branch/2.5-features/pypy/interpreter/pyparser/test/test_astbuilder.py (original)
+++ pypy/branch/2.5-features/pypy/interpreter/pyparser/test/test_astbuilder.py Sun May 18 22:51:27 2008
@@ -14,7 +14,7 @@
from pypy.interpreter.astcompiler import ast
from fakes import FakeSpace
-from expressions import TESTS, SINGLE_INPUTS, EXEC_INPUTS
+from expressions import TESTS, SINGLE_INPUTS, EXEC_INPUTS, CHANGES_25_INPUTS
def arglist_equal(left,right):
"""needs special case because we handle the argumentlist differently"""
@@ -168,6 +168,9 @@
"a[100, 1:]": "Module(None, Stmt([Discard(Subscript(Name('a'), 2, Tuple([Const(100), Sliceobj([Const(1), Const(None)])])))]))",
"a[100, :2,]": "Module(None, Stmt([Discard(Subscript(Name('a'), 2, Tuple([Const(100), Sliceobj([Const(None), Const(2)])])))]))",
"a[100, :]": "Module(None, Stmt([Discard(Subscript(Name('a'), 2, Tuple([Const(100), Sliceobj([Const(None), Const(None)])])))]))",
+
+ # stablecompiler can't produce AST for 2.5 syntax (yet)
+ "class A(): pass": "Module(None, Stmt([Class('A', [], None, Stmt([Pass()]))]))",
# stablecompiler produces a Pass statement which does not seem very consistent
# (a module should only have a Stmt child)
@@ -181,15 +184,14 @@
t = Transformer("dummyfile")
return ast_from_input(expr, target, t, stable_parser)
-def source2ast(source, mode, space=FakeSpace()):
- version = '2.4'
+def source2ast(source, mode, space=FakeSpace(), version='2.4'):
python_parser = pythonparse.make_pyparser(version)
builder = AstBuilder(python_parser, version, space=space)
python_parser.parse_source(source, mode, builder)
return builder.rule_stack[-1]
-def check_expression(expr, mode='single'):
- pypy_ast = source2ast(expr, mode)
+def check_expression(expr, mode='single', version='2.4'):
+ pypy_ast = source2ast(expr, mode, version=version)
try:
python_ast = EXPECTED[expr]
except KeyError:
@@ -219,6 +221,10 @@
for expr in family:
yield check_expression, expr, 'exec'
+def test_changes_25():
+ for family in CHANGES_25_INPUTS:
+ for expr in family:
+ yield check_expression, expr, 'exec', '2.5'
NEW_GRAMMAR_SNIPPETS = [
'snippet_with_1.py',
@@ -266,7 +272,7 @@
]
def test_snippets():
- for snippet_name in SNIPPETS: # + NEW_GRAMMAR_SNIPPETS: # Disabled 2.5 syntax
+ for snippet_name in SNIPPETS: # + NEW_GRAMMAR_SNIPPETS:
filepath = os.path.join(os.path.dirname(__file__), 'samples', snippet_name)
source = file(filepath).read()
# To avoid using the stable compiler we pull an explicit AST out of the snippet
More information about the Pypy-commit
mailing list