create Root node
This commit is contained in:
@@ -16,7 +16,7 @@ import (
|
||||
func TestSimpleVar(t *testing.T) {
|
||||
src := `<? "test $var";`
|
||||
|
||||
expected := &stmt.StmtList{
|
||||
expected := &node.Root{
|
||||
Stmts: []node.Node{
|
||||
&stmt.Expression{
|
||||
Expr: &scalar.Encapsed{
|
||||
@@ -43,7 +43,7 @@ func TestSimpleVar(t *testing.T) {
|
||||
func TestSimpleVarOneChar(t *testing.T) {
|
||||
src := `<? "test $a";`
|
||||
|
||||
expected := &stmt.StmtList{
|
||||
expected := &node.Root{
|
||||
Stmts: []node.Node{
|
||||
&stmt.Expression{
|
||||
Expr: &scalar.Encapsed{
|
||||
@@ -70,7 +70,7 @@ func TestSimpleVarOneChar(t *testing.T) {
|
||||
func TestSimpleVarEndsEcapsed(t *testing.T) {
|
||||
src := `<? "test $var\"";`
|
||||
|
||||
expected := &stmt.StmtList{
|
||||
expected := &node.Root{
|
||||
Stmts: []node.Node{
|
||||
&stmt.Expression{
|
||||
Expr: &scalar.Encapsed{
|
||||
@@ -98,7 +98,7 @@ func TestSimpleVarEndsEcapsed(t *testing.T) {
|
||||
func TestStringVarCurveOpen(t *testing.T) {
|
||||
src := `<? "=$a{$b}";`
|
||||
|
||||
expected := &stmt.StmtList{
|
||||
expected := &node.Root{
|
||||
Stmts: []node.Node{
|
||||
&stmt.Expression{
|
||||
Expr: &scalar.Encapsed{
|
||||
@@ -126,7 +126,7 @@ func TestStringVarCurveOpen(t *testing.T) {
|
||||
func TestSimpleVarPropertyFetch(t *testing.T) {
|
||||
src := `<? "test $foo->bar()";`
|
||||
|
||||
expected := &stmt.StmtList{
|
||||
expected := &node.Root{
|
||||
Stmts: []node.Node{
|
||||
&stmt.Expression{
|
||||
Expr: &scalar.Encapsed{
|
||||
@@ -157,7 +157,7 @@ func TestSimpleVarPropertyFetch(t *testing.T) {
|
||||
func TestDollarOpenCurlyBraces(t *testing.T) {
|
||||
src := `<? "test ${foo}";`
|
||||
|
||||
expected := &stmt.StmtList{
|
||||
expected := &node.Root{
|
||||
Stmts: []node.Node{
|
||||
&stmt.Expression{
|
||||
Expr: &scalar.Encapsed{
|
||||
@@ -184,7 +184,7 @@ func TestDollarOpenCurlyBraces(t *testing.T) {
|
||||
func TestDollarOpenCurlyBracesDimNumber(t *testing.T) {
|
||||
src := `<? "test ${foo[0]}";`
|
||||
|
||||
expected := &stmt.StmtList{
|
||||
expected := &node.Root{
|
||||
Stmts: []node.Node{
|
||||
&stmt.Expression{
|
||||
Expr: &scalar.Encapsed{
|
||||
@@ -214,7 +214,7 @@ func TestDollarOpenCurlyBracesDimNumber(t *testing.T) {
|
||||
func TestCurlyOpenMethodCall(t *testing.T) {
|
||||
src := `<? "test {$foo->bar()}";`
|
||||
|
||||
expected := &stmt.StmtList{
|
||||
expected := &node.Root{
|
||||
Stmts: []node.Node{
|
||||
&stmt.Expression{
|
||||
Expr: &scalar.Encapsed{
|
||||
|
||||
@@ -19,7 +19,7 @@ test $var
|
||||
LBL;
|
||||
`
|
||||
|
||||
expected := &stmt.StmtList{
|
||||
expected := &node.Root{
|
||||
Stmts: []node.Node{
|
||||
&stmt.Expression{
|
||||
Expr: &scalar.Heredoc{
|
||||
@@ -51,7 +51,7 @@ test $var
|
||||
LBL;
|
||||
`
|
||||
|
||||
expected := &stmt.StmtList{
|
||||
expected := &node.Root{
|
||||
Stmts: []node.Node{
|
||||
&stmt.Expression{
|
||||
Expr: &scalar.Heredoc{
|
||||
@@ -83,7 +83,7 @@ test $var
|
||||
LBL;
|
||||
`
|
||||
|
||||
expected := &stmt.StmtList{
|
||||
expected := &node.Root{
|
||||
Stmts: []node.Node{
|
||||
&stmt.Expression{
|
||||
Expr: &scalar.Heredoc{
|
||||
@@ -112,7 +112,7 @@ func TestEmptyHeredoc(t *testing.T) {
|
||||
CAD;
|
||||
`
|
||||
|
||||
expected := &stmt.StmtList{
|
||||
expected := &node.Root{
|
||||
Stmts: []node.Node{
|
||||
&stmt.Expression{
|
||||
Expr: &scalar.Heredoc{
|
||||
@@ -139,7 +139,7 @@ func TestHeredocScalarString(t *testing.T) {
|
||||
CAD;
|
||||
`
|
||||
|
||||
expected := &stmt.StmtList{
|
||||
expected := &node.Root{
|
||||
Stmts: []node.Node{
|
||||
&stmt.Expression{
|
||||
Expr: &scalar.Heredoc{
|
||||
|
||||
@@ -15,7 +15,7 @@ func TestMagicConstant(t *testing.T) {
|
||||
// TODO: test all magic constants
|
||||
src := `<? __DIR__;`
|
||||
|
||||
expected := &stmt.StmtList{
|
||||
expected := &node.Root{
|
||||
Stmts: []node.Node{
|
||||
&stmt.Expression{
|
||||
Expr: &scalar.MagicConstant{Value: "__DIR__"},
|
||||
|
||||
@@ -29,7 +29,7 @@ func assertEqual(t *testing.T, expected interface{}, actual interface{}) {
|
||||
func TestLNumber(t *testing.T) {
|
||||
src := `<? 1234567890123456789;`
|
||||
|
||||
expected := &stmt.StmtList{
|
||||
expected := &node.Root{
|
||||
Stmts: []node.Node{
|
||||
&stmt.Expression{
|
||||
Expr: &scalar.Lnumber{Value: "1234567890123456789"},
|
||||
@@ -51,7 +51,7 @@ func TestLNumber(t *testing.T) {
|
||||
func TestDNumber(t *testing.T) {
|
||||
src := `<? 12345678901234567890;`
|
||||
|
||||
expected := &stmt.StmtList{
|
||||
expected := &node.Root{
|
||||
Stmts: []node.Node{
|
||||
&stmt.Expression{
|
||||
Expr: &scalar.Dnumber{Value: "12345678901234567890"},
|
||||
@@ -73,7 +73,7 @@ func TestDNumber(t *testing.T) {
|
||||
func TestFloat(t *testing.T) {
|
||||
src := `<? 0.;`
|
||||
|
||||
expected := &stmt.StmtList{
|
||||
expected := &node.Root{
|
||||
Stmts: []node.Node{
|
||||
&stmt.Expression{
|
||||
Expr: &scalar.Dnumber{Value: "0."},
|
||||
@@ -95,7 +95,7 @@ func TestFloat(t *testing.T) {
|
||||
func TestBinaryLNumber(t *testing.T) {
|
||||
src := `<? 0b0111111111111111111111111111111111111111111111111111111111111111;`
|
||||
|
||||
expected := &stmt.StmtList{
|
||||
expected := &node.Root{
|
||||
Stmts: []node.Node{
|
||||
&stmt.Expression{
|
||||
Expr: &scalar.Lnumber{Value: "0b0111111111111111111111111111111111111111111111111111111111111111"},
|
||||
@@ -117,7 +117,7 @@ func TestBinaryLNumber(t *testing.T) {
|
||||
func TestBinaryDNumber(t *testing.T) {
|
||||
src := `<? 0b1111111111111111111111111111111111111111111111111111111111111111;`
|
||||
|
||||
expected := &stmt.StmtList{
|
||||
expected := &node.Root{
|
||||
Stmts: []node.Node{
|
||||
&stmt.Expression{
|
||||
Expr: &scalar.Dnumber{Value: "0b1111111111111111111111111111111111111111111111111111111111111111"},
|
||||
@@ -139,7 +139,7 @@ func TestBinaryDNumber(t *testing.T) {
|
||||
func TestHLNumber(t *testing.T) {
|
||||
src := `<? 0x007111111111111111;`
|
||||
|
||||
expected := &stmt.StmtList{
|
||||
expected := &node.Root{
|
||||
Stmts: []node.Node{
|
||||
&stmt.Expression{
|
||||
Expr: &scalar.Lnumber{Value: "0x007111111111111111"},
|
||||
@@ -161,7 +161,7 @@ func TestHLNumber(t *testing.T) {
|
||||
func TestHDNumber(t *testing.T) {
|
||||
src := `<? 0x8111111111111111;`
|
||||
|
||||
expected := &stmt.StmtList{
|
||||
expected := &node.Root{
|
||||
Stmts: []node.Node{
|
||||
&stmt.Expression{
|
||||
Expr: &scalar.Dnumber{Value: "0x8111111111111111"},
|
||||
|
||||
@@ -14,7 +14,7 @@ import (
|
||||
func TestDoubleQuotedScalarString(t *testing.T) {
|
||||
src := `<? "test";`
|
||||
|
||||
expected := &stmt.StmtList{
|
||||
expected := &node.Root{
|
||||
Stmts: []node.Node{
|
||||
&stmt.Expression{
|
||||
Expr: &scalar.String{Value: "\"test\""},
|
||||
@@ -35,7 +35,7 @@ func TestDoubleQuotedScalarString(t *testing.T) {
|
||||
func TestDoubleQuotedScalarStringWithEscapedVar(t *testing.T) {
|
||||
src := `<? "\$test";`
|
||||
|
||||
expected := &stmt.StmtList{
|
||||
expected := &node.Root{
|
||||
Stmts: []node.Node{
|
||||
&stmt.Expression{
|
||||
Expr: &scalar.String{Value: "\"\\$test\""},
|
||||
@@ -59,7 +59,7 @@ func TestMultilineDoubleQuotedScalarString(t *testing.T) {
|
||||
test
|
||||
";`
|
||||
|
||||
expected := &stmt.StmtList{
|
||||
expected := &node.Root{
|
||||
Stmts: []node.Node{
|
||||
&stmt.Expression{
|
||||
Expr: &scalar.String{Value: "\"\n\ttest\n\t\""},
|
||||
@@ -81,7 +81,7 @@ func TestMultilineDoubleQuotedScalarString(t *testing.T) {
|
||||
func TestSingleQuotedScalarString(t *testing.T) {
|
||||
src := `<? '$test';`
|
||||
|
||||
expected := &stmt.StmtList{
|
||||
expected := &node.Root{
|
||||
Stmts: []node.Node{
|
||||
&stmt.Expression{
|
||||
Expr: &scalar.String{Value: "'$test'"},
|
||||
@@ -105,7 +105,7 @@ func TestMultilineSingleQuotedScalarString(t *testing.T) {
|
||||
$test
|
||||
';`
|
||||
|
||||
expected := &stmt.StmtList{
|
||||
expected := &node.Root{
|
||||
Stmts: []node.Node{
|
||||
&stmt.Expression{
|
||||
Expr: &scalar.String{Value: "'\n\t$test\n\t'"},
|
||||
|
||||
Reference in New Issue
Block a user