diff options
| author | Justin M. Keyes <justinkz@gmail.com> | 2019-06-25 02:36:07 +0200 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2019-06-25 02:36:07 +0200 |
| commit | 79450f2da97e352676516d63521c18fbac46186b (patch) | |
| tree | 67f808bbb479d5c0ae737f079587530a4774a583 /src/nvim/testdir | |
| parent | 8cd87af8d67bd97f1897f527994e4d81cb39e286 (diff) | |
| parent | d0e1417254099eb8f8bee066e84d5a49246e737f (diff) | |
| download | rneovim-79450f2da97e352676516d63521c18fbac46186b.tar.gz rneovim-79450f2da97e352676516d63521c18fbac46186b.tar.bz2 rneovim-79450f2da97e352676516d63521c18fbac46186b.zip | |
Merge #10250 from blueyed/vim-8.0.1039
vim-patch:8.0.{10{39,53,55},1274}: cannot change a line in not current buffer
Diffstat (limited to 'src/nvim/testdir')
| -rw-r--r-- | src/nvim/testdir/shared.vim | 14 | ||||
| -rw-r--r-- | src/nvim/testdir/test_bufline.vim | 67 |
2 files changed, 77 insertions, 4 deletions
diff --git a/src/nvim/testdir/shared.vim b/src/nvim/testdir/shared.vim index ac34dec569..a5cf4def4f 100644 --- a/src/nvim/testdir/shared.vim +++ b/src/nvim/testdir/shared.vim @@ -190,12 +190,18 @@ func s:feedkeys(timer) endfunc " Get the command to run Vim, with -u NONE and --headless arguments. +" If there is an argument use it instead of "NONE". " Returns an empty string on error. -func GetVimCommand() +func GetVimCommand(...) + if a:0 == 0 + let name = 'NONE' + else + let name = a:1 + endif let cmd = v:progpath - let cmd = substitute(cmd, '-u \f\+', '-u NONE', '') - if cmd !~ '-u NONE' - let cmd = cmd . ' -u NONE' + let cmd = substitute(cmd, '-u \f\+', '-u ' . name, '') + if cmd !~ '-u '. name + let cmd = cmd . ' -u ' . name endif let cmd .= ' --headless -i NONE' let cmd = substitute(cmd, 'VIMRUNTIME=.*VIMRUNTIME;', '', '') diff --git a/src/nvim/testdir/test_bufline.vim b/src/nvim/testdir/test_bufline.vim new file mode 100644 index 0000000000..b886e99506 --- /dev/null +++ b/src/nvim/testdir/test_bufline.vim @@ -0,0 +1,67 @@ +" Tests for setbufline() and getbufline() + +source shared.vim + +func Test_setbufline_getbufline() + new + let b = bufnr('%') + hide + call assert_equal(0, setbufline(b, 1, ['foo', 'bar'])) + call assert_equal(['foo'], getbufline(b, 1)) + call assert_equal(['bar'], getbufline(b, 2)) + call assert_equal(['foo', 'bar'], getbufline(b, 1, 2)) + exe "bd!" b + call assert_equal([], getbufline(b, 1, 2)) + + split Xtest + call setline(1, ['a', 'b', 'c']) + let b = bufnr('%') + wincmd w + call assert_equal(1, setbufline(b, 5, ['x'])) + call assert_equal(1, setbufline(1234, 1, ['x'])) + call assert_equal(0, setbufline(b, 4, ['d', 'e'])) + call assert_equal(['c'], getbufline(b, 3)) + call assert_equal(['d'], getbufline(b, 4)) + call assert_equal(['e'], getbufline(b, 5)) + call assert_equal([], getbufline(b, 6)) + exe "bwipe! " . b +endfunc + +func Test_setbufline_getbufline_fold() + split Xtest + setlocal foldmethod=expr foldexpr=0 + let b = bufnr('%') + new + call assert_equal(0, setbufline(b, 1, ['foo', 'bar'])) + call assert_equal(['foo'], getbufline(b, 1)) + call assert_equal(['bar'], getbufline(b, 2)) + call assert_equal(['foo', 'bar'], getbufline(b, 1, 2)) + exe "bwipe!" b + bwipe! +endfunc + +func Test_setbufline_getbufline_fold_tab() + split Xtest + setlocal foldmethod=expr foldexpr=0 + let b = bufnr('%') + tab new + call assert_equal(0, setbufline(b, 1, ['foo', 'bar'])) + call assert_equal(['foo'], getbufline(b, 1)) + call assert_equal(['bar'], getbufline(b, 2)) + call assert_equal(['foo', 'bar'], getbufline(b, 1, 2)) + exe "bwipe!" b + bwipe! +endfunc + +func Test_setline_startup() + let cmd = GetVimCommand('Xscript') + if cmd == '' + return + endif + call writefile(['call setline(1, "Hello")', 'silent w Xtest', 'q!'], 'Xscript') + call system(cmd) + call assert_equal(['Hello'], readfile('Xtest')) + + call delete('Xscript') + call delete('Xtest') +endfunc |