-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtoken_test.go
More file actions
executable file
·34 lines (31 loc) · 1.03 KB
/
token_test.go
File metadata and controls
executable file
·34 lines (31 loc) · 1.03 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
package tokenizer_test
import (
"testing"
// Packages
tokenizer "github.com/mutablelogic/go-tokenizer"
assert "github.com/stretchr/testify/assert"
)
func Test_Token_001(t *testing.T) {
assert := assert.New(t)
t.Run("Any", func(t *testing.T) {
tok := tokenizer.NewToken(tokenizer.Any, "hello", tokenizer.Pos{Path: nil, Line: 0, Col: 0})
assert.NotNil(tok)
assert.Equal(tokenizer.Any, tok.Kind)
assert.Equal("hello", tok.Val)
assert.Equal("pos<1:1>", tok.Pos.String())
})
t.Run("String", func(t *testing.T) {
tok := tokenizer.NewToken(tokenizer.String, "hello", tokenizer.Pos{Path: nil, Line: 0, Col: 0})
assert.NotNil(tok)
assert.Equal(tokenizer.String, tok.Kind)
assert.Equal("hello", tok.Val)
assert.Equal("pos<1:1>", tok.Pos.String())
})
t.Run("Expr", func(t *testing.T) {
tok := tokenizer.NewToken(tokenizer.Expr, "hello", tokenizer.Pos{Path: nil, Line: 0, Col: 0})
assert.NotNil(tok)
assert.Equal(tokenizer.Expr, tok.Kind)
assert.Equal("hello", tok.Val)
assert.Equal("pos<1:1>", tok.Pos.String())
})
}