Mercurial > vim
diff src/testdir/test_excmd.vim @ 19425:67fbe280a502 v8.2.0270
patch 8.2.0270: some code not covered by tests
Commit: https://github.com/vim/vim/commit/bc2b71d44a0b90b6aeb3534a76912fccbe5577df
Author: Bram Moolenaar <Bram@vim.org>
Date: Mon Feb 17 21:33:30 2020 +0100
patch 8.2.0270: some code not covered by tests
Problem: Some code not covered by tests.
Solution: Add test cases. (Yegappan Lakshmanan, closes https://github.com/vim/vim/issues/5649)
author | Bram Moolenaar <Bram@vim.org> |
---|---|
date | Mon, 17 Feb 2020 21:45:04 +0100 |
parents | 02111977dd05 |
children | 8f8a5a15d00a |
line wrap: on
line diff
--- a/src/testdir/test_excmd.vim +++ b/src/testdir/test_excmd.vim @@ -267,6 +267,16 @@ func Test_redir_cmd() call assert_fails('redir! > Xfile', 'E190:') call delete('Xfile') endif + + " Test for redirecting to a register + redir @q> | echon 'clean ' | redir END + redir @q>> | echon 'water' | redir END + call assert_equal('clean water', @q) + + " Test for redirecting to a variable + redir => color | echon 'blue ' | redir END + redir =>> color | echon 'sky' | redir END + call assert_equal('blue sky', color) endfunc " Test for the :filetype command @@ -279,4 +289,50 @@ func Test_mode_cmd() call assert_fails('mode abc', 'E359:') endfunc +" Test for the :sleep command +func Test_sleep_cmd() + call assert_fails('sleep x', 'E475:') +endfunc + +" Test for the :read command +func Test_read_cmd() + call writefile(['one'], 'Xfile') + new + call assert_fails('read', 'E32:') + edit Xfile + read + call assert_equal(['one', 'one'], getline(1, '$')) + close! + new + read Xfile + call assert_equal(['', 'one'], getline(1, '$')) + call deletebufline('', 1, '$') + call feedkeys("Qr Xfile\<CR>visual\<CR>", 'xt') + call assert_equal(['one'], getline(1, '$')) + close! + call delete('Xfile') +endfunc + +" Test for running Ex commands when text is locked. +" <C-\>e in the command line is used to lock the text +func Test_run_excmd_with_text_locked() + " :quit + let cmd = ":\<C-\>eexecute('quit')\<CR>\<C-C>" + call assert_fails("call feedkeys(cmd, 'xt')", 'E523:') + + " :qall + let cmd = ":\<C-\>eexecute('qall')\<CR>\<C-C>" + call assert_fails("call feedkeys(cmd, 'xt')", 'E523:') + + " :exit + let cmd = ":\<C-\>eexecute('exit')\<CR>\<C-C>" + call assert_fails("call feedkeys(cmd, 'xt')", 'E523:') + + " :close - should be ignored + new + let cmd = ":\<C-\>eexecute('close')\<CR>\<C-C>" + call assert_equal(2, winnr('$')) + close +endfunc + " vim: shiftwidth=2 sts=2 expandtab