Skip to content

Commit

Permalink
Fix tests, rename Use to UseDeclarations
Browse files Browse the repository at this point in the history
  • Loading branch information
ramen committed Oct 10, 2010
1 parent 7b2d43b commit 1025194
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 12 deletions.
2 changes: 1 addition & 1 deletion phply/phpast.py
Expand Up @@ -121,5 +121,5 @@ def node(name, fields):
Case = node('Case', ['expr', 'nodes'])
Default = node('Default', ['nodes'])
Namespace = node('Namespace', ['name', 'nodes'])
Use = node('Use', ['declarations'])
UseDeclarations = node('UseDeclarations', ['nodes'])
UseDeclaration = node('UseDeclaration', ['name', 'alias'])
2 changes: 1 addition & 1 deletion phply/phpparse.py
Expand Up @@ -78,7 +78,7 @@ def p_top_statement_namespace(p):

def p_top_statement_use(p):
'top_statement : USE use_declarations SEMI'
p[0] = ast.Use(p[2], lineno=p.lineno(1))
p[0] = ast.UseDeclarations(p[2], lineno=p.lineno(1))

def p_use_declarations(p):
'''use_declarations : use_declarations COMMA use_declaration
Expand Down
22 changes: 12 additions & 10 deletions tests/test_parser.py
Expand Up @@ -524,14 +524,15 @@ def test_namespaces():
foo();
bar();
}
"""
?>"""
expected = [
Namespace('my\\name', []),
Namespace('my\\name', [FunctionCall('foo', []),
FunctionCall('bar', [])]),
Namespace(None, [FunctionCall('foo', []),
FunctionCall('bar', [])]),
]
eq_ast(input, expected)

def test_use_declarations():
input = r"""<?
Expand All @@ -541,14 +542,15 @@ def test_use_declarations():
use my\name as foo;
use a, b;
use a as b, \c\d\e as f;
"""
?>"""
expected = [
Use([UseDeclaration('me', None)]),
Use([UseDeclaration('\\me', None)]),
Use([UseDeclaration('\\me\\please', None)]),
Use([UseDeclaration('my\\name', 'foo')]),
Use([UseDeclaration('a', None),
UseDeclaration('b', None)]),
Use([UseDeclaration('a', 'b'),
UseDeclaration('\\c\\d\\e', 'f')]),
UseDeclarations([UseDeclaration('me', None)]),
UseDeclarations([UseDeclaration('\\me', None)]),
UseDeclarations([UseDeclaration('\\me\\please', None)]),
UseDeclarations([UseDeclaration('my\\name', 'foo')]),
UseDeclarations([UseDeclaration('a', None),
UseDeclaration('b', None)]),
UseDeclarations([UseDeclaration('a', 'b'),
UseDeclaration('\\c\\d\\e', 'f')]),
]
eq_ast(input, expected)

0 comments on commit 1025194

Please sign in to comment.