Skip to content

Commit 6188b86

Browse files
committed
vital: add error handling test on .import and .load
1 parent 3ecb3fb commit 6188b86

File tree

2 files changed

+29
-0
lines changed

2 files changed

+29
-0
lines changed
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
function! s:_vital_loaded(V) abort
2+
call s:Obj._anonymous_func()
3+
endfunction
4+
5+
let s:Obj = {}
6+
function! s:Obj._anonymous_func() dict abort
7+
call s:_throwFOO()
8+
endfunction
9+
10+
function! s:_throwFOO() abort
11+
throw 'FOO'
12+
endfunction

test/vital.vimspec

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -220,6 +220,14 @@ Describe vital
220220
Assert Equals(JSON.decode('[1, "ni"]'), [1, "ni"])
221221
End
222222

223+
It can handle error stack in s:_vital_loaded(V)
224+
Throws /^vital: fail to call \._vital_loaded(): FOO from:\_.*\n
225+
\function \S*_vital_loaded(\.\.\.) Line:1 (.*\/ErrorSelfmodule\.vim .* 1)\n
226+
\function \d\+(\.\.\.) Line:1 (.*\/ErrorSelfmodule\.vim .* 6)\n
227+
\function \S*_throwFOO(\.\.\.) Line:1 (.*\/ErrorSelfmodule\.vim .* 10)/
228+
\ :call V.import('ErrorSelfmodule')
229+
End
230+
223231
It supports s:_vital_created(V)
224232
let JSON = V.import('Web.JSON')
225233
Assert HasKey(JSON, 'true')
@@ -297,6 +305,15 @@ Describe vital
297305
Assert Equals(V.Web.JSON.decode('[1, "ni"]'), [1, "ni"])
298306
End
299307

308+
It can handle error stack in s:_vital_loaded(V)
309+
let V = vital#{g:testplugin_name}#new()
310+
Throws /^vital: fail to call \._vital_loaded(): FOO from:\_.*\n
311+
\function \S*_vital_loaded(\.\.\.) Line:1 (.*\/ErrorSelfmodule\.vim .* 1)\n
312+
\function \d\+(\.\.\.) Line:1 (.*\/ErrorSelfmodule\.vim .* 6)\n
313+
\function \S*_throwFOO(\.\.\.) Line:1 (.*\/ErrorSelfmodule\.vim .* 10)/
314+
\ :call V.load('ErrorSelfmodule')
315+
End
316+
300317
It supports s:_vital_created(V)
301318
let V = vital#{g:testplugin_name}#new()
302319
Assert Equals(V.load('Web.JSON'), V)

0 commit comments

Comments
 (0)