aboutsummaryrefslogtreecommitdiffstats
path: root/test/ast.py
diff options
context:
space:
mode:
authorMike Bayer <mike_mp@zzzcomputing.com>2006-11-20 08:44:22 +0000
committerMike Bayer <mike_mp@zzzcomputing.com>2006-11-20 08:44:22 +0000
commitc5eae67494631f904662235d9b6baf974482e466 (patch)
tree6b211787a97a300e187e9870fd902504153fc238 /test/ast.py
parenta39b16e665e822ab7d5cd4d837cf38c35f1761d2 (diff)
downloadexternal_python_mako-c5eae67494631f904662235d9b6baf974482e466.tar.gz
external_python_mako-c5eae67494631f904662235d9b6baf974482e466.tar.bz2
external_python_mako-c5eae67494631f904662235d9b6baf974482e466.zip
various cleanup, more scoping tweaks, ast tweaks
Diffstat (limited to 'test/ast.py')
-rw-r--r--test/ast.py15
1 files changed, 14 insertions, 1 deletions
diff --git a/test/ast.py b/test/ast.py
index f418d61..5a7da59 100644
--- a/test/ast.py
+++ b/test/ast.py
@@ -24,7 +24,7 @@ print "hello world, ", a, b
print "Another expr", c
"""
parsed = ast.PythonCode(code, 0, 0)
- assert parsed.declared_identifiers == util.Set(['a','b','c', 'g', 'h', 'i', 'u', 'k', 'j', 'gh', 'lar'])
+ assert parsed.declared_identifiers == util.Set(['a','b','c', 'g', 'h', 'i', 'u', 'k', 'j', 'gh', 'lar', 'x'])
assert parsed.undeclared_identifiers == util.Set(['x', 'q', 'foo', 'gah', 'blah'])
parsed = ast.PythonCode("x + 5 * (y-z)", 0, 0)
@@ -45,6 +45,19 @@ for x in data:
assert parsed.undeclared_identifiers == util.Set(['get_data'])
assert parsed.declared_identifiers == util.Set(['result', 'data', 'x', 'hoho', 'foobar', 'foo', 'yaya'])
+ def test_locate_identifiers_3(self):
+ """test that combination assignment/expressions of the same identifier log the ident as 'undeclared'"""
+ code = """
+x = x + 5
+for y in range(1, y):
+ print "hi"
+[z for z in range(1, z)]
+(q for q in range (1, q))
+"""
+ parsed = ast.PythonCode(code, 0, 0)
+ print parsed.undeclared_identifiers
+ assert parsed.undeclared_identifiers == util.Set(['x', 'y', 'z', 'q'])
+
def test_no_global_imports(self):
code = """
from foo import *