<s> from phply import phplex <EOL> from phply . phpparse import parser <EOL> from phply . phpast import * <EOL> import nose . tools <EOL> import pprint <EOL> def eq_ast ( input , expected , filename = None ) : <EOL> lexer = phplex . lexer . clone ( ) <EOL> lexer . filename = filename <EOL> output = parser . parse ( input , lexer = lexer ) <EOL> resolve_magic_constants ( output ) <EOL> print '<STR_LIT>' <EOL> pprint . pprint ( output ) <EOL> print <EOL> print '<STR_LIT>' <EOL> for out , exp in zip ( output , expected ) : <EOL> print '<STR_LIT>' , out , '<STR_LIT>' , exp <EOL> nose . tools . eq_ ( out , exp ) <EOL> assert len ( output ) == len ( expected ) , '<STR_LIT>' % ( len ( output ) , len ( expected ) ) <EOL> def test_inline_html ( ) : <EOL> input = '<STR_LIT>' <EOL> expected = [ InlineHTML ( '<STR_LIT>' ) , InlineHTML ( '<STR_LIT>' ) ] <EOL> eq_ast ( input , expected ) <EOL> def test_echo ( ) : <EOL> input = '<STR_LIT>' <EOL> expected = [ Echo ( [ "<STR_LIT>" ] ) ] <EOL> eq_ast ( input , expected ) <EOL> def test_open_tag_with_echo ( ) : <EOL> input = '<STR_LIT>' <EOL> expected = [ <EOL> Echo ( [ "<STR_LIT>" ] ) , <EOL> Echo ( [ "<STR_LIT:test>" ] ) , <EOL> Constant ( '<STR_LIT>' ) , <EOL> ] <EOL> eq_ast ( input , expected ) <EOL> def test_exit ( ) : <EOL> input = '<STR_LIT>' <EOL> expected = [ <EOL> Exit ( None ) , Exit ( None ) , Exit ( <NUM_LIT> ) , <EOL> Exit ( None ) , Exit ( None ) , Exit ( <NUM_LIT> ) , <EOL> ] <EOL> eq_ast ( input , expected ) <EOL> def test_isset ( ) : <EOL> input = r"""<STR_LIT>""" <EOL> expected = [ <EOL> IsSet ( [ Variable ( '<STR_LIT>' ) ] ) , <EOL> IsSet ( [ ObjectProperty ( Variable ( '<STR_LIT>' ) , '<STR_LIT:c>' ) ] ) , <EOL> IsSet ( [ ArrayOffset ( Variable ( '<STR_LIT>' ) , '<STR_LIT:e>' ) ] ) , <EOL> IsSet ( [ Variable ( '<STR_LIT>' ) , Variable ( '<STR_LIT>' ) ] ) , <EOL> ] <EOL> eq_ast ( input , expected ) <EOL> def test_namespace_names ( ) : <EOL> input = r"""<STR_LIT>""" <EOL> expected = [ <EOL> Constant ( r'<STR_LIT:foo>' ) , <EOL> Constant ( r'<STR_LIT>' ) , <EOL> Constant ( r'<STR_LIT>' ) , <EOL> Constant ( r'<STR_LIT>' ) , <EOL> Constant ( r'<STR_LIT>' ) , <EOL> Constant ( r'<STR_LIT>' ) , <EOL> ] <EOL> eq_ast ( input , expected ) <EOL> def test_unary_ops ( ) : <EOL> input = r"""<STR_LIT>""" <EOL> expected = [ <EOL> Assignment ( Variable ( '<STR_LIT>' ) , UnaryOp ( '<STR_LIT:->' , <NUM_LIT:5> ) , False ) , <EOL> Assignment ( Variable ( '<STR_LIT>' ) , UnaryOp ( '<STR_LIT:+>' , <NUM_LIT:6> ) , False ) , <EOL> Assignment ( Variable ( '<STR_LIT>' ) , UnaryOp ( '<STR_LIT:!>' , Variable ( '<STR_LIT>' ) ) , False ) , <EOL> Assignment ( Variable ( '<STR_LIT>' ) , UnaryOp ( '<STR_LIT>' , Variable ( '<STR_LIT>' ) ) , False ) , <EOL> ] <EOL> eq_ast ( input , expected ) <EOL> def test_assignment_ops ( ) : <EOL> input = r"""<STR_LIT>""" <EOL> expected = [ <EOL> AssignOp ( '<STR_LIT>' , Variable ( '<STR_LIT>' ) , <NUM_LIT:5> ) , <EOL> AssignOp ( '<STR_LIT>' , Variable ( '<STR_LIT>' ) , <NUM_LIT:6> ) , <EOL> AssignOp ( '<STR_LIT>' , Variable ( '<STR_LIT>' ) , Variable ( '<STR_LIT>' ) ) , <EOL> AssignOp ( '<STR_LIT>' , Variable ( '<STR_LIT>' ) , Variable ( '<STR_LIT>' ) ) , <EOL> ] <EOL> eq_ast ( input , expected ) <EOL> def test_object_properties ( ) : <EOL> input = r"""<STR_LIT>""" <EOL> expected = [ <EOL> ObjectProperty ( Variable ( '<STR_LIT>' ) , '<STR_LIT>' ) , <EOL> ObjectProperty ( Variable ( '<STR_LIT>' ) , '<STR_LIT>' ) , <EOL> ObjectProperty ( Variable ( '<STR_LIT>' ) , Variable ( '<STR_LIT>' ) ) , <EOL> ObjectProperty ( ObjectProperty ( Variable ( '<STR_LIT>' ) , Variable ( '<STR_LIT>' ) ) , <EOL> '<STR_LIT>' ) , <EOL> ObjectProperty ( ObjectProperty ( Variable ( '<STR_LIT>' ) , Variable ( '<STR_LIT>' ) ) , <EOL> Variable ( '<STR_LIT>' ) ) , <EOL> ] <EOL> eq_ast ( input , expected ) <EOL> def test_string_unescape ( ) : <EOL> input = r"""<STR_LIT>""" <EOL> expected = [ <EOL> r"<STR_LIT>" , <EOL> "<STR_LIT>" , <EOL> ] <EOL> eq_ast ( input , expected ) <EOL> def test_string_offset_lookups ( ) : <EOL> input = r"""<STR_LIT>""" <EOL> expected = [ <EOL> ArrayOffset ( Variable ( '<STR_LIT>' ) , '<STR_LIT>' ) , <EOL> ArrayOffset ( Variable ( '<STR_LIT>' ) , <NUM_LIT> ) , <EOL> ArrayOffset ( Variable ( '<STR_LIT>' ) , Variable ( '<STR_LIT>' ) ) , <EOL> ArrayOffset ( Variable ( '<STR_LIT>' ) , '<STR_LIT>' ) , <EOL> BinaryOp ( '<STR_LIT:.>' , ArrayOffset ( Variable ( '<STR_LIT>' ) , '<STR_LIT>' ) , '<STR_LIT>' ) , <EOL> BinaryOp ( '<STR_LIT:.>' , ArrayOffset ( Variable ( '<STR_LIT>' ) , '<STR_LIT:to>' ) , Variable ( '<STR_LIT>' ) ) , <EOL> ObjectProperty ( Variable ( '<STR_LIT>' ) , '<STR_LIT>' ) , <EOL> BinaryOp ( '<STR_LIT:.>' , ObjectProperty ( Variable ( '<STR_LIT>' ) , '<STR_LIT>' ) , '<STR_LIT>' ) , <EOL> BinaryOp ( '<STR_LIT:.>' , ObjectProperty ( Variable ( '<STR_LIT>' ) , '<STR_LIT:object>' ) , Variable ( '<STR_LIT>' ) ) , <EOL> BinaryOp ( '<STR_LIT:.>' , BinaryOp ( '<STR_LIT:.>' , Variable ( '<STR_LIT>' ) , '<STR_LIT>' ) , Variable ( '<STR_LIT>' ) ) , <EOL> '<STR_LIT>' , <EOL> '<STR_LIT>' , <EOL> '<STR_LIT>' , <EOL> ] <EOL> eq_ast ( input , expected ) <EOL> def test_string_curly_dollar_expressions ( ) : <EOL> input = r"""<STR_LIT>""" <EOL> expected = [ <EOL> BinaryOp ( '<STR_LIT:.>' , BinaryOp ( '<STR_LIT:.>' , '<STR_LIT:a>' , Variable ( '<STR_LIT>' ) ) , '<STR_LIT:b>' ) , <EOL> BinaryOp ( '<STR_LIT:.>' , BinaryOp ( '<STR_LIT:.>' , '<STR_LIT:c>' , Variable ( '<STR_LIT>' ) ) , '<STR_LIT:d>' ) , <EOL> BinaryOp ( '<STR_LIT:.>' , BinaryOp ( '<STR_LIT:.>' , '<STR_LIT:e>' , Variable ( '<STR_LIT>' ) ) , '<STR_LIT:f>' ) , <EOL> ArrayOffset ( ArrayOffset ( Variable ( '<STR_LIT>' ) , <NUM_LIT:0> ) , <NUM_LIT:1> ) , <EOL> ArrayOffset ( ArrayOffset ( Variable ( '<STR_LIT>' ) , '<STR_LIT>' ) , <NUM_LIT:3> ) , <EOL> ObjectProperty ( ArrayOffset ( ObjectProperty ( Variable ( '<STR_LIT>' ) , '<STR_LIT>' ) , <NUM_LIT:4> ) , '<STR_LIT>' ) , <EOL> Variable ( Variable ( '<STR_LIT>' ) ) , <EOL> Variable ( FunctionCall ( '<STR_LIT>' , [ ] ) ) , <EOL> Variable ( MethodCall ( Variable ( '<STR_LIT>' ) , '<STR_LIT>' , [ ] ) ) , <EOL> ObjectProperty ( Variable ( '<STR_LIT>' ) , Variable ( '<STR_LIT>' ) ) , <EOL> ObjectProperty ( Variable ( '<STR_LIT>' ) , ArrayOffset ( Variable ( '<STR_LIT>' ) , <NUM_LIT:1> ) ) , <EOL> Variable ( StaticProperty ( '<STR_LIT>' , '<STR_LIT>' ) ) , <EOL> Variable ( StaticProperty ( '<STR_LIT>' , Variable ( '<STR_LIT>' ) ) ) , <EOL> ] <EOL> eq_ast ( input , expected ) <EOL> def test_heredoc ( ) : <EOL> input = r"""<STR_LIT>""" <EOL> expected = [ <EOL> Echo ( [ BinaryOp ( '<STR_LIT:.>' , <EOL> BinaryOp ( '<STR_LIT:.>' , <EOL> BinaryOp ( '<STR_LIT:.>' , <EOL> BinaryOp ( '<STR_LIT:.>' , <EOL> BinaryOp ( '<STR_LIT:.>' , <EOL> BinaryOp ( '<STR_LIT:.>' , <EOL> BinaryOp ( '<STR_LIT:.>' , <EOL> '<STR_LIT>' , <EOL> '<STR_LIT>' ) , <EOL> Variable ( '<STR_LIT>' ) ) , <EOL> '<STR_LIT>' ) , <EOL> ObjectProperty ( Variable ( '<STR_LIT>' ) , <EOL> '<STR_LIT>' ) ) , <EOL> '<STR_LIT>' ) , <EOL> '<STR_LIT>' ) , <EOL> '<STR_LIT>' ) ] ) , <EOL> ] <EOL> eq_ast ( input , expected ) <EOL> def test_function_calls ( ) : <EOL> input = r"""<STR_LIT>""" <EOL> expected = [ <EOL> FunctionCall ( '<STR_LIT:f>' , [ ] ) , <EOL> FunctionCall ( '<STR_LIT>' , <EOL> [ Parameter ( Variable ( '<STR_LIT>' ) , False ) , <EOL> Parameter ( Variable ( '<STR_LIT>' ) , True ) , <EOL> Parameter ( BinaryOp ( '<STR_LIT:+>' , <NUM_LIT:3> , <NUM_LIT:4> ) , False ) ] ) , <EOL> FunctionCall ( '<STR_LIT>' , [ ] ) , <EOL> FunctionCall ( '<STR_LIT>' , [ ] ) , <EOL> FunctionCall ( '<STR_LIT>' , [ ] ) , <EOL> ] <EOL> eq_ast ( input , expected ) <EOL> def test_method_calls ( ) : <EOL> input = r"""<STR_LIT>""" <EOL> expected = [ <EOL> MethodCall ( Variable ( '<STR_LIT>' ) , '<STR_LIT>' , <EOL> [ Parameter ( Variable ( '<STR_LIT>' ) , False ) , <EOL> Parameter ( Variable ( '<STR_LIT>' ) , True ) , <EOL> Parameter ( BinaryOp ( '<STR_LIT:.>' , Variable ( '<STR_LIT>' ) , Variable ( '<STR_LIT>' ) ) , False ) ] ) , <EOL> MethodCall ( MethodCall ( Variable ( '<STR_LIT>' ) , <EOL> '<STR_LIT>' , [ Parameter ( Variable ( '<STR_LIT>' ) , False ) ] ) , <EOL> '<STR_LIT>' , [ Parameter ( Variable ( '<STR_LIT>' ) , True ) ] ) , <EOL> ] <EOL> eq_ast ( input , expected ) <EOL> def test_if ( ) : <EOL> input = r"""<STR_LIT>""" <EOL> expected = [ <EOL> If ( <NUM_LIT:1> , <EOL> If ( <NUM_LIT:2> , <EOL> Echo ( [ <NUM_LIT:3> ] ) , <EOL> [ ] , <EOL> Else ( Echo ( [ <NUM_LIT:4> ] ) ) ) , <EOL> [ ] , <EOL> Else ( Echo ( [ <NUM_LIT:5> ] ) ) ) , <EOL> If ( BinaryOp ( '<STR_LIT:<>' , Variable ( '<STR_LIT>' ) , Variable ( '<STR_LIT>' ) ) , <EOL> Block ( [ Return ( UnaryOp ( '<STR_LIT:->' , <NUM_LIT:1> ) ) ] ) , <EOL> [ ElseIf ( BinaryOp ( '<STR_LIT:>>' , Variable ( '<STR_LIT>' ) , Variable ( '<STR_LIT>' ) ) , <EOL> Block ( [ Return ( <NUM_LIT:1> ) ] ) ) , <EOL> ElseIf ( BinaryOp ( '<STR_LIT>' , Variable ( '<STR_LIT>' ) , Variable ( '<STR_LIT>' ) ) , <EOL> Block ( [ Return ( <NUM_LIT:0> ) ] ) ) ] , <EOL> Else ( Block ( [ Return ( '<STR_LIT>' ) ] ) ) ) , <EOL> If ( Variable ( '<STR_LIT>' ) , <EOL> Block ( [ Echo ( [ '<STR_LIT:a>' ] ) ] ) , <EOL> [ ElseIf ( Variable ( '<STR_LIT>' ) , <EOL> Block ( [ Echo ( [ '<STR_LIT:b>' ] ) ] ) ) ] , <EOL> Else ( Block ( [ Echo ( [ '<STR_LIT:c>' ] ) ] ) ) ) , <EOL> ] <EOL> eq_ast ( input , expected ) <EOL> def test_foreach ( ) : <EOL> input = r"""<STR_LIT>""" <EOL> expected = [ <EOL> Foreach ( Variable ( '<STR_LIT>' ) , None , ForeachVariable ( '<STR_LIT>' , False ) , <EOL> Block ( [ Echo ( [ Variable ( '<STR_LIT>' ) ] ) ] ) ) , <EOL> Foreach ( Variable ( '<STR_LIT>' ) , <EOL> ForeachVariable ( '<STR_LIT>' , False ) , <EOL> ForeachVariable ( '<STR_LIT>' , False ) , <EOL> Block ( [ Echo ( [ BinaryOp ( '<STR_LIT:.>' , <EOL> BinaryOp ( '<STR_LIT:.>' , Variable ( '<STR_LIT>' ) , '<STR_LIT>' ) , <EOL> Variable ( '<STR_LIT>' ) ) ] ) ] ) ) , <EOL> Foreach ( FunctionCall ( '<STR_LIT>' , [ Parameter ( Variable ( '<STR_LIT>' ) , <EOL> False ) ] ) , <EOL> None , ForeachVariable ( '<STR_LIT>' , True ) , <EOL> PostIncDecOp ( '<STR_LIT>' , Variable ( '<STR_LIT>' ) ) ) , <EOL> Foreach ( Variable ( '<STR_LIT>' ) , <EOL> ForeachVariable ( '<STR_LIT>' , True ) , <EOL> ForeachVariable ( '<STR_LIT>' , True ) , <EOL> Block ( [ FunctionCall ( '<STR_LIT>' , [ ] ) , <EOL> FunctionCall ( '<STR_LIT>' , [ ] ) ] ) ) , <EOL> ] <EOL> eq_ast ( input , expected ) <EOL> def test_global_variables ( ) : <EOL> input = r"""<STR_LIT>""" <EOL> expected = [ <EOL> Global ( [ Variable ( '<STR_LIT>' ) , Variable ( '<STR_LIT>' ) ] ) , <EOL> Global ( [ Variable ( Variable ( '<STR_LIT>' ) ) ] ) , <EOL> Global ( [ Variable ( Variable ( '<STR_LIT>' ) ) ] ) , <EOL> Global ( [ Variable ( ObjectProperty ( Variable ( '<STR_LIT>' ) , '<STR_LIT>' ) ) ] ) , <EOL> ] <EOL> eq_ast ( input , expected ) <EOL> def test_variable_variables ( ) : <EOL> input = r"""<STR_LIT>""" <EOL> expected = [ <EOL> Assignment ( Variable ( Variable ( '<STR_LIT>' ) ) , Variable ( Variable ( '<STR_LIT>' ) ) , False ) , <EOL> Assignment ( Variable ( Variable ( '<STR_LIT>' ) ) , Variable ( Variable ( '<STR_LIT>' ) ) , True ) , <EOL> Assignment ( Variable ( Variable ( '<STR_LIT>' ) ) , Variable ( Variable ( '<STR_LIT>' ) ) , False ) , <EOL> Assignment ( Variable ( Variable ( '<STR_LIT>' ) ) , Variable ( Variable ( '<STR_LIT>' ) ) , True ) , <EOL> ObjectProperty ( Variable ( Variable ( '<STR_LIT>' ) ) , '<STR_LIT:b>' ) , <EOL> Variable ( Variable ( Variable ( '<STR_LIT>' ) ) ) , <EOL> ] <EOL> eq_ast ( input , expected ) <EOL> def test_classes ( ) : <EOL> input = r"""<STR_LIT>""" <EOL> expected = [ <EOL> Class ( '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , [ '<STR_LIT>' , '<STR_LIT>' ] , [ <EOL> ClassConstants ( [ ClassConstant ( '<STR_LIT>' , '<STR_LIT>' ) , <EOL> ClassConstant ( '<STR_LIT>' , '<STR_LIT>' ) ] ) , <EOL> ClassConstants ( [ ClassConstant ( '<STR_LIT>' , '<STR_LIT>' ) ] ) , <EOL> ClassVariables ( [ ] , [ ClassVariable ( '<STR_LIT>' , <NUM_LIT> ) , <EOL> ClassVariable ( '<STR_LIT>' , None ) ] ) , <EOL> ClassVariables ( [ '<STR_LIT>' , '<STR_LIT>' ] , <EOL> [ ClassVariable ( '<STR_LIT>' , None ) ] ) , <EOL> Method ( '<STR_LIT>' , <EOL> [ '<STR_LIT>' ] , <EOL> [ FormalParameter ( '<STR_LIT>' , None , False , None ) , <EOL> FormalParameter ( '<STR_LIT>' , None , False , None ) ] , <EOL> [ Return ( BinaryOp ( '<STR_LIT:.>' , Variable ( '<STR_LIT>' ) , Variable ( '<STR_LIT>' ) ) ) ] , <EOL> False ) , <EOL> ] ) , <EOL> Class ( '<STR_LIT>' , None , None , [ ] , [ ] ) , <EOL> ] <EOL> eq_ast ( input , expected ) <EOL> def test_new ( ) : <EOL> input = r"""<STR_LIT>""" <EOL> expected = [ <EOL> New ( '<STR_LIT>' , [ ] ) , <EOL> New ( '<STR_LIT>' , [ ] ) , <EOL> New ( '<STR_LIT>' , [ Parameter ( <NUM_LIT:1> , False ) , <EOL> Parameter ( <NUM_LIT:2> , False ) , <EOL> Parameter ( <NUM_LIT:3> , False ) ] ) , <EOL> Assignment ( Variable ( '<STR_LIT>' ) , New ( '<STR_LIT>' , [ ] ) , True ) , <EOL> New ( '<STR_LIT>' , [ ] ) , <EOL> New ( '<STR_LIT>' , [ ] ) , <EOL> New ( '<STR_LIT>' , [ ] ) , <EOL> ] <EOL> eq_ast ( input , expected ) <EOL> def test_exceptions ( ) : <EOL> input = r"""<STR_LIT>""" <EOL> expected = [ <EOL> Try ( [ <EOL> Assignment ( Variable ( '<STR_LIT>' ) , <EOL> BinaryOp ( '<STR_LIT:+>' , Variable ( '<STR_LIT>' ) , Variable ( '<STR_LIT>' ) ) , <EOL> False ) , <EOL> Throw ( New ( '<STR_LIT>' , [ Parameter ( Variable ( '<STR_LIT>' ) , False ) ] ) ) , <EOL> ] , [ <EOL> Catch ( '<STR_LIT>' , Variable ( '<STR_LIT>' ) , [ <EOL> Echo ( [ BinaryOp ( '<STR_LIT:.>' , '<STR_LIT>' , Variable ( '<STR_LIT>' ) ) ] ) <EOL> ] ) , <EOL> Catch ( '<STR_LIT>' , Variable ( '<STR_LIT>' ) , [ <EOL> Echo ( [ BinaryOp ( '<STR_LIT:.>' , '<STR_LIT>' , Variable ( '<STR_LIT>' ) ) ] ) <EOL> ] ) , <EOL> Catch ( '<STR_LIT>' , Variable ( '<STR_LIT>' ) , [ <EOL> Echo ( [ BinaryOp ( '<STR_LIT:.>' , '<STR_LIT>' , Variable ( '<STR_LIT>' ) ) ] ) <EOL> ] ) , <EOL> Catch ( '<STR_LIT>' , Variable ( '<STR_LIT>' ) , [ <EOL> Echo ( [ '<STR_LIT>' ] ) , <EOL> ] ) , <EOL> ] ) <EOL> ] <EOL> eq_ast ( input , expected ) <EOL> def test_declare ( ) : <EOL> input = r"""<STR_LIT>""" <EOL> expected = [ <EOL> Declare ( [ Directive ( '<STR_LIT>' , <NUM_LIT:1> ) ] , Block ( [ <EOL> Echo ( [ '<STR_LIT>' ] ) , <EOL> ] ) ) , <EOL> Declare ( [ Directive ( '<STR_LIT>' , <NUM_LIT:2> ) ] , None ) , <EOL> Declare ( [ Directive ( '<STR_LIT>' , <NUM_LIT:3> ) ] , Block ( [ <EOL> Echo ( [ '<STR_LIT>' ] ) , <EOL> ] ) ) , <EOL> ] <EOL> eq_ast ( input , expected ) <EOL> def test_instanceof ( ) : <EOL> input = r"""<STR_LIT>""" <EOL> expected = [ <EOL> If ( BinaryOp ( '<STR_LIT>' , Variable ( '<STR_LIT>' ) , Constant ( '<STR_LIT>' ) ) , <EOL> Block ( [ Echo ( [ '<STR_LIT>' ] ) ] ) , [ ] , None ) , <EOL> BinaryOp ( '<STR_LIT>' , Variable ( '<STR_LIT>' ) , Variable ( '<STR_LIT>' ) ) , <EOL> ] <EOL> eq_ast ( input , expected ) <EOL> def test_static_members ( ) : <EOL> input = r"""<STR_LIT>""" <EOL> expected = [ <EOL> StaticProperty ( '<STR_LIT>' , '<STR_LIT>' ) , <EOL> StaticProperty ( '<STR_LIT>' , Variable ( '<STR_LIT>' ) ) , <EOL> StaticMethodCall ( '<STR_LIT>' , '<STR_LIT>' , [ ] ) , <EOL> StaticMethodCall ( '<STR_LIT>' , Variable ( '<STR_LIT>' ) , [ ] ) , <EOL> StaticProperty ( '<STR_LIT>' , '<STR_LIT>' ) , <EOL> StaticProperty ( '<STR_LIT>' , Variable ( '<STR_LIT>' ) ) , <EOL> StaticMethodCall ( '<STR_LIT>' , '<STR_LIT>' , [ ] ) , <EOL> ] <EOL> eq_ast ( input , expected ) <EOL> def test_casts ( ) : <EOL> input = r"""<STR_LIT>""" <EOL> expected = [ <EOL> Cast ( '<STR_LIT>' , Variable ( '<STR_LIT>' ) ) , <EOL> Cast ( '<STR_LIT:bool>' , Variable ( '<STR_LIT>' ) ) , <EOL> Cast ( '<STR_LIT:bool>' , Variable ( '<STR_LIT>' ) ) , <EOL> Cast ( '<STR_LIT>' , Variable ( '<STR_LIT>' ) ) , <EOL> Cast ( '<STR_LIT>' , Variable ( '<STR_LIT>' ) ) , <EOL> Cast ( '<STR_LIT>' , Variable ( '<STR_LIT>' ) ) , <EOL> Cast ( '<STR_LIT:int>' , Variable ( '<STR_LIT>' ) ) , <EOL> Cast ( '<STR_LIT:int>' , Variable ( '<STR_LIT>' ) ) , <EOL> Cast ( '<STR_LIT:string>' , Variable ( '<STR_LIT>' ) ) , <EOL> Cast ( '<STR_LIT>' , Variable ( '<STR_LIT>' ) ) , <EOL> ] <EOL> eq_ast ( input , expected ) <EOL> def test_namespaces ( ) : <EOL> input = r"""<STR_LIT>""" <EOL> expected = [ <EOL> Namespace ( '<STR_LIT>' , [ ] ) , <EOL> Namespace ( '<STR_LIT>' , [ FunctionCall ( '<STR_LIT:foo>' , [ ] ) , <EOL> FunctionCall ( '<STR_LIT:bar>' , [ ] ) ] ) , <EOL> Namespace ( None , [ FunctionCall ( '<STR_LIT:foo>' , [ ] ) , <EOL> FunctionCall ( '<STR_LIT:bar>' , [ ] ) ] ) , <EOL> ] <EOL> eq_ast ( input , expected ) <EOL> def test_use_declarations ( ) : <EOL> input = r"""<STR_LIT>""" <EOL> expected = [ <EOL> UseDeclarations ( [ UseDeclaration ( '<STR_LIT>' , None ) ] ) , <EOL> UseDeclarations ( [ UseDeclaration ( '<STR_LIT>' , None ) ] ) , <EOL> UseDeclarations ( [ UseDeclaration ( '<STR_LIT>' , None ) ] ) , <EOL> UseDeclarations ( [ UseDeclaration ( '<STR_LIT>' , '<STR_LIT:foo>' ) ] ) , <EOL> UseDeclarations ( [ UseDeclaration ( '<STR_LIT:a>' , None ) , <EOL> UseDeclaration ( '<STR_LIT:b>' , None ) ] ) , <EOL> UseDeclarations ( [ UseDeclaration ( '<STR_LIT:a>' , '<STR_LIT:b>' ) , <EOL> UseDeclaration ( '<STR_LIT>' , '<STR_LIT:f>' ) ] ) , <EOL> ] <EOL> eq_ast ( input , expected ) <EOL> def test_constant_declarations ( ) : <EOL> input = r"""<STR_LIT>""" <EOL> expected = [ <EOL> ConstantDeclarations ( [ ConstantDeclaration ( '<STR_LIT:foo>' , <NUM_LIT> ) ] ) , <EOL> ConstantDeclarations ( [ ConstantDeclaration ( '<STR_LIT:bar>' , '<STR_LIT>' ) , <EOL> ConstantDeclaration ( '<STR_LIT>' , Constant ( '<STR_LIT>' ) ) ] ) , <EOL> ConstantDeclarations ( [ ConstantDeclaration ( '<STR_LIT>' , Constant ( '<STR_LIT>' ) ) ] ) , <EOL> ConstantDeclarations ( [ ConstantDeclaration ( '<STR_LIT>' , '<STR_LIT>' ) ] ) , <EOL> ConstantDeclarations ( [ ConstantDeclaration ( '<STR_LIT>' , '<STR_LIT>' ) ] ) , <EOL> ] <EOL> eq_ast ( input , expected ) <EOL> def test_closures ( ) : <EOL> input = r"""<STR_LIT>""" <EOL> expected = [ <EOL> Assignment ( Variable ( '<STR_LIT>' ) , <EOL> Closure ( [ FormalParameter ( '<STR_LIT>' , None , False , None ) ] , <EOL> [ ] , <EOL> [ FunctionCall ( '<STR_LIT>' , <EOL> [ Parameter ( '<STR_LIT>' , False ) , <EOL> Parameter ( Variable ( '<STR_LIT>' ) , False ) ] ) ] , <EOL> False ) , <EOL> False ) , <EOL> FunctionCall ( Variable ( '<STR_LIT>' ) , [ Parameter ( '<STR_LIT>' , False ) ] ) , <EOL> Assignment ( Variable ( '<STR_LIT>' ) , <EOL> Closure ( [ FormalParameter ( '<STR_LIT>' , None , False , None ) , <EOL> FormalParameter ( '<STR_LIT>' , None , True , None ) ] , <EOL> [ LexicalVariable ( '<STR_LIT>' , False ) , <EOL> LexicalVariable ( '<STR_LIT>' , True ) ] , <EOL> [ ] , <EOL> True ) , <EOL> False ) , <EOL> ] <EOL> eq_ast ( input , expected ) <EOL> def test_magic_constants ( ) : <EOL> input = r"""<STR_LIT>""" <EOL> expected = [ <EOL> Namespace ( '<STR_LIT>' , [ ] ) , <EOL> Function ( '<STR_LIT:p>' , [ FormalParameter ( '<STR_LIT>' , None , False , None ) ] , [ <EOL> Echo ( [ BinaryOp ( '<STR_LIT:.>' , BinaryOp ( '<STR_LIT:.>' , BinaryOp ( '<STR_LIT:.>' , <EOL> MagicConstant ( '<STR_LIT>' , '<STR_LIT>' ) , '<STR_LIT>' ) , <EOL> Variable ( '<STR_LIT>' ) ) , '<STR_LIT:\n>' ) ] ) <EOL> ] , False ) , <EOL> Class ( '<STR_LIT>' , None , None , [ ] , <EOL> [ Method ( '<STR_LIT>' , [ ] , [ ] , <EOL> [ FunctionCall ( '<STR_LIT:p>' , [ Parameter ( MagicConstant ( '<STR_LIT>' , <NUM_LIT:10> ) , False ) ] ) , <EOL> FunctionCall ( '<STR_LIT:p>' , [ Parameter ( MagicConstant ( '<STR_LIT>' , '<STR_LIT>' ) , False ) ] ) , <EOL> FunctionCall ( '<STR_LIT:p>' , [ Parameter ( MagicConstant ( '<STR_LIT>' , '<STR_LIT>' ) , False ) ] ) , <EOL> FunctionCall ( '<STR_LIT:p>' , [ Parameter ( MagicConstant ( '<STR_LIT>' , '<STR_LIT>' ) , False ) ] ) , <EOL> FunctionCall ( '<STR_LIT:p>' , [ Parameter ( MagicConstant ( '<STR_LIT>' , '<STR_LIT>' ) , False ) ] ) , <EOL> FunctionCall ( '<STR_LIT:p>' , [ Parameter ( MagicConstant ( '<STR_LIT>' , '<STR_LIT>' ) , False ) ] ) ] , False ) ] ) , <EOL> New ( '<STR_LIT>' , [ ] ) , <EOL> ] <EOL> eq_ast ( input , expected , filename = '<STR_LIT>' ) <EOL> def test_type_hinting ( ) : <EOL> input = r"""<STR_LIT>""" ; <EOL> expected = [ <EOL> Function ( '<STR_LIT:foo>' , <EOL> [ FormalParameter ( '<STR_LIT>' , None , False , '<STR_LIT>' ) , <EOL> FormalParameter ( '<STR_LIT>' , <NUM_LIT:1> , False , '<STR_LIT>' ) , <EOL> FormalParameter ( '<STR_LIT>' , None , True , '<STR_LIT>' ) , <EOL> FormalParameter ( '<STR_LIT>' , <NUM_LIT:1> , True , '<STR_LIT>' ) ] , <EOL> [ ] , <EOL> False ) ] <EOL> eq_ast ( input , expected ) </s>
