2018-06-30 21:05:59 +00:00
|
|
|
package scalar_test
|
|
|
|
|
|
|
|
import (
|
|
|
|
"testing"
|
|
|
|
|
|
|
|
"github.com/z7zmey/php-parser/node/scalar"
|
|
|
|
|
|
|
|
"github.com/z7zmey/php-parser/meta"
|
|
|
|
|
|
|
|
"github.com/z7zmey/php-parser/node"
|
|
|
|
)
|
|
|
|
|
|
|
|
var nodes = []node.Node{
|
|
|
|
&scalar.Dnumber{},
|
|
|
|
&scalar.EncapsedStringPart{},
|
|
|
|
&scalar.Encapsed{},
|
|
|
|
&scalar.Heredoc{},
|
|
|
|
&scalar.Lnumber{},
|
|
|
|
&scalar.MagicConstant{},
|
|
|
|
&scalar.String{},
|
|
|
|
}
|
|
|
|
|
|
|
|
func TestMeta(t *testing.T) {
|
2018-07-29 08:44:38 +00:00
|
|
|
expected := &meta.Collection{
|
|
|
|
&meta.Data{
|
|
|
|
Value: "//comment\n",
|
|
|
|
Type: meta.CommentType,
|
|
|
|
Position: nil,
|
|
|
|
},
|
|
|
|
&meta.Data{
|
|
|
|
Value: " ",
|
|
|
|
Type: meta.WhiteSpaceType,
|
|
|
|
Position: nil,
|
|
|
|
},
|
2018-06-30 21:05:59 +00:00
|
|
|
}
|
|
|
|
for _, n := range nodes {
|
2018-07-29 08:44:38 +00:00
|
|
|
n.GetMeta().Push(*expected...)
|
2018-06-30 21:05:59 +00:00
|
|
|
actual := n.GetMeta()
|
|
|
|
assertEqual(t, expected, actual)
|
|
|
|
}
|
|
|
|
}
|