Simplified file structure
This commit is contained in:
parent
cacee7260a
commit
a466281307
219 changed files with 453 additions and 457 deletions
52
src/token/Token_test.go
Normal file
52
src/token/Token_test.go
Normal file
|
@ -0,0 +1,52 @@
|
|||
package token_test
|
||||
|
||||
import (
|
||||
"testing"
|
||||
|
||||
"git.akyoto.dev/cli/q/src/token"
|
||||
"git.akyoto.dev/go/assert"
|
||||
)
|
||||
|
||||
func TestTokenEnd(t *testing.T) {
|
||||
hello := token.Token{
|
||||
Kind: token.Identifier,
|
||||
Position: 0,
|
||||
Length: 5,
|
||||
}
|
||||
|
||||
assert.Equal(t, hello.End(), 5)
|
||||
}
|
||||
|
||||
func TestTokenReset(t *testing.T) {
|
||||
hello := token.Token{
|
||||
Kind: token.Identifier,
|
||||
Position: 1,
|
||||
Length: 5,
|
||||
}
|
||||
|
||||
hello.Reset()
|
||||
assert.Equal(t, hello.Position, 0)
|
||||
assert.Equal(t, hello.Length, 0)
|
||||
assert.Equal(t, hello.Kind, token.Invalid)
|
||||
}
|
||||
|
||||
func TestTokenText(t *testing.T) {
|
||||
buffer := []byte("hello, world")
|
||||
hello := token.Token{Kind: token.Identifier, Position: 0, Length: 5}
|
||||
comma := token.Token{Kind: token.Separator, Position: 5, Length: 1}
|
||||
world := token.Token{Kind: token.Identifier, Position: 7, Length: 5}
|
||||
|
||||
assert.Equal(t, hello.Text(buffer), "hello")
|
||||
assert.Equal(t, comma.Text(buffer), ",")
|
||||
assert.Equal(t, world.Text(buffer), "world")
|
||||
}
|
||||
|
||||
func TestTokenGroups(t *testing.T) {
|
||||
assignment := token.Token{Kind: token.Assign}
|
||||
operator := token.Token{Kind: token.Add}
|
||||
keyword := token.Token{Kind: token.If}
|
||||
|
||||
assert.True(t, assignment.IsAssignment())
|
||||
assert.True(t, operator.IsOperator())
|
||||
assert.True(t, keyword.IsKeyword())
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue