[pypy-svn] r66239 - in pypy/branch/parser-compiler/pypy/interpreter/astcompiler: . test

benjamin at codespeak.net benjamin at codespeak.net
Wed Jul 15 16:44:30 CEST 2009


Author: benjamin
Date: Wed Jul 15 16:44:30 2009
New Revision: 66239

Modified:
   pypy/branch/parser-compiler/pypy/interpreter/astcompiler/astbuilder.py
   pypy/branch/parser-compiler/pypy/interpreter/astcompiler/test/test_astbuilder.py
Log:
actually generate multiple statements for single input with semicolons

Modified: pypy/branch/parser-compiler/pypy/interpreter/astcompiler/astbuilder.py
==============================================================================
--- pypy/branch/parser-compiler/pypy/interpreter/astcompiler/astbuilder.py	(original)
+++ pypy/branch/parser-compiler/pypy/interpreter/astcompiler/astbuilder.py	Wed Jul 15 16:44:30 2009
@@ -81,7 +81,7 @@
                         stmt = first_child.children[i]
                         if stmt.type == tokens.NEWLINE:
                             break
-                        stmts.append(self.handle_stmt(first_child))
+                        stmts.append(self.handle_stmt(stmt))
                 return ast.Interactive(stmts)
         else:
             raise AssertionError("unkown root node")

Modified: pypy/branch/parser-compiler/pypy/interpreter/astcompiler/test/test_astbuilder.py
==============================================================================
--- pypy/branch/parser-compiler/pypy/interpreter/astcompiler/test/test_astbuilder.py	(original)
+++ pypy/branch/parser-compiler/pypy/interpreter/astcompiler/test/test_astbuilder.py	Wed Jul 15 16:44:30 2009
@@ -46,6 +46,12 @@
         mod = self.get_ast("x = 23", p_mode="single")
         assert isinstance(mod, ast.Interactive)
         assert len(mod.body) == 1
+        mod = self.get_ast("x = 23; y = 23; b = 23", p_mode="single")
+        assert isinstance(mod, ast.Interactive)
+        assert len(mod.body) == 3
+        for stmt in mod.body:
+            assert isinstance(stmt, ast.Assign)
+        assert mod.body[-1].targets[0].id == "b"
 
         mod = self.get_ast("x = 23; y = 23; b = 23")
         assert isinstance(mod, ast.Module)



More information about the Pypy-commit mailing list