This commit is contained in:
parent
714a722aaa
commit
ec300c9a70
3 changed files with 0 additions and 35 deletions
|
@ -1,4 +0,0 @@
|
|||
package compiler
|
||||
|
||||
// Result contains everything we need to write an executable file to disk.
|
||||
type Result struct{}
|
|
@ -1,14 +0,0 @@
|
|||
package token
|
||||
|
||||
// Count counts how often the given token appears in the token list.
|
||||
func Count(tokens []Token, buffer []byte, kind Kind, name string) uint8 {
|
||||
count := uint8(0)
|
||||
|
||||
for _, t := range tokens {
|
||||
if t.Kind == kind && t.String(buffer) == name {
|
||||
count++
|
||||
}
|
||||
}
|
||||
|
||||
return count
|
||||
}
|
|
@ -1,17 +0,0 @@
|
|||
package token_test
|
||||
|
||||
import (
|
||||
"testing"
|
||||
|
||||
"git.urbach.dev/cli/q/src/token"
|
||||
"git.urbach.dev/go/assert"
|
||||
)
|
||||
|
||||
func TestCount(t *testing.T) {
|
||||
buffer := []byte(`a b b c c c`)
|
||||
tokens := token.Tokenize(buffer)
|
||||
assert.Equal(t, token.Count(tokens, buffer, token.Identifier, "a"), 1)
|
||||
assert.Equal(t, token.Count(tokens, buffer, token.Identifier, "b"), 2)
|
||||
assert.Equal(t, token.Count(tokens, buffer, token.Identifier, "c"), 3)
|
||||
assert.Equal(t, token.Count(tokens, buffer, token.Identifier, "d"), 0)
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue