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 -205
-206 -206
208 208
-207
209 209
-210
211 211
212 212
213 213
214 214
-215
216 216
217 217
218 218
@ -391,9 +394,6 @@
528 528
-207
-210
-215
-219 -219
-220 -220
-221 -221

2133
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) { func TestAltFor(t *testing.T) {
src := `<? for($i = 0; $i < 10; $i++, $i++) : endfor;` src := `<? for(; $i < 10; $i++) : endfor;`
expected := &stmt.StmtList{ expected := &stmt.StmtList{
Stmts: []node.Node{ Stmts: []node.Node{
&stmt.For{ &stmt.For{
Init: []node.Node{
&assign_op.Assign{
Variable: &expr.Variable{VarName: &node.Identifier{Value: "$i"}},
Expression: &scalar.Lnumber{Value: "0"},
},
},
Cond: []node.Node{ Cond: []node.Node{
&binary_op.Smaller{ &binary_op.Smaller{
Left: &expr.Variable{VarName: &node.Identifier{Value: "$i"}}, Left: &expr.Variable{VarName: &node.Identifier{Value: "$i"}},
@ -77,9 +71,6 @@ func TestAltFor(t *testing.T) {
&expr.PostInc{ &expr.PostInc{
Variable: &expr.Variable{VarName: &node.Identifier{Value: "$i"}}, Variable: &expr.Variable{VarName: &node.Identifier{Value: "$i"}},
}, },
&expr.PostInc{
Variable: &expr.Variable{VarName: &node.Identifier{Value: "$i"}},
},
}, },
Stmt: &stmt.StmtList{Stmts: []node.Node{}}, 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") actual, _, _ = php5.Parse(bytes.NewBufferString(src), "test.php")
assertEqual(t, expected, actual) 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, 1;
echo($a); echo($a);
for($i = 0; $i < 10; $i++, $i++) {} 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 ($a as $v) {}
foreach ([] as $v) {} foreach ([] as $v) {}
foreach ($a as $v) : endforeach; foreach ($a as $v) : endforeach;
@ -161,6 +161,7 @@ CAD;
namespace {} namespace {}
class foo {var $a;} class foo {var $a;}
class foo {public static $a, $b = 1;} class foo {public static $a, $b = 1;}
class foo {public static $a = 1, $b;}
static $a, $b = 1; static $a, $b = 1;
static $a = 1, $b; static $a = 1, $b;
@ -893,12 +894,6 @@ CAD;
Stmt: &stmt.StmtList{Stmts: []node.Node{}}, Stmt: &stmt.StmtList{Stmts: []node.Node{}},
}, },
&stmt.For{ &stmt.For{
Init: []node.Node{
&assign_op.Assign{
Variable: &expr.Variable{VarName: &node.Identifier{Value: "$i"}},
Expression: &scalar.Lnumber{Value: "0"},
},
},
Cond: []node.Node{ Cond: []node.Node{
&binary_op.Smaller{ &binary_op.Smaller{
Left: &expr.Variable{VarName: &node.Identifier{Value: "$i"}}, Left: &expr.Variable{VarName: &node.Identifier{Value: "$i"}},
@ -909,9 +904,6 @@ CAD;
&expr.PostInc{ &expr.PostInc{
Variable: &expr.Variable{VarName: &node.Identifier{Value: "$i"}}, Variable: &expr.Variable{VarName: &node.Identifier{Value: "$i"}},
}, },
&expr.PostInc{
Variable: &expr.Variable{VarName: &node.Identifier{Value: "$i"}},
},
}, },
Stmt: &stmt.StmtList{Stmts: []node.Node{}}, 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{ &stmt.Static{
Vars: []node.Node{ Vars: []node.Node{
&stmt.StaticVar{ &stmt.StaticVar{