create Root node
This commit is contained in:
parent
d1b0cebf9a
commit
2abe1dfb84
@ -32,7 +32,7 @@ func assertEqual(t *testing.T, expected interface{}, actual interface{}) {
|
|||||||
func TestReference(t *testing.T) {
|
func TestReference(t *testing.T) {
|
||||||
src := `<? $a =& $b;`
|
src := `<? $a =& $b;`
|
||||||
|
|
||||||
expected := &stmt.StmtList{
|
expected := &node.Root{
|
||||||
Stmts: []node.Node{
|
Stmts: []node.Node{
|
||||||
&stmt.Expression{
|
&stmt.Expression{
|
||||||
Expr: &assign.Reference{
|
Expr: &assign.Reference{
|
||||||
@ -57,7 +57,7 @@ func TestReference(t *testing.T) {
|
|||||||
func TestReferenceNew(t *testing.T) {
|
func TestReferenceNew(t *testing.T) {
|
||||||
src := `<? $a =& new Foo;`
|
src := `<? $a =& new Foo;`
|
||||||
|
|
||||||
expected := &stmt.StmtList{
|
expected := &node.Root{
|
||||||
Stmts: []node.Node{
|
Stmts: []node.Node{
|
||||||
&stmt.Expression{
|
&stmt.Expression{
|
||||||
Expr: &assign.Reference{
|
Expr: &assign.Reference{
|
||||||
@ -88,7 +88,7 @@ func TestReferenceNew(t *testing.T) {
|
|||||||
func TestReferenceArgs(t *testing.T) {
|
func TestReferenceArgs(t *testing.T) {
|
||||||
src := `<? $a =& new Foo($b);`
|
src := `<? $a =& new Foo($b);`
|
||||||
|
|
||||||
expected := &stmt.StmtList{
|
expected := &node.Root{
|
||||||
Stmts: []node.Node{
|
Stmts: []node.Node{
|
||||||
&stmt.Expression{
|
&stmt.Expression{
|
||||||
Expr: &assign.Reference{
|
Expr: &assign.Reference{
|
||||||
@ -128,7 +128,7 @@ func TestReferenceArgs(t *testing.T) {
|
|||||||
func TestAssign(t *testing.T) {
|
func TestAssign(t *testing.T) {
|
||||||
src := `<? $a = $b;`
|
src := `<? $a = $b;`
|
||||||
|
|
||||||
expected := &stmt.StmtList{
|
expected := &node.Root{
|
||||||
Stmts: []node.Node{
|
Stmts: []node.Node{
|
||||||
&stmt.Expression{
|
&stmt.Expression{
|
||||||
Expr: &assign.Assign{
|
Expr: &assign.Assign{
|
||||||
@ -153,7 +153,7 @@ func TestAssign(t *testing.T) {
|
|||||||
func TestBitwiseAnd(t *testing.T) {
|
func TestBitwiseAnd(t *testing.T) {
|
||||||
src := `<? $a &= $b;`
|
src := `<? $a &= $b;`
|
||||||
|
|
||||||
expected := &stmt.StmtList{
|
expected := &node.Root{
|
||||||
Stmts: []node.Node{
|
Stmts: []node.Node{
|
||||||
&stmt.Expression{
|
&stmt.Expression{
|
||||||
Expr: &assign.BitwiseAnd{
|
Expr: &assign.BitwiseAnd{
|
||||||
@ -178,7 +178,7 @@ func TestBitwiseAnd(t *testing.T) {
|
|||||||
func TestBitwiseOr(t *testing.T) {
|
func TestBitwiseOr(t *testing.T) {
|
||||||
src := `<? $a |= $b;`
|
src := `<? $a |= $b;`
|
||||||
|
|
||||||
expected := &stmt.StmtList{
|
expected := &node.Root{
|
||||||
Stmts: []node.Node{
|
Stmts: []node.Node{
|
||||||
&stmt.Expression{
|
&stmt.Expression{
|
||||||
Expr: &assign.BitwiseOr{
|
Expr: &assign.BitwiseOr{
|
||||||
@ -203,7 +203,7 @@ func TestBitwiseOr(t *testing.T) {
|
|||||||
func TestBitwiseXor(t *testing.T) {
|
func TestBitwiseXor(t *testing.T) {
|
||||||
src := `<? $a ^= $b;`
|
src := `<? $a ^= $b;`
|
||||||
|
|
||||||
expected := &stmt.StmtList{
|
expected := &node.Root{
|
||||||
Stmts: []node.Node{
|
Stmts: []node.Node{
|
||||||
&stmt.Expression{
|
&stmt.Expression{
|
||||||
Expr: &assign.BitwiseXor{
|
Expr: &assign.BitwiseXor{
|
||||||
@ -228,7 +228,7 @@ func TestBitwiseXor(t *testing.T) {
|
|||||||
func TestConcat(t *testing.T) {
|
func TestConcat(t *testing.T) {
|
||||||
src := `<? $a .= $b;`
|
src := `<? $a .= $b;`
|
||||||
|
|
||||||
expected := &stmt.StmtList{
|
expected := &node.Root{
|
||||||
Stmts: []node.Node{
|
Stmts: []node.Node{
|
||||||
&stmt.Expression{
|
&stmt.Expression{
|
||||||
Expr: &assign.Concat{
|
Expr: &assign.Concat{
|
||||||
@ -253,7 +253,7 @@ func TestConcat(t *testing.T) {
|
|||||||
func TestDiv(t *testing.T) {
|
func TestDiv(t *testing.T) {
|
||||||
src := `<? $a /= $b;`
|
src := `<? $a /= $b;`
|
||||||
|
|
||||||
expected := &stmt.StmtList{
|
expected := &node.Root{
|
||||||
Stmts: []node.Node{
|
Stmts: []node.Node{
|
||||||
&stmt.Expression{
|
&stmt.Expression{
|
||||||
Expr: &assign.Div{
|
Expr: &assign.Div{
|
||||||
@ -278,7 +278,7 @@ func TestDiv(t *testing.T) {
|
|||||||
func TestMinus(t *testing.T) {
|
func TestMinus(t *testing.T) {
|
||||||
src := `<? $a -= $b;`
|
src := `<? $a -= $b;`
|
||||||
|
|
||||||
expected := &stmt.StmtList{
|
expected := &node.Root{
|
||||||
Stmts: []node.Node{
|
Stmts: []node.Node{
|
||||||
&stmt.Expression{
|
&stmt.Expression{
|
||||||
Expr: &assign.Minus{
|
Expr: &assign.Minus{
|
||||||
@ -303,7 +303,7 @@ func TestMinus(t *testing.T) {
|
|||||||
func TestMod(t *testing.T) {
|
func TestMod(t *testing.T) {
|
||||||
src := `<? $a %= $b;`
|
src := `<? $a %= $b;`
|
||||||
|
|
||||||
expected := &stmt.StmtList{
|
expected := &node.Root{
|
||||||
Stmts: []node.Node{
|
Stmts: []node.Node{
|
||||||
&stmt.Expression{
|
&stmt.Expression{
|
||||||
Expr: &assign.Mod{
|
Expr: &assign.Mod{
|
||||||
@ -328,7 +328,7 @@ func TestMod(t *testing.T) {
|
|||||||
func TestMul(t *testing.T) {
|
func TestMul(t *testing.T) {
|
||||||
src := `<? $a *= $b;`
|
src := `<? $a *= $b;`
|
||||||
|
|
||||||
expected := &stmt.StmtList{
|
expected := &node.Root{
|
||||||
Stmts: []node.Node{
|
Stmts: []node.Node{
|
||||||
&stmt.Expression{
|
&stmt.Expression{
|
||||||
Expr: &assign.Mul{
|
Expr: &assign.Mul{
|
||||||
@ -353,7 +353,7 @@ func TestMul(t *testing.T) {
|
|||||||
func TestPlus(t *testing.T) {
|
func TestPlus(t *testing.T) {
|
||||||
src := `<? $a += $b;`
|
src := `<? $a += $b;`
|
||||||
|
|
||||||
expected := &stmt.StmtList{
|
expected := &node.Root{
|
||||||
Stmts: []node.Node{
|
Stmts: []node.Node{
|
||||||
&stmt.Expression{
|
&stmt.Expression{
|
||||||
Expr: &assign.Plus{
|
Expr: &assign.Plus{
|
||||||
@ -378,7 +378,7 @@ func TestPlus(t *testing.T) {
|
|||||||
func TestPow(t *testing.T) {
|
func TestPow(t *testing.T) {
|
||||||
src := `<? $a **= $b;`
|
src := `<? $a **= $b;`
|
||||||
|
|
||||||
expected := &stmt.StmtList{
|
expected := &node.Root{
|
||||||
Stmts: []node.Node{
|
Stmts: []node.Node{
|
||||||
&stmt.Expression{
|
&stmt.Expression{
|
||||||
Expr: &assign.Pow{
|
Expr: &assign.Pow{
|
||||||
@ -403,7 +403,7 @@ func TestPow(t *testing.T) {
|
|||||||
func TestShiftLeft(t *testing.T) {
|
func TestShiftLeft(t *testing.T) {
|
||||||
src := `<? $a <<= $b;`
|
src := `<? $a <<= $b;`
|
||||||
|
|
||||||
expected := &stmt.StmtList{
|
expected := &node.Root{
|
||||||
Stmts: []node.Node{
|
Stmts: []node.Node{
|
||||||
&stmt.Expression{
|
&stmt.Expression{
|
||||||
Expr: &assign.ShiftLeft{
|
Expr: &assign.ShiftLeft{
|
||||||
@ -428,7 +428,7 @@ func TestShiftLeft(t *testing.T) {
|
|||||||
func TestShiftRight(t *testing.T) {
|
func TestShiftRight(t *testing.T) {
|
||||||
src := `<? $a >>= $b;`
|
src := `<? $a >>= $b;`
|
||||||
|
|
||||||
expected := &stmt.StmtList{
|
expected := &node.Root{
|
||||||
Stmts: []node.Node{
|
Stmts: []node.Node{
|
||||||
&stmt.Expression{
|
&stmt.Expression{
|
||||||
Expr: &assign.ShiftRight{
|
Expr: &assign.ShiftRight{
|
||||||
|
@ -30,7 +30,7 @@ func assertEqual(t *testing.T, expected interface{}, actual interface{}) {
|
|||||||
func TestBitwiseAnd(t *testing.T) {
|
func TestBitwiseAnd(t *testing.T) {
|
||||||
src := `<? $a & $b;`
|
src := `<? $a & $b;`
|
||||||
|
|
||||||
expected := &stmt.StmtList{
|
expected := &node.Root{
|
||||||
Stmts: []node.Node{
|
Stmts: []node.Node{
|
||||||
&stmt.Expression{
|
&stmt.Expression{
|
||||||
Expr: &binary.BitwiseAnd{
|
Expr: &binary.BitwiseAnd{
|
||||||
@ -55,7 +55,7 @@ func TestBitwiseAnd(t *testing.T) {
|
|||||||
func TestBitwiseOr(t *testing.T) {
|
func TestBitwiseOr(t *testing.T) {
|
||||||
src := `<? $a | $b;`
|
src := `<? $a | $b;`
|
||||||
|
|
||||||
expected := &stmt.StmtList{
|
expected := &node.Root{
|
||||||
Stmts: []node.Node{
|
Stmts: []node.Node{
|
||||||
&stmt.Expression{
|
&stmt.Expression{
|
||||||
Expr: &binary.BitwiseOr{
|
Expr: &binary.BitwiseOr{
|
||||||
@ -80,7 +80,7 @@ func TestBitwiseOr(t *testing.T) {
|
|||||||
func TestBitwiseXor(t *testing.T) {
|
func TestBitwiseXor(t *testing.T) {
|
||||||
src := `<? $a ^ $b;`
|
src := `<? $a ^ $b;`
|
||||||
|
|
||||||
expected := &stmt.StmtList{
|
expected := &node.Root{
|
||||||
Stmts: []node.Node{
|
Stmts: []node.Node{
|
||||||
&stmt.Expression{
|
&stmt.Expression{
|
||||||
Expr: &binary.BitwiseXor{
|
Expr: &binary.BitwiseXor{
|
||||||
@ -105,7 +105,7 @@ func TestBitwiseXor(t *testing.T) {
|
|||||||
func TestBooleanAnd(t *testing.T) {
|
func TestBooleanAnd(t *testing.T) {
|
||||||
src := `<? $a && $b;`
|
src := `<? $a && $b;`
|
||||||
|
|
||||||
expected := &stmt.StmtList{
|
expected := &node.Root{
|
||||||
Stmts: []node.Node{
|
Stmts: []node.Node{
|
||||||
&stmt.Expression{
|
&stmt.Expression{
|
||||||
Expr: &binary.BooleanAnd{
|
Expr: &binary.BooleanAnd{
|
||||||
@ -130,7 +130,7 @@ func TestBooleanAnd(t *testing.T) {
|
|||||||
func TestBooleanOr(t *testing.T) {
|
func TestBooleanOr(t *testing.T) {
|
||||||
src := `<? $a || $b;`
|
src := `<? $a || $b;`
|
||||||
|
|
||||||
expected := &stmt.StmtList{
|
expected := &node.Root{
|
||||||
Stmts: []node.Node{
|
Stmts: []node.Node{
|
||||||
&stmt.Expression{
|
&stmt.Expression{
|
||||||
Expr: &binary.BooleanOr{
|
Expr: &binary.BooleanOr{
|
||||||
@ -155,7 +155,7 @@ func TestBooleanOr(t *testing.T) {
|
|||||||
func TestCoalesce(t *testing.T) {
|
func TestCoalesce(t *testing.T) {
|
||||||
src := `<? $a ?? $b;`
|
src := `<? $a ?? $b;`
|
||||||
|
|
||||||
expected := &stmt.StmtList{
|
expected := &node.Root{
|
||||||
Stmts: []node.Node{
|
Stmts: []node.Node{
|
||||||
&stmt.Expression{
|
&stmt.Expression{
|
||||||
Expr: &binary.Coalesce{
|
Expr: &binary.Coalesce{
|
||||||
@ -175,7 +175,7 @@ func TestCoalesce(t *testing.T) {
|
|||||||
func TestConcat(t *testing.T) {
|
func TestConcat(t *testing.T) {
|
||||||
src := `<? $a . $b;`
|
src := `<? $a . $b;`
|
||||||
|
|
||||||
expected := &stmt.StmtList{
|
expected := &node.Root{
|
||||||
Stmts: []node.Node{
|
Stmts: []node.Node{
|
||||||
&stmt.Expression{
|
&stmt.Expression{
|
||||||
Expr: &binary.Concat{
|
Expr: &binary.Concat{
|
||||||
@ -200,7 +200,7 @@ func TestConcat(t *testing.T) {
|
|||||||
func TestDiv(t *testing.T) {
|
func TestDiv(t *testing.T) {
|
||||||
src := `<? $a / $b;`
|
src := `<? $a / $b;`
|
||||||
|
|
||||||
expected := &stmt.StmtList{
|
expected := &node.Root{
|
||||||
Stmts: []node.Node{
|
Stmts: []node.Node{
|
||||||
&stmt.Expression{
|
&stmt.Expression{
|
||||||
Expr: &binary.Div{
|
Expr: &binary.Div{
|
||||||
@ -225,7 +225,7 @@ func TestDiv(t *testing.T) {
|
|||||||
func TestEqual(t *testing.T) {
|
func TestEqual(t *testing.T) {
|
||||||
src := `<? $a == $b;`
|
src := `<? $a == $b;`
|
||||||
|
|
||||||
expected := &stmt.StmtList{
|
expected := &node.Root{
|
||||||
Stmts: []node.Node{
|
Stmts: []node.Node{
|
||||||
&stmt.Expression{
|
&stmt.Expression{
|
||||||
Expr: &binary.Equal{
|
Expr: &binary.Equal{
|
||||||
@ -250,7 +250,7 @@ func TestEqual(t *testing.T) {
|
|||||||
func TestGreaterOrEqual(t *testing.T) {
|
func TestGreaterOrEqual(t *testing.T) {
|
||||||
src := `<? $a >= $b;`
|
src := `<? $a >= $b;`
|
||||||
|
|
||||||
expected := &stmt.StmtList{
|
expected := &node.Root{
|
||||||
Stmts: []node.Node{
|
Stmts: []node.Node{
|
||||||
&stmt.Expression{
|
&stmt.Expression{
|
||||||
Expr: &binary.GreaterOrEqual{
|
Expr: &binary.GreaterOrEqual{
|
||||||
@ -275,7 +275,7 @@ func TestGreaterOrEqual(t *testing.T) {
|
|||||||
func TestGreater(t *testing.T) {
|
func TestGreater(t *testing.T) {
|
||||||
src := `<? $a > $b;`
|
src := `<? $a > $b;`
|
||||||
|
|
||||||
expected := &stmt.StmtList{
|
expected := &node.Root{
|
||||||
Stmts: []node.Node{
|
Stmts: []node.Node{
|
||||||
&stmt.Expression{
|
&stmt.Expression{
|
||||||
Expr: &binary.Greater{
|
Expr: &binary.Greater{
|
||||||
@ -300,7 +300,7 @@ func TestGreater(t *testing.T) {
|
|||||||
func TestIdentical(t *testing.T) {
|
func TestIdentical(t *testing.T) {
|
||||||
src := `<? $a === $b;`
|
src := `<? $a === $b;`
|
||||||
|
|
||||||
expected := &stmt.StmtList{
|
expected := &node.Root{
|
||||||
Stmts: []node.Node{
|
Stmts: []node.Node{
|
||||||
&stmt.Expression{
|
&stmt.Expression{
|
||||||
Expr: &binary.Identical{
|
Expr: &binary.Identical{
|
||||||
@ -325,7 +325,7 @@ func TestIdentical(t *testing.T) {
|
|||||||
func TestLogicalAnd(t *testing.T) {
|
func TestLogicalAnd(t *testing.T) {
|
||||||
src := `<? $a and $b;`
|
src := `<? $a and $b;`
|
||||||
|
|
||||||
expected := &stmt.StmtList{
|
expected := &node.Root{
|
||||||
Stmts: []node.Node{
|
Stmts: []node.Node{
|
||||||
&stmt.Expression{
|
&stmt.Expression{
|
||||||
Expr: &binary.LogicalAnd{
|
Expr: &binary.LogicalAnd{
|
||||||
@ -350,7 +350,7 @@ func TestLogicalAnd(t *testing.T) {
|
|||||||
func TestLogicalOr(t *testing.T) {
|
func TestLogicalOr(t *testing.T) {
|
||||||
src := `<? $a or $b;`
|
src := `<? $a or $b;`
|
||||||
|
|
||||||
expected := &stmt.StmtList{
|
expected := &node.Root{
|
||||||
Stmts: []node.Node{
|
Stmts: []node.Node{
|
||||||
&stmt.Expression{
|
&stmt.Expression{
|
||||||
Expr: &binary.LogicalOr{
|
Expr: &binary.LogicalOr{
|
||||||
@ -375,7 +375,7 @@ func TestLogicalOr(t *testing.T) {
|
|||||||
func TestLogicalXor(t *testing.T) {
|
func TestLogicalXor(t *testing.T) {
|
||||||
src := `<? $a xor $b;`
|
src := `<? $a xor $b;`
|
||||||
|
|
||||||
expected := &stmt.StmtList{
|
expected := &node.Root{
|
||||||
Stmts: []node.Node{
|
Stmts: []node.Node{
|
||||||
&stmt.Expression{
|
&stmt.Expression{
|
||||||
Expr: &binary.LogicalXor{
|
Expr: &binary.LogicalXor{
|
||||||
@ -400,7 +400,7 @@ func TestLogicalXor(t *testing.T) {
|
|||||||
func TestMinus(t *testing.T) {
|
func TestMinus(t *testing.T) {
|
||||||
src := `<? $a - $b;`
|
src := `<? $a - $b;`
|
||||||
|
|
||||||
expected := &stmt.StmtList{
|
expected := &node.Root{
|
||||||
Stmts: []node.Node{
|
Stmts: []node.Node{
|
||||||
&stmt.Expression{
|
&stmt.Expression{
|
||||||
Expr: &binary.Minus{
|
Expr: &binary.Minus{
|
||||||
@ -425,7 +425,7 @@ func TestMinus(t *testing.T) {
|
|||||||
func TestMod(t *testing.T) {
|
func TestMod(t *testing.T) {
|
||||||
src := `<? $a % $b;`
|
src := `<? $a % $b;`
|
||||||
|
|
||||||
expected := &stmt.StmtList{
|
expected := &node.Root{
|
||||||
Stmts: []node.Node{
|
Stmts: []node.Node{
|
||||||
&stmt.Expression{
|
&stmt.Expression{
|
||||||
Expr: &binary.Mod{
|
Expr: &binary.Mod{
|
||||||
@ -450,7 +450,7 @@ func TestMod(t *testing.T) {
|
|||||||
func TestMul(t *testing.T) {
|
func TestMul(t *testing.T) {
|
||||||
src := `<? $a * $b;`
|
src := `<? $a * $b;`
|
||||||
|
|
||||||
expected := &stmt.StmtList{
|
expected := &node.Root{
|
||||||
Stmts: []node.Node{
|
Stmts: []node.Node{
|
||||||
&stmt.Expression{
|
&stmt.Expression{
|
||||||
Expr: &binary.Mul{
|
Expr: &binary.Mul{
|
||||||
@ -475,7 +475,7 @@ func TestMul(t *testing.T) {
|
|||||||
func TestNotEqual(t *testing.T) {
|
func TestNotEqual(t *testing.T) {
|
||||||
src := `<? $a != $b;`
|
src := `<? $a != $b;`
|
||||||
|
|
||||||
expected := &stmt.StmtList{
|
expected := &node.Root{
|
||||||
Stmts: []node.Node{
|
Stmts: []node.Node{
|
||||||
&stmt.Expression{
|
&stmt.Expression{
|
||||||
Expr: &binary.NotEqual{
|
Expr: &binary.NotEqual{
|
||||||
@ -500,7 +500,7 @@ func TestNotEqual(t *testing.T) {
|
|||||||
func TestNotIdentical(t *testing.T) {
|
func TestNotIdentical(t *testing.T) {
|
||||||
src := `<? $a !== $b;`
|
src := `<? $a !== $b;`
|
||||||
|
|
||||||
expected := &stmt.StmtList{
|
expected := &node.Root{
|
||||||
Stmts: []node.Node{
|
Stmts: []node.Node{
|
||||||
&stmt.Expression{
|
&stmt.Expression{
|
||||||
Expr: &binary.NotIdentical{
|
Expr: &binary.NotIdentical{
|
||||||
@ -525,7 +525,7 @@ func TestNotIdentical(t *testing.T) {
|
|||||||
func TestPlus(t *testing.T) {
|
func TestPlus(t *testing.T) {
|
||||||
src := `<? $a + $b;`
|
src := `<? $a + $b;`
|
||||||
|
|
||||||
expected := &stmt.StmtList{
|
expected := &node.Root{
|
||||||
Stmts: []node.Node{
|
Stmts: []node.Node{
|
||||||
&stmt.Expression{
|
&stmt.Expression{
|
||||||
Expr: &binary.Plus{
|
Expr: &binary.Plus{
|
||||||
@ -550,7 +550,7 @@ func TestPlus(t *testing.T) {
|
|||||||
func TestPow(t *testing.T) {
|
func TestPow(t *testing.T) {
|
||||||
src := `<? $a ** $b;`
|
src := `<? $a ** $b;`
|
||||||
|
|
||||||
expected := &stmt.StmtList{
|
expected := &node.Root{
|
||||||
Stmts: []node.Node{
|
Stmts: []node.Node{
|
||||||
&stmt.Expression{
|
&stmt.Expression{
|
||||||
Expr: &binary.Pow{
|
Expr: &binary.Pow{
|
||||||
@ -575,7 +575,7 @@ func TestPow(t *testing.T) {
|
|||||||
func TestShiftLeft(t *testing.T) {
|
func TestShiftLeft(t *testing.T) {
|
||||||
src := `<? $a << $b;`
|
src := `<? $a << $b;`
|
||||||
|
|
||||||
expected := &stmt.StmtList{
|
expected := &node.Root{
|
||||||
Stmts: []node.Node{
|
Stmts: []node.Node{
|
||||||
&stmt.Expression{
|
&stmt.Expression{
|
||||||
Expr: &binary.ShiftLeft{
|
Expr: &binary.ShiftLeft{
|
||||||
@ -600,7 +600,7 @@ func TestShiftLeft(t *testing.T) {
|
|||||||
func TestShiftRight(t *testing.T) {
|
func TestShiftRight(t *testing.T) {
|
||||||
src := `<? $a >> $b;`
|
src := `<? $a >> $b;`
|
||||||
|
|
||||||
expected := &stmt.StmtList{
|
expected := &node.Root{
|
||||||
Stmts: []node.Node{
|
Stmts: []node.Node{
|
||||||
&stmt.Expression{
|
&stmt.Expression{
|
||||||
Expr: &binary.ShiftRight{
|
Expr: &binary.ShiftRight{
|
||||||
@ -625,7 +625,7 @@ func TestShiftRight(t *testing.T) {
|
|||||||
func TestSmallerOrEqual(t *testing.T) {
|
func TestSmallerOrEqual(t *testing.T) {
|
||||||
src := `<? $a <= $b;`
|
src := `<? $a <= $b;`
|
||||||
|
|
||||||
expected := &stmt.StmtList{
|
expected := &node.Root{
|
||||||
Stmts: []node.Node{
|
Stmts: []node.Node{
|
||||||
&stmt.Expression{
|
&stmt.Expression{
|
||||||
Expr: &binary.SmallerOrEqual{
|
Expr: &binary.SmallerOrEqual{
|
||||||
@ -650,7 +650,7 @@ func TestSmallerOrEqual(t *testing.T) {
|
|||||||
func TestSmaller(t *testing.T) {
|
func TestSmaller(t *testing.T) {
|
||||||
src := `<? $a < $b;`
|
src := `<? $a < $b;`
|
||||||
|
|
||||||
expected := &stmt.StmtList{
|
expected := &node.Root{
|
||||||
Stmts: []node.Node{
|
Stmts: []node.Node{
|
||||||
&stmt.Expression{
|
&stmt.Expression{
|
||||||
Expr: &binary.Smaller{
|
Expr: &binary.Smaller{
|
||||||
@ -675,7 +675,7 @@ func TestSmaller(t *testing.T) {
|
|||||||
func TestSpaceship(t *testing.T) {
|
func TestSpaceship(t *testing.T) {
|
||||||
src := `<? $a <=> $b;`
|
src := `<? $a <=> $b;`
|
||||||
|
|
||||||
expected := &stmt.StmtList{
|
expected := &node.Root{
|
||||||
Stmts: []node.Node{
|
Stmts: []node.Node{
|
||||||
&stmt.Expression{
|
&stmt.Expression{
|
||||||
Expr: &binary.Spaceship{
|
Expr: &binary.Spaceship{
|
||||||
|
@ -30,7 +30,7 @@ func assertEqual(t *testing.T, expected interface{}, actual interface{}) {
|
|||||||
func TestArray(t *testing.T) {
|
func TestArray(t *testing.T) {
|
||||||
src := `<? (array)$a;`
|
src := `<? (array)$a;`
|
||||||
|
|
||||||
expected := &stmt.StmtList{
|
expected := &node.Root{
|
||||||
Stmts: []node.Node{
|
Stmts: []node.Node{
|
||||||
&stmt.Expression{
|
&stmt.Expression{
|
||||||
Expr: &cast.Array{
|
Expr: &cast.Array{
|
||||||
@ -54,7 +54,7 @@ func TestArray(t *testing.T) {
|
|||||||
func TestBool(t *testing.T) {
|
func TestBool(t *testing.T) {
|
||||||
src := `<? (boolean)$a;`
|
src := `<? (boolean)$a;`
|
||||||
|
|
||||||
expected := &stmt.StmtList{
|
expected := &node.Root{
|
||||||
Stmts: []node.Node{
|
Stmts: []node.Node{
|
||||||
&stmt.Expression{
|
&stmt.Expression{
|
||||||
Expr: &cast.Bool{
|
Expr: &cast.Bool{
|
||||||
@ -78,7 +78,7 @@ func TestBool(t *testing.T) {
|
|||||||
func TestBoolShort(t *testing.T) {
|
func TestBoolShort(t *testing.T) {
|
||||||
src := `<? (bool)$a;`
|
src := `<? (bool)$a;`
|
||||||
|
|
||||||
expected := &stmt.StmtList{
|
expected := &node.Root{
|
||||||
Stmts: []node.Node{
|
Stmts: []node.Node{
|
||||||
&stmt.Expression{
|
&stmt.Expression{
|
||||||
Expr: &cast.Bool{
|
Expr: &cast.Bool{
|
||||||
@ -102,7 +102,7 @@ func TestBoolShort(t *testing.T) {
|
|||||||
func TestDouble(t *testing.T) {
|
func TestDouble(t *testing.T) {
|
||||||
src := `<? (double)$a;`
|
src := `<? (double)$a;`
|
||||||
|
|
||||||
expected := &stmt.StmtList{
|
expected := &node.Root{
|
||||||
Stmts: []node.Node{
|
Stmts: []node.Node{
|
||||||
&stmt.Expression{
|
&stmt.Expression{
|
||||||
Expr: &cast.Double{
|
Expr: &cast.Double{
|
||||||
@ -126,7 +126,7 @@ func TestDouble(t *testing.T) {
|
|||||||
func TestCastFloat(t *testing.T) {
|
func TestCastFloat(t *testing.T) {
|
||||||
src := `<? (float)$a;`
|
src := `<? (float)$a;`
|
||||||
|
|
||||||
expected := &stmt.StmtList{
|
expected := &node.Root{
|
||||||
Stmts: []node.Node{
|
Stmts: []node.Node{
|
||||||
&stmt.Expression{
|
&stmt.Expression{
|
||||||
Expr: &cast.Double{
|
Expr: &cast.Double{
|
||||||
@ -150,7 +150,7 @@ func TestCastFloat(t *testing.T) {
|
|||||||
func TestInt(t *testing.T) {
|
func TestInt(t *testing.T) {
|
||||||
src := `<? (integer)$a;`
|
src := `<? (integer)$a;`
|
||||||
|
|
||||||
expected := &stmt.StmtList{
|
expected := &node.Root{
|
||||||
Stmts: []node.Node{
|
Stmts: []node.Node{
|
||||||
&stmt.Expression{
|
&stmt.Expression{
|
||||||
Expr: &cast.Int{
|
Expr: &cast.Int{
|
||||||
@ -174,7 +174,7 @@ func TestInt(t *testing.T) {
|
|||||||
func TestIntShort(t *testing.T) {
|
func TestIntShort(t *testing.T) {
|
||||||
src := `<? (int)$a;`
|
src := `<? (int)$a;`
|
||||||
|
|
||||||
expected := &stmt.StmtList{
|
expected := &node.Root{
|
||||||
Stmts: []node.Node{
|
Stmts: []node.Node{
|
||||||
&stmt.Expression{
|
&stmt.Expression{
|
||||||
Expr: &cast.Int{
|
Expr: &cast.Int{
|
||||||
@ -198,7 +198,7 @@ func TestIntShort(t *testing.T) {
|
|||||||
func TestObject(t *testing.T) {
|
func TestObject(t *testing.T) {
|
||||||
src := `<? (object)$a;`
|
src := `<? (object)$a;`
|
||||||
|
|
||||||
expected := &stmt.StmtList{
|
expected := &node.Root{
|
||||||
Stmts: []node.Node{
|
Stmts: []node.Node{
|
||||||
&stmt.Expression{
|
&stmt.Expression{
|
||||||
Expr: &cast.Object{
|
Expr: &cast.Object{
|
||||||
@ -222,7 +222,7 @@ func TestObject(t *testing.T) {
|
|||||||
func TestString(t *testing.T) {
|
func TestString(t *testing.T) {
|
||||||
src := `<? (string)$a;`
|
src := `<? (string)$a;`
|
||||||
|
|
||||||
expected := &stmt.StmtList{
|
expected := &node.Root{
|
||||||
Stmts: []node.Node{
|
Stmts: []node.Node{
|
||||||
&stmt.Expression{
|
&stmt.Expression{
|
||||||
Expr: &cast.String{
|
Expr: &cast.String{
|
||||||
@ -246,7 +246,7 @@ func TestString(t *testing.T) {
|
|||||||
func TestUnset(t *testing.T) {
|
func TestUnset(t *testing.T) {
|
||||||
src := `<? (unset)$a;`
|
src := `<? (unset)$a;`
|
||||||
|
|
||||||
expected := &stmt.StmtList{
|
expected := &node.Root{
|
||||||
Stmts: []node.Node{
|
Stmts: []node.Node{
|
||||||
&stmt.Expression{
|
&stmt.Expression{
|
||||||
Expr: &cast.Unset{
|
Expr: &cast.Unset{
|
||||||
|
@ -31,7 +31,7 @@ func assertEqual(t *testing.T, expected interface{}, actual interface{}) {
|
|||||||
func TestArrayDimFetch(t *testing.T) {
|
func TestArrayDimFetch(t *testing.T) {
|
||||||
src := `<? $a[1];`
|
src := `<? $a[1];`
|
||||||
|
|
||||||
expected := &stmt.StmtList{
|
expected := &node.Root{
|
||||||
Stmts: []node.Node{
|
Stmts: []node.Node{
|
||||||
&stmt.Expression{
|
&stmt.Expression{
|
||||||
Expr: &expr.ArrayDimFetch{
|
Expr: &expr.ArrayDimFetch{
|
||||||
@ -56,7 +56,7 @@ func TestArrayDimFetch(t *testing.T) {
|
|||||||
func TestArrayDimFetchNested(t *testing.T) {
|
func TestArrayDimFetchNested(t *testing.T) {
|
||||||
src := `<? $a[1][2];`
|
src := `<? $a[1][2];`
|
||||||
|
|
||||||
expected := &stmt.StmtList{
|
expected := &node.Root{
|
||||||
Stmts: []node.Node{
|
Stmts: []node.Node{
|
||||||
&stmt.Expression{
|
&stmt.Expression{
|
||||||
Expr: &expr.ArrayDimFetch{
|
Expr: &expr.ArrayDimFetch{
|
||||||
|
@ -17,7 +17,7 @@ import (
|
|||||||
func TestArray(t *testing.T) {
|
func TestArray(t *testing.T) {
|
||||||
src := `<? array();`
|
src := `<? array();`
|
||||||
|
|
||||||
expected := &stmt.StmtList{
|
expected := &node.Root{
|
||||||
Stmts: []node.Node{
|
Stmts: []node.Node{
|
||||||
&stmt.Expression{
|
&stmt.Expression{
|
||||||
Expr: &expr.Array{
|
Expr: &expr.Array{
|
||||||
@ -41,7 +41,7 @@ func TestArray(t *testing.T) {
|
|||||||
func TestArrayItem(t *testing.T) {
|
func TestArrayItem(t *testing.T) {
|
||||||
src := `<? array(1);`
|
src := `<? array(1);`
|
||||||
|
|
||||||
expected := &stmt.StmtList{
|
expected := &node.Root{
|
||||||
Stmts: []node.Node{
|
Stmts: []node.Node{
|
||||||
&stmt.Expression{
|
&stmt.Expression{
|
||||||
Expr: &expr.Array{
|
Expr: &expr.Array{
|
||||||
@ -70,7 +70,7 @@ func TestArrayItem(t *testing.T) {
|
|||||||
func TestArrayItems(t *testing.T) {
|
func TestArrayItems(t *testing.T) {
|
||||||
src := `<? array(1=>1, &$b,);`
|
src := `<? array(1=>1, &$b,);`
|
||||||
|
|
||||||
expected := &stmt.StmtList{
|
expected := &node.Root{
|
||||||
Stmts: []node.Node{
|
Stmts: []node.Node{
|
||||||
&stmt.Expression{
|
&stmt.Expression{
|
||||||
Expr: &expr.Array{
|
Expr: &expr.Array{
|
||||||
|
@ -15,7 +15,7 @@ import (
|
|||||||
func TestBitwiseNot(t *testing.T) {
|
func TestBitwiseNot(t *testing.T) {
|
||||||
src := `<? ~$a;`
|
src := `<? ~$a;`
|
||||||
|
|
||||||
expected := &stmt.StmtList{
|
expected := &node.Root{
|
||||||
Stmts: []node.Node{
|
Stmts: []node.Node{
|
||||||
&stmt.Expression{
|
&stmt.Expression{
|
||||||
Expr: &expr.BitwiseNot{
|
Expr: &expr.BitwiseNot{
|
||||||
|
@ -15,7 +15,7 @@ import (
|
|||||||
func TestBooleanNot(t *testing.T) {
|
func TestBooleanNot(t *testing.T) {
|
||||||
src := `<? !$a;`
|
src := `<? !$a;`
|
||||||
|
|
||||||
expected := &stmt.StmtList{
|
expected := &node.Root{
|
||||||
Stmts: []node.Node{
|
Stmts: []node.Node{
|
||||||
&stmt.Expression{
|
&stmt.Expression{
|
||||||
Expr: &expr.BooleanNot{
|
Expr: &expr.BooleanNot{
|
||||||
|
@ -17,7 +17,7 @@ import (
|
|||||||
func TestClassConstFetch(t *testing.T) {
|
func TestClassConstFetch(t *testing.T) {
|
||||||
src := `<? Foo::Bar;`
|
src := `<? Foo::Bar;`
|
||||||
|
|
||||||
expected := &stmt.StmtList{
|
expected := &node.Root{
|
||||||
Stmts: []node.Node{
|
Stmts: []node.Node{
|
||||||
&stmt.Expression{
|
&stmt.Expression{
|
||||||
Expr: &expr.ClassConstFetch{
|
Expr: &expr.ClassConstFetch{
|
||||||
@ -46,7 +46,7 @@ func TestClassConstFetch(t *testing.T) {
|
|||||||
func TestStaticClassConstFetch(t *testing.T) {
|
func TestStaticClassConstFetch(t *testing.T) {
|
||||||
src := `<? static::bar;`
|
src := `<? static::bar;`
|
||||||
|
|
||||||
expected := &stmt.StmtList{
|
expected := &node.Root{
|
||||||
Stmts: []node.Node{
|
Stmts: []node.Node{
|
||||||
&stmt.Expression{
|
&stmt.Expression{
|
||||||
Expr: &expr.ClassConstFetch{
|
Expr: &expr.ClassConstFetch{
|
||||||
|
@ -15,7 +15,7 @@ import (
|
|||||||
func TestCloneBrackets(t *testing.T) {
|
func TestCloneBrackets(t *testing.T) {
|
||||||
src := `<? clone($a);`
|
src := `<? clone($a);`
|
||||||
|
|
||||||
expected := &stmt.StmtList{
|
expected := &node.Root{
|
||||||
Stmts: []node.Node{
|
Stmts: []node.Node{
|
||||||
&stmt.Expression{
|
&stmt.Expression{
|
||||||
Expr: &expr.Clone{
|
Expr: &expr.Clone{
|
||||||
@ -39,7 +39,7 @@ func TestCloneBrackets(t *testing.T) {
|
|||||||
func TestClone(t *testing.T) {
|
func TestClone(t *testing.T) {
|
||||||
src := `<? clone $a;`
|
src := `<? clone $a;`
|
||||||
|
|
||||||
expected := &stmt.StmtList{
|
expected := &node.Root{
|
||||||
Stmts: []node.Node{
|
Stmts: []node.Node{
|
||||||
&stmt.Expression{
|
&stmt.Expression{
|
||||||
Expr: &expr.Clone{
|
Expr: &expr.Clone{
|
||||||
|
@ -17,7 +17,7 @@ import (
|
|||||||
func TestClosure(t *testing.T) {
|
func TestClosure(t *testing.T) {
|
||||||
src := `<? function(){};`
|
src := `<? function(){};`
|
||||||
|
|
||||||
expected := &stmt.StmtList{
|
expected := &node.Root{
|
||||||
Stmts: []node.Node{
|
Stmts: []node.Node{
|
||||||
&stmt.Expression{
|
&stmt.Expression{
|
||||||
Expr: &expr.Closure{
|
Expr: &expr.Closure{
|
||||||
@ -45,7 +45,7 @@ func TestClosure(t *testing.T) {
|
|||||||
func TestClosureUse(t *testing.T) {
|
func TestClosureUse(t *testing.T) {
|
||||||
src := `<? function($a, $b) use ($c, &$d) {};`
|
src := `<? function($a, $b) use ($c, &$d) {};`
|
||||||
|
|
||||||
expected := &stmt.StmtList{
|
expected := &node.Root{
|
||||||
Stmts: []node.Node{
|
Stmts: []node.Node{
|
||||||
&stmt.Expression{
|
&stmt.Expression{
|
||||||
Expr: &expr.Closure{
|
Expr: &expr.Closure{
|
||||||
@ -94,7 +94,7 @@ func TestClosureUse(t *testing.T) {
|
|||||||
func TestClosureUse2(t *testing.T) {
|
func TestClosureUse2(t *testing.T) {
|
||||||
src := `<? function($a, $b) use (&$c, $d) {};`
|
src := `<? function($a, $b) use (&$c, $d) {};`
|
||||||
|
|
||||||
expected := &stmt.StmtList{
|
expected := &node.Root{
|
||||||
Stmts: []node.Node{
|
Stmts: []node.Node{
|
||||||
&stmt.Expression{
|
&stmt.Expression{
|
||||||
Expr: &expr.Closure{
|
Expr: &expr.Closure{
|
||||||
@ -143,7 +143,7 @@ func TestClosureUse2(t *testing.T) {
|
|||||||
func TestClosureReturnType(t *testing.T) {
|
func TestClosureReturnType(t *testing.T) {
|
||||||
src := `<? function(): void {};`
|
src := `<? function(): void {};`
|
||||||
|
|
||||||
expected := &stmt.StmtList{
|
expected := &node.Root{
|
||||||
Stmts: []node.Node{
|
Stmts: []node.Node{
|
||||||
&stmt.Expression{
|
&stmt.Expression{
|
||||||
Expr: &expr.Closure{
|
Expr: &expr.Closure{
|
||||||
|
@ -17,7 +17,7 @@ import (
|
|||||||
func TestConstFetch(t *testing.T) {
|
func TestConstFetch(t *testing.T) {
|
||||||
src := `<? foo;`
|
src := `<? foo;`
|
||||||
|
|
||||||
expected := &stmt.StmtList{
|
expected := &node.Root{
|
||||||
Stmts: []node.Node{
|
Stmts: []node.Node{
|
||||||
&stmt.Expression{
|
&stmt.Expression{
|
||||||
Expr: &expr.ConstFetch{
|
Expr: &expr.ConstFetch{
|
||||||
@ -41,7 +41,7 @@ func TestConstFetch(t *testing.T) {
|
|||||||
func TestConstFetchRelative(t *testing.T) {
|
func TestConstFetchRelative(t *testing.T) {
|
||||||
src := `<? namespace\foo;`
|
src := `<? namespace\foo;`
|
||||||
|
|
||||||
expected := &stmt.StmtList{
|
expected := &node.Root{
|
||||||
Stmts: []node.Node{
|
Stmts: []node.Node{
|
||||||
&stmt.Expression{
|
&stmt.Expression{
|
||||||
Expr: &expr.ConstFetch{
|
Expr: &expr.ConstFetch{
|
||||||
@ -65,7 +65,7 @@ func TestConstFetchRelative(t *testing.T) {
|
|||||||
func TestConstFetchFullyQualified(t *testing.T) {
|
func TestConstFetchFullyQualified(t *testing.T) {
|
||||||
src := `<? \foo;`
|
src := `<? \foo;`
|
||||||
|
|
||||||
expected := &stmt.StmtList{
|
expected := &node.Root{
|
||||||
Stmts: []node.Node{
|
Stmts: []node.Node{
|
||||||
&stmt.Expression{
|
&stmt.Expression{
|
||||||
Expr: &expr.ConstFetch{
|
Expr: &expr.ConstFetch{
|
||||||
|
@ -15,7 +15,7 @@ import (
|
|||||||
func TestEmpty(t *testing.T) {
|
func TestEmpty(t *testing.T) {
|
||||||
src := `<? empty($a);`
|
src := `<? empty($a);`
|
||||||
|
|
||||||
expected := &stmt.StmtList{
|
expected := &node.Root{
|
||||||
Stmts: []node.Node{
|
Stmts: []node.Node{
|
||||||
&stmt.Expression{
|
&stmt.Expression{
|
||||||
Expr: &expr.Empty{
|
Expr: &expr.Empty{
|
||||||
|
@ -15,7 +15,7 @@ import (
|
|||||||
func TestErrorSuppress(t *testing.T) {
|
func TestErrorSuppress(t *testing.T) {
|
||||||
src := `<? @$a;`
|
src := `<? @$a;`
|
||||||
|
|
||||||
expected := &stmt.StmtList{
|
expected := &node.Root{
|
||||||
Stmts: []node.Node{
|
Stmts: []node.Node{
|
||||||
&stmt.Expression{
|
&stmt.Expression{
|
||||||
Expr: &expr.ErrorSuppress{
|
Expr: &expr.ErrorSuppress{
|
||||||
|
@ -15,7 +15,7 @@ import (
|
|||||||
func TestEval(t *testing.T) {
|
func TestEval(t *testing.T) {
|
||||||
src := `<? eval($a);`
|
src := `<? eval($a);`
|
||||||
|
|
||||||
expected := &stmt.StmtList{
|
expected := &node.Root{
|
||||||
Stmts: []node.Node{
|
Stmts: []node.Node{
|
||||||
&stmt.Expression{
|
&stmt.Expression{
|
||||||
Expr: &expr.Eval{
|
Expr: &expr.Eval{
|
||||||
|
@ -15,7 +15,7 @@ import (
|
|||||||
func TestExit(t *testing.T) {
|
func TestExit(t *testing.T) {
|
||||||
src := `<? exit;`
|
src := `<? exit;`
|
||||||
|
|
||||||
expected := &stmt.StmtList{
|
expected := &node.Root{
|
||||||
Stmts: []node.Node{
|
Stmts: []node.Node{
|
||||||
&stmt.Expression{
|
&stmt.Expression{
|
||||||
Expr: &expr.Exit{},
|
Expr: &expr.Exit{},
|
||||||
@ -37,7 +37,7 @@ func TestExit(t *testing.T) {
|
|||||||
func TestExitExpr(t *testing.T) {
|
func TestExitExpr(t *testing.T) {
|
||||||
src := `<? exit($a);`
|
src := `<? exit($a);`
|
||||||
|
|
||||||
expected := &stmt.StmtList{
|
expected := &node.Root{
|
||||||
Stmts: []node.Node{
|
Stmts: []node.Node{
|
||||||
&stmt.Expression{
|
&stmt.Expression{
|
||||||
Expr: &expr.Exit{
|
Expr: &expr.Exit{
|
||||||
@ -61,7 +61,7 @@ func TestExitExpr(t *testing.T) {
|
|||||||
func TestDie(t *testing.T) {
|
func TestDie(t *testing.T) {
|
||||||
src := `<? die;`
|
src := `<? die;`
|
||||||
|
|
||||||
expected := &stmt.StmtList{
|
expected := &node.Root{
|
||||||
Stmts: []node.Node{
|
Stmts: []node.Node{
|
||||||
&stmt.Expression{
|
&stmt.Expression{
|
||||||
Expr: &expr.Die{},
|
Expr: &expr.Die{},
|
||||||
@ -83,7 +83,7 @@ func TestDie(t *testing.T) {
|
|||||||
func TestDieExpr(t *testing.T) {
|
func TestDieExpr(t *testing.T) {
|
||||||
src := `<? die($a);`
|
src := `<? die($a);`
|
||||||
|
|
||||||
expected := &stmt.StmtList{
|
expected := &node.Root{
|
||||||
Stmts: []node.Node{
|
Stmts: []node.Node{
|
||||||
&stmt.Expression{
|
&stmt.Expression{
|
||||||
Expr: &expr.Die{
|
Expr: &expr.Die{
|
||||||
|
@ -20,7 +20,7 @@ import (
|
|||||||
func TestFunctionCall(t *testing.T) {
|
func TestFunctionCall(t *testing.T) {
|
||||||
src := `<? foo();`
|
src := `<? foo();`
|
||||||
|
|
||||||
expected := &stmt.StmtList{
|
expected := &node.Root{
|
||||||
Stmts: []node.Node{
|
Stmts: []node.Node{
|
||||||
&stmt.Expression{
|
&stmt.Expression{
|
||||||
Expr: &expr.FunctionCall{
|
Expr: &expr.FunctionCall{
|
||||||
@ -49,7 +49,7 @@ func TestFunctionCall(t *testing.T) {
|
|||||||
func TestFunctionCallRelative(t *testing.T) {
|
func TestFunctionCallRelative(t *testing.T) {
|
||||||
src := `<? namespace\foo();`
|
src := `<? namespace\foo();`
|
||||||
|
|
||||||
expected := &stmt.StmtList{
|
expected := &node.Root{
|
||||||
Stmts: []node.Node{
|
Stmts: []node.Node{
|
||||||
&stmt.Expression{
|
&stmt.Expression{
|
||||||
Expr: &expr.FunctionCall{
|
Expr: &expr.FunctionCall{
|
||||||
@ -78,7 +78,7 @@ func TestFunctionCallRelative(t *testing.T) {
|
|||||||
func TestFunctionFullyQualified(t *testing.T) {
|
func TestFunctionFullyQualified(t *testing.T) {
|
||||||
src := `<? \foo([]);`
|
src := `<? \foo([]);`
|
||||||
|
|
||||||
expected := &stmt.StmtList{
|
expected := &node.Root{
|
||||||
Stmts: []node.Node{
|
Stmts: []node.Node{
|
||||||
&stmt.Expression{
|
&stmt.Expression{
|
||||||
Expr: &expr.FunctionCall{
|
Expr: &expr.FunctionCall{
|
||||||
@ -117,7 +117,7 @@ func TestFunctionFullyQualified(t *testing.T) {
|
|||||||
func TestFunctionCallVar(t *testing.T) {
|
func TestFunctionCallVar(t *testing.T) {
|
||||||
src := `<? $foo(yield $a);`
|
src := `<? $foo(yield $a);`
|
||||||
|
|
||||||
expected := &stmt.StmtList{
|
expected := &node.Root{
|
||||||
Stmts: []node.Node{
|
Stmts: []node.Node{
|
||||||
&stmt.Expression{
|
&stmt.Expression{
|
||||||
Expr: &expr.FunctionCall{
|
Expr: &expr.FunctionCall{
|
||||||
@ -152,7 +152,7 @@ func TestFunctionCallVar(t *testing.T) {
|
|||||||
func TestFunctionCallExprArg(t *testing.T) {
|
func TestFunctionCallExprArg(t *testing.T) {
|
||||||
src := `<? ceil($foo/3);`
|
src := `<? ceil($foo/3);`
|
||||||
|
|
||||||
expected := &stmt.StmtList{
|
expected := &node.Root{
|
||||||
Stmts: []node.Node{
|
Stmts: []node.Node{
|
||||||
&stmt.Expression{
|
&stmt.Expression{
|
||||||
Expr: &expr.FunctionCall{
|
Expr: &expr.FunctionCall{
|
||||||
|
@ -15,7 +15,7 @@ import (
|
|||||||
func TestPostDec(t *testing.T) {
|
func TestPostDec(t *testing.T) {
|
||||||
src := `<? $a--;`
|
src := `<? $a--;`
|
||||||
|
|
||||||
expected := &stmt.StmtList{
|
expected := &node.Root{
|
||||||
Stmts: []node.Node{
|
Stmts: []node.Node{
|
||||||
&stmt.Expression{
|
&stmt.Expression{
|
||||||
Expr: &expr.PostDec{
|
Expr: &expr.PostDec{
|
||||||
@ -39,7 +39,7 @@ func TestPostDec(t *testing.T) {
|
|||||||
func TestPostInc(t *testing.T) {
|
func TestPostInc(t *testing.T) {
|
||||||
src := `<? $a++;`
|
src := `<? $a++;`
|
||||||
|
|
||||||
expected := &stmt.StmtList{
|
expected := &node.Root{
|
||||||
Stmts: []node.Node{
|
Stmts: []node.Node{
|
||||||
&stmt.Expression{
|
&stmt.Expression{
|
||||||
Expr: &expr.PostInc{
|
Expr: &expr.PostInc{
|
||||||
@ -63,7 +63,7 @@ func TestPostInc(t *testing.T) {
|
|||||||
func TestPreDec(t *testing.T) {
|
func TestPreDec(t *testing.T) {
|
||||||
src := `<? --$a;`
|
src := `<? --$a;`
|
||||||
|
|
||||||
expected := &stmt.StmtList{
|
expected := &node.Root{
|
||||||
Stmts: []node.Node{
|
Stmts: []node.Node{
|
||||||
&stmt.Expression{
|
&stmt.Expression{
|
||||||
Expr: &expr.PreDec{
|
Expr: &expr.PreDec{
|
||||||
@ -87,7 +87,7 @@ func TestPreDec(t *testing.T) {
|
|||||||
func TestPreInc(t *testing.T) {
|
func TestPreInc(t *testing.T) {
|
||||||
src := `<? ++$a;`
|
src := `<? ++$a;`
|
||||||
|
|
||||||
expected := &stmt.StmtList{
|
expected := &node.Root{
|
||||||
Stmts: []node.Node{
|
Stmts: []node.Node{
|
||||||
&stmt.Expression{
|
&stmt.Expression{
|
||||||
Expr: &expr.PreInc{
|
Expr: &expr.PreInc{
|
||||||
|
@ -15,7 +15,7 @@ import (
|
|||||||
func TestInclude(t *testing.T) {
|
func TestInclude(t *testing.T) {
|
||||||
src := `<? include $a;`
|
src := `<? include $a;`
|
||||||
|
|
||||||
expected := &stmt.StmtList{
|
expected := &node.Root{
|
||||||
Stmts: []node.Node{
|
Stmts: []node.Node{
|
||||||
&stmt.Expression{
|
&stmt.Expression{
|
||||||
Expr: &expr.Include{
|
Expr: &expr.Include{
|
||||||
@ -39,7 +39,7 @@ func TestInclude(t *testing.T) {
|
|||||||
func TestIncludeOnce(t *testing.T) {
|
func TestIncludeOnce(t *testing.T) {
|
||||||
src := `<? include_once $a;`
|
src := `<? include_once $a;`
|
||||||
|
|
||||||
expected := &stmt.StmtList{
|
expected := &node.Root{
|
||||||
Stmts: []node.Node{
|
Stmts: []node.Node{
|
||||||
&stmt.Expression{
|
&stmt.Expression{
|
||||||
Expr: &expr.IncludeOnce{
|
Expr: &expr.IncludeOnce{
|
||||||
@ -63,7 +63,7 @@ func TestIncludeOnce(t *testing.T) {
|
|||||||
func TestRequire(t *testing.T) {
|
func TestRequire(t *testing.T) {
|
||||||
src := `<? require $a;`
|
src := `<? require $a;`
|
||||||
|
|
||||||
expected := &stmt.StmtList{
|
expected := &node.Root{
|
||||||
Stmts: []node.Node{
|
Stmts: []node.Node{
|
||||||
&stmt.Expression{
|
&stmt.Expression{
|
||||||
Expr: &expr.Require{
|
Expr: &expr.Require{
|
||||||
@ -87,7 +87,7 @@ func TestRequire(t *testing.T) {
|
|||||||
func TestRequireOnce(t *testing.T) {
|
func TestRequireOnce(t *testing.T) {
|
||||||
src := `<? require_once $a;`
|
src := `<? require_once $a;`
|
||||||
|
|
||||||
expected := &stmt.StmtList{
|
expected := &node.Root{
|
||||||
Stmts: []node.Node{
|
Stmts: []node.Node{
|
||||||
&stmt.Expression{
|
&stmt.Expression{
|
||||||
Expr: &expr.RequireOnce{
|
Expr: &expr.RequireOnce{
|
||||||
|
@ -17,7 +17,7 @@ import (
|
|||||||
func TestInstanceOf(t *testing.T) {
|
func TestInstanceOf(t *testing.T) {
|
||||||
src := `<? $a instanceof Foo;`
|
src := `<? $a instanceof Foo;`
|
||||||
|
|
||||||
expected := &stmt.StmtList{
|
expected := &node.Root{
|
||||||
Stmts: []node.Node{
|
Stmts: []node.Node{
|
||||||
&stmt.Expression{
|
&stmt.Expression{
|
||||||
Expr: &expr.InstanceOf{
|
Expr: &expr.InstanceOf{
|
||||||
@ -46,7 +46,7 @@ func TestInstanceOf(t *testing.T) {
|
|||||||
func TestInstanceOfRelative(t *testing.T) {
|
func TestInstanceOfRelative(t *testing.T) {
|
||||||
src := `<? $a instanceof namespace\Foo;`
|
src := `<? $a instanceof namespace\Foo;`
|
||||||
|
|
||||||
expected := &stmt.StmtList{
|
expected := &node.Root{
|
||||||
Stmts: []node.Node{
|
Stmts: []node.Node{
|
||||||
&stmt.Expression{
|
&stmt.Expression{
|
||||||
Expr: &expr.InstanceOf{
|
Expr: &expr.InstanceOf{
|
||||||
@ -75,7 +75,7 @@ func TestInstanceOfRelative(t *testing.T) {
|
|||||||
func TestInstanceOfFullyQualified(t *testing.T) {
|
func TestInstanceOfFullyQualified(t *testing.T) {
|
||||||
src := `<? $a instanceof \Foo;`
|
src := `<? $a instanceof \Foo;`
|
||||||
|
|
||||||
expected := &stmt.StmtList{
|
expected := &node.Root{
|
||||||
Stmts: []node.Node{
|
Stmts: []node.Node{
|
||||||
&stmt.Expression{
|
&stmt.Expression{
|
||||||
Expr: &expr.InstanceOf{
|
Expr: &expr.InstanceOf{
|
||||||
|
@ -15,7 +15,7 @@ import (
|
|||||||
func TestIsset(t *testing.T) {
|
func TestIsset(t *testing.T) {
|
||||||
src := `<? isset($a);`
|
src := `<? isset($a);`
|
||||||
|
|
||||||
expected := &stmt.StmtList{
|
expected := &node.Root{
|
||||||
Stmts: []node.Node{
|
Stmts: []node.Node{
|
||||||
&stmt.Expression{
|
&stmt.Expression{
|
||||||
Expr: &expr.Isset{
|
Expr: &expr.Isset{
|
||||||
@ -41,7 +41,7 @@ func TestIsset(t *testing.T) {
|
|||||||
func TestIssetVariables(t *testing.T) {
|
func TestIssetVariables(t *testing.T) {
|
||||||
src := `<? isset($a, $b);`
|
src := `<? isset($a, $b);`
|
||||||
|
|
||||||
expected := &stmt.StmtList{
|
expected := &node.Root{
|
||||||
Stmts: []node.Node{
|
Stmts: []node.Node{
|
||||||
&stmt.Expression{
|
&stmt.Expression{
|
||||||
Expr: &expr.Isset{
|
Expr: &expr.Isset{
|
||||||
|
@ -17,7 +17,7 @@ import (
|
|||||||
func TestEmptyList(t *testing.T) {
|
func TestEmptyList(t *testing.T) {
|
||||||
src := `<? list() = $b;`
|
src := `<? list() = $b;`
|
||||||
|
|
||||||
expected := &stmt.StmtList{
|
expected := &node.Root{
|
||||||
Stmts: []node.Node{
|
Stmts: []node.Node{
|
||||||
&stmt.Expression{
|
&stmt.Expression{
|
||||||
Expr: &assign.Assign{
|
Expr: &assign.Assign{
|
||||||
@ -44,7 +44,7 @@ func TestEmptyList(t *testing.T) {
|
|||||||
func TestList(t *testing.T) {
|
func TestList(t *testing.T) {
|
||||||
src := `<? list($a) = $b;`
|
src := `<? list($a) = $b;`
|
||||||
|
|
||||||
expected := &stmt.StmtList{
|
expected := &node.Root{
|
||||||
Stmts: []node.Node{
|
Stmts: []node.Node{
|
||||||
&stmt.Expression{
|
&stmt.Expression{
|
||||||
Expr: &assign.Assign{
|
Expr: &assign.Assign{
|
||||||
@ -76,7 +76,7 @@ func TestList(t *testing.T) {
|
|||||||
func TestListArrayIndex(t *testing.T) {
|
func TestListArrayIndex(t *testing.T) {
|
||||||
src := `<? list($a[]) = $b;`
|
src := `<? list($a[]) = $b;`
|
||||||
|
|
||||||
expected := &stmt.StmtList{
|
expected := &node.Root{
|
||||||
Stmts: []node.Node{
|
Stmts: []node.Node{
|
||||||
&stmt.Expression{
|
&stmt.Expression{
|
||||||
Expr: &assign.Assign{
|
Expr: &assign.Assign{
|
||||||
@ -110,7 +110,7 @@ func TestListArrayIndex(t *testing.T) {
|
|||||||
func TestListList(t *testing.T) {
|
func TestListList(t *testing.T) {
|
||||||
src := `<? list(list($a)) = $b;`
|
src := `<? list(list($a)) = $b;`
|
||||||
|
|
||||||
expected := &stmt.StmtList{
|
expected := &node.Root{
|
||||||
Stmts: []node.Node{
|
Stmts: []node.Node{
|
||||||
&stmt.Expression{
|
&stmt.Expression{
|
||||||
Expr: &assign.Assign{
|
Expr: &assign.Assign{
|
||||||
|
@ -15,7 +15,7 @@ import (
|
|||||||
func TestMethodCall(t *testing.T) {
|
func TestMethodCall(t *testing.T) {
|
||||||
src := `<? $a->foo();`
|
src := `<? $a->foo();`
|
||||||
|
|
||||||
expected := &stmt.StmtList{
|
expected := &node.Root{
|
||||||
Stmts: []node.Node{
|
Stmts: []node.Node{
|
||||||
&stmt.Expression{
|
&stmt.Expression{
|
||||||
Expr: &expr.MethodCall{
|
Expr: &expr.MethodCall{
|
||||||
|
@ -17,7 +17,7 @@ import (
|
|||||||
func TestNew(t *testing.T) {
|
func TestNew(t *testing.T) {
|
||||||
src := `<? new Foo;`
|
src := `<? new Foo;`
|
||||||
|
|
||||||
expected := &stmt.StmtList{
|
expected := &node.Root{
|
||||||
Stmts: []node.Node{
|
Stmts: []node.Node{
|
||||||
&stmt.Expression{
|
&stmt.Expression{
|
||||||
Expr: &expr.New{
|
Expr: &expr.New{
|
||||||
@ -45,7 +45,7 @@ func TestNew(t *testing.T) {
|
|||||||
func TestNewRelative(t *testing.T) {
|
func TestNewRelative(t *testing.T) {
|
||||||
src := `<? new namespace\Foo();`
|
src := `<? new namespace\Foo();`
|
||||||
|
|
||||||
expected := &stmt.StmtList{
|
expected := &node.Root{
|
||||||
Stmts: []node.Node{
|
Stmts: []node.Node{
|
||||||
&stmt.Expression{
|
&stmt.Expression{
|
||||||
Expr: &expr.New{
|
Expr: &expr.New{
|
||||||
@ -74,7 +74,7 @@ func TestNewRelative(t *testing.T) {
|
|||||||
func TestNewFullyQualified(t *testing.T) {
|
func TestNewFullyQualified(t *testing.T) {
|
||||||
src := `<? new \Foo();`
|
src := `<? new \Foo();`
|
||||||
|
|
||||||
expected := &stmt.StmtList{
|
expected := &node.Root{
|
||||||
Stmts: []node.Node{
|
Stmts: []node.Node{
|
||||||
&stmt.Expression{
|
&stmt.Expression{
|
||||||
Expr: &expr.New{
|
Expr: &expr.New{
|
||||||
@ -103,7 +103,7 @@ func TestNewFullyQualified(t *testing.T) {
|
|||||||
func TestNewAnonymous(t *testing.T) {
|
func TestNewAnonymous(t *testing.T) {
|
||||||
src := `<? new class ($a, ...$b) {};`
|
src := `<? new class ($a, ...$b) {};`
|
||||||
|
|
||||||
expected := &stmt.StmtList{
|
expected := &node.Root{
|
||||||
Stmts: []node.Node{
|
Stmts: []node.Node{
|
||||||
&stmt.Expression{
|
&stmt.Expression{
|
||||||
Expr: &expr.New{
|
Expr: &expr.New{
|
||||||
|
@ -15,7 +15,7 @@ import (
|
|||||||
func TestPrint(t *testing.T) {
|
func TestPrint(t *testing.T) {
|
||||||
src := `<? print($a);`
|
src := `<? print($a);`
|
||||||
|
|
||||||
expected := &stmt.StmtList{
|
expected := &node.Root{
|
||||||
Stmts: []node.Node{
|
Stmts: []node.Node{
|
||||||
&stmt.Expression{
|
&stmt.Expression{
|
||||||
Expr: &expr.Print{
|
Expr: &expr.Print{
|
||||||
|
@ -15,7 +15,7 @@ import (
|
|||||||
func TestPropertyFetch(t *testing.T) {
|
func TestPropertyFetch(t *testing.T) {
|
||||||
src := `<? $a->foo;`
|
src := `<? $a->foo;`
|
||||||
|
|
||||||
expected := &stmt.StmtList{
|
expected := &node.Root{
|
||||||
Stmts: []node.Node{
|
Stmts: []node.Node{
|
||||||
&stmt.Expression{
|
&stmt.Expression{
|
||||||
Expr: &expr.PropertyFetch{
|
Expr: &expr.PropertyFetch{
|
||||||
|
@ -17,7 +17,7 @@ import (
|
|||||||
func TestShellExec(t *testing.T) {
|
func TestShellExec(t *testing.T) {
|
||||||
src := "<? `cmd $a`;"
|
src := "<? `cmd $a`;"
|
||||||
|
|
||||||
expected := &stmt.StmtList{
|
expected := &node.Root{
|
||||||
Stmts: []node.Node{
|
Stmts: []node.Node{
|
||||||
&stmt.Expression{
|
&stmt.Expression{
|
||||||
Expr: &expr.ShellExec{
|
Expr: &expr.ShellExec{
|
||||||
|
@ -17,7 +17,7 @@ import (
|
|||||||
func TestShortArray(t *testing.T) {
|
func TestShortArray(t *testing.T) {
|
||||||
src := `<? [];`
|
src := `<? [];`
|
||||||
|
|
||||||
expected := &stmt.StmtList{
|
expected := &node.Root{
|
||||||
Stmts: []node.Node{
|
Stmts: []node.Node{
|
||||||
&stmt.Expression{
|
&stmt.Expression{
|
||||||
Expr: &expr.ShortArray{
|
Expr: &expr.ShortArray{
|
||||||
@ -41,7 +41,7 @@ func TestShortArray(t *testing.T) {
|
|||||||
func TestShortArrayItem(t *testing.T) {
|
func TestShortArrayItem(t *testing.T) {
|
||||||
src := `<? [1];`
|
src := `<? [1];`
|
||||||
|
|
||||||
expected := &stmt.StmtList{
|
expected := &node.Root{
|
||||||
Stmts: []node.Node{
|
Stmts: []node.Node{
|
||||||
&stmt.Expression{
|
&stmt.Expression{
|
||||||
Expr: &expr.ShortArray{
|
Expr: &expr.ShortArray{
|
||||||
@ -70,7 +70,7 @@ func TestShortArrayItem(t *testing.T) {
|
|||||||
func TestShortArrayItems(t *testing.T) {
|
func TestShortArrayItems(t *testing.T) {
|
||||||
src := `<? [1=>1, &$b,];`
|
src := `<? [1=>1, &$b,];`
|
||||||
|
|
||||||
expected := &stmt.StmtList{
|
expected := &node.Root{
|
||||||
Stmts: []node.Node{
|
Stmts: []node.Node{
|
||||||
&stmt.Expression{
|
&stmt.Expression{
|
||||||
Expr: &expr.ShortArray{
|
Expr: &expr.ShortArray{
|
||||||
|
@ -16,7 +16,7 @@ import (
|
|||||||
func TestShortList(t *testing.T) {
|
func TestShortList(t *testing.T) {
|
||||||
src := `<? [$a] = $b;`
|
src := `<? [$a] = $b;`
|
||||||
|
|
||||||
expected := &stmt.StmtList{
|
expected := &node.Root{
|
||||||
Stmts: []node.Node{
|
Stmts: []node.Node{
|
||||||
&stmt.Expression{
|
&stmt.Expression{
|
||||||
Expr: &assign.Assign{
|
Expr: &assign.Assign{
|
||||||
@ -43,7 +43,7 @@ func TestShortList(t *testing.T) {
|
|||||||
func TestShortListArrayIndex(t *testing.T) {
|
func TestShortListArrayIndex(t *testing.T) {
|
||||||
src := `<? [$a[]] = $b;`
|
src := `<? [$a[]] = $b;`
|
||||||
|
|
||||||
expected := &stmt.StmtList{
|
expected := &node.Root{
|
||||||
Stmts: []node.Node{
|
Stmts: []node.Node{
|
||||||
&stmt.Expression{
|
&stmt.Expression{
|
||||||
Expr: &assign.Assign{
|
Expr: &assign.Assign{
|
||||||
@ -72,7 +72,7 @@ func TestShortListArrayIndex(t *testing.T) {
|
|||||||
func TestShortListList(t *testing.T) {
|
func TestShortListList(t *testing.T) {
|
||||||
src := `<? [list($a)] = $b;`
|
src := `<? [list($a)] = $b;`
|
||||||
|
|
||||||
expected := &stmt.StmtList{
|
expected := &node.Root{
|
||||||
Stmts: []node.Node{
|
Stmts: []node.Node{
|
||||||
&stmt.Expression{
|
&stmt.Expression{
|
||||||
Expr: &assign.Assign{
|
Expr: &assign.Assign{
|
||||||
|
@ -17,7 +17,7 @@ import (
|
|||||||
func TestStaticCall(t *testing.T) {
|
func TestStaticCall(t *testing.T) {
|
||||||
src := `<? Foo::bar();`
|
src := `<? Foo::bar();`
|
||||||
|
|
||||||
expected := &stmt.StmtList{
|
expected := &node.Root{
|
||||||
Stmts: []node.Node{
|
Stmts: []node.Node{
|
||||||
&stmt.Expression{
|
&stmt.Expression{
|
||||||
Expr: &expr.StaticCall{
|
Expr: &expr.StaticCall{
|
||||||
@ -47,7 +47,7 @@ func TestStaticCall(t *testing.T) {
|
|||||||
func TestStaticCallRelative(t *testing.T) {
|
func TestStaticCallRelative(t *testing.T) {
|
||||||
src := `<? namespace\Foo::bar();`
|
src := `<? namespace\Foo::bar();`
|
||||||
|
|
||||||
expected := &stmt.StmtList{
|
expected := &node.Root{
|
||||||
Stmts: []node.Node{
|
Stmts: []node.Node{
|
||||||
&stmt.Expression{
|
&stmt.Expression{
|
||||||
Expr: &expr.StaticCall{
|
Expr: &expr.StaticCall{
|
||||||
@ -77,7 +77,7 @@ func TestStaticCallRelative(t *testing.T) {
|
|||||||
func TestStaticCallFullyQualified(t *testing.T) {
|
func TestStaticCallFullyQualified(t *testing.T) {
|
||||||
src := `<? \Foo::bar();`
|
src := `<? \Foo::bar();`
|
||||||
|
|
||||||
expected := &stmt.StmtList{
|
expected := &node.Root{
|
||||||
Stmts: []node.Node{
|
Stmts: []node.Node{
|
||||||
&stmt.Expression{
|
&stmt.Expression{
|
||||||
Expr: &expr.StaticCall{
|
Expr: &expr.StaticCall{
|
||||||
@ -107,7 +107,7 @@ func TestStaticCallFullyQualified(t *testing.T) {
|
|||||||
func TestStaticCallVar(t *testing.T) {
|
func TestStaticCallVar(t *testing.T) {
|
||||||
src := `<? Foo::$bar();`
|
src := `<? Foo::$bar();`
|
||||||
|
|
||||||
expected := &stmt.StmtList{
|
expected := &node.Root{
|
||||||
Stmts: []node.Node{
|
Stmts: []node.Node{
|
||||||
&stmt.Expression{
|
&stmt.Expression{
|
||||||
Expr: &expr.StaticCall{
|
Expr: &expr.StaticCall{
|
||||||
@ -137,7 +137,7 @@ func TestStaticCallVar(t *testing.T) {
|
|||||||
func TestStaticCallVarVar(t *testing.T) {
|
func TestStaticCallVarVar(t *testing.T) {
|
||||||
src := `<? $foo::$bar();`
|
src := `<? $foo::$bar();`
|
||||||
|
|
||||||
expected := &stmt.StmtList{
|
expected := &node.Root{
|
||||||
Stmts: []node.Node{
|
Stmts: []node.Node{
|
||||||
&stmt.Expression{
|
&stmt.Expression{
|
||||||
Expr: &expr.StaticCall{
|
Expr: &expr.StaticCall{
|
||||||
|
@ -16,7 +16,7 @@ import (
|
|||||||
func TestStaticPropertyFetch(t *testing.T) {
|
func TestStaticPropertyFetch(t *testing.T) {
|
||||||
src := `<? Foo::$bar;`
|
src := `<? Foo::$bar;`
|
||||||
|
|
||||||
expected := &stmt.StmtList{
|
expected := &node.Root{
|
||||||
Stmts: []node.Node{
|
Stmts: []node.Node{
|
||||||
&stmt.Expression{
|
&stmt.Expression{
|
||||||
Expr: &expr.StaticPropertyFetch{
|
Expr: &expr.StaticPropertyFetch{
|
||||||
@ -45,7 +45,7 @@ func TestStaticPropertyFetch(t *testing.T) {
|
|||||||
func TestStaticPropertyFetchRelative(t *testing.T) {
|
func TestStaticPropertyFetchRelative(t *testing.T) {
|
||||||
src := `<? namespace\Foo::$bar;`
|
src := `<? namespace\Foo::$bar;`
|
||||||
|
|
||||||
expected := &stmt.StmtList{
|
expected := &node.Root{
|
||||||
Stmts: []node.Node{
|
Stmts: []node.Node{
|
||||||
&stmt.Expression{
|
&stmt.Expression{
|
||||||
Expr: &expr.StaticPropertyFetch{
|
Expr: &expr.StaticPropertyFetch{
|
||||||
@ -74,7 +74,7 @@ func TestStaticPropertyFetchRelative(t *testing.T) {
|
|||||||
func TestStaticPropertyFetchFullyQualified(t *testing.T) {
|
func TestStaticPropertyFetchFullyQualified(t *testing.T) {
|
||||||
src := `<? \Foo::$bar;`
|
src := `<? \Foo::$bar;`
|
||||||
|
|
||||||
expected := &stmt.StmtList{
|
expected := &node.Root{
|
||||||
Stmts: []node.Node{
|
Stmts: []node.Node{
|
||||||
&stmt.Expression{
|
&stmt.Expression{
|
||||||
Expr: &expr.StaticPropertyFetch{
|
Expr: &expr.StaticPropertyFetch{
|
||||||
|
@ -15,7 +15,7 @@ import (
|
|||||||
func TestTernary(t *testing.T) {
|
func TestTernary(t *testing.T) {
|
||||||
src := `<? $a ? $b : $c;`
|
src := `<? $a ? $b : $c;`
|
||||||
|
|
||||||
expected := &stmt.StmtList{
|
expected := &node.Root{
|
||||||
Stmts: []node.Node{
|
Stmts: []node.Node{
|
||||||
&stmt.Expression{
|
&stmt.Expression{
|
||||||
Expr: &expr.Ternary{
|
Expr: &expr.Ternary{
|
||||||
@ -41,7 +41,7 @@ func TestTernary(t *testing.T) {
|
|||||||
func TestTernarySimple(t *testing.T) {
|
func TestTernarySimple(t *testing.T) {
|
||||||
src := `<? $a ? : $c;`
|
src := `<? $a ? : $c;`
|
||||||
|
|
||||||
expected := &stmt.StmtList{
|
expected := &node.Root{
|
||||||
Stmts: []node.Node{
|
Stmts: []node.Node{
|
||||||
&stmt.Expression{
|
&stmt.Expression{
|
||||||
Expr: &expr.Ternary{
|
Expr: &expr.Ternary{
|
||||||
@ -66,7 +66,7 @@ func TestTernarySimple(t *testing.T) {
|
|||||||
func TestTernaryNestedTrue(t *testing.T) {
|
func TestTernaryNestedTrue(t *testing.T) {
|
||||||
src := `<? $a ? $b ? $c : $d : $e;`
|
src := `<? $a ? $b ? $c : $d : $e;`
|
||||||
|
|
||||||
expected := &stmt.StmtList{
|
expected := &node.Root{
|
||||||
Stmts: []node.Node{
|
Stmts: []node.Node{
|
||||||
&stmt.Expression{
|
&stmt.Expression{
|
||||||
Expr: &expr.Ternary{
|
Expr: &expr.Ternary{
|
||||||
@ -96,7 +96,7 @@ func TestTernaryNestedTrue(t *testing.T) {
|
|||||||
func TestTernaryNestedCond(t *testing.T) {
|
func TestTernaryNestedCond(t *testing.T) {
|
||||||
src := `<? $a ? $b : $c ? $d : $e;`
|
src := `<? $a ? $b : $c ? $d : $e;`
|
||||||
|
|
||||||
expected := &stmt.StmtList{
|
expected := &node.Root{
|
||||||
Stmts: []node.Node{
|
Stmts: []node.Node{
|
||||||
&stmt.Expression{
|
&stmt.Expression{
|
||||||
Expr: &expr.Ternary{
|
Expr: &expr.Ternary{
|
||||||
|
@ -15,7 +15,7 @@ import (
|
|||||||
func TestUnaryMinus(t *testing.T) {
|
func TestUnaryMinus(t *testing.T) {
|
||||||
src := `<? -$a;`
|
src := `<? -$a;`
|
||||||
|
|
||||||
expected := &stmt.StmtList{
|
expected := &node.Root{
|
||||||
Stmts: []node.Node{
|
Stmts: []node.Node{
|
||||||
&stmt.Expression{
|
&stmt.Expression{
|
||||||
Expr: &expr.UnaryMinus{
|
Expr: &expr.UnaryMinus{
|
||||||
@ -39,7 +39,7 @@ func TestUnaryMinus(t *testing.T) {
|
|||||||
func TestUnaryPlus(t *testing.T) {
|
func TestUnaryPlus(t *testing.T) {
|
||||||
src := `<? +$a;`
|
src := `<? +$a;`
|
||||||
|
|
||||||
expected := &stmt.StmtList{
|
expected := &node.Root{
|
||||||
Stmts: []node.Node{
|
Stmts: []node.Node{
|
||||||
&stmt.Expression{
|
&stmt.Expression{
|
||||||
Expr: &expr.UnaryPlus{
|
Expr: &expr.UnaryPlus{
|
||||||
|
@ -15,7 +15,7 @@ import (
|
|||||||
func TestVariable(t *testing.T) {
|
func TestVariable(t *testing.T) {
|
||||||
src := `<? $a;`
|
src := `<? $a;`
|
||||||
|
|
||||||
expected := &stmt.StmtList{
|
expected := &node.Root{
|
||||||
Stmts: []node.Node{
|
Stmts: []node.Node{
|
||||||
&stmt.Expression{
|
&stmt.Expression{
|
||||||
Expr: &expr.Variable{VarName: &node.Identifier{Value: "a"}},
|
Expr: &expr.Variable{VarName: &node.Identifier{Value: "a"}},
|
||||||
@ -37,7 +37,7 @@ func TestVariable(t *testing.T) {
|
|||||||
func TestVariableVariable(t *testing.T) {
|
func TestVariableVariable(t *testing.T) {
|
||||||
src := `<? $$a;`
|
src := `<? $$a;`
|
||||||
|
|
||||||
expected := &stmt.StmtList{
|
expected := &node.Root{
|
||||||
Stmts: []node.Node{
|
Stmts: []node.Node{
|
||||||
&stmt.Expression{
|
&stmt.Expression{
|
||||||
Expr: &expr.Variable{VarName: &expr.Variable{VarName: &node.Identifier{Value: "a"}}},
|
Expr: &expr.Variable{VarName: &expr.Variable{VarName: &node.Identifier{Value: "a"}}},
|
||||||
|
@ -16,7 +16,7 @@ import (
|
|||||||
func TestYield(t *testing.T) {
|
func TestYield(t *testing.T) {
|
||||||
src := `<? yield;`
|
src := `<? yield;`
|
||||||
|
|
||||||
expected := &stmt.StmtList{
|
expected := &node.Root{
|
||||||
Stmts: []node.Node{
|
Stmts: []node.Node{
|
||||||
&stmt.Expression{
|
&stmt.Expression{
|
||||||
Expr: &expr.Yield{},
|
Expr: &expr.Yield{},
|
||||||
@ -38,7 +38,7 @@ func TestYield(t *testing.T) {
|
|||||||
func TestYieldVal(t *testing.T) {
|
func TestYieldVal(t *testing.T) {
|
||||||
src := `<? yield $a;`
|
src := `<? yield $a;`
|
||||||
|
|
||||||
expected := &stmt.StmtList{
|
expected := &node.Root{
|
||||||
Stmts: []node.Node{
|
Stmts: []node.Node{
|
||||||
&stmt.Expression{
|
&stmt.Expression{
|
||||||
Expr: &expr.Yield{
|
Expr: &expr.Yield{
|
||||||
@ -62,7 +62,7 @@ func TestYieldVal(t *testing.T) {
|
|||||||
func TestYieldKeyVal(t *testing.T) {
|
func TestYieldKeyVal(t *testing.T) {
|
||||||
src := `<? yield $a => $b;`
|
src := `<? yield $a => $b;`
|
||||||
|
|
||||||
expected := &stmt.StmtList{
|
expected := &node.Root{
|
||||||
Stmts: []node.Node{
|
Stmts: []node.Node{
|
||||||
&stmt.Expression{
|
&stmt.Expression{
|
||||||
Expr: &expr.Yield{
|
Expr: &expr.Yield{
|
||||||
@ -87,7 +87,7 @@ func TestYieldKeyVal(t *testing.T) {
|
|||||||
func TestYieldExpr(t *testing.T) {
|
func TestYieldExpr(t *testing.T) {
|
||||||
src := `<? yield 1;`
|
src := `<? yield 1;`
|
||||||
|
|
||||||
expected := &stmt.StmtList{
|
expected := &node.Root{
|
||||||
Stmts: []node.Node{
|
Stmts: []node.Node{
|
||||||
&stmt.Expression{
|
&stmt.Expression{
|
||||||
Expr: &expr.Yield{
|
Expr: &expr.Yield{
|
||||||
@ -111,7 +111,7 @@ func TestYieldExpr(t *testing.T) {
|
|||||||
func TestYieldKeyExpr(t *testing.T) {
|
func TestYieldKeyExpr(t *testing.T) {
|
||||||
src := `<? yield $a => 1;`
|
src := `<? yield $a => 1;`
|
||||||
|
|
||||||
expected := &stmt.StmtList{
|
expected := &node.Root{
|
||||||
Stmts: []node.Node{
|
Stmts: []node.Node{
|
||||||
&stmt.Expression{
|
&stmt.Expression{
|
||||||
Expr: &expr.Yield{
|
Expr: &expr.Yield{
|
||||||
@ -136,7 +136,7 @@ func TestYieldKeyExpr(t *testing.T) {
|
|||||||
func TestYieldFrom(t *testing.T) {
|
func TestYieldFrom(t *testing.T) {
|
||||||
src := `<? yield from $a;`
|
src := `<? yield from $a;`
|
||||||
|
|
||||||
expected := &stmt.StmtList{
|
expected := &node.Root{
|
||||||
Stmts: []node.Node{
|
Stmts: []node.Node{
|
||||||
&stmt.Expression{
|
&stmt.Expression{
|
||||||
Expr: &expr.YieldFrom{
|
Expr: &expr.YieldFrom{
|
||||||
|
41
node/n_root.go
Normal file
41
node/n_root.go
Normal file
@ -0,0 +1,41 @@
|
|||||||
|
package node
|
||||||
|
|
||||||
|
import (
|
||||||
|
"github.com/z7zmey/php-parser/walker"
|
||||||
|
)
|
||||||
|
|
||||||
|
// Root node
|
||||||
|
type Root struct {
|
||||||
|
Stmts []Node
|
||||||
|
}
|
||||||
|
|
||||||
|
// NewRoot node constructor
|
||||||
|
func NewRoot(Stmts []Node) *Root {
|
||||||
|
return &Root{
|
||||||
|
Stmts,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Attributes returns node attributes as map
|
||||||
|
func (n *Root) Attributes() map[string]interface{} {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// Walk traverses nodes
|
||||||
|
// Walk is invoked recursively until v.EnterNode returns true
|
||||||
|
func (n *Root) Walk(v walker.Visitor) {
|
||||||
|
if v.EnterNode(n) == false {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
if n.Stmts != nil {
|
||||||
|
vv := v.GetChildrenVisitor("Stmts")
|
||||||
|
for _, nn := range n.Stmts {
|
||||||
|
if nn != nil {
|
||||||
|
nn.Walk(vv)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
v.LeaveNode(n)
|
||||||
|
}
|
@ -31,7 +31,7 @@ func assertEqual(t *testing.T, expected interface{}, actual interface{}) {
|
|||||||
func TestName(t *testing.T) {
|
func TestName(t *testing.T) {
|
||||||
src := `<? foo();`
|
src := `<? foo();`
|
||||||
|
|
||||||
expected := &stmt.StmtList{
|
expected := &node.Root{
|
||||||
Stmts: []node.Node{
|
Stmts: []node.Node{
|
||||||
&stmt.Expression{
|
&stmt.Expression{
|
||||||
Expr: &expr.FunctionCall{
|
Expr: &expr.FunctionCall{
|
||||||
@ -58,7 +58,7 @@ func TestName(t *testing.T) {
|
|||||||
func TestFullyQualified(t *testing.T) {
|
func TestFullyQualified(t *testing.T) {
|
||||||
src := `<? \foo();`
|
src := `<? \foo();`
|
||||||
|
|
||||||
expected := &stmt.StmtList{
|
expected := &node.Root{
|
||||||
Stmts: []node.Node{
|
Stmts: []node.Node{
|
||||||
&stmt.Expression{
|
&stmt.Expression{
|
||||||
Expr: &expr.FunctionCall{
|
Expr: &expr.FunctionCall{
|
||||||
@ -85,7 +85,7 @@ func TestFullyQualified(t *testing.T) {
|
|||||||
func TestRelative(t *testing.T) {
|
func TestRelative(t *testing.T) {
|
||||||
src := `<? namespace\foo();`
|
src := `<? namespace\foo();`
|
||||||
|
|
||||||
expected := &stmt.StmtList{
|
expected := &node.Root{
|
||||||
Stmts: []node.Node{
|
Stmts: []node.Node{
|
||||||
&stmt.Expression{
|
&stmt.Expression{
|
||||||
Expr: &expr.FunctionCall{
|
Expr: &expr.FunctionCall{
|
||||||
|
@ -16,7 +16,7 @@ import (
|
|||||||
func TestSimpleVar(t *testing.T) {
|
func TestSimpleVar(t *testing.T) {
|
||||||
src := `<? "test $var";`
|
src := `<? "test $var";`
|
||||||
|
|
||||||
expected := &stmt.StmtList{
|
expected := &node.Root{
|
||||||
Stmts: []node.Node{
|
Stmts: []node.Node{
|
||||||
&stmt.Expression{
|
&stmt.Expression{
|
||||||
Expr: &scalar.Encapsed{
|
Expr: &scalar.Encapsed{
|
||||||
@ -43,7 +43,7 @@ func TestSimpleVar(t *testing.T) {
|
|||||||
func TestSimpleVarOneChar(t *testing.T) {
|
func TestSimpleVarOneChar(t *testing.T) {
|
||||||
src := `<? "test $a";`
|
src := `<? "test $a";`
|
||||||
|
|
||||||
expected := &stmt.StmtList{
|
expected := &node.Root{
|
||||||
Stmts: []node.Node{
|
Stmts: []node.Node{
|
||||||
&stmt.Expression{
|
&stmt.Expression{
|
||||||
Expr: &scalar.Encapsed{
|
Expr: &scalar.Encapsed{
|
||||||
@ -70,7 +70,7 @@ func TestSimpleVarOneChar(t *testing.T) {
|
|||||||
func TestSimpleVarEndsEcapsed(t *testing.T) {
|
func TestSimpleVarEndsEcapsed(t *testing.T) {
|
||||||
src := `<? "test $var\"";`
|
src := `<? "test $var\"";`
|
||||||
|
|
||||||
expected := &stmt.StmtList{
|
expected := &node.Root{
|
||||||
Stmts: []node.Node{
|
Stmts: []node.Node{
|
||||||
&stmt.Expression{
|
&stmt.Expression{
|
||||||
Expr: &scalar.Encapsed{
|
Expr: &scalar.Encapsed{
|
||||||
@ -98,7 +98,7 @@ func TestSimpleVarEndsEcapsed(t *testing.T) {
|
|||||||
func TestStringVarCurveOpen(t *testing.T) {
|
func TestStringVarCurveOpen(t *testing.T) {
|
||||||
src := `<? "=$a{$b}";`
|
src := `<? "=$a{$b}";`
|
||||||
|
|
||||||
expected := &stmt.StmtList{
|
expected := &node.Root{
|
||||||
Stmts: []node.Node{
|
Stmts: []node.Node{
|
||||||
&stmt.Expression{
|
&stmt.Expression{
|
||||||
Expr: &scalar.Encapsed{
|
Expr: &scalar.Encapsed{
|
||||||
@ -126,7 +126,7 @@ func TestStringVarCurveOpen(t *testing.T) {
|
|||||||
func TestSimpleVarPropertyFetch(t *testing.T) {
|
func TestSimpleVarPropertyFetch(t *testing.T) {
|
||||||
src := `<? "test $foo->bar()";`
|
src := `<? "test $foo->bar()";`
|
||||||
|
|
||||||
expected := &stmt.StmtList{
|
expected := &node.Root{
|
||||||
Stmts: []node.Node{
|
Stmts: []node.Node{
|
||||||
&stmt.Expression{
|
&stmt.Expression{
|
||||||
Expr: &scalar.Encapsed{
|
Expr: &scalar.Encapsed{
|
||||||
@ -157,7 +157,7 @@ func TestSimpleVarPropertyFetch(t *testing.T) {
|
|||||||
func TestDollarOpenCurlyBraces(t *testing.T) {
|
func TestDollarOpenCurlyBraces(t *testing.T) {
|
||||||
src := `<? "test ${foo}";`
|
src := `<? "test ${foo}";`
|
||||||
|
|
||||||
expected := &stmt.StmtList{
|
expected := &node.Root{
|
||||||
Stmts: []node.Node{
|
Stmts: []node.Node{
|
||||||
&stmt.Expression{
|
&stmt.Expression{
|
||||||
Expr: &scalar.Encapsed{
|
Expr: &scalar.Encapsed{
|
||||||
@ -184,7 +184,7 @@ func TestDollarOpenCurlyBraces(t *testing.T) {
|
|||||||
func TestDollarOpenCurlyBracesDimNumber(t *testing.T) {
|
func TestDollarOpenCurlyBracesDimNumber(t *testing.T) {
|
||||||
src := `<? "test ${foo[0]}";`
|
src := `<? "test ${foo[0]}";`
|
||||||
|
|
||||||
expected := &stmt.StmtList{
|
expected := &node.Root{
|
||||||
Stmts: []node.Node{
|
Stmts: []node.Node{
|
||||||
&stmt.Expression{
|
&stmt.Expression{
|
||||||
Expr: &scalar.Encapsed{
|
Expr: &scalar.Encapsed{
|
||||||
@ -214,7 +214,7 @@ func TestDollarOpenCurlyBracesDimNumber(t *testing.T) {
|
|||||||
func TestCurlyOpenMethodCall(t *testing.T) {
|
func TestCurlyOpenMethodCall(t *testing.T) {
|
||||||
src := `<? "test {$foo->bar()}";`
|
src := `<? "test {$foo->bar()}";`
|
||||||
|
|
||||||
expected := &stmt.StmtList{
|
expected := &node.Root{
|
||||||
Stmts: []node.Node{
|
Stmts: []node.Node{
|
||||||
&stmt.Expression{
|
&stmt.Expression{
|
||||||
Expr: &scalar.Encapsed{
|
Expr: &scalar.Encapsed{
|
||||||
|
@ -19,7 +19,7 @@ test $var
|
|||||||
LBL;
|
LBL;
|
||||||
`
|
`
|
||||||
|
|
||||||
expected := &stmt.StmtList{
|
expected := &node.Root{
|
||||||
Stmts: []node.Node{
|
Stmts: []node.Node{
|
||||||
&stmt.Expression{
|
&stmt.Expression{
|
||||||
Expr: &scalar.Heredoc{
|
Expr: &scalar.Heredoc{
|
||||||
@ -51,7 +51,7 @@ test $var
|
|||||||
LBL;
|
LBL;
|
||||||
`
|
`
|
||||||
|
|
||||||
expected := &stmt.StmtList{
|
expected := &node.Root{
|
||||||
Stmts: []node.Node{
|
Stmts: []node.Node{
|
||||||
&stmt.Expression{
|
&stmt.Expression{
|
||||||
Expr: &scalar.Heredoc{
|
Expr: &scalar.Heredoc{
|
||||||
@ -83,7 +83,7 @@ test $var
|
|||||||
LBL;
|
LBL;
|
||||||
`
|
`
|
||||||
|
|
||||||
expected := &stmt.StmtList{
|
expected := &node.Root{
|
||||||
Stmts: []node.Node{
|
Stmts: []node.Node{
|
||||||
&stmt.Expression{
|
&stmt.Expression{
|
||||||
Expr: &scalar.Heredoc{
|
Expr: &scalar.Heredoc{
|
||||||
@ -112,7 +112,7 @@ func TestEmptyHeredoc(t *testing.T) {
|
|||||||
CAD;
|
CAD;
|
||||||
`
|
`
|
||||||
|
|
||||||
expected := &stmt.StmtList{
|
expected := &node.Root{
|
||||||
Stmts: []node.Node{
|
Stmts: []node.Node{
|
||||||
&stmt.Expression{
|
&stmt.Expression{
|
||||||
Expr: &scalar.Heredoc{
|
Expr: &scalar.Heredoc{
|
||||||
@ -139,7 +139,7 @@ func TestHeredocScalarString(t *testing.T) {
|
|||||||
CAD;
|
CAD;
|
||||||
`
|
`
|
||||||
|
|
||||||
expected := &stmt.StmtList{
|
expected := &node.Root{
|
||||||
Stmts: []node.Node{
|
Stmts: []node.Node{
|
||||||
&stmt.Expression{
|
&stmt.Expression{
|
||||||
Expr: &scalar.Heredoc{
|
Expr: &scalar.Heredoc{
|
||||||
|
@ -15,7 +15,7 @@ func TestMagicConstant(t *testing.T) {
|
|||||||
// TODO: test all magic constants
|
// TODO: test all magic constants
|
||||||
src := `<? __DIR__;`
|
src := `<? __DIR__;`
|
||||||
|
|
||||||
expected := &stmt.StmtList{
|
expected := &node.Root{
|
||||||
Stmts: []node.Node{
|
Stmts: []node.Node{
|
||||||
&stmt.Expression{
|
&stmt.Expression{
|
||||||
Expr: &scalar.MagicConstant{Value: "__DIR__"},
|
Expr: &scalar.MagicConstant{Value: "__DIR__"},
|
||||||
|
@ -29,7 +29,7 @@ func assertEqual(t *testing.T, expected interface{}, actual interface{}) {
|
|||||||
func TestLNumber(t *testing.T) {
|
func TestLNumber(t *testing.T) {
|
||||||
src := `<? 1234567890123456789;`
|
src := `<? 1234567890123456789;`
|
||||||
|
|
||||||
expected := &stmt.StmtList{
|
expected := &node.Root{
|
||||||
Stmts: []node.Node{
|
Stmts: []node.Node{
|
||||||
&stmt.Expression{
|
&stmt.Expression{
|
||||||
Expr: &scalar.Lnumber{Value: "1234567890123456789"},
|
Expr: &scalar.Lnumber{Value: "1234567890123456789"},
|
||||||
@ -51,7 +51,7 @@ func TestLNumber(t *testing.T) {
|
|||||||
func TestDNumber(t *testing.T) {
|
func TestDNumber(t *testing.T) {
|
||||||
src := `<? 12345678901234567890;`
|
src := `<? 12345678901234567890;`
|
||||||
|
|
||||||
expected := &stmt.StmtList{
|
expected := &node.Root{
|
||||||
Stmts: []node.Node{
|
Stmts: []node.Node{
|
||||||
&stmt.Expression{
|
&stmt.Expression{
|
||||||
Expr: &scalar.Dnumber{Value: "12345678901234567890"},
|
Expr: &scalar.Dnumber{Value: "12345678901234567890"},
|
||||||
@ -73,7 +73,7 @@ func TestDNumber(t *testing.T) {
|
|||||||
func TestFloat(t *testing.T) {
|
func TestFloat(t *testing.T) {
|
||||||
src := `<? 0.;`
|
src := `<? 0.;`
|
||||||
|
|
||||||
expected := &stmt.StmtList{
|
expected := &node.Root{
|
||||||
Stmts: []node.Node{
|
Stmts: []node.Node{
|
||||||
&stmt.Expression{
|
&stmt.Expression{
|
||||||
Expr: &scalar.Dnumber{Value: "0."},
|
Expr: &scalar.Dnumber{Value: "0."},
|
||||||
@ -95,7 +95,7 @@ func TestFloat(t *testing.T) {
|
|||||||
func TestBinaryLNumber(t *testing.T) {
|
func TestBinaryLNumber(t *testing.T) {
|
||||||
src := `<? 0b0111111111111111111111111111111111111111111111111111111111111111;`
|
src := `<? 0b0111111111111111111111111111111111111111111111111111111111111111;`
|
||||||
|
|
||||||
expected := &stmt.StmtList{
|
expected := &node.Root{
|
||||||
Stmts: []node.Node{
|
Stmts: []node.Node{
|
||||||
&stmt.Expression{
|
&stmt.Expression{
|
||||||
Expr: &scalar.Lnumber{Value: "0b0111111111111111111111111111111111111111111111111111111111111111"},
|
Expr: &scalar.Lnumber{Value: "0b0111111111111111111111111111111111111111111111111111111111111111"},
|
||||||
@ -117,7 +117,7 @@ func TestBinaryLNumber(t *testing.T) {
|
|||||||
func TestBinaryDNumber(t *testing.T) {
|
func TestBinaryDNumber(t *testing.T) {
|
||||||
src := `<? 0b1111111111111111111111111111111111111111111111111111111111111111;`
|
src := `<? 0b1111111111111111111111111111111111111111111111111111111111111111;`
|
||||||
|
|
||||||
expected := &stmt.StmtList{
|
expected := &node.Root{
|
||||||
Stmts: []node.Node{
|
Stmts: []node.Node{
|
||||||
&stmt.Expression{
|
&stmt.Expression{
|
||||||
Expr: &scalar.Dnumber{Value: "0b1111111111111111111111111111111111111111111111111111111111111111"},
|
Expr: &scalar.Dnumber{Value: "0b1111111111111111111111111111111111111111111111111111111111111111"},
|
||||||
@ -139,7 +139,7 @@ func TestBinaryDNumber(t *testing.T) {
|
|||||||
func TestHLNumber(t *testing.T) {
|
func TestHLNumber(t *testing.T) {
|
||||||
src := `<? 0x007111111111111111;`
|
src := `<? 0x007111111111111111;`
|
||||||
|
|
||||||
expected := &stmt.StmtList{
|
expected := &node.Root{
|
||||||
Stmts: []node.Node{
|
Stmts: []node.Node{
|
||||||
&stmt.Expression{
|
&stmt.Expression{
|
||||||
Expr: &scalar.Lnumber{Value: "0x007111111111111111"},
|
Expr: &scalar.Lnumber{Value: "0x007111111111111111"},
|
||||||
@ -161,7 +161,7 @@ func TestHLNumber(t *testing.T) {
|
|||||||
func TestHDNumber(t *testing.T) {
|
func TestHDNumber(t *testing.T) {
|
||||||
src := `<? 0x8111111111111111;`
|
src := `<? 0x8111111111111111;`
|
||||||
|
|
||||||
expected := &stmt.StmtList{
|
expected := &node.Root{
|
||||||
Stmts: []node.Node{
|
Stmts: []node.Node{
|
||||||
&stmt.Expression{
|
&stmt.Expression{
|
||||||
Expr: &scalar.Dnumber{Value: "0x8111111111111111"},
|
Expr: &scalar.Dnumber{Value: "0x8111111111111111"},
|
||||||
|
@ -14,7 +14,7 @@ import (
|
|||||||
func TestDoubleQuotedScalarString(t *testing.T) {
|
func TestDoubleQuotedScalarString(t *testing.T) {
|
||||||
src := `<? "test";`
|
src := `<? "test";`
|
||||||
|
|
||||||
expected := &stmt.StmtList{
|
expected := &node.Root{
|
||||||
Stmts: []node.Node{
|
Stmts: []node.Node{
|
||||||
&stmt.Expression{
|
&stmt.Expression{
|
||||||
Expr: &scalar.String{Value: "\"test\""},
|
Expr: &scalar.String{Value: "\"test\""},
|
||||||
@ -35,7 +35,7 @@ func TestDoubleQuotedScalarString(t *testing.T) {
|
|||||||
func TestDoubleQuotedScalarStringWithEscapedVar(t *testing.T) {
|
func TestDoubleQuotedScalarStringWithEscapedVar(t *testing.T) {
|
||||||
src := `<? "\$test";`
|
src := `<? "\$test";`
|
||||||
|
|
||||||
expected := &stmt.StmtList{
|
expected := &node.Root{
|
||||||
Stmts: []node.Node{
|
Stmts: []node.Node{
|
||||||
&stmt.Expression{
|
&stmt.Expression{
|
||||||
Expr: &scalar.String{Value: "\"\\$test\""},
|
Expr: &scalar.String{Value: "\"\\$test\""},
|
||||||
@ -59,7 +59,7 @@ func TestMultilineDoubleQuotedScalarString(t *testing.T) {
|
|||||||
test
|
test
|
||||||
";`
|
";`
|
||||||
|
|
||||||
expected := &stmt.StmtList{
|
expected := &node.Root{
|
||||||
Stmts: []node.Node{
|
Stmts: []node.Node{
|
||||||
&stmt.Expression{
|
&stmt.Expression{
|
||||||
Expr: &scalar.String{Value: "\"\n\ttest\n\t\""},
|
Expr: &scalar.String{Value: "\"\n\ttest\n\t\""},
|
||||||
@ -81,7 +81,7 @@ func TestMultilineDoubleQuotedScalarString(t *testing.T) {
|
|||||||
func TestSingleQuotedScalarString(t *testing.T) {
|
func TestSingleQuotedScalarString(t *testing.T) {
|
||||||
src := `<? '$test';`
|
src := `<? '$test';`
|
||||||
|
|
||||||
expected := &stmt.StmtList{
|
expected := &node.Root{
|
||||||
Stmts: []node.Node{
|
Stmts: []node.Node{
|
||||||
&stmt.Expression{
|
&stmt.Expression{
|
||||||
Expr: &scalar.String{Value: "'$test'"},
|
Expr: &scalar.String{Value: "'$test'"},
|
||||||
@ -105,7 +105,7 @@ func TestMultilineSingleQuotedScalarString(t *testing.T) {
|
|||||||
$test
|
$test
|
||||||
';`
|
';`
|
||||||
|
|
||||||
expected := &stmt.StmtList{
|
expected := &node.Root{
|
||||||
Stmts: []node.Node{
|
Stmts: []node.Node{
|
||||||
&stmt.Expression{
|
&stmt.Expression{
|
||||||
Expr: &scalar.String{Value: "'\n\t$test\n\t'"},
|
Expr: &scalar.String{Value: "'\n\t$test\n\t'"},
|
||||||
|
@ -33,7 +33,7 @@ func TestAltIf(t *testing.T) {
|
|||||||
endif;
|
endif;
|
||||||
`
|
`
|
||||||
|
|
||||||
expected := &stmt.StmtList{
|
expected := &node.Root{
|
||||||
Stmts: []node.Node{
|
Stmts: []node.Node{
|
||||||
&stmt.AltIf{
|
&stmt.AltIf{
|
||||||
Cond: &expr.Variable{VarName: &node.Identifier{Value: "a"}},
|
Cond: &expr.Variable{VarName: &node.Identifier{Value: "a"}},
|
||||||
@ -60,7 +60,7 @@ func TestAltElseIf(t *testing.T) {
|
|||||||
endif;
|
endif;
|
||||||
`
|
`
|
||||||
|
|
||||||
expected := &stmt.StmtList{
|
expected := &node.Root{
|
||||||
Stmts: []node.Node{
|
Stmts: []node.Node{
|
||||||
&stmt.AltIf{
|
&stmt.AltIf{
|
||||||
Cond: &expr.Variable{VarName: &node.Identifier{Value: "a"}},
|
Cond: &expr.Variable{VarName: &node.Identifier{Value: "a"}},
|
||||||
@ -93,7 +93,7 @@ func TestAltElse(t *testing.T) {
|
|||||||
endif;
|
endif;
|
||||||
`
|
`
|
||||||
|
|
||||||
expected := &stmt.StmtList{
|
expected := &node.Root{
|
||||||
Stmts: []node.Node{
|
Stmts: []node.Node{
|
||||||
&stmt.AltIf{
|
&stmt.AltIf{
|
||||||
Cond: &expr.Variable{VarName: &node.Identifier{Value: "a"}},
|
Cond: &expr.Variable{VarName: &node.Identifier{Value: "a"}},
|
||||||
@ -125,7 +125,7 @@ func TestAltElseElseIf(t *testing.T) {
|
|||||||
endif;
|
endif;
|
||||||
`
|
`
|
||||||
|
|
||||||
expected := &stmt.StmtList{
|
expected := &node.Root{
|
||||||
Stmts: []node.Node{
|
Stmts: []node.Node{
|
||||||
&stmt.AltIf{
|
&stmt.AltIf{
|
||||||
Cond: &expr.Variable{VarName: &node.Identifier{Value: "a"}},
|
Cond: &expr.Variable{VarName: &node.Identifier{Value: "a"}},
|
||||||
|
@ -15,7 +15,7 @@ import (
|
|||||||
func TestClassConstList(t *testing.T) {
|
func TestClassConstList(t *testing.T) {
|
||||||
src := `<? class foo{ public const FOO = 1, BAR = 2; }`
|
src := `<? class foo{ public const FOO = 1, BAR = 2; }`
|
||||||
|
|
||||||
expected := &stmt.StmtList{
|
expected := &node.Root{
|
||||||
Stmts: []node.Node{
|
Stmts: []node.Node{
|
||||||
&stmt.Class{
|
&stmt.Class{
|
||||||
ClassName: &node.Identifier{Value: "foo"},
|
ClassName: &node.Identifier{Value: "foo"},
|
||||||
@ -51,7 +51,7 @@ func TestClassConstList(t *testing.T) {
|
|||||||
func TestClassConstListWithoutModifiers(t *testing.T) {
|
func TestClassConstListWithoutModifiers(t *testing.T) {
|
||||||
src := `<? class foo{ const FOO = 1, BAR = 2; }`
|
src := `<? class foo{ const FOO = 1, BAR = 2; }`
|
||||||
|
|
||||||
expected := &stmt.StmtList{
|
expected := &node.Root{
|
||||||
Stmts: []node.Node{
|
Stmts: []node.Node{
|
||||||
&stmt.Class{
|
&stmt.Class{
|
||||||
ClassName: &node.Identifier{Value: "foo"},
|
ClassName: &node.Identifier{Value: "foo"},
|
||||||
|
@ -14,7 +14,7 @@ import (
|
|||||||
func TestSimpleClassMethod(t *testing.T) {
|
func TestSimpleClassMethod(t *testing.T) {
|
||||||
src := `<? class foo{ function bar() {} }`
|
src := `<? class foo{ function bar() {} }`
|
||||||
|
|
||||||
expected := &stmt.StmtList{
|
expected := &node.Root{
|
||||||
Stmts: []node.Node{
|
Stmts: []node.Node{
|
||||||
&stmt.Class{
|
&stmt.Class{
|
||||||
ClassName: &node.Identifier{Value: "foo"},
|
ClassName: &node.Identifier{Value: "foo"},
|
||||||
@ -43,7 +43,7 @@ func TestSimpleClassMethod(t *testing.T) {
|
|||||||
func TestPrivateProtectedClassMethod(t *testing.T) {
|
func TestPrivateProtectedClassMethod(t *testing.T) {
|
||||||
src := `<? class foo{ final private function bar() {} protected function baz() {} }`
|
src := `<? class foo{ final private function bar() {} protected function baz() {} }`
|
||||||
|
|
||||||
expected := &stmt.StmtList{
|
expected := &node.Root{
|
||||||
Stmts: []node.Node{
|
Stmts: []node.Node{
|
||||||
&stmt.Class{
|
&stmt.Class{
|
||||||
ClassName: &node.Identifier{Value: "foo"},
|
ClassName: &node.Identifier{Value: "foo"},
|
||||||
@ -86,7 +86,7 @@ func TestPrivateProtectedClassMethod(t *testing.T) {
|
|||||||
func TestPhp5ClassMethod(t *testing.T) {
|
func TestPhp5ClassMethod(t *testing.T) {
|
||||||
src := `<? class foo{ public static function &bar() {} }`
|
src := `<? class foo{ public static function &bar() {} }`
|
||||||
|
|
||||||
expected := &stmt.StmtList{
|
expected := &node.Root{
|
||||||
Stmts: []node.Node{
|
Stmts: []node.Node{
|
||||||
&stmt.Class{
|
&stmt.Class{
|
||||||
ClassName: &node.Identifier{Value: "foo"},
|
ClassName: &node.Identifier{Value: "foo"},
|
||||||
@ -115,7 +115,7 @@ func TestPhp5ClassMethod(t *testing.T) {
|
|||||||
func TestPhp7ClassMethod(t *testing.T) {
|
func TestPhp7ClassMethod(t *testing.T) {
|
||||||
src := `<? class foo{ public static function &bar(): void {} }`
|
src := `<? class foo{ public static function &bar(): void {} }`
|
||||||
|
|
||||||
expected := &stmt.StmtList{
|
expected := &node.Root{
|
||||||
Stmts: []node.Node{
|
Stmts: []node.Node{
|
||||||
&stmt.Class{
|
&stmt.Class{
|
||||||
ClassName: &node.Identifier{Value: "foo"},
|
ClassName: &node.Identifier{Value: "foo"},
|
||||||
@ -149,7 +149,7 @@ func TestPhp7ClassMethod(t *testing.T) {
|
|||||||
func TestAbstractClassMethod(t *testing.T) {
|
func TestAbstractClassMethod(t *testing.T) {
|
||||||
src := `<? abstract class Foo{ abstract public function bar(); }`
|
src := `<? abstract class Foo{ abstract public function bar(); }`
|
||||||
|
|
||||||
expected := &stmt.StmtList{
|
expected := &node.Root{
|
||||||
Stmts: []node.Node{
|
Stmts: []node.Node{
|
||||||
&stmt.Class{
|
&stmt.Class{
|
||||||
Modifiers: []node.Node{&node.Identifier{Value: "abstract"}},
|
Modifiers: []node.Node{&node.Identifier{Value: "abstract"}},
|
||||||
@ -183,7 +183,7 @@ func TestAbstractClassMethod(t *testing.T) {
|
|||||||
func TestPhp7AbstractClassMethod(t *testing.T) {
|
func TestPhp7AbstractClassMethod(t *testing.T) {
|
||||||
src := `<? abstract class Foo{ public function bar(): void; }`
|
src := `<? abstract class Foo{ public function bar(): void; }`
|
||||||
|
|
||||||
expected := &stmt.StmtList{
|
expected := &node.Root{
|
||||||
Stmts: []node.Node{
|
Stmts: []node.Node{
|
||||||
&stmt.Class{
|
&stmt.Class{
|
||||||
Modifiers: []node.Node{&node.Identifier{Value: "abstract"}},
|
Modifiers: []node.Node{&node.Identifier{Value: "abstract"}},
|
||||||
|
@ -16,7 +16,7 @@ import (
|
|||||||
func TestSimpleClass(t *testing.T) {
|
func TestSimpleClass(t *testing.T) {
|
||||||
src := `<? class foo{ }`
|
src := `<? class foo{ }`
|
||||||
|
|
||||||
expected := &stmt.StmtList{
|
expected := &node.Root{
|
||||||
Stmts: []node.Node{
|
Stmts: []node.Node{
|
||||||
&stmt.Class{
|
&stmt.Class{
|
||||||
ClassName: &node.Identifier{Value: "foo"},
|
ClassName: &node.Identifier{Value: "foo"},
|
||||||
@ -39,7 +39,7 @@ func TestSimpleClass(t *testing.T) {
|
|||||||
func TestAbstractClass(t *testing.T) {
|
func TestAbstractClass(t *testing.T) {
|
||||||
src := `<? abstract class foo{ }`
|
src := `<? abstract class foo{ }`
|
||||||
|
|
||||||
expected := &stmt.StmtList{
|
expected := &node.Root{
|
||||||
Stmts: []node.Node{
|
Stmts: []node.Node{
|
||||||
&stmt.Class{
|
&stmt.Class{
|
||||||
ClassName: &node.Identifier{Value: "foo"},
|
ClassName: &node.Identifier{Value: "foo"},
|
||||||
@ -65,7 +65,7 @@ func TestAbstractClass(t *testing.T) {
|
|||||||
func TestClassExtends(t *testing.T) {
|
func TestClassExtends(t *testing.T) {
|
||||||
src := `<? final class foo extends bar { }`
|
src := `<? final class foo extends bar { }`
|
||||||
|
|
||||||
expected := &stmt.StmtList{
|
expected := &node.Root{
|
||||||
Stmts: []node.Node{
|
Stmts: []node.Node{
|
||||||
&stmt.Class{
|
&stmt.Class{
|
||||||
ClassName: &node.Identifier{Value: "foo"},
|
ClassName: &node.Identifier{Value: "foo"},
|
||||||
@ -96,7 +96,7 @@ func TestClassExtends(t *testing.T) {
|
|||||||
func TestClassImplement(t *testing.T) {
|
func TestClassImplement(t *testing.T) {
|
||||||
src := `<? final class foo implements bar { }`
|
src := `<? final class foo implements bar { }`
|
||||||
|
|
||||||
expected := &stmt.StmtList{
|
expected := &node.Root{
|
||||||
Stmts: []node.Node{
|
Stmts: []node.Node{
|
||||||
&stmt.Class{
|
&stmt.Class{
|
||||||
ClassName: &node.Identifier{Value: "foo"},
|
ClassName: &node.Identifier{Value: "foo"},
|
||||||
@ -129,7 +129,7 @@ func TestClassImplement(t *testing.T) {
|
|||||||
func TestClassImplements(t *testing.T) {
|
func TestClassImplements(t *testing.T) {
|
||||||
src := `<? final class foo implements bar, baz { }`
|
src := `<? final class foo implements bar, baz { }`
|
||||||
|
|
||||||
expected := &stmt.StmtList{
|
expected := &node.Root{
|
||||||
Stmts: []node.Node{
|
Stmts: []node.Node{
|
||||||
&stmt.Class{
|
&stmt.Class{
|
||||||
ClassName: &node.Identifier{Value: "foo"},
|
ClassName: &node.Identifier{Value: "foo"},
|
||||||
@ -167,7 +167,7 @@ func TestClassImplements(t *testing.T) {
|
|||||||
func TestAnonimousClass(t *testing.T) {
|
func TestAnonimousClass(t *testing.T) {
|
||||||
src := `<? new class() extends foo implements bar, baz { };`
|
src := `<? new class() extends foo implements bar, baz { };`
|
||||||
|
|
||||||
expected := &stmt.StmtList{
|
expected := &node.Root{
|
||||||
Stmts: []node.Node{
|
Stmts: []node.Node{
|
||||||
&stmt.Expression{
|
&stmt.Expression{
|
||||||
Expr: &expr.New{
|
Expr: &expr.New{
|
||||||
|
@ -15,7 +15,7 @@ import (
|
|||||||
func TestConstList(t *testing.T) {
|
func TestConstList(t *testing.T) {
|
||||||
src := `<? const FOO = 1, BAR = 2;`
|
src := `<? const FOO = 1, BAR = 2;`
|
||||||
|
|
||||||
expected := &stmt.StmtList{
|
expected := &node.Root{
|
||||||
Stmts: []node.Node{
|
Stmts: []node.Node{
|
||||||
&stmt.ConstList{
|
&stmt.ConstList{
|
||||||
Consts: []node.Node{
|
Consts: []node.Node{
|
||||||
|
@ -15,7 +15,7 @@ import (
|
|||||||
func TestContinueEmpty(t *testing.T) {
|
func TestContinueEmpty(t *testing.T) {
|
||||||
src := `<? while (1) { continue; }`
|
src := `<? while (1) { continue; }`
|
||||||
|
|
||||||
expected := &stmt.StmtList{
|
expected := &node.Root{
|
||||||
Stmts: []node.Node{
|
Stmts: []node.Node{
|
||||||
&stmt.While{
|
&stmt.While{
|
||||||
Cond: &scalar.Lnumber{Value: "1"},
|
Cond: &scalar.Lnumber{Value: "1"},
|
||||||
@ -42,7 +42,7 @@ func TestContinueEmpty(t *testing.T) {
|
|||||||
func TestContinueLight(t *testing.T) {
|
func TestContinueLight(t *testing.T) {
|
||||||
src := `<? while (1) { continue 2; }`
|
src := `<? while (1) { continue 2; }`
|
||||||
|
|
||||||
expected := &stmt.StmtList{
|
expected := &node.Root{
|
||||||
Stmts: []node.Node{
|
Stmts: []node.Node{
|
||||||
&stmt.While{
|
&stmt.While{
|
||||||
Cond: &scalar.Lnumber{Value: "1"},
|
Cond: &scalar.Lnumber{Value: "1"},
|
||||||
@ -71,7 +71,7 @@ func TestContinueLight(t *testing.T) {
|
|||||||
func TestContinue(t *testing.T) {
|
func TestContinue(t *testing.T) {
|
||||||
src := `<? while (1) { continue(3); }`
|
src := `<? while (1) { continue(3); }`
|
||||||
|
|
||||||
expected := &stmt.StmtList{
|
expected := &node.Root{
|
||||||
Stmts: []node.Node{
|
Stmts: []node.Node{
|
||||||
&stmt.While{
|
&stmt.While{
|
||||||
Cond: &scalar.Lnumber{Value: "1"},
|
Cond: &scalar.Lnumber{Value: "1"},
|
||||||
|
@ -15,7 +15,7 @@ import (
|
|||||||
func TestDeclare(t *testing.T) {
|
func TestDeclare(t *testing.T) {
|
||||||
src := `<? declare(ticks=1);`
|
src := `<? declare(ticks=1);`
|
||||||
|
|
||||||
expected := &stmt.StmtList{
|
expected := &node.Root{
|
||||||
Stmts: []node.Node{
|
Stmts: []node.Node{
|
||||||
&stmt.Declare{
|
&stmt.Declare{
|
||||||
Consts: []node.Node{
|
Consts: []node.Node{
|
||||||
@ -44,7 +44,7 @@ func TestDeclare(t *testing.T) {
|
|||||||
func TestDeclareStmts(t *testing.T) {
|
func TestDeclareStmts(t *testing.T) {
|
||||||
src := `<? declare(ticks=1, strict_types=1) {}`
|
src := `<? declare(ticks=1, strict_types=1) {}`
|
||||||
|
|
||||||
expected := &stmt.StmtList{
|
expected := &node.Root{
|
||||||
Stmts: []node.Node{
|
Stmts: []node.Node{
|
||||||
&stmt.Declare{
|
&stmt.Declare{
|
||||||
Consts: []node.Node{
|
Consts: []node.Node{
|
||||||
@ -80,7 +80,7 @@ func TestDeclareStmts(t *testing.T) {
|
|||||||
func TestAltDeclare(t *testing.T) {
|
func TestAltDeclare(t *testing.T) {
|
||||||
src := `<? declare(ticks=1): enddeclare;`
|
src := `<? declare(ticks=1): enddeclare;`
|
||||||
|
|
||||||
expected := &stmt.StmtList{
|
expected := &node.Root{
|
||||||
Stmts: []node.Node{
|
Stmts: []node.Node{
|
||||||
&stmt.Declare{
|
&stmt.Declare{
|
||||||
Consts: []node.Node{
|
Consts: []node.Node{
|
||||||
|
@ -15,7 +15,7 @@ import (
|
|||||||
func TestDo(t *testing.T) {
|
func TestDo(t *testing.T) {
|
||||||
src := `<? do {} while(1);`
|
src := `<? do {} while(1);`
|
||||||
|
|
||||||
expected := &stmt.StmtList{
|
expected := &node.Root{
|
||||||
Stmts: []node.Node{
|
Stmts: []node.Node{
|
||||||
&stmt.Do{
|
&stmt.Do{
|
||||||
Stmt: &stmt.StmtList{
|
Stmt: &stmt.StmtList{
|
||||||
|
@ -17,7 +17,7 @@ import (
|
|||||||
func TestSimpleEcho(t *testing.T) {
|
func TestSimpleEcho(t *testing.T) {
|
||||||
src := `<? echo $a, 1;`
|
src := `<? echo $a, 1;`
|
||||||
|
|
||||||
expected := &stmt.StmtList{
|
expected := &node.Root{
|
||||||
Stmts: []node.Node{
|
Stmts: []node.Node{
|
||||||
&stmt.Echo{
|
&stmt.Echo{
|
||||||
Exprs: []node.Node{
|
Exprs: []node.Node{
|
||||||
@ -44,7 +44,7 @@ func TestSimpleEcho(t *testing.T) {
|
|||||||
func TestEcho(t *testing.T) {
|
func TestEcho(t *testing.T) {
|
||||||
src := `<? echo($a);`
|
src := `<? echo($a);`
|
||||||
|
|
||||||
expected := &stmt.StmtList{
|
expected := &node.Root{
|
||||||
Stmts: []node.Node{
|
Stmts: []node.Node{
|
||||||
&stmt.Echo{
|
&stmt.Echo{
|
||||||
Exprs: []node.Node{
|
Exprs: []node.Node{
|
||||||
|
@ -15,7 +15,7 @@ import (
|
|||||||
func TestExpression(t *testing.T) {
|
func TestExpression(t *testing.T) {
|
||||||
src := `<? 1;`
|
src := `<? 1;`
|
||||||
|
|
||||||
expected := &stmt.StmtList{
|
expected := &node.Root{
|
||||||
Stmts: []node.Node{
|
Stmts: []node.Node{
|
||||||
&stmt.Expression{
|
&stmt.Expression{
|
||||||
Expr: &scalar.Lnumber{Value: "1"},
|
Expr: &scalar.Lnumber{Value: "1"},
|
||||||
|
@ -20,7 +20,7 @@ import (
|
|||||||
func TestFor(t *testing.T) {
|
func TestFor(t *testing.T) {
|
||||||
src := `<? for($i = 0; $i < 10; $i++, $i++) {}`
|
src := `<? for($i = 0; $i < 10; $i++, $i++) {}`
|
||||||
|
|
||||||
expected := &stmt.StmtList{
|
expected := &node.Root{
|
||||||
Stmts: []node.Node{
|
Stmts: []node.Node{
|
||||||
&stmt.For{
|
&stmt.For{
|
||||||
Init: []node.Node{
|
Init: []node.Node{
|
||||||
@ -62,7 +62,7 @@ func TestFor(t *testing.T) {
|
|||||||
func TestAltFor(t *testing.T) {
|
func TestAltFor(t *testing.T) {
|
||||||
src := `<? for(; $i < 10; $i++) : endfor;`
|
src := `<? for(; $i < 10; $i++) : endfor;`
|
||||||
|
|
||||||
expected := &stmt.StmtList{
|
expected := &node.Root{
|
||||||
Stmts: []node.Node{
|
Stmts: []node.Node{
|
||||||
&stmt.AltFor{
|
&stmt.AltFor{
|
||||||
Cond: []node.Node{
|
Cond: []node.Node{
|
||||||
|
@ -15,7 +15,7 @@ import (
|
|||||||
func TestForeach(t *testing.T) {
|
func TestForeach(t *testing.T) {
|
||||||
src := `<? foreach ($a as $v) {}`
|
src := `<? foreach ($a as $v) {}`
|
||||||
|
|
||||||
expected := &stmt.StmtList{
|
expected := &node.Root{
|
||||||
Stmts: []node.Node{
|
Stmts: []node.Node{
|
||||||
&stmt.Foreach{
|
&stmt.Foreach{
|
||||||
Expr: &expr.Variable{VarName: &node.Identifier{Value: "a"}},
|
Expr: &expr.Variable{VarName: &node.Identifier{Value: "a"}},
|
||||||
@ -39,7 +39,7 @@ func TestForeach(t *testing.T) {
|
|||||||
func TestForeachExpr(t *testing.T) {
|
func TestForeachExpr(t *testing.T) {
|
||||||
src := `<? foreach ([] as $v) {}`
|
src := `<? foreach ([] as $v) {}`
|
||||||
|
|
||||||
expected := &stmt.StmtList{
|
expected := &node.Root{
|
||||||
Stmts: []node.Node{
|
Stmts: []node.Node{
|
||||||
&stmt.Foreach{
|
&stmt.Foreach{
|
||||||
Expr: &expr.ShortArray{Items: []node.Node{}},
|
Expr: &expr.ShortArray{Items: []node.Node{}},
|
||||||
@ -63,7 +63,7 @@ func TestForeachExpr(t *testing.T) {
|
|||||||
func TestAltForeach(t *testing.T) {
|
func TestAltForeach(t *testing.T) {
|
||||||
src := `<? foreach ($a as $v) : endforeach;`
|
src := `<? foreach ($a as $v) : endforeach;`
|
||||||
|
|
||||||
expected := &stmt.StmtList{
|
expected := &node.Root{
|
||||||
Stmts: []node.Node{
|
Stmts: []node.Node{
|
||||||
&stmt.AltForeach{
|
&stmt.AltForeach{
|
||||||
Expr: &expr.Variable{VarName: &node.Identifier{Value: "a"}},
|
Expr: &expr.Variable{VarName: &node.Identifier{Value: "a"}},
|
||||||
@ -87,7 +87,7 @@ func TestAltForeach(t *testing.T) {
|
|||||||
func TestForeachWithKey(t *testing.T) {
|
func TestForeachWithKey(t *testing.T) {
|
||||||
src := `<? foreach ($a as $k => $v) {}`
|
src := `<? foreach ($a as $k => $v) {}`
|
||||||
|
|
||||||
expected := &stmt.StmtList{
|
expected := &node.Root{
|
||||||
Stmts: []node.Node{
|
Stmts: []node.Node{
|
||||||
&stmt.Foreach{
|
&stmt.Foreach{
|
||||||
Expr: &expr.Variable{VarName: &node.Identifier{Value: "a"}},
|
Expr: &expr.Variable{VarName: &node.Identifier{Value: "a"}},
|
||||||
@ -112,7 +112,7 @@ func TestForeachWithKey(t *testing.T) {
|
|||||||
func TestForeachExprWithKey(t *testing.T) {
|
func TestForeachExprWithKey(t *testing.T) {
|
||||||
src := `<? foreach ([] as $k => $v) {}`
|
src := `<? foreach ([] as $k => $v) {}`
|
||||||
|
|
||||||
expected := &stmt.StmtList{
|
expected := &node.Root{
|
||||||
Stmts: []node.Node{
|
Stmts: []node.Node{
|
||||||
&stmt.Foreach{
|
&stmt.Foreach{
|
||||||
Expr: &expr.ShortArray{Items: []node.Node{}},
|
Expr: &expr.ShortArray{Items: []node.Node{}},
|
||||||
@ -137,7 +137,7 @@ func TestForeachExprWithKey(t *testing.T) {
|
|||||||
func TestForeachWithRef(t *testing.T) {
|
func TestForeachWithRef(t *testing.T) {
|
||||||
src := `<? foreach ($a as $k => &$v) {}`
|
src := `<? foreach ($a as $k => &$v) {}`
|
||||||
|
|
||||||
expected := &stmt.StmtList{
|
expected := &node.Root{
|
||||||
Stmts: []node.Node{
|
Stmts: []node.Node{
|
||||||
&stmt.Foreach{
|
&stmt.Foreach{
|
||||||
ByRef: true,
|
ByRef: true,
|
||||||
@ -163,7 +163,7 @@ func TestForeachWithRef(t *testing.T) {
|
|||||||
func TestForeachWithList(t *testing.T) {
|
func TestForeachWithList(t *testing.T) {
|
||||||
src := `<? foreach ($a as $k => list($v)) {}`
|
src := `<? foreach ($a as $k => list($v)) {}`
|
||||||
|
|
||||||
expected := &stmt.StmtList{
|
expected := &node.Root{
|
||||||
Stmts: []node.Node{
|
Stmts: []node.Node{
|
||||||
&stmt.Foreach{
|
&stmt.Foreach{
|
||||||
ByRef: false,
|
ByRef: false,
|
||||||
|
@ -17,7 +17,7 @@ import (
|
|||||||
func TestSimpleFunction(t *testing.T) {
|
func TestSimpleFunction(t *testing.T) {
|
||||||
src := `<? function foo() {}`
|
src := `<? function foo() {}`
|
||||||
|
|
||||||
expected := &stmt.StmtList{
|
expected := &node.Root{
|
||||||
Stmts: []node.Node{
|
Stmts: []node.Node{
|
||||||
&stmt.Function{
|
&stmt.Function{
|
||||||
ReturnsRef: false,
|
ReturnsRef: false,
|
||||||
@ -42,7 +42,7 @@ func TestSimpleFunction(t *testing.T) {
|
|||||||
func TestFunctionReturn(t *testing.T) {
|
func TestFunctionReturn(t *testing.T) {
|
||||||
src := `<? function foo() {return;}`
|
src := `<? function foo() {return;}`
|
||||||
|
|
||||||
expected := &stmt.StmtList{
|
expected := &node.Root{
|
||||||
Stmts: []node.Node{
|
Stmts: []node.Node{
|
||||||
&stmt.Function{
|
&stmt.Function{
|
||||||
ReturnsRef: false,
|
ReturnsRef: false,
|
||||||
@ -69,7 +69,7 @@ func TestFunctionReturn(t *testing.T) {
|
|||||||
func TestFunctionReturnVar(t *testing.T) {
|
func TestFunctionReturnVar(t *testing.T) {
|
||||||
src := `<? function foo(array $a, callable $b) {return $a;}`
|
src := `<? function foo(array $a, callable $b) {return $a;}`
|
||||||
|
|
||||||
expected := &stmt.StmtList{
|
expected := &node.Root{
|
||||||
Stmts: []node.Node{
|
Stmts: []node.Node{
|
||||||
&stmt.Function{
|
&stmt.Function{
|
||||||
ReturnsRef: false,
|
ReturnsRef: false,
|
||||||
@ -112,7 +112,7 @@ func TestFunctionReturnVar(t *testing.T) {
|
|||||||
func TestRefFunction(t *testing.T) {
|
func TestRefFunction(t *testing.T) {
|
||||||
src := `<? function &foo() {return 1;}`
|
src := `<? function &foo() {return 1;}`
|
||||||
|
|
||||||
expected := &stmt.StmtList{
|
expected := &node.Root{
|
||||||
Stmts: []node.Node{
|
Stmts: []node.Node{
|
||||||
&stmt.Function{
|
&stmt.Function{
|
||||||
ReturnsRef: true,
|
ReturnsRef: true,
|
||||||
@ -141,7 +141,7 @@ func TestRefFunction(t *testing.T) {
|
|||||||
func TestReturnTypeFunction(t *testing.T) {
|
func TestReturnTypeFunction(t *testing.T) {
|
||||||
src := `<? function &foo(): void {}`
|
src := `<? function &foo(): void {}`
|
||||||
|
|
||||||
expected := &stmt.StmtList{
|
expected := &node.Root{
|
||||||
Stmts: []node.Node{
|
Stmts: []node.Node{
|
||||||
&stmt.Function{
|
&stmt.Function{
|
||||||
ReturnsRef: true,
|
ReturnsRef: true,
|
||||||
|
@ -15,7 +15,7 @@ import (
|
|||||||
func TestGlobal(t *testing.T) {
|
func TestGlobal(t *testing.T) {
|
||||||
src := `<? global $a;`
|
src := `<? global $a;`
|
||||||
|
|
||||||
expected := &stmt.StmtList{
|
expected := &node.Root{
|
||||||
Stmts: []node.Node{
|
Stmts: []node.Node{
|
||||||
&stmt.Global{
|
&stmt.Global{
|
||||||
Vars: []node.Node{
|
Vars: []node.Node{
|
||||||
@ -39,7 +39,7 @@ func TestGlobal(t *testing.T) {
|
|||||||
func TestGlobalVars(t *testing.T) {
|
func TestGlobalVars(t *testing.T) {
|
||||||
src := `<? global $a, $b, $$c, ${foo()};`
|
src := `<? global $a, $b, $$c, ${foo()};`
|
||||||
|
|
||||||
expected := &stmt.StmtList{
|
expected := &node.Root{
|
||||||
Stmts: []node.Node{
|
Stmts: []node.Node{
|
||||||
&stmt.Global{
|
&stmt.Global{
|
||||||
Vars: []node.Node{
|
Vars: []node.Node{
|
||||||
|
@ -13,7 +13,7 @@ import (
|
|||||||
func TestGotoLabel(t *testing.T) {
|
func TestGotoLabel(t *testing.T) {
|
||||||
src := `<? a: goto a;`
|
src := `<? a: goto a;`
|
||||||
|
|
||||||
expected := &stmt.StmtList{
|
expected := &node.Root{
|
||||||
Stmts: []node.Node{
|
Stmts: []node.Node{
|
||||||
&stmt.Label{
|
&stmt.Label{
|
||||||
LabelName: &node.Identifier{Value: "a"},
|
LabelName: &node.Identifier{Value: "a"},
|
||||||
|
@ -13,7 +13,7 @@ import (
|
|||||||
func TestHaltCompiler(t *testing.T) {
|
func TestHaltCompiler(t *testing.T) {
|
||||||
src := `<? __halt_compiler();`
|
src := `<? __halt_compiler();`
|
||||||
|
|
||||||
expected := &stmt.StmtList{
|
expected := &node.Root{
|
||||||
Stmts: []node.Node{
|
Stmts: []node.Node{
|
||||||
&stmt.HaltCompiler{},
|
&stmt.HaltCompiler{},
|
||||||
},
|
},
|
||||||
|
@ -15,7 +15,7 @@ import (
|
|||||||
func TestIf(t *testing.T) {
|
func TestIf(t *testing.T) {
|
||||||
src := `<? if ($a) {}`
|
src := `<? if ($a) {}`
|
||||||
|
|
||||||
expected := &stmt.StmtList{
|
expected := &node.Root{
|
||||||
Stmts: []node.Node{
|
Stmts: []node.Node{
|
||||||
&stmt.If{
|
&stmt.If{
|
||||||
Cond: &expr.Variable{VarName: &node.Identifier{Value: "a"}},
|
Cond: &expr.Variable{VarName: &node.Identifier{Value: "a"}},
|
||||||
@ -39,7 +39,7 @@ func TestElseIf(t *testing.T) {
|
|||||||
src := `<? if ($a) {} elseif ($b) {}
|
src := `<? if ($a) {} elseif ($b) {}
|
||||||
`
|
`
|
||||||
|
|
||||||
expected := &stmt.StmtList{
|
expected := &node.Root{
|
||||||
Stmts: []node.Node{
|
Stmts: []node.Node{
|
||||||
&stmt.If{
|
&stmt.If{
|
||||||
Cond: &expr.Variable{VarName: &node.Identifier{Value: "a"}},
|
Cond: &expr.Variable{VarName: &node.Identifier{Value: "a"}},
|
||||||
@ -68,7 +68,7 @@ func TestElseIf(t *testing.T) {
|
|||||||
func TestElse(t *testing.T) {
|
func TestElse(t *testing.T) {
|
||||||
src := `<? if ($a) {} else {}`
|
src := `<? if ($a) {} else {}`
|
||||||
|
|
||||||
expected := &stmt.StmtList{
|
expected := &node.Root{
|
||||||
Stmts: []node.Node{
|
Stmts: []node.Node{
|
||||||
&stmt.If{
|
&stmt.If{
|
||||||
Cond: &expr.Variable{VarName: &node.Identifier{Value: "a"}},
|
Cond: &expr.Variable{VarName: &node.Identifier{Value: "a"}},
|
||||||
@ -94,7 +94,7 @@ func TestElse(t *testing.T) {
|
|||||||
func TestElseElseIf(t *testing.T) {
|
func TestElseElseIf(t *testing.T) {
|
||||||
src := `<? if ($a) {} elseif ($b) {} elseif ($c) {} else {}`
|
src := `<? if ($a) {} elseif ($b) {} elseif ($c) {} else {}`
|
||||||
|
|
||||||
expected := &stmt.StmtList{
|
expected := &node.Root{
|
||||||
Stmts: []node.Node{
|
Stmts: []node.Node{
|
||||||
&stmt.If{
|
&stmt.If{
|
||||||
Cond: &expr.Variable{VarName: &node.Identifier{Value: "a"}},
|
Cond: &expr.Variable{VarName: &node.Identifier{Value: "a"}},
|
||||||
@ -130,7 +130,7 @@ func TestElseElseIf(t *testing.T) {
|
|||||||
func TestElseIfElseIfElse(t *testing.T) {
|
func TestElseIfElseIfElse(t *testing.T) {
|
||||||
src := `<? if ($a) {} elseif ($b) {} else if ($c) {} else {}`
|
src := `<? if ($a) {} elseif ($b) {} else if ($c) {} else {}`
|
||||||
|
|
||||||
expected := &stmt.StmtList{
|
expected := &node.Root{
|
||||||
Stmts: []node.Node{
|
Stmts: []node.Node{
|
||||||
&stmt.If{
|
&stmt.If{
|
||||||
Cond: &expr.Variable{VarName: &node.Identifier{Value: "a"}},
|
Cond: &expr.Variable{VarName: &node.Identifier{Value: "a"}},
|
||||||
|
@ -13,7 +13,7 @@ import (
|
|||||||
func TestInlineHtml(t *testing.T) {
|
func TestInlineHtml(t *testing.T) {
|
||||||
src := `<? ?> <div></div>`
|
src := `<? ?> <div></div>`
|
||||||
|
|
||||||
expected := &stmt.StmtList{
|
expected := &node.Root{
|
||||||
Stmts: []node.Node{
|
Stmts: []node.Node{
|
||||||
&stmt.Nop{},
|
&stmt.Nop{},
|
||||||
&stmt.InlineHtml{Value: "<div></div>"},
|
&stmt.InlineHtml{Value: "<div></div>"},
|
||||||
|
@ -14,7 +14,7 @@ import (
|
|||||||
func TestInterface(t *testing.T) {
|
func TestInterface(t *testing.T) {
|
||||||
src := `<? interface Foo {}`
|
src := `<? interface Foo {}`
|
||||||
|
|
||||||
expected := &stmt.StmtList{
|
expected := &node.Root{
|
||||||
Stmts: []node.Node{
|
Stmts: []node.Node{
|
||||||
&stmt.Interface{
|
&stmt.Interface{
|
||||||
PhpDocComment: "",
|
PhpDocComment: "",
|
||||||
@ -38,7 +38,7 @@ func TestInterface(t *testing.T) {
|
|||||||
func TestInterfaceExtend(t *testing.T) {
|
func TestInterfaceExtend(t *testing.T) {
|
||||||
src := `<? interface Foo extends Bar {}`
|
src := `<? interface Foo extends Bar {}`
|
||||||
|
|
||||||
expected := &stmt.StmtList{
|
expected := &node.Root{
|
||||||
Stmts: []node.Node{
|
Stmts: []node.Node{
|
||||||
&stmt.Interface{
|
&stmt.Interface{
|
||||||
PhpDocComment: "",
|
PhpDocComment: "",
|
||||||
@ -69,7 +69,7 @@ func TestInterfaceExtend(t *testing.T) {
|
|||||||
func TestInterfaceExtends(t *testing.T) {
|
func TestInterfaceExtends(t *testing.T) {
|
||||||
src := `<? interface Foo extends Bar, Baz {}`
|
src := `<? interface Foo extends Bar, Baz {}`
|
||||||
|
|
||||||
expected := &stmt.StmtList{
|
expected := &node.Root{
|
||||||
Stmts: []node.Node{
|
Stmts: []node.Node{
|
||||||
&stmt.Interface{
|
&stmt.Interface{
|
||||||
PhpDocComment: "",
|
PhpDocComment: "",
|
||||||
|
@ -14,7 +14,7 @@ import (
|
|||||||
func TestNamespace(t *testing.T) {
|
func TestNamespace(t *testing.T) {
|
||||||
src := `<? namespace Foo;`
|
src := `<? namespace Foo;`
|
||||||
|
|
||||||
expected := &stmt.StmtList{
|
expected := &node.Root{
|
||||||
Stmts: []node.Node{
|
Stmts: []node.Node{
|
||||||
&stmt.Namespace{
|
&stmt.Namespace{
|
||||||
NamespaceName: &name.Name{
|
NamespaceName: &name.Name{
|
||||||
@ -40,7 +40,7 @@ func TestNamespace(t *testing.T) {
|
|||||||
func TestNamespaceStmts(t *testing.T) {
|
func TestNamespaceStmts(t *testing.T) {
|
||||||
src := `<? namespace Foo {}`
|
src := `<? namespace Foo {}`
|
||||||
|
|
||||||
expected := &stmt.StmtList{
|
expected := &node.Root{
|
||||||
Stmts: []node.Node{
|
Stmts: []node.Node{
|
||||||
&stmt.Namespace{
|
&stmt.Namespace{
|
||||||
NamespaceName: &name.Name{
|
NamespaceName: &name.Name{
|
||||||
@ -67,7 +67,7 @@ func TestNamespaceStmts(t *testing.T) {
|
|||||||
func TestAnonymousNamespace(t *testing.T) {
|
func TestAnonymousNamespace(t *testing.T) {
|
||||||
src := `<? namespace {}`
|
src := `<? namespace {}`
|
||||||
|
|
||||||
expected := &stmt.StmtList{
|
expected := &node.Root{
|
||||||
Stmts: []node.Node{
|
Stmts: []node.Node{
|
||||||
&stmt.Namespace{
|
&stmt.Namespace{
|
||||||
Stmts: []node.Node{},
|
Stmts: []node.Node{},
|
||||||
|
@ -15,7 +15,7 @@ import (
|
|||||||
func TestProperty(t *testing.T) {
|
func TestProperty(t *testing.T) {
|
||||||
src := `<? class foo {var $a;}`
|
src := `<? class foo {var $a;}`
|
||||||
|
|
||||||
expected := &stmt.StmtList{
|
expected := &node.Root{
|
||||||
Stmts: []node.Node{
|
Stmts: []node.Node{
|
||||||
&stmt.Class{
|
&stmt.Class{
|
||||||
ClassName: &node.Identifier{Value: "foo"},
|
ClassName: &node.Identifier{Value: "foo"},
|
||||||
@ -50,7 +50,7 @@ func TestProperty(t *testing.T) {
|
|||||||
func TestProperties(t *testing.T) {
|
func TestProperties(t *testing.T) {
|
||||||
src := `<? class foo {public static $a, $b = 1;}`
|
src := `<? class foo {public static $a, $b = 1;}`
|
||||||
|
|
||||||
expected := &stmt.StmtList{
|
expected := &node.Root{
|
||||||
Stmts: []node.Node{
|
Stmts: []node.Node{
|
||||||
&stmt.Class{
|
&stmt.Class{
|
||||||
ClassName: &node.Identifier{Value: "foo"},
|
ClassName: &node.Identifier{Value: "foo"},
|
||||||
@ -91,7 +91,7 @@ func TestProperties(t *testing.T) {
|
|||||||
func TestProperties2(t *testing.T) {
|
func TestProperties2(t *testing.T) {
|
||||||
src := `<? class foo {public static $a = 1, $b;}`
|
src := `<? class foo {public static $a = 1, $b;}`
|
||||||
|
|
||||||
expected := &stmt.StmtList{
|
expected := &node.Root{
|
||||||
Stmts: []node.Node{
|
Stmts: []node.Node{
|
||||||
&stmt.Class{
|
&stmt.Class{
|
||||||
ClassName: &node.Identifier{Value: "foo"},
|
ClassName: &node.Identifier{Value: "foo"},
|
||||||
|
@ -15,7 +15,7 @@ import (
|
|||||||
func TestStaticVar(t *testing.T) {
|
func TestStaticVar(t *testing.T) {
|
||||||
src := `<? static $a;`
|
src := `<? static $a;`
|
||||||
|
|
||||||
expected := &stmt.StmtList{
|
expected := &node.Root{
|
||||||
Stmts: []node.Node{
|
Stmts: []node.Node{
|
||||||
&stmt.Static{
|
&stmt.Static{
|
||||||
Vars: []node.Node{
|
Vars: []node.Node{
|
||||||
@ -41,7 +41,7 @@ func TestStaticVar(t *testing.T) {
|
|||||||
func TestStaticVars(t *testing.T) {
|
func TestStaticVars(t *testing.T) {
|
||||||
src := `<? static $a, $b = 1;`
|
src := `<? static $a, $b = 1;`
|
||||||
|
|
||||||
expected := &stmt.StmtList{
|
expected := &node.Root{
|
||||||
Stmts: []node.Node{
|
Stmts: []node.Node{
|
||||||
&stmt.Static{
|
&stmt.Static{
|
||||||
Vars: []node.Node{
|
Vars: []node.Node{
|
||||||
@ -71,7 +71,7 @@ func TestStaticVars(t *testing.T) {
|
|||||||
func TestStaticVars2(t *testing.T) {
|
func TestStaticVars2(t *testing.T) {
|
||||||
src := `<? static $a = 1, $b;`
|
src := `<? static $a = 1, $b;`
|
||||||
|
|
||||||
expected := &stmt.StmtList{
|
expected := &node.Root{
|
||||||
Stmts: []node.Node{
|
Stmts: []node.Node{
|
||||||
&stmt.Static{
|
&stmt.Static{
|
||||||
Vars: []node.Node{
|
Vars: []node.Node{
|
||||||
|
@ -21,7 +21,7 @@ func TestAltSwitch(t *testing.T) {
|
|||||||
endswitch;
|
endswitch;
|
||||||
`
|
`
|
||||||
|
|
||||||
expected := &stmt.StmtList{
|
expected := &node.Root{
|
||||||
Stmts: []node.Node{
|
Stmts: []node.Node{
|
||||||
&stmt.AltSwitch{
|
&stmt.AltSwitch{
|
||||||
Cond: &scalar.Lnumber{Value: "1"},
|
Cond: &scalar.Lnumber{Value: "1"},
|
||||||
@ -63,7 +63,7 @@ func TestAltSwitchSemicolon(t *testing.T) {
|
|||||||
endswitch;
|
endswitch;
|
||||||
`
|
`
|
||||||
|
|
||||||
expected := &stmt.StmtList{
|
expected := &node.Root{
|
||||||
Stmts: []node.Node{
|
Stmts: []node.Node{
|
||||||
&stmt.AltSwitch{
|
&stmt.AltSwitch{
|
||||||
Cond: &scalar.Lnumber{Value: "1"},
|
Cond: &scalar.Lnumber{Value: "1"},
|
||||||
@ -102,7 +102,7 @@ func TestSwitch(t *testing.T) {
|
|||||||
}
|
}
|
||||||
`
|
`
|
||||||
|
|
||||||
expected := &stmt.StmtList{
|
expected := &node.Root{
|
||||||
Stmts: []node.Node{
|
Stmts: []node.Node{
|
||||||
&stmt.Switch{
|
&stmt.Switch{
|
||||||
Cond: &scalar.Lnumber{Value: "1"},
|
Cond: &scalar.Lnumber{Value: "1"},
|
||||||
@ -145,7 +145,7 @@ func TestSwitchSemicolon(t *testing.T) {
|
|||||||
}
|
}
|
||||||
`
|
`
|
||||||
|
|
||||||
expected := &stmt.StmtList{
|
expected := &node.Root{
|
||||||
Stmts: []node.Node{
|
Stmts: []node.Node{
|
||||||
&stmt.Switch{
|
&stmt.Switch{
|
||||||
Cond: &scalar.Lnumber{Value: "1"},
|
Cond: &scalar.Lnumber{Value: "1"},
|
||||||
|
@ -14,7 +14,7 @@ import (
|
|||||||
func TestThrow(t *testing.T) {
|
func TestThrow(t *testing.T) {
|
||||||
src := `<? throw $e;`
|
src := `<? throw $e;`
|
||||||
|
|
||||||
expected := &stmt.StmtList{
|
expected := &node.Root{
|
||||||
Stmts: []node.Node{
|
Stmts: []node.Node{
|
||||||
&stmt.Throw{
|
&stmt.Throw{
|
||||||
Expr: &expr.Variable{VarName: &node.Identifier{Value: "e"}},
|
Expr: &expr.Variable{VarName: &node.Identifier{Value: "e"}},
|
||||||
|
@ -13,7 +13,7 @@ import (
|
|||||||
func TestTrait(t *testing.T) {
|
func TestTrait(t *testing.T) {
|
||||||
src := `<? trait Foo {}`
|
src := `<? trait Foo {}`
|
||||||
|
|
||||||
expected := &stmt.StmtList{
|
expected := &node.Root{
|
||||||
Stmts: []node.Node{
|
Stmts: []node.Node{
|
||||||
&stmt.Trait{
|
&stmt.Trait{
|
||||||
PhpDocComment: "",
|
PhpDocComment: "",
|
||||||
|
@ -15,7 +15,7 @@ import (
|
|||||||
func TestTraitUse(t *testing.T) {
|
func TestTraitUse(t *testing.T) {
|
||||||
src := `<? class Foo { use Bar; }`
|
src := `<? class Foo { use Bar; }`
|
||||||
|
|
||||||
expected := &stmt.StmtList{
|
expected := &node.Root{
|
||||||
Stmts: []node.Node{
|
Stmts: []node.Node{
|
||||||
&stmt.Class{
|
&stmt.Class{
|
||||||
PhpDocComment: "",
|
PhpDocComment: "",
|
||||||
@ -49,7 +49,7 @@ func TestTraitUse(t *testing.T) {
|
|||||||
func TestTraitsUse(t *testing.T) {
|
func TestTraitsUse(t *testing.T) {
|
||||||
src := `<? class Foo { use Bar, Baz; }`
|
src := `<? class Foo { use Bar, Baz; }`
|
||||||
|
|
||||||
expected := &stmt.StmtList{
|
expected := &node.Root{
|
||||||
Stmts: []node.Node{
|
Stmts: []node.Node{
|
||||||
&stmt.Class{
|
&stmt.Class{
|
||||||
PhpDocComment: "",
|
PhpDocComment: "",
|
||||||
@ -88,7 +88,7 @@ func TestTraitsUse(t *testing.T) {
|
|||||||
func TestTraitsUseEmptyAdaptations(t *testing.T) {
|
func TestTraitsUseEmptyAdaptations(t *testing.T) {
|
||||||
src := `<? class Foo { use Bar, Baz {} }`
|
src := `<? class Foo { use Bar, Baz {} }`
|
||||||
|
|
||||||
expected := &stmt.StmtList{
|
expected := &node.Root{
|
||||||
Stmts: []node.Node{
|
Stmts: []node.Node{
|
||||||
&stmt.Class{
|
&stmt.Class{
|
||||||
PhpDocComment: "",
|
PhpDocComment: "",
|
||||||
@ -128,7 +128,7 @@ func TestTraitsUseEmptyAdaptations(t *testing.T) {
|
|||||||
func TestTraitsUseModifier(t *testing.T) {
|
func TestTraitsUseModifier(t *testing.T) {
|
||||||
src := `<? class Foo { use Bar, Baz { one as public; } }`
|
src := `<? class Foo { use Bar, Baz { one as public; } }`
|
||||||
|
|
||||||
expected := &stmt.StmtList{
|
expected := &node.Root{
|
||||||
Stmts: []node.Node{
|
Stmts: []node.Node{
|
||||||
&stmt.Class{
|
&stmt.Class{
|
||||||
PhpDocComment: "",
|
PhpDocComment: "",
|
||||||
@ -177,7 +177,7 @@ func TestTraitsUseModifier(t *testing.T) {
|
|||||||
func TestTraitsUseAliasModifier(t *testing.T) {
|
func TestTraitsUseAliasModifier(t *testing.T) {
|
||||||
src := `<? class Foo { use Bar, Baz { one as public two; } }`
|
src := `<? class Foo { use Bar, Baz { one as public two; } }`
|
||||||
|
|
||||||
expected := &stmt.StmtList{
|
expected := &node.Root{
|
||||||
Stmts: []node.Node{
|
Stmts: []node.Node{
|
||||||
&stmt.Class{
|
&stmt.Class{
|
||||||
PhpDocComment: "",
|
PhpDocComment: "",
|
||||||
@ -227,7 +227,7 @@ func TestTraitsUseAliasModifier(t *testing.T) {
|
|||||||
func TestTraitsUseAdaptions(t *testing.T) {
|
func TestTraitsUseAdaptions(t *testing.T) {
|
||||||
src := `<? class Foo { use Bar, Baz { Bar::one insteadof Baz, Quux; Baz::one as two; } }`
|
src := `<? class Foo { use Bar, Baz { Bar::one insteadof Baz, Quux; Baz::one as two; } }`
|
||||||
|
|
||||||
expected := &stmt.StmtList{
|
expected := &node.Root{
|
||||||
Stmts: []node.Node{
|
Stmts: []node.Node{
|
||||||
&stmt.Class{
|
&stmt.Class{
|
||||||
PhpDocComment: "",
|
PhpDocComment: "",
|
||||||
|
@ -17,7 +17,7 @@ func TestTry(t *testing.T) {
|
|||||||
try {}
|
try {}
|
||||||
`
|
`
|
||||||
|
|
||||||
expected := &stmt.StmtList{
|
expected := &node.Root{
|
||||||
Stmts: []node.Node{
|
Stmts: []node.Node{
|
||||||
&stmt.Try{
|
&stmt.Try{
|
||||||
Stmts: []node.Node{},
|
Stmts: []node.Node{},
|
||||||
@ -42,7 +42,7 @@ func TestTryCatch(t *testing.T) {
|
|||||||
try {} catch (Exception $e) {}
|
try {} catch (Exception $e) {}
|
||||||
`
|
`
|
||||||
|
|
||||||
expected := &stmt.StmtList{
|
expected := &node.Root{
|
||||||
Stmts: []node.Node{
|
Stmts: []node.Node{
|
||||||
&stmt.Try{
|
&stmt.Try{
|
||||||
Stmts: []node.Node{},
|
Stmts: []node.Node{},
|
||||||
@ -81,7 +81,7 @@ func TestPhp7TryCatch(t *testing.T) {
|
|||||||
try {} catch (Exception|RuntimeException $e) {}
|
try {} catch (Exception|RuntimeException $e) {}
|
||||||
`
|
`
|
||||||
|
|
||||||
expected := &stmt.StmtList{
|
expected := &node.Root{
|
||||||
Stmts: []node.Node{
|
Stmts: []node.Node{
|
||||||
&stmt.Try{
|
&stmt.Try{
|
||||||
Stmts: []node.Node{},
|
Stmts: []node.Node{},
|
||||||
@ -120,7 +120,7 @@ func TestTryCatchCatch(t *testing.T) {
|
|||||||
try {} catch (Exception $e) {} catch (RuntimeException $e) {}
|
try {} catch (Exception $e) {} catch (RuntimeException $e) {}
|
||||||
`
|
`
|
||||||
|
|
||||||
expected := &stmt.StmtList{
|
expected := &node.Root{
|
||||||
Stmts: []node.Node{
|
Stmts: []node.Node{
|
||||||
&stmt.Try{
|
&stmt.Try{
|
||||||
Stmts: []node.Node{},
|
Stmts: []node.Node{},
|
||||||
@ -172,7 +172,7 @@ func TestTryCatchFinally(t *testing.T) {
|
|||||||
try {} catch (Exception $e) {} finally {}
|
try {} catch (Exception $e) {} finally {}
|
||||||
`
|
`
|
||||||
|
|
||||||
expected := &stmt.StmtList{
|
expected := &node.Root{
|
||||||
Stmts: []node.Node{
|
Stmts: []node.Node{
|
||||||
&stmt.Try{
|
&stmt.Try{
|
||||||
Stmts: []node.Node{},
|
Stmts: []node.Node{},
|
||||||
@ -212,7 +212,7 @@ func TestTryCatchFinally(t *testing.T) {
|
|||||||
func TestTryCatchCatchCatch(t *testing.T) {
|
func TestTryCatchCatchCatch(t *testing.T) {
|
||||||
src := `<? try {} catch (Exception $e) {} catch (\RuntimeException $e) {} catch (namespace\AdditionException $e) {}`
|
src := `<? try {} catch (Exception $e) {} catch (\RuntimeException $e) {} catch (namespace\AdditionException $e) {}`
|
||||||
|
|
||||||
expected := &stmt.StmtList{
|
expected := &node.Root{
|
||||||
Stmts: []node.Node{
|
Stmts: []node.Node{
|
||||||
&stmt.Try{
|
&stmt.Try{
|
||||||
Stmts: []node.Node{},
|
Stmts: []node.Node{},
|
||||||
|
@ -14,7 +14,7 @@ import (
|
|||||||
func TestUnset(t *testing.T) {
|
func TestUnset(t *testing.T) {
|
||||||
src := `<? unset($a);`
|
src := `<? unset($a);`
|
||||||
|
|
||||||
expected := &stmt.StmtList{
|
expected := &node.Root{
|
||||||
Stmts: []node.Node{
|
Stmts: []node.Node{
|
||||||
&stmt.Unset{
|
&stmt.Unset{
|
||||||
Vars: []node.Node{
|
Vars: []node.Node{
|
||||||
@ -38,7 +38,7 @@ func TestUnset(t *testing.T) {
|
|||||||
func TestUnsetVars(t *testing.T) {
|
func TestUnsetVars(t *testing.T) {
|
||||||
src := `<? unset($a, $b);`
|
src := `<? unset($a, $b);`
|
||||||
|
|
||||||
expected := &stmt.StmtList{
|
expected := &node.Root{
|
||||||
Stmts: []node.Node{
|
Stmts: []node.Node{
|
||||||
&stmt.Unset{
|
&stmt.Unset{
|
||||||
Vars: []node.Node{
|
Vars: []node.Node{
|
||||||
@ -63,7 +63,7 @@ func TestUnsetVars(t *testing.T) {
|
|||||||
func TestUnsetTrailingComma(t *testing.T) {
|
func TestUnsetTrailingComma(t *testing.T) {
|
||||||
src := `<? unset($a, $b,);`
|
src := `<? unset($a, $b,);`
|
||||||
|
|
||||||
expected := &stmt.StmtList{
|
expected := &node.Root{
|
||||||
Stmts: []node.Node{
|
Stmts: []node.Node{
|
||||||
&stmt.Unset{
|
&stmt.Unset{
|
||||||
Vars: []node.Node{
|
Vars: []node.Node{
|
||||||
|
@ -14,7 +14,7 @@ import (
|
|||||||
func TestSimpleUse(t *testing.T) {
|
func TestSimpleUse(t *testing.T) {
|
||||||
src := `<? use Foo;`
|
src := `<? use Foo;`
|
||||||
|
|
||||||
expected := &stmt.StmtList{
|
expected := &node.Root{
|
||||||
Stmts: []node.Node{
|
Stmts: []node.Node{
|
||||||
&stmt.UseList{
|
&stmt.UseList{
|
||||||
Uses: []node.Node{
|
Uses: []node.Node{
|
||||||
@ -44,7 +44,7 @@ func TestSimpleUse(t *testing.T) {
|
|||||||
func TestUseFullyQualified(t *testing.T) {
|
func TestUseFullyQualified(t *testing.T) {
|
||||||
src := `<? use \Foo;`
|
src := `<? use \Foo;`
|
||||||
|
|
||||||
expected := &stmt.StmtList{
|
expected := &node.Root{
|
||||||
Stmts: []node.Node{
|
Stmts: []node.Node{
|
||||||
&stmt.UseList{
|
&stmt.UseList{
|
||||||
Uses: []node.Node{
|
Uses: []node.Node{
|
||||||
@ -74,7 +74,7 @@ func TestUseFullyQualified(t *testing.T) {
|
|||||||
func TestUseFullyQualifiedAlias(t *testing.T) {
|
func TestUseFullyQualifiedAlias(t *testing.T) {
|
||||||
src := `<? use \Foo as Bar;`
|
src := `<? use \Foo as Bar;`
|
||||||
|
|
||||||
expected := &stmt.StmtList{
|
expected := &node.Root{
|
||||||
Stmts: []node.Node{
|
Stmts: []node.Node{
|
||||||
&stmt.UseList{
|
&stmt.UseList{
|
||||||
Uses: []node.Node{
|
Uses: []node.Node{
|
||||||
@ -105,7 +105,7 @@ func TestUseFullyQualifiedAlias(t *testing.T) {
|
|||||||
func TestUseList(t *testing.T) {
|
func TestUseList(t *testing.T) {
|
||||||
src := `<? use Foo, Bar;`
|
src := `<? use Foo, Bar;`
|
||||||
|
|
||||||
expected := &stmt.StmtList{
|
expected := &node.Root{
|
||||||
Stmts: []node.Node{
|
Stmts: []node.Node{
|
||||||
&stmt.UseList{
|
&stmt.UseList{
|
||||||
Uses: []node.Node{
|
Uses: []node.Node{
|
||||||
@ -142,7 +142,7 @@ func TestUseList(t *testing.T) {
|
|||||||
func TestUseListAlias(t *testing.T) {
|
func TestUseListAlias(t *testing.T) {
|
||||||
src := `<? use Foo, Bar as Baz;`
|
src := `<? use Foo, Bar as Baz;`
|
||||||
|
|
||||||
expected := &stmt.StmtList{
|
expected := &node.Root{
|
||||||
Stmts: []node.Node{
|
Stmts: []node.Node{
|
||||||
&stmt.UseList{
|
&stmt.UseList{
|
||||||
Uses: []node.Node{
|
Uses: []node.Node{
|
||||||
@ -180,7 +180,7 @@ func TestUseListAlias(t *testing.T) {
|
|||||||
func TestUseListFunctionType(t *testing.T) {
|
func TestUseListFunctionType(t *testing.T) {
|
||||||
src := `<? use function Foo, \Bar;`
|
src := `<? use function Foo, \Bar;`
|
||||||
|
|
||||||
expected := &stmt.StmtList{
|
expected := &node.Root{
|
||||||
Stmts: []node.Node{
|
Stmts: []node.Node{
|
||||||
&stmt.UseList{
|
&stmt.UseList{
|
||||||
UseType: &node.Identifier{Value: "function"},
|
UseType: &node.Identifier{Value: "function"},
|
||||||
@ -218,7 +218,7 @@ func TestUseListFunctionType(t *testing.T) {
|
|||||||
func TestUseListFunctionTypeAliases(t *testing.T) {
|
func TestUseListFunctionTypeAliases(t *testing.T) {
|
||||||
src := `<? use function Foo as foo, \Bar as bar;`
|
src := `<? use function Foo as foo, \Bar as bar;`
|
||||||
|
|
||||||
expected := &stmt.StmtList{
|
expected := &node.Root{
|
||||||
Stmts: []node.Node{
|
Stmts: []node.Node{
|
||||||
&stmt.UseList{
|
&stmt.UseList{
|
||||||
UseType: &node.Identifier{Value: "function"},
|
UseType: &node.Identifier{Value: "function"},
|
||||||
@ -258,7 +258,7 @@ func TestUseListFunctionTypeAliases(t *testing.T) {
|
|||||||
func TestUseListConstType(t *testing.T) {
|
func TestUseListConstType(t *testing.T) {
|
||||||
src := `<? use const Foo, \Bar;`
|
src := `<? use const Foo, \Bar;`
|
||||||
|
|
||||||
expected := &stmt.StmtList{
|
expected := &node.Root{
|
||||||
Stmts: []node.Node{
|
Stmts: []node.Node{
|
||||||
&stmt.UseList{
|
&stmt.UseList{
|
||||||
UseType: &node.Identifier{Value: "const"},
|
UseType: &node.Identifier{Value: "const"},
|
||||||
@ -296,7 +296,7 @@ func TestUseListConstType(t *testing.T) {
|
|||||||
func TestUseListConstTypeAliases(t *testing.T) {
|
func TestUseListConstTypeAliases(t *testing.T) {
|
||||||
src := `<? use const Foo as foo, \Bar as bar;`
|
src := `<? use const Foo as foo, \Bar as bar;`
|
||||||
|
|
||||||
expected := &stmt.StmtList{
|
expected := &node.Root{
|
||||||
Stmts: []node.Node{
|
Stmts: []node.Node{
|
||||||
&stmt.UseList{
|
&stmt.UseList{
|
||||||
UseType: &node.Identifier{Value: "const"},
|
UseType: &node.Identifier{Value: "const"},
|
||||||
@ -336,7 +336,7 @@ func TestUseListConstTypeAliases(t *testing.T) {
|
|||||||
func TestGroupUse(t *testing.T) {
|
func TestGroupUse(t *testing.T) {
|
||||||
src := `<? use Foo\{Bar, Baz};`
|
src := `<? use Foo\{Bar, Baz};`
|
||||||
|
|
||||||
expected := &stmt.StmtList{
|
expected := &node.Root{
|
||||||
Stmts: []node.Node{
|
Stmts: []node.Node{
|
||||||
&stmt.GroupUse{
|
&stmt.GroupUse{
|
||||||
Prefix: &name.Name{
|
Prefix: &name.Name{
|
||||||
@ -373,7 +373,7 @@ func TestGroupUse(t *testing.T) {
|
|||||||
func TestGroupUseAlias(t *testing.T) {
|
func TestGroupUseAlias(t *testing.T) {
|
||||||
src := `<? use Foo\{Bar, Baz as quux};`
|
src := `<? use Foo\{Bar, Baz as quux};`
|
||||||
|
|
||||||
expected := &stmt.StmtList{
|
expected := &node.Root{
|
||||||
Stmts: []node.Node{
|
Stmts: []node.Node{
|
||||||
&stmt.GroupUse{
|
&stmt.GroupUse{
|
||||||
Prefix: &name.Name{
|
Prefix: &name.Name{
|
||||||
@ -411,7 +411,7 @@ func TestGroupUseAlias(t *testing.T) {
|
|||||||
func TestFunctionGroupUse(t *testing.T) {
|
func TestFunctionGroupUse(t *testing.T) {
|
||||||
src := `<? use function Foo\{Bar, Baz};`
|
src := `<? use function Foo\{Bar, Baz};`
|
||||||
|
|
||||||
expected := &stmt.StmtList{
|
expected := &node.Root{
|
||||||
Stmts: []node.Node{
|
Stmts: []node.Node{
|
||||||
&stmt.GroupUse{
|
&stmt.GroupUse{
|
||||||
UseType: &node.Identifier{Value: "function"},
|
UseType: &node.Identifier{Value: "function"},
|
||||||
@ -449,7 +449,7 @@ func TestFunctionGroupUse(t *testing.T) {
|
|||||||
func TestConstGroupUse(t *testing.T) {
|
func TestConstGroupUse(t *testing.T) {
|
||||||
src := `<? use const Foo\{Bar, Baz};`
|
src := `<? use const Foo\{Bar, Baz};`
|
||||||
|
|
||||||
expected := &stmt.StmtList{
|
expected := &node.Root{
|
||||||
Stmts: []node.Node{
|
Stmts: []node.Node{
|
||||||
&stmt.GroupUse{
|
&stmt.GroupUse{
|
||||||
UseType: &node.Identifier{Value: "const"},
|
UseType: &node.Identifier{Value: "const"},
|
||||||
@ -487,7 +487,7 @@ func TestConstGroupUse(t *testing.T) {
|
|||||||
func TestMixedGroupUse(t *testing.T) {
|
func TestMixedGroupUse(t *testing.T) {
|
||||||
src := `<? use Foo\{const Bar, function Baz};`
|
src := `<? use Foo\{const Bar, function Baz};`
|
||||||
|
|
||||||
expected := &stmt.StmtList{
|
expected := &node.Root{
|
||||||
Stmts: []node.Node{
|
Stmts: []node.Node{
|
||||||
&stmt.GroupUse{
|
&stmt.GroupUse{
|
||||||
Prefix: &name.Name{
|
Prefix: &name.Name{
|
||||||
|
@ -15,7 +15,7 @@ import (
|
|||||||
func TestBreakEmpty(t *testing.T) {
|
func TestBreakEmpty(t *testing.T) {
|
||||||
src := `<? while (1) { break; }`
|
src := `<? while (1) { break; }`
|
||||||
|
|
||||||
expected := &stmt.StmtList{
|
expected := &node.Root{
|
||||||
Stmts: []node.Node{
|
Stmts: []node.Node{
|
||||||
&stmt.While{
|
&stmt.While{
|
||||||
Cond: &scalar.Lnumber{Value: "1"},
|
Cond: &scalar.Lnumber{Value: "1"},
|
||||||
@ -42,7 +42,7 @@ func TestBreakEmpty(t *testing.T) {
|
|||||||
func TestBreakLight(t *testing.T) {
|
func TestBreakLight(t *testing.T) {
|
||||||
src := `<? while (1) { break 2; }`
|
src := `<? while (1) { break 2; }`
|
||||||
|
|
||||||
expected := &stmt.StmtList{
|
expected := &node.Root{
|
||||||
Stmts: []node.Node{
|
Stmts: []node.Node{
|
||||||
&stmt.While{
|
&stmt.While{
|
||||||
Cond: &scalar.Lnumber{Value: "1"},
|
Cond: &scalar.Lnumber{Value: "1"},
|
||||||
@ -71,7 +71,7 @@ func TestBreakLight(t *testing.T) {
|
|||||||
func TestBreak(t *testing.T) {
|
func TestBreak(t *testing.T) {
|
||||||
src := `<? while (1) : break(3); endwhile;`
|
src := `<? while (1) : break(3); endwhile;`
|
||||||
|
|
||||||
expected := &stmt.StmtList{
|
expected := &node.Root{
|
||||||
Stmts: []node.Node{
|
Stmts: []node.Node{
|
||||||
&stmt.AltWhile{
|
&stmt.AltWhile{
|
||||||
Cond: &scalar.Lnumber{Value: "1"},
|
Cond: &scalar.Lnumber{Value: "1"},
|
||||||
|
@ -32,7 +32,7 @@ func assertEqual(t *testing.T, expected interface{}, actual interface{}) {
|
|||||||
func TestIdentifier(t *testing.T) {
|
func TestIdentifier(t *testing.T) {
|
||||||
src := `<? $foo;`
|
src := `<? $foo;`
|
||||||
|
|
||||||
expected := &stmt.StmtList{
|
expected := &node.Root{
|
||||||
Stmts: []node.Node{
|
Stmts: []node.Node{
|
||||||
&stmt.Expression{
|
&stmt.Expression{
|
||||||
Expr: &expr.Variable{
|
Expr: &expr.Variable{
|
||||||
@ -65,7 +65,7 @@ func TestPhp7ArgumentNode(t *testing.T) {
|
|||||||
new class ($a, ...$b) {};
|
new class ($a, ...$b) {};
|
||||||
`
|
`
|
||||||
|
|
||||||
expected := &stmt.StmtList{
|
expected := &node.Root{
|
||||||
Stmts: []node.Node{
|
Stmts: []node.Node{
|
||||||
&stmt.Expression{
|
&stmt.Expression{
|
||||||
Expr: &expr.FunctionCall{
|
Expr: &expr.FunctionCall{
|
||||||
@ -169,7 +169,7 @@ func TestPhp5ArgumentNode(t *testing.T) {
|
|||||||
new foo($a, ...$b);
|
new foo($a, ...$b);
|
||||||
`
|
`
|
||||||
|
|
||||||
expected := &stmt.StmtList{
|
expected := &node.Root{
|
||||||
Stmts: []node.Node{
|
Stmts: []node.Node{
|
||||||
&stmt.Expression{
|
&stmt.Expression{
|
||||||
Expr: &expr.FunctionCall{
|
Expr: &expr.FunctionCall{
|
||||||
@ -273,7 +273,7 @@ func TestPhp7ParameterNode(t *testing.T) {
|
|||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
expected := &stmt.StmtList{
|
expected := &node.Root{
|
||||||
Stmts: []node.Node{
|
Stmts: []node.Node{
|
||||||
&stmt.Function{
|
&stmt.Function{
|
||||||
ReturnsRef: false,
|
ReturnsRef: false,
|
||||||
@ -341,7 +341,7 @@ func TestPhp5ParameterNode(t *testing.T) {
|
|||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
expected := &stmt.StmtList{
|
expected := &node.Root{
|
||||||
Stmts: []node.Node{
|
Stmts: []node.Node{
|
||||||
&stmt.Function{
|
&stmt.Function{
|
||||||
ReturnsRef: false,
|
ReturnsRef: false,
|
||||||
@ -388,7 +388,7 @@ func TestPhp5ParameterNode(t *testing.T) {
|
|||||||
func TestCommentEndFile(t *testing.T) {
|
func TestCommentEndFile(t *testing.T) {
|
||||||
src := `<? //comment at the end)`
|
src := `<? //comment at the end)`
|
||||||
|
|
||||||
expected := &stmt.StmtList{
|
expected := &node.Root{
|
||||||
Stmts: []node.Node{},
|
Stmts: []node.Node{},
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -4,6 +4,8 @@ import (
|
|||||||
"reflect"
|
"reflect"
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
|
"github.com/z7zmey/php-parser/node/stmt"
|
||||||
|
|
||||||
"github.com/z7zmey/php-parser/node/scalar"
|
"github.com/z7zmey/php-parser/node/scalar"
|
||||||
"github.com/z7zmey/php-parser/walker"
|
"github.com/z7zmey/php-parser/walker"
|
||||||
|
|
||||||
@ -53,6 +55,13 @@ var nodesToTest = []struct {
|
|||||||
[]string{"Arguments"},
|
[]string{"Arguments"},
|
||||||
map[string]interface{}{},
|
map[string]interface{}{},
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
&node.Root{
|
||||||
|
Stmts: []node.Node{&stmt.Expression{}},
|
||||||
|
},
|
||||||
|
[]string{"Stmts"},
|
||||||
|
map[string]interface{}{},
|
||||||
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
type visitorMock struct {
|
type visitorMock struct {
|
||||||
|
@ -2347,7 +2347,7 @@ yydefault:
|
|||||||
yyDollar = yyS[yypt-1 : yypt+1]
|
yyDollar = yyS[yypt-1 : yypt+1]
|
||||||
//line php5/php5.y:272
|
//line php5/php5.y:272
|
||||||
{
|
{
|
||||||
yylex.(*Parser).rootNode = stmt.NewStmtList(yyDollar[1].list)
|
yylex.(*Parser).rootNode = node.NewRoot(yyDollar[1].list)
|
||||||
yylex.(*Parser).positions.AddPosition(yylex.(*Parser).rootNode, yylex.(*Parser).positionBuilder.NewNodeListPosition(yyDollar[1].list))
|
yylex.(*Parser).positions.AddPosition(yylex.(*Parser).rootNode, yylex.(*Parser).positionBuilder.NewNodeListPosition(yyDollar[1].list))
|
||||||
}
|
}
|
||||||
case 2:
|
case 2:
|
||||||
|
@ -270,7 +270,7 @@ import (
|
|||||||
start:
|
start:
|
||||||
top_statement_list
|
top_statement_list
|
||||||
{
|
{
|
||||||
yylex.(*Parser).rootNode = stmt.NewStmtList($1)
|
yylex.(*Parser).rootNode = node.NewRoot($1)
|
||||||
yylex.(*Parser).positions.AddPosition(yylex.(*Parser).rootNode, yylex.(*Parser).positionBuilder.NewNodeListPosition($1))
|
yylex.(*Parser).positions.AddPosition(yylex.(*Parser).rootNode, yylex.(*Parser).positionBuilder.NewNodeListPosition($1))
|
||||||
}
|
}
|
||||||
;
|
;
|
||||||
|
@ -429,7 +429,7 @@ func TestPhp5(t *testing.T) {
|
|||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
expected := &stmt.StmtList{
|
expected := &node.Root{
|
||||||
Stmts: []node.Node{
|
Stmts: []node.Node{
|
||||||
&stmt.Expression{
|
&stmt.Expression{
|
||||||
Expr: &expr.FunctionCall{
|
Expr: &expr.FunctionCall{
|
||||||
@ -3669,7 +3669,7 @@ func TestPhp5Strings(t *testing.T) {
|
|||||||
';
|
';
|
||||||
`
|
`
|
||||||
|
|
||||||
expected := &stmt.StmtList{
|
expected := &node.Root{
|
||||||
Stmts: []node.Node{
|
Stmts: []node.Node{
|
||||||
&stmt.Expression{
|
&stmt.Expression{
|
||||||
Expr: &scalar.String{Value: "\"test\""},
|
Expr: &scalar.String{Value: "\"test\""},
|
||||||
@ -3713,7 +3713,7 @@ CAD;
|
|||||||
CAD;
|
CAD;
|
||||||
`
|
`
|
||||||
|
|
||||||
expected := &stmt.StmtList{
|
expected := &node.Root{
|
||||||
Stmts: []node.Node{
|
Stmts: []node.Node{
|
||||||
&stmt.Expression{
|
&stmt.Expression{
|
||||||
Expr: &scalar.Heredoc{
|
Expr: &scalar.Heredoc{
|
||||||
|
@ -2135,7 +2135,7 @@ yydefault:
|
|||||||
yyDollar = yyS[yypt-1 : yypt+1]
|
yyDollar = yyS[yypt-1 : yypt+1]
|
||||||
//line php7/php7.y:296
|
//line php7/php7.y:296
|
||||||
{
|
{
|
||||||
yylex.(*Parser).rootNode = stmt.NewStmtList(yyDollar[1].list)
|
yylex.(*Parser).rootNode = node.NewRoot(yyDollar[1].list)
|
||||||
|
|
||||||
// save position
|
// save position
|
||||||
yylex.(*Parser).positions.AddPosition(yylex.(*Parser).rootNode, yylex.(*Parser).positionBuilder.NewNodeListPosition(yyDollar[1].list))
|
yylex.(*Parser).positions.AddPosition(yylex.(*Parser).rootNode, yylex.(*Parser).positionBuilder.NewNodeListPosition(yyDollar[1].list))
|
||||||
|
@ -294,7 +294,7 @@ import (
|
|||||||
start:
|
start:
|
||||||
top_statement_list
|
top_statement_list
|
||||||
{
|
{
|
||||||
yylex.(*Parser).rootNode = stmt.NewStmtList($1)
|
yylex.(*Parser).rootNode = node.NewRoot($1)
|
||||||
|
|
||||||
// save position
|
// save position
|
||||||
yylex.(*Parser).positions.AddPosition(yylex.(*Parser).rootNode, yylex.(*Parser).positionBuilder.NewNodeListPosition($1))
|
yylex.(*Parser).positions.AddPosition(yylex.(*Parser).rootNode, yylex.(*Parser).positionBuilder.NewNodeListPosition($1))
|
||||||
@ -1950,7 +1950,7 @@ class_statement:
|
|||||||
// save position
|
// save position
|
||||||
yylex.(*Parser).positions.AddPosition(name, yylex.(*Parser).positionBuilder.NewTokenPosition($4))
|
yylex.(*Parser).positions.AddPosition(name, yylex.(*Parser).positionBuilder.NewTokenPosition($4))
|
||||||
yylex.(*Parser).positions.AddPosition($$, yylex.(*Parser).positionBuilder.NewOptionalListTokensPosition($1, $2, $10.endToken))
|
yylex.(*Parser).positions.AddPosition($$, yylex.(*Parser).positionBuilder.NewOptionalListTokensPosition($1, $2, $10.endToken))
|
||||||
|
|
||||||
// save comments
|
// save comments
|
||||||
yylex.(*Parser).comments.AddFromToken($$, $2, comment.FunctionToken)
|
yylex.(*Parser).comments.AddFromToken($$, $2, comment.FunctionToken)
|
||||||
if $3.value {
|
if $3.value {
|
||||||
|
@ -397,7 +397,7 @@ func TestPhp7(t *testing.T) {
|
|||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
expected := &stmt.StmtList{
|
expected := &node.Root{
|
||||||
Stmts: []node.Node{
|
Stmts: []node.Node{
|
||||||
&stmt.Expression{
|
&stmt.Expression{
|
||||||
Expr: &expr.FunctionCall{
|
Expr: &expr.FunctionCall{
|
||||||
@ -3241,7 +3241,7 @@ func TestPhp5Strings(t *testing.T) {
|
|||||||
';
|
';
|
||||||
`
|
`
|
||||||
|
|
||||||
expected := &stmt.StmtList{
|
expected := &node.Root{
|
||||||
Stmts: []node.Node{
|
Stmts: []node.Node{
|
||||||
&stmt.Expression{
|
&stmt.Expression{
|
||||||
Expr: &scalar.String{Value: "\"test\""},
|
Expr: &scalar.String{Value: "\"test\""},
|
||||||
@ -3285,7 +3285,7 @@ CAD;
|
|||||||
CAD;
|
CAD;
|
||||||
`
|
`
|
||||||
|
|
||||||
expected := &stmt.StmtList{
|
expected := &node.Root{
|
||||||
Stmts: []node.Node{
|
Stmts: []node.Node{
|
||||||
&stmt.Expression{
|
&stmt.Expression{
|
||||||
Expr: &scalar.Heredoc{
|
Expr: &scalar.Heredoc{
|
||||||
|
@ -30,27 +30,6 @@ func NewPrinter(w io.Writer, indentStr string) *Printer {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (p *Printer) PrintFile(n *stmt.StmtList) {
|
|
||||||
if len(n.Stmts) > 0 {
|
|
||||||
firstStmt := n.Stmts[0]
|
|
||||||
n.Stmts = n.Stmts[1:]
|
|
||||||
|
|
||||||
switch fs := firstStmt.(type) {
|
|
||||||
case *stmt.InlineHtml:
|
|
||||||
io.WriteString(p.w, fs.Value)
|
|
||||||
io.WriteString(p.w, "<?php\n")
|
|
||||||
default:
|
|
||||||
io.WriteString(p.w, "<?php\n")
|
|
||||||
p.printIndent()
|
|
||||||
p.Print(fs)
|
|
||||||
io.WriteString(p.w, "\n")
|
|
||||||
}
|
|
||||||
}
|
|
||||||
p.indentDepth--
|
|
||||||
p.printNodes(n.Stmts)
|
|
||||||
io.WriteString(p.w, "\n")
|
|
||||||
}
|
|
||||||
|
|
||||||
func (p *Printer) Print(n node.Node) {
|
func (p *Printer) Print(n node.Node) {
|
||||||
p.printNode(n)
|
p.printNode(n)
|
||||||
}
|
}
|
||||||
@ -89,6 +68,8 @@ func (p *Printer) printNode(n node.Node) {
|
|||||||
|
|
||||||
// node
|
// node
|
||||||
|
|
||||||
|
case *node.Root:
|
||||||
|
p.printNodeRoot(n)
|
||||||
case *node.Identifier:
|
case *node.Identifier:
|
||||||
p.printNodeIdentifier(n)
|
p.printNodeIdentifier(n)
|
||||||
case *node.Parameter:
|
case *node.Parameter:
|
||||||
@ -433,6 +414,29 @@ func (p *Printer) printNode(n node.Node) {
|
|||||||
|
|
||||||
// node
|
// node
|
||||||
|
|
||||||
|
func (p *Printer) printNodeRoot(n node.Node) {
|
||||||
|
v := n.(*node.Root)
|
||||||
|
|
||||||
|
if len(v.Stmts) > 0 {
|
||||||
|
firstStmt := v.Stmts[0]
|
||||||
|
v.Stmts = v.Stmts[1:]
|
||||||
|
|
||||||
|
switch fs := firstStmt.(type) {
|
||||||
|
case *stmt.InlineHtml:
|
||||||
|
io.WriteString(p.w, fs.Value)
|
||||||
|
io.WriteString(p.w, "<?php\n")
|
||||||
|
default:
|
||||||
|
io.WriteString(p.w, "<?php\n")
|
||||||
|
p.printIndent()
|
||||||
|
p.Print(fs)
|
||||||
|
io.WriteString(p.w, "\n")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
p.indentDepth--
|
||||||
|
p.printNodes(v.Stmts)
|
||||||
|
io.WriteString(p.w, "\n")
|
||||||
|
}
|
||||||
|
|
||||||
func (p *Printer) printNodeIdentifier(n node.Node) {
|
func (p *Printer) printNodeIdentifier(n node.Node) {
|
||||||
v := n.(*node.Identifier).Value
|
v := n.(*node.Identifier).Value
|
||||||
io.WriteString(p.w, v)
|
io.WriteString(p.w, v)
|
||||||
|
@ -19,7 +19,7 @@ func TestPrintFile(t *testing.T) {
|
|||||||
o := bytes.NewBufferString("")
|
o := bytes.NewBufferString("")
|
||||||
|
|
||||||
p := printer.NewPrinter(o, "\t")
|
p := printer.NewPrinter(o, "\t")
|
||||||
p.PrintFile(&stmt.StmtList{
|
p.Print(&node.Root{
|
||||||
Stmts: []node.Node{
|
Stmts: []node.Node{
|
||||||
&stmt.Namespace{
|
&stmt.Namespace{
|
||||||
NamespaceName: &name.Name{
|
NamespaceName: &name.Name{
|
||||||
@ -78,7 +78,7 @@ func TestPrintFileInlineHtml(t *testing.T) {
|
|||||||
o := bytes.NewBufferString("")
|
o := bytes.NewBufferString("")
|
||||||
|
|
||||||
p := printer.NewPrinter(o, " ")
|
p := printer.NewPrinter(o, " ")
|
||||||
p.PrintFile(&stmt.StmtList{
|
p.Print(&node.Root{
|
||||||
Stmts: []node.Node{
|
Stmts: []node.Node{
|
||||||
&stmt.InlineHtml{Value: "<div>HTML</div>"},
|
&stmt.InlineHtml{Value: "<div>HTML</div>"},
|
||||||
&stmt.Expression{
|
&stmt.Expression{
|
||||||
|
@ -39,7 +39,7 @@ func ExampleDumper() {
|
|||||||
nodes.Walk(dumper)
|
nodes.Walk(dumper)
|
||||||
|
|
||||||
// Unordered output:
|
// Unordered output:
|
||||||
//| [*stmt.StmtList]
|
//| [*node.Root]
|
||||||
//| "Position": Pos{Line: 3-11 Pos: 10-143};
|
//| "Position": Pos{Line: 3-11 Pos: 10-143};
|
||||||
//| "Stmts":
|
//| "Stmts":
|
||||||
//| [*stmt.Namespace]
|
//| [*stmt.Namespace]
|
||||||
|
Loading…
Reference in New Issue
Block a user