2018-04-15 11:47:40 +00:00
|
|
|
package scanner_test
|
2018-02-18 10:55:32 +00:00
|
|
|
|
|
|
|
import (
|
|
|
|
"reflect"
|
|
|
|
"testing"
|
|
|
|
|
2018-04-15 19:56:20 +00:00
|
|
|
"github.com/z7zmey/php-parser/position"
|
|
|
|
|
2018-02-18 10:55:32 +00:00
|
|
|
"github.com/z7zmey/php-parser/comment"
|
|
|
|
|
2018-04-15 11:47:40 +00:00
|
|
|
"github.com/z7zmey/php-parser/scanner"
|
2018-02-18 10:55:32 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
func TestToken(t *testing.T) {
|
2018-04-15 19:56:20 +00:00
|
|
|
pos := position.NewPosition(1, 1, 0, 3)
|
|
|
|
tkn := scanner.NewToken([]byte(`foo`), pos)
|
2018-02-18 10:55:32 +00:00
|
|
|
|
2018-04-15 12:55:33 +00:00
|
|
|
c := []*comment.Comment{
|
2018-04-15 18:39:26 +00:00
|
|
|
comment.NewComment("test comment", nil),
|
2018-02-18 10:55:32 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
tkn.SetComments(c)
|
|
|
|
|
2018-04-15 19:56:20 +00:00
|
|
|
if !reflect.DeepEqual(tkn.Comments(), c) {
|
2018-02-18 10:55:32 +00:00
|
|
|
t.Errorf("comments are not equal\n")
|
|
|
|
}
|
|
|
|
|
|
|
|
if tkn.String() != `foo` {
|
|
|
|
t.Errorf("token value is not equal\n")
|
|
|
|
}
|
|
|
|
|
2018-04-15 19:56:20 +00:00
|
|
|
if tkn.Position() != pos {
|
2018-02-18 10:55:32 +00:00
|
|
|
t.Errorf("token position is not equal\n")
|
|
|
|
}
|
|
|
|
}
|