php-parser/comment/comment_test.go

42 lines
911 B
Go
Raw Normal View History

2018-01-12 23:58:59 +00:00
package comment_test
import (
"testing"
2018-04-15 18:39:26 +00:00
"github.com/z7zmey/php-parser/position"
2018-01-12 23:58:59 +00:00
"github.com/z7zmey/php-parser/comment"
"github.com/z7zmey/php-parser/node"
)
func TestComments(t *testing.T) {
n := node.NewIdentifier("test")
2018-04-15 12:55:33 +00:00
commentGroup := []*comment.Comment{
2018-04-15 18:39:26 +00:00
comment.NewComment("/** hello world */", nil),
comment.NewComment("// hello world", nil),
2018-01-12 23:58:59 +00:00
}
comments := comment.Comments{}
comments.AddComments(n, commentGroup)
if comments[n][0].String() != "/** hello world */" {
t.Errorf("expected and actual are not equal\n")
}
if comments[n][1].String() != "// hello world" {
t.Errorf("expected and actual are not equal\n")
}
}
2018-04-15 18:39:26 +00:00
func TestCommentPos(t *testing.T) {
expected := position.NewPosition(0, 0, 0, 0)
comment := comment.NewComment("/** hello world */", expected)
actual := comment.Position()
if expected != actual {
t.Errorf("expected and actual are not equal\n")
}
}