optimizations
Some checks failed
Build / build (push) Successful in 9m47s
Publish Image / publish (push) Failing after 49s
Test / build (push) Failing after 6m19s

This commit is contained in:
Chuck Smith
2024-04-02 14:32:03 -04:00
parent 07fd82b261
commit 88e3330856
18 changed files with 510 additions and 31 deletions

View File

@@ -210,3 +210,35 @@ c := "\r\n\t"
}
}
func TestFloats(t *testing.T) {
input := `2.5
3.14
`
tests := []struct {
expectedType token.TokenType
expectedLiteral string
}{
{token.FLOAT, "2.5"},
{token.FLOAT, "3.14"},
{token.EOF, ""},
}
lexer := New(input)
for i, test := range tests {
token := lexer.NextToken()
if token.Type != test.expectedType {
t.Fatalf("tests[%d] - token type wrong. expected=%q, got=%q",
i, test.expectedType, token.Type)
}
if token.Literal != test.expectedLiteral {
t.Fatalf("tests[%d] - literal wrong. expected=%q, got=%q",
i, test.expectedLiteral, token.Literal)
}
}
}