Skip to content

Commit a37f937

Browse files
committed
Add check for empty test errors
1 parent 49ea3fb commit a37f937

File tree

3 files changed

+3
-3
lines changed

3 files changed

+3
-3
lines changed

eval_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -405,7 +405,7 @@ func TestEvalError(t *testing.T) {
405405
if err == nil {
406406
err = fmt.Errorf("<nil>")
407407
}
408-
if !strings.HasPrefix(err.Error(), test.err) {
408+
if !strings.HasPrefix(err.Error(), test.err) || test.err == "" {
409409
t.Errorf("%s:\ngot\n\t%+v\nexpected\n\t%v", test.input, err.Error(), test.err)
410410
}
411411
}

lexer_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,7 @@ func TestLex(t *testing.T) {
137137
func TestLexError(t *testing.T) {
138138
for _, test := range lexErrorTests {
139139
_, err := lex(test.input)
140-
if !strings.HasPrefix(err.Error(), test.err) {
140+
if !strings.HasPrefix(err.Error(), test.err) || test.err == "" {
141141
t.Errorf("%s:\ngot\n\t%+v\nexpected\n\t%v", test.input, err.Error(), test.err)
142142
}
143143
}

parser_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -178,7 +178,7 @@ func TestParseError(t *testing.T) {
178178
if err == nil {
179179
err = fmt.Errorf("<nil>")
180180
}
181-
if !strings.HasPrefix(err.Error(), test.err) {
181+
if !strings.HasPrefix(err.Error(), test.err) || test.err == "" {
182182
t.Errorf("%s:\ngot\n\t%+v\nexpected\n\t%v", test.input, err.Error(), test.err)
183183
}
184184
}

0 commit comments

Comments
 (0)