[pypy-svn] r32637 - in pypy/dist/pypy/interpreter: pyparser test
ac at codespeak.net
ac at codespeak.net
Mon Sep 25 18:34:51 CEST 2006
Author: ac
Date: Mon Sep 25 18:34:50 2006
New Revision: 32637
Modified:
pypy/dist/pypy/interpreter/pyparser/astbuilder.py
pypy/dist/pypy/interpreter/test/test_syntax.py
Log:
Add some tests for the 'as' keyword.
Modified: pypy/dist/pypy/interpreter/pyparser/astbuilder.py
==============================================================================
--- pypy/dist/pypy/interpreter/pyparser/astbuilder.py (original)
+++ pypy/dist/pypy/interpreter/pyparser/astbuilder.py Mon Sep 25 18:34:50 2006
@@ -1262,8 +1262,6 @@
else:
token = atoms[2]
assert isinstance(token, TokenObject)
- if token.get_value() != 'as':
- raise SyntaxError("invalid syntax", token.lineno, token.col)
varexpr = atoms[3]
var = to_lvalue(varexpr, consts.OP_ASSIGN)
body = atoms[5]
Modified: pypy/dist/pypy/interpreter/test/test_syntax.py
==============================================================================
--- pypy/dist/pypy/interpreter/test/test_syntax.py (original)
+++ pypy/dist/pypy/interpreter/test/test_syntax.py Mon Sep 25 18:34:50 2006
@@ -472,6 +472,21 @@
pass
else:
assert False, 'Assignment to with did not raise SyntaxError'
+
+ def test_as_as_identifier(self):
+ exec "as = 9"
+ exec "import sys as foo"
+
+ def test_as_as_keyword(self):
+ try:
+ exec "from __future__ import with_statement\nas = 9"
+ except SyntaxError:
+ pass
+ else:
+ assert False, 'Assignment to as did not raise SyntaxError'
+
+ exec "from __future__ import with_statement\nimport sys as foo"
+
def test_with_propagate_compileflag(self):
s = """from __future__ import with_statement
More information about the Pypy-commit
mailing list