[pypy-svn] r16346 - pypy/dist/pypy/interpreter/pyparser/test
ludal at codespeak.net
ludal at codespeak.net
Wed Aug 24 10:37:03 CEST 2005
Author: ludal
Date: Wed Aug 24 10:37:01 2005
New Revision: 16346
Modified:
pypy/dist/pypy/interpreter/pyparser/test/test_astbuilder.py
pypy/dist/pypy/interpreter/pyparser/test/test_astcompiler.py
Log:
some tests can't pass with 2.3 some don't include them if we run 2.3
Modified: pypy/dist/pypy/interpreter/pyparser/test/test_astbuilder.py
==============================================================================
--- pypy/dist/pypy/interpreter/pyparser/test/test_astbuilder.py (original)
+++ pypy/dist/pypy/interpreter/pyparser/test/test_astbuilder.py Wed Aug 24 10:37:01 2005
@@ -223,6 +223,9 @@
'import a.b.c.d as abcd',
'from os import path',
'from os import path, system',
+ ]
+
+imports_newstyle = [
'from os import path, system,',
'from os import path as P, system as S,',
'from os import (path as P, system as S,)',
@@ -405,6 +408,7 @@
attraccess,
slices,
imports,
+ imports_newstyle,
asserts,
execs,
prints,
@@ -445,7 +449,6 @@
print
print "BUILT:", r1.rule_stack[-1]
print "-" * 30
- # r1.rule_stack[-1].equals(ast)
assert nodes_equal( ast, r1.rule_stack[-1]), 'failed on %r' % (expr)
@@ -502,7 +505,7 @@
source = file(filepath).read()
yield check_expression, source, 'exec'
-# FIXME: find the sys' attriubte that define this
+# FIXME: find the sys' attribute that define this
STDLIB_PATH = os.path.dirname(os.__file__)
def test_on_stdlib():
py.test.skip('too ambitious for now (and time consuming)')
Modified: pypy/dist/pypy/interpreter/pyparser/test/test_astcompiler.py
==============================================================================
--- pypy/dist/pypy/interpreter/pyparser/test/test_astcompiler.py (original)
+++ pypy/dist/pypy/interpreter/pyparser/test/test_astcompiler.py Wed Aug 24 10:37:01 2005
@@ -7,8 +7,35 @@
from pypy.interpreter.astcompiler import ast, misc, pycodegen
-from test_astbuilder import TESTS
-
+from test_astbuilder import expressions, comparisons, funccalls, backtrackings,\
+ listmakers, genexps, dictmakers, multiexpr, attraccess, slices, imports,\
+ asserts, execs, prints, globs, raises, imports_newstyle
+
+
+TESTS = [
+ expressions,
+ comparisons,
+ funccalls,
+ backtrackings,
+ listmakers,
+ dictmakers,
+ multiexpr,
+ attraccess,
+ slices,
+ imports,
+ execs,
+ prints,
+ globs,
+ raises,
+ ]
+
+import sys
+if sys.version_info[0]==2 and sys.version_info[1]>=4:
+ # genexps and new style import don't work on python2.3
+ TESTS.append(genexps)
+ TESTS.append(imports_newstyle)
+ # assertions give different bytecode with 2.4 (optimize if __debug__)
+ TESTS.append(asserts)
TARGET_DICT = {
'single' : 'single_input',
'exec' : 'file_input',
@@ -36,13 +63,20 @@
assert code1.co_filename == code2.co_filename
#print repr(code1.co_code)
#print repr(code2.co_code)
- assert code1.co_code == code2.co_code
+ if code1.co_code != code2.co_code:
+ import dis
+ print "Code from pypy:"
+ dis.dis(code1)
+ print "Code from python", sys.version
+ dis.dis(code2)
+ assert code1.co_code == code2.co_code
assert code1.co_varnames == code2.co_varnames
def check_compile( expr ):
import new
ast_tree = ast_parse_expr( expr )
misc.set_filename("<?>", ast_tree)
+ print "Compiling:", expr
#print ast_tree
codegenerator = pycodegen.InteractiveCodeGenerator(ast_tree)
code1 = new.code(*codegenerator.getCode())
More information about the Pypy-commit
mailing list