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
|
let s:suite = themis#suite(":rubydo")
let s:expect = themis#helper("expect")
function! s:suite.before_each() abort
1,$delete
call append(0, ["one", "two", "three", "four"])
endfunction
function! s:suite.has_nvim() abort
call s:expect(has("nvim")).to_equal(1)
endfunction
function! s:suite.updates_one_line() abort
2rubydo $_.upcase!
call s:expect(getline(1, 4)).to_equal(["one", "TWO", "three", "four"])
endfunction
function! s:suite.updates_line_range() abort
2,3rubydo $_.upcase!
call s:expect(getline(1, 4)).to_equal(["one", "TWO", "THREE", "four"])
endfunction
function! s:suite.updates_large_line_range() abort
1,$delete
for _ in range(0, 6000)
call append(0, "x")
endfor
%rubydo $_.succ!
call s:expect(getline(1)).to_equal("y")
call s:expect(getline(6001)).to_equal("y")
call s:expect(getline(6002)).to_equal("")
endfunction
function! s:suite.updates_all_lines() abort
%rubydo $_.upcase!
call s:expect(getline(1, 4)).to_equal(["ONE", "TWO", "THREE", "FOUR"])
endfunction
function! s:suite.ignores_line_deletion() abort
" Just ensure `Index out of bounds` exception isn't raised.
"
" Deleting or adding lines inside `:rubydo` is documented as not supported.
" Therefore this will remain inconsistent with Vim, which deletes all but
" the first line (?)
%rubydo Vim.command("%d")
endfunction
function! s:suite.handles_standard_error() abort
try
1rubydo raise "BOOM"
throw "Nothing raised"
catch /BOOM/
endtry
call s:suite.updates_one_line()
endfunction
function! s:suite.handles_syntax_error() abort
try
1rubydo puts[
throw "Nothing raised"
catch /SyntaxError/
endtry
call s:suite.updates_one_line()
endfunction
|