Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Fix tests, rename Use to UseDeclarations

  • Loading branch information...
commit 10251946841de1efa31cb160ad404678044e9372 1 parent 7b2d43b
@ramen authored
Showing with 14 additions and 12 deletions.
  1. +1 −1  phply/phpast.py
  2. +1 −1  phply/phpparse.py
  3. +12 −10 tests/test_parser.py
View
2  phply/phpast.py
@@ -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'])
View
2  phply/phpparse.py
@@ -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
View
22 tests/test_parser.py
@@ -524,7 +524,7 @@ def test_namespaces():
foo();
bar();
}
- """
+ ?>"""
expected = [
Namespace('my\\name', []),
Namespace('my\\name', [FunctionCall('foo', []),
@@ -532,6 +532,7 @@ def test_namespaces():
Namespace(None, [FunctionCall('foo', []),
FunctionCall('bar', [])]),
]
+ eq_ast(input, expected)
def test_use_declarations():
input = r"""<?
@@ -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)
Please sign in to comment.
Something went wrong with that request. Please try again.