blob: 692e191a3cf20884f1158958e21625fdb98c13d4 [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
zeertzjq7002c052024-06-21 07:55:07 +02008source view_util.vim
Bram Moolenaar7751d1d2019-10-18 20:37:08 +02009
Bram Moolenaar1a0f2002017-07-28 15:38:10 +020010func TearDown()
11 set nospell
12 call delete('Xtest.aff')
13 call delete('Xtest.dic')
14 call delete('Xtest.latin1.add')
15 call delete('Xtest.latin1.add.spl')
16 call delete('Xtest.latin1.spl')
17 call delete('Xtest.latin1.sug')
zeertzjq288ed232022-07-04 11:03:07 +010018 " set 'encoding' to clear the word list
19 set encoding=utf-8
Bram Moolenaar1a0f2002017-07-28 15:38:10 +020020endfunc
21
Bram Moolenaard3f78dc2017-02-25 14:21:10 +010022func Test_wrap_search()
23 new
24 call setline(1, ['The', '', 'A plong line with two zpelling mistakes', '', 'End'])
25 set spell wrapscan
26 normal ]s
27 call assert_equal('plong', expand('<cword>'))
28 normal ]s
29 call assert_equal('zpelling', expand('<cword>'))
30 normal ]s
31 call assert_equal('plong', expand('<cword>'))
32 bwipe!
33 set nospell
34endfunc
Bram Moolenaar5b276aa2017-04-22 23:49:52 +020035
Bram Moolenaarb73fa622017-12-21 20:27:47 +010036func Test_curswant()
37 new
38 call setline(1, ['Another plong line', 'abcdefghijklmnopq'])
39 set spell wrapscan
40 normal 0]s
41 call assert_equal('plong', expand('<cword>'))
42 normal j
43 call assert_equal(9, getcurpos()[2])
44 normal 0[s
45 call assert_equal('plong', expand('<cword>'))
46 normal j
47 call assert_equal(9, getcurpos()[2])
48
49 normal 0]S
50 call assert_equal('plong', expand('<cword>'))
51 normal j
52 call assert_equal(9, getcurpos()[2])
53 normal 0[S
54 call assert_equal('plong', expand('<cword>'))
55 normal j
56 call assert_equal(9, getcurpos()[2])
57
58 normal 1G0
59 call assert_equal('plong', spellbadword()[0])
60 normal j
61 call assert_equal(9, getcurpos()[2])
62
63 bwipe!
64 set nospell
65endfunc
66
Bram Moolenaar5b276aa2017-04-22 23:49:52 +020067func Test_z_equal_on_invalid_utf8_word()
68 split
69 set spell
70 call setline(1, "\xff")
71 norm z=
72 set nospell
73 bwipe!
74endfunc
Bram Moolenaar545cb792017-05-23 11:31:22 +020075
Bram Moolenaar156d3912022-06-18 14:09:08 +010076func Test_z_equal_on_single_character()
77 " this was decrementing the index below zero
78 new
79 norm a0\Ê
80 norm zW
81 norm z=
82
83 bwipe!
84endfunc
85
Bram Moolenaar872e4512018-07-20 23:36:26 +020086" Test spellbadword() with argument
87func Test_spellbadword()
88 set spell
89
90 call assert_equal(['bycycle', 'bad'], spellbadword('My bycycle.'))
Bram Moolenaarf6ed61e2019-09-07 19:05:09 +020091 call assert_equal(['another', 'caps'], 'A sentence. another sentence'->spellbadword())
Bram Moolenaar872e4512018-07-20 23:36:26 +020092
Bram Moolenaar362b44b2020-06-10 21:47:00 +020093 call assert_equal(['TheCamelWord', 'bad'], 'TheCamelWord asdf'->spellbadword())
94 set spelloptions=camel
95 call assert_equal(['asdf', 'bad'], 'TheCamelWord asdf'->spellbadword())
96 set spelloptions=
97
Bram Moolenaar872e4512018-07-20 23:36:26 +020098 set spelllang=en
99 call assert_equal(['', ''], spellbadword('centre'))
100 call assert_equal(['', ''], spellbadword('center'))
101 set spelllang=en_us
102 call assert_equal(['centre', 'local'], spellbadword('centre'))
103 call assert_equal(['', ''], spellbadword('center'))
104 set spelllang=en_gb
105 call assert_equal(['', ''], spellbadword('centre'))
106 call assert_equal(['center', 'local'], spellbadword('center'))
107
108 " Create a small word list to test that spellbadword('...')
109 " can return ['...', 'rare'].
110 e Xwords
111 insert
112foo
113foobar/?
114.
115 w!
116 mkspell! Xwords.spl Xwords
117 set spelllang=Xwords.spl
118 call assert_equal(['foobar', 'rare'], spellbadword('foo foobar'))
119
Bram Moolenaar152e79e2020-06-10 15:32:08 +0200120 " Typo should be detected even without the 'spell' option.
Bram Moolenaar872e4512018-07-20 23:36:26 +0200121 set spelllang=en_gb nospell
122 call assert_equal(['', ''], spellbadword('centre'))
Bram Moolenaar152e79e2020-06-10 15:32:08 +0200123 call assert_equal(['bycycle', 'bad'], spellbadword('My bycycle.'))
124 call assert_equal(['another', 'caps'], spellbadword('A sentence. another sentence'))
125
126 set spelllang=
127 call assert_fails("call spellbadword('maxch')", 'E756:')
Bram Moolenaar96fdf432020-09-11 18:11:50 +0200128 call assert_fails("spelldump", 'E756:')
Bram Moolenaar872e4512018-07-20 23:36:26 +0200129
130 call delete('Xwords.spl')
131 call delete('Xwords')
132 set spelllang&
133 set spell&
134endfunc
135
LemonBoyd0874502023-08-27 21:52:27 +0200136func Test_spell_camelcase()
137 set spell spelloptions=camel
138 let words = [
139 \ 'UPPER',
140 \ 'lower',
141 \ 'mixedCase',
142 \ 'HTML',
143 \ 'XMLHttpRequest',
144 \ 'foo123bar',
145 \ '12345678',
146 \ 'HELLO123world',
147 \]
148
149 for word in words
150 call assert_equal(['', ''], spellbadword(word))
151 endfor
152
153 set spell& spelloptions&
154endfunc
155
Bram Moolenaard569a9e2020-09-28 23:13:15 +0200156func Test_spell_file_missing()
157 let s:spell_file_missing = 0
158 augroup TestSpellFileMissing
159 autocmd! SpellFileMissing * let s:spell_file_missing += 1
160 augroup END
161
162 set spell spelllang=ab_cd
163 let messages = GetMessages()
164 call assert_equal('Warning: Cannot find word list "ab.utf-8.spl" or "ab.ascii.spl"', messages[-1])
165 call assert_equal(1, s:spell_file_missing)
166
167 new XTestSpellFileMissing
168 augroup TestSpellFileMissing
169 autocmd! SpellFileMissing * bwipe
170 augroup END
Bram Moolenaar371951d2022-09-28 14:08:23 +0100171 call assert_fails('set spell spelllang=ab_cd', 'E937:')
Bram Moolenaard569a9e2020-09-28 23:13:15 +0200172
Bram Moolenaarfc9f0fd2022-06-15 16:57:44 +0100173 " clean up
174 augroup TestSpellFileMissing
175 autocmd! SpellFileMissing
176 augroup END
Bram Moolenaard569a9e2020-09-28 23:13:15 +0200177 augroup! TestSpellFileMissing
178 unlet s:spell_file_missing
179 set spell& spelllang&
180 %bwipe!
181endfunc
182
Bram Moolenaarc3d27ad2022-11-14 20:52:14 +0000183func Test_spell_file_missing_bwipe()
184 " this was using a window that was wiped out in a SpellFileMissing autocmd
185 set spelllang=xy
186 au SpellFileMissing * n0
187 set spell
188 au SpellFileMissing * bw
189 snext somefile
190
191 au! SpellFileMissing
192 bwipe!
193 set nospell spelllang=en
194endfunc
195
Bram Moolenaarf12f0022020-10-07 12:58:44 +0200196func Test_spelldump()
Bram Moolenaarfc9f0fd2022-06-15 16:57:44 +0100197 " In case the spell file is not found avoid getting the download dialog, we
198 " would get stuck at the prompt.
199 let g:en_not_found = 0
200 augroup TestSpellFileMissing
201 au! SpellFileMissing * let g:en_not_found = 1
202 augroup END
Bram Moolenaarf12f0022020-10-07 12:58:44 +0200203 set spell spelllang=en
204 spellrare! emacs
Bram Moolenaarfc9f0fd2022-06-15 16:57:44 +0100205 if g:en_not_found
206 call assert_report("Could not find English spell file")
207 else
208 spelldump
Bram Moolenaarf12f0022020-10-07 12:58:44 +0200209
Bram Moolenaarfc9f0fd2022-06-15 16:57:44 +0100210 " Check assumption about region: 1: us, 2: au, 3: ca, 4: gb, 5: nz.
211 call assert_equal('/regions=usaucagbnz', getline(1))
212 call assert_notequal(0, search('^theater/1$')) " US English only.
213 call assert_notequal(0, search('^theatre/2345$')) " AU, CA, GB or NZ English.
Bram Moolenaarf12f0022020-10-07 12:58:44 +0200214
Bram Moolenaarfc9f0fd2022-06-15 16:57:44 +0100215 call assert_notequal(0, search('^emacs/?$')) " ? for a rare word.
216 call assert_notequal(0, search('^the the/!$')) " ! for a wrong word.
217 endif
Bram Moolenaarf12f0022020-10-07 12:58:44 +0200218
Bram Moolenaarfc9f0fd2022-06-15 16:57:44 +0100219 " clean up
220 unlet g:en_not_found
221 augroup TestSpellFileMissing
222 autocmd! SpellFileMissing
223 augroup END
224 augroup! TestSpellFileMissing
Bram Moolenaarf12f0022020-10-07 12:58:44 +0200225 bwipe
226 set spell&
227endfunc
228
229func Test_spelldump_bang()
230 new
231 call setline(1, 'This is a sample sentence.')
232 redraw
Bram Moolenaarfc9f0fd2022-06-15 16:57:44 +0100233
234 " In case the spell file is not found avoid getting the download dialog, we
235 " would get stuck at the prompt.
236 let g:en_not_found = 0
237 augroup TestSpellFileMissing
238 au! SpellFileMissing * let g:en_not_found = 1
239 augroup END
240
Bram Moolenaarf12f0022020-10-07 12:58:44 +0200241 set spell
Bram Moolenaarf12f0022020-10-07 12:58:44 +0200242
Bram Moolenaarfc9f0fd2022-06-15 16:57:44 +0100243 if g:en_not_found
244 call assert_report("Could not find English spell file")
245 else
246 redraw
247 spelldump!
Bram Moolenaarf12f0022020-10-07 12:58:44 +0200248
Bram Moolenaarfc9f0fd2022-06-15 16:57:44 +0100249 " :spelldump! includes the number of times a word was found while updating
250 " the screen.
251 " Common word count starts at 10, regular word count starts at 0.
252 call assert_notequal(0, search("^is\t11$")) " common word found once.
253 call assert_notequal(0, search("^the\t10$")) " common word never found.
254 call assert_notequal(0, search("^sample\t1$")) " regular word found once.
255 call assert_equal(0, search("^screen\t")) " regular word never found.
256 endif
257
258 " clean up
259 unlet g:en_not_found
260 augroup TestSpellFileMissing
261 autocmd! SpellFileMissing
262 augroup END
263 augroup! TestSpellFileMissing
Bram Moolenaarf12f0022020-10-07 12:58:44 +0200264 %bwipe!
265 set spell&
266endfunc
267
Bram Moolenaar8c7ad362020-09-27 13:58:38 +0200268func Test_spelllang_inv_region()
269 set spell spelllang=en_xx
270 let messages = GetMessages()
271 call assert_equal('Warning: region xx not supported', messages[-1])
272 set spell& spelllang&
273endfunc
274
275func Test_compl_with_CTRL_X_CTRL_K_using_spell()
276 " When spell checking is enabled and 'dictionary' is empty,
277 " CTRL-X CTRL-K in insert mode completes using the spelling dictionary.
278 new
279 set spell spelllang=en dictionary=
280
281 set ignorecase
282 call feedkeys("Senglis\<c-x>\<c-k>\<esc>", 'tnx')
283 call assert_equal(['English'], getline(1, '$'))
284 call feedkeys("SEnglis\<c-x>\<c-k>\<esc>", 'tnx')
285 call assert_equal(['English'], getline(1, '$'))
286
287 set noignorecase
288 call feedkeys("Senglis\<c-x>\<c-k>\<esc>", 'tnx')
289 call assert_equal(['englis'], getline(1, '$'))
290 call feedkeys("SEnglis\<c-x>\<c-k>\<esc>", 'tnx')
291 call assert_equal(['English'], getline(1, '$'))
292
293 set spelllang=en_us
294 call feedkeys("Stheat\<c-x>\<c-k>\<esc>", 'tnx')
295 call assert_equal(['theater'], getline(1, '$'))
296 set spelllang=en_gb
297 call feedkeys("Stheat\<c-x>\<c-k>\<esc>", 'tnx')
LemonBoye98fb642023-08-15 23:07:55 +0200298 call assert_equal(['theatre'], getline(1, '$'))
Bram Moolenaar8c7ad362020-09-27 13:58:38 +0200299
300 bwipe!
301 set spell& spelllang& dictionary& ignorecase&
302endfunc
303
zeertzjq7002c052024-06-21 07:55:07 +0200304func Test_compl_with_CTRL_X_s()
305 new
306 set spell spelllang=en_us showmode
307 inoremap <buffer><F2> <Cmd>let g:msg = Screenline(&lines)<CR>
308
309 call feedkeys("STheatre\<C-X>s\<F2>\<C-Y>\<Esc>", 'tx')
310 call assert_equal(['Theater'], getline(1, '$'))
311 call assert_match('(^S^N^P)', g:msg)
312
313 bwipe!
314 set spell& spelllang& showmode&
315 unlet g:msg
316endfunc
317
zeertzjq59f70382023-06-06 15:59:59 +0100318func Test_spellrepall()
Bram Moolenaar545cb792017-05-23 11:31:22 +0200319 new
320 set spell
321 call assert_fails('spellrepall', 'E752:')
322 call setline(1, ['A speling mistake. The same speling mistake.',
Bram Moolenaard2c061d2017-06-22 21:42:49 +0200323 \ 'Another speling mistake.'])
Bram Moolenaar545cb792017-05-23 11:31:22 +0200324 call feedkeys(']s1z=', 'tx')
325 call assert_equal('A spelling mistake. The same speling mistake.', getline(1))
326 call assert_equal('Another speling mistake.', getline(2))
327 spellrepall
328 call assert_equal('A spelling mistake. The same spelling mistake.', getline(1))
329 call assert_equal('Another spelling mistake.', getline(2))
330 call assert_fails('spellrepall', 'E753:')
331 set spell&
332 bwipe!
333endfunc
Bram Moolenaard2c061d2017-06-22 21:42:49 +0200334
Bram Moolenaar54e5fed2022-07-04 13:37:07 +0100335func Test_spell_dump_word_length()
336 " this was running over MAXWLEN
337 new
338 noremap 0 0a0zW0000000
339 sil! norm 0z=0
340 sil norm 0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
341 sil! norm 0z=0
342
343 bwipe!
344 nunmap 0
345endfunc
346
Bram Moolenaare9a8d1f2019-12-25 13:36:36 +0100347" Test spellsuggest({word} [, {max} [, {capital}]])
348func Test_spellsuggest()
Bram Moolenaar152e79e2020-06-10 15:32:08 +0200349 " Verify suggestions are given even when spell checking is not enabled.
Bram Moolenaare9a8d1f2019-12-25 13:36:36 +0100350 set nospell
Bram Moolenaar152e79e2020-06-10 15:32:08 +0200351 call assert_equal(['march', 'March'], spellsuggest('marrch', 2))
Bram Moolenaare9a8d1f2019-12-25 13:36:36 +0100352
353 set spell
354
355 " With 1 argument.
Bram Moolenaar76734052019-12-26 14:30:15 +0100356 call assert_equal(['march', 'March'], spellsuggest('marrch')[0:1])
Bram Moolenaare9a8d1f2019-12-25 13:36:36 +0100357
358 " With 2 arguments.
Bram Moolenaar76734052019-12-26 14:30:15 +0100359 call assert_equal(['march', 'March'], spellsuggest('marrch', 2))
Bram Moolenaare9a8d1f2019-12-25 13:36:36 +0100360
361 " With 3 arguments.
Bram Moolenaar76734052019-12-26 14:30:15 +0100362 call assert_equal(['march'], spellsuggest('marrch', 1, 0))
363 call assert_equal(['March'], spellsuggest('marrch', 1, 1))
Bram Moolenaare9a8d1f2019-12-25 13:36:36 +0100364
365 " Test with digits and hyphen.
366 call assert_equal('Carbon-14', spellsuggest('Carbon-15')[0])
367
368 " Comment taken from spellsuggest.c explains the following test cases:
369 "
370 " If there are more UPPER than lower case letters suggest an
371 " ALLCAP word. Otherwise, if the first letter is UPPER then
372 " suggest ONECAP. Exception: "ALl" most likely should be "All",
373 " require three upper case letters.
Bram Moolenaar76734052019-12-26 14:30:15 +0100374 call assert_equal(['THIRD', 'third'], spellsuggest('thIRD', 2))
375 call assert_equal(['third', 'THIRD'], spellsuggest('tHIrd', 2))
376 call assert_equal(['Third'], spellsuggest('THird', 1))
Bram Moolenaare9a8d1f2019-12-25 13:36:36 +0100377 call assert_equal(['All'], spellsuggest('ALl', 1))
378
Dominique Pellef645ee42021-12-05 13:21:18 +0000379 " Special suggestion for repeated 'the the'.
380 call assert_inrange(0, 2, index(spellsuggest('the the', 3), 'the'))
381 call assert_inrange(0, 2, index(spellsuggest('the the', 3), 'the'))
382 call assert_inrange(0, 2, index(spellsuggest('The the', 3), 'The'))
383
Bram Moolenaar0e05de42020-03-25 22:23:46 +0100384 call assert_fails("call spellsuggest('maxch', [])", 'E745:')
385 call assert_fails("call spellsuggest('maxch', 2, [])", 'E745:')
386
Bram Moolenaar152e79e2020-06-10 15:32:08 +0200387 set spelllang=
388 call assert_fails("call spellsuggest('maxch')", 'E756:')
389 set spelllang&
390
Bram Moolenaare9a8d1f2019-12-25 13:36:36 +0100391 set spell&
392endfunc
393
394" Test 'spellsuggest' option with methods fast, best and double.
395func Test_spellsuggest_option_methods()
396 set spell
397
Bram Moolenaar76734052019-12-26 14:30:15 +0100398 for e in ['latin1', 'utf-8']
399 exe 'set encoding=' .. e
Bram Moolenaare9a8d1f2019-12-25 13:36:36 +0100400
Bram Moolenaar76734052019-12-26 14:30:15 +0100401 set spellsuggest=fast
402 call assert_equal(['Stick', 'Stitch'], spellsuggest('Stich', 2), e)
Bram Moolenaare9a8d1f2019-12-25 13:36:36 +0100403
Bram Moolenaar76734052019-12-26 14:30:15 +0100404 " With best or double option, "Stitch" should become the top suggestion
405 " because of better phonetic matching.
406 set spellsuggest=best
407 call assert_equal(['Stitch', 'Stick'], spellsuggest('Stich', 2), e)
Bram Moolenaare9a8d1f2019-12-25 13:36:36 +0100408
Bram Moolenaar76734052019-12-26 14:30:15 +0100409 set spellsuggest=double
410 call assert_equal(['Stitch', 'Stick'], spellsuggest('Stich', 2), e)
411 endfor
412
413 set spell& spellsuggest& encoding&
Bram Moolenaare9a8d1f2019-12-25 13:36:36 +0100414endfunc
415
416" Test 'spellsuggest' option with value file:{filename}
417func Test_spellsuggest_option_file()
418 set spell spellsuggest=file:Xspellsuggest
419 call writefile(['emacs/vim',
420 \ 'theribal/terrible',
421 \ 'teribal/terrrible',
422 \ 'terribal'],
423 \ 'Xspellsuggest')
424
425 call assert_equal(['vim'], spellsuggest('emacs', 2))
426 call assert_equal(['terrible'], spellsuggest('theribal',2))
427
428 " If the suggestion is misspelled (*terrrible* with 3 r),
429 " it should not be proposed.
430 " The entry for "terribal" should be ignored because of missing slash.
431 call assert_equal([], spellsuggest('teribal', 2))
432 call assert_equal([], spellsuggest('terribal', 2))
433
434 set spell spellsuggest=best,file:Xspellsuggest
435 call assert_equal(['vim', 'Emacs'], spellsuggest('emacs', 2))
436 call assert_equal(['terrible', 'tribal'], spellsuggest('theribal', 2))
437 call assert_equal(['tribal'], spellsuggest('teribal', 1))
438 call assert_equal(['tribal'], spellsuggest('terribal', 1))
439
440 call delete('Xspellsuggest')
441 call assert_fails("call spellsuggest('vim')", "E484: Can't open file Xspellsuggest")
442
443 set spellsuggest& spell&
444endfunc
445
446" Test 'spellsuggest' option with value {number}
447" to limit the number of suggestions
448func Test_spellsuggest_option_number()
449 set spell spellsuggest=2,best
450 new
451
452 " We limited the number of suggestions to 2, so selecting
453 " the 1st and 2nd suggestion should correct the word, but
454 " selecting a 3rd suggestion should do nothing.
Bram Moolenaar76734052019-12-26 14:30:15 +0100455 call setline(1, 'A baord')
456 norm $1z=
457 call assert_equal('A board', getline(1))
Bram Moolenaare9a8d1f2019-12-25 13:36:36 +0100458
Bram Moolenaar76734052019-12-26 14:30:15 +0100459 call setline(1, 'A baord')
460 norm $2z=
461 call assert_equal('A bard', getline(1))
Bram Moolenaare9a8d1f2019-12-25 13:36:36 +0100462
Bram Moolenaar76734052019-12-26 14:30:15 +0100463 call setline(1, 'A baord')
464 norm $3z=
465 call assert_equal('A baord', getline(1))
Bram Moolenaare9a8d1f2019-12-25 13:36:36 +0100466
Bram Moolenaar76734052019-12-26 14:30:15 +0100467 let a = execute('norm $z=')
Bram Moolenaare9a8d1f2019-12-25 13:36:36 +0100468 call assert_equal(
469 \ "\n"
Bram Moolenaar76734052019-12-26 14:30:15 +0100470 \ .. "Change \"baord\" to:\n"
471 \ .. " 1 \"board\"\n"
472 \ .. " 2 \"bard\"\n"
Bram Moolenaard281b7c2020-06-10 16:39:32 +0200473 \ .. "Type number and <Enter> or click with the mouse (q or empty cancels): ", a)
Bram Moolenaare9a8d1f2019-12-25 13:36:36 +0100474
475 set spell spellsuggest=0
Bram Moolenaar76734052019-12-26 14:30:15 +0100476 call assert_equal("\nSorry, no suggestions", execute('norm $z='))
Bram Moolenaare9a8d1f2019-12-25 13:36:36 +0100477
478 " Unlike z=, function spellsuggest(...) should not be affected by the
479 " max number of suggestions (2) set by the 'spellsuggest' option.
Bram Moolenaar76734052019-12-26 14:30:15 +0100480 call assert_equal(['board', 'bard', 'broad'], spellsuggest('baord', 3))
Bram Moolenaare9a8d1f2019-12-25 13:36:36 +0100481
482 set spellsuggest& spell&
483 bwipe!
484endfunc
485
486" Test 'spellsuggest' option with value expr:{expr}
487func Test_spellsuggest_option_expr()
488 " A silly 'spellsuggest' function which makes suggestions all uppercase
489 " and makes the score of each suggestion the length of the suggested word.
490 " So shorter suggestions are preferred.
491 func MySuggest()
492 let spellsuggest_save = &spellsuggest
Bram Moolenaar76734052019-12-26 14:30:15 +0100493 set spellsuggest=3,best
Bram Moolenaare9a8d1f2019-12-25 13:36:36 +0100494 let result = map(spellsuggest(v:val, 3), "[toupper(v:val), len(v:val)]")
495 let &spellsuggest = spellsuggest_save
496 return result
497 endfunc
498
Bram Moolenaar76734052019-12-26 14:30:15 +0100499 set spell spellsuggest=expr:MySuggest()
500 call assert_equal(['BARD', 'BOARD', 'BROAD'], spellsuggest('baord', 3))
Bram Moolenaare9a8d1f2019-12-25 13:36:36 +0100501
502 new
Bram Moolenaar76734052019-12-26 14:30:15 +0100503 call setline(1, 'baord')
Bram Moolenaare9a8d1f2019-12-25 13:36:36 +0100504 let a = execute('norm z=')
505 call assert_equal(
506 \ "\n"
Bram Moolenaar76734052019-12-26 14:30:15 +0100507 \ .. "Change \"baord\" to:\n"
508 \ .. " 1 \"BARD\"\n"
509 \ .. " 2 \"BOARD\"\n"
510 \ .. " 3 \"BROAD\"\n"
Bram Moolenaard281b7c2020-06-10 16:39:32 +0200511 \ .. "Type number and <Enter> or click with the mouse (q or empty cancels): ", a)
Bram Moolenaare9a8d1f2019-12-25 13:36:36 +0100512
513 " With verbose, z= should show the score i.e. word length with
514 " our SpellSuggest() function.
515 set verbose=1
516 let a = execute('norm z=')
517 call assert_equal(
518 \ "\n"
Bram Moolenaar76734052019-12-26 14:30:15 +0100519 \ .. "Change \"baord\" to:\n"
520 \ .. " 1 \"BARD\" (4 - 0)\n"
521 \ .. " 2 \"BOARD\" (5 - 0)\n"
522 \ .. " 3 \"BROAD\" (5 - 0)\n"
Bram Moolenaard281b7c2020-06-10 16:39:32 +0200523 \ .. "Type number and <Enter> or click with the mouse (q or empty cancels): ", a)
Bram Moolenaare9a8d1f2019-12-25 13:36:36 +0100524
525 set spell& spellsuggest& verbose&
526 bwipe!
527endfunc
528
Dominique Pelle81b573d2022-03-22 21:14:55 +0000529" Test for 'spellsuggest' expr errors
Bram Moolenaar8dfcce32020-03-18 19:32:26 +0100530func Test_spellsuggest_expr_errors()
531 " 'spellsuggest'
532 func MySuggest()
533 return range(3)
534 endfunc
535 set spell spellsuggest=expr:MySuggest()
536 call assert_equal([], spellsuggest('baord', 3))
537
538 " Test for 'spellsuggest' expression returning a non-list value
539 func! MySuggest2()
540 return 'good'
541 endfunc
542 set spellsuggest=expr:MySuggest2()
543 call assert_equal([], spellsuggest('baord'))
544
545 " Test for 'spellsuggest' expression returning a list with dict values
546 func! MySuggest3()
547 return [[{}, {}]]
548 endfunc
549 set spellsuggest=expr:MySuggest3()
Bram Moolenaar9b7bf9e2020-07-11 22:14:59 +0200550 call assert_fails("call spellsuggest('baord')", 'E731:')
Bram Moolenaar8dfcce32020-03-18 19:32:26 +0100551
552 set nospell spellsuggest&
553 delfunc MySuggest
554 delfunc MySuggest2
555 delfunc MySuggest3
556endfunc
557
Bram Moolenaar585ee072022-01-29 11:22:17 +0000558func Test_spellsuggest_timeout()
559 set spellsuggest=timeout:30
560 set spellsuggest=timeout:-123
561 set spellsuggest=timeout:999999
562 call assert_fails('set spellsuggest=timeout', 'E474:')
563 call assert_fails('set spellsuggest=timeout:x', 'E474:')
564 call assert_fails('set spellsuggest=timeout:-x', 'E474:')
565 call assert_fails('set spellsuggest=timeout:--9', 'E474:')
566endfunc
567
Bram Moolenaar5c686172022-03-13 20:12:25 +0000568func Test_spellsuggest_visual_end_of_line()
569 let enc_save = &encoding
570 set encoding=iso8859
571
572 " This was reading beyond the end of the line.
573 norm R00000000000
574 sil norm 0
575 sil! norm i00000)
576 sil! norm i00000)
577 call feedkeys("\<CR>")
578 norm z=
579
580 let &encoding = enc_save
581endfunc
582
Bram Moolenaar9049b682018-08-31 22:26:53 +0200583func Test_spellinfo()
584 new
Bram Moolenaarc25e7022019-10-10 14:08:26 +0200585 let runtime = substitute($VIMRUNTIME, '\\', '/', 'g')
Bram Moolenaar9049b682018-08-31 22:26:53 +0200586
587 set enc=latin1 spell spelllang=en
Bram Moolenaarc25e7022019-10-10 14:08:26 +0200588 call assert_match("^\nfile: " .. runtime .. "/spell/en.latin1.spl\n$", execute('spellinfo'))
Bram Moolenaar9049b682018-08-31 22:26:53 +0200589
590 set enc=cp1250 spell spelllang=en
Bram Moolenaarc25e7022019-10-10 14:08:26 +0200591 call assert_match("^\nfile: " .. runtime .. "/spell/en.ascii.spl\n$", execute('spellinfo'))
Bram Moolenaar9049b682018-08-31 22:26:53 +0200592
Bram Moolenaar30276f22019-01-24 17:59:39 +0100593 set enc=utf-8 spell spelllang=en
Bram Moolenaarc25e7022019-10-10 14:08:26 +0200594 call assert_match("^\nfile: " .. runtime .. "/spell/en.utf-8.spl\n$", execute('spellinfo'))
Bram Moolenaar9049b682018-08-31 22:26:53 +0200595
596 set enc=latin1 spell spelllang=en_us,en_nz
597 call assert_match("^\n" .
Bram Moolenaarc25e7022019-10-10 14:08:26 +0200598 \ "file: " .. runtime .. "/spell/en.latin1.spl\n" .
599 \ "file: " .. runtime.. "/spell/en.latin1.spl\n$", execute('spellinfo'))
Bram Moolenaar9049b682018-08-31 22:26:53 +0200600
601 set spell spelllang=
602 call assert_fails('spellinfo', 'E756:')
603
604 set nospell spelllang=en
605 call assert_fails('spellinfo', 'E756:')
606
Bram Moolenaar8f130ed2019-04-10 22:15:19 +0200607 call assert_fails('set spelllang=foo/bar', 'E474:')
608 call assert_fails('set spelllang=foo\ bar', 'E474:')
609 call assert_fails("set spelllang=foo\\\nbar", 'E474:')
610 call assert_fails("set spelllang=foo\\\rbar", 'E474:')
611 call assert_fails("set spelllang=foo+bar", 'E474:')
612
Bram Moolenaar9049b682018-08-31 22:26:53 +0200613 set enc& spell& spelllang&
614 bwipe
615endfunc
616
Bram Moolenaard2c061d2017-06-22 21:42:49 +0200617func Test_zz_basic()
618 call LoadAffAndDic(g:test_data_aff1, g:test_data_dic1)
619 call RunGoodBad("wrong OK puts. Test the end",
620 \ "bad: inputs comment ok Ok. test d\xE9\xF4l end the",
621 \["Comment", "deol", "d\xE9\xF4r", "input", "OK", "output", "outputs", "outtest", "put", "puts",
622 \ "test", "testen", "testn", "the end", "uk", "wrong"],
623 \[
624 \ ["bad", ["put", "uk", "OK"]],
625 \ ["inputs", ["input", "puts", "outputs"]],
626 \ ["comment", ["Comment", "outtest", "the end"]],
627 \ ["ok", ["OK", "uk", "put"]],
628 \ ["Ok", ["OK", "Uk", "Put"]],
629 \ ["test", ["Test", "testn", "testen"]],
630 \ ["d\xE9\xF4l", ["deol", "d\xE9\xF4r", "test"]],
631 \ ["end", ["put", "uk", "test"]],
632 \ ["the", ["put", "uk", "test"]],
633 \ ]
634 \ )
635
636 call assert_equal("gebletegek", soundfold('goobledygoook'))
Bram Moolenaarf6ed61e2019-09-07 19:05:09 +0200637 call assert_equal("kepereneven", 'kóopërÿnôven'->soundfold())
Bram Moolenaard2c061d2017-06-22 21:42:49 +0200638 call assert_equal("everles gesvets etele", soundfold('oeverloos gezwets edale'))
639endfunc
640
641" Postponed prefixes
642func Test_zz_prefixes()
643 call LoadAffAndDic(g:test_data_aff2, g:test_data_dic1)
644 call RunGoodBad("puts",
645 \ "bad: inputs comment ok Ok end the. test d\xE9\xF4l",
646 \ ["Comment", "deol", "d\xE9\xF4r", "OK", "put", "input", "output", "puts", "outputs", "test", "outtest", "testen", "testn", "the end", "uk", "wrong"],
647 \ [
648 \ ["bad", ["put", "uk", "OK"]],
649 \ ["inputs", ["input", "puts", "outputs"]],
650 \ ["comment", ["Comment"]],
651 \ ["ok", ["OK", "uk", "put"]],
652 \ ["Ok", ["OK", "Uk", "Put"]],
653 \ ["end", ["put", "uk", "deol"]],
654 \ ["the", ["put", "uk", "test"]],
655 \ ["test", ["Test", "testn", "testen"]],
656 \ ["d\xE9\xF4l", ["deol", "d\xE9\xF4r", "test"]],
657 \ ])
658endfunc
659
660"Compound words
661func Test_zz_compound()
662 call LoadAffAndDic(g:test_data_aff3, g:test_data_dic3)
663 call RunGoodBad("foo m\xEF foobar foofoobar barfoo barbarfoo",
664 \ "bad: bar la foom\xEF barm\xEF m\xEFfoo m\xEFbar m\xEFm\xEF lala m\xEFla lam\xEF foola labar",
665 \ ["foo", "m\xEF"],
666 \ [
667 \ ["bad", ["foo", "m\xEF"]],
668 \ ["bar", ["barfoo", "foobar", "foo"]],
669 \ ["la", ["m\xEF", "foo"]],
670 \ ["foom\xEF", ["foo m\xEF", "foo", "foofoo"]],
671 \ ["barm\xEF", ["barfoo", "m\xEF", "barbar"]],
672 \ ["m\xEFfoo", ["m\xEF foo", "foo", "foofoo"]],
673 \ ["m\xEFbar", ["foobar", "barbar", "m\xEF"]],
674 \ ["m\xEFm\xEF", ["m\xEF m\xEF", "m\xEF"]],
675 \ ["lala", []],
676 \ ["m\xEFla", ["m\xEF", "m\xEF m\xEF"]],
677 \ ["lam\xEF", ["m\xEF", "m\xEF m\xEF"]],
678 \ ["foola", ["foo", "foobar", "foofoo"]],
679 \ ["labar", ["barbar", "foobar"]],
680 \ ])
681
682 call LoadAffAndDic(g:test_data_aff4, g:test_data_dic4)
683 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",
684 \ "bad: wordutilize pro borkborkborkborkborkbork tomatotomatotomato endstart endend startstart wordend wordstart preborkprebork preborkpreborkbork startwordwordwordwordend borkpreborkpreborkbork utilsbork startnouword",
685 \ ["bork", "prebork", "end", "pro-ok", "start", "tomato", "util", "utilize", "utils", "word", "nouword"],
686 \ [
687 \ ["bad", ["end", "bork", "word"]],
688 \ ["wordutilize", ["word utilize", "wordutils", "wordutil"]],
689 \ ["pro", ["bork", "word", "end"]],
690 \ ["borkborkborkborkborkbork", ["bork borkborkborkborkbork", "borkbork borkborkborkbork", "borkborkbork borkborkbork"]],
691 \ ["tomatotomatotomato", ["tomato tomatotomato", "tomatotomato tomato", "tomato tomato tomato"]],
692 \ ["endstart", ["end start", "start"]],
693 \ ["endend", ["end end", "end"]],
694 \ ["startstart", ["start start"]],
695 \ ["wordend", ["word end", "word", "wordword"]],
696 \ ["wordstart", ["word start", "bork start"]],
697 \ ["preborkprebork", ["prebork prebork", "preborkbork", "preborkborkbork"]],
698 \ ["preborkpreborkbork", ["prebork preborkbork", "preborkborkbork", "preborkborkborkbork"]],
699 \ ["startwordwordwordwordend", ["startwordwordwordword end", "startwordwordwordword", "start wordwordwordword end"]],
700 \ ["borkpreborkpreborkbork", ["bork preborkpreborkbork", "bork prebork preborkbork", "bork preborkprebork bork"]],
701 \ ["utilsbork", ["utilbork", "utils bork", "util bork"]],
702 \ ["startnouword", ["start nouword", "startword", "startborkword"]],
703 \ ])
704
705endfunc
706
707"Test affix flags with two characters
708func Test_zz_affix()
709 call LoadAffAndDic(g:test_data_aff5, g:test_data_dic5)
710 call RunGoodBad("fooa1 fooa\xE9 bar prebar barbork prebarbork startprebar start end startend startmiddleend nouend",
711 \ "bad: foo fooa2 prabar probarbirk middle startmiddle middleend endstart startprobar startnouend",
712 \ ["bar", "barbork", "end", "fooa1", "fooa\xE9", "nouend", "prebar", "prebarbork", "start"],
713 \ [
714 \ ["bad", ["bar", "end", "fooa1"]],
715 \ ["foo", ["fooa1", "fooa\xE9", "bar"]],
716 \ ["fooa2", ["fooa1", "fooa\xE9", "bar"]],
717 \ ["prabar", ["prebar", "bar", "bar bar"]],
718 \ ["probarbirk", ["prebarbork"]],
719 \ ["middle", []],
720 \ ["startmiddle", ["startmiddleend", "startmiddlebar"]],
721 \ ["middleend", []],
722 \ ["endstart", ["end start", "start"]],
723 \ ["startprobar", ["startprebar", "start prebar", "startbar"]],
724 \ ["startnouend", ["start nouend", "startend"]],
725 \ ])
726
727 call LoadAffAndDic(g:test_data_aff6, g:test_data_dic6)
728 call RunGoodBad("meea1 meea\xE9 bar prebar barbork prebarbork leadprebar lead end leadend leadmiddleend",
729 \ "bad: mee meea2 prabar probarbirk middle leadmiddle middleend endlead leadprobar",
730 \ ["bar", "barbork", "end", "lead", "meea1", "meea\xE9", "prebar", "prebarbork"],
731 \ [
732 \ ["bad", ["bar", "end", "lead"]],
733 \ ["mee", ["meea1", "meea\xE9", "bar"]],
734 \ ["meea2", ["meea1", "meea\xE9", "lead"]],
735 \ ["prabar", ["prebar", "bar", "leadbar"]],
736 \ ["probarbirk", ["prebarbork"]],
737 \ ["middle", []],
738 \ ["leadmiddle", ["leadmiddleend", "leadmiddlebar"]],
739 \ ["middleend", []],
740 \ ["endlead", ["end lead", "lead", "end end"]],
741 \ ["leadprobar", ["leadprebar", "lead prebar", "leadbar"]],
742 \ ])
743
744 call LoadAffAndDic(g:test_data_aff7, g:test_data_dic7)
Bram Moolenaar3d2a47c2019-11-07 20:48:42 +0100745 call RunGoodBad("meea1 meezero meea\xE9 bar prebar barmeat prebarmeat leadprebar lead tail leadtail leadmiddletail",
Bram Moolenaard2c061d2017-06-22 21:42:49 +0200746 \ "bad: mee meea2 prabar probarmaat middle leadmiddle middletail taillead leadprobar",
Bram Moolenaar3d2a47c2019-11-07 20:48:42 +0100747 \ ["bar", "barmeat", "lead", "meea1", "meea\xE9", "meezero", "prebar", "prebarmeat", "tail"],
Bram Moolenaard2c061d2017-06-22 21:42:49 +0200748 \ [
749 \ ["bad", ["bar", "lead", "tail"]],
750 \ ["mee", ["meea1", "meea\xE9", "bar"]],
751 \ ["meea2", ["meea1", "meea\xE9", "lead"]],
752 \ ["prabar", ["prebar", "bar", "leadbar"]],
753 \ ["probarmaat", ["prebarmeat"]],
754 \ ["middle", []],
755 \ ["leadmiddle", ["leadmiddlebar"]],
756 \ ["middletail", []],
757 \ ["taillead", ["tail lead", "tail"]],
758 \ ["leadprobar", ["leadprebar", "lead prebar", "leadbar"]],
759 \ ])
760endfunc
761
762func Test_zz_NOSLITSUGS()
763 call LoadAffAndDic(g:test_data_aff8, g:test_data_dic8)
764 call RunGoodBad("foo bar faabar", "bad: foobar barfoo",
765 \ ["bar", "faabar", "foo"],
766 \ [
767 \ ["bad", ["bar", "foo"]],
768 \ ["foobar", ["faabar", "foo bar", "bar"]],
769 \ ["barfoo", ["bar foo", "bar", "foo"]],
770 \ ])
771endfunc
772
773" Numbers
774func Test_zz_Numbers()
775 call LoadAffAndDic(g:test_data_aff9, g:test_data_dic9)
776 call RunGoodBad("0b1011 0777 1234 0x01ff", "",
777 \ ["bar", "foo"],
778 \ [
779 \ ])
780endfunc
781
Bram Moolenaar37ff4cf2019-11-17 20:10:20 +0100782" Affix flags
783func Test_zz_affix_flags()
784 call LoadAffAndDic(g:test_data_aff10, g:test_data_dic10)
785 call RunGoodBad("drink drinkable drinkables drinktable drinkabletable",
786 \ "bad: drinks drinkstable drinkablestable",
787 \ ["drink", "drinkable", "drinkables", "table"],
788 \ [['bad', []],
789 \ ['drinks', ['drink']],
790 \ ['drinkstable', ['drinktable', 'drinkable', 'drink table']],
791 \ ['drinkablestable', ['drinkabletable', 'drinkables table', 'drinkable table']],
792 \ ])
793endfunc
794
Bram Moolenaard2c061d2017-06-22 21:42:49 +0200795function FirstSpellWord()
796 call feedkeys("/^start:\n", 'tx')
797 normal ]smm
798 let [str, a] = spellbadword()
799 return str
800endfunc
801
802function SecondSpellWord()
803 normal `m]s
804 let [str, a] = spellbadword()
805 return str
806endfunc
807
808"Test with SAL instead of SOFO items; test automatic reloading
809func Test_zz_sal_and_addition()
810 set enc=latin1
811 set spellfile=
Bram Moolenaar56564962022-10-10 22:39:42 +0100812 call writefile(g:test_data_dic1, "Xtest.dic", 'D')
813 call writefile(g:test_data_aff_sal, "Xtest.aff", 'D')
Bram Moolenaard2c061d2017-06-22 21:42:49 +0200814 mkspell! Xtest Xtest
815 set spl=Xtest.latin1.spl spell
816 call assert_equal('kbltykk', soundfold('goobledygoook'))
817 call assert_equal('kprnfn', soundfold('kóopërÿnôven'))
818 call assert_equal('*fls kswts tl', soundfold('oeverloos gezwets edale'))
819
820 "also use an addition file
Bram Moolenaar56564962022-10-10 22:39:42 +0100821 call writefile(["/regions=usgbnz", "elequint/2", "elekwint/3"], "Xtest.latin1.add", 'D')
Bram Moolenaard2c061d2017-06-22 21:42:49 +0200822 mkspell! Xtest.latin1.add.spl Xtest.latin1.add
823
824 bwipe!
825 call setline(1, ["start: elequint test elekwint test elekwent asdf"])
826
827 set spellfile=Xtest.latin1.add
828 call assert_equal("elekwent", FirstSpellWord())
829
830 set spl=Xtest_us.latin1.spl
831 call assert_equal("elequint", FirstSpellWord())
832 call assert_equal("elekwint", SecondSpellWord())
833
834 set spl=Xtest_gb.latin1.spl
835 call assert_equal("elekwint", FirstSpellWord())
836 call assert_equal("elekwent", SecondSpellWord())
837
838 set spl=Xtest_nz.latin1.spl
839 call assert_equal("elequint", FirstSpellWord())
840 call assert_equal("elekwent", SecondSpellWord())
841
842 set spl=Xtest_ca.latin1.spl
843 call assert_equal("elequint", FirstSpellWord())
844 call assert_equal("elekwint", SecondSpellWord())
zeertzjq288ed232022-07-04 11:03:07 +0100845
846 bwipe!
847 set spellfile=
848 set spl&
Bram Moolenaard2c061d2017-06-22 21:42:49 +0200849endfunc
850
Bram Moolenaar862f1e12019-04-10 22:33:41 +0200851func Test_spellfile_value()
852 set spellfile=Xdir/Xtest.latin1.add
853 set spellfile=Xdir/Xtest.utf-8.add,Xtest_other.add
854endfunc
855
Bram Moolenaaree03b942017-10-27 00:57:05 +0200856func Test_region_error()
857 messages clear
Bram Moolenaar56564962022-10-10 22:39:42 +0100858 call writefile(["/regions=usgbnz", "elequint/0"], "Xtest.latin1.add", 'D')
Bram Moolenaaree03b942017-10-27 00:57:05 +0200859 mkspell! Xtest.latin1.add.spl Xtest.latin1.add
860 call assert_match('Invalid region nr in Xtest.latin1.add line 2: 0', execute('messages'))
Bram Moolenaaree03b942017-10-27 00:57:05 +0200861 call delete('Xtest.latin1.add.spl')
862endfunc
863
Bram Moolenaard2c061d2017-06-22 21:42:49 +0200864" Check using z= in new buffer (crash fixed by patch 7.4a.028).
865func Test_zeq_crash()
866 new
867 set maxmem=512 spell
868 call feedkeys('iasdz=:\"', 'tx')
869
870 bwipe!
871endfunc
872
Bram Moolenaar152e79e2020-06-10 15:32:08 +0200873" Check that z= works even when 'nospell' is set. This test uses one of the
874" tests in Test_spellsuggest_option_number() just to verify that z= basically
875" works and that "E756: Spell checking is not enabled" is not generated.
876func Test_zeq_nospell()
877 new
878 set nospell spellsuggest=1,best
879 call setline(1, 'A baord')
880 try
881 norm $1z=
882 call assert_equal('A board', getline(1))
883 catch
884 call assert_report("Caught exception: " . v:exception)
885 endtry
886 set spell& spellsuggest&
887 bwipe!
888endfunc
889
890" Check that "E756: Spell checking is not possible" is reported when z= is
891" executed and 'spelllang' is empty.
892func Test_zeq_no_spelllang()
893 new
894 set spelllang= spellsuggest=1,best
895 call setline(1, 'A baord')
896 call assert_fails('normal $1z=', 'E756:')
897 set spelllang& spellsuggest&
898 bwipe!
899endfunc
900
Bram Moolenaar5bcc5a12019-08-06 22:48:02 +0200901" Check handling a word longer than MAXWLEN.
902func Test_spell_long_word()
903 set enc=utf-8
904 new
905 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")
906 set spell spelllang=en
907 redraw
908 redraw!
909 bwipe!
910 set nospell
911endfunc
912
Bram Moolenaar06f15412022-01-29 10:51:59 +0000913func Test_spellsuggest_too_deep()
914 " This was incrementing "depth" over MAXWLEN.
915 new
916 norm s000G00ý000000000000
917 sil norm ..vzG................vvzG0 v z=
918 bwipe!
919endfunc
920
Bram Moolenaar5e59ea52022-07-01 22:26:20 +0100921func Test_spell_good_word_invalid()
922 " This was adding a word with a 0x02 byte, which causes havoc.
923 enew
924 norm o0
925 sil! norm rzzWs00/
926 2
927 sil! norm VzGprzzW
928 sil! norm z=
929
930 bwipe!
Bram Moolenaar5e59ea52022-07-01 22:26:20 +0100931endfunc
932
K.Takata2ebcc352022-07-14 17:25:14 +0100933func Test_spell_good_word_slash()
934 " This caused E1280.
935 new
936 norm afoo /
937 1
938 norm zG
939
940 bwipe!
941endfunc
942
Bram Moolenaard2c061d2017-06-22 21:42:49 +0200943func LoadAffAndDic(aff_contents, dic_contents)
944 set enc=latin1
945 set spellfile=
946 call writefile(a:aff_contents, "Xtest.aff")
947 call writefile(a:dic_contents, "Xtest.dic")
948 " Generate a .spl file from a .dic and .aff file.
949 mkspell! Xtest Xtest
950 " use that spell file
951 set spl=Xtest.latin1.spl spell
952endfunc
953
954func ListWords()
955 spelldump
956 %yank
957 quit
958 return split(@", "\n")
959endfunc
960
961func TestGoodBadBase()
962 exe '1;/^good:'
963 normal 0f:]s
964 let prevbad = ''
965 let result = []
966 while 1
967 let [bad, a] = spellbadword()
968 if bad == '' || bad == prevbad || bad == 'badend'
969 break
970 endif
971 let prevbad = bad
Bram Moolenaarf6ed61e2019-09-07 19:05:09 +0200972 let lst = bad->spellsuggest(3)
Bram Moolenaard2c061d2017-06-22 21:42:49 +0200973 normal mm
974
975 call add(result, [bad, lst])
976 normal `m]s
977 endwhile
978 return result
979endfunc
980
981func RunGoodBad(good, bad, expected_words, expected_bad_words)
982 bwipe!
983 call setline(1, ["good: ", a:good, a:bad, " badend "])
984 let words = ListWords()
985 call assert_equal(a:expected_words, words[1:-1])
986 let bad_words = TestGoodBadBase()
987 call assert_equal(a:expected_bad_words, bad_words)
988 bwipe!
989endfunc
990
Bram Moolenaar7751d1d2019-10-18 20:37:08 +0200991func Test_spell_screendump()
992 CheckScreendump
993
994 let lines =<< trim END
Luuk van Baale84c7732023-05-31 18:57:36 +0100995 call test_override('alloc_lines', 1)
Bram Moolenaar7751d1d2019-10-18 20:37:08 +0200996 call setline(1, [
997 \ "This is some text without any spell errors. Everything",
998 \ "should just be black, nothing wrong here.",
999 \ "",
1000 \ "This line has a sepll error. and missing caps.",
1001 \ "And and this is the the duplication.",
1002 \ "with missing caps here.",
1003 \ ])
1004 set spell spelllang=en_nz
1005 END
Bram Moolenaarf3ef0262022-10-05 13:29:15 +01001006 call writefile(lines, 'XtestSpell', 'D')
Bram Moolenaar7751d1d2019-10-18 20:37:08 +02001007 let buf = RunVimInTerminal('-S XtestSpell', {'rows': 8})
1008 call VerifyScreenDump(buf, 'Test_spell_1', {})
1009
1010 " clean up
1011 call StopVimInTerminal(buf)
Bram Moolenaar7751d1d2019-10-18 20:37:08 +02001012endfunc
1013
Christian Brabandtafa23d12022-08-09 12:25:10 +01001014func Test_spell_screendump_spellcap()
1015 CheckScreendump
1016
1017 let lines =<< trim END
Luuk van Baale84c7732023-05-31 18:57:36 +01001018 call test_override('alloc_lines', 1)
Christian Brabandtafa23d12022-08-09 12:25:10 +01001019 call setline(1, [
1020 \ " This line has a sepll error. and missing caps and trailing spaces. ",
1021 \ "another missing cap here.",
1022 \ "",
1023 \ "and here.",
1024 \ " ",
1025 \ "and here."
1026 \ ])
1027 set spell spelllang=en
1028 END
Bram Moolenaarf3ef0262022-10-05 13:29:15 +01001029 call writefile(lines, 'XtestSpellCap', 'D')
Christian Brabandtafa23d12022-08-09 12:25:10 +01001030 let buf = RunVimInTerminal('-S XtestSpellCap', {'rows': 8})
1031 call VerifyScreenDump(buf, 'Test_spell_2', {})
1032
Bram Moolenaaree09fcc2022-09-25 20:58:30 +01001033 " After adding word missing Cap in next line is updated
1034 call term_sendkeys(buf, "3GANot\<Esc>")
1035 call VerifyScreenDump(buf, 'Test_spell_3', {})
1036
Bram Moolenaar26f09ea2022-09-27 16:29:38 +01001037 " Deleting a full stop removes missing Cap in next line
Luuk van Baal2ac64972023-05-25 17:14:42 +01001038 call term_sendkeys(buf, "5Gdd\<C-L>k$x")
Bram Moolenaar26f09ea2022-09-27 16:29:38 +01001039 call VerifyScreenDump(buf, 'Test_spell_4', {})
1040
1041 " Undo also updates the next line (go to command line to remove message)
1042 call term_sendkeys(buf, "u:\<Esc>")
1043 call VerifyScreenDump(buf, 'Test_spell_5', {})
1044
Luuk van Baal2ac64972023-05-25 17:14:42 +01001045 " Folding an empty line does not remove Cap in next line
1046 call term_sendkeys(buf, "uzfk:\<Esc>")
1047 call VerifyScreenDump(buf, 'Test_spell_6', {})
1048
1049 " Folding the end of a sentence does not remove Cap in next line
1050 " and editing a line does not remove Cap in current line
1051 call term_sendkeys(buf, "Jzfkk$x")
1052 call VerifyScreenDump(buf, 'Test_spell_7', {})
1053
1054 " Cap is correctly applied in the first row of a window
1055 call term_sendkeys(buf, "\<C-E>\<C-L>")
1056 call VerifyScreenDump(buf, 'Test_spell_8', {})
1057
Luuk van Baale84c7732023-05-31 18:57:36 +01001058 " Adding an empty line does not remove Cap in "mod_bot" area
1059 call term_sendkeys(buf, "zbO\<Esc>")
1060 call VerifyScreenDump(buf, 'Test_spell_9', {})
1061
1062 " Multiple empty lines does not remove Cap in the line after
1063 call term_sendkeys(buf, "O\<Esc>\<C-L>")
1064 call VerifyScreenDump(buf, 'Test_spell_10', {})
1065
Christian Brabandtafa23d12022-08-09 12:25:10 +01001066 " clean up
1067 call StopVimInTerminal(buf)
Bram Moolenaarf3ef0262022-10-05 13:29:15 +01001068endfunc
1069
1070func Test_spell_compatible()
1071 CheckScreendump
1072
1073 let lines =<< trim END
Luuk van Baale84c7732023-05-31 18:57:36 +01001074 call test_override('alloc_lines', 1)
Bram Moolenaarf3ef0262022-10-05 13:29:15 +01001075 call setline(1, [
1076 \ "test "->repeat(20),
1077 \ "",
1078 \ "end",
1079 \ ])
1080 set spell cpo+=$
1081 END
1082 call writefile(lines, 'XtestSpellComp', 'D')
1083 let buf = RunVimInTerminal('-S XtestSpellComp', {'rows': 8})
1084
1085 call term_sendkeys(buf, "51|C")
1086 call VerifyScreenDump(buf, 'Test_spell_compatible_1', {})
1087
1088 call term_sendkeys(buf, "x")
1089 call VerifyScreenDump(buf, 'Test_spell_compatible_2', {})
1090
1091 " clean up
1092 call StopVimInTerminal(buf)
Christian Brabandtafa23d12022-08-09 12:25:10 +01001093endfunc
1094
Christian Brabandt73b2d372023-11-14 21:58:26 +01001095func Test_z_equal_with_large_count()
1096 split
1097 set spell
1098 call setline(1, "ff")
1099 norm 0z=337203685477580
1100 set nospell
1101 bwipe!
1102endfunc
1103
Bram Moolenaard2c061d2017-06-22 21:42:49 +02001104let g:test_data_aff1 = [
1105 \"SET ISO8859-1",
1106 \"TRY esianrtolcdugmphbyfvkwjkqxz-\xEB\xE9\xE8\xEA\xEF\xEE\xE4\xE0\xE2\xF6\xFC\xFB'ESIANRTOLCDUGMPHBYFVKWJKQXZ",
1107 \"",
1108 \"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",
1109 \"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",
1110 \"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",
1111 \"",
1112 \"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",
1113 \"SOFOTO ebctefghejklnnepkrstevvkesebctefghejklnnepkrstevvkeseeeeeeeceeeeeeeedneeeeeeeeeeepseeeeeeeeceeeeeeeedneeeeeeeeeeep?",
1114 \"",
1115 \"MIDWORD\t'-",
1116 \"",
1117 \"KEP =",
1118 \"RAR ?",
1119 \"BAD !",
1120 \"",
1121 \"PFX I N 1",
1122 \"PFX I 0 in .",
1123 \"",
1124 \"PFX O Y 1",
1125 \"PFX O 0 out .",
1126 \"",
1127 \"SFX S Y 2",
1128 \"SFX S 0 s [^s]",
1129 \"SFX S 0 es s",
1130 \"",
1131 \"SFX N N 3",
1132 \"SFX N 0 en [^n]",
1133 \"SFX N 0 nen n",
1134 \"SFX N 0 n .",
1135 \"",
1136 \"REP 3",
1137 \"REP g ch",
1138 \"REP ch g",
1139 \"REP svp s.v.p.",
1140 \"",
1141 \"MAP 9",
1142 \"MAP a\xE0\xE1\xE2\xE3\xE4\xE5",
1143 \"MAP e\xE8\xE9\xEA\xEB",
1144 \"MAP i\xEC\xED\xEE\xEF",
1145 \"MAP o\xF2\xF3\xF4\xF5\xF6",
1146 \"MAP u\xF9\xFA\xFB\xFC",
1147 \"MAP n\xF1",
1148 \"MAP c\xE7",
1149 \"MAP y\xFF\xFD",
1150 \"MAP s\xDF",
1151 \ ]
1152let g:test_data_dic1 = [
1153 \"123456",
1154 \"test/NO",
1155 \"# comment",
1156 \"wrong",
1157 \"Comment",
1158 \"OK",
1159 \"uk",
1160 \"put/ISO",
1161 \"the end",
1162 \"deol",
1163 \"d\xE9\xF4r",
1164 \ ]
1165let g:test_data_aff2 = [
1166 \"SET ISO8859-1",
1167 \"",
1168 \"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",
1169 \"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",
1170 \"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",
1171 \"",
1172 \"PFXPOSTPONE",
1173 \"",
1174 \"MIDWORD\t'-",
1175 \"",
1176 \"KEP =",
1177 \"RAR ?",
1178 \"BAD !",
1179 \"",
1180 \"PFX I N 1",
1181 \"PFX I 0 in .",
1182 \"",
1183 \"PFX O Y 1",
1184 \"PFX O 0 out [a-z]",
1185 \"",
1186 \"SFX S Y 2",
1187 \"SFX S 0 s [^s]",
1188 \"SFX S 0 es s",
1189 \"",
1190 \"SFX N N 3",
1191 \"SFX N 0 en [^n]",
1192 \"SFX N 0 nen n",
1193 \"SFX N 0 n .",
1194 \"",
1195 \"REP 3",
1196 \"REP g ch",
1197 \"REP ch g",
1198 \"REP svp s.v.p.",
1199 \"",
1200 \"MAP 9",
1201 \"MAP a\xE0\xE1\xE2\xE3\xE4\xE5",
1202 \"MAP e\xE8\xE9\xEA\xEB",
1203 \"MAP i\xEC\xED\xEE\xEF",
1204 \"MAP o\xF2\xF3\xF4\xF5\xF6",
1205 \"MAP u\xF9\xFA\xFB\xFC",
1206 \"MAP n\xF1",
1207 \"MAP c\xE7",
1208 \"MAP y\xFF\xFD",
1209 \"MAP s\xDF",
1210 \ ]
1211let g:test_data_aff3 = [
1212 \"SET ISO8859-1",
1213 \"",
1214 \"COMPOUNDMIN 3",
1215 \"COMPOUNDRULE m*",
1216 \"NEEDCOMPOUND x",
1217 \ ]
1218let g:test_data_dic3 = [
1219 \"1234",
1220 \"foo/m",
1221 \"bar/mx",
1222 \"m\xEF/m",
1223 \"la/mx",
1224 \ ]
1225let g:test_data_aff4 = [
1226 \"SET ISO8859-1",
1227 \"",
1228 \"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",
1229 \"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",
1230 \"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",
1231 \"",
1232 \"COMPOUNDRULE m+",
1233 \"COMPOUNDRULE sm*e",
1234 \"COMPOUNDRULE sm+",
1235 \"COMPOUNDMIN 3",
1236 \"COMPOUNDWORDMAX 3",
1237 \"COMPOUNDFORBIDFLAG t",
1238 \"",
1239 \"COMPOUNDSYLMAX 5",
1240 \"SYLLABLE a\xE1e\xE9i\xEDo\xF3\xF6\xF5u\xFA\xFC\xFBy/aa/au/ea/ee/ei/ie/oa/oe/oo/ou/uu/ui",
1241 \"",
1242 \"MAP 9",
1243 \"MAP a\xE0\xE1\xE2\xE3\xE4\xE5",
1244 \"MAP e\xE8\xE9\xEA\xEB",
1245 \"MAP i\xEC\xED\xEE\xEF",
1246 \"MAP o\xF2\xF3\xF4\xF5\xF6",
1247 \"MAP u\xF9\xFA\xFB\xFC",
1248 \"MAP n\xF1",
1249 \"MAP c\xE7",
1250 \"MAP y\xFF\xFD",
1251 \"MAP s\xDF",
1252 \"",
1253 \"NEEDAFFIX x",
1254 \"",
1255 \"PFXPOSTPONE",
1256 \"",
1257 \"MIDWORD '-",
1258 \"",
1259 \"SFX q N 1",
1260 \"SFX q 0 -ok .",
1261 \"",
1262 \"SFX a Y 2",
1263 \"SFX a 0 s .",
1264 \"SFX a 0 ize/t .",
1265 \"",
1266 \"PFX p N 1",
1267 \"PFX p 0 pre .",
1268 \"",
1269 \"PFX P N 1",
1270 \"PFX P 0 nou .",
1271 \ ]
1272let g:test_data_dic4 = [
1273 \"1234",
1274 \"word/mP",
1275 \"util/am",
1276 \"pro/xq",
1277 \"tomato/m",
1278 \"bork/mp",
1279 \"start/s",
1280 \"end/e",
1281 \ ]
1282let g:test_data_aff5 = [
1283 \"SET ISO8859-1",
1284 \"",
1285 \"FLAG long",
1286 \"",
1287 \"NEEDAFFIX !!",
1288 \"",
1289 \"COMPOUNDRULE ssmm*ee",
1290 \"",
1291 \"NEEDCOMPOUND xx",
1292 \"COMPOUNDPERMITFLAG pp",
1293 \"",
1294 \"SFX 13 Y 1",
1295 \"SFX 13 0 bork .",
1296 \"",
1297 \"SFX a1 Y 1",
1298 \"SFX a1 0 a1 .",
1299 \"",
1300 \"SFX a\xE9 Y 1",
1301 \"SFX a\xE9 0 a\xE9 .",
1302 \"",
1303 \"PFX zz Y 1",
1304 \"PFX zz 0 pre/pp .",
1305 \"",
1306 \"PFX yy Y 1",
1307 \"PFX yy 0 nou .",
1308 \ ]
1309let g:test_data_dic5 = [
1310 \"1234",
1311 \"foo/a1a\xE9!!",
1312 \"bar/zz13ee",
1313 \"start/ss",
1314 \"end/eeyy",
1315 \"middle/mmxx",
1316 \ ]
1317let g:test_data_aff6 = [
1318 \"SET ISO8859-1",
1319 \"",
1320 \"FLAG caplong",
1321 \"",
1322 \"NEEDAFFIX A!",
1323 \"",
1324 \"COMPOUNDRULE sMm*Ee",
1325 \"",
1326 \"NEEDCOMPOUND Xx",
1327 \"",
1328 \"COMPOUNDPERMITFLAG p",
1329 \"",
1330 \"SFX N3 Y 1",
1331 \"SFX N3 0 bork .",
1332 \"",
1333 \"SFX A1 Y 1",
1334 \"SFX A1 0 a1 .",
1335 \"",
1336 \"SFX A\xE9 Y 1",
1337 \"SFX A\xE9 0 a\xE9 .",
1338 \"",
1339 \"PFX Zz Y 1",
1340 \"PFX Zz 0 pre/p .",
1341 \ ]
1342let g:test_data_dic6 = [
1343 \"1234",
1344 \"mee/A1A\xE9A!",
1345 \"bar/ZzN3Ee",
1346 \"lead/s",
1347 \"end/Ee",
1348 \"middle/MmXx",
1349 \ ]
1350let g:test_data_aff7 = [
1351 \"SET ISO8859-1",
1352 \"",
1353 \"FLAG num",
1354 \"",
1355 \"NEEDAFFIX 9999",
1356 \"",
1357 \"COMPOUNDRULE 2,77*123",
1358 \"",
1359 \"NEEDCOMPOUND 1",
1360 \"COMPOUNDPERMITFLAG 432",
1361 \"",
1362 \"SFX 61003 Y 1",
1363 \"SFX 61003 0 meat .",
1364 \"",
Bram Moolenaar3d2a47c2019-11-07 20:48:42 +01001365 \"SFX 0 Y 1",
1366 \"SFX 0 0 zero .",
1367 \"",
Bram Moolenaard2c061d2017-06-22 21:42:49 +02001368 \"SFX 391 Y 1",
1369 \"SFX 391 0 a1 .",
1370 \"",
1371 \"SFX 111 Y 1",
1372 \"SFX 111 0 a\xE9 .",
1373 \"",
1374 \"PFX 17 Y 1",
1375 \"PFX 17 0 pre/432 .",
1376 \ ]
1377let g:test_data_dic7 = [
1378 \"1234",
Bram Moolenaar3d2a47c2019-11-07 20:48:42 +01001379 \"mee/0,391,111,9999",
Bram Moolenaard2c061d2017-06-22 21:42:49 +02001380 \"bar/17,61003,123",
1381 \"lead/2",
1382 \"tail/123",
1383 \"middle/77,1",
1384 \ ]
1385let g:test_data_aff8 = [
1386 \"SET ISO8859-1",
1387 \"",
1388 \"NOSPLITSUGS",
1389 \ ]
1390let g:test_data_dic8 = [
1391 \"1234",
1392 \"foo",
1393 \"bar",
1394 \"faabar",
1395 \ ]
1396let g:test_data_aff9 = [
1397 \ ]
1398let g:test_data_dic9 = [
1399 \"1234",
1400 \"foo",
1401 \"bar",
1402 \ ]
Bram Moolenaar37ff4cf2019-11-17 20:10:20 +01001403let g:test_data_aff10 = [
1404 \"COMPOUNDRULE se",
1405 \"COMPOUNDPERMITFLAG p",
1406 \"",
1407 \"SFX A Y 1",
1408 \"SFX A 0 able/Mp .",
1409 \"",
1410 \"SFX M Y 1",
1411 \"SFX M 0 s .",
1412 \ ]
1413let g:test_data_dic10 = [
1414 \"1234",
1415 \"drink/As",
1416 \"table/e",
1417 \ ]
Bram Moolenaard2c061d2017-06-22 21:42:49 +02001418let g:test_data_aff_sal = [
1419 \"SET ISO8859-1",
1420 \"TRY esianrtolcdugmphbyfvkwjkqxz-\xEB\xE9\xE8\xEA\xEF\xEE\xE4\xE0\xE2\xF6\xFC\xFB'ESIANRTOLCDUGMPHBYFVKWJKQXZ",
1421 \"",
1422 \"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",
1423 \"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",
1424 \"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",
1425 \"",
1426 \"MIDWORD\t'-",
1427 \"",
1428 \"KEP =",
1429 \"RAR ?",
1430 \"BAD !",
1431 \"",
1432 \"PFX I N 1",
1433 \"PFX I 0 in .",
1434 \"",
1435 \"PFX O Y 1",
1436 \"PFX O 0 out .",
1437 \"",
1438 \"SFX S Y 2",
1439 \"SFX S 0 s [^s]",
1440 \"SFX S 0 es s",
1441 \"",
1442 \"SFX N N 3",
1443 \"SFX N 0 en [^n]",
1444 \"SFX N 0 nen n",
1445 \"SFX N 0 n .",
1446 \"",
1447 \"REP 3",
1448 \"REP g ch",
1449 \"REP ch g",
1450 \"REP svp s.v.p.",
1451 \"",
1452 \"MAP 9",
1453 \"MAP a\xE0\xE1\xE2\xE3\xE4\xE5",
1454 \"MAP e\xE8\xE9\xEA\xEB",
1455 \"MAP i\xEC\xED\xEE\xEF",
1456 \"MAP o\xF2\xF3\xF4\xF5\xF6",
1457 \"MAP u\xF9\xFA\xFB\xFC",
1458 \"MAP n\xF1",
1459 \"MAP c\xE7",
1460 \"MAP y\xFF\xFD",
1461 \"MAP s\xDF",
1462 \"",
1463 \"SAL AH(AEIOUY)-^ *H",
1464 \"SAL AR(AEIOUY)-^ *R",
1465 \"SAL A(HR)^ *",
1466 \"SAL A^ *",
1467 \"SAL AH(AEIOUY)- H",
1468 \"SAL AR(AEIOUY)- R",
1469 \"SAL A(HR) _",
1470 \"SAL \xC0^ *",
1471 \"SAL \xC5^ *",
1472 \"SAL BB- _",
1473 \"SAL B B",
1474 \"SAL CQ- _",
1475 \"SAL CIA X",
1476 \"SAL CH X",
1477 \"SAL C(EIY)- S",
1478 \"SAL CK K",
1479 \"SAL COUGH^ KF",
1480 \"SAL CC< C",
1481 \"SAL C K",
1482 \"SAL DG(EIY) K",
1483 \"SAL DD- _",
1484 \"SAL D T",
1485 \"SAL \xC9< E",
1486 \"SAL EH(AEIOUY)-^ *H",
1487 \"SAL ER(AEIOUY)-^ *R",
1488 \"SAL E(HR)^ *",
1489 \"SAL ENOUGH^$ *NF",
1490 \"SAL E^ *",
1491 \"SAL EH(AEIOUY)- H",
1492 \"SAL ER(AEIOUY)- R",
1493 \"SAL E(HR) _",
1494 \"SAL FF- _",
1495 \"SAL F F",
1496 \"SAL GN^ N",
1497 \"SAL GN$ N",
1498 \"SAL GNS$ NS",
1499 \"SAL GNED$ N",
1500 \"SAL GH(AEIOUY)- K",
1501 \"SAL GH _",
1502 \"SAL GG9 K",
1503 \"SAL G K",
1504 \"SAL H H",
1505 \"SAL IH(AEIOUY)-^ *H",
1506 \"SAL IR(AEIOUY)-^ *R",
1507 \"SAL I(HR)^ *",
1508 \"SAL I^ *",
1509 \"SAL ING6 N",
1510 \"SAL IH(AEIOUY)- H",
1511 \"SAL IR(AEIOUY)- R",
1512 \"SAL I(HR) _",
1513 \"SAL J K",
1514 \"SAL KN^ N",
1515 \"SAL KK- _",
1516 \"SAL K K",
1517 \"SAL LAUGH^ LF",
1518 \"SAL LL- _",
1519 \"SAL L L",
1520 \"SAL MB$ M",
1521 \"SAL MM M",
1522 \"SAL M M",
1523 \"SAL NN- _",
1524 \"SAL N N",
1525 \"SAL OH(AEIOUY)-^ *H",
1526 \"SAL OR(AEIOUY)-^ *R",
1527 \"SAL O(HR)^ *",
1528 \"SAL O^ *",
1529 \"SAL OH(AEIOUY)- H",
1530 \"SAL OR(AEIOUY)- R",
1531 \"SAL O(HR) _",
1532 \"SAL PH F",
1533 \"SAL PN^ N",
1534 \"SAL PP- _",
1535 \"SAL P P",
1536 \"SAL Q K",
1537 \"SAL RH^ R",
1538 \"SAL ROUGH^ RF",
1539 \"SAL RR- _",
1540 \"SAL R R",
1541 \"SAL SCH(EOU)- SK",
1542 \"SAL SC(IEY)- S",
1543 \"SAL SH X",
1544 \"SAL SI(AO)- X",
1545 \"SAL SS- _",
1546 \"SAL S S",
1547 \"SAL TI(AO)- X",
1548 \"SAL TH @",
1549 \"SAL TCH-- _",
1550 \"SAL TOUGH^ TF",
1551 \"SAL TT- _",
1552 \"SAL T T",
1553 \"SAL UH(AEIOUY)-^ *H",
1554 \"SAL UR(AEIOUY)-^ *R",
1555 \"SAL U(HR)^ *",
1556 \"SAL U^ *",
1557 \"SAL UH(AEIOUY)- H",
1558 \"SAL UR(AEIOUY)- R",
1559 \"SAL U(HR) _",
1560 \"SAL V^ W",
1561 \"SAL V F",
1562 \"SAL WR^ R",
1563 \"SAL WH^ W",
1564 \"SAL W(AEIOU)- W",
1565 \"SAL X^ S",
1566 \"SAL X KS",
1567 \"SAL Y(AEIOU)- Y",
1568 \"SAL ZZ- _",
1569 \"SAL Z S",
1570 \ ]
Bram Moolenaar0e05de42020-03-25 22:23:46 +01001571
1572" vim: shiftwidth=2 sts=2 expandtab