-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathexception-lines.test.elv
More file actions
192 lines (173 loc) · 4.13 KB
/
exception-lines.test.elv
File metadata and controls
192 lines (173 loc) · 4.13 KB
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
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
use str
use github.com/giancosta86/ethereal/v1/command
use ./exception-lines
>> 'Exception lines - trimming clockwork stack' {
>> 'with no lines' {
all [] |
exception-lines:trim-clockwork-stack |
put [(all)] |
should-be []
}
>> 'with stack referencing Ethereal''s command' {
all [
Alpha
Beta
Gamma
github.com/giancosta86/ethereal/v1/command.elv:10:11-22
CLOCKWORK 1
CLOCKWORK 2
] |
exception-lines:trim-clockwork-stack |
put [(all)] |
should-be [
Alpha
Beta
Gamma
]
}
>> 'with hand-made exception referencing test-script from a specific Velvet version' {
all [
'[eval 1]:8:9-12: var v = $asd'
Ro
Sigma
'github.com/giancosta86/velvet/v3/test-script.elv:34'
SomeOtherLine
'~/.local/share/elvish/lib/github.com/giancosta86/velvet/v3/sandbox.elv:7:3-25: each $test-script:run~ |'
] |
exception-lines:trim-clockwork-stack |
put [(all)] |
should-be [
'[eval 1]:8:9-12: var v = $asd'
Ro
Sigma
]
}
>> 'with hand-made exception referencing Velvet''s working directory' {
all [
'[eval 1]:8:9-12: var v = $asd'
Ro
Sigma
~'/fake-project-dir/velvet/test-script.elv:34'
SomeOtherLine
'~/.local/share/elvish/lib/github.com/giancosta86/velvet/v3/sandbox.elv:7:3-25: each $test-script:run~ |'
] |
exception-lines:trim-clockwork-stack |
put [(all)] |
should-be [
'[eval 1]:8:9-12: var v = $asd'
Ro
Sigma
]
}
>> 'with stack obtained from command capturing' {
var capture-result = (
command:capture {
fail DODUS
}
)
show $capture-result[exception] |
exception-lines:trim-clockwork-stack |
str:join "\n" |
str:contains (all) command.elv |
should-be $false
}
}
>> 'Exception lines - replacing eval' {
>> 'with no lines' {
all [] |
exception-lines:replace-bottom-eval ciop.elv |
put [(all)] |
should-be []
}
>> 'with no eval' {
var lines = [
Alpha
Beta
Gamma
]
all $lines |
exception-lines:replace-bottom-eval ciop.elv |
put [(all)] |
should-be $lines
}
>> 'with single bottom eval' {
all [
Alpha
Beta
'[eval 123]:45:8-11: Fake error'
] |
exception-lines:replace-bottom-eval ciop.elv |
put [(all)] |
should-be [
Alpha
Beta
'ciop.elv:45:8-11: Fake error'
]
}
>> 'with different initial spaces for same eval' {
all [
Alpha
Beta
'[eval 123]:65:4-18: Alpha'
' [eval 123]:23:7-13: Beta'
' [eval 123]:45:8-11: Gamma'
] |
exception-lines:replace-bottom-eval ciop.elv |
put [(all)] |
should-be [
Alpha
Beta
'ciop.elv:65:4-18: Alpha'
' ciop.elv:23:7-13: Beta'
' ciop.elv:45:8-11: Gamma'
]
}
>> 'with multiple instances of eval' {
all [
Alpha
Beta
'[eval 123]:12:15:17-23: First eval here'
'[eval 456]:123:7: Yet another fake error'
'[eval 123]:80:3:4-67: Another fake error'
Gamma
'[eval 123]:45:8-11: Fake error'
Delta
] |
exception-lines:replace-bottom-eval ciop.elv |
put [(all)] |
should-be [
Alpha
Beta
'ciop.elv:12:15:17-23: First eval here'
'[eval 456]:123:7: Yet another fake error'
'ciop.elv:80:3:4-67: Another fake error'
Gamma
'ciop.elv:45:8-11: Fake error'
Delta
]
}
>> 'with eval call within command capturing' {
var capture-result = (command:capture {
var code = '
fn beta {
fail DODO
}
fn alpha {
beta
}
alpha
'
eval $code
})
var exception-log = (
show $capture-result[exception] |
exception-lines:trim-clockwork-stack |
exception-lines:replace-bottom-eval ciop.elv |
str:join "\n"
)
str:contains $exception-log DODO |
should-be $true
str:contains $exception-log ciop.elv |
should-be $true
}
}