blob: 0ebf33adfec3ca9ee542e714b659befe3c0b5380 [file] [log] [blame]
Bram Moolenaard3f78dc2017-02-25 14:21:10 +01001" Test spell checking
Bram Moolenaar5bcc5a12019-08-06 22:48:02 +02002" Note: this file uses latin1 encoding, but is used with utf-8 encoding.
Bram Moolenaard3f78dc2017-02-25 14:21:10 +01003
Bram Moolenaarb46fecd2019-06-15 17:58:09 +02004source check.vim
5CheckFeature spell
Bram Moolenaard3f78dc2017-02-25 14:21:10 +01006
Bram Moolenaar7751d1d2019-10-18 20:37:08 +02007source screendump.vim
8
Bram Moolenaar1a0f2002017-07-28 15:38:10 +02009func TearDown()
10 set nospell
11 call delete('Xtest.aff')
12 call delete('Xtest.dic')
13 call delete('Xtest.latin1.add')
14 call delete('Xtest.latin1.add.spl')
15 call delete('Xtest.latin1.spl')
16 call delete('Xtest.latin1.sug')
17endfunc
18
Bram Moolenaard3f78dc2017-02-25 14:21:10 +010019func Test_wrap_search()
20 new
21 call setline(1, ['The', '', 'A plong line with two zpelling mistakes', '', 'End'])
22 set spell wrapscan
23 normal ]s
24 call assert_equal('plong', expand('<cword>'))
25 normal ]s
26 call assert_equal('zpelling', expand('<cword>'))
27 normal ]s
28 call assert_equal('plong', expand('<cword>'))
29 bwipe!
30 set nospell
31endfunc
Bram Moolenaar5b276aa2017-04-22 23:49:52 +020032
Bram Moolenaarb73fa622017-12-21 20:27:47 +010033func Test_curswant()
34 new
35 call setline(1, ['Another plong line', 'abcdefghijklmnopq'])
36 set spell wrapscan
37 normal 0]s
38 call assert_equal('plong', expand('<cword>'))
39 normal j
40 call assert_equal(9, getcurpos()[2])
41 normal 0[s
42 call assert_equal('plong', expand('<cword>'))
43 normal j
44 call assert_equal(9, getcurpos()[2])
45
46 normal 0]S
47 call assert_equal('plong', expand('<cword>'))
48 normal j
49 call assert_equal(9, getcurpos()[2])
50 normal 0[S
51 call assert_equal('plong', expand('<cword>'))
52 normal j
53 call assert_equal(9, getcurpos()[2])
54
55 normal 1G0
56 call assert_equal('plong', spellbadword()[0])
57 normal j
58 call assert_equal(9, getcurpos()[2])
59
60 bwipe!
61 set nospell
62endfunc
63
Bram Moolenaar5b276aa2017-04-22 23:49:52 +020064func Test_z_equal_on_invalid_utf8_word()
65 split
66 set spell
67 call setline(1, "\xff")
68 norm z=
69 set nospell
70 bwipe!
71endfunc
Bram Moolenaar545cb792017-05-23 11:31:22 +020072
Bram Moolenaar872e4512018-07-20 23:36:26 +020073" Test spellbadword() with argument
74func Test_spellbadword()
75 set spell
76
77 call assert_equal(['bycycle', 'bad'], spellbadword('My bycycle.'))
Bram Moolenaarf6ed61e2019-09-07 19:05:09 +020078 call assert_equal(['another', 'caps'], 'A sentence. another sentence'->spellbadword())
Bram Moolenaar872e4512018-07-20 23:36:26 +020079
80 set spelllang=en
81 call assert_equal(['', ''], spellbadword('centre'))
82 call assert_equal(['', ''], spellbadword('center'))
83 set spelllang=en_us
84 call assert_equal(['centre', 'local'], spellbadword('centre'))
85 call assert_equal(['', ''], spellbadword('center'))
86 set spelllang=en_gb
87 call assert_equal(['', ''], spellbadword('centre'))
88 call assert_equal(['center', 'local'], spellbadword('center'))
89
90 " Create a small word list to test that spellbadword('...')
91 " can return ['...', 'rare'].
92 e Xwords
93 insert
94foo
95foobar/?
96.
97 w!
98 mkspell! Xwords.spl Xwords
99 set spelllang=Xwords.spl
100 call assert_equal(['foobar', 'rare'], spellbadword('foo foobar'))
101
102 " Typo should not be detected without the 'spell' option.
103 set spelllang=en_gb nospell
104 call assert_equal(['', ''], spellbadword('centre'))
105 call assert_equal(['', ''], spellbadword('My bycycle.'))
106 call assert_equal(['', ''], spellbadword('A sentence. another sentence'))
107
108 call delete('Xwords.spl')
109 call delete('Xwords')
110 set spelllang&
111 set spell&
112endfunc
113
Bram Moolenaar545cb792017-05-23 11:31:22 +0200114func Test_spellreall()
115 new
116 set spell
117 call assert_fails('spellrepall', 'E752:')
118 call setline(1, ['A speling mistake. The same speling mistake.',
Bram Moolenaard2c061d2017-06-22 21:42:49 +0200119 \ 'Another speling mistake.'])
Bram Moolenaar545cb792017-05-23 11:31:22 +0200120 call feedkeys(']s1z=', 'tx')
121 call assert_equal('A spelling mistake. The same speling mistake.', getline(1))
122 call assert_equal('Another speling mistake.', getline(2))
123 spellrepall
124 call assert_equal('A spelling mistake. The same spelling mistake.', getline(1))
125 call assert_equal('Another spelling mistake.', getline(2))
126 call assert_fails('spellrepall', 'E753:')
127 set spell&
128 bwipe!
129endfunc
Bram Moolenaard2c061d2017-06-22 21:42:49 +0200130
Bram Moolenaare9a8d1f2019-12-25 13:36:36 +0100131" Test spellsuggest({word} [, {max} [, {capital}]])
132func Test_spellsuggest()
133 " No suggestions when spell checking is not enabled.
134 set nospell
Bram Moolenaar76734052019-12-26 14:30:15 +0100135 call assert_equal([], spellsuggest('marrch'))
Bram Moolenaare9a8d1f2019-12-25 13:36:36 +0100136
137 set spell
138
139 " With 1 argument.
Bram Moolenaar76734052019-12-26 14:30:15 +0100140 call assert_equal(['march', 'March'], spellsuggest('marrch')[0:1])
Bram Moolenaare9a8d1f2019-12-25 13:36:36 +0100141
142 " With 2 arguments.
Bram Moolenaar76734052019-12-26 14:30:15 +0100143 call assert_equal(['march', 'March'], spellsuggest('marrch', 2))
Bram Moolenaare9a8d1f2019-12-25 13:36:36 +0100144
145 " With 3 arguments.
Bram Moolenaar76734052019-12-26 14:30:15 +0100146 call assert_equal(['march'], spellsuggest('marrch', 1, 0))
147 call assert_equal(['March'], spellsuggest('marrch', 1, 1))
Bram Moolenaare9a8d1f2019-12-25 13:36:36 +0100148
149 " Test with digits and hyphen.
150 call assert_equal('Carbon-14', spellsuggest('Carbon-15')[0])
151
152 " Comment taken from spellsuggest.c explains the following test cases:
153 "
154 " If there are more UPPER than lower case letters suggest an
155 " ALLCAP word. Otherwise, if the first letter is UPPER then
156 " suggest ONECAP. Exception: "ALl" most likely should be "All",
157 " require three upper case letters.
Bram Moolenaar76734052019-12-26 14:30:15 +0100158 call assert_equal(['THIRD', 'third'], spellsuggest('thIRD', 2))
159 call assert_equal(['third', 'THIRD'], spellsuggest('tHIrd', 2))
160 call assert_equal(['Third'], spellsuggest('THird', 1))
Bram Moolenaare9a8d1f2019-12-25 13:36:36 +0100161 call assert_equal(['All'], spellsuggest('ALl', 1))
162
163 set spell&
164endfunc
165
166" Test 'spellsuggest' option with methods fast, best and double.
167func Test_spellsuggest_option_methods()
168 set spell
169
Bram Moolenaar76734052019-12-26 14:30:15 +0100170 for e in ['latin1', 'utf-8']
171 exe 'set encoding=' .. e
Bram Moolenaare9a8d1f2019-12-25 13:36:36 +0100172
Bram Moolenaar76734052019-12-26 14:30:15 +0100173 set spellsuggest=fast
174 call assert_equal(['Stick', 'Stitch'], spellsuggest('Stich', 2), e)
Bram Moolenaare9a8d1f2019-12-25 13:36:36 +0100175
Bram Moolenaar76734052019-12-26 14:30:15 +0100176 " With best or double option, "Stitch" should become the top suggestion
177 " because of better phonetic matching.
178 set spellsuggest=best
179 call assert_equal(['Stitch', 'Stick'], spellsuggest('Stich', 2), e)
Bram Moolenaare9a8d1f2019-12-25 13:36:36 +0100180
Bram Moolenaar76734052019-12-26 14:30:15 +0100181 set spellsuggest=double
182 call assert_equal(['Stitch', 'Stick'], spellsuggest('Stich', 2), e)
183 endfor
184
185 set spell& spellsuggest& encoding&
Bram Moolenaare9a8d1f2019-12-25 13:36:36 +0100186endfunc
187
188" Test 'spellsuggest' option with value file:{filename}
189func Test_spellsuggest_option_file()
190 set spell spellsuggest=file:Xspellsuggest
191 call writefile(['emacs/vim',
192 \ 'theribal/terrible',
193 \ 'teribal/terrrible',
194 \ 'terribal'],
195 \ 'Xspellsuggest')
196
197 call assert_equal(['vim'], spellsuggest('emacs', 2))
198 call assert_equal(['terrible'], spellsuggest('theribal',2))
199
200 " If the suggestion is misspelled (*terrrible* with 3 r),
201 " it should not be proposed.
202 " The entry for "terribal" should be ignored because of missing slash.
203 call assert_equal([], spellsuggest('teribal', 2))
204 call assert_equal([], spellsuggest('terribal', 2))
205
206 set spell spellsuggest=best,file:Xspellsuggest
207 call assert_equal(['vim', 'Emacs'], spellsuggest('emacs', 2))
208 call assert_equal(['terrible', 'tribal'], spellsuggest('theribal', 2))
209 call assert_equal(['tribal'], spellsuggest('teribal', 1))
210 call assert_equal(['tribal'], spellsuggest('terribal', 1))
211
212 call delete('Xspellsuggest')
213 call assert_fails("call spellsuggest('vim')", "E484: Can't open file Xspellsuggest")
214
215 set spellsuggest& spell&
216endfunc
217
218" Test 'spellsuggest' option with value {number}
219" to limit the number of suggestions
220func Test_spellsuggest_option_number()
221 set spell spellsuggest=2,best
222 new
223
224 " We limited the number of suggestions to 2, so selecting
225 " the 1st and 2nd suggestion should correct the word, but
226 " selecting a 3rd suggestion should do nothing.
Bram Moolenaar76734052019-12-26 14:30:15 +0100227 call setline(1, 'A baord')
228 norm $1z=
229 call assert_equal('A board', getline(1))
Bram Moolenaare9a8d1f2019-12-25 13:36:36 +0100230
Bram Moolenaar76734052019-12-26 14:30:15 +0100231 call setline(1, 'A baord')
232 norm $2z=
233 call assert_equal('A bard', getline(1))
Bram Moolenaare9a8d1f2019-12-25 13:36:36 +0100234
Bram Moolenaar76734052019-12-26 14:30:15 +0100235 call setline(1, 'A baord')
236 norm $3z=
237 call assert_equal('A baord', getline(1))
Bram Moolenaare9a8d1f2019-12-25 13:36:36 +0100238
Bram Moolenaar76734052019-12-26 14:30:15 +0100239 let a = execute('norm $z=')
Bram Moolenaare9a8d1f2019-12-25 13:36:36 +0100240 call assert_equal(
241 \ "\n"
Bram Moolenaar76734052019-12-26 14:30:15 +0100242 \ .. "Change \"baord\" to:\n"
243 \ .. " 1 \"board\"\n"
244 \ .. " 2 \"bard\"\n"
Bram Moolenaare9a8d1f2019-12-25 13:36:36 +0100245 \ .. "Type number and <Enter> or click with mouse (empty cancels): ", a)
246
247 set spell spellsuggest=0
Bram Moolenaar76734052019-12-26 14:30:15 +0100248 call assert_equal("\nSorry, no suggestions", execute('norm $z='))
Bram Moolenaare9a8d1f2019-12-25 13:36:36 +0100249
250 " Unlike z=, function spellsuggest(...) should not be affected by the
251 " max number of suggestions (2) set by the 'spellsuggest' option.
Bram Moolenaar76734052019-12-26 14:30:15 +0100252 call assert_equal(['board', 'bard', 'broad'], spellsuggest('baord', 3))
Bram Moolenaare9a8d1f2019-12-25 13:36:36 +0100253
254 set spellsuggest& spell&
255 bwipe!
256endfunc
257
258" Test 'spellsuggest' option with value expr:{expr}
259func Test_spellsuggest_option_expr()
260 " A silly 'spellsuggest' function which makes suggestions all uppercase
261 " and makes the score of each suggestion the length of the suggested word.
262 " So shorter suggestions are preferred.
263 func MySuggest()
264 let spellsuggest_save = &spellsuggest
Bram Moolenaar76734052019-12-26 14:30:15 +0100265 set spellsuggest=3,best
Bram Moolenaare9a8d1f2019-12-25 13:36:36 +0100266 let result = map(spellsuggest(v:val, 3), "[toupper(v:val), len(v:val)]")
267 let &spellsuggest = spellsuggest_save
268 return result
269 endfunc
270
Bram Moolenaar76734052019-12-26 14:30:15 +0100271 set spell spellsuggest=expr:MySuggest()
272 call assert_equal(['BARD', 'BOARD', 'BROAD'], spellsuggest('baord', 3))
Bram Moolenaare9a8d1f2019-12-25 13:36:36 +0100273
274 new
Bram Moolenaar76734052019-12-26 14:30:15 +0100275 call setline(1, 'baord')
Bram Moolenaare9a8d1f2019-12-25 13:36:36 +0100276 let a = execute('norm z=')
277 call assert_equal(
278 \ "\n"
Bram Moolenaar76734052019-12-26 14:30:15 +0100279 \ .. "Change \"baord\" to:\n"
280 \ .. " 1 \"BARD\"\n"
281 \ .. " 2 \"BOARD\"\n"
282 \ .. " 3 \"BROAD\"\n"
Bram Moolenaare9a8d1f2019-12-25 13:36:36 +0100283 \ .. "Type number and <Enter> or click with mouse (empty cancels): ", a)
284
285 " With verbose, z= should show the score i.e. word length with
286 " our SpellSuggest() function.
287 set verbose=1
288 let a = execute('norm z=')
289 call assert_equal(
290 \ "\n"
Bram Moolenaar76734052019-12-26 14:30:15 +0100291 \ .. "Change \"baord\" to:\n"
292 \ .. " 1 \"BARD\" (4 - 0)\n"
293 \ .. " 2 \"BOARD\" (5 - 0)\n"
294 \ .. " 3 \"BROAD\" (5 - 0)\n"
Bram Moolenaare9a8d1f2019-12-25 13:36:36 +0100295 \ .. "Type number and <Enter> or click with mouse (empty cancels): ", a)
296
297 set spell& spellsuggest& verbose&
298 bwipe!
299endfunc
300
Bram Moolenaar9049b682018-08-31 22:26:53 +0200301func Test_spellinfo()
302 new
Bram Moolenaarc25e7022019-10-10 14:08:26 +0200303 let runtime = substitute($VIMRUNTIME, '\\', '/', 'g')
Bram Moolenaar9049b682018-08-31 22:26:53 +0200304
305 set enc=latin1 spell spelllang=en
Bram Moolenaarc25e7022019-10-10 14:08:26 +0200306 call assert_match("^\nfile: " .. runtime .. "/spell/en.latin1.spl\n$", execute('spellinfo'))
Bram Moolenaar9049b682018-08-31 22:26:53 +0200307
308 set enc=cp1250 spell spelllang=en
Bram Moolenaarc25e7022019-10-10 14:08:26 +0200309 call assert_match("^\nfile: " .. runtime .. "/spell/en.ascii.spl\n$", execute('spellinfo'))
Bram Moolenaar9049b682018-08-31 22:26:53 +0200310
Bram Moolenaar30276f22019-01-24 17:59:39 +0100311 set enc=utf-8 spell spelllang=en
Bram Moolenaarc25e7022019-10-10 14:08:26 +0200312 call assert_match("^\nfile: " .. runtime .. "/spell/en.utf-8.spl\n$", execute('spellinfo'))
Bram Moolenaar9049b682018-08-31 22:26:53 +0200313
314 set enc=latin1 spell spelllang=en_us,en_nz
315 call assert_match("^\n" .
Bram Moolenaarc25e7022019-10-10 14:08:26 +0200316 \ "file: " .. runtime .. "/spell/en.latin1.spl\n" .
317 \ "file: " .. runtime.. "/spell/en.latin1.spl\n$", execute('spellinfo'))
Bram Moolenaar9049b682018-08-31 22:26:53 +0200318
319 set spell spelllang=
320 call assert_fails('spellinfo', 'E756:')
321
322 set nospell spelllang=en
323 call assert_fails('spellinfo', 'E756:')
324
Bram Moolenaar8f130ed2019-04-10 22:15:19 +0200325 call assert_fails('set spelllang=foo/bar', 'E474:')
326 call assert_fails('set spelllang=foo\ bar', 'E474:')
327 call assert_fails("set spelllang=foo\\\nbar", 'E474:')
328 call assert_fails("set spelllang=foo\\\rbar", 'E474:')
329 call assert_fails("set spelllang=foo+bar", 'E474:')
330
Bram Moolenaar9049b682018-08-31 22:26:53 +0200331 set enc& spell& spelllang&
332 bwipe
333endfunc
334
Bram Moolenaard2c061d2017-06-22 21:42:49 +0200335func Test_zz_basic()
336 call LoadAffAndDic(g:test_data_aff1, g:test_data_dic1)
337 call RunGoodBad("wrong OK puts. Test the end",
338 \ "bad: inputs comment ok Ok. test d\xE9\xF4l end the",
339 \["Comment", "deol", "d\xE9\xF4r", "input", "OK", "output", "outputs", "outtest", "put", "puts",
340 \ "test", "testen", "testn", "the end", "uk", "wrong"],
341 \[
342 \ ["bad", ["put", "uk", "OK"]],
343 \ ["inputs", ["input", "puts", "outputs"]],
344 \ ["comment", ["Comment", "outtest", "the end"]],
345 \ ["ok", ["OK", "uk", "put"]],
346 \ ["Ok", ["OK", "Uk", "Put"]],
347 \ ["test", ["Test", "testn", "testen"]],
348 \ ["d\xE9\xF4l", ["deol", "d\xE9\xF4r", "test"]],
349 \ ["end", ["put", "uk", "test"]],
350 \ ["the", ["put", "uk", "test"]],
351 \ ]
352 \ )
353
354 call assert_equal("gebletegek", soundfold('goobledygoook'))
Bram Moolenaarf6ed61e2019-09-07 19:05:09 +0200355 call assert_equal("kepereneven", 'kóopërÿnôven'->soundfold())
Bram Moolenaard2c061d2017-06-22 21:42:49 +0200356 call assert_equal("everles gesvets etele", soundfold('oeverloos gezwets edale'))
357endfunc
358
359" Postponed prefixes
360func Test_zz_prefixes()
361 call LoadAffAndDic(g:test_data_aff2, g:test_data_dic1)
362 call RunGoodBad("puts",
363 \ "bad: inputs comment ok Ok end the. test d\xE9\xF4l",
364 \ ["Comment", "deol", "d\xE9\xF4r", "OK", "put", "input", "output", "puts", "outputs", "test", "outtest", "testen", "testn", "the end", "uk", "wrong"],
365 \ [
366 \ ["bad", ["put", "uk", "OK"]],
367 \ ["inputs", ["input", "puts", "outputs"]],
368 \ ["comment", ["Comment"]],
369 \ ["ok", ["OK", "uk", "put"]],
370 \ ["Ok", ["OK", "Uk", "Put"]],
371 \ ["end", ["put", "uk", "deol"]],
372 \ ["the", ["put", "uk", "test"]],
373 \ ["test", ["Test", "testn", "testen"]],
374 \ ["d\xE9\xF4l", ["deol", "d\xE9\xF4r", "test"]],
375 \ ])
376endfunc
377
378"Compound words
379func Test_zz_compound()
380 call LoadAffAndDic(g:test_data_aff3, g:test_data_dic3)
381 call RunGoodBad("foo m\xEF foobar foofoobar barfoo barbarfoo",
382 \ "bad: bar la foom\xEF barm\xEF m\xEFfoo m\xEFbar m\xEFm\xEF lala m\xEFla lam\xEF foola labar",
383 \ ["foo", "m\xEF"],
384 \ [
385 \ ["bad", ["foo", "m\xEF"]],
386 \ ["bar", ["barfoo", "foobar", "foo"]],
387 \ ["la", ["m\xEF", "foo"]],
388 \ ["foom\xEF", ["foo m\xEF", "foo", "foofoo"]],
389 \ ["barm\xEF", ["barfoo", "m\xEF", "barbar"]],
390 \ ["m\xEFfoo", ["m\xEF foo", "foo", "foofoo"]],
391 \ ["m\xEFbar", ["foobar", "barbar", "m\xEF"]],
392 \ ["m\xEFm\xEF", ["m\xEF m\xEF", "m\xEF"]],
393 \ ["lala", []],
394 \ ["m\xEFla", ["m\xEF", "m\xEF m\xEF"]],
395 \ ["lam\xEF", ["m\xEF", "m\xEF m\xEF"]],
396 \ ["foola", ["foo", "foobar", "foofoo"]],
397 \ ["labar", ["barbar", "foobar"]],
398 \ ])
399
400 call LoadAffAndDic(g:test_data_aff4, g:test_data_dic4)
401 call RunGoodBad("word util bork prebork start end wordutil wordutils pro-ok bork borkbork borkborkbork borkborkborkbork borkborkborkborkbork tomato tomatotomato startend startword startwordword startwordend startwordwordend startwordwordwordend prebork preborkbork preborkborkbork nouword",
402 \ "bad: wordutilize pro borkborkborkborkborkbork tomatotomatotomato endstart endend startstart wordend wordstart preborkprebork preborkpreborkbork startwordwordwordwordend borkpreborkpreborkbork utilsbork startnouword",
403 \ ["bork", "prebork", "end", "pro-ok", "start", "tomato", "util", "utilize", "utils", "word", "nouword"],
404 \ [
405 \ ["bad", ["end", "bork", "word"]],
406 \ ["wordutilize", ["word utilize", "wordutils", "wordutil"]],
407 \ ["pro", ["bork", "word", "end"]],
408 \ ["borkborkborkborkborkbork", ["bork borkborkborkborkbork", "borkbork borkborkborkbork", "borkborkbork borkborkbork"]],
409 \ ["tomatotomatotomato", ["tomato tomatotomato", "tomatotomato tomato", "tomato tomato tomato"]],
410 \ ["endstart", ["end start", "start"]],
411 \ ["endend", ["end end", "end"]],
412 \ ["startstart", ["start start"]],
413 \ ["wordend", ["word end", "word", "wordword"]],
414 \ ["wordstart", ["word start", "bork start"]],
415 \ ["preborkprebork", ["prebork prebork", "preborkbork", "preborkborkbork"]],
416 \ ["preborkpreborkbork", ["prebork preborkbork", "preborkborkbork", "preborkborkborkbork"]],
417 \ ["startwordwordwordwordend", ["startwordwordwordword end", "startwordwordwordword", "start wordwordwordword end"]],
418 \ ["borkpreborkpreborkbork", ["bork preborkpreborkbork", "bork prebork preborkbork", "bork preborkprebork bork"]],
419 \ ["utilsbork", ["utilbork", "utils bork", "util bork"]],
420 \ ["startnouword", ["start nouword", "startword", "startborkword"]],
421 \ ])
422
423endfunc
424
425"Test affix flags with two characters
426func Test_zz_affix()
427 call LoadAffAndDic(g:test_data_aff5, g:test_data_dic5)
428 call RunGoodBad("fooa1 fooa\xE9 bar prebar barbork prebarbork startprebar start end startend startmiddleend nouend",
429 \ "bad: foo fooa2 prabar probarbirk middle startmiddle middleend endstart startprobar startnouend",
430 \ ["bar", "barbork", "end", "fooa1", "fooa\xE9", "nouend", "prebar", "prebarbork", "start"],
431 \ [
432 \ ["bad", ["bar", "end", "fooa1"]],
433 \ ["foo", ["fooa1", "fooa\xE9", "bar"]],
434 \ ["fooa2", ["fooa1", "fooa\xE9", "bar"]],
435 \ ["prabar", ["prebar", "bar", "bar bar"]],
436 \ ["probarbirk", ["prebarbork"]],
437 \ ["middle", []],
438 \ ["startmiddle", ["startmiddleend", "startmiddlebar"]],
439 \ ["middleend", []],
440 \ ["endstart", ["end start", "start"]],
441 \ ["startprobar", ["startprebar", "start prebar", "startbar"]],
442 \ ["startnouend", ["start nouend", "startend"]],
443 \ ])
444
445 call LoadAffAndDic(g:test_data_aff6, g:test_data_dic6)
446 call RunGoodBad("meea1 meea\xE9 bar prebar barbork prebarbork leadprebar lead end leadend leadmiddleend",
447 \ "bad: mee meea2 prabar probarbirk middle leadmiddle middleend endlead leadprobar",
448 \ ["bar", "barbork", "end", "lead", "meea1", "meea\xE9", "prebar", "prebarbork"],
449 \ [
450 \ ["bad", ["bar", "end", "lead"]],
451 \ ["mee", ["meea1", "meea\xE9", "bar"]],
452 \ ["meea2", ["meea1", "meea\xE9", "lead"]],
453 \ ["prabar", ["prebar", "bar", "leadbar"]],
454 \ ["probarbirk", ["prebarbork"]],
455 \ ["middle", []],
456 \ ["leadmiddle", ["leadmiddleend", "leadmiddlebar"]],
457 \ ["middleend", []],
458 \ ["endlead", ["end lead", "lead", "end end"]],
459 \ ["leadprobar", ["leadprebar", "lead prebar", "leadbar"]],
460 \ ])
461
462 call LoadAffAndDic(g:test_data_aff7, g:test_data_dic7)
Bram Moolenaar3d2a47c2019-11-07 20:48:42 +0100463 call RunGoodBad("meea1 meezero meea\xE9 bar prebar barmeat prebarmeat leadprebar lead tail leadtail leadmiddletail",
Bram Moolenaard2c061d2017-06-22 21:42:49 +0200464 \ "bad: mee meea2 prabar probarmaat middle leadmiddle middletail taillead leadprobar",
Bram Moolenaar3d2a47c2019-11-07 20:48:42 +0100465 \ ["bar", "barmeat", "lead", "meea1", "meea\xE9", "meezero", "prebar", "prebarmeat", "tail"],
Bram Moolenaard2c061d2017-06-22 21:42:49 +0200466 \ [
467 \ ["bad", ["bar", "lead", "tail"]],
468 \ ["mee", ["meea1", "meea\xE9", "bar"]],
469 \ ["meea2", ["meea1", "meea\xE9", "lead"]],
470 \ ["prabar", ["prebar", "bar", "leadbar"]],
471 \ ["probarmaat", ["prebarmeat"]],
472 \ ["middle", []],
473 \ ["leadmiddle", ["leadmiddlebar"]],
474 \ ["middletail", []],
475 \ ["taillead", ["tail lead", "tail"]],
476 \ ["leadprobar", ["leadprebar", "lead prebar", "leadbar"]],
477 \ ])
478endfunc
479
480func Test_zz_NOSLITSUGS()
481 call LoadAffAndDic(g:test_data_aff8, g:test_data_dic8)
482 call RunGoodBad("foo bar faabar", "bad: foobar barfoo",
483 \ ["bar", "faabar", "foo"],
484 \ [
485 \ ["bad", ["bar", "foo"]],
486 \ ["foobar", ["faabar", "foo bar", "bar"]],
487 \ ["barfoo", ["bar foo", "bar", "foo"]],
488 \ ])
489endfunc
490
491" Numbers
492func Test_zz_Numbers()
493 call LoadAffAndDic(g:test_data_aff9, g:test_data_dic9)
494 call RunGoodBad("0b1011 0777 1234 0x01ff", "",
495 \ ["bar", "foo"],
496 \ [
497 \ ])
498endfunc
499
Bram Moolenaar37ff4cf2019-11-17 20:10:20 +0100500" Affix flags
501func Test_zz_affix_flags()
502 call LoadAffAndDic(g:test_data_aff10, g:test_data_dic10)
503 call RunGoodBad("drink drinkable drinkables drinktable drinkabletable",
504 \ "bad: drinks drinkstable drinkablestable",
505 \ ["drink", "drinkable", "drinkables", "table"],
506 \ [['bad', []],
507 \ ['drinks', ['drink']],
508 \ ['drinkstable', ['drinktable', 'drinkable', 'drink table']],
509 \ ['drinkablestable', ['drinkabletable', 'drinkables table', 'drinkable table']],
510 \ ])
511endfunc
512
Bram Moolenaard2c061d2017-06-22 21:42:49 +0200513function FirstSpellWord()
514 call feedkeys("/^start:\n", 'tx')
515 normal ]smm
516 let [str, a] = spellbadword()
517 return str
518endfunc
519
520function SecondSpellWord()
521 normal `m]s
522 let [str, a] = spellbadword()
523 return str
524endfunc
525
526"Test with SAL instead of SOFO items; test automatic reloading
527func Test_zz_sal_and_addition()
528 set enc=latin1
529 set spellfile=
Bram Moolenaar1a0f2002017-07-28 15:38:10 +0200530 call writefile(g:test_data_dic1, "Xtest.dic")
Bram Moolenaard2c061d2017-06-22 21:42:49 +0200531 call writefile(g:test_data_aff_sal, "Xtest.aff")
532 mkspell! Xtest Xtest
533 set spl=Xtest.latin1.spl spell
534 call assert_equal('kbltykk', soundfold('goobledygoook'))
535 call assert_equal('kprnfn', soundfold('kóopërÿnôven'))
536 call assert_equal('*fls kswts tl', soundfold('oeverloos gezwets edale'))
537
538 "also use an addition file
539 call writefile(["/regions=usgbnz", "elequint/2", "elekwint/3"], "Xtest.latin1.add")
540 mkspell! Xtest.latin1.add.spl Xtest.latin1.add
541
542 bwipe!
543 call setline(1, ["start: elequint test elekwint test elekwent asdf"])
544
545 set spellfile=Xtest.latin1.add
546 call assert_equal("elekwent", FirstSpellWord())
547
548 set spl=Xtest_us.latin1.spl
549 call assert_equal("elequint", FirstSpellWord())
550 call assert_equal("elekwint", SecondSpellWord())
551
552 set spl=Xtest_gb.latin1.spl
553 call assert_equal("elekwint", FirstSpellWord())
554 call assert_equal("elekwent", SecondSpellWord())
555
556 set spl=Xtest_nz.latin1.spl
557 call assert_equal("elequint", FirstSpellWord())
558 call assert_equal("elekwent", SecondSpellWord())
559
560 set spl=Xtest_ca.latin1.spl
561 call assert_equal("elequint", FirstSpellWord())
562 call assert_equal("elekwint", SecondSpellWord())
563endfunc
564
Bram Moolenaar862f1e12019-04-10 22:33:41 +0200565func Test_spellfile_value()
566 set spellfile=Xdir/Xtest.latin1.add
567 set spellfile=Xdir/Xtest.utf-8.add,Xtest_other.add
568endfunc
569
Bram Moolenaaree03b942017-10-27 00:57:05 +0200570func Test_region_error()
571 messages clear
572 call writefile(["/regions=usgbnz", "elequint/0"], "Xtest.latin1.add")
573 mkspell! Xtest.latin1.add.spl Xtest.latin1.add
574 call assert_match('Invalid region nr in Xtest.latin1.add line 2: 0', execute('messages'))
575 call delete('Xtest.latin1.add')
576 call delete('Xtest.latin1.add.spl')
577endfunc
578
Bram Moolenaard2c061d2017-06-22 21:42:49 +0200579" Check using z= in new buffer (crash fixed by patch 7.4a.028).
580func Test_zeq_crash()
581 new
582 set maxmem=512 spell
583 call feedkeys('iasdz=:\"', 'tx')
584
585 bwipe!
586endfunc
587
Bram Moolenaar5bcc5a12019-08-06 22:48:02 +0200588" Check handling a word longer than MAXWLEN.
589func Test_spell_long_word()
590 set enc=utf-8
591 new
592 call setline(1, "d\xCC\xB4\xCC\xBD\xCD\x88\xCD\x94a\xCC\xB5\xCD\x84\xCD\x84\xCC\xA8\xCD\x9Cr\xCC\xB5\xCC\x8E\xCD\x85\xCD\x85k\xCC\xB6\xCC\x89\xCC\x9D \xCC\xB6\xCC\x83\xCC\x8F\xCC\xA4\xCD\x8Ef\xCC\xB7\xCC\x81\xCC\x80\xCC\xA9\xCC\xB0\xCC\xAC\xCC\xA2\xCD\x95\xCD\x87\xCD\x8D\xCC\x9E\xCD\x99\xCC\xAD\xCC\xAB\xCC\x97\xCC\xBBo\xCC\xB6\xCC\x84\xCC\x95\xCC\x8C\xCC\x8B\xCD\x9B\xCD\x9C\xCC\xAFr\xCC\xB7\xCC\x94\xCD\x83\xCD\x97\xCC\x8C\xCC\x82\xCD\x82\xCD\x80\xCD\x91\xCC\x80\xCC\xBE\xCC\x82\xCC\x8F\xCC\xA3\xCD\x85\xCC\xAE\xCD\x8D\xCD\x99\xCC\xBC\xCC\xAB\xCC\xA7\xCD\x88c\xCC\xB7\xCD\x83\xCC\x84\xCD\x92\xCC\x86\xCC\x83\xCC\x88\xCC\x92\xCC\x94\xCC\xBE\xCC\x9D\xCC\xAF\xCC\x98\xCC\x9D\xCC\xBB\xCD\x8E\xCC\xBB\xCC\xB3\xCC\xA3\xCD\x8E\xCD\x99\xCC\xA5\xCC\xAD\xCC\x99\xCC\xB9\xCC\xAE\xCC\xA5\xCC\x9E\xCD\x88\xCC\xAE\xCC\x9E\xCC\xA9\xCC\x97\xCC\xBC\xCC\x99\xCC\xA5\xCD\x87\xCC\x97\xCD\x8E\xCD\x94\xCC\x99\xCC\x9D\xCC\x96\xCD\x94\xCC\xAB\xCC\xA7\xCC\xA5\xCC\x98\xCC\xBB\xCC\xAF\xCC\xABe\xCC\xB7\xCC\x8E\xCC\x82\xCD\x86\xCD\x9B\xCC\x94\xCD\x83\xCC\x85\xCD\x8A\xCD\x8C\xCC\x8B\xCD\x92\xCD\x91\xCC\x8F\xCC\x81\xCD\x95\xCC\xA2\xCC\xB9\xCC\xB2\xCD\x9C\xCC\xB1\xCC\xA6\xCC\xB3\xCC\xAF\xCC\xAE\xCC\x9C\xCD\x99s\xCC\xB8\xCC\x8C\xCC\x8E\xCC\x87\xCD\x81\xCD\x82\xCC\x86\xCD\x8C\xCD\x8C\xCC\x8B\xCC\x84\xCC\x8C\xCD\x84\xCD\x9B\xCD\x86\xCC\x93\xCD\x90\xCC\x85\xCC\x94\xCD\x98\xCD\x84\xCD\x92\xCD\x8B\xCC\x90\xCC\x83\xCC\x8F\xCD\x84\xCD\x81\xCD\x9B\xCC\x90\xCD\x81\xCC\x8F\xCC\xBD\xCC\x88\xCC\xBF\xCC\x88\xCC\x84\xCC\x8E\xCD\x99\xCD\x94\xCC\x99\xCD\x99\xCC\xB0\xCC\xA8\xCC\xA3\xCC\xA8\xCC\x96\xCC\x99\xCC\xAE\xCC\xBC\xCC\x99\xCD\x9A\xCC\xB2\xCC\xB1\xCC\x9F\xCC\xBB\xCC\xA6\xCD\x85\xCC\xAA\xCD\x89\xCC\x9D\xCC\x99\xCD\x96\xCC\xB1\xCC\xB1\xCC\x99\xCC\xA6\xCC\xA5\xCD\x95\xCC\xB2\xCC\xA0\xCD\x99 within")
593 set spell spelllang=en
594 redraw
595 redraw!
596 bwipe!
597 set nospell
598endfunc
599
Bram Moolenaard2c061d2017-06-22 21:42:49 +0200600func LoadAffAndDic(aff_contents, dic_contents)
601 set enc=latin1
602 set spellfile=
603 call writefile(a:aff_contents, "Xtest.aff")
604 call writefile(a:dic_contents, "Xtest.dic")
605 " Generate a .spl file from a .dic and .aff file.
606 mkspell! Xtest Xtest
607 " use that spell file
608 set spl=Xtest.latin1.spl spell
609endfunc
610
611func ListWords()
612 spelldump
613 %yank
614 quit
615 return split(@", "\n")
616endfunc
617
618func TestGoodBadBase()
619 exe '1;/^good:'
620 normal 0f:]s
621 let prevbad = ''
622 let result = []
623 while 1
624 let [bad, a] = spellbadword()
625 if bad == '' || bad == prevbad || bad == 'badend'
626 break
627 endif
628 let prevbad = bad
Bram Moolenaarf6ed61e2019-09-07 19:05:09 +0200629 let lst = bad->spellsuggest(3)
Bram Moolenaard2c061d2017-06-22 21:42:49 +0200630 normal mm
631
632 call add(result, [bad, lst])
633 normal `m]s
634 endwhile
635 return result
636endfunc
637
638func RunGoodBad(good, bad, expected_words, expected_bad_words)
639 bwipe!
640 call setline(1, ["good: ", a:good, a:bad, " badend "])
641 let words = ListWords()
642 call assert_equal(a:expected_words, words[1:-1])
643 let bad_words = TestGoodBadBase()
644 call assert_equal(a:expected_bad_words, bad_words)
645 bwipe!
646endfunc
647
Bram Moolenaar7751d1d2019-10-18 20:37:08 +0200648func Test_spell_screendump()
649 CheckScreendump
650
651 let lines =<< trim END
652 call setline(1, [
653 \ "This is some text without any spell errors. Everything",
654 \ "should just be black, nothing wrong here.",
655 \ "",
656 \ "This line has a sepll error. and missing caps.",
657 \ "And and this is the the duplication.",
658 \ "with missing caps here.",
659 \ ])
660 set spell spelllang=en_nz
661 END
662 call writefile(lines, 'XtestSpell')
663 let buf = RunVimInTerminal('-S XtestSpell', {'rows': 8})
664 call VerifyScreenDump(buf, 'Test_spell_1', {})
665
666 " clean up
667 call StopVimInTerminal(buf)
668 call delete('XtestSpell')
669endfunc
670
Bram Moolenaard2c061d2017-06-22 21:42:49 +0200671let g:test_data_aff1 = [
672 \"SET ISO8859-1",
673 \"TRY esianrtolcdugmphbyfvkwjkqxz-\xEB\xE9\xE8\xEA\xEF\xEE\xE4\xE0\xE2\xF6\xFC\xFB'ESIANRTOLCDUGMPHBYFVKWJKQXZ",
674 \"",
675 \"FOL \xE0\xE1\xE2\xE3\xE4\xE5\xE6\xE7\xE8\xE9\xEA\xEB\xEC\xED\xEE\xEF\xF0\xF1\xF2\xF3\xF4\xF5\xF6\xF8\xF9\xFA\xFB\xFC\xFD\xFE\xDF\xFF",
676 \"LOW \xE0\xE1\xE2\xE3\xE4\xE5\xE6\xE7\xE8\xE9\xEA\xEB\xEC\xED\xEE\xEF\xF0\xF1\xF2\xF3\xF4\xF5\xF6\xF8\xF9\xFA\xFB\xFC\xFD\xFE\xDF\xFF",
677 \"UPP \xC0\xC1\xC2\xC3\xC4\xC5\xC6\xC7\xC8\xC9\xCA\xCB\xCC\xCD\xCE\xCF\xD0\xD1\xD2\xD3\xD4\xD5\xD6\xD8\xD9\xDA\xDB\xDC\xDD\xDE\xDF\xFF",
678 \"",
679 \"SOFOFROM abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ\xE0\xE1\xE2\xE3\xE4\xE5\xE6\xE7\xE8\xE9\xEA\xEB\xEC\xED\xEE\xEF\xF0\xF1\xF2\xF3\xF4\xF5\xF6\xF8\xF9\xFA\xFB\xFC\xFD\xFE\xDF\xFF\xC0\xC1\xC2\xC3\xC4\xC5\xC6\xC7\xC8\xC9\xCA\xCB\xCC\xCD\xCE\xCF\xD0\xD1\xD2\xD3\xD4\xD5\xD6\xD8\xD9\xDA\xDB\xDC\xDD\xDE\xBF",
680 \"SOFOTO ebctefghejklnnepkrstevvkesebctefghejklnnepkrstevvkeseeeeeeeceeeeeeeedneeeeeeeeeeepseeeeeeeeceeeeeeeedneeeeeeeeeeep?",
681 \"",
682 \"MIDWORD\t'-",
683 \"",
684 \"KEP =",
685 \"RAR ?",
686 \"BAD !",
687 \"",
688 \"PFX I N 1",
689 \"PFX I 0 in .",
690 \"",
691 \"PFX O Y 1",
692 \"PFX O 0 out .",
693 \"",
694 \"SFX S Y 2",
695 \"SFX S 0 s [^s]",
696 \"SFX S 0 es s",
697 \"",
698 \"SFX N N 3",
699 \"SFX N 0 en [^n]",
700 \"SFX N 0 nen n",
701 \"SFX N 0 n .",
702 \"",
703 \"REP 3",
704 \"REP g ch",
705 \"REP ch g",
706 \"REP svp s.v.p.",
707 \"",
708 \"MAP 9",
709 \"MAP a\xE0\xE1\xE2\xE3\xE4\xE5",
710 \"MAP e\xE8\xE9\xEA\xEB",
711 \"MAP i\xEC\xED\xEE\xEF",
712 \"MAP o\xF2\xF3\xF4\xF5\xF6",
713 \"MAP u\xF9\xFA\xFB\xFC",
714 \"MAP n\xF1",
715 \"MAP c\xE7",
716 \"MAP y\xFF\xFD",
717 \"MAP s\xDF",
718 \ ]
719let g:test_data_dic1 = [
720 \"123456",
721 \"test/NO",
722 \"# comment",
723 \"wrong",
724 \"Comment",
725 \"OK",
726 \"uk",
727 \"put/ISO",
728 \"the end",
729 \"deol",
730 \"d\xE9\xF4r",
731 \ ]
732let g:test_data_aff2 = [
733 \"SET ISO8859-1",
734 \"",
735 \"FOL \xE0\xE1\xE2\xE3\xE4\xE5\xE6\xE7\xE8\xE9\xEA\xEB\xEC\xED\xEE\xEF\xF0\xF1\xF2\xF3\xF4\xF5\xF6\xF8\xF9\xFA\xFB\xFC\xFD\xFE\xDF\xFF",
736 \"LOW \xE0\xE1\xE2\xE3\xE4\xE5\xE6\xE7\xE8\xE9\xEA\xEB\xEC\xED\xEE\xEF\xF0\xF1\xF2\xF3\xF4\xF5\xF6\xF8\xF9\xFA\xFB\xFC\xFD\xFE\xDF\xFF",
737 \"UPP \xC0\xC1\xC2\xC3\xC4\xC5\xC6\xC7\xC8\xC9\xCA\xCB\xCC\xCD\xCE\xCF\xD0\xD1\xD2\xD3\xD4\xD5\xD6\xD8\xD9\xDA\xDB\xDC\xDD\xDE\xDF\xFF",
738 \"",
739 \"PFXPOSTPONE",
740 \"",
741 \"MIDWORD\t'-",
742 \"",
743 \"KEP =",
744 \"RAR ?",
745 \"BAD !",
746 \"",
747 \"PFX I N 1",
748 \"PFX I 0 in .",
749 \"",
750 \"PFX O Y 1",
751 \"PFX O 0 out [a-z]",
752 \"",
753 \"SFX S Y 2",
754 \"SFX S 0 s [^s]",
755 \"SFX S 0 es s",
756 \"",
757 \"SFX N N 3",
758 \"SFX N 0 en [^n]",
759 \"SFX N 0 nen n",
760 \"SFX N 0 n .",
761 \"",
762 \"REP 3",
763 \"REP g ch",
764 \"REP ch g",
765 \"REP svp s.v.p.",
766 \"",
767 \"MAP 9",
768 \"MAP a\xE0\xE1\xE2\xE3\xE4\xE5",
769 \"MAP e\xE8\xE9\xEA\xEB",
770 \"MAP i\xEC\xED\xEE\xEF",
771 \"MAP o\xF2\xF3\xF4\xF5\xF6",
772 \"MAP u\xF9\xFA\xFB\xFC",
773 \"MAP n\xF1",
774 \"MAP c\xE7",
775 \"MAP y\xFF\xFD",
776 \"MAP s\xDF",
777 \ ]
778let g:test_data_aff3 = [
779 \"SET ISO8859-1",
780 \"",
781 \"COMPOUNDMIN 3",
782 \"COMPOUNDRULE m*",
783 \"NEEDCOMPOUND x",
784 \ ]
785let g:test_data_dic3 = [
786 \"1234",
787 \"foo/m",
788 \"bar/mx",
789 \"m\xEF/m",
790 \"la/mx",
791 \ ]
792let g:test_data_aff4 = [
793 \"SET ISO8859-1",
794 \"",
795 \"FOL \xE0\xE1\xE2\xE3\xE4\xE5\xE6\xE7\xE8\xE9\xEA\xEB\xEC\xED\xEE\xEF\xF0\xF1\xF2\xF3\xF4\xF5\xF6\xF8\xF9\xFA\xFB\xFC\xFD\xFE\xDF\xFF",
796 \"LOW \xE0\xE1\xE2\xE3\xE4\xE5\xE6\xE7\xE8\xE9\xEA\xEB\xEC\xED\xEE\xEF\xF0\xF1\xF2\xF3\xF4\xF5\xF6\xF8\xF9\xFA\xFB\xFC\xFD\xFE\xDF\xFF",
797 \"UPP \xC0\xC1\xC2\xC3\xC4\xC5\xC6\xC7\xC8\xC9\xCA\xCB\xCC\xCD\xCE\xCF\xD0\xD1\xD2\xD3\xD4\xD5\xD6\xD8\xD9\xDA\xDB\xDC\xDD\xDE\xDF\xFF",
798 \"",
799 \"COMPOUNDRULE m+",
800 \"COMPOUNDRULE sm*e",
801 \"COMPOUNDRULE sm+",
802 \"COMPOUNDMIN 3",
803 \"COMPOUNDWORDMAX 3",
804 \"COMPOUNDFORBIDFLAG t",
805 \"",
806 \"COMPOUNDSYLMAX 5",
807 \"SYLLABLE a\xE1e\xE9i\xEDo\xF3\xF6\xF5u\xFA\xFC\xFBy/aa/au/ea/ee/ei/ie/oa/oe/oo/ou/uu/ui",
808 \"",
809 \"MAP 9",
810 \"MAP a\xE0\xE1\xE2\xE3\xE4\xE5",
811 \"MAP e\xE8\xE9\xEA\xEB",
812 \"MAP i\xEC\xED\xEE\xEF",
813 \"MAP o\xF2\xF3\xF4\xF5\xF6",
814 \"MAP u\xF9\xFA\xFB\xFC",
815 \"MAP n\xF1",
816 \"MAP c\xE7",
817 \"MAP y\xFF\xFD",
818 \"MAP s\xDF",
819 \"",
820 \"NEEDAFFIX x",
821 \"",
822 \"PFXPOSTPONE",
823 \"",
824 \"MIDWORD '-",
825 \"",
826 \"SFX q N 1",
827 \"SFX q 0 -ok .",
828 \"",
829 \"SFX a Y 2",
830 \"SFX a 0 s .",
831 \"SFX a 0 ize/t .",
832 \"",
833 \"PFX p N 1",
834 \"PFX p 0 pre .",
835 \"",
836 \"PFX P N 1",
837 \"PFX P 0 nou .",
838 \ ]
839let g:test_data_dic4 = [
840 \"1234",
841 \"word/mP",
842 \"util/am",
843 \"pro/xq",
844 \"tomato/m",
845 \"bork/mp",
846 \"start/s",
847 \"end/e",
848 \ ]
849let g:test_data_aff5 = [
850 \"SET ISO8859-1",
851 \"",
852 \"FLAG long",
853 \"",
854 \"NEEDAFFIX !!",
855 \"",
856 \"COMPOUNDRULE ssmm*ee",
857 \"",
858 \"NEEDCOMPOUND xx",
859 \"COMPOUNDPERMITFLAG pp",
860 \"",
861 \"SFX 13 Y 1",
862 \"SFX 13 0 bork .",
863 \"",
864 \"SFX a1 Y 1",
865 \"SFX a1 0 a1 .",
866 \"",
867 \"SFX a\xE9 Y 1",
868 \"SFX a\xE9 0 a\xE9 .",
869 \"",
870 \"PFX zz Y 1",
871 \"PFX zz 0 pre/pp .",
872 \"",
873 \"PFX yy Y 1",
874 \"PFX yy 0 nou .",
875 \ ]
876let g:test_data_dic5 = [
877 \"1234",
878 \"foo/a1a\xE9!!",
879 \"bar/zz13ee",
880 \"start/ss",
881 \"end/eeyy",
882 \"middle/mmxx",
883 \ ]
884let g:test_data_aff6 = [
885 \"SET ISO8859-1",
886 \"",
887 \"FLAG caplong",
888 \"",
889 \"NEEDAFFIX A!",
890 \"",
891 \"COMPOUNDRULE sMm*Ee",
892 \"",
893 \"NEEDCOMPOUND Xx",
894 \"",
895 \"COMPOUNDPERMITFLAG p",
896 \"",
897 \"SFX N3 Y 1",
898 \"SFX N3 0 bork .",
899 \"",
900 \"SFX A1 Y 1",
901 \"SFX A1 0 a1 .",
902 \"",
903 \"SFX A\xE9 Y 1",
904 \"SFX A\xE9 0 a\xE9 .",
905 \"",
906 \"PFX Zz Y 1",
907 \"PFX Zz 0 pre/p .",
908 \ ]
909let g:test_data_dic6 = [
910 \"1234",
911 \"mee/A1A\xE9A!",
912 \"bar/ZzN3Ee",
913 \"lead/s",
914 \"end/Ee",
915 \"middle/MmXx",
916 \ ]
917let g:test_data_aff7 = [
918 \"SET ISO8859-1",
919 \"",
920 \"FLAG num",
921 \"",
922 \"NEEDAFFIX 9999",
923 \"",
924 \"COMPOUNDRULE 2,77*123",
925 \"",
926 \"NEEDCOMPOUND 1",
927 \"COMPOUNDPERMITFLAG 432",
928 \"",
929 \"SFX 61003 Y 1",
930 \"SFX 61003 0 meat .",
931 \"",
Bram Moolenaar3d2a47c2019-11-07 20:48:42 +0100932 \"SFX 0 Y 1",
933 \"SFX 0 0 zero .",
934 \"",
Bram Moolenaard2c061d2017-06-22 21:42:49 +0200935 \"SFX 391 Y 1",
936 \"SFX 391 0 a1 .",
937 \"",
938 \"SFX 111 Y 1",
939 \"SFX 111 0 a\xE9 .",
940 \"",
941 \"PFX 17 Y 1",
942 \"PFX 17 0 pre/432 .",
943 \ ]
944let g:test_data_dic7 = [
945 \"1234",
Bram Moolenaar3d2a47c2019-11-07 20:48:42 +0100946 \"mee/0,391,111,9999",
Bram Moolenaard2c061d2017-06-22 21:42:49 +0200947 \"bar/17,61003,123",
948 \"lead/2",
949 \"tail/123",
950 \"middle/77,1",
951 \ ]
952let g:test_data_aff8 = [
953 \"SET ISO8859-1",
954 \"",
955 \"NOSPLITSUGS",
956 \ ]
957let g:test_data_dic8 = [
958 \"1234",
959 \"foo",
960 \"bar",
961 \"faabar",
962 \ ]
963let g:test_data_aff9 = [
964 \ ]
965let g:test_data_dic9 = [
966 \"1234",
967 \"foo",
968 \"bar",
969 \ ]
Bram Moolenaar37ff4cf2019-11-17 20:10:20 +0100970let g:test_data_aff10 = [
971 \"COMPOUNDRULE se",
972 \"COMPOUNDPERMITFLAG p",
973 \"",
974 \"SFX A Y 1",
975 \"SFX A 0 able/Mp .",
976 \"",
977 \"SFX M Y 1",
978 \"SFX M 0 s .",
979 \ ]
980let g:test_data_dic10 = [
981 \"1234",
982 \"drink/As",
983 \"table/e",
984 \ ]
Bram Moolenaard2c061d2017-06-22 21:42:49 +0200985let g:test_data_aff_sal = [
986 \"SET ISO8859-1",
987 \"TRY esianrtolcdugmphbyfvkwjkqxz-\xEB\xE9\xE8\xEA\xEF\xEE\xE4\xE0\xE2\xF6\xFC\xFB'ESIANRTOLCDUGMPHBYFVKWJKQXZ",
988 \"",
989 \"FOL \xE0\xE1\xE2\xE3\xE4\xE5\xE6\xE7\xE8\xE9\xEA\xEB\xEC\xED\xEE\xEF\xF0\xF1\xF2\xF3\xF4\xF5\xF6\xF8\xF9\xFA\xFB\xFC\xFD\xFE\xDF\xFF",
990 \"LOW \xE0\xE1\xE2\xE3\xE4\xE5\xE6\xE7\xE8\xE9\xEA\xEB\xEC\xED\xEE\xEF\xF0\xF1\xF2\xF3\xF4\xF5\xF6\xF8\xF9\xFA\xFB\xFC\xFD\xFE\xDF\xFF",
991 \"UPP \xC0\xC1\xC2\xC3\xC4\xC5\xC6\xC7\xC8\xC9\xCA\xCB\xCC\xCD\xCE\xCF\xD0\xD1\xD2\xD3\xD4\xD5\xD6\xD8\xD9\xDA\xDB\xDC\xDD\xDE\xDF\xFF",
992 \"",
993 \"MIDWORD\t'-",
994 \"",
995 \"KEP =",
996 \"RAR ?",
997 \"BAD !",
998 \"",
999 \"PFX I N 1",
1000 \"PFX I 0 in .",
1001 \"",
1002 \"PFX O Y 1",
1003 \"PFX O 0 out .",
1004 \"",
1005 \"SFX S Y 2",
1006 \"SFX S 0 s [^s]",
1007 \"SFX S 0 es s",
1008 \"",
1009 \"SFX N N 3",
1010 \"SFX N 0 en [^n]",
1011 \"SFX N 0 nen n",
1012 \"SFX N 0 n .",
1013 \"",
1014 \"REP 3",
1015 \"REP g ch",
1016 \"REP ch g",
1017 \"REP svp s.v.p.",
1018 \"",
1019 \"MAP 9",
1020 \"MAP a\xE0\xE1\xE2\xE3\xE4\xE5",
1021 \"MAP e\xE8\xE9\xEA\xEB",
1022 \"MAP i\xEC\xED\xEE\xEF",
1023 \"MAP o\xF2\xF3\xF4\xF5\xF6",
1024 \"MAP u\xF9\xFA\xFB\xFC",
1025 \"MAP n\xF1",
1026 \"MAP c\xE7",
1027 \"MAP y\xFF\xFD",
1028 \"MAP s\xDF",
1029 \"",
1030 \"SAL AH(AEIOUY)-^ *H",
1031 \"SAL AR(AEIOUY)-^ *R",
1032 \"SAL A(HR)^ *",
1033 \"SAL A^ *",
1034 \"SAL AH(AEIOUY)- H",
1035 \"SAL AR(AEIOUY)- R",
1036 \"SAL A(HR) _",
1037 \"SAL \xC0^ *",
1038 \"SAL \xC5^ *",
1039 \"SAL BB- _",
1040 \"SAL B B",
1041 \"SAL CQ- _",
1042 \"SAL CIA X",
1043 \"SAL CH X",
1044 \"SAL C(EIY)- S",
1045 \"SAL CK K",
1046 \"SAL COUGH^ KF",
1047 \"SAL CC< C",
1048 \"SAL C K",
1049 \"SAL DG(EIY) K",
1050 \"SAL DD- _",
1051 \"SAL D T",
1052 \"SAL \xC9< E",
1053 \"SAL EH(AEIOUY)-^ *H",
1054 \"SAL ER(AEIOUY)-^ *R",
1055 \"SAL E(HR)^ *",
1056 \"SAL ENOUGH^$ *NF",
1057 \"SAL E^ *",
1058 \"SAL EH(AEIOUY)- H",
1059 \"SAL ER(AEIOUY)- R",
1060 \"SAL E(HR) _",
1061 \"SAL FF- _",
1062 \"SAL F F",
1063 \"SAL GN^ N",
1064 \"SAL GN$ N",
1065 \"SAL GNS$ NS",
1066 \"SAL GNED$ N",
1067 \"SAL GH(AEIOUY)- K",
1068 \"SAL GH _",
1069 \"SAL GG9 K",
1070 \"SAL G K",
1071 \"SAL H H",
1072 \"SAL IH(AEIOUY)-^ *H",
1073 \"SAL IR(AEIOUY)-^ *R",
1074 \"SAL I(HR)^ *",
1075 \"SAL I^ *",
1076 \"SAL ING6 N",
1077 \"SAL IH(AEIOUY)- H",
1078 \"SAL IR(AEIOUY)- R",
1079 \"SAL I(HR) _",
1080 \"SAL J K",
1081 \"SAL KN^ N",
1082 \"SAL KK- _",
1083 \"SAL K K",
1084 \"SAL LAUGH^ LF",
1085 \"SAL LL- _",
1086 \"SAL L L",
1087 \"SAL MB$ M",
1088 \"SAL MM M",
1089 \"SAL M M",
1090 \"SAL NN- _",
1091 \"SAL N N",
1092 \"SAL OH(AEIOUY)-^ *H",
1093 \"SAL OR(AEIOUY)-^ *R",
1094 \"SAL O(HR)^ *",
1095 \"SAL O^ *",
1096 \"SAL OH(AEIOUY)- H",
1097 \"SAL OR(AEIOUY)- R",
1098 \"SAL O(HR) _",
1099 \"SAL PH F",
1100 \"SAL PN^ N",
1101 \"SAL PP- _",
1102 \"SAL P P",
1103 \"SAL Q K",
1104 \"SAL RH^ R",
1105 \"SAL ROUGH^ RF",
1106 \"SAL RR- _",
1107 \"SAL R R",
1108 \"SAL SCH(EOU)- SK",
1109 \"SAL SC(IEY)- S",
1110 \"SAL SH X",
1111 \"SAL SI(AO)- X",
1112 \"SAL SS- _",
1113 \"SAL S S",
1114 \"SAL TI(AO)- X",
1115 \"SAL TH @",
1116 \"SAL TCH-- _",
1117 \"SAL TOUGH^ TF",
1118 \"SAL TT- _",
1119 \"SAL T T",
1120 \"SAL UH(AEIOUY)-^ *H",
1121 \"SAL UR(AEIOUY)-^ *R",
1122 \"SAL U(HR)^ *",
1123 \"SAL U^ *",
1124 \"SAL UH(AEIOUY)- H",
1125 \"SAL UR(AEIOUY)- R",
1126 \"SAL U(HR) _",
1127 \"SAL V^ W",
1128 \"SAL V F",
1129 \"SAL WR^ R",
1130 \"SAL WH^ W",
1131 \"SAL W(AEIOU)- W",
1132 \"SAL X^ S",
1133 \"SAL X KS",
1134 \"SAL Y(AEIOU)- Y",
1135 \"SAL ZZ- _",
1136 \"SAL Z S",
1137 \ ]