update Clone tests

This commit is contained in:
z7zmey 2018-02-10 11:58:41 +02:00
parent 572c9e1d79
commit 3dbab3b2a7

View File

@ -12,7 +12,7 @@ import (
"github.com/z7zmey/php-parser/php7" "github.com/z7zmey/php-parser/php7"
) )
func TestClone(t *testing.T) { func TestCloneBrackets(t *testing.T) {
src := `<? clone($a);` src := `<? clone($a);`
expected := &stmt.StmtList{ expected := &stmt.StmtList{
@ -31,3 +31,23 @@ func TestClone(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 TestClone(t *testing.T) {
src := `<? clone $a;`
expected := &stmt.StmtList{
Stmts: []node.Node{
&stmt.Expression{
Expr: &expr.Clone{
Expr: &expr.Variable{VarName: &node.Identifier{Value: "$a"}},
},
},
},
}
actual, _, _ := php7.Parse(bytes.NewBufferString(src), "test.php")
assertEqual(t, expected, actual)
actual, _, _ = php5.Parse(bytes.NewBufferString(src), "test.php")
assertEqual(t, expected, actual)
}