@@ -37,7 +37,7 @@ func TestPrintParameter(t *testing.T) {
37
37
Variadic : true ,
38
38
VariableType : & name.FullyQualified {Parts : []node.Node {& name.NamePart {Value : "Foo" }}},
39
39
Variable : & expr.Variable {VarName : & node.Identifier {Value : "var" }},
40
- DefaultValue : & scalar.String {Value : "default" },
40
+ DefaultValue : & scalar.String {Value : "' default' " },
41
41
})
42
42
43
43
expected := "\\ Foo ...$var = 'default'"
@@ -58,7 +58,7 @@ func TestPrintNullable(t *testing.T) {
58
58
Variadic : true ,
59
59
VariableType : & name.FullyQualified {Parts : []node.Node {& name.NamePart {Value : "Foo" }}},
60
60
Variable : & expr.Variable {VarName : & node.Identifier {Value : "var" }},
61
- DefaultValue : & scalar.String {Value : "default" },
61
+ DefaultValue : & scalar.String {Value : "' default' " },
62
62
},
63
63
})
64
64
@@ -220,10 +220,13 @@ func TestPrintScalarString(t *testing.T) {
220
220
o := bytes .NewBufferString ("" )
221
221
222
222
p := printer .NewPrinter (o , " " )
223
- p .Print (& scalar.String {Value : "hello world" })
223
+ p .Print (& scalar.String {Value : "' hello world' " })
224
224
225
- if o .String () != `'hello world'` {
226
- t .Errorf ("TestPrintScalarString is failed\n " )
225
+ expected := `'hello world'`
226
+ actual := o .String ()
227
+
228
+ if expected != actual {
229
+ t .Errorf ("\n expected: %s\n got: %s\n " , expected , actual )
227
230
}
228
231
}
229
232
@@ -1106,7 +1109,7 @@ func TestPrintExprArrayItemWithKey(t *testing.T) {
1106
1109
p := printer .NewPrinter (o , " " )
1107
1110
p .Print (& expr.ArrayItem {
1108
1111
ByRef : false ,
1109
- Key : & scalar.String {Value : "Hello" },
1112
+ Key : & scalar.String {Value : "' Hello' " },
1110
1113
Val : & expr.Variable {VarName : & node.Identifier {Value : "world" }},
1111
1114
})
1112
1115
@@ -1143,7 +1146,7 @@ func TestPrintExprArray(t *testing.T) {
1143
1146
Items : []node.Node {
1144
1147
& expr.ArrayItem {
1145
1148
ByRef : false ,
1146
- Key : & scalar.String {Value : "Hello" },
1149
+ Key : & scalar.String {Value : "' Hello' " },
1147
1150
Val : & expr.Variable {VarName : & node.Identifier {Value : "world" }},
1148
1151
},
1149
1152
& expr.ArrayItem {
@@ -1413,7 +1416,7 @@ func TestPrintInclude(t *testing.T) {
1413
1416
o := bytes .NewBufferString ("" )
1414
1417
1415
1418
p := printer .NewPrinter (o , " " )
1416
- p .Print (& expr.Include {Expr : & scalar.String {Value : "path" }})
1419
+ p .Print (& expr.Include {Expr : & scalar.String {Value : "' path' " }})
1417
1420
1418
1421
expected := `include 'path'`
1419
1422
actual := o .String ()
@@ -1427,7 +1430,7 @@ func TestPrintIncludeOnce(t *testing.T) {
1427
1430
o := bytes .NewBufferString ("" )
1428
1431
1429
1432
p := printer .NewPrinter (o , " " )
1430
- p .Print (& expr.IncludeOnce {Expr : & scalar.String {Value : "path" }})
1433
+ p .Print (& expr.IncludeOnce {Expr : & scalar.String {Value : "' path' " }})
1431
1434
1432
1435
expected := `include_once 'path'`
1433
1436
actual := o .String ()
@@ -1653,7 +1656,7 @@ func TestPrintRequire(t *testing.T) {
1653
1656
o := bytes .NewBufferString ("" )
1654
1657
1655
1658
p := printer .NewPrinter (o , " " )
1656
- p .Print (& expr.Require {Expr : & scalar.String {Value : "path" }})
1659
+ p .Print (& expr.Require {Expr : & scalar.String {Value : "' path' " }})
1657
1660
1658
1661
expected := `require 'path'`
1659
1662
actual := o .String ()
@@ -1667,7 +1670,7 @@ func TestPrintRequireOnce(t *testing.T) {
1667
1670
o := bytes .NewBufferString ("" )
1668
1671
1669
1672
p := printer .NewPrinter (o , " " )
1670
- p .Print (& expr.RequireOnce {Expr : & scalar.String {Value : "path" }})
1673
+ p .Print (& expr.RequireOnce {Expr : & scalar.String {Value : "' path' " }})
1671
1674
1672
1675
expected := `require_once 'path'`
1673
1676
actual := o .String ()
@@ -1704,7 +1707,7 @@ func TestPrintExprShortArray(t *testing.T) {
1704
1707
p .Print (& expr.ShortArray {
1705
1708
Items : []node.Node {
1706
1709
& expr.ArrayItem {
1707
- Key : & scalar.String {Value : "Hello" },
1710
+ Key : & scalar.String {Value : "' Hello' " },
1708
1711
Val : & expr.Variable {VarName : & node.Identifier {Value : "world" }},
1709
1712
},
1710
1713
& expr.ArrayItem {
@@ -1806,7 +1809,7 @@ func TestPrintTernary(t *testing.T) {
1806
1809
p := printer .NewPrinter (o , " " )
1807
1810
p .Print (& expr.Ternary {
1808
1811
Condition : & expr.Variable {VarName : & node.Identifier {Value : "a" }},
1809
- IfTrue : & expr.Variable {VarName : & node.Identifier {Value : "b" }},
1812
+ IfFalse : & expr.Variable {VarName : & node.Identifier {Value : "b" }},
1810
1813
})
1811
1814
1812
1815
expected := `$a ?: $b`
@@ -1823,8 +1826,8 @@ func TestPrintTernaryFull(t *testing.T) {
1823
1826
p := printer .NewPrinter (o , " " )
1824
1827
p .Print (& expr.Ternary {
1825
1828
Condition : & expr.Variable {VarName : & node.Identifier {Value : "a" }},
1826
- IfFalse : & expr.Variable {VarName : & node.Identifier {Value : "b" }},
1827
- IfTrue : & expr.Variable {VarName : & node.Identifier {Value : "c" }},
1829
+ IfTrue : & expr.Variable {VarName : & node.Identifier {Value : "b" }},
1830
+ IfFalse : & expr.Variable {VarName : & node.Identifier {Value : "c" }},
1828
1831
})
1829
1832
1830
1833
expected := `$a ? $b : $c`
@@ -2142,13 +2145,13 @@ func TestPrintStmtAltSwitch(t *testing.T) {
2142
2145
Cond : & expr.Variable {VarName : & node.Identifier {Value : "var" }},
2143
2146
Cases : []node.Node {
2144
2147
& stmt.Case {
2145
- Cond : & scalar.String {Value : "a " },
2148
+ Cond : & scalar.String {Value : "'a' " },
2146
2149
Stmts : []node.Node {
2147
2150
& stmt.Expression {Expr : & expr.Variable {VarName : & node.Identifier {Value : "a" }}},
2148
2151
},
2149
2152
},
2150
2153
& stmt.Case {
2151
- Cond : & scalar.String {Value : "b " },
2154
+ Cond : & scalar.String {Value : "'b' " },
2152
2155
Stmts : []node.Node {
2153
2156
& stmt.Expression {Expr : & expr.Variable {VarName : & node.Identifier {Value : "b" }}},
2154
2157
},
@@ -2343,7 +2346,7 @@ func TestPrintStmtClass(t *testing.T) {
2343
2346
Consts : []node.Node {
2344
2347
& stmt.Constant {
2345
2348
ConstantName : & node.Identifier {Value : "FOO" },
2346
- Expr : & scalar.String {Value : "bar" },
2349
+ Expr : & scalar.String {Value : "' bar' " },
2347
2350
},
2348
2351
},
2349
2352
},
@@ -2392,7 +2395,7 @@ func TestPrintStmtAnonymousClass(t *testing.T) {
2392
2395
Consts : []node.Node {
2393
2396
& stmt.Constant {
2394
2397
ConstantName : & node.Identifier {Value : "FOO" },
2395
- Expr : & scalar.String {Value : "bar" },
2398
+ Expr : & scalar.String {Value : "' bar' " },
2396
2399
},
2397
2400
},
2398
2401
},
@@ -2423,11 +2426,11 @@ func TestPrintStmtClassConstList(t *testing.T) {
2423
2426
Consts : []node.Node {
2424
2427
& stmt.Constant {
2425
2428
ConstantName : & node.Identifier {Value : "FOO" },
2426
- Expr : & scalar.String {Value : "a " },
2429
+ Expr : & scalar.String {Value : "'a' " },
2427
2430
},
2428
2431
& stmt.Constant {
2429
2432
ConstantName : & node.Identifier {Value : "BAR" },
2430
- Expr : & scalar.String {Value : "b " },
2433
+ Expr : & scalar.String {Value : "'b' " },
2431
2434
},
2432
2435
},
2433
2436
})
@@ -2446,7 +2449,7 @@ func TestPrintStmtConstant(t *testing.T) {
2446
2449
p := printer .NewPrinter (o , " " )
2447
2450
p .Print (& stmt.Constant {
2448
2451
ConstantName : & node.Identifier {Value : "FOO" },
2449
- Expr : & scalar.String {Value : "BAR" },
2452
+ Expr : & scalar.String {Value : "' BAR' " },
2450
2453
})
2451
2454
2452
2455
expected := "FOO = 'BAR'"
@@ -2483,7 +2486,7 @@ func TestPrintStmtDeclareStmts(t *testing.T) {
2483
2486
Consts : []node.Node {
2484
2487
& stmt.Constant {
2485
2488
ConstantName : & node.Identifier {Value : "FOO" },
2486
- Expr : & scalar.String {Value : "bar" },
2489
+ Expr : & scalar.String {Value : "' bar' " },
2487
2490
},
2488
2491
},
2489
2492
Stmt : & stmt.StmtList {
@@ -2517,10 +2520,10 @@ func TestPrintStmtDeclareExpr(t *testing.T) {
2517
2520
Consts : []node.Node {
2518
2521
& stmt.Constant {
2519
2522
ConstantName : & node.Identifier {Value : "FOO" },
2520
- Expr : & scalar.String {Value : "bar" },
2523
+ Expr : & scalar.String {Value : "' bar' " },
2521
2524
},
2522
2525
},
2523
- Stmt : & stmt.Expression {Expr : & scalar.String {Value : "bar" }},
2526
+ Stmt : & stmt.Expression {Expr : & scalar.String {Value : "' bar' " }},
2524
2527
},
2525
2528
},
2526
2529
})
@@ -2544,7 +2547,7 @@ func TestPrintStmtDeclareNop(t *testing.T) {
2544
2547
Consts : []node.Node {
2545
2548
& stmt.Constant {
2546
2549
ConstantName : & node.Identifier {Value : "FOO" },
2547
- Expr : & scalar.String {Value : "bar" },
2550
+ Expr : & scalar.String {Value : "' bar' " },
2548
2551
},
2549
2552
},
2550
2553
Stmt : & stmt.Nop {},
@@ -2697,7 +2700,7 @@ func TestPrintStmtElseIfExpr(t *testing.T) {
2697
2700
p := printer .NewPrinter (o , " " )
2698
2701
p .Print (& stmt.ElseIf {
2699
2702
Cond : & expr.Variable {VarName : & node.Identifier {Value : "a" }},
2700
- Stmt : & stmt.Expression {Expr : & scalar.String {Value : "bar" }},
2703
+ Stmt : & stmt.Expression {Expr : & scalar.String {Value : "' bar' " }},
2701
2704
})
2702
2705
2703
2706
expected := `elseif ($a)
@@ -2753,7 +2756,7 @@ func TestPrintStmtElseExpr(t *testing.T) {
2753
2756
2754
2757
p := printer .NewPrinter (o , " " )
2755
2758
p .Print (& stmt.Else {
2756
- Stmt : & stmt.Expression {Expr : & scalar.String {Value : "bar" }},
2759
+ Stmt : & stmt.Expression {Expr : & scalar.String {Value : "' bar' " }},
2757
2760
})
2758
2761
2759
2762
expected := `else
@@ -2877,7 +2880,7 @@ func TestPrintStmtForExpr(t *testing.T) {
2877
2880
Loop : []node.Node {
2878
2881
& expr.Variable {VarName : & node.Identifier {Value : "c" }},
2879
2882
},
2880
- Stmt : & stmt.Expression {Expr : & scalar.String {Value : "bar" }},
2883
+ Stmt : & stmt.Expression {Expr : & scalar.String {Value : "' bar' " }},
2881
2884
},
2882
2885
},
2883
2886
})
@@ -2958,7 +2961,7 @@ func TestPrintStmtForeachExpr(t *testing.T) {
2958
2961
Expr : & expr.Variable {VarName : & node.Identifier {Value : "a" }},
2959
2962
Key : & expr.Variable {VarName : & node.Identifier {Value : "k" }},
2960
2963
Variable : & expr.Variable {VarName : & node.Identifier {Value : "v" }},
2961
- Stmt : & stmt.Expression {Expr : & scalar.String {Value : "bar" }},
2964
+ Stmt : & stmt.Expression {Expr : & scalar.String {Value : "' bar' " }},
2962
2965
},
2963
2966
},
2964
2967
})
@@ -3505,13 +3508,13 @@ func TestPrintStmtSwitch(t *testing.T) {
3505
3508
Cond : & expr.Variable {VarName : & node.Identifier {Value : "var" }},
3506
3509
Cases : []node.Node {
3507
3510
& stmt.Case {
3508
- Cond : & scalar.String {Value : "a " },
3511
+ Cond : & scalar.String {Value : "'a' " },
3509
3512
Stmts : []node.Node {
3510
3513
& stmt.Expression {Expr : & expr.Variable {VarName : & node.Identifier {Value : "a" }}},
3511
3514
},
3512
3515
},
3513
3516
& stmt.Case {
3514
- Cond : & scalar.String {Value : "b " },
3517
+ Cond : & scalar.String {Value : "'b' " },
3515
3518
Stmts : []node.Node {
3516
3519
& stmt.Expression {Expr : & expr.Variable {VarName : & node.Identifier {Value : "b" }}},
3517
3520
},
0 commit comments