annotate src/testdir/test_put.vim @ 15547:1dd0a47f4be2 v8.1.0781

patch 8.1.0781: build error when using if_xcmdsrv.c commit https://github.com/vim/vim/commit/a502caab8bd396316a6eb5cb821b0a0df55c502a Author: Bram Moolenaar <Bram@vim.org> Date: Sat Jan 19 18:23:41 2019 +0100 patch 8.1.0781: build error when using if_xcmdsrv.c Problem: Build error when using if_xcmdsrv.c. Solution: Add missing part of 8.1.0779.
author Bram Moolenaar <Bram@vim.org>
date Sat, 19 Jan 2019 18:30:07 +0100
parents 1b9f3932a130
children 2dcaa860e3fc
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
14202
51693b1a640e patch 8.1.0118: duplicate error message for put command
Christian Brabandt <cb@256bit.org>
parents: 14009
diff changeset
1 " Tests for put commands, e.g. ":put", "p", "gp", "P", "gP", etc.
10664
94db9c08e206 patch 8.0.0222: blockwise put on multi-byte character misplaced
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2
94db9c08e206 patch 8.0.0222: blockwise put on multi-byte character misplaced
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3 func Test_put_block()
94db9c08e206 patch 8.0.0222: blockwise put on multi-byte character misplaced
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4 if !has('multi_byte')
94db9c08e206 patch 8.0.0222: blockwise put on multi-byte character misplaced
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5 return
94db9c08e206 patch 8.0.0222: blockwise put on multi-byte character misplaced
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6 endif
94db9c08e206 patch 8.0.0222: blockwise put on multi-byte character misplaced
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7 new
94db9c08e206 patch 8.0.0222: blockwise put on multi-byte character misplaced
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
8 call feedkeys("i\<C-V>u2500\<CR>x\<ESC>", 'x')
94db9c08e206 patch 8.0.0222: blockwise put on multi-byte character misplaced
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
9 call feedkeys("\<C-V>y", 'x')
94db9c08e206 patch 8.0.0222: blockwise put on multi-byte character misplaced
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
10 call feedkeys("gg0p", 'x')
94db9c08e206 patch 8.0.0222: blockwise put on multi-byte character misplaced
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
11 call assert_equal("\u2500x", getline(1))
94db9c08e206 patch 8.0.0222: blockwise put on multi-byte character misplaced
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
12 bwipe!
94db9c08e206 patch 8.0.0222: blockwise put on multi-byte character misplaced
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
13 endfunc
10670
bce3eccea39a patch 8.0.0225: put in Visual block mode terminates early
Christian Brabandt <cb@256bit.org>
parents: 10664
diff changeset
14
bce3eccea39a patch 8.0.0225: put in Visual block mode terminates early
Christian Brabandt <cb@256bit.org>
parents: 10664
diff changeset
15 func Test_put_char_block()
bce3eccea39a patch 8.0.0225: put in Visual block mode terminates early
Christian Brabandt <cb@256bit.org>
parents: 10664
diff changeset
16 new
bce3eccea39a patch 8.0.0225: put in Visual block mode terminates early
Christian Brabandt <cb@256bit.org>
parents: 10664
diff changeset
17 call setline(1, ['Line 1', 'Line 2'])
bce3eccea39a patch 8.0.0225: put in Visual block mode terminates early
Christian Brabandt <cb@256bit.org>
parents: 10664
diff changeset
18 f Xfile_put
bce3eccea39a patch 8.0.0225: put in Visual block mode terminates early
Christian Brabandt <cb@256bit.org>
parents: 10664
diff changeset
19 " visually select both lines and put the cursor at the top of the visual
bce3eccea39a patch 8.0.0225: put in Visual block mode terminates early
Christian Brabandt <cb@256bit.org>
parents: 10664
diff changeset
20 " selection and then put the buffer name over it
bce3eccea39a patch 8.0.0225: put in Visual block mode terminates early
Christian Brabandt <cb@256bit.org>
parents: 10664
diff changeset
21 exe "norm! G0\<c-v>ke\"%p"
bce3eccea39a patch 8.0.0225: put in Visual block mode terminates early
Christian Brabandt <cb@256bit.org>
parents: 10664
diff changeset
22 call assert_equal(['Xfile_put 1', 'Xfile_put 2'], getline(1,2))
bce3eccea39a patch 8.0.0225: put in Visual block mode terminates early
Christian Brabandt <cb@256bit.org>
parents: 10664
diff changeset
23 bw!
bce3eccea39a patch 8.0.0225: put in Visual block mode terminates early
Christian Brabandt <cb@256bit.org>
parents: 10664
diff changeset
24 endfunc
10688
3d1872fbecc4 patch 8.0.0234: crash when using put in Visual mode
Christian Brabandt <cb@256bit.org>
parents: 10670
diff changeset
25
3d1872fbecc4 patch 8.0.0234: crash when using put in Visual mode
Christian Brabandt <cb@256bit.org>
parents: 10670
diff changeset
26 func Test_put_char_block2()
3d1872fbecc4 patch 8.0.0234: crash when using put in Visual mode
Christian Brabandt <cb@256bit.org>
parents: 10670
diff changeset
27 new
3d1872fbecc4 patch 8.0.0234: crash when using put in Visual mode
Christian Brabandt <cb@256bit.org>
parents: 10670
diff changeset
28 let a = [ getreg('a'), getregtype('a') ]
3d1872fbecc4 patch 8.0.0234: crash when using put in Visual mode
Christian Brabandt <cb@256bit.org>
parents: 10670
diff changeset
29 call setreg('a', ' one ', 'v')
3d1872fbecc4 patch 8.0.0234: crash when using put in Visual mode
Christian Brabandt <cb@256bit.org>
parents: 10670
diff changeset
30 call setline(1, ['Line 1', '', 'Line 3', ''])
3d1872fbecc4 patch 8.0.0234: crash when using put in Visual mode
Christian Brabandt <cb@256bit.org>
parents: 10670
diff changeset
31 " visually select the first 3 lines and put register a over it
3d1872fbecc4 patch 8.0.0234: crash when using put in Visual mode
Christian Brabandt <cb@256bit.org>
parents: 10670
diff changeset
32 exe "norm! ggl\<c-v>2j2l\"ap"
3d1872fbecc4 patch 8.0.0234: crash when using put in Visual mode
Christian Brabandt <cb@256bit.org>
parents: 10670
diff changeset
33 call assert_equal(['L one 1', '', 'L one 3', ''], getline(1,4))
3d1872fbecc4 patch 8.0.0234: crash when using put in Visual mode
Christian Brabandt <cb@256bit.org>
parents: 10670
diff changeset
34 " clean up
3d1872fbecc4 patch 8.0.0234: crash when using put in Visual mode
Christian Brabandt <cb@256bit.org>
parents: 10670
diff changeset
35 bw!
3d1872fbecc4 patch 8.0.0234: crash when using put in Visual mode
Christian Brabandt <cb@256bit.org>
parents: 10670
diff changeset
36 call setreg('a', a[0], a[1])
3d1872fbecc4 patch 8.0.0234: crash when using put in Visual mode
Christian Brabandt <cb@256bit.org>
parents: 10670
diff changeset
37 endfunc
11597
72b20190dce6 patch 8.0.0681: unnamed register only contains the last deleted text
Christian Brabandt <cb@256bit.org>
parents: 10688
diff changeset
38
72b20190dce6 patch 8.0.0681: unnamed register only contains the last deleted text
Christian Brabandt <cb@256bit.org>
parents: 10688
diff changeset
39 func Test_put_lines()
72b20190dce6 patch 8.0.0681: unnamed register only contains the last deleted text
Christian Brabandt <cb@256bit.org>
parents: 10688
diff changeset
40 new
72b20190dce6 patch 8.0.0681: unnamed register only contains the last deleted text
Christian Brabandt <cb@256bit.org>
parents: 10688
diff changeset
41 let a = [ getreg('a'), getregtype('a') ]
72b20190dce6 patch 8.0.0681: unnamed register only contains the last deleted text
Christian Brabandt <cb@256bit.org>
parents: 10688
diff changeset
42 call setline(1, ['Line 1', 'Line2', 'Line 3', ''])
72b20190dce6 patch 8.0.0681: unnamed register only contains the last deleted text
Christian Brabandt <cb@256bit.org>
parents: 10688
diff changeset
43 exe 'norm! gg"add"AddG""p'
72b20190dce6 patch 8.0.0681: unnamed register only contains the last deleted text
Christian Brabandt <cb@256bit.org>
parents: 10688
diff changeset
44 call assert_equal(['Line 3', '', 'Line 1', 'Line2'], getline(1,'$'))
72b20190dce6 patch 8.0.0681: unnamed register only contains the last deleted text
Christian Brabandt <cb@256bit.org>
parents: 10688
diff changeset
45 " clean up
72b20190dce6 patch 8.0.0681: unnamed register only contains the last deleted text
Christian Brabandt <cb@256bit.org>
parents: 10688
diff changeset
46 bw!
72b20190dce6 patch 8.0.0681: unnamed register only contains the last deleted text
Christian Brabandt <cb@256bit.org>
parents: 10688
diff changeset
47 call setreg('a', a[0], a[1])
72b20190dce6 patch 8.0.0681: unnamed register only contains the last deleted text
Christian Brabandt <cb@256bit.org>
parents: 10688
diff changeset
48 endfunc
14009
830a47e48791 patch 8.1.0022: repeating put from expression register fails
Christian Brabandt <cb@256bit.org>
parents: 11597
diff changeset
49
830a47e48791 patch 8.1.0022: repeating put from expression register fails
Christian Brabandt <cb@256bit.org>
parents: 11597
diff changeset
50 func Test_put_expr()
830a47e48791 patch 8.1.0022: repeating put from expression register fails
Christian Brabandt <cb@256bit.org>
parents: 11597
diff changeset
51 new
830a47e48791 patch 8.1.0022: repeating put from expression register fails
Christian Brabandt <cb@256bit.org>
parents: 11597
diff changeset
52 call setline(1, repeat(['A'], 6))
830a47e48791 patch 8.1.0022: repeating put from expression register fails
Christian Brabandt <cb@256bit.org>
parents: 11597
diff changeset
53 exec "1norm! \"=line('.')\<cr>p"
830a47e48791 patch 8.1.0022: repeating put from expression register fails
Christian Brabandt <cb@256bit.org>
parents: 11597
diff changeset
54 norm! j0.
830a47e48791 patch 8.1.0022: repeating put from expression register fails
Christian Brabandt <cb@256bit.org>
parents: 11597
diff changeset
55 norm! j0.
830a47e48791 patch 8.1.0022: repeating put from expression register fails
Christian Brabandt <cb@256bit.org>
parents: 11597
diff changeset
56 exec "4norm! \"=\<cr>P"
830a47e48791 patch 8.1.0022: repeating put from expression register fails
Christian Brabandt <cb@256bit.org>
parents: 11597
diff changeset
57 norm! j0.
830a47e48791 patch 8.1.0022: repeating put from expression register fails
Christian Brabandt <cb@256bit.org>
parents: 11597
diff changeset
58 norm! j0.
830a47e48791 patch 8.1.0022: repeating put from expression register fails
Christian Brabandt <cb@256bit.org>
parents: 11597
diff changeset
59 call assert_equal(['A1','A2','A3','4A','5A','6A'], getline(1,'$'))
830a47e48791 patch 8.1.0022: repeating put from expression register fails
Christian Brabandt <cb@256bit.org>
parents: 11597
diff changeset
60 bw!
830a47e48791 patch 8.1.0022: repeating put from expression register fails
Christian Brabandt <cb@256bit.org>
parents: 11597
diff changeset
61 endfunc
14202
51693b1a640e patch 8.1.0118: duplicate error message for put command
Christian Brabandt <cb@256bit.org>
parents: 14009
diff changeset
62
51693b1a640e patch 8.1.0118: duplicate error message for put command
Christian Brabandt <cb@256bit.org>
parents: 14009
diff changeset
63 func Test_put_fails_when_nomodifiable()
51693b1a640e patch 8.1.0118: duplicate error message for put command
Christian Brabandt <cb@256bit.org>
parents: 14009
diff changeset
64 new
14204
1b9f3932a130 patch 8.1.0119: failing test goes unnoticed because messages is not written
Christian Brabandt <cb@256bit.org>
parents: 14202
diff changeset
65 setlocal nomodifiable
14202
51693b1a640e patch 8.1.0118: duplicate error message for put command
Christian Brabandt <cb@256bit.org>
parents: 14009
diff changeset
66
51693b1a640e patch 8.1.0118: duplicate error message for put command
Christian Brabandt <cb@256bit.org>
parents: 14009
diff changeset
67 normal! yy
51693b1a640e patch 8.1.0118: duplicate error message for put command
Christian Brabandt <cb@256bit.org>
parents: 14009
diff changeset
68 call assert_fails(':put', 'E21')
51693b1a640e patch 8.1.0118: duplicate error message for put command
Christian Brabandt <cb@256bit.org>
parents: 14009
diff changeset
69 call assert_fails(':put!', 'E21')
51693b1a640e patch 8.1.0118: duplicate error message for put command
Christian Brabandt <cb@256bit.org>
parents: 14009
diff changeset
70 call assert_fails(':normal! p', 'E21')
51693b1a640e patch 8.1.0118: duplicate error message for put command
Christian Brabandt <cb@256bit.org>
parents: 14009
diff changeset
71 call assert_fails(':normal! gp', 'E21')
51693b1a640e patch 8.1.0118: duplicate error message for put command
Christian Brabandt <cb@256bit.org>
parents: 14009
diff changeset
72 call assert_fails(':normal! P', 'E21')
51693b1a640e patch 8.1.0118: duplicate error message for put command
Christian Brabandt <cb@256bit.org>
parents: 14009
diff changeset
73 call assert_fails(':normal! gP', 'E21')
51693b1a640e patch 8.1.0118: duplicate error message for put command
Christian Brabandt <cb@256bit.org>
parents: 14009
diff changeset
74
51693b1a640e patch 8.1.0118: duplicate error message for put command
Christian Brabandt <cb@256bit.org>
parents: 14009
diff changeset
75 if has('mouse')
51693b1a640e patch 8.1.0118: duplicate error message for put command
Christian Brabandt <cb@256bit.org>
parents: 14009
diff changeset
76 set mouse=n
51693b1a640e patch 8.1.0118: duplicate error message for put command
Christian Brabandt <cb@256bit.org>
parents: 14009
diff changeset
77 call assert_fails('execute "normal! \<MiddleMouse>"', 'E21')
51693b1a640e patch 8.1.0118: duplicate error message for put command
Christian Brabandt <cb@256bit.org>
parents: 14009
diff changeset
78 set mouse&
51693b1a640e patch 8.1.0118: duplicate error message for put command
Christian Brabandt <cb@256bit.org>
parents: 14009
diff changeset
79 endif
51693b1a640e patch 8.1.0118: duplicate error message for put command
Christian Brabandt <cb@256bit.org>
parents: 14009
diff changeset
80
51693b1a640e patch 8.1.0118: duplicate error message for put command
Christian Brabandt <cb@256bit.org>
parents: 14009
diff changeset
81 bwipeout!
51693b1a640e patch 8.1.0118: duplicate error message for put command
Christian Brabandt <cb@256bit.org>
parents: 14009
diff changeset
82 endfunc
51693b1a640e patch 8.1.0118: duplicate error message for put command
Christian Brabandt <cb@256bit.org>
parents: 14009
diff changeset
83
51693b1a640e patch 8.1.0118: duplicate error message for put command
Christian Brabandt <cb@256bit.org>
parents: 14009
diff changeset
84 " A bug was discovered where the Normal mode put commands (e.g., "p") would
51693b1a640e patch 8.1.0118: duplicate error message for put command
Christian Brabandt <cb@256bit.org>
parents: 14009
diff changeset
85 " output duplicate error messages when invoked in a non-modifiable buffer.
51693b1a640e patch 8.1.0118: duplicate error message for put command
Christian Brabandt <cb@256bit.org>
parents: 14009
diff changeset
86 func Test_put_p_errmsg_nodup()
51693b1a640e patch 8.1.0118: duplicate error message for put command
Christian Brabandt <cb@256bit.org>
parents: 14009
diff changeset
87 new
14204
1b9f3932a130 patch 8.1.0119: failing test goes unnoticed because messages is not written
Christian Brabandt <cb@256bit.org>
parents: 14202
diff changeset
88 setlocal nomodifiable
14202
51693b1a640e patch 8.1.0118: duplicate error message for put command
Christian Brabandt <cb@256bit.org>
parents: 14009
diff changeset
89
51693b1a640e patch 8.1.0118: duplicate error message for put command
Christian Brabandt <cb@256bit.org>
parents: 14009
diff changeset
90 normal! yy
51693b1a640e patch 8.1.0118: duplicate error message for put command
Christian Brabandt <cb@256bit.org>
parents: 14009
diff changeset
91
51693b1a640e patch 8.1.0118: duplicate error message for put command
Christian Brabandt <cb@256bit.org>
parents: 14009
diff changeset
92 func Capture_p_error()
51693b1a640e patch 8.1.0118: duplicate error message for put command
Christian Brabandt <cb@256bit.org>
parents: 14009
diff changeset
93 redir => s:p_err
51693b1a640e patch 8.1.0118: duplicate error message for put command
Christian Brabandt <cb@256bit.org>
parents: 14009
diff changeset
94 normal! p
51693b1a640e patch 8.1.0118: duplicate error message for put command
Christian Brabandt <cb@256bit.org>
parents: 14009
diff changeset
95 redir END
51693b1a640e patch 8.1.0118: duplicate error message for put command
Christian Brabandt <cb@256bit.org>
parents: 14009
diff changeset
96 endfunc
51693b1a640e patch 8.1.0118: duplicate error message for put command
Christian Brabandt <cb@256bit.org>
parents: 14009
diff changeset
97
51693b1a640e patch 8.1.0118: duplicate error message for put command
Christian Brabandt <cb@256bit.org>
parents: 14009
diff changeset
98 silent! call Capture_p_error()
51693b1a640e patch 8.1.0118: duplicate error message for put command
Christian Brabandt <cb@256bit.org>
parents: 14009
diff changeset
99
51693b1a640e patch 8.1.0118: duplicate error message for put command
Christian Brabandt <cb@256bit.org>
parents: 14009
diff changeset
100 " Error message output within a function should be three lines (the function
51693b1a640e patch 8.1.0118: duplicate error message for put command
Christian Brabandt <cb@256bit.org>
parents: 14009
diff changeset
101 " name, the line number, and the error message).
51693b1a640e patch 8.1.0118: duplicate error message for put command
Christian Brabandt <cb@256bit.org>
parents: 14009
diff changeset
102 call assert_equal(3, count(s:p_err, "\n"))
51693b1a640e patch 8.1.0118: duplicate error message for put command
Christian Brabandt <cb@256bit.org>
parents: 14009
diff changeset
103
51693b1a640e patch 8.1.0118: duplicate error message for put command
Christian Brabandt <cb@256bit.org>
parents: 14009
diff changeset
104 delfunction Capture_p_error
51693b1a640e patch 8.1.0118: duplicate error message for put command
Christian Brabandt <cb@256bit.org>
parents: 14009
diff changeset
105 bwipeout!
51693b1a640e patch 8.1.0118: duplicate error message for put command
Christian Brabandt <cb@256bit.org>
parents: 14009
diff changeset
106 endfunc