mirror of
https://github.com/hanzoai/eval.git
synced 2026-09-30 21:47:09 +00:00
Module path renamed to github.com/hanzoai/eval and the Go package renamed from govaluate to eval. Evaluation, parsing, lexing, and operator behavior are unchanged; MIT license and George Lester attribution retained. See NOTICE for lineage.
48 lines
857 B
Go
48 lines
857 B
Go
package eval
|
|
|
|
import (
|
|
"testing"
|
|
)
|
|
|
|
/*
|
|
Tests to make sure that all the different token kinds have different string representations
|
|
Gotta get that 95% code coverage yall. That's why tests like this get written; over-reliance on bad metrics.
|
|
*/
|
|
func TestTokenKindStrings(test *testing.T) {
|
|
|
|
var kindStrings []string
|
|
var kindString string
|
|
|
|
kinds := []TokenKind{
|
|
UNKNOWN,
|
|
PREFIX,
|
|
NUMERIC,
|
|
BOOLEAN,
|
|
STRING,
|
|
PATTERN,
|
|
TIME,
|
|
VARIABLE,
|
|
COMPARATOR,
|
|
LOGICALOP,
|
|
MODIFIER,
|
|
CLAUSE,
|
|
CLAUSE_CLOSE,
|
|
TERNARY,
|
|
}
|
|
|
|
for _, kind := range kinds {
|
|
|
|
kindString = kind.String()
|
|
|
|
for _, extantKind := range kindStrings {
|
|
if extantKind == kindString {
|
|
test.Logf("Token kind test found duplicate string for token kind %v ('%v')\n", kind, kindString)
|
|
test.Fail()
|
|
return
|
|
}
|
|
}
|
|
|
|
kindStrings = append(kindStrings, kindString)
|
|
}
|
|
}
|