-
Notifications
You must be signed in to change notification settings - Fork 0
/
test_simple.vim
41 lines (35 loc) · 959 Bytes
/
test_simple.vim
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
let g:test_name = expand( "<sfile>:p:t" )
let g:test_path = expand( "<sfile>:p:h" )
let init_script = expand( '<sfile>:p:h' ) . '/../support/' . test_name
execute 'source ' . init_script
function! s:EarlyExit()
call add( v:errors, "Test caused Vim to quit!" )
call s:Done()
endfunction
function! s:Done()
if len( v:errors ) > 0
" Append errors to test failure log
let logfile = g:test_path . "/" . g:test_name . ".failed.log"
call writefile( v:errors, logfile, 'as' )
" Quit with an error code
cquit!
else
quit!
endif
endfunction
" * Type `i<C-x><C-u>`. Expect the buffer to contain `Jan`
let v:errors = []
au VimLeavePre * call s:EarlyExit()
try
call feedkeys( "i\<C-x>\<C-u>", 'xt' )
call assert_equal( 'Jan', getline( 1 ) )
catch
call add( v:errors,
\ "Uncaught exception in test: "
\ . v:exception
\ . " at "
\ . v:throwpoint )
finally
au! VimLeavePre
endtry
call s:Done()