comparison src/testdir/test_spellfile.vim @ 17682:3dbff5d37520 v8.1.1838

patch 8.1.1838: there is :spellwrong and :spellgood but not :spellrare commit https://github.com/vim/vim/commit/08cc374dabd2a02785129fa1c0100f7745c244ad Author: Bram Moolenaar <Bram@vim.org> Date: Sun Aug 11 22:51:14 2019 +0200 patch 8.1.1838: there is :spellwrong and :spellgood but not :spellrare Problem: There is :spellwrong and :spellgood but not :spellrare. Solution: Add :spellrare. (Martin Tournoij, closes https://github.com/vim/vim/issues/4291)
author Bram Moolenaar <Bram@vim.org>
date Sun, 11 Aug 2019 23:00:07 +0200
parents
children 08940efa6b4e
comparison
equal deleted inserted replaced
17681:fbdef42903ae 17682:3dbff5d37520
1 " Test for commands that operate on the spellfile.
2
3 source shared.vim
4 source check.vim
5
6 CheckFeature spell
7 CheckFeature syntax
8
9 func Test_spell_normal()
10 new
11 call append(0, ['1 good', '2 goood', '3 goood'])
12 set spell spellfile=./Xspellfile.add spelllang=en
13 let oldlang=v:lang
14 lang C
15
16 " Test for zg
17 1
18 norm! ]s
19 call assert_equal('2 goood', getline('.'))
20 norm! zg
21 1
22 let a=execute('unsilent :norm! ]s')
23 call assert_equal('1 good', getline('.'))
24 call assert_equal('search hit BOTTOM, continuing at TOP', a[1:])
25 let cnt=readfile('./Xspellfile.add')
26 call assert_equal('goood', cnt[0])
27
28 " Test for zw
29 2
30 norm! $zw
31 1
32 norm! ]s
33 call assert_equal('2 goood', getline('.'))
34 let cnt=readfile('./Xspellfile.add')
35 call assert_equal('#oood', cnt[0])
36 call assert_equal('goood/!', cnt[1])
37
38 " Test for :spellrare
39 spellrare rare
40 let cnt=readfile('./Xspellfile.add')
41 call assert_equal(['#oood', 'goood/!', 'rare/?'], cnt)
42
43 " Make sure :spellundo works for rare words.
44 spellundo rare
45 let cnt=readfile('./Xspellfile.add')
46 call assert_equal(['#oood', 'goood/!', '#are/?'], cnt)
47
48 " Test for zg in visual mode
49 let a=execute('unsilent :norm! V$zg')
50 call assert_equal("Word '2 goood' added to ./Xspellfile.add", a[1:])
51 1
52 norm! ]s
53 call assert_equal('3 goood', getline('.'))
54 let cnt=readfile('./Xspellfile.add')
55 call assert_equal('2 goood', cnt[3])
56 " Remove "2 good" from spellfile
57 2
58 let a=execute('unsilent norm! V$zw')
59 call assert_equal("Word '2 goood' added to ./Xspellfile.add", a[1:])
60 let cnt=readfile('./Xspellfile.add')
61 call assert_equal('2 goood/!', cnt[4])
62
63 " Test for zG
64 let a=execute('unsilent norm! V$zG')
65 call assert_match("Word '2 goood' added to .*", a)
66 let fname=matchstr(a, 'to\s\+\zs\f\+$')
67 let cnt=readfile(fname)
68 call assert_equal('2 goood', cnt[0])
69
70 " Test for zW
71 let a=execute('unsilent norm! V$zW')
72 call assert_match("Word '2 goood' added to .*", a)
73 let cnt=readfile(fname)
74 call assert_equal('# goood', cnt[0])
75 call assert_equal('2 goood/!', cnt[1])
76
77 " Test for zuW
78 let a=execute('unsilent norm! V$zuW')
79 call assert_match("Word '2 goood' removed from .*", a)
80 let cnt=readfile(fname)
81 call assert_equal('# goood', cnt[0])
82 call assert_equal('# goood/!', cnt[1])
83
84 " Test for zuG
85 let a=execute('unsilent norm! $zG')
86 call assert_match("Word 'goood' added to .*", a)
87 let cnt=readfile(fname)
88 call assert_equal('# goood', cnt[0])
89 call assert_equal('# goood/!', cnt[1])
90 call assert_equal('goood', cnt[2])
91 let a=execute('unsilent norm! $zuG')
92 let cnt=readfile(fname)
93 call assert_match("Word 'goood' removed from .*", a)
94 call assert_equal('# goood', cnt[0])
95 call assert_equal('# goood/!', cnt[1])
96 call assert_equal('#oood', cnt[2])
97 " word not found in wordlist
98 let a=execute('unsilent norm! V$zuG')
99 let cnt=readfile(fname)
100 call assert_match("", a)
101 call assert_equal('# goood', cnt[0])
102 call assert_equal('# goood/!', cnt[1])
103 call assert_equal('#oood', cnt[2])
104
105 " Test for zug
106 call delete('./Xspellfile.add')
107 2
108 let a=execute('unsilent norm! $zg')
109 let cnt=readfile('./Xspellfile.add')
110 call assert_equal('goood', cnt[0])
111 let a=execute('unsilent norm! $zug')
112 call assert_match("Word 'goood' removed from \./Xspellfile.add", a)
113 let cnt=readfile('./Xspellfile.add')
114 call assert_equal('#oood', cnt[0])
115 " word not in wordlist
116 let a=execute('unsilent norm! V$zug')
117 call assert_match('', a)
118 let cnt=readfile('./Xspellfile.add')
119 call assert_equal('#oood', cnt[0])
120
121 " Test for zuw
122 call delete('./Xspellfile.add')
123 2
124 let a=execute('unsilent norm! Vzw')
125 let cnt=readfile('./Xspellfile.add')
126 call assert_equal('2 goood/!', cnt[0])
127 let a=execute('unsilent norm! Vzuw')
128 call assert_match("Word '2 goood' removed from \./Xspellfile.add", a)
129 let cnt=readfile('./Xspellfile.add')
130 call assert_equal('# goood/!', cnt[0])
131 " word not in wordlist
132 let a=execute('unsilent norm! $zug')
133 call assert_match('', a)
134 let cnt=readfile('./Xspellfile.add')
135 call assert_equal('# goood/!', cnt[0])
136
137 " add second entry to spellfile setting
138 set spellfile=./Xspellfile.add,./Xspellfile2.add
139 call delete('./Xspellfile.add')
140 2
141 let a=execute('unsilent norm! $2zg')
142 let cnt=readfile('./Xspellfile2.add')
143 call assert_match("Word 'goood' added to ./Xspellfile2.add", a)
144 call assert_equal('goood', cnt[0])
145
146 " Test for :spellgood!
147 let temp = execute(':spe!0/0')
148 call assert_match('Invalid region', temp)
149 let spellfile = matchstr(temp, 'Invalid region nr in \zs.*\ze line \d: 0')
150 call assert_equal(['# goood', '# goood/!', '#oood', '0/0'], readfile(spellfile))
151
152 " Test for :spellrare!
153 :spellrare! raare
154 call assert_equal(['# goood', '# goood/!', '#oood', '0/0', 'raare/?'], readfile(spellfile))
155 call delete(spellfile)
156
157 " clean up
158 exe "lang" oldlang
159 call delete("./Xspellfile.add")
160 call delete("./Xspellfile2.add")
161 call delete("./Xspellfile.add.spl")
162 call delete("./Xspellfile2.add.spl")
163
164 " zux -> no-op
165 2
166 norm! $zux
167 call assert_equal([], glob('Xspellfile.add',0,1))
168 call assert_equal([], glob('Xspellfile2.add',0,1))
169
170 set spellfile=
171 bw!
172 endfunc