annotate src/testdir/test_registers.vim @ 18755:a0be066d0b48 v8.1.2367

patch 8.1.2367: registers are not sufficiently tested Commit: https://github.com/vim/vim/commit/71136db1bfbc67c2e55f8070cdf0a241c643e45b Author: Bram Moolenaar <Bram@vim.org> Date: Sat Nov 30 19:48:46 2019 +0100 patch 8.1.2367: registers are not sufficiently tested Problem: Registers are not sufficiently tested. Solution: Add a few more test cases. (Yegappan Lakshmanan, closes https://github.com/vim/vim/issues/5288)
author Bram Moolenaar <Bram@vim.org>
date Sat, 30 Nov 2019 20:00:03 +0100
parents 6ec1bfb4690b
children 50fde4e20790
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
18755
a0be066d0b48 patch 8.1.2367: registers are not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 18436
diff changeset
1 "
a0be066d0b48 patch 8.1.2367: registers are not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 18436
diff changeset
2 " Tests for register operations
a0be066d0b48 patch 8.1.2367: registers are not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 18436
diff changeset
3 "
a0be066d0b48 patch 8.1.2367: registers are not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 18436
diff changeset
4
a0be066d0b48 patch 8.1.2367: registers are not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 18436
diff changeset
5 " This test must be executed first to check for empty and unset registers.
a0be066d0b48 patch 8.1.2367: registers are not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 18436
diff changeset
6 func Test_aaa_empty_reg_test()
a0be066d0b48 patch 8.1.2367: registers are not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 18436
diff changeset
7 call assert_fails('normal @@', 'E748:')
a0be066d0b48 patch 8.1.2367: registers are not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 18436
diff changeset
8 call assert_fails('normal @%', 'E354:')
a0be066d0b48 patch 8.1.2367: registers are not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 18436
diff changeset
9 call assert_fails('normal @#', 'E354:')
a0be066d0b48 patch 8.1.2367: registers are not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 18436
diff changeset
10 call assert_fails('normal @!', 'E354:')
a0be066d0b48 patch 8.1.2367: registers are not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 18436
diff changeset
11 call assert_fails('normal @:', 'E30:')
a0be066d0b48 patch 8.1.2367: registers are not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 18436
diff changeset
12 call assert_fails('normal @.', 'E29:')
a0be066d0b48 patch 8.1.2367: registers are not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 18436
diff changeset
13 endfunc
11682
b9928ef8632f patch 8.0.0724: the message for yanking doesn't indicate the register
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
14
b9928ef8632f patch 8.0.0724: the message for yanking doesn't indicate the register
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
15 func Test_yank_shows_register()
b9928ef8632f patch 8.0.0724: the message for yanking doesn't indicate the register
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
16 enew
b9928ef8632f patch 8.0.0724: the message for yanking doesn't indicate the register
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
17 set report=0
b9928ef8632f patch 8.0.0724: the message for yanking doesn't indicate the register
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
18 call setline(1, ['foo', 'bar'])
b9928ef8632f patch 8.0.0724: the message for yanking doesn't indicate the register
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
19 " Line-wise
b9928ef8632f patch 8.0.0724: the message for yanking doesn't indicate the register
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
20 exe 'norm! yy'
b9928ef8632f patch 8.0.0724: the message for yanking doesn't indicate the register
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
21 call assert_equal('1 line yanked', v:statusmsg)
b9928ef8632f patch 8.0.0724: the message for yanking doesn't indicate the register
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
22 exe 'norm! "zyy'
b9928ef8632f patch 8.0.0724: the message for yanking doesn't indicate the register
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
23 call assert_equal('1 line yanked into "z', v:statusmsg)
b9928ef8632f patch 8.0.0724: the message for yanking doesn't indicate the register
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
24 exe 'norm! yj'
b9928ef8632f patch 8.0.0724: the message for yanking doesn't indicate the register
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
25 call assert_equal('2 lines yanked', v:statusmsg)
b9928ef8632f patch 8.0.0724: the message for yanking doesn't indicate the register
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
26 exe 'norm! "zyj'
b9928ef8632f patch 8.0.0724: the message for yanking doesn't indicate the register
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
27 call assert_equal('2 lines yanked into "z', v:statusmsg)
b9928ef8632f patch 8.0.0724: the message for yanking doesn't indicate the register
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
28
b9928ef8632f patch 8.0.0724: the message for yanking doesn't indicate the register
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
29 " Block-wise
b9928ef8632f patch 8.0.0724: the message for yanking doesn't indicate the register
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
30 exe "norm! \<C-V>y"
b9928ef8632f patch 8.0.0724: the message for yanking doesn't indicate the register
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
31 call assert_equal('block of 1 line yanked', v:statusmsg)
b9928ef8632f patch 8.0.0724: the message for yanking doesn't indicate the register
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
32 exe "norm! \<C-V>\"zy"
b9928ef8632f patch 8.0.0724: the message for yanking doesn't indicate the register
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
33 call assert_equal('block of 1 line yanked into "z', v:statusmsg)
b9928ef8632f patch 8.0.0724: the message for yanking doesn't indicate the register
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
34 exe "norm! \<C-V>jy"
b9928ef8632f patch 8.0.0724: the message for yanking doesn't indicate the register
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
35 call assert_equal('block of 2 lines yanked', v:statusmsg)
b9928ef8632f patch 8.0.0724: the message for yanking doesn't indicate the register
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
36 exe "norm! \<C-V>j\"zy"
b9928ef8632f patch 8.0.0724: the message for yanking doesn't indicate the register
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
37 call assert_equal('block of 2 lines yanked into "z', v:statusmsg)
b9928ef8632f patch 8.0.0724: the message for yanking doesn't indicate the register
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
38
b9928ef8632f patch 8.0.0724: the message for yanking doesn't indicate the register
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
39 bwipe!
b9928ef8632f patch 8.0.0724: the message for yanking doesn't indicate the register
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
40 endfunc
13855
536874138ecd patch 8.0.1799: no test for :registers command
Christian Brabandt <cb@256bit.org>
parents: 11682
diff changeset
41
536874138ecd patch 8.0.1799: no test for :registers command
Christian Brabandt <cb@256bit.org>
parents: 11682
diff changeset
42 func Test_display_registers()
536874138ecd patch 8.0.1799: no test for :registers command
Christian Brabandt <cb@256bit.org>
parents: 11682
diff changeset
43 e file1
536874138ecd patch 8.0.1799: no test for :registers command
Christian Brabandt <cb@256bit.org>
parents: 11682
diff changeset
44 e file2
536874138ecd patch 8.0.1799: no test for :registers command
Christian Brabandt <cb@256bit.org>
parents: 11682
diff changeset
45 call setline(1, ['foo', 'bar'])
536874138ecd patch 8.0.1799: no test for :registers command
Christian Brabandt <cb@256bit.org>
parents: 11682
diff changeset
46 /bar
536874138ecd patch 8.0.1799: no test for :registers command
Christian Brabandt <cb@256bit.org>
parents: 11682
diff changeset
47 exe 'norm! y2l"axx'
536874138ecd patch 8.0.1799: no test for :registers command
Christian Brabandt <cb@256bit.org>
parents: 11682
diff changeset
48 call feedkeys("i\<C-R>=2*4\n\<esc>")
536874138ecd patch 8.0.1799: no test for :registers command
Christian Brabandt <cb@256bit.org>
parents: 11682
diff changeset
49 call feedkeys(":ls\n", 'xt')
536874138ecd patch 8.0.1799: no test for :registers command
Christian Brabandt <cb@256bit.org>
parents: 11682
diff changeset
50
536874138ecd patch 8.0.1799: no test for :registers command
Christian Brabandt <cb@256bit.org>
parents: 11682
diff changeset
51 let a = execute('display')
536874138ecd patch 8.0.1799: no test for :registers command
Christian Brabandt <cb@256bit.org>
parents: 11682
diff changeset
52 let b = execute('registers')
536874138ecd patch 8.0.1799: no test for :registers command
Christian Brabandt <cb@256bit.org>
parents: 11682
diff changeset
53
536874138ecd patch 8.0.1799: no test for :registers command
Christian Brabandt <cb@256bit.org>
parents: 11682
diff changeset
54 call assert_equal(a, b)
18436
6ec1bfb4690b patch 8.1.2212: cannot see the selection type in :reg output
Bram Moolenaar <Bram@vim.org>
parents: 16784
diff changeset
55 call assert_match('^\nType Name Content\n'
6ec1bfb4690b patch 8.1.2212: cannot see the selection type in :reg output
Bram Moolenaar <Bram@vim.org>
parents: 16784
diff changeset
56 \ . ' c "" a\n'
6ec1bfb4690b patch 8.1.2212: cannot see the selection type in :reg output
Bram Moolenaar <Bram@vim.org>
parents: 16784
diff changeset
57 \ . ' c "0 ba\n'
6ec1bfb4690b patch 8.1.2212: cannot see the selection type in :reg output
Bram Moolenaar <Bram@vim.org>
parents: 16784
diff changeset
58 \ . ' c "a b\n'
13855
536874138ecd patch 8.0.1799: no test for :registers command
Christian Brabandt <cb@256bit.org>
parents: 11682
diff changeset
59 \ . '.*'
18436
6ec1bfb4690b patch 8.1.2212: cannot see the selection type in :reg output
Bram Moolenaar <Bram@vim.org>
parents: 16784
diff changeset
60 \ . ' c "- a\n'
13855
536874138ecd patch 8.0.1799: no test for :registers command
Christian Brabandt <cb@256bit.org>
parents: 11682
diff changeset
61 \ . '.*'
18436
6ec1bfb4690b patch 8.1.2212: cannot see the selection type in :reg output
Bram Moolenaar <Bram@vim.org>
parents: 16784
diff changeset
62 \ . ' c ": ls\n'
6ec1bfb4690b patch 8.1.2212: cannot see the selection type in :reg output
Bram Moolenaar <Bram@vim.org>
parents: 16784
diff changeset
63 \ . ' c "% file2\n'
6ec1bfb4690b patch 8.1.2212: cannot see the selection type in :reg output
Bram Moolenaar <Bram@vim.org>
parents: 16784
diff changeset
64 \ . ' c "# file1\n'
6ec1bfb4690b patch 8.1.2212: cannot see the selection type in :reg output
Bram Moolenaar <Bram@vim.org>
parents: 16784
diff changeset
65 \ . ' c "/ bar\n'
6ec1bfb4690b patch 8.1.2212: cannot see the selection type in :reg output
Bram Moolenaar <Bram@vim.org>
parents: 16784
diff changeset
66 \ . ' c "= 2\*4', a)
13855
536874138ecd patch 8.0.1799: no test for :registers command
Christian Brabandt <cb@256bit.org>
parents: 11682
diff changeset
67
536874138ecd patch 8.0.1799: no test for :registers command
Christian Brabandt <cb@256bit.org>
parents: 11682
diff changeset
68 let a = execute('registers a')
18436
6ec1bfb4690b patch 8.1.2212: cannot see the selection type in :reg output
Bram Moolenaar <Bram@vim.org>
parents: 16784
diff changeset
69 call assert_match('^\nType Name Content\n'
6ec1bfb4690b patch 8.1.2212: cannot see the selection type in :reg output
Bram Moolenaar <Bram@vim.org>
parents: 16784
diff changeset
70 \ . ' c "a b', a)
13855
536874138ecd patch 8.0.1799: no test for :registers command
Christian Brabandt <cb@256bit.org>
parents: 11682
diff changeset
71
536874138ecd patch 8.0.1799: no test for :registers command
Christian Brabandt <cb@256bit.org>
parents: 11682
diff changeset
72 let a = execute('registers :')
18436
6ec1bfb4690b patch 8.1.2212: cannot see the selection type in :reg output
Bram Moolenaar <Bram@vim.org>
parents: 16784
diff changeset
73 call assert_match('^\nType Name Content\n'
6ec1bfb4690b patch 8.1.2212: cannot see the selection type in :reg output
Bram Moolenaar <Bram@vim.org>
parents: 16784
diff changeset
74 \ . ' c ": ls', a)
13855
536874138ecd patch 8.0.1799: no test for :registers command
Christian Brabandt <cb@256bit.org>
parents: 11682
diff changeset
75
536874138ecd patch 8.0.1799: no test for :registers command
Christian Brabandt <cb@256bit.org>
parents: 11682
diff changeset
76 bwipe!
536874138ecd patch 8.0.1799: no test for :registers command
Christian Brabandt <cb@256bit.org>
parents: 11682
diff changeset
77 endfunc
15987
29de75f53b1a patch 8.1.0999: use register one too often and not properly tested
Bram Moolenaar <Bram@vim.org>
parents: 13855
diff changeset
78
29de75f53b1a patch 8.1.0999: use register one too often and not properly tested
Bram Moolenaar <Bram@vim.org>
parents: 13855
diff changeset
79 func Test_register_one()
29de75f53b1a patch 8.1.0999: use register one too often and not properly tested
Bram Moolenaar <Bram@vim.org>
parents: 13855
diff changeset
80 " delete a line goes into register one
29de75f53b1a patch 8.1.0999: use register one too often and not properly tested
Bram Moolenaar <Bram@vim.org>
parents: 13855
diff changeset
81 new
29de75f53b1a patch 8.1.0999: use register one too often and not properly tested
Bram Moolenaar <Bram@vim.org>
parents: 13855
diff changeset
82 call setline(1, "one")
29de75f53b1a patch 8.1.0999: use register one too often and not properly tested
Bram Moolenaar <Bram@vim.org>
parents: 13855
diff changeset
83 normal dd
29de75f53b1a patch 8.1.0999: use register one too often and not properly tested
Bram Moolenaar <Bram@vim.org>
parents: 13855
diff changeset
84 call assert_equal("one\n", @1)
29de75f53b1a patch 8.1.0999: use register one too often and not properly tested
Bram Moolenaar <Bram@vim.org>
parents: 13855
diff changeset
85
29de75f53b1a patch 8.1.0999: use register one too often and not properly tested
Bram Moolenaar <Bram@vim.org>
parents: 13855
diff changeset
86 " delete a word does not change register one, does change "-
29de75f53b1a patch 8.1.0999: use register one too often and not properly tested
Bram Moolenaar <Bram@vim.org>
parents: 13855
diff changeset
87 call setline(1, "two")
29de75f53b1a patch 8.1.0999: use register one too often and not properly tested
Bram Moolenaar <Bram@vim.org>
parents: 13855
diff changeset
88 normal de
29de75f53b1a patch 8.1.0999: use register one too often and not properly tested
Bram Moolenaar <Bram@vim.org>
parents: 13855
diff changeset
89 call assert_equal("one\n", @1)
29de75f53b1a patch 8.1.0999: use register one too often and not properly tested
Bram Moolenaar <Bram@vim.org>
parents: 13855
diff changeset
90 call assert_equal("two", @-)
29de75f53b1a patch 8.1.0999: use register one too often and not properly tested
Bram Moolenaar <Bram@vim.org>
parents: 13855
diff changeset
91
29de75f53b1a patch 8.1.0999: use register one too often and not properly tested
Bram Moolenaar <Bram@vim.org>
parents: 13855
diff changeset
92 " delete a word with a register does not change register one
29de75f53b1a patch 8.1.0999: use register one too often and not properly tested
Bram Moolenaar <Bram@vim.org>
parents: 13855
diff changeset
93 call setline(1, "three")
29de75f53b1a patch 8.1.0999: use register one too often and not properly tested
Bram Moolenaar <Bram@vim.org>
parents: 13855
diff changeset
94 normal "ade
29de75f53b1a patch 8.1.0999: use register one too often and not properly tested
Bram Moolenaar <Bram@vim.org>
parents: 13855
diff changeset
95 call assert_equal("three", @a)
29de75f53b1a patch 8.1.0999: use register one too often and not properly tested
Bram Moolenaar <Bram@vim.org>
parents: 13855
diff changeset
96 call assert_equal("one\n", @1)
29de75f53b1a patch 8.1.0999: use register one too often and not properly tested
Bram Moolenaar <Bram@vim.org>
parents: 13855
diff changeset
97
29de75f53b1a patch 8.1.0999: use register one too often and not properly tested
Bram Moolenaar <Bram@vim.org>
parents: 13855
diff changeset
98 " delete a word with register DOES change register one with one of a list of
29de75f53b1a patch 8.1.0999: use register one too often and not properly tested
Bram Moolenaar <Bram@vim.org>
parents: 13855
diff changeset
99 " operators
29de75f53b1a patch 8.1.0999: use register one too often and not properly tested
Bram Moolenaar <Bram@vim.org>
parents: 13855
diff changeset
100 " %
29de75f53b1a patch 8.1.0999: use register one too often and not properly tested
Bram Moolenaar <Bram@vim.org>
parents: 13855
diff changeset
101 call setline(1, ["(12)3"])
29de75f53b1a patch 8.1.0999: use register one too often and not properly tested
Bram Moolenaar <Bram@vim.org>
parents: 13855
diff changeset
102 normal "ad%
29de75f53b1a patch 8.1.0999: use register one too often and not properly tested
Bram Moolenaar <Bram@vim.org>
parents: 13855
diff changeset
103 call assert_equal("(12)", @a)
29de75f53b1a patch 8.1.0999: use register one too often and not properly tested
Bram Moolenaar <Bram@vim.org>
parents: 13855
diff changeset
104 call assert_equal("(12)", @1)
29de75f53b1a patch 8.1.0999: use register one too often and not properly tested
Bram Moolenaar <Bram@vim.org>
parents: 13855
diff changeset
105
29de75f53b1a patch 8.1.0999: use register one too often and not properly tested
Bram Moolenaar <Bram@vim.org>
parents: 13855
diff changeset
106 " (
29de75f53b1a patch 8.1.0999: use register one too often and not properly tested
Bram Moolenaar <Bram@vim.org>
parents: 13855
diff changeset
107 call setline(1, ["first second"])
29de75f53b1a patch 8.1.0999: use register one too often and not properly tested
Bram Moolenaar <Bram@vim.org>
parents: 13855
diff changeset
108 normal $"ad(
29de75f53b1a patch 8.1.0999: use register one too often and not properly tested
Bram Moolenaar <Bram@vim.org>
parents: 13855
diff changeset
109 call assert_equal("first secon", @a)
29de75f53b1a patch 8.1.0999: use register one too often and not properly tested
Bram Moolenaar <Bram@vim.org>
parents: 13855
diff changeset
110 call assert_equal("first secon", @1)
29de75f53b1a patch 8.1.0999: use register one too often and not properly tested
Bram Moolenaar <Bram@vim.org>
parents: 13855
diff changeset
111
29de75f53b1a patch 8.1.0999: use register one too often and not properly tested
Bram Moolenaar <Bram@vim.org>
parents: 13855
diff changeset
112 " )
29de75f53b1a patch 8.1.0999: use register one too often and not properly tested
Bram Moolenaar <Bram@vim.org>
parents: 13855
diff changeset
113 call setline(1, ["First Second."])
29de75f53b1a patch 8.1.0999: use register one too often and not properly tested
Bram Moolenaar <Bram@vim.org>
parents: 13855
diff changeset
114 normal gg0"ad)
29de75f53b1a patch 8.1.0999: use register one too often and not properly tested
Bram Moolenaar <Bram@vim.org>
parents: 13855
diff changeset
115 call assert_equal("First Second.", @a)
29de75f53b1a patch 8.1.0999: use register one too often and not properly tested
Bram Moolenaar <Bram@vim.org>
parents: 13855
diff changeset
116 call assert_equal("First Second.", @1)
29de75f53b1a patch 8.1.0999: use register one too often and not properly tested
Bram Moolenaar <Bram@vim.org>
parents: 13855
diff changeset
117
29de75f53b1a patch 8.1.0999: use register one too often and not properly tested
Bram Moolenaar <Bram@vim.org>
parents: 13855
diff changeset
118 " `
29de75f53b1a patch 8.1.0999: use register one too often and not properly tested
Bram Moolenaar <Bram@vim.org>
parents: 13855
diff changeset
119 call setline(1, ["start here."])
29de75f53b1a patch 8.1.0999: use register one too often and not properly tested
Bram Moolenaar <Bram@vim.org>
parents: 13855
diff changeset
120 normal gg0fhmx0"ad`x
29de75f53b1a patch 8.1.0999: use register one too often and not properly tested
Bram Moolenaar <Bram@vim.org>
parents: 13855
diff changeset
121 call assert_equal("start ", @a)
29de75f53b1a patch 8.1.0999: use register one too often and not properly tested
Bram Moolenaar <Bram@vim.org>
parents: 13855
diff changeset
122 call assert_equal("start ", @1)
29de75f53b1a patch 8.1.0999: use register one too often and not properly tested
Bram Moolenaar <Bram@vim.org>
parents: 13855
diff changeset
123
29de75f53b1a patch 8.1.0999: use register one too often and not properly tested
Bram Moolenaar <Bram@vim.org>
parents: 13855
diff changeset
124 " /
29de75f53b1a patch 8.1.0999: use register one too often and not properly tested
Bram Moolenaar <Bram@vim.org>
parents: 13855
diff changeset
125 call setline(1, ["searchX"])
29de75f53b1a patch 8.1.0999: use register one too often and not properly tested
Bram Moolenaar <Bram@vim.org>
parents: 13855
diff changeset
126 exe "normal gg0\"ad/X\<CR>"
29de75f53b1a patch 8.1.0999: use register one too often and not properly tested
Bram Moolenaar <Bram@vim.org>
parents: 13855
diff changeset
127 call assert_equal("search", @a)
29de75f53b1a patch 8.1.0999: use register one too often and not properly tested
Bram Moolenaar <Bram@vim.org>
parents: 13855
diff changeset
128 call assert_equal("search", @1)
29de75f53b1a patch 8.1.0999: use register one too often and not properly tested
Bram Moolenaar <Bram@vim.org>
parents: 13855
diff changeset
129
29de75f53b1a patch 8.1.0999: use register one too often and not properly tested
Bram Moolenaar <Bram@vim.org>
parents: 13855
diff changeset
130 " ?
29de75f53b1a patch 8.1.0999: use register one too often and not properly tested
Bram Moolenaar <Bram@vim.org>
parents: 13855
diff changeset
131 call setline(1, ["Ysearch"])
29de75f53b1a patch 8.1.0999: use register one too often and not properly tested
Bram Moolenaar <Bram@vim.org>
parents: 13855
diff changeset
132 exe "normal gg$\"ad?Y\<CR>"
29de75f53b1a patch 8.1.0999: use register one too often and not properly tested
Bram Moolenaar <Bram@vim.org>
parents: 13855
diff changeset
133 call assert_equal("Ysearc", @a)
29de75f53b1a patch 8.1.0999: use register one too often and not properly tested
Bram Moolenaar <Bram@vim.org>
parents: 13855
diff changeset
134 call assert_equal("Ysearc", @1)
29de75f53b1a patch 8.1.0999: use register one too often and not properly tested
Bram Moolenaar <Bram@vim.org>
parents: 13855
diff changeset
135
29de75f53b1a patch 8.1.0999: use register one too often and not properly tested
Bram Moolenaar <Bram@vim.org>
parents: 13855
diff changeset
136 " n
29de75f53b1a patch 8.1.0999: use register one too often and not properly tested
Bram Moolenaar <Bram@vim.org>
parents: 13855
diff changeset
137 call setline(1, ["Ynext"])
29de75f53b1a patch 8.1.0999: use register one too often and not properly tested
Bram Moolenaar <Bram@vim.org>
parents: 13855
diff changeset
138 normal gg$"adn
29de75f53b1a patch 8.1.0999: use register one too often and not properly tested
Bram Moolenaar <Bram@vim.org>
parents: 13855
diff changeset
139 call assert_equal("Ynex", @a)
29de75f53b1a patch 8.1.0999: use register one too often and not properly tested
Bram Moolenaar <Bram@vim.org>
parents: 13855
diff changeset
140 call assert_equal("Ynex", @1)
29de75f53b1a patch 8.1.0999: use register one too often and not properly tested
Bram Moolenaar <Bram@vim.org>
parents: 13855
diff changeset
141
29de75f53b1a patch 8.1.0999: use register one too often and not properly tested
Bram Moolenaar <Bram@vim.org>
parents: 13855
diff changeset
142 " N
29de75f53b1a patch 8.1.0999: use register one too often and not properly tested
Bram Moolenaar <Bram@vim.org>
parents: 13855
diff changeset
143 call setline(1, ["prevY"])
29de75f53b1a patch 8.1.0999: use register one too often and not properly tested
Bram Moolenaar <Bram@vim.org>
parents: 13855
diff changeset
144 normal gg0"adN
29de75f53b1a patch 8.1.0999: use register one too often and not properly tested
Bram Moolenaar <Bram@vim.org>
parents: 13855
diff changeset
145 call assert_equal("prev", @a)
29de75f53b1a patch 8.1.0999: use register one too often and not properly tested
Bram Moolenaar <Bram@vim.org>
parents: 13855
diff changeset
146 call assert_equal("prev", @1)
29de75f53b1a patch 8.1.0999: use register one too often and not properly tested
Bram Moolenaar <Bram@vim.org>
parents: 13855
diff changeset
147
29de75f53b1a patch 8.1.0999: use register one too often and not properly tested
Bram Moolenaar <Bram@vim.org>
parents: 13855
diff changeset
148 " }
29de75f53b1a patch 8.1.0999: use register one too often and not properly tested
Bram Moolenaar <Bram@vim.org>
parents: 13855
diff changeset
149 call setline(1, ["one", ""])
29de75f53b1a patch 8.1.0999: use register one too often and not properly tested
Bram Moolenaar <Bram@vim.org>
parents: 13855
diff changeset
150 normal gg0"ad}
29de75f53b1a patch 8.1.0999: use register one too often and not properly tested
Bram Moolenaar <Bram@vim.org>
parents: 13855
diff changeset
151 call assert_equal("one\n", @a)
29de75f53b1a patch 8.1.0999: use register one too often and not properly tested
Bram Moolenaar <Bram@vim.org>
parents: 13855
diff changeset
152 call assert_equal("one\n", @1)
29de75f53b1a patch 8.1.0999: use register one too often and not properly tested
Bram Moolenaar <Bram@vim.org>
parents: 13855
diff changeset
153
29de75f53b1a patch 8.1.0999: use register one too often and not properly tested
Bram Moolenaar <Bram@vim.org>
parents: 13855
diff changeset
154 " {
29de75f53b1a patch 8.1.0999: use register one too often and not properly tested
Bram Moolenaar <Bram@vim.org>
parents: 13855
diff changeset
155 call setline(1, ["", "two"])
29de75f53b1a patch 8.1.0999: use register one too often and not properly tested
Bram Moolenaar <Bram@vim.org>
parents: 13855
diff changeset
156 normal 2G$"ad{
29de75f53b1a patch 8.1.0999: use register one too often and not properly tested
Bram Moolenaar <Bram@vim.org>
parents: 13855
diff changeset
157 call assert_equal("\ntw", @a)
29de75f53b1a patch 8.1.0999: use register one too often and not properly tested
Bram Moolenaar <Bram@vim.org>
parents: 13855
diff changeset
158 call assert_equal("\ntw", @1)
29de75f53b1a patch 8.1.0999: use register one too often and not properly tested
Bram Moolenaar <Bram@vim.org>
parents: 13855
diff changeset
159
29de75f53b1a patch 8.1.0999: use register one too often and not properly tested
Bram Moolenaar <Bram@vim.org>
parents: 13855
diff changeset
160 bwipe!
29de75f53b1a patch 8.1.0999: use register one too often and not properly tested
Bram Moolenaar <Bram@vim.org>
parents: 13855
diff changeset
161 endfunc
15995
e7030c0c79cd patch 8.1.1003: playing back recorded key sequence mistakes key code
Bram Moolenaar <Bram@vim.org>
parents: 15987
diff changeset
162
e7030c0c79cd patch 8.1.1003: playing back recorded key sequence mistakes key code
Bram Moolenaar <Bram@vim.org>
parents: 15987
diff changeset
163 " Check that replaying a typed sequence does not use an Esc and following
e7030c0c79cd patch 8.1.1003: playing back recorded key sequence mistakes key code
Bram Moolenaar <Bram@vim.org>
parents: 15987
diff changeset
164 " characters as an escape sequence.
e7030c0c79cd patch 8.1.1003: playing back recorded key sequence mistakes key code
Bram Moolenaar <Bram@vim.org>
parents: 15987
diff changeset
165 func Test_recording_esc_sequence()
e7030c0c79cd patch 8.1.1003: playing back recorded key sequence mistakes key code
Bram Moolenaar <Bram@vim.org>
parents: 15987
diff changeset
166 new
15999
f4c282082ec8 patch 8.1.1005: test fails because t_F2 is not set
Bram Moolenaar <Bram@vim.org>
parents: 15995
diff changeset
167 try
f4c282082ec8 patch 8.1.1005: test fails because t_F2 is not set
Bram Moolenaar <Bram@vim.org>
parents: 15995
diff changeset
168 let save_F2 = &t_F2
f4c282082ec8 patch 8.1.1005: test fails because t_F2 is not set
Bram Moolenaar <Bram@vim.org>
parents: 15995
diff changeset
169 catch
f4c282082ec8 patch 8.1.1005: test fails because t_F2 is not set
Bram Moolenaar <Bram@vim.org>
parents: 15995
diff changeset
170 endtry
15995
e7030c0c79cd patch 8.1.1003: playing back recorded key sequence mistakes key code
Bram Moolenaar <Bram@vim.org>
parents: 15987
diff changeset
171 let t_F2 = "\<Esc>OQ"
e7030c0c79cd patch 8.1.1003: playing back recorded key sequence mistakes key code
Bram Moolenaar <Bram@vim.org>
parents: 15987
diff changeset
172 call feedkeys("qqiTest\<Esc>", "xt")
e7030c0c79cd patch 8.1.1003: playing back recorded key sequence mistakes key code
Bram Moolenaar <Bram@vim.org>
parents: 15987
diff changeset
173 call feedkeys("OQuirk\<Esc>q", "xt")
e7030c0c79cd patch 8.1.1003: playing back recorded key sequence mistakes key code
Bram Moolenaar <Bram@vim.org>
parents: 15987
diff changeset
174 call feedkeys("Go\<Esc>@q", "xt")
e7030c0c79cd patch 8.1.1003: playing back recorded key sequence mistakes key code
Bram Moolenaar <Bram@vim.org>
parents: 15987
diff changeset
175 call assert_equal(['Quirk', 'Test', 'Quirk', 'Test'], getline(1, 4))
e7030c0c79cd patch 8.1.1003: playing back recorded key sequence mistakes key code
Bram Moolenaar <Bram@vim.org>
parents: 15987
diff changeset
176 bwipe!
15999
f4c282082ec8 patch 8.1.1005: test fails because t_F2 is not set
Bram Moolenaar <Bram@vim.org>
parents: 15995
diff changeset
177 if exists('save_F2')
16784
62d84ef82f96 patch 8.1.1394: not restoring t_F2 in registers test
Bram Moolenaar <Bram@vim.org>
parents: 16376
diff changeset
178 let &t_F2 = save_F2
16376
3b5d401a58ce patch 8.1.1193: typos and small problems in test files
Bram Moolenaar <Bram@vim.org>
parents: 15999
diff changeset
179 else
3b5d401a58ce patch 8.1.1193: typos and small problems in test files
Bram Moolenaar <Bram@vim.org>
parents: 15999
diff changeset
180 set t_F2=
15999
f4c282082ec8 patch 8.1.1005: test fails because t_F2 is not set
Bram Moolenaar <Bram@vim.org>
parents: 15995
diff changeset
181 endif
15995
e7030c0c79cd patch 8.1.1003: playing back recorded key sequence mistakes key code
Bram Moolenaar <Bram@vim.org>
parents: 15987
diff changeset
182 endfunc
18755
a0be066d0b48 patch 8.1.2367: registers are not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 18436
diff changeset
183
a0be066d0b48 patch 8.1.2367: registers are not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 18436
diff changeset
184 " Test for executing the last used register (@)
a0be066d0b48 patch 8.1.2367: registers are not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 18436
diff changeset
185 func Test_last_used_exec_reg()
a0be066d0b48 patch 8.1.2367: registers are not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 18436
diff changeset
186 " Test for the @: command
a0be066d0b48 patch 8.1.2367: registers are not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 18436
diff changeset
187 let a = ''
a0be066d0b48 patch 8.1.2367: registers are not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 18436
diff changeset
188 call feedkeys(":let a ..= 'Vim'\<CR>", 'xt')
a0be066d0b48 patch 8.1.2367: registers are not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 18436
diff changeset
189 normal @:
a0be066d0b48 patch 8.1.2367: registers are not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 18436
diff changeset
190 call assert_equal('VimVim', a)
a0be066d0b48 patch 8.1.2367: registers are not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 18436
diff changeset
191
a0be066d0b48 patch 8.1.2367: registers are not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 18436
diff changeset
192 " Test for the @= command
a0be066d0b48 patch 8.1.2367: registers are not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 18436
diff changeset
193 let x = ''
a0be066d0b48 patch 8.1.2367: registers are not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 18436
diff changeset
194 let a = ":let x ..= 'Vim'\<CR>"
a0be066d0b48 patch 8.1.2367: registers are not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 18436
diff changeset
195 exe "normal @=a\<CR>"
a0be066d0b48 patch 8.1.2367: registers are not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 18436
diff changeset
196 normal @@
a0be066d0b48 patch 8.1.2367: registers are not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 18436
diff changeset
197 call assert_equal('VimVim', x)
a0be066d0b48 patch 8.1.2367: registers are not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 18436
diff changeset
198
a0be066d0b48 patch 8.1.2367: registers are not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 18436
diff changeset
199 " Test for the @. command
a0be066d0b48 patch 8.1.2367: registers are not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 18436
diff changeset
200 let a = ''
a0be066d0b48 patch 8.1.2367: registers are not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 18436
diff changeset
201 call feedkeys("i:let a ..= 'Edit'\<CR>", 'xt')
a0be066d0b48 patch 8.1.2367: registers are not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 18436
diff changeset
202 normal @.
a0be066d0b48 patch 8.1.2367: registers are not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 18436
diff changeset
203 normal @@
a0be066d0b48 patch 8.1.2367: registers are not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 18436
diff changeset
204 call assert_equal('EditEdit', a)
a0be066d0b48 patch 8.1.2367: registers are not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 18436
diff changeset
205
a0be066d0b48 patch 8.1.2367: registers are not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 18436
diff changeset
206 enew!
a0be066d0b48 patch 8.1.2367: registers are not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 18436
diff changeset
207 endfunc
a0be066d0b48 patch 8.1.2367: registers are not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 18436
diff changeset
208
a0be066d0b48 patch 8.1.2367: registers are not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 18436
diff changeset
209 func Test_get_register()
a0be066d0b48 patch 8.1.2367: registers are not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 18436
diff changeset
210 enew
a0be066d0b48 patch 8.1.2367: registers are not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 18436
diff changeset
211 edit Xfile1
a0be066d0b48 patch 8.1.2367: registers are not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 18436
diff changeset
212 edit Xfile2
a0be066d0b48 patch 8.1.2367: registers are not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 18436
diff changeset
213 call assert_equal('Xfile2', getreg('%'))
a0be066d0b48 patch 8.1.2367: registers are not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 18436
diff changeset
214 call assert_equal('Xfile1', getreg('#'))
a0be066d0b48 patch 8.1.2367: registers are not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 18436
diff changeset
215
a0be066d0b48 patch 8.1.2367: registers are not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 18436
diff changeset
216 call feedkeys("iTwo\<Esc>", 'xt')
a0be066d0b48 patch 8.1.2367: registers are not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 18436
diff changeset
217 call assert_equal('Two', getreg('.'))
a0be066d0b48 patch 8.1.2367: registers are not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 18436
diff changeset
218 call assert_equal('', getreg('_'))
a0be066d0b48 patch 8.1.2367: registers are not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 18436
diff changeset
219 call assert_beeps('normal ":yy')
a0be066d0b48 patch 8.1.2367: registers are not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 18436
diff changeset
220 call assert_beeps('normal "%yy')
a0be066d0b48 patch 8.1.2367: registers are not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 18436
diff changeset
221 call assert_beeps('normal ".yy')
a0be066d0b48 patch 8.1.2367: registers are not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 18436
diff changeset
222
a0be066d0b48 patch 8.1.2367: registers are not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 18436
diff changeset
223 call assert_equal('', getreg("\<C-F>"))
a0be066d0b48 patch 8.1.2367: registers are not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 18436
diff changeset
224 call assert_equal('', getreg("\<C-W>"))
a0be066d0b48 patch 8.1.2367: registers are not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 18436
diff changeset
225 call assert_equal('', getreg("\<C-L>"))
a0be066d0b48 patch 8.1.2367: registers are not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 18436
diff changeset
226
a0be066d0b48 patch 8.1.2367: registers are not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 18436
diff changeset
227 call assert_equal('', getregtype('!'))
a0be066d0b48 patch 8.1.2367: registers are not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 18436
diff changeset
228
a0be066d0b48 patch 8.1.2367: registers are not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 18436
diff changeset
229 enew!
a0be066d0b48 patch 8.1.2367: registers are not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 18436
diff changeset
230 endfunc
a0be066d0b48 patch 8.1.2367: registers are not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 18436
diff changeset
231
a0be066d0b48 patch 8.1.2367: registers are not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 18436
diff changeset
232 func Test_set_register()
a0be066d0b48 patch 8.1.2367: registers are not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 18436
diff changeset
233 call assert_fails("call setreg('#', 200)", 'E86:')
a0be066d0b48 patch 8.1.2367: registers are not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 18436
diff changeset
234
a0be066d0b48 patch 8.1.2367: registers are not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 18436
diff changeset
235 edit Xfile_alt_1
a0be066d0b48 patch 8.1.2367: registers are not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 18436
diff changeset
236 let b1 = bufnr('')
a0be066d0b48 patch 8.1.2367: registers are not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 18436
diff changeset
237 edit Xfile_alt_2
a0be066d0b48 patch 8.1.2367: registers are not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 18436
diff changeset
238 let b2 = bufnr('')
a0be066d0b48 patch 8.1.2367: registers are not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 18436
diff changeset
239 edit Xfile_alt_3
a0be066d0b48 patch 8.1.2367: registers are not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 18436
diff changeset
240 let b3 = bufnr('')
a0be066d0b48 patch 8.1.2367: registers are not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 18436
diff changeset
241 call setreg('#', 'alt_1')
a0be066d0b48 patch 8.1.2367: registers are not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 18436
diff changeset
242 call assert_equal('Xfile_alt_1', getreg('#'))
a0be066d0b48 patch 8.1.2367: registers are not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 18436
diff changeset
243 call setreg('#', b2)
a0be066d0b48 patch 8.1.2367: registers are not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 18436
diff changeset
244 call assert_equal('Xfile_alt_2', getreg('#'))
a0be066d0b48 patch 8.1.2367: registers are not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 18436
diff changeset
245
a0be066d0b48 patch 8.1.2367: registers are not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 18436
diff changeset
246 let ab = 'regwrite'
a0be066d0b48 patch 8.1.2367: registers are not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 18436
diff changeset
247 call setreg('=', '')
a0be066d0b48 patch 8.1.2367: registers are not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 18436
diff changeset
248 call setreg('=', 'a', 'a')
a0be066d0b48 patch 8.1.2367: registers are not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 18436
diff changeset
249 call setreg('=', 'b', 'a')
a0be066d0b48 patch 8.1.2367: registers are not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 18436
diff changeset
250 call assert_equal('regwrite', getreg('='))
a0be066d0b48 patch 8.1.2367: registers are not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 18436
diff changeset
251
a0be066d0b48 patch 8.1.2367: registers are not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 18436
diff changeset
252 enew!
a0be066d0b48 patch 8.1.2367: registers are not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 18436
diff changeset
253 endfunc
a0be066d0b48 patch 8.1.2367: registers are not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 18436
diff changeset
254
a0be066d0b48 patch 8.1.2367: registers are not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 18436
diff changeset
255 " vim: shiftwidth=2 sts=2 expandtab