2017-12-04 10:40:36 +00:00
|
|
|
package test
|
|
|
|
|
|
|
|
import (
|
|
|
|
"bytes"
|
|
|
|
"testing"
|
|
|
|
|
2017-12-04 10:56:55 +00:00
|
|
|
"github.com/kylelemons/godebug/pretty"
|
2017-12-04 10:40:36 +00:00
|
|
|
"github.com/z7zmey/php-parser/node"
|
|
|
|
"github.com/z7zmey/php-parser/parser"
|
|
|
|
"github.com/z7zmey/php-parser/token"
|
|
|
|
)
|
|
|
|
|
|
|
|
func TestNewNodeScalarString(t *testing.T) {
|
|
|
|
src := `<? "test";`
|
|
|
|
|
|
|
|
strToken := token.NewToken([]byte("\"test\""), 1, 1)
|
|
|
|
strNode := node.NewNodeScalarString(strToken)
|
|
|
|
expected := node.SimpleNode("Statements").Append(strNode)
|
|
|
|
|
|
|
|
node := parser.Parse(bytes.NewBufferString(src), "test.php")
|
|
|
|
|
2017-12-04 10:56:55 +00:00
|
|
|
if diff := pretty.Compare(expected, node); diff != "" {
|
|
|
|
t.Errorf("post-AddCrew diff: (-expected +actual)\n%s", diff)
|
2017-12-04 10:40:36 +00:00
|
|
|
}
|
|
|
|
}
|