|
| 1 | +" Tests for put commands, e.g. ":put", "p", "gp", "P", "gP", etc. |
1 | 2 |
|
2 | 3 | func Test_put_block() |
3 | 4 | if !has('multi_byte') |
@@ -58,3 +59,48 @@ func Test_put_expr() |
58 | 59 | call assert_equal(['A1','A2','A3','4A','5A','6A'], getline(1,'$')) |
59 | 60 | bw! |
60 | 61 | endfunc |
| 62 | + |
| 63 | +func Test_put_fails_when_nomodifiable() |
| 64 | + new |
| 65 | + set nomodifiable |
| 66 | + |
| 67 | + normal! yy |
| 68 | + call assert_fails(':put', 'E21') |
| 69 | + call assert_fails(':put!', 'E21') |
| 70 | + call assert_fails(':normal! p', 'E21') |
| 71 | + call assert_fails(':normal! gp', 'E21') |
| 72 | + call assert_fails(':normal! P', 'E21') |
| 73 | + call assert_fails(':normal! gP', 'E21') |
| 74 | + |
| 75 | + if has('mouse') |
| 76 | + set mouse=n |
| 77 | + call assert_fails('execute "normal! \<MiddleMouse>"', 'E21') |
| 78 | + set mouse& |
| 79 | + endif |
| 80 | + |
| 81 | + bwipeout! |
| 82 | +endfunc |
| 83 | + |
| 84 | +" A bug was discovered where the Normal mode put commands (e.g., "p") would |
| 85 | +" output duplicate error messages when invoked in a non-modifiable buffer. |
| 86 | +func Test_put_p_errmsg_nodup() |
| 87 | + new |
| 88 | + set nomodifiable |
| 89 | + |
| 90 | + normal! yy |
| 91 | + |
| 92 | + func Capture_p_error() |
| 93 | + redir => s:p_err |
| 94 | + normal! p |
| 95 | + redir END |
| 96 | + endfunc |
| 97 | + |
| 98 | + silent! call Capture_p_error() |
| 99 | + |
| 100 | + " Error message output within a function should be three lines (the function |
| 101 | + " name, the line number, and the error message). |
| 102 | + call assert_equal(3, count(s:p_err, "\n")) |
| 103 | + |
| 104 | + delfunction Capture_p_error |
| 105 | + bwipeout! |
| 106 | +endfunc |
0 commit comments