2018-04-15 11:47:40 +00:00
|
|
|
package scanner_test
|
2018-02-18 10:55:32 +00:00
|
|
|
|
|
|
|
import (
|
|
|
|
"reflect"
|
|
|
|
"testing"
|
|
|
|
|
2019-02-13 20:18:07 +00:00
|
|
|
"github.com/z7zmey/php-parser/freefloating"
|
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-06-10 23:41:12 +00:00
|
|
|
tkn := &scanner.Token{
|
2018-06-24 07:19:44 +00:00
|
|
|
Value: `foo`,
|
|
|
|
StartLine: 1,
|
|
|
|
EndLine: 1,
|
|
|
|
StartPos: 0,
|
|
|
|
EndPos: 3,
|
2018-06-10 23:41:12 +00:00
|
|
|
}
|
2018-02-18 10:55:32 +00:00
|
|
|
|
2019-02-13 20:18:07 +00:00
|
|
|
c := []freefloating.String{
|
|
|
|
{
|
|
|
|
Value: "test comment",
|
|
|
|
StringType: freefloating.CommentType,
|
|
|
|
Position: nil,
|
2018-07-29 08:44:38 +00:00
|
|
|
},
|
2018-02-18 10:55:32 +00:00
|
|
|
}
|
|
|
|
|
2019-02-13 20:18:07 +00:00
|
|
|
tkn.FreeFloating = c
|
2018-02-18 10:55:32 +00:00
|
|
|
|
2019-02-13 20:18:07 +00:00
|
|
|
if !reflect.DeepEqual(tkn.FreeFloating, 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")
|
|
|
|
}
|
|
|
|
}
|