-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy patherrors_test.go
65 lines (58 loc) · 1.17 KB
/
errors_test.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
package golisp2
import "testing"
import "github.com/stretchr/testify/require"
func Test_ForbiddenRuneError(t *testing.T) {
err := NewForbiddenRuneError('\x00', ScannerPosition{
SourceFile: "abc.l",
Col: 3,
Row: 4,
})
require.Contains(t, err.Error(), "Forbidden")
}
func Test_ParseError(t *testing.T) {
err := NewParseError(
"test parse error",
ScannedToken{
Typ: IdentTT,
Value: "abc.....efg",
Pos: ScannerPosition{
SourceFile: "abc.l",
Col: 3,
Row: 4,
},
},
)
require.Contains(t, err.Error(), "Parse")
}
func Test_TypeError(t *testing.T) {
err := NewTypeError(
"number",
"string",
ScannerPosition{
SourceFile: "abc.l",
Col: 3,
Row: 4,
},
)
require.Contains(t, err.Error(), "Type")
}
func Test_EvalError(t *testing.T) {
err := EvalError{
Msg: "runtime error",
Pos: ScannerPosition{
SourceFile: "abc.l",
Col: 3,
Row: 4,
},
}
require.Contains(t, err.Error(), "Eval")
}
func Test_ArgTypeError(t *testing.T) {
err := ArgTypeError{
FnName: "add",
ArgI: 2,
Expected: "Number",
Actual: "nil",
}
require.Contains(t, err.Error(), "Arg")
}