aboutsummaryrefslogtreecommitdiff
path: root/src/nvim/testdir
diff options
context:
space:
mode:
authorRom Grk <romgrk.cc@gmail.com>2020-11-03 03:11:08 -0500
committerRom Grk <romgrk.cc@gmail.com>2020-11-03 03:11:08 -0500
commit13e0ca3e194a438383b8451e19090355aa6c29dc (patch)
tree0ac33ef5ac829b7c74dd15f34b17540c3186c356 /src/nvim/testdir
parentc7c865214655f7d88fde85ed4947f07319c14182 (diff)
parent5b5848f2fb1f4b7995bb8a59d94b6766d2182070 (diff)
downloadrneovim-13e0ca3e194a438383b8451e19090355aa6c29dc.tar.gz
rneovim-13e0ca3e194a438383b8451e19090355aa6c29dc.tar.bz2
rneovim-13e0ca3e194a438383b8451e19090355aa6c29dc.zip
Merge branch 'master' into add-scroll-events
Diffstat (limited to 'src/nvim/testdir')
-rw-r--r--src/nvim/testdir/test_autocmd.vim13
-rw-r--r--src/nvim/testdir/test_cindent.vim36
-rw-r--r--src/nvim/testdir/test_cjk_linebreak.vim97
-rw-r--r--src/nvim/testdir/test_cmdline.vim21
-rw-r--r--src/nvim/testdir/test_edit.vim18
-rw-r--r--src/nvim/testdir/test_filetype.vim2
-rw-r--r--src/nvim/testdir/test_ins_complete.vim86
-rw-r--r--src/nvim/testdir/test_listdict.vim4
-rw-r--r--src/nvim/testdir/test_messages.vim24
-rw-r--r--src/nvim/testdir/test_mksession.vim13
-rw-r--r--src/nvim/testdir/test_options.vim1
-rw-r--r--src/nvim/testdir/test_quickfix.vim4
-rw-r--r--src/nvim/testdir/test_registers.vim69
-rw-r--r--src/nvim/testdir/test_ruby.vim197
-rw-r--r--src/nvim/testdir/test_statusline.vim15
15 files changed, 484 insertions, 116 deletions
diff --git a/src/nvim/testdir/test_autocmd.vim b/src/nvim/testdir/test_autocmd.vim
index 094bb3ebd1..04a678eeb8 100644
--- a/src/nvim/testdir/test_autocmd.vim
+++ b/src/nvim/testdir/test_autocmd.vim
@@ -1897,4 +1897,17 @@ func Test_autocmd_FileReadCmd()
delfunc ReadFileCmd
endfunc
+" Tests for SigUSR1 autocmd event, which is only available on posix systems.
+func Test_autocmd_sigusr1()
+ CheckUnix
+
+ let g:sigusr1_passed = 0
+ au Signal SIGUSR1 let g:sigusr1_passed = 1
+ call system('/bin/kill -s usr1 ' . getpid())
+ call WaitForAssert({-> assert_true(g:sigusr1_passed)})
+
+ au! Signal
+ unlet g:sigusr1_passed
+endfunc
+
" vim: shiftwidth=2 sts=2 expandtab
diff --git a/src/nvim/testdir/test_cindent.vim b/src/nvim/testdir/test_cindent.vim
index debc9da46d..b6c2d1467e 100644
--- a/src/nvim/testdir/test_cindent.vim
+++ b/src/nvim/testdir/test_cindent.vim
@@ -127,4 +127,40 @@ func Test_cindent_case()
bwipe!
endfunc
+func Test_cindent_pragma()
+ new
+ setl cindent ts=4 sw=4
+ setl cino=Ps
+
+ let code =<< trim [CODE]
+ {
+ #pragma omp parallel
+ {
+ #pragma omp task
+ foo();
+ # pragma omp taskwait
+ }
+ }
+ [CODE]
+
+ call append(0, code)
+ normal gg
+ normal =G
+
+ let expected =<< trim [CODE]
+ {
+ #pragma omp parallel
+ {
+ #pragma omp task
+ foo();
+ # pragma omp taskwait
+ }
+ }
+
+ [CODE]
+
+ call assert_equal(expected, getline(1, '$'))
+ enew! | close
+endfunc
+
" vim: shiftwidth=2 sts=2 expandtab
diff --git a/src/nvim/testdir/test_cjk_linebreak.vim b/src/nvim/testdir/test_cjk_linebreak.vim
new file mode 100644
index 0000000000..dfaa8fa1af
--- /dev/null
+++ b/src/nvim/testdir/test_cjk_linebreak.vim
@@ -0,0 +1,97 @@
+scriptencoding utf-8
+
+func Run_cjk_linebreak_after(rigorous)
+ set textwidth=12
+ for punct in [
+ \ '!', '%', ')', ',', ':', ';', '>', '?', ']', '}', '’', '”', '†', '‡',
+ \ '…', '‰', '‱', '‼', '⁇', '⁈', '⁉', '℃', '℉', '、', '。', '〉', '》',
+ \ '」', '』', '】', '〕', '〗', '〙', '〛', '!', ')', ',', '.', ':',
+ \ ';', '?', ']', '}']
+ call setline('.', '这是一个测试' .. punct.'试试 CJK 行禁则补丁。')
+ normal gqq
+ if a:rigorous
+ call assert_equal('这是一个测', getline(1))
+ else
+ call assert_equal('这是一个测试' .. punct, getline(1))
+ endif
+ %d_
+ endfor
+endfunc
+
+func Test_cjk_linebreak_after()
+ set formatoptions=croqn2mB1j
+ call Run_cjk_linebreak_after(0)
+endfunc
+
+func Test_cjk_linebreak_after_rigorous()
+ set formatoptions=croqn2mB1j]
+ call Run_cjk_linebreak_after(1)
+endfunc
+
+func Run_cjk_linebreak_before()
+ set textwidth=12
+ for punct in [
+ \ '(', '<', '[', '`', '{', '‘', '“', '〈', '《', '「', '『', '【', '〔',
+ \ '〖', '〘', '〚', '(', '[', '{']
+ call setline('.', '这是个测试' .. punct.'试试 CJK 行禁则补丁。')
+ normal gqq
+ call assert_equal('这是个测试', getline(1))
+ %d_
+ endfor
+endfunc
+
+func Test_cjk_linebreak_before()
+ set formatoptions=croqn2mB1j
+ call Run_cjk_linebreak_before()
+endfunc
+
+func Test_cjk_linebreak_before_rigorous()
+ set formatoptions=croqn2mB1j]
+ call Run_cjk_linebreak_before()
+endfunc
+
+func Run_cjk_linebreak_nobetween(rigorous)
+ " …… must not start a line
+ call setline('.', '这是个测试……试试 CJK 行禁则补丁。')
+ set textwidth=12 ambiwidth=double
+ normal gqq
+ if a:rigorous
+ call assert_equal('这是个测', getline(1))
+ else
+ call assert_equal('这是个测试……', getline(1))
+ endif
+ %d_
+
+ call setline('.', '这是一个测试……试试 CJK 行禁则补丁。')
+ set textwidth=12 ambiwidth=double
+ normal gqq
+ call assert_equal('这是一个测', getline(1))
+ %d_
+
+ " but —— can
+ call setline('.', '这是个测试——试试 CJK 行禁则补丁。')
+ set textwidth=12 ambiwidth=double
+ normal gqq
+ call assert_equal('这是个测试', getline(1))
+endfunc
+
+func Test_cjk_linebreak_nobetween()
+ set formatoptions=croqn2mB1j
+ call Run_cjk_linebreak_nobetween(0)
+endfunc
+
+func Test_cjk_linebreak_nobetween_rigorous()
+ set formatoptions=croqn2mB1j]
+ call Run_cjk_linebreak_nobetween(1)
+endfunc
+
+func Test_cjk_linebreak_join_punct()
+ for punct in ['——', '〗', ',', '。', '……']
+ call setline(1, '文本文本' .. punct)
+ call setline(2, 'English')
+ set formatoptions=croqn2mB1j
+ normal ggJ
+ call assert_equal('文本文本' .. punct.'English', getline(1))
+ %d_
+ endfor
+endfunc
diff --git a/src/nvim/testdir/test_cmdline.vim b/src/nvim/testdir/test_cmdline.vim
index 871143699a..e3c42a4fe3 100644
--- a/src/nvim/testdir/test_cmdline.vim
+++ b/src/nvim/testdir/test_cmdline.vim
@@ -722,7 +722,7 @@ func Test_verbosefile()
endfunc
func Test_verbose_option()
- " See test/functional/ui/cmdline_spec.lua
+ " See test/functional/legacy/cmdline_spec.lua
CheckScreendump
let lines =<< trim [SCRIPT]
@@ -842,6 +842,25 @@ func Test_buffers_lastused()
bwipeout bufc
endfunc
+func Test_cmdlineclear_tabenter()
+ " See test/functional/legacy/cmdline_spec.lua
+ CheckScreendump
+
+ let lines =<< trim [SCRIPT]
+ call setline(1, range(30))
+ [SCRIPT]
+
+ call writefile(lines, 'XtestCmdlineClearTabenter')
+ let buf = RunVimInTerminal('-S XtestCmdlineClearTabenter', #{rows: 10})
+ call term_wait(buf, 50)
+ " in one tab make the command line higher with CTRL-W -
+ call term_sendkeys(buf, ":tabnew\<cr>\<C-w>-\<C-w>-gtgt")
+ call VerifyScreenDump(buf, 'Test_cmdlineclear_tabenter', {})
+
+ call StopVimInTerminal(buf)
+ call delete('XtestCmdlineClearTabenter')
+endfunc
+
" test that ";" works to find a match at the start of the first line
func Test_zero_line_search()
new
diff --git a/src/nvim/testdir/test_edit.vim b/src/nvim/testdir/test_edit.vim
index caebc341e0..abad6983dc 100644
--- a/src/nvim/testdir/test_edit.vim
+++ b/src/nvim/testdir/test_edit.vim
@@ -1441,31 +1441,40 @@ endfunc
func Test_edit_InsertLeave()
new
+ au InsertLeavePre * let g:did_au_pre = 1
au InsertLeave * let g:did_au = 1
+ let g:did_au_pre = 0
let g:did_au = 0
call feedkeys("afoo\<Esc>", 'tx')
+ call assert_equal(1, g:did_au_pre)
call assert_equal(1, g:did_au)
call assert_equal('foo', getline(1))
+ let g:did_au_pre = 0
let g:did_au = 0
call feedkeys("Sbar\<C-C>", 'tx')
+ call assert_equal(1, g:did_au_pre)
call assert_equal(0, g:did_au)
call assert_equal('bar', getline(1))
inoremap x xx<Esc>
+ let g:did_au_pre = 0
let g:did_au = 0
call feedkeys("Saax", 'tx')
+ call assert_equal(1, g:did_au_pre)
call assert_equal(1, g:did_au)
call assert_equal('aaxx', getline(1))
inoremap x xx<C-C>
+ let g:did_au_pre = 0
let g:did_au = 0
call feedkeys("Sbbx", 'tx')
+ call assert_equal(1, g:did_au_pre)
call assert_equal(0, g:did_au)
call assert_equal('bbxx', getline(1))
bwipe!
- au! InsertLeave
+ au! InsertLeave InsertLeavePre
iunmap x
endfunc
@@ -1578,4 +1587,11 @@ func Test_edit_browse()
bwipe!
endfunc
+func Test_read_invalid()
+ " set encoding=latin1
+ " This was not properly checking for going past the end.
+ call assert_fails('r`=', 'E484')
+ set encoding=utf-8
+endfunc
+
" vim: shiftwidth=2 sts=2 expandtab
diff --git a/src/nvim/testdir/test_filetype.vim b/src/nvim/testdir/test_filetype.vim
index c7ca682c8c..9f79c1b545 100644
--- a/src/nvim/testdir/test_filetype.vim
+++ b/src/nvim/testdir/test_filetype.vim
@@ -532,6 +532,7 @@ let s:filename_case_checks = {
\ }
func CheckItems(checks)
+ set noswapfile
for [ft, names] in items(a:checks)
for i in range(0, len(names) - 1)
new
@@ -548,6 +549,7 @@ func CheckItems(checks)
bwipe!
endfor
endfor
+ set swapfile&
endfunc
func Test_filetype_detection()
diff --git a/src/nvim/testdir/test_ins_complete.vim b/src/nvim/testdir/test_ins_complete.vim
index 1339a9f25d..57a0a7aaf4 100644
--- a/src/nvim/testdir/test_ins_complete.vim
+++ b/src/nvim/testdir/test_ins_complete.vim
@@ -327,7 +327,10 @@ func Test_compl_in_cmdwin()
set wildmenu wildchar=<Tab>
com! -nargs=1 -complete=command GetInput let input = <q-args>
com! -buffer TestCommand echo 'TestCommand'
+ let w:test_winvar = 'winvar'
+ let b:test_bufvar = 'bufvar'
+ " User-defined commands
let input = ''
call feedkeys("q:iGetInput T\<C-x>\<C-v>\<CR>", 'tx!')
call assert_equal('TestCommand', input)
@@ -336,11 +339,94 @@ func Test_compl_in_cmdwin()
call feedkeys("q::GetInput T\<Tab>\<CR>:q\<CR>", 'tx!')
call assert_equal('T', input)
+ com! -nargs=1 -complete=var GetInput let input = <q-args>
+ " Window-local variables
+ let input = ''
+ call feedkeys("q:iGetInput w:test_\<C-x>\<C-v>\<CR>", 'tx!')
+ call assert_equal('w:test_winvar', input)
+
+ let input = ''
+ call feedkeys("q::GetInput w:test_\<Tab>\<CR>:q\<CR>", 'tx!')
+ call assert_equal('w:test_', input)
+
+ " Buffer-local variables
+ let input = ''
+ call feedkeys("q:iGetInput b:test_\<C-x>\<C-v>\<CR>", 'tx!')
+ call assert_equal('b:test_bufvar', input)
+
+ let input = ''
+ call feedkeys("q::GetInput b:test_\<Tab>\<CR>:q\<CR>", 'tx!')
+ call assert_equal('b:test_', input)
+
delcom TestCommand
delcom GetInput
+ unlet w:test_winvar
+ unlet b:test_bufvar
set wildmenu& wildchar&
endfunc
+" Test for insert path completion with completeslash option
+func Test_ins_completeslash()
+ CheckMSWindows
+
+ call mkdir('Xdir')
+
+ let orig_shellslash = &shellslash
+ set cpt&
+
+ new
+
+ set noshellslash
+
+ set completeslash=
+ exe "normal oXd\<C-X>\<C-F>"
+ call assert_equal('Xdir\', getline('.'))
+
+ set completeslash=backslash
+ exe "normal oXd\<C-X>\<C-F>"
+ call assert_equal('Xdir\', getline('.'))
+
+ set completeslash=slash
+ exe "normal oXd\<C-X>\<C-F>"
+ call assert_equal('Xdir/', getline('.'))
+
+ set shellslash
+
+ set completeslash=
+ exe "normal oXd\<C-X>\<C-F>"
+ call assert_equal('Xdir/', getline('.'))
+
+ set completeslash=backslash
+ exe "normal oXd\<C-X>\<C-F>"
+ call assert_equal('Xdir\', getline('.'))
+
+ set completeslash=slash
+ exe "normal oXd\<C-X>\<C-F>"
+ call assert_equal('Xdir/', getline('.'))
+ %bw!
+ call delete('Xdir', 'rf')
+
+ set noshellslash
+ set completeslash=slash
+ call assert_true(stridx(globpath(&rtp, 'syntax/*.vim', 1, 1)[0], '\') != -1)
+
+ let &shellslash = orig_shellslash
+ set completeslash=
+endfunc
+
+func Test_issue_7021()
+ CheckMSWindows
+
+ let orig_shellslash = &shellslash
+ set noshellslash
+
+ set completeslash=slash
+ call assert_false(expand('~') =~ '/')
+
+ let &shellslash = orig_shellslash
+ set completeslash=
+endfunc
+
func Test_pum_with_folds_two_tabs()
CheckScreendump
diff --git a/src/nvim/testdir/test_listdict.vim b/src/nvim/testdir/test_listdict.vim
index 31a8b48d37..8e2a987e74 100644
--- a/src/nvim/testdir/test_listdict.vim
+++ b/src/nvim/testdir/test_listdict.vim
@@ -199,9 +199,9 @@ func Test_dict_big()
try
let n = d[1500]
catch
- let str=substitute(v:exception, '\v(.{14}).*( \d{4}).*', '\1\2', '')
+ let str = substitute(v:exception, '\v(.{14}).*( "\d{4}").*', '\1\2', '')
endtry
- call assert_equal('Vim(let):E716: 1500', str)
+ call assert_equal('Vim(let):E716: "1500"', str)
" lookup each items
for i in range(1500)
diff --git a/src/nvim/testdir/test_messages.vim b/src/nvim/testdir/test_messages.vim
index 7fbf04311d..30239a90c2 100644
--- a/src/nvim/testdir/test_messages.vim
+++ b/src/nvim/testdir/test_messages.vim
@@ -1,20 +1,16 @@
" Tests for :messages, :echomsg, :echoerr
-function Test_messages()
+source shared.vim
+
+func Test_messages()
let oldmore = &more
try
set nomore
- " Avoid the "message maintainer" line.
- let $LANG = ''
- let $LC_ALL = ''
- let $LC_MESSAGES = ''
- let $LC_COLLATE = ''
let arr = map(range(10), '"hello" . v:val')
for s in arr
echomsg s | redraw
endfor
- let result = ''
" get last two messages
redir => result
@@ -25,22 +21,17 @@ function Test_messages()
" clear messages without last one
1messages clear
- redir => result
- redraw | messages
- redir END
- let msg_list = split(result, "\n")
+ let msg_list = GetMessages()
call assert_equal(['hello9'], msg_list)
" clear all messages
messages clear
- redir => result
- redraw | messages
- redir END
- call assert_equal('', result)
+ let msg_list = GetMessages()
+ call assert_equal([], msg_list)
finally
let &more = oldmore
endtry
-endfunction
+endfunc
" Patch 7.4.1696 defined the "clearmode()" command for clearing the mode
" indicator (e.g., "-- INSERT --") when ":stopinsert" is invoked. Message
@@ -74,6 +65,7 @@ func Test_echomsg()
call assert_equal("\n12345", execute(':echomsg 12345'))
call assert_equal("\n[]", execute(':echomsg []'))
call assert_equal("\n[1, 2, 3]", execute(':echomsg [1, 2, 3]'))
+ call assert_equal("\n[1, 2, []]", execute(':echomsg [1, 2, v:_null_list]'))
call assert_equal("\n{}", execute(':echomsg {}'))
call assert_equal("\n{'a': 1, 'b': 2}", execute(':echomsg {"a": 1, "b": 2}'))
if has('float')
diff --git a/src/nvim/testdir/test_mksession.vim b/src/nvim/testdir/test_mksession.vim
index 3243edbf55..215065f941 100644
--- a/src/nvim/testdir/test_mksession.vim
+++ b/src/nvim/testdir/test_mksession.vim
@@ -470,4 +470,17 @@ func Test_mkvimrc()
call delete('Xtestvimrc')
endfunc
+func Test_scrolloff()
+ set sessionoptions+=localoptions
+ setlocal so=1 siso=1
+ mksession! Xtest_mks.out
+ setlocal so=-1 siso=-1
+ source Xtest_mks.out
+ call assert_equal(1, &l:so)
+ call assert_equal(1, &l:siso)
+ call delete('Xtest_mks.out')
+ setlocal so& siso&
+ set sessionoptions&
+endfunc
+
" vim: shiftwidth=2 sts=2 expandtab
diff --git a/src/nvim/testdir/test_options.vim b/src/nvim/testdir/test_options.vim
index 9e8da74db7..10e16f4198 100644
--- a/src/nvim/testdir/test_options.vim
+++ b/src/nvim/testdir/test_options.vim
@@ -267,7 +267,6 @@ func Test_set_errors()
call assert_fails('set commentstring=x', 'E537:')
call assert_fails('set complete=x', 'E539:')
call assert_fails('set statusline=%{', 'E540:')
- call assert_fails('set statusline=' . repeat("%p", 81), 'E541:')
call assert_fails('set statusline=%(', 'E542:')
if has('cursorshape')
" This invalid value for 'guicursor' used to cause Vim to crash.
diff --git a/src/nvim/testdir/test_quickfix.vim b/src/nvim/testdir/test_quickfix.vim
index cf0af07528..049163890e 100644
--- a/src/nvim/testdir/test_quickfix.vim
+++ b/src/nvim/testdir/test_quickfix.vim
@@ -3602,6 +3602,10 @@ func Test_lhelpgrep_autocmd()
au BufEnter * call setqflist([], 'f')
augroup END
call assert_fails('helpgrep quickfix', 'E925:')
+ " run the test with a help window already open
+ help
+ wincmd w
+ call assert_fails('helpgrep quickfix', 'E925:')
augroup QF_Test
au! BufEnter
augroup END
diff --git a/src/nvim/testdir/test_registers.vim b/src/nvim/testdir/test_registers.vim
index d20f8d1eef..19a7c6c9d0 100644
--- a/src/nvim/testdir/test_registers.vim
+++ b/src/nvim/testdir/test_registers.vim
@@ -167,6 +167,75 @@ func Test_set_register()
enew!
endfunc
+func Test_v_register()
+ enew
+ call setline(1, 'nothing')
+
+ func s:Put()
+ let s:register = v:register
+ exec 'normal! "' .. v:register .. 'P'
+ endfunc
+ nnoremap <buffer> <plug>(test) :<c-u>call s:Put()<cr>
+ nmap <buffer> S <plug>(test)
+
+ let @z = "testz\n"
+ let @" = "test@\n"
+
+ let s:register = ''
+ call feedkeys('"_ddS', 'mx')
+ call assert_equal('test@', getline('.')) " fails before 8.2.0929
+ call assert_equal('"', s:register) " fails before 8.2.0929
+
+ let s:register = ''
+ call feedkeys('"zS', 'mx')
+ call assert_equal('z', s:register)
+
+ let s:register = ''
+ call feedkeys('"zSS', 'mx')
+ call assert_equal('"', s:register)
+
+ let s:register = ''
+ call feedkeys('"_S', 'mx')
+ call assert_equal('_', s:register)
+
+ let s:register = ''
+ normal "_ddS
+ call assert_equal('"', s:register) " fails before 8.2.0929
+ call assert_equal('test@', getline('.')) " fails before 8.2.0929
+
+ let s:register = ''
+ execute 'normal "z:call' "s:Put()\n"
+ call assert_equal('z', s:register)
+ call assert_equal('testz', getline('.'))
+
+ " Test operator and omap
+ let @b = 'testb'
+ func s:OpFunc(...)
+ let s:register2 = v:register
+ endfunc
+ set opfunc=s:OpFunc
+
+ normal "bg@l
+ normal S
+ call assert_equal('"', s:register) " fails before 8.2.0929
+ call assert_equal('b', s:register2)
+
+ func s:Motion()
+ let s:register1 = v:register
+ normal! l
+ endfunc
+ onoremap <buffer> Q :<c-u>call s:Motion()<cr>
+
+ normal "bg@Q
+ normal S
+ call assert_equal('"', s:register)
+ call assert_equal('b', s:register1)
+ call assert_equal('"', s:register2)
+
+ set opfunc&
+ bwipe!
+endfunc
+
func Test_ve_blockpaste()
new
set ve=all
diff --git a/src/nvim/testdir/test_ruby.vim b/src/nvim/testdir/test_ruby.vim
index 77a42e0a8a..9c74c35049 100644
--- a/src/nvim/testdir/test_ruby.vim
+++ b/src/nvim/testdir/test_ruby.vim
@@ -1,15 +1,7 @@
" Tests for ruby interface
-if !has('ruby')
- finish
-end
-
-" Helper function as there is no builtin rubyeval() function similar
-" to perleval, luaevel() or pyeval().
-func RubyEval(ruby_expr)
- let s = split(execute('ruby print ' . a:ruby_expr), "\n")
- return (len(s) == 0) ? '' : s[-1]
-endfunc
+source check.vim
+CheckFeature ruby
func Test_ruby_change_buffer()
call setline(line('$'), ['1 line 1'])
@@ -43,19 +35,19 @@ func Test_rubyfile()
call delete(tempfile)
endfunc
-func Test_set_cursor()
+func Test_ruby_set_cursor()
" Check that setting the cursor position works.
new
call setline(1, ['first line', 'second line'])
normal gg
rubydo $curwin.cursor = [1, 5]
call assert_equal([1, 6], [line('.'), col('.')])
- call assert_equal('[1, 5]', RubyEval('$curwin.cursor'))
+ call assert_equal([1, 5], rubyeval('$curwin.cursor'))
" Check that movement after setting cursor position keeps current column.
normal j
call assert_equal([2, 6], [line('.'), col('.')])
- call assert_equal('[2, 5]', RubyEval('$curwin.cursor'))
+ call assert_equal([2, 5], rubyeval('$curwin.cursor'))
" call assert_fails('ruby $curwin.cursor = [1]',
" \ 'ArgumentError: array length must be 2')
@@ -63,34 +55,34 @@ func Test_set_cursor()
endfunc
" Test buffer.count and buffer.length (number of lines in buffer)
-func Test_buffer_count()
+func Test_ruby_buffer_count()
new
call setline(1, ['one', 'two', 'three'])
- call assert_equal('3', RubyEval('$curbuf.count'))
- call assert_equal('3', RubyEval('$curbuf.length'))
+ call assert_equal(3, rubyeval('$curbuf.count'))
+ call assert_equal(3, rubyeval('$curbuf.length'))
bwipe!
endfunc
" Test buffer.name (buffer name)
-func Test_buffer_name()
+func Test_ruby_buffer_name()
new Xfoo
- call assert_equal(expand('%:p'), RubyEval('$curbuf.name'))
+ call assert_equal(expand('%:p'), rubyeval('$curbuf.name'))
bwipe
- call assert_equal('', RubyEval('$curbuf.name'))
+ call assert_equal('', rubyeval('$curbuf.name'))
endfunc
" Test buffer.number (number of the buffer).
-func Test_buffer_number()
+func Test_ruby_buffer_number()
new
- call assert_equal(string(bufnr('%')), RubyEval('$curbuf.number'))
+ call assert_equal(bufnr('%'), rubyeval('$curbuf.number'))
new
- call assert_equal(string(bufnr('%')), RubyEval('$curbuf.number'))
+ call assert_equal(bufnr('%'), rubyeval('$curbuf.number'))
%bwipe
endfunc
" Test buffer.delete({n}) (delete line {n})
-func Test_buffer_delete()
+func Test_ruby_buffer_delete()
new
call setline(1, ['one', 'two', 'three'])
ruby $curbuf.delete(2)
@@ -104,7 +96,7 @@ func Test_buffer_delete()
endfunc
" Test buffer.append({str}, str) (append line {str} after line {n})
-func Test_buffer_append()
+func Test_ruby_buffer_append()
new
ruby $curbuf.append(0, 'one')
ruby $curbuf.append(1, 'three')
@@ -124,11 +116,11 @@ func Test_buffer_append()
endfunc
" Test buffer.line (get or set the current line)
-func Test_buffer_line()
+func Test_ruby_buffer_line()
new
call setline(1, ['one', 'two', 'three'])
2
- call assert_equal('two', RubyEval('$curbuf.line'))
+ call assert_equal('two', rubyeval('$curbuf.line'))
ruby $curbuf.line = 'TWO'
call assert_equal(['one', 'TWO', 'three'], getline(1, '$'))
@@ -137,20 +129,20 @@ func Test_buffer_line()
endfunc
" Test buffer.line_number (get current line number)
-func Test_buffer_line_number()
+func Test_ruby_buffer_line_number()
new
call setline(1, ['one', 'two', 'three'])
2
- call assert_equal('2', RubyEval('$curbuf.line_number'))
+ call assert_equal(2, rubyeval('$curbuf.line_number'))
bwipe!
endfunc
-func Test_buffer_get()
+func Test_ruby_buffer_get()
new
call setline(1, ['one', 'two'])
- call assert_equal('one', RubyEval('$curbuf[1]'))
- call assert_equal('two', RubyEval('$curbuf[2]'))
+ call assert_equal('one', rubyeval('$curbuf[1]'))
+ call assert_equal('two', rubyeval('$curbuf[2]'))
" call assert_fails('ruby $curbuf[0]',
" \ 'IndexError: line number 0 out of range')
@@ -160,7 +152,7 @@ func Test_buffer_get()
bwipe!
endfunc
-func Test_buffer_set()
+func Test_ruby_buffer_set()
new
call setline(1, ['one', 'two'])
ruby $curbuf[2] = 'TWO'
@@ -176,7 +168,7 @@ func Test_buffer_set()
endfunc
" Test window.width (get or set window height).
-func Test_window_height()
+func Test_ruby_window_height()
new
" Test setting window height
@@ -184,13 +176,13 @@ func Test_window_height()
call assert_equal(2, winheight(0))
" Test getting window height
- call assert_equal('2', RubyEval('$curwin.height'))
+ call assert_equal(2, rubyeval('$curwin.height'))
bwipe
endfunc
" Test window.width (get or set window width).
-func Test_window_width()
+func Test_ruby_window_width()
vnew
" Test setting window width
@@ -198,13 +190,13 @@ func Test_window_width()
call assert_equal(2, winwidth(0))
" Test getting window width
- call assert_equal('2', RubyEval('$curwin.width'))
+ call assert_equal(2, rubyeval('$curwin.width'))
bwipe
endfunc
" Test window.buffer (get buffer object of a window object).
-func Test_window_buffer()
+func Test_ruby_window_buffer()
new Xfoo1
new Xfoo2
ruby $b2 = $curwin.buffer
@@ -213,69 +205,69 @@ func Test_window_buffer()
ruby $b1 = $curwin.buffer
ruby $w1 = $curwin
- " call assert_equal(RubyEval('$b1'), RubyEval('$w1.buffer'))
- " call assert_equal(RubyEval('$b2'), RubyEval('$w2.buffer'))
- call assert_equal(string(bufnr('Xfoo1')), RubyEval('$w1.buffer.number'))
- call assert_equal(string(bufnr('Xfoo2')), RubyEval('$w2.buffer.number'))
+ " call assert_equal(rubyeval('$b1'), rubyeval('$w1.buffer'))
+ " call assert_equal(rubyeval('$b2'), rubyeval('$w2.buffer'))
+ call assert_equal(bufnr('Xfoo1'), rubyeval('$w1.buffer.number'))
+ call assert_equal(bufnr('Xfoo2'), rubyeval('$w2.buffer.number'))
ruby $b1, $w1, $b2, $w2 = nil
%bwipe
endfunc
" Test Vim::Window.current (get current window object)
-func Test_Vim_window_current()
- let cw = RubyEval('$curwin')
- " call assert_equal(cw, RubyEval('Vim::Window.current'))
+func Test_ruby_Vim_window_current()
+ let cw = rubyeval('$curwin.to_s')
+ " call assert_equal(cw, rubyeval('Vim::Window.current'))
call assert_match('^#<Neovim::Window:0x\x\+>$', cw)
endfunc
" Test Vim::Window.count (number of windows)
-func Test_Vim_window_count()
+func Test_ruby_Vim_window_count()
new Xfoo1
new Xfoo2
split
- call assert_equal('4', RubyEval('Vim::Window.count'))
+ call assert_equal(4, rubyeval('Vim::Window.count'))
%bwipe
- call assert_equal('1', RubyEval('Vim::Window.count'))
+ call assert_equal(1, rubyeval('Vim::Window.count'))
endfunc
" Test Vim::Window[n] (get window object of window n)
-func Test_Vim_window_get()
+func Test_ruby_Vim_window_get()
new Xfoo1
new Xfoo2
- call assert_match('Xfoo2$', RubyEval('Vim::Window[0].buffer.name'))
+ call assert_match('Xfoo2$', rubyeval('Vim::Window[0].buffer.name'))
wincmd j
- call assert_match('Xfoo1$', RubyEval('Vim::Window[1].buffer.name'))
+ call assert_match('Xfoo1$', rubyeval('Vim::Window[1].buffer.name'))
wincmd j
- call assert_equal('', RubyEval('Vim::Window[2].buffer.name'))
+ call assert_equal('', rubyeval('Vim::Window[2].buffer.name'))
%bwipe
endfunc
" Test Vim::Buffer.current (return the buffer object of current buffer)
-func Test_Vim_buffer_current()
- let cb = RubyEval('$curbuf')
- " call assert_equal(cb, RubyEval('Vim::Buffer.current'))
+func Test_ruby_Vim_buffer_current()
+ let cb = rubyeval('$curbuf.to_s')
+ " call assert_equal(cb, rubyeval('Vim::Buffer.current'))
call assert_match('^#<Neovim::Buffer:0x\x\+>$', cb)
endfunc
" Test Vim::Buffer:.count (return the number of buffers)
-func Test_Vim_buffer_count()
+func Test_ruby_Vim_buffer_count()
new Xfoo1
new Xfoo2
- call assert_equal('3', RubyEval('Vim::Buffer.count'))
+ call assert_equal(3, rubyeval('Vim::Buffer.count'))
%bwipe
- call assert_equal('1', RubyEval('Vim::Buffer.count'))
+ call assert_equal(1, rubyeval('Vim::Buffer.count'))
endfunc
" Test Vim::buffer[n] (return the buffer object of buffer number n)
-func Test_Vim_buffer_get()
+func Test_ruby_Vim_buffer_get()
new Xfoo1
new Xfoo2
" Index of Vim::Buffer[n] goes from 0 to the number of buffers.
- call assert_equal('', RubyEval('Vim::Buffer[0].name'))
- call assert_match('Xfoo1$', RubyEval('Vim::Buffer[1].name'))
- call assert_match('Xfoo2$', RubyEval('Vim::Buffer[2].name'))
+ call assert_equal('', rubyeval('Vim::Buffer[0].name'))
+ call assert_match('Xfoo1$', rubyeval('Vim::Buffer[1].name'))
+ call assert_match('Xfoo2$', rubyeval('Vim::Buffer[2].name'))
call assert_fails('ruby print Vim::Buffer[3].name',
\ "NoMethodError: undefined method `name' for nil:NilClass")
%bwipe
@@ -283,7 +275,7 @@ endfunc
" Test Vim::command({cmd}) (execute a Ex command))
" Test Vim::command({cmd})
-func Test_Vim_command()
+func Test_ruby_Vim_command()
new
call setline(1, ['one', 'two', 'three', 'four'])
ruby Vim::command('2,3d')
@@ -292,7 +284,7 @@ func Test_Vim_command()
endfunc
" Test Vim::set_option (set a vim option)
-func Test_Vim_set_option()
+func Test_ruby_Vim_set_option()
call assert_equal(0, &number)
ruby Vim::set_option('number')
call assert_equal(1, &number)
@@ -300,37 +292,39 @@ func Test_Vim_set_option()
call assert_equal(0, &number)
endfunc
-func Test_Vim_evaluate()
- call assert_equal('123', RubyEval('Vim::evaluate("123")'))
+func Test_ruby_Vim_evaluate()
+ call assert_equal(123, rubyeval('Vim::evaluate("123")'))
" Vim::evaluate("123").class gives Integer or Fixnum depending
" on versions of Ruby.
- call assert_match('^Integer\|Fixnum$', RubyEval('Vim::evaluate("123").class'))
+ call assert_match('^Integer\|Fixnum$', rubyeval('Vim::evaluate("123").class'))
- call assert_equal('1.23', RubyEval('Vim::evaluate("1.23")'))
- call assert_equal('Float', RubyEval('Vim::evaluate("1.23").class'))
+ if has('float')
+ call assert_equal(1.23, rubyeval('Vim::evaluate("1.23")'))
+ call assert_equal('Float', rubyeval('Vim::evaluate("1.23").class'))
+ endif
- call assert_equal('foo', RubyEval('Vim::evaluate("\"foo\"")'))
- call assert_equal('String', RubyEval('Vim::evaluate("\"foo\"").class'))
+ call assert_equal('foo', rubyeval('Vim::evaluate("\"foo\"")'))
+ call assert_equal('String', rubyeval('Vim::evaluate("\"foo\"").class'))
- call assert_equal('[1, 2]', RubyEval('Vim::evaluate("[1, 2]")'))
- call assert_equal('Array', RubyEval('Vim::evaluate("[1, 2]").class'))
+ call assert_equal([1, 2], rubyeval('Vim::evaluate("[1, 2]")'))
+ call assert_equal('Array', rubyeval('Vim::evaluate("[1, 2]").class'))
- call assert_equal('{"1"=>2}', RubyEval('Vim::evaluate("{1:2}")'))
- call assert_equal('Hash', RubyEval('Vim::evaluate("{1:2}").class'))
+ call assert_equal({'1': 2}, rubyeval('Vim::evaluate("{1:2}")'))
+ call assert_equal('Hash', rubyeval('Vim::evaluate("{1:2}").class'))
- call assert_equal('', RubyEval('Vim::evaluate("v:null")'))
- call assert_equal('NilClass', RubyEval('Vim::evaluate("v:null").class'))
+ call assert_equal(v:null, rubyeval('Vim::evaluate("v:null")'))
+ call assert_equal('NilClass', rubyeval('Vim::evaluate("v:null").class'))
- " call assert_equal('', RubyEval('Vim::evaluate("v:none")'))
- " call assert_equal('NilClass', RubyEval('Vim::evaluate("v:none").class'))
+ " call assert_equal(v:null, rubyeval('Vim::evaluate("v:none")'))
+ " call assert_equal('NilClass', rubyeval('Vim::evaluate("v:none").class'))
- call assert_equal('true', RubyEval('Vim::evaluate("v:true")'))
- call assert_equal('TrueClass', RubyEval('Vim::evaluate("v:true").class'))
- call assert_equal('false', RubyEval('Vim::evaluate("v:false")'))
- call assert_equal('FalseClass',RubyEval('Vim::evaluate("v:false").class'))
+ call assert_equal(v:true, rubyeval('Vim::evaluate("v:true")'))
+ call assert_equal('TrueClass', rubyeval('Vim::evaluate("v:true").class'))
+ call assert_equal(v:false, rubyeval('Vim::evaluate("v:false")'))
+ call assert_equal('FalseClass',rubyeval('Vim::evaluate("v:false").class'))
endfunc
-func Test_Vim_evaluate_list()
+func Test_ruby_Vim_evaluate_list()
call setline(line('$'), ['2 line 2'])
ruby Vim.command("normal /^2\n")
let l = ["abc", "def"]
@@ -344,7 +338,7 @@ EOF
call assert_equal('abc/def', getline('$'))
endfunc
-func Test_Vim_evaluate_dict()
+func Test_ruby_Vim_evaluate_dict()
let d = {'a': 'foo', 'b': 123}
redir => l:out
ruby d = Vim.evaluate("d"); print d
@@ -353,34 +347,47 @@ func Test_Vim_evaluate_dict()
endfunc
" Test Vim::message({msg}) (display message {msg})
-func Test_Vim_message()
+func Test_ruby_Vim_message()
throw 'skipped: TODO: '
ruby Vim::message('A message')
let messages = split(execute('message'), "\n")
call assert_equal('A message', messages[-1])
endfunc
-func Test_print()
- ruby print "Hello World!"
- let messages = split(execute('message'), "\n")
- call assert_equal('Hello World!', messages[-1])
+func Test_ruby_print()
+ func RubyPrint(expr)
+ return trim(execute('ruby print ' . a:expr))
+ endfunc
+
+ call assert_equal('123', RubyPrint('123'))
+ call assert_equal('1.23', RubyPrint('1.23'))
+ call assert_equal('Hello World!', RubyPrint('"Hello World!"'))
+ call assert_equal('[1, 2]', RubyPrint('[1, 2]'))
+ call assert_equal('{"k1"=>"v1", "k2"=>"v2"}', RubyPrint('({"k1" => "v1", "k2" => "v2"})'))
+ call assert_equal('true', RubyPrint('true'))
+ call assert_equal('false', RubyPrint('false'))
+ call assert_equal('', RubyPrint('nil'))
+ call assert_match('Vim', RubyPrint('Vim'))
+ call assert_match('Module', RubyPrint('Vim.class'))
+
+ delfunc RubyPrint
endfunc
-func Test_p()
+func Test_ruby_p()
ruby p 'Just a test'
- let messages = split(execute('message'), "\n")
+ let messages = GetMessages()
call assert_equal('"Just a test"', messages[-1])
" Check return values of p method
- call assert_equal('123', RubyEval('p(123)'))
- call assert_equal('[1, 2, 3]', RubyEval('p(1, 2, 3)'))
+ call assert_equal(123, rubyeval('p(123)'))
+ call assert_equal([1, 2, 3], rubyeval('p(1, 2, 3)'))
" Avoid the "message maintainer" line.
let $LANG = ''
messages clear
- call assert_equal('true', RubyEval('p() == nil'))
+ call assert_equal(v:true, rubyeval('p() == nil'))
- let messages = split(execute('message'), "\n")
+ let messages = GetMessages()
call assert_equal(0, len(messages))
endfunc
diff --git a/src/nvim/testdir/test_statusline.vim b/src/nvim/testdir/test_statusline.vim
index 7efd181d04..4e38f7ebd8 100644
--- a/src/nvim/testdir/test_statusline.vim
+++ b/src/nvim/testdir/test_statusline.vim
@@ -354,6 +354,21 @@ func Test_statusline()
delfunc GetNested
delfunc GetStatusLine
+ " Test statusline works with 80+ items
+ function! StatusLabel()
+ redrawstatus
+ return '[label]'
+ endfunc
+ let statusline = '%{StatusLabel()}'
+ for i in range(150)
+ let statusline .= '%#TabLine' . (i % 2 == 0 ? 'Fill' : 'Sel') . '#' . string(i)[0]
+ endfor
+ let &statusline = statusline
+ redrawstatus
+ set statusline&
+ delfunc StatusLabel
+
+
" Check statusline in current and non-current window
" with the 'fillchars' option.
set fillchars=stl:^,stlnc:=,vert:\|,fold:-,diff:-