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

@@ -126,6 +126,37 @@ func TestIntegerLiteralExpression(t *testing.T) {
}
}
func TestFloatLiteralExpression(t *testing.T) {
input := "2.5;"
l := lexer.New(input)
p := New("<test>", l)
program := p.ParseProgram()
checkParserErrors(t, p)
if len(program.Statements) != 1 {
t.Fatalf("program has not enough statements. got=%d",
len(program.Statements))
}
stmt, ok := program.Statements[0].(*ast.ExpressionStatement)
if !ok {
t.Fatalf("program.Statements[0] is not ast.ExpressionStatement. got=%T",
program.Statements[0])
}
literal, ok := stmt.Expression.(*ast.FloatLiteral)
if !ok {
t.Fatalf("exp not *ast.FloatLiteral. got=%T", stmt.Expression)
}
if literal.Value != 2.5 {
t.Errorf("literal.Value not %f. got=%f", 2.5, literal.Value)
}
if literal.TokenLiteral() != "2.5" {
t.Errorf("literal.TokenLiteral not %s. got=%s", "2.5",
literal.TokenLiteral())
}
}
func TestParsingPrefixExpressions(t *testing.T) {
prefixTests := []struct {
input string