blob: fbd5c1a1da8992924d67941705b93d458ca1c2e8 [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
Bram Moolenaar362b44b2020-06-10 21:47:00 +020080 call assert_equal(['TheCamelWord', 'bad'], 'TheCamelWord asdf'->spellbadword())
81 set spelloptions=camel
82 call assert_equal(['asdf', 'bad'], 'TheCamelWord asdf'->spellbadword())
83 set spelloptions=
84
Bram Moolenaar872e4512018-07-20 23:36:26 +020085 set spelllang=en
86 call assert_equal(['', ''], spellbadword('centre'))
87 call assert_equal(['', ''], spellbadword('center'))
88 set spelllang=en_us
89 call assert_equal(['centre', 'local'], spellbadword('centre'))
90 call assert_equal(['', ''], spellbadword('center'))
91 set spelllang=en_gb
92 call assert_equal(['', ''], spellbadword('centre'))
93 call assert_equal(['center', 'local'], spellbadword('center'))
94
95 " Create a small word list to test that spellbadword('...')
96 " can return ['...', 'rare'].
97 e Xwords
98 insert
99foo
100foobar/?
101.
102 w!
103 mkspell! Xwords.spl Xwords
104 set spelllang=Xwords.spl
105 call assert_equal(['foobar', 'rare'], spellbadword('foo foobar'))
106
Bram Moolenaar152e79e2020-06-10 15:32:08 +0200107 " Typo should be detected even without the 'spell' option.
Bram Moolenaar872e4512018-07-20 23:36:26 +0200108 set spelllang=en_gb nospell
109 call assert_equal(['', ''], spellbadword('centre'))
Bram Moolenaar152e79e2020-06-10 15:32:08 +0200110 call assert_equal(['bycycle', 'bad'], spellbadword('My bycycle.'))
111 call assert_equal(['another', 'caps'], spellbadword('A sentence. another sentence'))
112
113 set spelllang=
114 call assert_fails("call spellbadword('maxch')", 'E756:')
Bram Moolenaar872e4512018-07-20 23:36:26 +0200115
116 call delete('Xwords.spl')
117 call delete('Xwords')
118 set spelllang&
119 set spell&
120endfunc
121
Bram Moolenaar545cb792017-05-23 11:31:22 +0200122func Test_spellreall()
123 new
124 set spell
125 call assert_fails('spellrepall', 'E752:')
126 call setline(1, ['A speling mistake. The same speling mistake.',
Bram Moolenaard2c061d2017-06-22 21:42:49 +0200127 \ 'Another speling mistake.'])
Bram Moolenaar545cb792017-05-23 11:31:22 +0200128 call feedkeys(']s1z=', 'tx')
129 call assert_equal('A spelling mistake. The same speling mistake.', getline(1))
130 call assert_equal('Another speling mistake.', getline(2))
131 spellrepall
132 call assert_equal('A spelling mistake. The same spelling mistake.', getline(1))
133 call assert_equal('Another spelling mistake.', getline(2))
134 call assert_fails('spellrepall', 'E753:')
135 set spell&
136 bwipe!
137endfunc
Bram Moolenaard2c061d2017-06-22 21:42:49 +0200138
Bram Moolenaare9a8d1f2019-12-25 13:36:36 +0100139" Test spellsuggest({word} [, {max} [, {capital}]])
140func Test_spellsuggest()
Bram Moolenaar152e79e2020-06-10 15:32:08 +0200141 " Verify suggestions are given even when spell checking is not enabled.
Bram Moolenaare9a8d1f2019-12-25 13:36:36 +0100142 set nospell
Bram Moolenaar152e79e2020-06-10 15:32:08 +0200143 call assert_equal(['march', 'March'], spellsuggest('marrch', 2))
Bram Moolenaare9a8d1f2019-12-25 13:36:36 +0100144
145 set spell
146
147 " With 1 argument.
Bram Moolenaar76734052019-12-26 14:30:15 +0100148 call assert_equal(['march', 'March'], spellsuggest('marrch')[0:1])
Bram Moolenaare9a8d1f2019-12-25 13:36:36 +0100149
150 " With 2 arguments.
Bram Moolenaar76734052019-12-26 14:30:15 +0100151 call assert_equal(['march', 'March'], spellsuggest('marrch', 2))
Bram Moolenaare9a8d1f2019-12-25 13:36:36 +0100152
153 " With 3 arguments.
Bram Moolenaar76734052019-12-26 14:30:15 +0100154 call assert_equal(['march'], spellsuggest('marrch', 1, 0))
155 call assert_equal(['March'], spellsuggest('marrch', 1, 1))
Bram Moolenaare9a8d1f2019-12-25 13:36:36 +0100156
157 " Test with digits and hyphen.
158 call assert_equal('Carbon-14', spellsuggest('Carbon-15')[0])
159
160 " Comment taken from spellsuggest.c explains the following test cases:
161 "
162 " If there are more UPPER than lower case letters suggest an
163 " ALLCAP word. Otherwise, if the first letter is UPPER then
164 " suggest ONECAP. Exception: "ALl" most likely should be "All",
165 " require three upper case letters.
Bram Moolenaar76734052019-12-26 14:30:15 +0100166 call assert_equal(['THIRD', 'third'], spellsuggest('thIRD', 2))
167 call assert_equal(['third', 'THIRD'], spellsuggest('tHIrd', 2))
168 call assert_equal(['Third'], spellsuggest('THird', 1))
Bram Moolenaare9a8d1f2019-12-25 13:36:36 +0100169 call assert_equal(['All'], spellsuggest('ALl', 1))
170
Bram Moolenaar0e05de42020-03-25 22:23:46 +0100171 call assert_fails("call spellsuggest('maxch', [])", 'E745:')
172 call assert_fails("call spellsuggest('maxch', 2, [])", 'E745:')
173
Bram Moolenaar152e79e2020-06-10 15:32:08 +0200174 set spelllang=
175 call assert_fails("call spellsuggest('maxch')", 'E756:')
176 set spelllang&
177
Bram Moolenaare9a8d1f2019-12-25 13:36:36 +0100178 set spell&
179endfunc
180
181" Test 'spellsuggest' option with methods fast, best and double.
182func Test_spellsuggest_option_methods()
183 set spell
184
Bram Moolenaar76734052019-12-26 14:30:15 +0100185 for e in ['latin1', 'utf-8']
186 exe 'set encoding=' .. e
Bram Moolenaare9a8d1f2019-12-25 13:36:36 +0100187
Bram Moolenaar76734052019-12-26 14:30:15 +0100188 set spellsuggest=fast
189 call assert_equal(['Stick', 'Stitch'], spellsuggest('Stich', 2), e)
Bram Moolenaare9a8d1f2019-12-25 13:36:36 +0100190
Bram Moolenaar76734052019-12-26 14:30:15 +0100191 " With best or double option, "Stitch" should become the top suggestion
192 " because of better phonetic matching.
193 set spellsuggest=best
194 call assert_equal(['Stitch', 'Stick'], spellsuggest('Stich', 2), e)
Bram Moolenaare9a8d1f2019-12-25 13:36:36 +0100195
Bram Moolenaar76734052019-12-26 14:30:15 +0100196 set spellsuggest=double
197 call assert_equal(['Stitch', 'Stick'], spellsuggest('Stich', 2), e)
198 endfor
199
200 set spell& spellsuggest& encoding&
Bram Moolenaare9a8d1f2019-12-25 13:36:36 +0100201endfunc
202
203" Test 'spellsuggest' option with value file:{filename}
204func Test_spellsuggest_option_file()
205 set spell spellsuggest=file:Xspellsuggest
206 call writefile(['emacs/vim',
207 \ 'theribal/terrible',
208 \ 'teribal/terrrible',
209 \ 'terribal'],
210 \ 'Xspellsuggest')
211
212 call assert_equal(['vim'], spellsuggest('emacs', 2))
213 call assert_equal(['terrible'], spellsuggest('theribal',2))
214
215 " If the suggestion is misspelled (*terrrible* with 3 r),
216 " it should not be proposed.
217 " The entry for "terribal" should be ignored because of missing slash.
218 call assert_equal([], spellsuggest('teribal', 2))
219 call assert_equal([], spellsuggest('terribal', 2))
220
221 set spell spellsuggest=best,file:Xspellsuggest
222 call assert_equal(['vim', 'Emacs'], spellsuggest('emacs', 2))
223 call assert_equal(['terrible', 'tribal'], spellsuggest('theribal', 2))
224 call assert_equal(['tribal'], spellsuggest('teribal', 1))
225 call assert_equal(['tribal'], spellsuggest('terribal', 1))
226
227 call delete('Xspellsuggest')
228 call assert_fails("call spellsuggest('vim')", "E484: Can't open file Xspellsuggest")
229
230 set spellsuggest& spell&
231endfunc
232
233" Test 'spellsuggest' option with value {number}
234" to limit the number of suggestions
235func Test_spellsuggest_option_number()
236 set spell spellsuggest=2,best
237 new
238
239 " We limited the number of suggestions to 2, so selecting
240 " the 1st and 2nd suggestion should correct the word, but
241 " selecting a 3rd suggestion should do nothing.
Bram Moolenaar76734052019-12-26 14:30:15 +0100242 call setline(1, 'A baord')
243 norm $1z=
244 call assert_equal('A board', getline(1))
Bram Moolenaare9a8d1f2019-12-25 13:36:36 +0100245
Bram Moolenaar76734052019-12-26 14:30:15 +0100246 call setline(1, 'A baord')
247 norm $2z=
248 call assert_equal('A bard', getline(1))
Bram Moolenaare9a8d1f2019-12-25 13:36:36 +0100249
Bram Moolenaar76734052019-12-26 14:30:15 +0100250 call setline(1, 'A baord')
251 norm $3z=
252 call assert_equal('A baord', getline(1))
Bram Moolenaare9a8d1f2019-12-25 13:36:36 +0100253
Bram Moolenaar76734052019-12-26 14:30:15 +0100254 let a = execute('norm $z=')
Bram Moolenaare9a8d1f2019-12-25 13:36:36 +0100255 call assert_equal(
256 \ "\n"
Bram Moolenaar76734052019-12-26 14:30:15 +0100257 \ .. "Change \"baord\" to:\n"
258 \ .. " 1 \"board\"\n"
259 \ .. " 2 \"bard\"\n"
Bram Moolenaard281b7c2020-06-10 16:39:32 +0200260 \ .. "Type number and <Enter> or click with the mouse (q or empty cancels): ", a)
Bram Moolenaare9a8d1f2019-12-25 13:36:36 +0100261
262 set spell spellsuggest=0
Bram Moolenaar76734052019-12-26 14:30:15 +0100263 call assert_equal("\nSorry, no suggestions", execute('norm $z='))
Bram Moolenaare9a8d1f2019-12-25 13:36:36 +0100264
265 " Unlike z=, function spellsuggest(...) should not be affected by the
266 " max number of suggestions (2) set by the 'spellsuggest' option.
Bram Moolenaar76734052019-12-26 14:30:15 +0100267 call assert_equal(['board', 'bard', 'broad'], spellsuggest('baord', 3))
Bram Moolenaare9a8d1f2019-12-25 13:36:36 +0100268
269 set spellsuggest& spell&
270 bwipe!
271endfunc
272
273" Test 'spellsuggest' option with value expr:{expr}
274func Test_spellsuggest_option_expr()
275 " A silly 'spellsuggest' function which makes suggestions all uppercase
276 " and makes the score of each suggestion the length of the suggested word.
277 " So shorter suggestions are preferred.
278 func MySuggest()
279 let spellsuggest_save = &spellsuggest
Bram Moolenaar76734052019-12-26 14:30:15 +0100280 set spellsuggest=3,best
Bram Moolenaare9a8d1f2019-12-25 13:36:36 +0100281 let result = map(spellsuggest(v:val, 3), "[toupper(v:val), len(v:val)]")
282 let &spellsuggest = spellsuggest_save
283 return result
284 endfunc
285
Bram Moolenaar76734052019-12-26 14:30:15 +0100286 set spell spellsuggest=expr:MySuggest()
287 call assert_equal(['BARD', 'BOARD', 'BROAD'], spellsuggest('baord', 3))
Bram Moolenaare9a8d1f2019-12-25 13:36:36 +0100288
289 new
Bram Moolenaar76734052019-12-26 14:30:15 +0100290 call setline(1, 'baord')
Bram Moolenaare9a8d1f2019-12-25 13:36:36 +0100291 let a = execute('norm z=')
292 call assert_equal(
293 \ "\n"
Bram Moolenaar76734052019-12-26 14:30:15 +0100294 \ .. "Change \"baord\" to:\n"
295 \ .. " 1 \"BARD\"\n"
296 \ .. " 2 \"BOARD\"\n"
297 \ .. " 3 \"BROAD\"\n"
Bram Moolenaard281b7c2020-06-10 16:39:32 +0200298 \ .. "Type number and <Enter> or click with the mouse (q or empty cancels): ", a)
Bram Moolenaare9a8d1f2019-12-25 13:36:36 +0100299
300 " With verbose, z= should show the score i.e. word length with
301 " our SpellSuggest() function.
302 set verbose=1
303 let a = execute('norm z=')
304 call assert_equal(
305 \ "\n"
Bram Moolenaar76734052019-12-26 14:30:15 +0100306 \ .. "Change \"baord\" to:\n"
307 \ .. " 1 \"BARD\" (4 - 0)\n"
308 \ .. " 2 \"BOARD\" (5 - 0)\n"
309 \ .. " 3 \"BROAD\" (5 - 0)\n"
Bram Moolenaard281b7c2020-06-10 16:39:32 +0200310 \ .. "Type number and <Enter> or click with the mouse (q or empty cancels): ", a)
Bram Moolenaare9a8d1f2019-12-25 13:36:36 +0100311
312 set spell& spellsuggest& verbose&
313 bwipe!
314endfunc
315
Bram Moolenaar8dfcce32020-03-18 19:32:26 +0100316" Test for 'spellsuggest' expr errrors
317func Test_spellsuggest_expr_errors()
318 " 'spellsuggest'
319 func MySuggest()
320 return range(3)
321 endfunc
322 set spell spellsuggest=expr:MySuggest()
323 call assert_equal([], spellsuggest('baord', 3))
324
325 " Test for 'spellsuggest' expression returning a non-list value
326 func! MySuggest2()
327 return 'good'
328 endfunc
329 set spellsuggest=expr:MySuggest2()
330 call assert_equal([], spellsuggest('baord'))
331
332 " Test for 'spellsuggest' expression returning a list with dict values
333 func! MySuggest3()
334 return [[{}, {}]]
335 endfunc
336 set spellsuggest=expr:MySuggest3()
337 call assert_fails("call spellsuggest('baord')", 'E728:')
338
339 set nospell spellsuggest&
340 delfunc MySuggest
341 delfunc MySuggest2
342 delfunc MySuggest3
343endfunc
344
Bram Moolenaar9049b682018-08-31 22:26:53 +0200345func Test_spellinfo()
346 new
Bram Moolenaarc25e7022019-10-10 14:08:26 +0200347 let runtime = substitute($VIMRUNTIME, '\\', '/', 'g')
Bram Moolenaar9049b682018-08-31 22:26:53 +0200348
349 set enc=latin1 spell spelllang=en
Bram Moolenaarc25e7022019-10-10 14:08:26 +0200350 call assert_match("^\nfile: " .. runtime .. "/spell/en.latin1.spl\n$", execute('spellinfo'))
Bram Moolenaar9049b682018-08-31 22:26:53 +0200351
352 set enc=cp1250 spell spelllang=en
Bram Moolenaarc25e7022019-10-10 14:08:26 +0200353 call assert_match("^\nfile: " .. runtime .. "/spell/en.ascii.spl\n$", execute('spellinfo'))
Bram Moolenaar9049b682018-08-31 22:26:53 +0200354
Bram Moolenaar30276f22019-01-24 17:59:39 +0100355 set enc=utf-8 spell spelllang=en
Bram Moolenaarc25e7022019-10-10 14:08:26 +0200356 call assert_match("^\nfile: " .. runtime .. "/spell/en.utf-8.spl\n$", execute('spellinfo'))
Bram Moolenaar9049b682018-08-31 22:26:53 +0200357
358 set enc=latin1 spell spelllang=en_us,en_nz
359 call assert_match("^\n" .
Bram Moolenaarc25e7022019-10-10 14:08:26 +0200360 \ "file: " .. runtime .. "/spell/en.latin1.spl\n" .
361 \ "file: " .. runtime.. "/spell/en.latin1.spl\n$", execute('spellinfo'))
Bram Moolenaar9049b682018-08-31 22:26:53 +0200362
363 set spell spelllang=
364 call assert_fails('spellinfo', 'E756:')
365
366 set nospell spelllang=en
367 call assert_fails('spellinfo', 'E756:')
368
Bram Moolenaar8f130ed2019-04-10 22:15:19 +0200369 call assert_fails('set spelllang=foo/bar', 'E474:')
370 call assert_fails('set spelllang=foo\ bar', 'E474:')
371 call assert_fails("set spelllang=foo\\\nbar", 'E474:')
372 call assert_fails("set spelllang=foo\\\rbar", 'E474:')
373 call assert_fails("set spelllang=foo+bar", 'E474:')
374
Bram Moolenaar9049b682018-08-31 22:26:53 +0200375 set enc& spell& spelllang&
376 bwipe
377endfunc
378
Bram Moolenaard2c061d2017-06-22 21:42:49 +0200379func Test_zz_basic()
380 call LoadAffAndDic(g:test_data_aff1, g:test_data_dic1)
381 call RunGoodBad("wrong OK puts. Test the end",
382 \ "bad: inputs comment ok Ok. test d\xE9\xF4l end the",
383 \["Comment", "deol", "d\xE9\xF4r", "input", "OK", "output", "outputs", "outtest", "put", "puts",
384 \ "test", "testen", "testn", "the end", "uk", "wrong"],
385 \[
386 \ ["bad", ["put", "uk", "OK"]],
387 \ ["inputs", ["input", "puts", "outputs"]],
388 \ ["comment", ["Comment", "outtest", "the end"]],
389 \ ["ok", ["OK", "uk", "put"]],
390 \ ["Ok", ["OK", "Uk", "Put"]],
391 \ ["test", ["Test", "testn", "testen"]],
392 \ ["d\xE9\xF4l", ["deol", "d\xE9\xF4r", "test"]],
393 \ ["end", ["put", "uk", "test"]],
394 \ ["the", ["put", "uk", "test"]],
395 \ ]
396 \ )
397
398 call assert_equal("gebletegek", soundfold('goobledygoook'))
Bram Moolenaarf6ed61e2019-09-07 19:05:09 +0200399 call assert_equal("kepereneven", 'kóopërÿnôven'->soundfold())
Bram Moolenaard2c061d2017-06-22 21:42:49 +0200400 call assert_equal("everles gesvets etele", soundfold('oeverloos gezwets edale'))
401endfunc
402
403" Postponed prefixes
404func Test_zz_prefixes()
405 call LoadAffAndDic(g:test_data_aff2, g:test_data_dic1)
406 call RunGoodBad("puts",
407 \ "bad: inputs comment ok Ok end the. test d\xE9\xF4l",
408 \ ["Comment", "deol", "d\xE9\xF4r", "OK", "put", "input", "output", "puts", "outputs", "test", "outtest", "testen", "testn", "the end", "uk", "wrong"],
409 \ [
410 \ ["bad", ["put", "uk", "OK"]],
411 \ ["inputs", ["input", "puts", "outputs"]],
412 \ ["comment", ["Comment"]],
413 \ ["ok", ["OK", "uk", "put"]],
414 \ ["Ok", ["OK", "Uk", "Put"]],
415 \ ["end", ["put", "uk", "deol"]],
416 \ ["the", ["put", "uk", "test"]],
417 \ ["test", ["Test", "testn", "testen"]],
418 \ ["d\xE9\xF4l", ["deol", "d\xE9\xF4r", "test"]],
419 \ ])
420endfunc
421
422"Compound words
423func Test_zz_compound()
424 call LoadAffAndDic(g:test_data_aff3, g:test_data_dic3)
425 call RunGoodBad("foo m\xEF foobar foofoobar barfoo barbarfoo",
426 \ "bad: bar la foom\xEF barm\xEF m\xEFfoo m\xEFbar m\xEFm\xEF lala m\xEFla lam\xEF foola labar",
427 \ ["foo", "m\xEF"],
428 \ [
429 \ ["bad", ["foo", "m\xEF"]],
430 \ ["bar", ["barfoo", "foobar", "foo"]],
431 \ ["la", ["m\xEF", "foo"]],
432 \ ["foom\xEF", ["foo m\xEF", "foo", "foofoo"]],
433 \ ["barm\xEF", ["barfoo", "m\xEF", "barbar"]],
434 \ ["m\xEFfoo", ["m\xEF foo", "foo", "foofoo"]],
435 \ ["m\xEFbar", ["foobar", "barbar", "m\xEF"]],
436 \ ["m\xEFm\xEF", ["m\xEF m\xEF", "m\xEF"]],
437 \ ["lala", []],
438 \ ["m\xEFla", ["m\xEF", "m\xEF m\xEF"]],
439 \ ["lam\xEF", ["m\xEF", "m\xEF m\xEF"]],
440 \ ["foola", ["foo", "foobar", "foofoo"]],
441 \ ["labar", ["barbar", "foobar"]],
442 \ ])
443
444 call LoadAffAndDic(g:test_data_aff4, g:test_data_dic4)
445 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",
446 \ "bad: wordutilize pro borkborkborkborkborkbork tomatotomatotomato endstart endend startstart wordend wordstart preborkprebork preborkpreborkbork startwordwordwordwordend borkpreborkpreborkbork utilsbork startnouword",
447 \ ["bork", "prebork", "end", "pro-ok", "start", "tomato", "util", "utilize", "utils", "word", "nouword"],
448 \ [
449 \ ["bad", ["end", "bork", "word"]],
450 \ ["wordutilize", ["word utilize", "wordutils", "wordutil"]],
451 \ ["pro", ["bork", "word", "end"]],
452 \ ["borkborkborkborkborkbork", ["bork borkborkborkborkbork", "borkbork borkborkborkbork", "borkborkbork borkborkbork"]],
453 \ ["tomatotomatotomato", ["tomato tomatotomato", "tomatotomato tomato", "tomato tomato tomato"]],
454 \ ["endstart", ["end start", "start"]],
455 \ ["endend", ["end end", "end"]],
456 \ ["startstart", ["start start"]],
457 \ ["wordend", ["word end", "word", "wordword"]],
458 \ ["wordstart", ["word start", "bork start"]],
459 \ ["preborkprebork", ["prebork prebork", "preborkbork", "preborkborkbork"]],
460 \ ["preborkpreborkbork", ["prebork preborkbork", "preborkborkbork", "preborkborkborkbork"]],
461 \ ["startwordwordwordwordend", ["startwordwordwordword end", "startwordwordwordword", "start wordwordwordword end"]],
462 \ ["borkpreborkpreborkbork", ["bork preborkpreborkbork", "bork prebork preborkbork", "bork preborkprebork bork"]],
463 \ ["utilsbork", ["utilbork", "utils bork", "util bork"]],
464 \ ["startnouword", ["start nouword", "startword", "startborkword"]],
465 \ ])
466
467endfunc
468
469"Test affix flags with two characters
470func Test_zz_affix()
471 call LoadAffAndDic(g:test_data_aff5, g:test_data_dic5)
472 call RunGoodBad("fooa1 fooa\xE9 bar prebar barbork prebarbork startprebar start end startend startmiddleend nouend",
473 \ "bad: foo fooa2 prabar probarbirk middle startmiddle middleend endstart startprobar startnouend",
474 \ ["bar", "barbork", "end", "fooa1", "fooa\xE9", "nouend", "prebar", "prebarbork", "start"],
475 \ [
476 \ ["bad", ["bar", "end", "fooa1"]],
477 \ ["foo", ["fooa1", "fooa\xE9", "bar"]],
478 \ ["fooa2", ["fooa1", "fooa\xE9", "bar"]],
479 \ ["prabar", ["prebar", "bar", "bar bar"]],
480 \ ["probarbirk", ["prebarbork"]],
481 \ ["middle", []],
482 \ ["startmiddle", ["startmiddleend", "startmiddlebar"]],
483 \ ["middleend", []],
484 \ ["endstart", ["end start", "start"]],
485 \ ["startprobar", ["startprebar", "start prebar", "startbar"]],
486 \ ["startnouend", ["start nouend", "startend"]],
487 \ ])
488
489 call LoadAffAndDic(g:test_data_aff6, g:test_data_dic6)
490 call RunGoodBad("meea1 meea\xE9 bar prebar barbork prebarbork leadprebar lead end leadend leadmiddleend",
491 \ "bad: mee meea2 prabar probarbirk middle leadmiddle middleend endlead leadprobar",
492 \ ["bar", "barbork", "end", "lead", "meea1", "meea\xE9", "prebar", "prebarbork"],
493 \ [
494 \ ["bad", ["bar", "end", "lead"]],
495 \ ["mee", ["meea1", "meea\xE9", "bar"]],
496 \ ["meea2", ["meea1", "meea\xE9", "lead"]],
497 \ ["prabar", ["prebar", "bar", "leadbar"]],
498 \ ["probarbirk", ["prebarbork"]],
499 \ ["middle", []],
500 \ ["leadmiddle", ["leadmiddleend", "leadmiddlebar"]],
501 \ ["middleend", []],
502 \ ["endlead", ["end lead", "lead", "end end"]],
503 \ ["leadprobar", ["leadprebar", "lead prebar", "leadbar"]],
504 \ ])
505
506 call LoadAffAndDic(g:test_data_aff7, g:test_data_dic7)
Bram Moolenaar3d2a47c2019-11-07 20:48:42 +0100507 call RunGoodBad("meea1 meezero meea\xE9 bar prebar barmeat prebarmeat leadprebar lead tail leadtail leadmiddletail",
Bram Moolenaard2c061d2017-06-22 21:42:49 +0200508 \ "bad: mee meea2 prabar probarmaat middle leadmiddle middletail taillead leadprobar",
Bram Moolenaar3d2a47c2019-11-07 20:48:42 +0100509 \ ["bar", "barmeat", "lead", "meea1", "meea\xE9", "meezero", "prebar", "prebarmeat", "tail"],
Bram Moolenaard2c061d2017-06-22 21:42:49 +0200510 \ [
511 \ ["bad", ["bar", "lead", "tail"]],
512 \ ["mee", ["meea1", "meea\xE9", "bar"]],
513 \ ["meea2", ["meea1", "meea\xE9", "lead"]],
514 \ ["prabar", ["prebar", "bar", "leadbar"]],
515 \ ["probarmaat", ["prebarmeat"]],
516 \ ["middle", []],
517 \ ["leadmiddle", ["leadmiddlebar"]],
518 \ ["middletail", []],
519 \ ["taillead", ["tail lead", "tail"]],
520 \ ["leadprobar", ["leadprebar", "lead prebar", "leadbar"]],
521 \ ])
522endfunc
523
524func Test_zz_NOSLITSUGS()
525 call LoadAffAndDic(g:test_data_aff8, g:test_data_dic8)
526 call RunGoodBad("foo bar faabar", "bad: foobar barfoo",
527 \ ["bar", "faabar", "foo"],
528 \ [
529 \ ["bad", ["bar", "foo"]],
530 \ ["foobar", ["faabar", "foo bar", "bar"]],
531 \ ["barfoo", ["bar foo", "bar", "foo"]],
532 \ ])
533endfunc
534
535" Numbers
536func Test_zz_Numbers()
537 call LoadAffAndDic(g:test_data_aff9, g:test_data_dic9)
538 call RunGoodBad("0b1011 0777 1234 0x01ff", "",
539 \ ["bar", "foo"],
540 \ [
541 \ ])
542endfunc
543
Bram Moolenaar37ff4cf2019-11-17 20:10:20 +0100544" Affix flags
545func Test_zz_affix_flags()
546 call LoadAffAndDic(g:test_data_aff10, g:test_data_dic10)
547 call RunGoodBad("drink drinkable drinkables drinktable drinkabletable",
548 \ "bad: drinks drinkstable drinkablestable",
549 \ ["drink", "drinkable", "drinkables", "table"],
550 \ [['bad', []],
551 \ ['drinks', ['drink']],
552 \ ['drinkstable', ['drinktable', 'drinkable', 'drink table']],
553 \ ['drinkablestable', ['drinkabletable', 'drinkables table', 'drinkable table']],
554 \ ])
555endfunc
556
Bram Moolenaard2c061d2017-06-22 21:42:49 +0200557function FirstSpellWord()
558 call feedkeys("/^start:\n", 'tx')
559 normal ]smm
560 let [str, a] = spellbadword()
561 return str
562endfunc
563
564function SecondSpellWord()
565 normal `m]s
566 let [str, a] = spellbadword()
567 return str
568endfunc
569
570"Test with SAL instead of SOFO items; test automatic reloading
571func Test_zz_sal_and_addition()
572 set enc=latin1
573 set spellfile=
Bram Moolenaar1a0f2002017-07-28 15:38:10 +0200574 call writefile(g:test_data_dic1, "Xtest.dic")
Bram Moolenaard2c061d2017-06-22 21:42:49 +0200575 call writefile(g:test_data_aff_sal, "Xtest.aff")
576 mkspell! Xtest Xtest
577 set spl=Xtest.latin1.spl spell
578 call assert_equal('kbltykk', soundfold('goobledygoook'))
579 call assert_equal('kprnfn', soundfold('kóopërÿnôven'))
580 call assert_equal('*fls kswts tl', soundfold('oeverloos gezwets edale'))
581
582 "also use an addition file
583 call writefile(["/regions=usgbnz", "elequint/2", "elekwint/3"], "Xtest.latin1.add")
584 mkspell! Xtest.latin1.add.spl Xtest.latin1.add
585
586 bwipe!
587 call setline(1, ["start: elequint test elekwint test elekwent asdf"])
588
589 set spellfile=Xtest.latin1.add
590 call assert_equal("elekwent", FirstSpellWord())
591
592 set spl=Xtest_us.latin1.spl
593 call assert_equal("elequint", FirstSpellWord())
594 call assert_equal("elekwint", SecondSpellWord())
595
596 set spl=Xtest_gb.latin1.spl
597 call assert_equal("elekwint", FirstSpellWord())
598 call assert_equal("elekwent", SecondSpellWord())
599
600 set spl=Xtest_nz.latin1.spl
601 call assert_equal("elequint", FirstSpellWord())
602 call assert_equal("elekwent", SecondSpellWord())
603
604 set spl=Xtest_ca.latin1.spl
605 call assert_equal("elequint", FirstSpellWord())
606 call assert_equal("elekwint", SecondSpellWord())
607endfunc
608
Bram Moolenaar862f1e12019-04-10 22:33:41 +0200609func Test_spellfile_value()
610 set spellfile=Xdir/Xtest.latin1.add
611 set spellfile=Xdir/Xtest.utf-8.add,Xtest_other.add
612endfunc
613
Bram Moolenaaree03b942017-10-27 00:57:05 +0200614func Test_region_error()
615 messages clear
616 call writefile(["/regions=usgbnz", "elequint/0"], "Xtest.latin1.add")
617 mkspell! Xtest.latin1.add.spl Xtest.latin1.add
618 call assert_match('Invalid region nr in Xtest.latin1.add line 2: 0', execute('messages'))
619 call delete('Xtest.latin1.add')
620 call delete('Xtest.latin1.add.spl')
621endfunc
622
Bram Moolenaard2c061d2017-06-22 21:42:49 +0200623" Check using z= in new buffer (crash fixed by patch 7.4a.028).
624func Test_zeq_crash()
625 new
626 set maxmem=512 spell
627 call feedkeys('iasdz=:\"', 'tx')
628
629 bwipe!
630endfunc
631
Bram Moolenaar152e79e2020-06-10 15:32:08 +0200632" Check that z= works even when 'nospell' is set. This test uses one of the
633" tests in Test_spellsuggest_option_number() just to verify that z= basically
634" works and that "E756: Spell checking is not enabled" is not generated.
635func Test_zeq_nospell()
636 new
637 set nospell spellsuggest=1,best
638 call setline(1, 'A baord')
639 try
640 norm $1z=
641 call assert_equal('A board', getline(1))
642 catch
643 call assert_report("Caught exception: " . v:exception)
644 endtry
645 set spell& spellsuggest&
646 bwipe!
647endfunc
648
649" Check that "E756: Spell checking is not possible" is reported when z= is
650" executed and 'spelllang' is empty.
651func Test_zeq_no_spelllang()
652 new
653 set spelllang= spellsuggest=1,best
654 call setline(1, 'A baord')
655 call assert_fails('normal $1z=', 'E756:')
656 set spelllang& spellsuggest&
657 bwipe!
658endfunc
659
Bram Moolenaar5bcc5a12019-08-06 22:48:02 +0200660" Check handling a word longer than MAXWLEN.
661func Test_spell_long_word()
662 set enc=utf-8
663 new
664 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")
665 set spell spelllang=en
666 redraw
667 redraw!
668 bwipe!
669 set nospell
670endfunc
671
Bram Moolenaard2c061d2017-06-22 21:42:49 +0200672func LoadAffAndDic(aff_contents, dic_contents)
673 set enc=latin1
674 set spellfile=
675 call writefile(a:aff_contents, "Xtest.aff")
676 call writefile(a:dic_contents, "Xtest.dic")
677 " Generate a .spl file from a .dic and .aff file.
678 mkspell! Xtest Xtest
679 " use that spell file
680 set spl=Xtest.latin1.spl spell
681endfunc
682
683func ListWords()
684 spelldump
685 %yank
686 quit
687 return split(@", "\n")
688endfunc
689
690func TestGoodBadBase()
691 exe '1;/^good:'
692 normal 0f:]s
693 let prevbad = ''
694 let result = []
695 while 1
696 let [bad, a] = spellbadword()
697 if bad == '' || bad == prevbad || bad == 'badend'
698 break
699 endif
700 let prevbad = bad
Bram Moolenaarf6ed61e2019-09-07 19:05:09 +0200701 let lst = bad->spellsuggest(3)
Bram Moolenaard2c061d2017-06-22 21:42:49 +0200702 normal mm
703
704 call add(result, [bad, lst])
705 normal `m]s
706 endwhile
707 return result
708endfunc
709
710func RunGoodBad(good, bad, expected_words, expected_bad_words)
711 bwipe!
712 call setline(1, ["good: ", a:good, a:bad, " badend "])
713 let words = ListWords()
714 call assert_equal(a:expected_words, words[1:-1])
715 let bad_words = TestGoodBadBase()
716 call assert_equal(a:expected_bad_words, bad_words)
717 bwipe!
718endfunc
719
Bram Moolenaar7751d1d2019-10-18 20:37:08 +0200720func Test_spell_screendump()
721 CheckScreendump
722
723 let lines =<< trim END
724 call setline(1, [
725 \ "This is some text without any spell errors. Everything",
726 \ "should just be black, nothing wrong here.",
727 \ "",
728 \ "This line has a sepll error. and missing caps.",
729 \ "And and this is the the duplication.",
730 \ "with missing caps here.",
731 \ ])
732 set spell spelllang=en_nz
733 END
734 call writefile(lines, 'XtestSpell')
735 let buf = RunVimInTerminal('-S XtestSpell', {'rows': 8})
736 call VerifyScreenDump(buf, 'Test_spell_1', {})
737
738 " clean up
739 call StopVimInTerminal(buf)
740 call delete('XtestSpell')
741endfunc
742
Bram Moolenaard2c061d2017-06-22 21:42:49 +0200743let g:test_data_aff1 = [
744 \"SET ISO8859-1",
745 \"TRY esianrtolcdugmphbyfvkwjkqxz-\xEB\xE9\xE8\xEA\xEF\xEE\xE4\xE0\xE2\xF6\xFC\xFB'ESIANRTOLCDUGMPHBYFVKWJKQXZ",
746 \"",
747 \"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",
748 \"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",
749 \"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",
750 \"",
751 \"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",
752 \"SOFOTO ebctefghejklnnepkrstevvkesebctefghejklnnepkrstevvkeseeeeeeeceeeeeeeedneeeeeeeeeeepseeeeeeeeceeeeeeeedneeeeeeeeeeep?",
753 \"",
754 \"MIDWORD\t'-",
755 \"",
756 \"KEP =",
757 \"RAR ?",
758 \"BAD !",
759 \"",
760 \"PFX I N 1",
761 \"PFX I 0 in .",
762 \"",
763 \"PFX O Y 1",
764 \"PFX O 0 out .",
765 \"",
766 \"SFX S Y 2",
767 \"SFX S 0 s [^s]",
768 \"SFX S 0 es s",
769 \"",
770 \"SFX N N 3",
771 \"SFX N 0 en [^n]",
772 \"SFX N 0 nen n",
773 \"SFX N 0 n .",
774 \"",
775 \"REP 3",
776 \"REP g ch",
777 \"REP ch g",
778 \"REP svp s.v.p.",
779 \"",
780 \"MAP 9",
781 \"MAP a\xE0\xE1\xE2\xE3\xE4\xE5",
782 \"MAP e\xE8\xE9\xEA\xEB",
783 \"MAP i\xEC\xED\xEE\xEF",
784 \"MAP o\xF2\xF3\xF4\xF5\xF6",
785 \"MAP u\xF9\xFA\xFB\xFC",
786 \"MAP n\xF1",
787 \"MAP c\xE7",
788 \"MAP y\xFF\xFD",
789 \"MAP s\xDF",
790 \ ]
791let g:test_data_dic1 = [
792 \"123456",
793 \"test/NO",
794 \"# comment",
795 \"wrong",
796 \"Comment",
797 \"OK",
798 \"uk",
799 \"put/ISO",
800 \"the end",
801 \"deol",
802 \"d\xE9\xF4r",
803 \ ]
804let g:test_data_aff2 = [
805 \"SET ISO8859-1",
806 \"",
807 \"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",
808 \"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",
809 \"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",
810 \"",
811 \"PFXPOSTPONE",
812 \"",
813 \"MIDWORD\t'-",
814 \"",
815 \"KEP =",
816 \"RAR ?",
817 \"BAD !",
818 \"",
819 \"PFX I N 1",
820 \"PFX I 0 in .",
821 \"",
822 \"PFX O Y 1",
823 \"PFX O 0 out [a-z]",
824 \"",
825 \"SFX S Y 2",
826 \"SFX S 0 s [^s]",
827 \"SFX S 0 es s",
828 \"",
829 \"SFX N N 3",
830 \"SFX N 0 en [^n]",
831 \"SFX N 0 nen n",
832 \"SFX N 0 n .",
833 \"",
834 \"REP 3",
835 \"REP g ch",
836 \"REP ch g",
837 \"REP svp s.v.p.",
838 \"",
839 \"MAP 9",
840 \"MAP a\xE0\xE1\xE2\xE3\xE4\xE5",
841 \"MAP e\xE8\xE9\xEA\xEB",
842 \"MAP i\xEC\xED\xEE\xEF",
843 \"MAP o\xF2\xF3\xF4\xF5\xF6",
844 \"MAP u\xF9\xFA\xFB\xFC",
845 \"MAP n\xF1",
846 \"MAP c\xE7",
847 \"MAP y\xFF\xFD",
848 \"MAP s\xDF",
849 \ ]
850let g:test_data_aff3 = [
851 \"SET ISO8859-1",
852 \"",
853 \"COMPOUNDMIN 3",
854 \"COMPOUNDRULE m*",
855 \"NEEDCOMPOUND x",
856 \ ]
857let g:test_data_dic3 = [
858 \"1234",
859 \"foo/m",
860 \"bar/mx",
861 \"m\xEF/m",
862 \"la/mx",
863 \ ]
864let g:test_data_aff4 = [
865 \"SET ISO8859-1",
866 \"",
867 \"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",
868 \"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",
869 \"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",
870 \"",
871 \"COMPOUNDRULE m+",
872 \"COMPOUNDRULE sm*e",
873 \"COMPOUNDRULE sm+",
874 \"COMPOUNDMIN 3",
875 \"COMPOUNDWORDMAX 3",
876 \"COMPOUNDFORBIDFLAG t",
877 \"",
878 \"COMPOUNDSYLMAX 5",
879 \"SYLLABLE a\xE1e\xE9i\xEDo\xF3\xF6\xF5u\xFA\xFC\xFBy/aa/au/ea/ee/ei/ie/oa/oe/oo/ou/uu/ui",
880 \"",
881 \"MAP 9",
882 \"MAP a\xE0\xE1\xE2\xE3\xE4\xE5",
883 \"MAP e\xE8\xE9\xEA\xEB",
884 \"MAP i\xEC\xED\xEE\xEF",
885 \"MAP o\xF2\xF3\xF4\xF5\xF6",
886 \"MAP u\xF9\xFA\xFB\xFC",
887 \"MAP n\xF1",
888 \"MAP c\xE7",
889 \"MAP y\xFF\xFD",
890 \"MAP s\xDF",
891 \"",
892 \"NEEDAFFIX x",
893 \"",
894 \"PFXPOSTPONE",
895 \"",
896 \"MIDWORD '-",
897 \"",
898 \"SFX q N 1",
899 \"SFX q 0 -ok .",
900 \"",
901 \"SFX a Y 2",
902 \"SFX a 0 s .",
903 \"SFX a 0 ize/t .",
904 \"",
905 \"PFX p N 1",
906 \"PFX p 0 pre .",
907 \"",
908 \"PFX P N 1",
909 \"PFX P 0 nou .",
910 \ ]
911let g:test_data_dic4 = [
912 \"1234",
913 \"word/mP",
914 \"util/am",
915 \"pro/xq",
916 \"tomato/m",
917 \"bork/mp",
918 \"start/s",
919 \"end/e",
920 \ ]
921let g:test_data_aff5 = [
922 \"SET ISO8859-1",
923 \"",
924 \"FLAG long",
925 \"",
926 \"NEEDAFFIX !!",
927 \"",
928 \"COMPOUNDRULE ssmm*ee",
929 \"",
930 \"NEEDCOMPOUND xx",
931 \"COMPOUNDPERMITFLAG pp",
932 \"",
933 \"SFX 13 Y 1",
934 \"SFX 13 0 bork .",
935 \"",
936 \"SFX a1 Y 1",
937 \"SFX a1 0 a1 .",
938 \"",
939 \"SFX a\xE9 Y 1",
940 \"SFX a\xE9 0 a\xE9 .",
941 \"",
942 \"PFX zz Y 1",
943 \"PFX zz 0 pre/pp .",
944 \"",
945 \"PFX yy Y 1",
946 \"PFX yy 0 nou .",
947 \ ]
948let g:test_data_dic5 = [
949 \"1234",
950 \"foo/a1a\xE9!!",
951 \"bar/zz13ee",
952 \"start/ss",
953 \"end/eeyy",
954 \"middle/mmxx",
955 \ ]
956let g:test_data_aff6 = [
957 \"SET ISO8859-1",
958 \"",
959 \"FLAG caplong",
960 \"",
961 \"NEEDAFFIX A!",
962 \"",
963 \"COMPOUNDRULE sMm*Ee",
964 \"",
965 \"NEEDCOMPOUND Xx",
966 \"",
967 \"COMPOUNDPERMITFLAG p",
968 \"",
969 \"SFX N3 Y 1",
970 \"SFX N3 0 bork .",
971 \"",
972 \"SFX A1 Y 1",
973 \"SFX A1 0 a1 .",
974 \"",
975 \"SFX A\xE9 Y 1",
976 \"SFX A\xE9 0 a\xE9 .",
977 \"",
978 \"PFX Zz Y 1",
979 \"PFX Zz 0 pre/p .",
980 \ ]
981let g:test_data_dic6 = [
982 \"1234",
983 \"mee/A1A\xE9A!",
984 \"bar/ZzN3Ee",
985 \"lead/s",
986 \"end/Ee",
987 \"middle/MmXx",
988 \ ]
989let g:test_data_aff7 = [
990 \"SET ISO8859-1",
991 \"",
992 \"FLAG num",
993 \"",
994 \"NEEDAFFIX 9999",
995 \"",
996 \"COMPOUNDRULE 2,77*123",
997 \"",
998 \"NEEDCOMPOUND 1",
999 \"COMPOUNDPERMITFLAG 432",
1000 \"",
1001 \"SFX 61003 Y 1",
1002 \"SFX 61003 0 meat .",
1003 \"",
Bram Moolenaar3d2a47c2019-11-07 20:48:42 +01001004 \"SFX 0 Y 1",
1005 \"SFX 0 0 zero .",
1006 \"",
Bram Moolenaard2c061d2017-06-22 21:42:49 +02001007 \"SFX 391 Y 1",
1008 \"SFX 391 0 a1 .",
1009 \"",
1010 \"SFX 111 Y 1",
1011 \"SFX 111 0 a\xE9 .",
1012 \"",
1013 \"PFX 17 Y 1",
1014 \"PFX 17 0 pre/432 .",
1015 \ ]
1016let g:test_data_dic7 = [
1017 \"1234",
Bram Moolenaar3d2a47c2019-11-07 20:48:42 +01001018 \"mee/0,391,111,9999",
Bram Moolenaard2c061d2017-06-22 21:42:49 +02001019 \"bar/17,61003,123",
1020 \"lead/2",
1021 \"tail/123",
1022 \"middle/77,1",
1023 \ ]
1024let g:test_data_aff8 = [
1025 \"SET ISO8859-1",
1026 \"",
1027 \"NOSPLITSUGS",
1028 \ ]
1029let g:test_data_dic8 = [
1030 \"1234",
1031 \"foo",
1032 \"bar",
1033 \"faabar",
1034 \ ]
1035let g:test_data_aff9 = [
1036 \ ]
1037let g:test_data_dic9 = [
1038 \"1234",
1039 \"foo",
1040 \"bar",
1041 \ ]
Bram Moolenaar37ff4cf2019-11-17 20:10:20 +01001042let g:test_data_aff10 = [
1043 \"COMPOUNDRULE se",
1044 \"COMPOUNDPERMITFLAG p",
1045 \"",
1046 \"SFX A Y 1",
1047 \"SFX A 0 able/Mp .",
1048 \"",
1049 \"SFX M Y 1",
1050 \"SFX M 0 s .",
1051 \ ]
1052let g:test_data_dic10 = [
1053 \"1234",
1054 \"drink/As",
1055 \"table/e",
1056 \ ]
Bram Moolenaard2c061d2017-06-22 21:42:49 +02001057let g:test_data_aff_sal = [
1058 \"SET ISO8859-1",
1059 \"TRY esianrtolcdugmphbyfvkwjkqxz-\xEB\xE9\xE8\xEA\xEF\xEE\xE4\xE0\xE2\xF6\xFC\xFB'ESIANRTOLCDUGMPHBYFVKWJKQXZ",
1060 \"",
1061 \"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",
1062 \"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",
1063 \"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",
1064 \"",
1065 \"MIDWORD\t'-",
1066 \"",
1067 \"KEP =",
1068 \"RAR ?",
1069 \"BAD !",
1070 \"",
1071 \"PFX I N 1",
1072 \"PFX I 0 in .",
1073 \"",
1074 \"PFX O Y 1",
1075 \"PFX O 0 out .",
1076 \"",
1077 \"SFX S Y 2",
1078 \"SFX S 0 s [^s]",
1079 \"SFX S 0 es s",
1080 \"",
1081 \"SFX N N 3",
1082 \"SFX N 0 en [^n]",
1083 \"SFX N 0 nen n",
1084 \"SFX N 0 n .",
1085 \"",
1086 \"REP 3",
1087 \"REP g ch",
1088 \"REP ch g",
1089 \"REP svp s.v.p.",
1090 \"",
1091 \"MAP 9",
1092 \"MAP a\xE0\xE1\xE2\xE3\xE4\xE5",
1093 \"MAP e\xE8\xE9\xEA\xEB",
1094 \"MAP i\xEC\xED\xEE\xEF",
1095 \"MAP o\xF2\xF3\xF4\xF5\xF6",
1096 \"MAP u\xF9\xFA\xFB\xFC",
1097 \"MAP n\xF1",
1098 \"MAP c\xE7",
1099 \"MAP y\xFF\xFD",
1100 \"MAP s\xDF",
1101 \"",
1102 \"SAL AH(AEIOUY)-^ *H",
1103 \"SAL AR(AEIOUY)-^ *R",
1104 \"SAL A(HR)^ *",
1105 \"SAL A^ *",
1106 \"SAL AH(AEIOUY)- H",
1107 \"SAL AR(AEIOUY)- R",
1108 \"SAL A(HR) _",
1109 \"SAL \xC0^ *",
1110 \"SAL \xC5^ *",
1111 \"SAL BB- _",
1112 \"SAL B B",
1113 \"SAL CQ- _",
1114 \"SAL CIA X",
1115 \"SAL CH X",
1116 \"SAL C(EIY)- S",
1117 \"SAL CK K",
1118 \"SAL COUGH^ KF",
1119 \"SAL CC< C",
1120 \"SAL C K",
1121 \"SAL DG(EIY) K",
1122 \"SAL DD- _",
1123 \"SAL D T",
1124 \"SAL \xC9< E",
1125 \"SAL EH(AEIOUY)-^ *H",
1126 \"SAL ER(AEIOUY)-^ *R",
1127 \"SAL E(HR)^ *",
1128 \"SAL ENOUGH^$ *NF",
1129 \"SAL E^ *",
1130 \"SAL EH(AEIOUY)- H",
1131 \"SAL ER(AEIOUY)- R",
1132 \"SAL E(HR) _",
1133 \"SAL FF- _",
1134 \"SAL F F",
1135 \"SAL GN^ N",
1136 \"SAL GN$ N",
1137 \"SAL GNS$ NS",
1138 \"SAL GNED$ N",
1139 \"SAL GH(AEIOUY)- K",
1140 \"SAL GH _",
1141 \"SAL GG9 K",
1142 \"SAL G K",
1143 \"SAL H H",
1144 \"SAL IH(AEIOUY)-^ *H",
1145 \"SAL IR(AEIOUY)-^ *R",
1146 \"SAL I(HR)^ *",
1147 \"SAL I^ *",
1148 \"SAL ING6 N",
1149 \"SAL IH(AEIOUY)- H",
1150 \"SAL IR(AEIOUY)- R",
1151 \"SAL I(HR) _",
1152 \"SAL J K",
1153 \"SAL KN^ N",
1154 \"SAL KK- _",
1155 \"SAL K K",
1156 \"SAL LAUGH^ LF",
1157 \"SAL LL- _",
1158 \"SAL L L",
1159 \"SAL MB$ M",
1160 \"SAL MM M",
1161 \"SAL M M",
1162 \"SAL NN- _",
1163 \"SAL N N",
1164 \"SAL OH(AEIOUY)-^ *H",
1165 \"SAL OR(AEIOUY)-^ *R",
1166 \"SAL O(HR)^ *",
1167 \"SAL O^ *",
1168 \"SAL OH(AEIOUY)- H",
1169 \"SAL OR(AEIOUY)- R",
1170 \"SAL O(HR) _",
1171 \"SAL PH F",
1172 \"SAL PN^ N",
1173 \"SAL PP- _",
1174 \"SAL P P",
1175 \"SAL Q K",
1176 \"SAL RH^ R",
1177 \"SAL ROUGH^ RF",
1178 \"SAL RR- _",
1179 \"SAL R R",
1180 \"SAL SCH(EOU)- SK",
1181 \"SAL SC(IEY)- S",
1182 \"SAL SH X",
1183 \"SAL SI(AO)- X",
1184 \"SAL SS- _",
1185 \"SAL S S",
1186 \"SAL TI(AO)- X",
1187 \"SAL TH @",
1188 \"SAL TCH-- _",
1189 \"SAL TOUGH^ TF",
1190 \"SAL TT- _",
1191 \"SAL T T",
1192 \"SAL UH(AEIOUY)-^ *H",
1193 \"SAL UR(AEIOUY)-^ *R",
1194 \"SAL U(HR)^ *",
1195 \"SAL U^ *",
1196 \"SAL UH(AEIOUY)- H",
1197 \"SAL UR(AEIOUY)- R",
1198 \"SAL U(HR) _",
1199 \"SAL V^ W",
1200 \"SAL V F",
1201 \"SAL WR^ R",
1202 \"SAL WH^ W",
1203 \"SAL W(AEIOU)- W",
1204 \"SAL X^ S",
1205 \"SAL X KS",
1206 \"SAL Y(AEIOU)- Y",
1207 \"SAL ZZ- _",
1208 \"SAL Z S",
1209 \ ]
Bram Moolenaar0e05de42020-03-25 22:23:46 +01001210
1211" vim: shiftwidth=2 sts=2 expandtab