php-parser/node/scalar/t_magic_constant_test.go

31 lines
637 B
Go
Raw Normal View History

2018-01-12 13:13:05 +00:00
package scalar_test
import (
"bytes"
"testing"
"github.com/kylelemons/godebug/pretty"
"github.com/z7zmey/php-parser/node"
"github.com/z7zmey/php-parser/node/scalar"
"github.com/z7zmey/php-parser/node/stmt"
2018-02-04 19:44:58 +00:00
"github.com/z7zmey/php-parser/php7"
2018-01-12 13:13:05 +00:00
)
func TestMagicConstant(t *testing.T) {
src := `<? __DIR__;`
expected := &stmt.StmtList{
Stmts: []node.Node{
&stmt.Expression{
Expr: &scalar.MagicConstant{Value: "__DIR__"},
},
},
}
2018-02-04 19:44:58 +00:00
actual, _, _ := php7.Parse(bytes.NewBufferString(src), "test.php")
2018-01-12 13:13:05 +00:00
if diff := pretty.Compare(expected, actual); diff != "" {
t.Errorf("diff: (-expected +actual)\n%s", diff)
}
}