php5 test coverage
This commit is contained in:
@@ -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{}},
|
||||
},
|
||||
|
||||
@@ -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)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user