diff options
author | Jan Edmund Lazo <janedmundlazo@hotmail.com> | 2018-09-02 21:10:55 -0400 |
---|---|---|
committer | Jan Edmund Lazo <janedmundlazo@hotmail.com> | 2018-09-02 21:12:09 -0400 |
commit | 5c9cd009e161fac9d549533f966b930c51877f4f (patch) | |
tree | d95ca938cfc47f04c9b83265214e591681677ded | |
parent | f62d4865d88de0bd60218ecb3e08d9f3c772e12e (diff) | |
download | rneovim-5c9cd009e161fac9d549533f966b930c51877f4f.tar.gz rneovim-5c9cd009e161fac9d549533f966b930c51877f4f.tar.bz2 rneovim-5c9cd009e161fac9d549533f966b930c51877f4f.zip |
vim-patch:8.1.0331: insufficient test coverage for :mkview and :loadview
Problem: Insufficient test coverage for :mkview and :loadview.
Solution: Add tests. (Dominique Pelle, closes vim/vim#3385)
https://github.com/vim/vim/commit/627cb6a6b37d17433fe2d7df1f287eefb5b370e3
-rw-r--r-- | src/nvim/testdir/test_mksession.vim | 81 |
1 files changed, 81 insertions, 0 deletions
diff --git a/src/nvim/testdir/test_mksession.vim b/src/nvim/testdir/test_mksession.vim index 4774cf4af5..f7836ea4b9 100644 --- a/src/nvim/testdir/test_mksession.vim +++ b/src/nvim/testdir/test_mksession.vim @@ -151,5 +151,86 @@ func Test_mksession_one_buffer_two_windows() call delete('Xtest_mks.out') endfunc +" Test :mkview with a file argument. +func Test_mkview_file() + " Create a view with line number and a fold. + help :mkview + set number + norm! V}zf + let pos = getpos('.') + let linefoldclosed1 = foldclosed('.') + mkview! Xview + set nonumber + norm! zrj + " We can close the help window, as mkview with a file name should + " generate a command to edit the file. + helpclose + + source Xview + call assert_equal(1, &number) + call assert_match('\*:mkview\*$', getline('.')) + call assert_equal(pos, getpos('.')) + call assert_equal(linefoldclosed1, foldclosed('.')) + + " Creating a view again with the same file name should fail (file + " already exists). But with a !, the previous view should be + " overwritten without error. + help :loadview + call assert_fails('mkview Xview', 'E189:') + call assert_match('\*:loadview\*$', getline('.')) + mkview! Xview + call assert_match('\*:loadview\*$', getline('.')) + + call delete('Xview') + bwipe +endfunc + +" Test :mkview and :loadview with a custom 'viewdir'. +func Test_mkview_loadview_with_viewdir() + set viewdir=Xviewdir + + help :mkview + set number + norm! V}zf + let pos = getpos('.') + let linefoldclosed1 = foldclosed('.') + mkview 1 + set nonumber + norm! zrj + + loadview 1 + + " The directory Xviewdir/ should have been created and the view + " should be stored in that directory. + call assert_equal('Xviewdir/' . + \ substitute( + \ substitute( + \ expand('%:p'), '/', '=+', 'g'), ':', '=-', 'g') . '=1.vim', + \ glob('Xviewdir/*')) + call assert_equal(1, &number) + call assert_match('\*:mkview\*$', getline('.')) + call assert_equal(pos, getpos('.')) + call assert_equal(linefoldclosed1, foldclosed('.')) + + call delete('Xviewdir', 'rf') + set viewdir& + helpclose +endfunc + +func Test_mkview_no_file_name() + new + " :mkview or :mkview {nr} should fail in a unnamed buffer. + call assert_fails('mkview', 'E32:') + call assert_fails('mkview 1', 'E32:') + + " :mkview {file} should succeed in a unnamed buffer. + mkview Xview + help + source Xview + call assert_equal('', bufname('%')) + + call delete('Xview') + %bwipe +endfunc " vim: shiftwidth=2 sts=2 expandtab |