Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

wip: fix unit tests #30

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion evaluator/evaluator_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,7 @@ func TestErrorHandling(t *testing.T) {
{"5; true+false; 5;", "unknown operator: BOOLEAN + BOOLEAN"},
{"if(10>1){true+false;}", "unknown operator: BOOLEAN + BOOLEAN"},
//{"if(10>1){if(10>1){return true+false;}return 1;}", "unknown operator: BOOLEAN + BOOLEAN"},
{"foobar", "variable name not found: foobar"},
{"foobar", "identifier not found: foobar"},
{`"Hello" - "World"`, "unknown operator: STRING - STRING"},
{`{"name":"GraHms"}[fn(x){x}]`, "unusable as hash key: FUNCTION"},
}
Expand Down
8 changes: 6 additions & 2 deletions parser/parser_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -216,8 +216,12 @@ func testFloatLiteral(t *testing.T, il ast.Expression, value float64) bool {
// t.Errorf("float.Value not %d. got=%d", value, floatLit.Value)
// return false
//}
if floatLit.TokenLiteral() != fmt.Sprintf("%f", value) {
t.Errorf("float.TokenLiteral() not %f. got=%s", value, floatLit.TokenLiteral())

literal := floatLit.TokenLiteral()
formatted := fmt.Sprintf("%.1f", value)

if literal != formatted {
t.Errorf("float.TokenLiteral() not %s. got=%s", formatted, literal)
return false
}
return true
Expand Down