php5 test coverage

This commit is contained in:
z7zmey
2018-02-13 19:38:37 +02:00
parent 0a34643856
commit b13d520387
6 changed files with 1026 additions and 799 deletions

View File

@@ -38,3 +38,24 @@ func TestClassConstFetch(t *testing.T) {
actual, _, _ = php5.Parse(bytes.NewBufferString(src), "test.php")
assertEqual(t, expected, actual)
}
func TestStaticClassConstFetch(t *testing.T) {
src := `<? static::bar;`
expected := &stmt.StmtList{
Stmts: []node.Node{
&stmt.Expression{
Expr: &expr.ClassConstFetch{
Class: &node.Identifier{Value: "static"},
ConstantName: &node.Identifier{Value: "bar"},
},
},
},
}
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

@@ -91,3 +91,51 @@ func TestStaticCallFullyQualified(t *testing.T) {
actual, _, _ = php5.Parse(bytes.NewBufferString(src), "test.php")
assertEqual(t, expected, actual)
}
func TestStaticCallVar(t *testing.T) {
src := `<? Foo::$bar();`
expected := &stmt.StmtList{
Stmts: []node.Node{
&stmt.Expression{
Expr: &expr.StaticCall{
Class: &name.Name{
Parts: []node.Node{
&name.NamePart{Value: "Foo"},
},
},
Call: &expr.Variable{VarName: &node.Identifier{Value: "$bar"}},
Arguments: []node.Node{},
},
},
},
}
actual, _, _ := php7.Parse(bytes.NewBufferString(src), "test.php")
assertEqual(t, expected, actual)
actual, _, _ = php5.Parse(bytes.NewBufferString(src), "test.php")
assertEqual(t, expected, actual)
}
func TestStaticCallVarVar(t *testing.T) {
src := `<? $foo::$bar();`
expected := &stmt.StmtList{
Stmts: []node.Node{
&stmt.Expression{
Expr: &expr.StaticCall{
Class: &expr.Variable{VarName: &node.Identifier{Value: "$foo"}},
Call: &expr.Variable{VarName: &node.Identifier{Value: "$bar"}},
Arguments: []node.Node{},
},
},
},
}
actual, _, _ := php7.Parse(bytes.NewBufferString(src), "test.php")
assertEqual(t, expected, actual)
actual, _, _ = php5.Parse(bytes.NewBufferString(src), "test.php")
assertEqual(t, expected, actual)
}