php5 test coverage

This commit is contained in:
z7zmey 2018-02-13 12:33:21 +02:00
parent 172f46d0f7
commit edc2513433
5 changed files with 1120 additions and 1071 deletions

6
diff
View File

@ -205,11 +205,14 @@
-205
-206
208
-207
209
-210
211
212
213
214
-215
216
217
218
@ -391,9 +394,6 @@
528
-207
-210
-215
-219
-220
-221

2103
log

File diff suppressed because it is too large Load Diff

View File

@ -56,17 +56,11 @@ func TestFor(t *testing.T) {
}
func TestAltFor(t *testing.T) {
src := `<? for($i = 0; $i < 10; $i++, $i++) : endfor;`
src := `<? for(; $i < 10; $i++) : endfor;`
expected := &stmt.StmtList{
Stmts: []node.Node{
&stmt.For{
Init: []node.Node{
&assign_op.Assign{
Variable: &expr.Variable{VarName: &node.Identifier{Value: "$i"}},
Expression: &scalar.Lnumber{Value: "0"},
},
},
Cond: []node.Node{
&binary_op.Smaller{
Left: &expr.Variable{VarName: &node.Identifier{Value: "$i"}},
@ -77,9 +71,6 @@ func TestAltFor(t *testing.T) {
&expr.PostInc{
Variable: &expr.Variable{VarName: &node.Identifier{Value: "$i"}},
},
&expr.PostInc{
Variable: &expr.Variable{VarName: &node.Identifier{Value: "$i"}},
},
},
Stmt: &stmt.StmtList{Stmts: []node.Node{}},
},

View File

@ -79,3 +79,40 @@ func TestProperties(t *testing.T) {
actual, _, _ = php5.Parse(bytes.NewBufferString(src), "test.php")
assertEqual(t, expected, actual)
}
func TestProperties2(t *testing.T) {
src := `<? class foo {public static $a = 1, $b;}`
expected := &stmt.StmtList{
Stmts: []node.Node{
&stmt.Class{
ClassName: &node.Identifier{Value: "foo"},
Stmts: []node.Node{
&stmt.PropertyList{
Modifiers: []node.Node{
&node.Identifier{Value: "public"},
&node.Identifier{Value: "static"},
},
Properties: []node.Node{
&stmt.Property{
PhpDocComment: "",
Variable: &expr.Variable{VarName: &node.Identifier{Value: "$a"}},
Expr: &scalar.Lnumber{Value: "1"},
},
&stmt.Property{
PhpDocComment: "",
Variable: &expr.Variable{VarName: &node.Identifier{Value: "$b"}},
},
},
},
},
},
},
}
actual, _, _ := php7.Parse(bytes.NewBufferString(src), "test.php")
assertEqual(t, expected, actual)
actual, _, _ = php5.Parse(bytes.NewBufferString(src), "test.php")
assertEqual(t, expected, actual)
}

View File

@ -123,7 +123,7 @@ CAD;
echo $a, 1;
echo($a);
for($i = 0; $i < 10; $i++, $i++) {}
for($i = 0; $i < 10; $i++, $i++) : endfor;
for(; $i < 10; $i++) : endfor;
foreach ($a as $v) {}
foreach ([] as $v) {}
foreach ($a as $v) : endforeach;
@ -161,6 +161,7 @@ CAD;
namespace {}
class foo {var $a;}
class foo {public static $a, $b = 1;}
class foo {public static $a = 1, $b;}
static $a, $b = 1;
static $a = 1, $b;
@ -893,12 +894,6 @@ CAD;
Stmt: &stmt.StmtList{Stmts: []node.Node{}},
},
&stmt.For{
Init: []node.Node{
&assign_op.Assign{
Variable: &expr.Variable{VarName: &node.Identifier{Value: "$i"}},
Expression: &scalar.Lnumber{Value: "0"},
},
},
Cond: []node.Node{
&binary_op.Smaller{
Left: &expr.Variable{VarName: &node.Identifier{Value: "$i"}},
@ -909,9 +904,6 @@ CAD;
&expr.PostInc{
Variable: &expr.Variable{VarName: &node.Identifier{Value: "$i"}},
},
&expr.PostInc{
Variable: &expr.Variable{VarName: &node.Identifier{Value: "$i"}},
},
},
Stmt: &stmt.StmtList{Stmts: []node.Node{}},
},
@ -1203,6 +1195,28 @@ CAD;
},
},
},
&stmt.Class{
ClassName: &node.Identifier{Value: "foo"},
Stmts: []node.Node{
&stmt.PropertyList{
Modifiers: []node.Node{
&node.Identifier{Value: "public"},
&node.Identifier{Value: "static"},
},
Properties: []node.Node{
&stmt.Property{
PhpDocComment: "",
Variable: &expr.Variable{VarName: &node.Identifier{Value: "$a"}},
Expr: &scalar.Lnumber{Value: "1"},
},
&stmt.Property{
PhpDocComment: "",
Variable: &expr.Variable{VarName: &node.Identifier{Value: "$b"}},
},
},
},
},
},
&stmt.Static{
Vars: []node.Node{
&stmt.StaticVar{