summaryrefslogtreecommitdiffstats
path: root/src/testdir/test_put.vim
diff options
context:
space:
mode:
authorBram Moolenaar <Bram@vim.org>2018-06-27 20:49:44 +0200
committerBram Moolenaar <Bram@vim.org>2018-06-27 20:49:44 +0200
commitf52f9ea8f5fb3df51a308c56f2bf66f735ef3ca7 (patch)
tree28df043ec3739ec82a80cef96605de5a91e6ba11 /src/testdir/test_put.vim
parentbd87eb38c558521ff709651ac190ffd1b9dee057 (diff)
patch 8.1.0118: duplicate error message for put commandv8.1.0118
Problem: Duplicate error message for put command. Solution: Check return value of u_save(). (Jason Franklin)
Diffstat (limited to 'src/testdir/test_put.vim')
-rw-r--r--src/testdir/test_put.vim46
1 files changed, 46 insertions, 0 deletions
diff --git a/src/testdir/test_put.vim b/src/testdir/test_put.vim
index 0a23a43919..e425c44f9f 100644
--- a/src/testdir/test_put.vim
+++ b/src/testdir/test_put.vim
@@ -1,3 +1,4 @@
+" Tests for put commands, e.g. ":put", "p", "gp", "P", "gP", etc.
func Test_put_block()
if !has('multi_byte')
@@ -58,3 +59,48 @@ func Test_put_expr()
call assert_equal(['A1','A2','A3','4A','5A','6A'], getline(1,'$'))
bw!
endfunc
+
+func Test_put_fails_when_nomodifiable()
+ new
+ set nomodifiable
+
+ normal! yy
+ call assert_fails(':put', 'E21')
+ call assert_fails(':put!', 'E21')
+ call assert_fails(':normal! p', 'E21')
+ call assert_fails(':normal! gp', 'E21')
+ call assert_fails(':normal! P', 'E21')
+ call assert_fails(':normal! gP', 'E21')
+
+ if has('mouse')
+ set mouse=n
+ call assert_fails('execute "normal! \<MiddleMouse>"', 'E21')
+ set mouse&
+ endif
+
+ bwipeout!
+endfunc
+
+" A bug was discovered where the Normal mode put commands (e.g., "p") would
+" output duplicate error messages when invoked in a non-modifiable buffer.
+func Test_put_p_errmsg_nodup()
+ new
+ set nomodifiable
+
+ normal! yy
+
+ func Capture_p_error()
+ redir => s:p_err
+ normal! p
+ redir END
+ endfunc
+
+ silent! call Capture_p_error()
+
+ " Error message output within a function should be three lines (the function
+ " name, the line number, and the error message).
+ call assert_equal(3, count(s:p_err, "\n"))
+
+ delfunction Capture_p_error
+ bwipeout!
+endfunc