create Root node
This commit is contained in:
@@ -33,7 +33,7 @@ func TestAltIf(t *testing.T) {
|
||||
endif;
|
||||
`
|
||||
|
||||
expected := &stmt.StmtList{
|
||||
expected := &node.Root{
|
||||
Stmts: []node.Node{
|
||||
&stmt.AltIf{
|
||||
Cond: &expr.Variable{VarName: &node.Identifier{Value: "a"}},
|
||||
@@ -60,7 +60,7 @@ func TestAltElseIf(t *testing.T) {
|
||||
endif;
|
||||
`
|
||||
|
||||
expected := &stmt.StmtList{
|
||||
expected := &node.Root{
|
||||
Stmts: []node.Node{
|
||||
&stmt.AltIf{
|
||||
Cond: &expr.Variable{VarName: &node.Identifier{Value: "a"}},
|
||||
@@ -93,7 +93,7 @@ func TestAltElse(t *testing.T) {
|
||||
endif;
|
||||
`
|
||||
|
||||
expected := &stmt.StmtList{
|
||||
expected := &node.Root{
|
||||
Stmts: []node.Node{
|
||||
&stmt.AltIf{
|
||||
Cond: &expr.Variable{VarName: &node.Identifier{Value: "a"}},
|
||||
@@ -125,7 +125,7 @@ func TestAltElseElseIf(t *testing.T) {
|
||||
endif;
|
||||
`
|
||||
|
||||
expected := &stmt.StmtList{
|
||||
expected := &node.Root{
|
||||
Stmts: []node.Node{
|
||||
&stmt.AltIf{
|
||||
Cond: &expr.Variable{VarName: &node.Identifier{Value: "a"}},
|
||||
|
||||
@@ -15,7 +15,7 @@ import (
|
||||
func TestClassConstList(t *testing.T) {
|
||||
src := `<? class foo{ public const FOO = 1, BAR = 2; }`
|
||||
|
||||
expected := &stmt.StmtList{
|
||||
expected := &node.Root{
|
||||
Stmts: []node.Node{
|
||||
&stmt.Class{
|
||||
ClassName: &node.Identifier{Value: "foo"},
|
||||
@@ -51,7 +51,7 @@ func TestClassConstList(t *testing.T) {
|
||||
func TestClassConstListWithoutModifiers(t *testing.T) {
|
||||
src := `<? class foo{ const FOO = 1, BAR = 2; }`
|
||||
|
||||
expected := &stmt.StmtList{
|
||||
expected := &node.Root{
|
||||
Stmts: []node.Node{
|
||||
&stmt.Class{
|
||||
ClassName: &node.Identifier{Value: "foo"},
|
||||
|
||||
@@ -14,7 +14,7 @@ import (
|
||||
func TestSimpleClassMethod(t *testing.T) {
|
||||
src := `<? class foo{ function bar() {} }`
|
||||
|
||||
expected := &stmt.StmtList{
|
||||
expected := &node.Root{
|
||||
Stmts: []node.Node{
|
||||
&stmt.Class{
|
||||
ClassName: &node.Identifier{Value: "foo"},
|
||||
@@ -43,7 +43,7 @@ func TestSimpleClassMethod(t *testing.T) {
|
||||
func TestPrivateProtectedClassMethod(t *testing.T) {
|
||||
src := `<? class foo{ final private function bar() {} protected function baz() {} }`
|
||||
|
||||
expected := &stmt.StmtList{
|
||||
expected := &node.Root{
|
||||
Stmts: []node.Node{
|
||||
&stmt.Class{
|
||||
ClassName: &node.Identifier{Value: "foo"},
|
||||
@@ -86,7 +86,7 @@ func TestPrivateProtectedClassMethod(t *testing.T) {
|
||||
func TestPhp5ClassMethod(t *testing.T) {
|
||||
src := `<? class foo{ public static function &bar() {} }`
|
||||
|
||||
expected := &stmt.StmtList{
|
||||
expected := &node.Root{
|
||||
Stmts: []node.Node{
|
||||
&stmt.Class{
|
||||
ClassName: &node.Identifier{Value: "foo"},
|
||||
@@ -115,7 +115,7 @@ func TestPhp5ClassMethod(t *testing.T) {
|
||||
func TestPhp7ClassMethod(t *testing.T) {
|
||||
src := `<? class foo{ public static function &bar(): void {} }`
|
||||
|
||||
expected := &stmt.StmtList{
|
||||
expected := &node.Root{
|
||||
Stmts: []node.Node{
|
||||
&stmt.Class{
|
||||
ClassName: &node.Identifier{Value: "foo"},
|
||||
@@ -149,7 +149,7 @@ func TestPhp7ClassMethod(t *testing.T) {
|
||||
func TestAbstractClassMethod(t *testing.T) {
|
||||
src := `<? abstract class Foo{ abstract public function bar(); }`
|
||||
|
||||
expected := &stmt.StmtList{
|
||||
expected := &node.Root{
|
||||
Stmts: []node.Node{
|
||||
&stmt.Class{
|
||||
Modifiers: []node.Node{&node.Identifier{Value: "abstract"}},
|
||||
@@ -183,7 +183,7 @@ func TestAbstractClassMethod(t *testing.T) {
|
||||
func TestPhp7AbstractClassMethod(t *testing.T) {
|
||||
src := `<? abstract class Foo{ public function bar(): void; }`
|
||||
|
||||
expected := &stmt.StmtList{
|
||||
expected := &node.Root{
|
||||
Stmts: []node.Node{
|
||||
&stmt.Class{
|
||||
Modifiers: []node.Node{&node.Identifier{Value: "abstract"}},
|
||||
|
||||
@@ -16,7 +16,7 @@ import (
|
||||
func TestSimpleClass(t *testing.T) {
|
||||
src := `<? class foo{ }`
|
||||
|
||||
expected := &stmt.StmtList{
|
||||
expected := &node.Root{
|
||||
Stmts: []node.Node{
|
||||
&stmt.Class{
|
||||
ClassName: &node.Identifier{Value: "foo"},
|
||||
@@ -39,7 +39,7 @@ func TestSimpleClass(t *testing.T) {
|
||||
func TestAbstractClass(t *testing.T) {
|
||||
src := `<? abstract class foo{ }`
|
||||
|
||||
expected := &stmt.StmtList{
|
||||
expected := &node.Root{
|
||||
Stmts: []node.Node{
|
||||
&stmt.Class{
|
||||
ClassName: &node.Identifier{Value: "foo"},
|
||||
@@ -65,7 +65,7 @@ func TestAbstractClass(t *testing.T) {
|
||||
func TestClassExtends(t *testing.T) {
|
||||
src := `<? final class foo extends bar { }`
|
||||
|
||||
expected := &stmt.StmtList{
|
||||
expected := &node.Root{
|
||||
Stmts: []node.Node{
|
||||
&stmt.Class{
|
||||
ClassName: &node.Identifier{Value: "foo"},
|
||||
@@ -96,7 +96,7 @@ func TestClassExtends(t *testing.T) {
|
||||
func TestClassImplement(t *testing.T) {
|
||||
src := `<? final class foo implements bar { }`
|
||||
|
||||
expected := &stmt.StmtList{
|
||||
expected := &node.Root{
|
||||
Stmts: []node.Node{
|
||||
&stmt.Class{
|
||||
ClassName: &node.Identifier{Value: "foo"},
|
||||
@@ -129,7 +129,7 @@ func TestClassImplement(t *testing.T) {
|
||||
func TestClassImplements(t *testing.T) {
|
||||
src := `<? final class foo implements bar, baz { }`
|
||||
|
||||
expected := &stmt.StmtList{
|
||||
expected := &node.Root{
|
||||
Stmts: []node.Node{
|
||||
&stmt.Class{
|
||||
ClassName: &node.Identifier{Value: "foo"},
|
||||
@@ -167,7 +167,7 @@ func TestClassImplements(t *testing.T) {
|
||||
func TestAnonimousClass(t *testing.T) {
|
||||
src := `<? new class() extends foo implements bar, baz { };`
|
||||
|
||||
expected := &stmt.StmtList{
|
||||
expected := &node.Root{
|
||||
Stmts: []node.Node{
|
||||
&stmt.Expression{
|
||||
Expr: &expr.New{
|
||||
|
||||
@@ -15,7 +15,7 @@ import (
|
||||
func TestConstList(t *testing.T) {
|
||||
src := `<? const FOO = 1, BAR = 2;`
|
||||
|
||||
expected := &stmt.StmtList{
|
||||
expected := &node.Root{
|
||||
Stmts: []node.Node{
|
||||
&stmt.ConstList{
|
||||
Consts: []node.Node{
|
||||
|
||||
@@ -15,7 +15,7 @@ import (
|
||||
func TestContinueEmpty(t *testing.T) {
|
||||
src := `<? while (1) { continue; }`
|
||||
|
||||
expected := &stmt.StmtList{
|
||||
expected := &node.Root{
|
||||
Stmts: []node.Node{
|
||||
&stmt.While{
|
||||
Cond: &scalar.Lnumber{Value: "1"},
|
||||
@@ -42,7 +42,7 @@ func TestContinueEmpty(t *testing.T) {
|
||||
func TestContinueLight(t *testing.T) {
|
||||
src := `<? while (1) { continue 2; }`
|
||||
|
||||
expected := &stmt.StmtList{
|
||||
expected := &node.Root{
|
||||
Stmts: []node.Node{
|
||||
&stmt.While{
|
||||
Cond: &scalar.Lnumber{Value: "1"},
|
||||
@@ -71,7 +71,7 @@ func TestContinueLight(t *testing.T) {
|
||||
func TestContinue(t *testing.T) {
|
||||
src := `<? while (1) { continue(3); }`
|
||||
|
||||
expected := &stmt.StmtList{
|
||||
expected := &node.Root{
|
||||
Stmts: []node.Node{
|
||||
&stmt.While{
|
||||
Cond: &scalar.Lnumber{Value: "1"},
|
||||
|
||||
@@ -15,7 +15,7 @@ import (
|
||||
func TestDeclare(t *testing.T) {
|
||||
src := `<? declare(ticks=1);`
|
||||
|
||||
expected := &stmt.StmtList{
|
||||
expected := &node.Root{
|
||||
Stmts: []node.Node{
|
||||
&stmt.Declare{
|
||||
Consts: []node.Node{
|
||||
@@ -44,7 +44,7 @@ func TestDeclare(t *testing.T) {
|
||||
func TestDeclareStmts(t *testing.T) {
|
||||
src := `<? declare(ticks=1, strict_types=1) {}`
|
||||
|
||||
expected := &stmt.StmtList{
|
||||
expected := &node.Root{
|
||||
Stmts: []node.Node{
|
||||
&stmt.Declare{
|
||||
Consts: []node.Node{
|
||||
@@ -80,7 +80,7 @@ func TestDeclareStmts(t *testing.T) {
|
||||
func TestAltDeclare(t *testing.T) {
|
||||
src := `<? declare(ticks=1): enddeclare;`
|
||||
|
||||
expected := &stmt.StmtList{
|
||||
expected := &node.Root{
|
||||
Stmts: []node.Node{
|
||||
&stmt.Declare{
|
||||
Consts: []node.Node{
|
||||
|
||||
@@ -15,7 +15,7 @@ import (
|
||||
func TestDo(t *testing.T) {
|
||||
src := `<? do {} while(1);`
|
||||
|
||||
expected := &stmt.StmtList{
|
||||
expected := &node.Root{
|
||||
Stmts: []node.Node{
|
||||
&stmt.Do{
|
||||
Stmt: &stmt.StmtList{
|
||||
|
||||
@@ -17,7 +17,7 @@ import (
|
||||
func TestSimpleEcho(t *testing.T) {
|
||||
src := `<? echo $a, 1;`
|
||||
|
||||
expected := &stmt.StmtList{
|
||||
expected := &node.Root{
|
||||
Stmts: []node.Node{
|
||||
&stmt.Echo{
|
||||
Exprs: []node.Node{
|
||||
@@ -44,7 +44,7 @@ func TestSimpleEcho(t *testing.T) {
|
||||
func TestEcho(t *testing.T) {
|
||||
src := `<? echo($a);`
|
||||
|
||||
expected := &stmt.StmtList{
|
||||
expected := &node.Root{
|
||||
Stmts: []node.Node{
|
||||
&stmt.Echo{
|
||||
Exprs: []node.Node{
|
||||
|
||||
@@ -15,7 +15,7 @@ import (
|
||||
func TestExpression(t *testing.T) {
|
||||
src := `<? 1;`
|
||||
|
||||
expected := &stmt.StmtList{
|
||||
expected := &node.Root{
|
||||
Stmts: []node.Node{
|
||||
&stmt.Expression{
|
||||
Expr: &scalar.Lnumber{Value: "1"},
|
||||
|
||||
@@ -20,7 +20,7 @@ import (
|
||||
func TestFor(t *testing.T) {
|
||||
src := `<? for($i = 0; $i < 10; $i++, $i++) {}`
|
||||
|
||||
expected := &stmt.StmtList{
|
||||
expected := &node.Root{
|
||||
Stmts: []node.Node{
|
||||
&stmt.For{
|
||||
Init: []node.Node{
|
||||
@@ -62,7 +62,7 @@ func TestFor(t *testing.T) {
|
||||
func TestAltFor(t *testing.T) {
|
||||
src := `<? for(; $i < 10; $i++) : endfor;`
|
||||
|
||||
expected := &stmt.StmtList{
|
||||
expected := &node.Root{
|
||||
Stmts: []node.Node{
|
||||
&stmt.AltFor{
|
||||
Cond: []node.Node{
|
||||
|
||||
@@ -15,7 +15,7 @@ import (
|
||||
func TestForeach(t *testing.T) {
|
||||
src := `<? foreach ($a as $v) {}`
|
||||
|
||||
expected := &stmt.StmtList{
|
||||
expected := &node.Root{
|
||||
Stmts: []node.Node{
|
||||
&stmt.Foreach{
|
||||
Expr: &expr.Variable{VarName: &node.Identifier{Value: "a"}},
|
||||
@@ -39,7 +39,7 @@ func TestForeach(t *testing.T) {
|
||||
func TestForeachExpr(t *testing.T) {
|
||||
src := `<? foreach ([] as $v) {}`
|
||||
|
||||
expected := &stmt.StmtList{
|
||||
expected := &node.Root{
|
||||
Stmts: []node.Node{
|
||||
&stmt.Foreach{
|
||||
Expr: &expr.ShortArray{Items: []node.Node{}},
|
||||
@@ -63,7 +63,7 @@ func TestForeachExpr(t *testing.T) {
|
||||
func TestAltForeach(t *testing.T) {
|
||||
src := `<? foreach ($a as $v) : endforeach;`
|
||||
|
||||
expected := &stmt.StmtList{
|
||||
expected := &node.Root{
|
||||
Stmts: []node.Node{
|
||||
&stmt.AltForeach{
|
||||
Expr: &expr.Variable{VarName: &node.Identifier{Value: "a"}},
|
||||
@@ -87,7 +87,7 @@ func TestAltForeach(t *testing.T) {
|
||||
func TestForeachWithKey(t *testing.T) {
|
||||
src := `<? foreach ($a as $k => $v) {}`
|
||||
|
||||
expected := &stmt.StmtList{
|
||||
expected := &node.Root{
|
||||
Stmts: []node.Node{
|
||||
&stmt.Foreach{
|
||||
Expr: &expr.Variable{VarName: &node.Identifier{Value: "a"}},
|
||||
@@ -112,7 +112,7 @@ func TestForeachWithKey(t *testing.T) {
|
||||
func TestForeachExprWithKey(t *testing.T) {
|
||||
src := `<? foreach ([] as $k => $v) {}`
|
||||
|
||||
expected := &stmt.StmtList{
|
||||
expected := &node.Root{
|
||||
Stmts: []node.Node{
|
||||
&stmt.Foreach{
|
||||
Expr: &expr.ShortArray{Items: []node.Node{}},
|
||||
@@ -137,7 +137,7 @@ func TestForeachExprWithKey(t *testing.T) {
|
||||
func TestForeachWithRef(t *testing.T) {
|
||||
src := `<? foreach ($a as $k => &$v) {}`
|
||||
|
||||
expected := &stmt.StmtList{
|
||||
expected := &node.Root{
|
||||
Stmts: []node.Node{
|
||||
&stmt.Foreach{
|
||||
ByRef: true,
|
||||
@@ -163,7 +163,7 @@ func TestForeachWithRef(t *testing.T) {
|
||||
func TestForeachWithList(t *testing.T) {
|
||||
src := `<? foreach ($a as $k => list($v)) {}`
|
||||
|
||||
expected := &stmt.StmtList{
|
||||
expected := &node.Root{
|
||||
Stmts: []node.Node{
|
||||
&stmt.Foreach{
|
||||
ByRef: false,
|
||||
|
||||
@@ -17,7 +17,7 @@ import (
|
||||
func TestSimpleFunction(t *testing.T) {
|
||||
src := `<? function foo() {}`
|
||||
|
||||
expected := &stmt.StmtList{
|
||||
expected := &node.Root{
|
||||
Stmts: []node.Node{
|
||||
&stmt.Function{
|
||||
ReturnsRef: false,
|
||||
@@ -42,7 +42,7 @@ func TestSimpleFunction(t *testing.T) {
|
||||
func TestFunctionReturn(t *testing.T) {
|
||||
src := `<? function foo() {return;}`
|
||||
|
||||
expected := &stmt.StmtList{
|
||||
expected := &node.Root{
|
||||
Stmts: []node.Node{
|
||||
&stmt.Function{
|
||||
ReturnsRef: false,
|
||||
@@ -69,7 +69,7 @@ func TestFunctionReturn(t *testing.T) {
|
||||
func TestFunctionReturnVar(t *testing.T) {
|
||||
src := `<? function foo(array $a, callable $b) {return $a;}`
|
||||
|
||||
expected := &stmt.StmtList{
|
||||
expected := &node.Root{
|
||||
Stmts: []node.Node{
|
||||
&stmt.Function{
|
||||
ReturnsRef: false,
|
||||
@@ -112,7 +112,7 @@ func TestFunctionReturnVar(t *testing.T) {
|
||||
func TestRefFunction(t *testing.T) {
|
||||
src := `<? function &foo() {return 1;}`
|
||||
|
||||
expected := &stmt.StmtList{
|
||||
expected := &node.Root{
|
||||
Stmts: []node.Node{
|
||||
&stmt.Function{
|
||||
ReturnsRef: true,
|
||||
@@ -141,7 +141,7 @@ func TestRefFunction(t *testing.T) {
|
||||
func TestReturnTypeFunction(t *testing.T) {
|
||||
src := `<? function &foo(): void {}`
|
||||
|
||||
expected := &stmt.StmtList{
|
||||
expected := &node.Root{
|
||||
Stmts: []node.Node{
|
||||
&stmt.Function{
|
||||
ReturnsRef: true,
|
||||
|
||||
@@ -15,7 +15,7 @@ import (
|
||||
func TestGlobal(t *testing.T) {
|
||||
src := `<? global $a;`
|
||||
|
||||
expected := &stmt.StmtList{
|
||||
expected := &node.Root{
|
||||
Stmts: []node.Node{
|
||||
&stmt.Global{
|
||||
Vars: []node.Node{
|
||||
@@ -39,7 +39,7 @@ func TestGlobal(t *testing.T) {
|
||||
func TestGlobalVars(t *testing.T) {
|
||||
src := `<? global $a, $b, $$c, ${foo()};`
|
||||
|
||||
expected := &stmt.StmtList{
|
||||
expected := &node.Root{
|
||||
Stmts: []node.Node{
|
||||
&stmt.Global{
|
||||
Vars: []node.Node{
|
||||
|
||||
@@ -13,7 +13,7 @@ import (
|
||||
func TestGotoLabel(t *testing.T) {
|
||||
src := `<? a: goto a;`
|
||||
|
||||
expected := &stmt.StmtList{
|
||||
expected := &node.Root{
|
||||
Stmts: []node.Node{
|
||||
&stmt.Label{
|
||||
LabelName: &node.Identifier{Value: "a"},
|
||||
|
||||
@@ -13,7 +13,7 @@ import (
|
||||
func TestHaltCompiler(t *testing.T) {
|
||||
src := `<? __halt_compiler();`
|
||||
|
||||
expected := &stmt.StmtList{
|
||||
expected := &node.Root{
|
||||
Stmts: []node.Node{
|
||||
&stmt.HaltCompiler{},
|
||||
},
|
||||
|
||||
@@ -15,7 +15,7 @@ import (
|
||||
func TestIf(t *testing.T) {
|
||||
src := `<? if ($a) {}`
|
||||
|
||||
expected := &stmt.StmtList{
|
||||
expected := &node.Root{
|
||||
Stmts: []node.Node{
|
||||
&stmt.If{
|
||||
Cond: &expr.Variable{VarName: &node.Identifier{Value: "a"}},
|
||||
@@ -39,7 +39,7 @@ func TestElseIf(t *testing.T) {
|
||||
src := `<? if ($a) {} elseif ($b) {}
|
||||
`
|
||||
|
||||
expected := &stmt.StmtList{
|
||||
expected := &node.Root{
|
||||
Stmts: []node.Node{
|
||||
&stmt.If{
|
||||
Cond: &expr.Variable{VarName: &node.Identifier{Value: "a"}},
|
||||
@@ -68,7 +68,7 @@ func TestElseIf(t *testing.T) {
|
||||
func TestElse(t *testing.T) {
|
||||
src := `<? if ($a) {} else {}`
|
||||
|
||||
expected := &stmt.StmtList{
|
||||
expected := &node.Root{
|
||||
Stmts: []node.Node{
|
||||
&stmt.If{
|
||||
Cond: &expr.Variable{VarName: &node.Identifier{Value: "a"}},
|
||||
@@ -94,7 +94,7 @@ func TestElse(t *testing.T) {
|
||||
func TestElseElseIf(t *testing.T) {
|
||||
src := `<? if ($a) {} elseif ($b) {} elseif ($c) {} else {}`
|
||||
|
||||
expected := &stmt.StmtList{
|
||||
expected := &node.Root{
|
||||
Stmts: []node.Node{
|
||||
&stmt.If{
|
||||
Cond: &expr.Variable{VarName: &node.Identifier{Value: "a"}},
|
||||
@@ -130,7 +130,7 @@ func TestElseElseIf(t *testing.T) {
|
||||
func TestElseIfElseIfElse(t *testing.T) {
|
||||
src := `<? if ($a) {} elseif ($b) {} else if ($c) {} else {}`
|
||||
|
||||
expected := &stmt.StmtList{
|
||||
expected := &node.Root{
|
||||
Stmts: []node.Node{
|
||||
&stmt.If{
|
||||
Cond: &expr.Variable{VarName: &node.Identifier{Value: "a"}},
|
||||
|
||||
@@ -13,7 +13,7 @@ import (
|
||||
func TestInlineHtml(t *testing.T) {
|
||||
src := `<? ?> <div></div>`
|
||||
|
||||
expected := &stmt.StmtList{
|
||||
expected := &node.Root{
|
||||
Stmts: []node.Node{
|
||||
&stmt.Nop{},
|
||||
&stmt.InlineHtml{Value: "<div></div>"},
|
||||
|
||||
@@ -14,7 +14,7 @@ import (
|
||||
func TestInterface(t *testing.T) {
|
||||
src := `<? interface Foo {}`
|
||||
|
||||
expected := &stmt.StmtList{
|
||||
expected := &node.Root{
|
||||
Stmts: []node.Node{
|
||||
&stmt.Interface{
|
||||
PhpDocComment: "",
|
||||
@@ -38,7 +38,7 @@ func TestInterface(t *testing.T) {
|
||||
func TestInterfaceExtend(t *testing.T) {
|
||||
src := `<? interface Foo extends Bar {}`
|
||||
|
||||
expected := &stmt.StmtList{
|
||||
expected := &node.Root{
|
||||
Stmts: []node.Node{
|
||||
&stmt.Interface{
|
||||
PhpDocComment: "",
|
||||
@@ -69,7 +69,7 @@ func TestInterfaceExtend(t *testing.T) {
|
||||
func TestInterfaceExtends(t *testing.T) {
|
||||
src := `<? interface Foo extends Bar, Baz {}`
|
||||
|
||||
expected := &stmt.StmtList{
|
||||
expected := &node.Root{
|
||||
Stmts: []node.Node{
|
||||
&stmt.Interface{
|
||||
PhpDocComment: "",
|
||||
|
||||
@@ -14,7 +14,7 @@ import (
|
||||
func TestNamespace(t *testing.T) {
|
||||
src := `<? namespace Foo;`
|
||||
|
||||
expected := &stmt.StmtList{
|
||||
expected := &node.Root{
|
||||
Stmts: []node.Node{
|
||||
&stmt.Namespace{
|
||||
NamespaceName: &name.Name{
|
||||
@@ -40,7 +40,7 @@ func TestNamespace(t *testing.T) {
|
||||
func TestNamespaceStmts(t *testing.T) {
|
||||
src := `<? namespace Foo {}`
|
||||
|
||||
expected := &stmt.StmtList{
|
||||
expected := &node.Root{
|
||||
Stmts: []node.Node{
|
||||
&stmt.Namespace{
|
||||
NamespaceName: &name.Name{
|
||||
@@ -67,7 +67,7 @@ func TestNamespaceStmts(t *testing.T) {
|
||||
func TestAnonymousNamespace(t *testing.T) {
|
||||
src := `<? namespace {}`
|
||||
|
||||
expected := &stmt.StmtList{
|
||||
expected := &node.Root{
|
||||
Stmts: []node.Node{
|
||||
&stmt.Namespace{
|
||||
Stmts: []node.Node{},
|
||||
|
||||
@@ -15,7 +15,7 @@ import (
|
||||
func TestProperty(t *testing.T) {
|
||||
src := `<? class foo {var $a;}`
|
||||
|
||||
expected := &stmt.StmtList{
|
||||
expected := &node.Root{
|
||||
Stmts: []node.Node{
|
||||
&stmt.Class{
|
||||
ClassName: &node.Identifier{Value: "foo"},
|
||||
@@ -50,7 +50,7 @@ func TestProperty(t *testing.T) {
|
||||
func TestProperties(t *testing.T) {
|
||||
src := `<? class foo {public static $a, $b = 1;}`
|
||||
|
||||
expected := &stmt.StmtList{
|
||||
expected := &node.Root{
|
||||
Stmts: []node.Node{
|
||||
&stmt.Class{
|
||||
ClassName: &node.Identifier{Value: "foo"},
|
||||
@@ -91,7 +91,7 @@ func TestProperties(t *testing.T) {
|
||||
func TestProperties2(t *testing.T) {
|
||||
src := `<? class foo {public static $a = 1, $b;}`
|
||||
|
||||
expected := &stmt.StmtList{
|
||||
expected := &node.Root{
|
||||
Stmts: []node.Node{
|
||||
&stmt.Class{
|
||||
ClassName: &node.Identifier{Value: "foo"},
|
||||
|
||||
@@ -15,7 +15,7 @@ import (
|
||||
func TestStaticVar(t *testing.T) {
|
||||
src := `<? static $a;`
|
||||
|
||||
expected := &stmt.StmtList{
|
||||
expected := &node.Root{
|
||||
Stmts: []node.Node{
|
||||
&stmt.Static{
|
||||
Vars: []node.Node{
|
||||
@@ -41,7 +41,7 @@ func TestStaticVar(t *testing.T) {
|
||||
func TestStaticVars(t *testing.T) {
|
||||
src := `<? static $a, $b = 1;`
|
||||
|
||||
expected := &stmt.StmtList{
|
||||
expected := &node.Root{
|
||||
Stmts: []node.Node{
|
||||
&stmt.Static{
|
||||
Vars: []node.Node{
|
||||
@@ -71,7 +71,7 @@ func TestStaticVars(t *testing.T) {
|
||||
func TestStaticVars2(t *testing.T) {
|
||||
src := `<? static $a = 1, $b;`
|
||||
|
||||
expected := &stmt.StmtList{
|
||||
expected := &node.Root{
|
||||
Stmts: []node.Node{
|
||||
&stmt.Static{
|
||||
Vars: []node.Node{
|
||||
|
||||
@@ -21,7 +21,7 @@ func TestAltSwitch(t *testing.T) {
|
||||
endswitch;
|
||||
`
|
||||
|
||||
expected := &stmt.StmtList{
|
||||
expected := &node.Root{
|
||||
Stmts: []node.Node{
|
||||
&stmt.AltSwitch{
|
||||
Cond: &scalar.Lnumber{Value: "1"},
|
||||
@@ -63,7 +63,7 @@ func TestAltSwitchSemicolon(t *testing.T) {
|
||||
endswitch;
|
||||
`
|
||||
|
||||
expected := &stmt.StmtList{
|
||||
expected := &node.Root{
|
||||
Stmts: []node.Node{
|
||||
&stmt.AltSwitch{
|
||||
Cond: &scalar.Lnumber{Value: "1"},
|
||||
@@ -102,7 +102,7 @@ func TestSwitch(t *testing.T) {
|
||||
}
|
||||
`
|
||||
|
||||
expected := &stmt.StmtList{
|
||||
expected := &node.Root{
|
||||
Stmts: []node.Node{
|
||||
&stmt.Switch{
|
||||
Cond: &scalar.Lnumber{Value: "1"},
|
||||
@@ -145,7 +145,7 @@ func TestSwitchSemicolon(t *testing.T) {
|
||||
}
|
||||
`
|
||||
|
||||
expected := &stmt.StmtList{
|
||||
expected := &node.Root{
|
||||
Stmts: []node.Node{
|
||||
&stmt.Switch{
|
||||
Cond: &scalar.Lnumber{Value: "1"},
|
||||
|
||||
@@ -14,7 +14,7 @@ import (
|
||||
func TestThrow(t *testing.T) {
|
||||
src := `<? throw $e;`
|
||||
|
||||
expected := &stmt.StmtList{
|
||||
expected := &node.Root{
|
||||
Stmts: []node.Node{
|
||||
&stmt.Throw{
|
||||
Expr: &expr.Variable{VarName: &node.Identifier{Value: "e"}},
|
||||
|
||||
@@ -13,7 +13,7 @@ import (
|
||||
func TestTrait(t *testing.T) {
|
||||
src := `<? trait Foo {}`
|
||||
|
||||
expected := &stmt.StmtList{
|
||||
expected := &node.Root{
|
||||
Stmts: []node.Node{
|
||||
&stmt.Trait{
|
||||
PhpDocComment: "",
|
||||
|
||||
@@ -15,7 +15,7 @@ import (
|
||||
func TestTraitUse(t *testing.T) {
|
||||
src := `<? class Foo { use Bar; }`
|
||||
|
||||
expected := &stmt.StmtList{
|
||||
expected := &node.Root{
|
||||
Stmts: []node.Node{
|
||||
&stmt.Class{
|
||||
PhpDocComment: "",
|
||||
@@ -49,7 +49,7 @@ func TestTraitUse(t *testing.T) {
|
||||
func TestTraitsUse(t *testing.T) {
|
||||
src := `<? class Foo { use Bar, Baz; }`
|
||||
|
||||
expected := &stmt.StmtList{
|
||||
expected := &node.Root{
|
||||
Stmts: []node.Node{
|
||||
&stmt.Class{
|
||||
PhpDocComment: "",
|
||||
@@ -88,7 +88,7 @@ func TestTraitsUse(t *testing.T) {
|
||||
func TestTraitsUseEmptyAdaptations(t *testing.T) {
|
||||
src := `<? class Foo { use Bar, Baz {} }`
|
||||
|
||||
expected := &stmt.StmtList{
|
||||
expected := &node.Root{
|
||||
Stmts: []node.Node{
|
||||
&stmt.Class{
|
||||
PhpDocComment: "",
|
||||
@@ -128,7 +128,7 @@ func TestTraitsUseEmptyAdaptations(t *testing.T) {
|
||||
func TestTraitsUseModifier(t *testing.T) {
|
||||
src := `<? class Foo { use Bar, Baz { one as public; } }`
|
||||
|
||||
expected := &stmt.StmtList{
|
||||
expected := &node.Root{
|
||||
Stmts: []node.Node{
|
||||
&stmt.Class{
|
||||
PhpDocComment: "",
|
||||
@@ -177,7 +177,7 @@ func TestTraitsUseModifier(t *testing.T) {
|
||||
func TestTraitsUseAliasModifier(t *testing.T) {
|
||||
src := `<? class Foo { use Bar, Baz { one as public two; } }`
|
||||
|
||||
expected := &stmt.StmtList{
|
||||
expected := &node.Root{
|
||||
Stmts: []node.Node{
|
||||
&stmt.Class{
|
||||
PhpDocComment: "",
|
||||
@@ -227,7 +227,7 @@ func TestTraitsUseAliasModifier(t *testing.T) {
|
||||
func TestTraitsUseAdaptions(t *testing.T) {
|
||||
src := `<? class Foo { use Bar, Baz { Bar::one insteadof Baz, Quux; Baz::one as two; } }`
|
||||
|
||||
expected := &stmt.StmtList{
|
||||
expected := &node.Root{
|
||||
Stmts: []node.Node{
|
||||
&stmt.Class{
|
||||
PhpDocComment: "",
|
||||
|
||||
@@ -17,7 +17,7 @@ func TestTry(t *testing.T) {
|
||||
try {}
|
||||
`
|
||||
|
||||
expected := &stmt.StmtList{
|
||||
expected := &node.Root{
|
||||
Stmts: []node.Node{
|
||||
&stmt.Try{
|
||||
Stmts: []node.Node{},
|
||||
@@ -42,7 +42,7 @@ func TestTryCatch(t *testing.T) {
|
||||
try {} catch (Exception $e) {}
|
||||
`
|
||||
|
||||
expected := &stmt.StmtList{
|
||||
expected := &node.Root{
|
||||
Stmts: []node.Node{
|
||||
&stmt.Try{
|
||||
Stmts: []node.Node{},
|
||||
@@ -81,7 +81,7 @@ func TestPhp7TryCatch(t *testing.T) {
|
||||
try {} catch (Exception|RuntimeException $e) {}
|
||||
`
|
||||
|
||||
expected := &stmt.StmtList{
|
||||
expected := &node.Root{
|
||||
Stmts: []node.Node{
|
||||
&stmt.Try{
|
||||
Stmts: []node.Node{},
|
||||
@@ -120,7 +120,7 @@ func TestTryCatchCatch(t *testing.T) {
|
||||
try {} catch (Exception $e) {} catch (RuntimeException $e) {}
|
||||
`
|
||||
|
||||
expected := &stmt.StmtList{
|
||||
expected := &node.Root{
|
||||
Stmts: []node.Node{
|
||||
&stmt.Try{
|
||||
Stmts: []node.Node{},
|
||||
@@ -172,7 +172,7 @@ func TestTryCatchFinally(t *testing.T) {
|
||||
try {} catch (Exception $e) {} finally {}
|
||||
`
|
||||
|
||||
expected := &stmt.StmtList{
|
||||
expected := &node.Root{
|
||||
Stmts: []node.Node{
|
||||
&stmt.Try{
|
||||
Stmts: []node.Node{},
|
||||
@@ -212,7 +212,7 @@ func TestTryCatchFinally(t *testing.T) {
|
||||
func TestTryCatchCatchCatch(t *testing.T) {
|
||||
src := `<? try {} catch (Exception $e) {} catch (\RuntimeException $e) {} catch (namespace\AdditionException $e) {}`
|
||||
|
||||
expected := &stmt.StmtList{
|
||||
expected := &node.Root{
|
||||
Stmts: []node.Node{
|
||||
&stmt.Try{
|
||||
Stmts: []node.Node{},
|
||||
|
||||
@@ -14,7 +14,7 @@ import (
|
||||
func TestUnset(t *testing.T) {
|
||||
src := `<? unset($a);`
|
||||
|
||||
expected := &stmt.StmtList{
|
||||
expected := &node.Root{
|
||||
Stmts: []node.Node{
|
||||
&stmt.Unset{
|
||||
Vars: []node.Node{
|
||||
@@ -38,7 +38,7 @@ func TestUnset(t *testing.T) {
|
||||
func TestUnsetVars(t *testing.T) {
|
||||
src := `<? unset($a, $b);`
|
||||
|
||||
expected := &stmt.StmtList{
|
||||
expected := &node.Root{
|
||||
Stmts: []node.Node{
|
||||
&stmt.Unset{
|
||||
Vars: []node.Node{
|
||||
@@ -63,7 +63,7 @@ func TestUnsetVars(t *testing.T) {
|
||||
func TestUnsetTrailingComma(t *testing.T) {
|
||||
src := `<? unset($a, $b,);`
|
||||
|
||||
expected := &stmt.StmtList{
|
||||
expected := &node.Root{
|
||||
Stmts: []node.Node{
|
||||
&stmt.Unset{
|
||||
Vars: []node.Node{
|
||||
|
||||
@@ -14,7 +14,7 @@ import (
|
||||
func TestSimpleUse(t *testing.T) {
|
||||
src := `<? use Foo;`
|
||||
|
||||
expected := &stmt.StmtList{
|
||||
expected := &node.Root{
|
||||
Stmts: []node.Node{
|
||||
&stmt.UseList{
|
||||
Uses: []node.Node{
|
||||
@@ -44,7 +44,7 @@ func TestSimpleUse(t *testing.T) {
|
||||
func TestUseFullyQualified(t *testing.T) {
|
||||
src := `<? use \Foo;`
|
||||
|
||||
expected := &stmt.StmtList{
|
||||
expected := &node.Root{
|
||||
Stmts: []node.Node{
|
||||
&stmt.UseList{
|
||||
Uses: []node.Node{
|
||||
@@ -74,7 +74,7 @@ func TestUseFullyQualified(t *testing.T) {
|
||||
func TestUseFullyQualifiedAlias(t *testing.T) {
|
||||
src := `<? use \Foo as Bar;`
|
||||
|
||||
expected := &stmt.StmtList{
|
||||
expected := &node.Root{
|
||||
Stmts: []node.Node{
|
||||
&stmt.UseList{
|
||||
Uses: []node.Node{
|
||||
@@ -105,7 +105,7 @@ func TestUseFullyQualifiedAlias(t *testing.T) {
|
||||
func TestUseList(t *testing.T) {
|
||||
src := `<? use Foo, Bar;`
|
||||
|
||||
expected := &stmt.StmtList{
|
||||
expected := &node.Root{
|
||||
Stmts: []node.Node{
|
||||
&stmt.UseList{
|
||||
Uses: []node.Node{
|
||||
@@ -142,7 +142,7 @@ func TestUseList(t *testing.T) {
|
||||
func TestUseListAlias(t *testing.T) {
|
||||
src := `<? use Foo, Bar as Baz;`
|
||||
|
||||
expected := &stmt.StmtList{
|
||||
expected := &node.Root{
|
||||
Stmts: []node.Node{
|
||||
&stmt.UseList{
|
||||
Uses: []node.Node{
|
||||
@@ -180,7 +180,7 @@ func TestUseListAlias(t *testing.T) {
|
||||
func TestUseListFunctionType(t *testing.T) {
|
||||
src := `<? use function Foo, \Bar;`
|
||||
|
||||
expected := &stmt.StmtList{
|
||||
expected := &node.Root{
|
||||
Stmts: []node.Node{
|
||||
&stmt.UseList{
|
||||
UseType: &node.Identifier{Value: "function"},
|
||||
@@ -218,7 +218,7 @@ func TestUseListFunctionType(t *testing.T) {
|
||||
func TestUseListFunctionTypeAliases(t *testing.T) {
|
||||
src := `<? use function Foo as foo, \Bar as bar;`
|
||||
|
||||
expected := &stmt.StmtList{
|
||||
expected := &node.Root{
|
||||
Stmts: []node.Node{
|
||||
&stmt.UseList{
|
||||
UseType: &node.Identifier{Value: "function"},
|
||||
@@ -258,7 +258,7 @@ func TestUseListFunctionTypeAliases(t *testing.T) {
|
||||
func TestUseListConstType(t *testing.T) {
|
||||
src := `<? use const Foo, \Bar;`
|
||||
|
||||
expected := &stmt.StmtList{
|
||||
expected := &node.Root{
|
||||
Stmts: []node.Node{
|
||||
&stmt.UseList{
|
||||
UseType: &node.Identifier{Value: "const"},
|
||||
@@ -296,7 +296,7 @@ func TestUseListConstType(t *testing.T) {
|
||||
func TestUseListConstTypeAliases(t *testing.T) {
|
||||
src := `<? use const Foo as foo, \Bar as bar;`
|
||||
|
||||
expected := &stmt.StmtList{
|
||||
expected := &node.Root{
|
||||
Stmts: []node.Node{
|
||||
&stmt.UseList{
|
||||
UseType: &node.Identifier{Value: "const"},
|
||||
@@ -336,7 +336,7 @@ func TestUseListConstTypeAliases(t *testing.T) {
|
||||
func TestGroupUse(t *testing.T) {
|
||||
src := `<? use Foo\{Bar, Baz};`
|
||||
|
||||
expected := &stmt.StmtList{
|
||||
expected := &node.Root{
|
||||
Stmts: []node.Node{
|
||||
&stmt.GroupUse{
|
||||
Prefix: &name.Name{
|
||||
@@ -373,7 +373,7 @@ func TestGroupUse(t *testing.T) {
|
||||
func TestGroupUseAlias(t *testing.T) {
|
||||
src := `<? use Foo\{Bar, Baz as quux};`
|
||||
|
||||
expected := &stmt.StmtList{
|
||||
expected := &node.Root{
|
||||
Stmts: []node.Node{
|
||||
&stmt.GroupUse{
|
||||
Prefix: &name.Name{
|
||||
@@ -411,7 +411,7 @@ func TestGroupUseAlias(t *testing.T) {
|
||||
func TestFunctionGroupUse(t *testing.T) {
|
||||
src := `<? use function Foo\{Bar, Baz};`
|
||||
|
||||
expected := &stmt.StmtList{
|
||||
expected := &node.Root{
|
||||
Stmts: []node.Node{
|
||||
&stmt.GroupUse{
|
||||
UseType: &node.Identifier{Value: "function"},
|
||||
@@ -449,7 +449,7 @@ func TestFunctionGroupUse(t *testing.T) {
|
||||
func TestConstGroupUse(t *testing.T) {
|
||||
src := `<? use const Foo\{Bar, Baz};`
|
||||
|
||||
expected := &stmt.StmtList{
|
||||
expected := &node.Root{
|
||||
Stmts: []node.Node{
|
||||
&stmt.GroupUse{
|
||||
UseType: &node.Identifier{Value: "const"},
|
||||
@@ -487,7 +487,7 @@ func TestConstGroupUse(t *testing.T) {
|
||||
func TestMixedGroupUse(t *testing.T) {
|
||||
src := `<? use Foo\{const Bar, function Baz};`
|
||||
|
||||
expected := &stmt.StmtList{
|
||||
expected := &node.Root{
|
||||
Stmts: []node.Node{
|
||||
&stmt.GroupUse{
|
||||
Prefix: &name.Name{
|
||||
|
||||
@@ -15,7 +15,7 @@ import (
|
||||
func TestBreakEmpty(t *testing.T) {
|
||||
src := `<? while (1) { break; }`
|
||||
|
||||
expected := &stmt.StmtList{
|
||||
expected := &node.Root{
|
||||
Stmts: []node.Node{
|
||||
&stmt.While{
|
||||
Cond: &scalar.Lnumber{Value: "1"},
|
||||
@@ -42,7 +42,7 @@ func TestBreakEmpty(t *testing.T) {
|
||||
func TestBreakLight(t *testing.T) {
|
||||
src := `<? while (1) { break 2; }`
|
||||
|
||||
expected := &stmt.StmtList{
|
||||
expected := &node.Root{
|
||||
Stmts: []node.Node{
|
||||
&stmt.While{
|
||||
Cond: &scalar.Lnumber{Value: "1"},
|
||||
@@ -71,7 +71,7 @@ func TestBreakLight(t *testing.T) {
|
||||
func TestBreak(t *testing.T) {
|
||||
src := `<? while (1) : break(3); endwhile;`
|
||||
|
||||
expected := &stmt.StmtList{
|
||||
expected := &node.Root{
|
||||
Stmts: []node.Node{
|
||||
&stmt.AltWhile{
|
||||
Cond: &scalar.Lnumber{Value: "1"},
|
||||
|
||||
Reference in New Issue
Block a user