blob: 170ea57926ac2b4e934c3a99eda64d326d99d401 [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 +02004CheckFeature spell
Bram Moolenaard3f78dc2017-02-25 14:21:10 +01005
Christian Brabandteb380b92025-07-07 20:53:55 +02006source util/screendump.vim
Bram Moolenaar7751d1d2019-10-18 20:37:08 +02007
Bram Moolenaar1a0f2002017-07-28 15:38:10 +02008func TearDown()
9 set nospell
10 call delete('Xtest.aff')
11 call delete('Xtest.dic')
12 call delete('Xtest.latin1.add')
13 call delete('Xtest.latin1.add.spl')
14 call delete('Xtest.latin1.spl')
15 call delete('Xtest.latin1.sug')
zeertzjq288ed232022-07-04 11:03:07 +010016 " set 'encoding' to clear the word list
17 set encoding=utf-8
Bram Moolenaar1a0f2002017-07-28 15:38:10 +020018endfunc
19
Bram Moolenaard3f78dc2017-02-25 14:21:10 +010020func Test_wrap_search()
21 new
22 call setline(1, ['The', '', 'A plong line with two zpelling mistakes', '', 'End'])
23 set spell wrapscan
24 normal ]s
25 call assert_equal('plong', expand('<cword>'))
26 normal ]s
27 call assert_equal('zpelling', expand('<cword>'))
28 normal ]s
29 call assert_equal('plong', expand('<cword>'))
30 bwipe!
31 set nospell
32endfunc
Bram Moolenaar5b276aa2017-04-22 23:49:52 +020033
Bram Moolenaarb73fa622017-12-21 20:27:47 +010034func Test_curswant()
35 new
36 call setline(1, ['Another plong line', 'abcdefghijklmnopq'])
37 set spell wrapscan
38 normal 0]s
39 call assert_equal('plong', expand('<cword>'))
40 normal j
41 call assert_equal(9, getcurpos()[2])
42 normal 0[s
43 call assert_equal('plong', expand('<cword>'))
44 normal j
45 call assert_equal(9, getcurpos()[2])
46
47 normal 0]S
48 call assert_equal('plong', expand('<cword>'))
49 normal j
50 call assert_equal(9, getcurpos()[2])
51 normal 0[S
52 call assert_equal('plong', expand('<cword>'))
53 normal j
54 call assert_equal(9, getcurpos()[2])
55
56 normal 1G0
57 call assert_equal('plong', spellbadword()[0])
58 normal j
59 call assert_equal(9, getcurpos()[2])
60
61 bwipe!
62 set nospell
63endfunc
64
Bram Moolenaar5b276aa2017-04-22 23:49:52 +020065func Test_z_equal_on_invalid_utf8_word()
66 split
67 set spell
68 call setline(1, "\xff")
69 norm z=
70 set nospell
71 bwipe!
72endfunc
Bram Moolenaar545cb792017-05-23 11:31:22 +020073
Bram Moolenaar156d3912022-06-18 14:09:08 +010074func Test_z_equal_on_single_character()
75 " this was decrementing the index below zero
76 new
77 norm a0\Ê
78 norm zW
79 norm z=
80
81 bwipe!
82endfunc
83
Bram Moolenaar872e4512018-07-20 23:36:26 +020084" Test spellbadword() with argument
85func Test_spellbadword()
86 set spell
87
88 call assert_equal(['bycycle', 'bad'], spellbadword('My bycycle.'))
Bram Moolenaarf6ed61e2019-09-07 19:05:09 +020089 call assert_equal(['another', 'caps'], 'A sentence. another sentence'->spellbadword())
Bram Moolenaar872e4512018-07-20 23:36:26 +020090
Bram Moolenaar362b44b2020-06-10 21:47:00 +020091 call assert_equal(['TheCamelWord', 'bad'], 'TheCamelWord asdf'->spellbadword())
92 set spelloptions=camel
93 call assert_equal(['asdf', 'bad'], 'TheCamelWord asdf'->spellbadword())
94 set spelloptions=
95
Bram Moolenaar872e4512018-07-20 23:36:26 +020096 set spelllang=en
97 call assert_equal(['', ''], spellbadword('centre'))
98 call assert_equal(['', ''], spellbadword('center'))
99 set spelllang=en_us
100 call assert_equal(['centre', 'local'], spellbadword('centre'))
101 call assert_equal(['', ''], spellbadword('center'))
102 set spelllang=en_gb
103 call assert_equal(['', ''], spellbadword('centre'))
104 call assert_equal(['center', 'local'], spellbadword('center'))
105
106 " Create a small word list to test that spellbadword('...')
107 " can return ['...', 'rare'].
108 e Xwords
109 insert
110foo
111foobar/?
112.
113 w!
114 mkspell! Xwords.spl Xwords
115 set spelllang=Xwords.spl
116 call assert_equal(['foobar', 'rare'], spellbadword('foo foobar'))
117
Bram Moolenaar152e79e2020-06-10 15:32:08 +0200118 " Typo should be detected even without the 'spell' option.
Bram Moolenaar872e4512018-07-20 23:36:26 +0200119 set spelllang=en_gb nospell
120 call assert_equal(['', ''], spellbadword('centre'))
Bram Moolenaar152e79e2020-06-10 15:32:08 +0200121 call assert_equal(['bycycle', 'bad'], spellbadword('My bycycle.'))
122 call assert_equal(['another', 'caps'], spellbadword('A sentence. another sentence'))
123
124 set spelllang=
125 call assert_fails("call spellbadword('maxch')", 'E756:')
Bram Moolenaar96fdf432020-09-11 18:11:50 +0200126 call assert_fails("spelldump", 'E756:')
Bram Moolenaar872e4512018-07-20 23:36:26 +0200127
128 call delete('Xwords.spl')
129 call delete('Xwords')
130 set spelllang&
131 set spell&
132endfunc
133
LemonBoyd0874502023-08-27 21:52:27 +0200134func Test_spell_camelcase()
135 set spell spelloptions=camel
136 let words = [
137 \ 'UPPER',
138 \ 'lower',
139 \ 'mixedCase',
140 \ 'HTML',
141 \ 'XMLHttpRequest',
142 \ 'foo123bar',
143 \ '12345678',
144 \ 'HELLO123world',
145 \]
146
147 for word in words
148 call assert_equal(['', ''], spellbadword(word))
149 endfor
150
151 set spell& spelloptions&
152endfunc
153
Bram Moolenaard569a9e2020-09-28 23:13:15 +0200154func Test_spell_file_missing()
155 let s:spell_file_missing = 0
156 augroup TestSpellFileMissing
157 autocmd! SpellFileMissing * let s:spell_file_missing += 1
158 augroup END
159
160 set spell spelllang=ab_cd
161 let messages = GetMessages()
162 call assert_equal('Warning: Cannot find word list "ab.utf-8.spl" or "ab.ascii.spl"', messages[-1])
163 call assert_equal(1, s:spell_file_missing)
164
165 new XTestSpellFileMissing
166 augroup TestSpellFileMissing
167 autocmd! SpellFileMissing * bwipe
168 augroup END
Bram Moolenaar371951d2022-09-28 14:08:23 +0100169 call assert_fails('set spell spelllang=ab_cd', 'E937:')
Bram Moolenaard569a9e2020-09-28 23:13:15 +0200170
Bram Moolenaarfc9f0fd2022-06-15 16:57:44 +0100171 " clean up
172 augroup TestSpellFileMissing
173 autocmd! SpellFileMissing
174 augroup END
Bram Moolenaard569a9e2020-09-28 23:13:15 +0200175 augroup! TestSpellFileMissing
176 unlet s:spell_file_missing
177 set spell& spelllang&
178 %bwipe!
179endfunc
180
Bram Moolenaarc3d27ad2022-11-14 20:52:14 +0000181func Test_spell_file_missing_bwipe()
182 " this was using a window that was wiped out in a SpellFileMissing autocmd
183 set spelllang=xy
184 au SpellFileMissing * n0
185 set spell
186 au SpellFileMissing * bw
187 snext somefile
188
189 au! SpellFileMissing
190 bwipe!
191 set nospell spelllang=en
192endfunc
193
Bram Moolenaarf12f0022020-10-07 12:58:44 +0200194func Test_spelldump()
Bram Moolenaarfc9f0fd2022-06-15 16:57:44 +0100195 " In case the spell file is not found avoid getting the download dialog, we
196 " would get stuck at the prompt.
197 let g:en_not_found = 0
198 augroup TestSpellFileMissing
199 au! SpellFileMissing * let g:en_not_found = 1
200 augroup END
Bram Moolenaarf12f0022020-10-07 12:58:44 +0200201 set spell spelllang=en
202 spellrare! emacs
Bram Moolenaarfc9f0fd2022-06-15 16:57:44 +0100203 if g:en_not_found
204 call assert_report("Could not find English spell file")
205 else
206 spelldump
Bram Moolenaarf12f0022020-10-07 12:58:44 +0200207
Bram Moolenaarfc9f0fd2022-06-15 16:57:44 +0100208 " Check assumption about region: 1: us, 2: au, 3: ca, 4: gb, 5: nz.
209 call assert_equal('/regions=usaucagbnz', getline(1))
210 call assert_notequal(0, search('^theater/1$')) " US English only.
211 call assert_notequal(0, search('^theatre/2345$')) " AU, CA, GB or NZ English.
Bram Moolenaarf12f0022020-10-07 12:58:44 +0200212
Bram Moolenaarfc9f0fd2022-06-15 16:57:44 +0100213 call assert_notequal(0, search('^emacs/?$')) " ? for a rare word.
214 call assert_notequal(0, search('^the the/!$')) " ! for a wrong word.
215 endif
Bram Moolenaarf12f0022020-10-07 12:58:44 +0200216
Bram Moolenaarfc9f0fd2022-06-15 16:57:44 +0100217 " clean up
218 unlet g:en_not_found
219 augroup TestSpellFileMissing
220 autocmd! SpellFileMissing
221 augroup END
222 augroup! TestSpellFileMissing
Bram Moolenaarf12f0022020-10-07 12:58:44 +0200223 bwipe
224 set spell&
225endfunc
226
227func Test_spelldump_bang()
228 new
229 call setline(1, 'This is a sample sentence.')
230 redraw
Bram Moolenaarfc9f0fd2022-06-15 16:57:44 +0100231
232 " In case the spell file is not found avoid getting the download dialog, we
233 " would get stuck at the prompt.
234 let g:en_not_found = 0
235 augroup TestSpellFileMissing
236 au! SpellFileMissing * let g:en_not_found = 1
237 augroup END
238
Bram Moolenaarf12f0022020-10-07 12:58:44 +0200239 set spell
Bram Moolenaarf12f0022020-10-07 12:58:44 +0200240
Bram Moolenaarfc9f0fd2022-06-15 16:57:44 +0100241 if g:en_not_found
242 call assert_report("Could not find English spell file")
243 else
244 redraw
245 spelldump!
Bram Moolenaarf12f0022020-10-07 12:58:44 +0200246
Bram Moolenaarfc9f0fd2022-06-15 16:57:44 +0100247 " :spelldump! includes the number of times a word was found while updating
248 " the screen.
249 " Common word count starts at 10, regular word count starts at 0.
250 call assert_notequal(0, search("^is\t11$")) " common word found once.
251 call assert_notequal(0, search("^the\t10$")) " common word never found.
252 call assert_notequal(0, search("^sample\t1$")) " regular word found once.
253 call assert_equal(0, search("^screen\t")) " regular word never found.
254 endif
255
256 " clean up
257 unlet g:en_not_found
258 augroup TestSpellFileMissing
259 autocmd! SpellFileMissing
260 augroup END
261 augroup! TestSpellFileMissing
Bram Moolenaarf12f0022020-10-07 12:58:44 +0200262 %bwipe!
263 set spell&
264endfunc
265
Bram Moolenaar8c7ad362020-09-27 13:58:38 +0200266func Test_spelllang_inv_region()
267 set spell spelllang=en_xx
268 let messages = GetMessages()
269 call assert_equal('Warning: region xx not supported', messages[-1])
270 set spell& spelllang&
271endfunc
272
273func Test_compl_with_CTRL_X_CTRL_K_using_spell()
274 " When spell checking is enabled and 'dictionary' is empty,
275 " CTRL-X CTRL-K in insert mode completes using the spelling dictionary.
276 new
277 set spell spelllang=en dictionary=
278
279 set ignorecase
280 call feedkeys("Senglis\<c-x>\<c-k>\<esc>", 'tnx')
281 call assert_equal(['English'], getline(1, '$'))
282 call feedkeys("SEnglis\<c-x>\<c-k>\<esc>", 'tnx')
283 call assert_equal(['English'], getline(1, '$'))
284
285 set noignorecase
286 call feedkeys("Senglis\<c-x>\<c-k>\<esc>", 'tnx')
287 call assert_equal(['englis'], getline(1, '$'))
288 call feedkeys("SEnglis\<c-x>\<c-k>\<esc>", 'tnx')
289 call assert_equal(['English'], getline(1, '$'))
290
291 set spelllang=en_us
292 call feedkeys("Stheat\<c-x>\<c-k>\<esc>", 'tnx')
293 call assert_equal(['theater'], getline(1, '$'))
294 set spelllang=en_gb
295 call feedkeys("Stheat\<c-x>\<c-k>\<esc>", 'tnx')
LemonBoye98fb642023-08-15 23:07:55 +0200296 call assert_equal(['theatre'], getline(1, '$'))
Bram Moolenaar8c7ad362020-09-27 13:58:38 +0200297
298 bwipe!
299 set spell& spelllang& dictionary& ignorecase&
300endfunc
301
zeertzjq7002c052024-06-21 07:55:07 +0200302func Test_compl_with_CTRL_X_s()
303 new
304 set spell spelllang=en_us showmode
305 inoremap <buffer><F2> <Cmd>let g:msg = Screenline(&lines)<CR>
306
307 call feedkeys("STheatre\<C-X>s\<F2>\<C-Y>\<Esc>", 'tx')
308 call assert_equal(['Theater'], getline(1, '$'))
309 call assert_match('(^S^N^P)', g:msg)
310
311 bwipe!
312 set spell& spelllang& showmode&
313 unlet g:msg
314endfunc
315
zeertzjq59f70382023-06-06 15:59:59 +0100316func Test_spellrepall()
Bram Moolenaar545cb792017-05-23 11:31:22 +0200317 new
318 set spell
319 call assert_fails('spellrepall', 'E752:')
320 call setline(1, ['A speling mistake. The same speling mistake.',
Bram Moolenaard2c061d2017-06-22 21:42:49 +0200321 \ 'Another speling mistake.'])
Bram Moolenaar545cb792017-05-23 11:31:22 +0200322 call feedkeys(']s1z=', 'tx')
323 call assert_equal('A spelling mistake. The same speling mistake.', getline(1))
324 call assert_equal('Another speling mistake.', getline(2))
325 spellrepall
326 call assert_equal('A spelling mistake. The same spelling mistake.', getline(1))
327 call assert_equal('Another spelling mistake.', getline(2))
328 call assert_fails('spellrepall', 'E753:')
329 set spell&
330 bwipe!
331endfunc
Bram Moolenaard2c061d2017-06-22 21:42:49 +0200332
Bram Moolenaar54e5fed2022-07-04 13:37:07 +0100333func Test_spell_dump_word_length()
334 " this was running over MAXWLEN
335 new
336 noremap 0 0a0zW0000000
337 sil! norm 0z=0
338 sil norm 0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
339 sil! norm 0z=0
340
341 bwipe!
342 nunmap 0
343endfunc
344
Bram Moolenaare9a8d1f2019-12-25 13:36:36 +0100345" Test spellsuggest({word} [, {max} [, {capital}]])
346func Test_spellsuggest()
Bram Moolenaar152e79e2020-06-10 15:32:08 +0200347 " Verify suggestions are given even when spell checking is not enabled.
Bram Moolenaare9a8d1f2019-12-25 13:36:36 +0100348 set nospell
Bram Moolenaar152e79e2020-06-10 15:32:08 +0200349 call assert_equal(['march', 'March'], spellsuggest('marrch', 2))
Bram Moolenaare9a8d1f2019-12-25 13:36:36 +0100350
351 set spell
352
353 " With 1 argument.
Bram Moolenaar76734052019-12-26 14:30:15 +0100354 call assert_equal(['march', 'March'], spellsuggest('marrch')[0:1])
Bram Moolenaare9a8d1f2019-12-25 13:36:36 +0100355
356 " With 2 arguments.
Bram Moolenaar76734052019-12-26 14:30:15 +0100357 call assert_equal(['march', 'March'], spellsuggest('marrch', 2))
Bram Moolenaare9a8d1f2019-12-25 13:36:36 +0100358
359 " With 3 arguments.
Bram Moolenaar76734052019-12-26 14:30:15 +0100360 call assert_equal(['march'], spellsuggest('marrch', 1, 0))
361 call assert_equal(['March'], spellsuggest('marrch', 1, 1))
Bram Moolenaare9a8d1f2019-12-25 13:36:36 +0100362
363 " Test with digits and hyphen.
364 call assert_equal('Carbon-14', spellsuggest('Carbon-15')[0])
365
366 " Comment taken from spellsuggest.c explains the following test cases:
367 "
368 " If there are more UPPER than lower case letters suggest an
369 " ALLCAP word. Otherwise, if the first letter is UPPER then
370 " suggest ONECAP. Exception: "ALl" most likely should be "All",
371 " require three upper case letters.
Bram Moolenaar76734052019-12-26 14:30:15 +0100372 call assert_equal(['THIRD', 'third'], spellsuggest('thIRD', 2))
373 call assert_equal(['third', 'THIRD'], spellsuggest('tHIrd', 2))
374 call assert_equal(['Third'], spellsuggest('THird', 1))
Bram Moolenaare9a8d1f2019-12-25 13:36:36 +0100375 call assert_equal(['All'], spellsuggest('ALl', 1))
376
Dominique Pellef645ee42021-12-05 13:21:18 +0000377 " Special suggestion for repeated 'the the'.
378 call assert_inrange(0, 2, index(spellsuggest('the the', 3), 'the'))
379 call assert_inrange(0, 2, index(spellsuggest('the the', 3), 'the'))
380 call assert_inrange(0, 2, index(spellsuggest('The the', 3), 'The'))
381
Bram Moolenaar0e05de42020-03-25 22:23:46 +0100382 call assert_fails("call spellsuggest('maxch', [])", 'E745:')
383 call assert_fails("call spellsuggest('maxch', 2, [])", 'E745:')
384
Bram Moolenaar152e79e2020-06-10 15:32:08 +0200385 set spelllang=
386 call assert_fails("call spellsuggest('maxch')", 'E756:')
387 set spelllang&
388
Bram Moolenaare9a8d1f2019-12-25 13:36:36 +0100389 set spell&
390endfunc
391
392" Test 'spellsuggest' option with methods fast, best and double.
393func Test_spellsuggest_option_methods()
394 set spell
395
Bram Moolenaar76734052019-12-26 14:30:15 +0100396 for e in ['latin1', 'utf-8']
397 exe 'set encoding=' .. e
Bram Moolenaare9a8d1f2019-12-25 13:36:36 +0100398
Bram Moolenaar76734052019-12-26 14:30:15 +0100399 set spellsuggest=fast
400 call assert_equal(['Stick', 'Stitch'], spellsuggest('Stich', 2), e)
Bram Moolenaare9a8d1f2019-12-25 13:36:36 +0100401
Bram Moolenaar76734052019-12-26 14:30:15 +0100402 " With best or double option, "Stitch" should become the top suggestion
403 " because of better phonetic matching.
404 set spellsuggest=best
405 call assert_equal(['Stitch', 'Stick'], spellsuggest('Stich', 2), e)
Bram Moolenaare9a8d1f2019-12-25 13:36:36 +0100406
Bram Moolenaar76734052019-12-26 14:30:15 +0100407 set spellsuggest=double
408 call assert_equal(['Stitch', 'Stick'], spellsuggest('Stich', 2), e)
409 endfor
410
411 set spell& spellsuggest& encoding&
Bram Moolenaare9a8d1f2019-12-25 13:36:36 +0100412endfunc
413
414" Test 'spellsuggest' option with value file:{filename}
415func Test_spellsuggest_option_file()
416 set spell spellsuggest=file:Xspellsuggest
417 call writefile(['emacs/vim',
418 \ 'theribal/terrible',
419 \ 'teribal/terrrible',
420 \ 'terribal'],
421 \ 'Xspellsuggest')
422
423 call assert_equal(['vim'], spellsuggest('emacs', 2))
424 call assert_equal(['terrible'], spellsuggest('theribal',2))
425
426 " If the suggestion is misspelled (*terrrible* with 3 r),
427 " it should not be proposed.
428 " The entry for "terribal" should be ignored because of missing slash.
429 call assert_equal([], spellsuggest('teribal', 2))
430 call assert_equal([], spellsuggest('terribal', 2))
431
432 set spell spellsuggest=best,file:Xspellsuggest
433 call assert_equal(['vim', 'Emacs'], spellsuggest('emacs', 2))
434 call assert_equal(['terrible', 'tribal'], spellsuggest('theribal', 2))
435 call assert_equal(['tribal'], spellsuggest('teribal', 1))
436 call assert_equal(['tribal'], spellsuggest('terribal', 1))
437
438 call delete('Xspellsuggest')
439 call assert_fails("call spellsuggest('vim')", "E484: Can't open file Xspellsuggest")
440
441 set spellsuggest& spell&
442endfunc
443
444" Test 'spellsuggest' option with value {number}
445" to limit the number of suggestions
446func Test_spellsuggest_option_number()
447 set spell spellsuggest=2,best
448 new
449
450 " We limited the number of suggestions to 2, so selecting
451 " the 1st and 2nd suggestion should correct the word, but
452 " selecting a 3rd suggestion should do nothing.
Bram Moolenaar76734052019-12-26 14:30:15 +0100453 call setline(1, 'A baord')
454 norm $1z=
455 call assert_equal('A board', getline(1))
Bram Moolenaare9a8d1f2019-12-25 13:36:36 +0100456
Bram Moolenaar76734052019-12-26 14:30:15 +0100457 call setline(1, 'A baord')
458 norm $2z=
459 call assert_equal('A bard', getline(1))
Bram Moolenaare9a8d1f2019-12-25 13:36:36 +0100460
Bram Moolenaar76734052019-12-26 14:30:15 +0100461 call setline(1, 'A baord')
462 norm $3z=
463 call assert_equal('A baord', getline(1))
Bram Moolenaare9a8d1f2019-12-25 13:36:36 +0100464
Bram Moolenaar76734052019-12-26 14:30:15 +0100465 let a = execute('norm $z=')
Bram Moolenaare9a8d1f2019-12-25 13:36:36 +0100466 call assert_equal(
467 \ "\n"
Bram Moolenaar76734052019-12-26 14:30:15 +0100468 \ .. "Change \"baord\" to:\n"
469 \ .. " 1 \"board\"\n"
470 \ .. " 2 \"bard\"\n"
Bram Moolenaard281b7c2020-06-10 16:39:32 +0200471 \ .. "Type number and <Enter> or click with the mouse (q or empty cancels): ", a)
Bram Moolenaare9a8d1f2019-12-25 13:36:36 +0100472
473 set spell spellsuggest=0
Bram Moolenaar76734052019-12-26 14:30:15 +0100474 call assert_equal("\nSorry, no suggestions", execute('norm $z='))
Bram Moolenaare9a8d1f2019-12-25 13:36:36 +0100475
476 " Unlike z=, function spellsuggest(...) should not be affected by the
477 " max number of suggestions (2) set by the 'spellsuggest' option.
Bram Moolenaar76734052019-12-26 14:30:15 +0100478 call assert_equal(['board', 'bard', 'broad'], spellsuggest('baord', 3))
Bram Moolenaare9a8d1f2019-12-25 13:36:36 +0100479
480 set spellsuggest& spell&
481 bwipe!
482endfunc
483
484" Test 'spellsuggest' option with value expr:{expr}
485func Test_spellsuggest_option_expr()
486 " A silly 'spellsuggest' function which makes suggestions all uppercase
487 " and makes the score of each suggestion the length of the suggested word.
488 " So shorter suggestions are preferred.
489 func MySuggest()
490 let spellsuggest_save = &spellsuggest
Bram Moolenaar76734052019-12-26 14:30:15 +0100491 set spellsuggest=3,best
Bram Moolenaare9a8d1f2019-12-25 13:36:36 +0100492 let result = map(spellsuggest(v:val, 3), "[toupper(v:val), len(v:val)]")
493 let &spellsuggest = spellsuggest_save
494 return result
495 endfunc
496
Bram Moolenaar76734052019-12-26 14:30:15 +0100497 set spell spellsuggest=expr:MySuggest()
498 call assert_equal(['BARD', 'BOARD', 'BROAD'], spellsuggest('baord', 3))
Bram Moolenaare9a8d1f2019-12-25 13:36:36 +0100499
500 new
Bram Moolenaar76734052019-12-26 14:30:15 +0100501 call setline(1, 'baord')
Bram Moolenaare9a8d1f2019-12-25 13:36:36 +0100502 let a = execute('norm z=')
503 call assert_equal(
504 \ "\n"
Bram Moolenaar76734052019-12-26 14:30:15 +0100505 \ .. "Change \"baord\" to:\n"
506 \ .. " 1 \"BARD\"\n"
507 \ .. " 2 \"BOARD\"\n"
508 \ .. " 3 \"BROAD\"\n"
Bram Moolenaard281b7c2020-06-10 16:39:32 +0200509 \ .. "Type number and <Enter> or click with the mouse (q or empty cancels): ", a)
Bram Moolenaare9a8d1f2019-12-25 13:36:36 +0100510
511 " With verbose, z= should show the score i.e. word length with
512 " our SpellSuggest() function.
513 set verbose=1
514 let a = execute('norm z=')
515 call assert_equal(
516 \ "\n"
Bram Moolenaar76734052019-12-26 14:30:15 +0100517 \ .. "Change \"baord\" to:\n"
518 \ .. " 1 \"BARD\" (4 - 0)\n"
519 \ .. " 2 \"BOARD\" (5 - 0)\n"
520 \ .. " 3 \"BROAD\" (5 - 0)\n"
Bram Moolenaard281b7c2020-06-10 16:39:32 +0200521 \ .. "Type number and <Enter> or click with the mouse (q or empty cancels): ", a)
Bram Moolenaare9a8d1f2019-12-25 13:36:36 +0100522
523 set spell& spellsuggest& verbose&
524 bwipe!
525endfunc
526
Dominique Pelle81b573d2022-03-22 21:14:55 +0000527" Test for 'spellsuggest' expr errors
Bram Moolenaar8dfcce32020-03-18 19:32:26 +0100528func Test_spellsuggest_expr_errors()
529 " 'spellsuggest'
530 func MySuggest()
531 return range(3)
532 endfunc
533 set spell spellsuggest=expr:MySuggest()
534 call assert_equal([], spellsuggest('baord', 3))
535
536 " Test for 'spellsuggest' expression returning a non-list value
537 func! MySuggest2()
538 return 'good'
539 endfunc
540 set spellsuggest=expr:MySuggest2()
541 call assert_equal([], spellsuggest('baord'))
542
543 " Test for 'spellsuggest' expression returning a list with dict values
544 func! MySuggest3()
545 return [[{}, {}]]
546 endfunc
547 set spellsuggest=expr:MySuggest3()
Bram Moolenaar9b7bf9e2020-07-11 22:14:59 +0200548 call assert_fails("call spellsuggest('baord')", 'E731:')
Bram Moolenaar8dfcce32020-03-18 19:32:26 +0100549
550 set nospell spellsuggest&
551 delfunc MySuggest
552 delfunc MySuggest2
553 delfunc MySuggest3
554endfunc
555
Bram Moolenaar585ee072022-01-29 11:22:17 +0000556func Test_spellsuggest_timeout()
557 set spellsuggest=timeout:30
558 set spellsuggest=timeout:-123
559 set spellsuggest=timeout:999999
560 call assert_fails('set spellsuggest=timeout', 'E474:')
561 call assert_fails('set spellsuggest=timeout:x', 'E474:')
562 call assert_fails('set spellsuggest=timeout:-x', 'E474:')
563 call assert_fails('set spellsuggest=timeout:--9', 'E474:')
564endfunc
565
Bram Moolenaar5c686172022-03-13 20:12:25 +0000566func Test_spellsuggest_visual_end_of_line()
567 let enc_save = &encoding
568 set encoding=iso8859
569
570 " This was reading beyond the end of the line.
571 norm R00000000000
572 sil norm 0
573 sil! norm i00000)
574 sil! norm i00000)
575 call feedkeys("\<CR>")
576 norm z=
577
578 let &encoding = enc_save
579endfunc
580
Bram Moolenaar9049b682018-08-31 22:26:53 +0200581func Test_spellinfo()
582 new
Bram Moolenaarc25e7022019-10-10 14:08:26 +0200583 let runtime = substitute($VIMRUNTIME, '\\', '/', 'g')
Bram Moolenaar9049b682018-08-31 22:26:53 +0200584
585 set enc=latin1 spell spelllang=en
Bram Moolenaarc25e7022019-10-10 14:08:26 +0200586 call assert_match("^\nfile: " .. runtime .. "/spell/en.latin1.spl\n$", execute('spellinfo'))
Bram Moolenaar9049b682018-08-31 22:26:53 +0200587
588 set enc=cp1250 spell spelllang=en
Bram Moolenaarc25e7022019-10-10 14:08:26 +0200589 call assert_match("^\nfile: " .. runtime .. "/spell/en.ascii.spl\n$", execute('spellinfo'))
Bram Moolenaar9049b682018-08-31 22:26:53 +0200590
Bram Moolenaar30276f22019-01-24 17:59:39 +0100591 set enc=utf-8 spell spelllang=en
Bram Moolenaarc25e7022019-10-10 14:08:26 +0200592 call assert_match("^\nfile: " .. runtime .. "/spell/en.utf-8.spl\n$", execute('spellinfo'))
Bram Moolenaar9049b682018-08-31 22:26:53 +0200593
594 set enc=latin1 spell spelllang=en_us,en_nz
595 call assert_match("^\n" .
Bram Moolenaarc25e7022019-10-10 14:08:26 +0200596 \ "file: " .. runtime .. "/spell/en.latin1.spl\n" .
597 \ "file: " .. runtime.. "/spell/en.latin1.spl\n$", execute('spellinfo'))
Bram Moolenaar9049b682018-08-31 22:26:53 +0200598
599 set spell spelllang=
600 call assert_fails('spellinfo', 'E756:')
601
602 set nospell spelllang=en
603 call assert_fails('spellinfo', 'E756:')
604
Bram Moolenaar8f130ed2019-04-10 22:15:19 +0200605 call assert_fails('set spelllang=foo/bar', 'E474:')
606 call assert_fails('set spelllang=foo\ bar', 'E474:')
607 call assert_fails("set spelllang=foo\\\nbar", 'E474:')
608 call assert_fails("set spelllang=foo\\\rbar", 'E474:')
609 call assert_fails("set spelllang=foo+bar", 'E474:')
610
Bram Moolenaar9049b682018-08-31 22:26:53 +0200611 set enc& spell& spelllang&
612 bwipe
613endfunc
614
Bram Moolenaard2c061d2017-06-22 21:42:49 +0200615func Test_zz_basic()
616 call LoadAffAndDic(g:test_data_aff1, g:test_data_dic1)
617 call RunGoodBad("wrong OK puts. Test the end",
618 \ "bad: inputs comment ok Ok. test d\xE9\xF4l end the",
619 \["Comment", "deol", "d\xE9\xF4r", "input", "OK", "output", "outputs", "outtest", "put", "puts",
620 \ "test", "testen", "testn", "the end", "uk", "wrong"],
621 \[
622 \ ["bad", ["put", "uk", "OK"]],
623 \ ["inputs", ["input", "puts", "outputs"]],
624 \ ["comment", ["Comment", "outtest", "the end"]],
625 \ ["ok", ["OK", "uk", "put"]],
626 \ ["Ok", ["OK", "Uk", "Put"]],
627 \ ["test", ["Test", "testn", "testen"]],
628 \ ["d\xE9\xF4l", ["deol", "d\xE9\xF4r", "test"]],
629 \ ["end", ["put", "uk", "test"]],
630 \ ["the", ["put", "uk", "test"]],
631 \ ]
632 \ )
633
634 call assert_equal("gebletegek", soundfold('goobledygoook'))
Bram Moolenaarf6ed61e2019-09-07 19:05:09 +0200635 call assert_equal("kepereneven", 'kóopërÿnôven'->soundfold())
Bram Moolenaard2c061d2017-06-22 21:42:49 +0200636 call assert_equal("everles gesvets etele", soundfold('oeverloos gezwets edale'))
637endfunc
638
639" Postponed prefixes
640func Test_zz_prefixes()
641 call LoadAffAndDic(g:test_data_aff2, g:test_data_dic1)
642 call RunGoodBad("puts",
643 \ "bad: inputs comment ok Ok end the. test d\xE9\xF4l",
644 \ ["Comment", "deol", "d\xE9\xF4r", "OK", "put", "input", "output", "puts", "outputs", "test", "outtest", "testen", "testn", "the end", "uk", "wrong"],
645 \ [
646 \ ["bad", ["put", "uk", "OK"]],
647 \ ["inputs", ["input", "puts", "outputs"]],
648 \ ["comment", ["Comment"]],
649 \ ["ok", ["OK", "uk", "put"]],
650 \ ["Ok", ["OK", "Uk", "Put"]],
651 \ ["end", ["put", "uk", "deol"]],
652 \ ["the", ["put", "uk", "test"]],
653 \ ["test", ["Test", "testn", "testen"]],
654 \ ["d\xE9\xF4l", ["deol", "d\xE9\xF4r", "test"]],
655 \ ])
656endfunc
657
658"Compound words
659func Test_zz_compound()
660 call LoadAffAndDic(g:test_data_aff3, g:test_data_dic3)
661 call RunGoodBad("foo m\xEF foobar foofoobar barfoo barbarfoo",
662 \ "bad: bar la foom\xEF barm\xEF m\xEFfoo m\xEFbar m\xEFm\xEF lala m\xEFla lam\xEF foola labar",
663 \ ["foo", "m\xEF"],
664 \ [
665 \ ["bad", ["foo", "m\xEF"]],
666 \ ["bar", ["barfoo", "foobar", "foo"]],
667 \ ["la", ["m\xEF", "foo"]],
668 \ ["foom\xEF", ["foo m\xEF", "foo", "foofoo"]],
669 \ ["barm\xEF", ["barfoo", "m\xEF", "barbar"]],
670 \ ["m\xEFfoo", ["m\xEF foo", "foo", "foofoo"]],
671 \ ["m\xEFbar", ["foobar", "barbar", "m\xEF"]],
672 \ ["m\xEFm\xEF", ["m\xEF m\xEF", "m\xEF"]],
673 \ ["lala", []],
674 \ ["m\xEFla", ["m\xEF", "m\xEF m\xEF"]],
675 \ ["lam\xEF", ["m\xEF", "m\xEF m\xEF"]],
676 \ ["foola", ["foo", "foobar", "foofoo"]],
677 \ ["labar", ["barbar", "foobar"]],
678 \ ])
679
680 call LoadAffAndDic(g:test_data_aff4, g:test_data_dic4)
681 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",
682 \ "bad: wordutilize pro borkborkborkborkborkbork tomatotomatotomato endstart endend startstart wordend wordstart preborkprebork preborkpreborkbork startwordwordwordwordend borkpreborkpreborkbork utilsbork startnouword",
683 \ ["bork", "prebork", "end", "pro-ok", "start", "tomato", "util", "utilize", "utils", "word", "nouword"],
684 \ [
685 \ ["bad", ["end", "bork", "word"]],
686 \ ["wordutilize", ["word utilize", "wordutils", "wordutil"]],
687 \ ["pro", ["bork", "word", "end"]],
688 \ ["borkborkborkborkborkbork", ["bork borkborkborkborkbork", "borkbork borkborkborkbork", "borkborkbork borkborkbork"]],
689 \ ["tomatotomatotomato", ["tomato tomatotomato", "tomatotomato tomato", "tomato tomato tomato"]],
690 \ ["endstart", ["end start", "start"]],
691 \ ["endend", ["end end", "end"]],
692 \ ["startstart", ["start start"]],
693 \ ["wordend", ["word end", "word", "wordword"]],
694 \ ["wordstart", ["word start", "bork start"]],
695 \ ["preborkprebork", ["prebork prebork", "preborkbork", "preborkborkbork"]],
696 \ ["preborkpreborkbork", ["prebork preborkbork", "preborkborkbork", "preborkborkborkbork"]],
697 \ ["startwordwordwordwordend", ["startwordwordwordword end", "startwordwordwordword", "start wordwordwordword end"]],
698 \ ["borkpreborkpreborkbork", ["bork preborkpreborkbork", "bork prebork preborkbork", "bork preborkprebork bork"]],
699 \ ["utilsbork", ["utilbork", "utils bork", "util bork"]],
700 \ ["startnouword", ["start nouword", "startword", "startborkword"]],
701 \ ])
702
703endfunc
704
705"Test affix flags with two characters
706func Test_zz_affix()
707 call LoadAffAndDic(g:test_data_aff5, g:test_data_dic5)
708 call RunGoodBad("fooa1 fooa\xE9 bar prebar barbork prebarbork startprebar start end startend startmiddleend nouend",
709 \ "bad: foo fooa2 prabar probarbirk middle startmiddle middleend endstart startprobar startnouend",
710 \ ["bar", "barbork", "end", "fooa1", "fooa\xE9", "nouend", "prebar", "prebarbork", "start"],
711 \ [
712 \ ["bad", ["bar", "end", "fooa1"]],
713 \ ["foo", ["fooa1", "fooa\xE9", "bar"]],
714 \ ["fooa2", ["fooa1", "fooa\xE9", "bar"]],
715 \ ["prabar", ["prebar", "bar", "bar bar"]],
716 \ ["probarbirk", ["prebarbork"]],
717 \ ["middle", []],
718 \ ["startmiddle", ["startmiddleend", "startmiddlebar"]],
719 \ ["middleend", []],
720 \ ["endstart", ["end start", "start"]],
721 \ ["startprobar", ["startprebar", "start prebar", "startbar"]],
722 \ ["startnouend", ["start nouend", "startend"]],
723 \ ])
724
725 call LoadAffAndDic(g:test_data_aff6, g:test_data_dic6)
726 call RunGoodBad("meea1 meea\xE9 bar prebar barbork prebarbork leadprebar lead end leadend leadmiddleend",
727 \ "bad: mee meea2 prabar probarbirk middle leadmiddle middleend endlead leadprobar",
728 \ ["bar", "barbork", "end", "lead", "meea1", "meea\xE9", "prebar", "prebarbork"],
729 \ [
730 \ ["bad", ["bar", "end", "lead"]],
731 \ ["mee", ["meea1", "meea\xE9", "bar"]],
732 \ ["meea2", ["meea1", "meea\xE9", "lead"]],
733 \ ["prabar", ["prebar", "bar", "leadbar"]],
734 \ ["probarbirk", ["prebarbork"]],
735 \ ["middle", []],
736 \ ["leadmiddle", ["leadmiddleend", "leadmiddlebar"]],
737 \ ["middleend", []],
738 \ ["endlead", ["end lead", "lead", "end end"]],
739 \ ["leadprobar", ["leadprebar", "lead prebar", "leadbar"]],
740 \ ])
741
742 call LoadAffAndDic(g:test_data_aff7, g:test_data_dic7)
Bram Moolenaar3d2a47c2019-11-07 20:48:42 +0100743 call RunGoodBad("meea1 meezero meea\xE9 bar prebar barmeat prebarmeat leadprebar lead tail leadtail leadmiddletail",
Bram Moolenaard2c061d2017-06-22 21:42:49 +0200744 \ "bad: mee meea2 prabar probarmaat middle leadmiddle middletail taillead leadprobar",
Bram Moolenaar3d2a47c2019-11-07 20:48:42 +0100745 \ ["bar", "barmeat", "lead", "meea1", "meea\xE9", "meezero", "prebar", "prebarmeat", "tail"],
Bram Moolenaard2c061d2017-06-22 21:42:49 +0200746 \ [
747 \ ["bad", ["bar", "lead", "tail"]],
748 \ ["mee", ["meea1", "meea\xE9", "bar"]],
749 \ ["meea2", ["meea1", "meea\xE9", "lead"]],
750 \ ["prabar", ["prebar", "bar", "leadbar"]],
751 \ ["probarmaat", ["prebarmeat"]],
752 \ ["middle", []],
753 \ ["leadmiddle", ["leadmiddlebar"]],
754 \ ["middletail", []],
755 \ ["taillead", ["tail lead", "tail"]],
756 \ ["leadprobar", ["leadprebar", "lead prebar", "leadbar"]],
757 \ ])
758endfunc
759
760func Test_zz_NOSLITSUGS()
761 call LoadAffAndDic(g:test_data_aff8, g:test_data_dic8)
762 call RunGoodBad("foo bar faabar", "bad: foobar barfoo",
763 \ ["bar", "faabar", "foo"],
764 \ [
765 \ ["bad", ["bar", "foo"]],
766 \ ["foobar", ["faabar", "foo bar", "bar"]],
767 \ ["barfoo", ["bar foo", "bar", "foo"]],
768 \ ])
769endfunc
770
771" Numbers
772func Test_zz_Numbers()
773 call LoadAffAndDic(g:test_data_aff9, g:test_data_dic9)
774 call RunGoodBad("0b1011 0777 1234 0x01ff", "",
775 \ ["bar", "foo"],
776 \ [
777 \ ])
778endfunc
779
Bram Moolenaar37ff4cf2019-11-17 20:10:20 +0100780" Affix flags
781func Test_zz_affix_flags()
782 call LoadAffAndDic(g:test_data_aff10, g:test_data_dic10)
783 call RunGoodBad("drink drinkable drinkables drinktable drinkabletable",
784 \ "bad: drinks drinkstable drinkablestable",
785 \ ["drink", "drinkable", "drinkables", "table"],
786 \ [['bad', []],
787 \ ['drinks', ['drink']],
788 \ ['drinkstable', ['drinktable', 'drinkable', 'drink table']],
789 \ ['drinkablestable', ['drinkabletable', 'drinkables table', 'drinkable table']],
790 \ ])
791endfunc
792
Bram Moolenaard2c061d2017-06-22 21:42:49 +0200793function FirstSpellWord()
794 call feedkeys("/^start:\n", 'tx')
795 normal ]smm
796 let [str, a] = spellbadword()
797 return str
798endfunc
799
800function SecondSpellWord()
801 normal `m]s
802 let [str, a] = spellbadword()
803 return str
804endfunc
805
806"Test with SAL instead of SOFO items; test automatic reloading
807func Test_zz_sal_and_addition()
808 set enc=latin1
809 set spellfile=
Bram Moolenaar56564962022-10-10 22:39:42 +0100810 call writefile(g:test_data_dic1, "Xtest.dic", 'D')
811 call writefile(g:test_data_aff_sal, "Xtest.aff", 'D')
Bram Moolenaard2c061d2017-06-22 21:42:49 +0200812 mkspell! Xtest Xtest
813 set spl=Xtest.latin1.spl spell
814 call assert_equal('kbltykk', soundfold('goobledygoook'))
815 call assert_equal('kprnfn', soundfold('kóopërÿnôven'))
816 call assert_equal('*fls kswts tl', soundfold('oeverloos gezwets edale'))
817
818 "also use an addition file
Bram Moolenaar56564962022-10-10 22:39:42 +0100819 call writefile(["/regions=usgbnz", "elequint/2", "elekwint/3"], "Xtest.latin1.add", 'D')
Bram Moolenaard2c061d2017-06-22 21:42:49 +0200820 mkspell! Xtest.latin1.add.spl Xtest.latin1.add
821
822 bwipe!
823 call setline(1, ["start: elequint test elekwint test elekwent asdf"])
824
825 set spellfile=Xtest.latin1.add
826 call assert_equal("elekwent", FirstSpellWord())
827
828 set spl=Xtest_us.latin1.spl
829 call assert_equal("elequint", FirstSpellWord())
830 call assert_equal("elekwint", SecondSpellWord())
831
832 set spl=Xtest_gb.latin1.spl
833 call assert_equal("elekwint", FirstSpellWord())
834 call assert_equal("elekwent", SecondSpellWord())
835
836 set spl=Xtest_nz.latin1.spl
837 call assert_equal("elequint", FirstSpellWord())
838 call assert_equal("elekwent", SecondSpellWord())
839
840 set spl=Xtest_ca.latin1.spl
841 call assert_equal("elequint", FirstSpellWord())
842 call assert_equal("elekwint", SecondSpellWord())
zeertzjq288ed232022-07-04 11:03:07 +0100843
844 bwipe!
845 set spellfile=
846 set spl&
Bram Moolenaard2c061d2017-06-22 21:42:49 +0200847endfunc
848
Bram Moolenaar862f1e12019-04-10 22:33:41 +0200849func Test_spellfile_value()
850 set spellfile=Xdir/Xtest.latin1.add
851 set spellfile=Xdir/Xtest.utf-8.add,Xtest_other.add
852endfunc
853
Bram Moolenaaree03b942017-10-27 00:57:05 +0200854func Test_region_error()
855 messages clear
Bram Moolenaar56564962022-10-10 22:39:42 +0100856 call writefile(["/regions=usgbnz", "elequint/0"], "Xtest.latin1.add", 'D')
Bram Moolenaaree03b942017-10-27 00:57:05 +0200857 mkspell! Xtest.latin1.add.spl Xtest.latin1.add
858 call assert_match('Invalid region nr in Xtest.latin1.add line 2: 0', execute('messages'))
Bram Moolenaaree03b942017-10-27 00:57:05 +0200859 call delete('Xtest.latin1.add.spl')
860endfunc
861
Bram Moolenaard2c061d2017-06-22 21:42:49 +0200862" Check using z= in new buffer (crash fixed by patch 7.4a.028).
863func Test_zeq_crash()
864 new
865 set maxmem=512 spell
866 call feedkeys('iasdz=:\"', 'tx')
867
868 bwipe!
869endfunc
870
Bram Moolenaar152e79e2020-06-10 15:32:08 +0200871" Check that z= works even when 'nospell' is set. This test uses one of the
872" tests in Test_spellsuggest_option_number() just to verify that z= basically
873" works and that "E756: Spell checking is not enabled" is not generated.
874func Test_zeq_nospell()
875 new
876 set nospell spellsuggest=1,best
877 call setline(1, 'A baord')
878 try
879 norm $1z=
880 call assert_equal('A board', getline(1))
881 catch
882 call assert_report("Caught exception: " . v:exception)
883 endtry
884 set spell& spellsuggest&
885 bwipe!
886endfunc
887
888" Check that "E756: Spell checking is not possible" is reported when z= is
889" executed and 'spelllang' is empty.
890func Test_zeq_no_spelllang()
891 new
892 set spelllang= spellsuggest=1,best
893 call setline(1, 'A baord')
894 call assert_fails('normal $1z=', 'E756:')
895 set spelllang& spellsuggest&
896 bwipe!
897endfunc
898
Bram Moolenaar5bcc5a12019-08-06 22:48:02 +0200899" Check handling a word longer than MAXWLEN.
900func Test_spell_long_word()
901 set enc=utf-8
902 new
903 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")
904 set spell spelllang=en
905 redraw
906 redraw!
907 bwipe!
908 set nospell
909endfunc
910
Bram Moolenaar06f15412022-01-29 10:51:59 +0000911func Test_spellsuggest_too_deep()
912 " This was incrementing "depth" over MAXWLEN.
913 new
914 norm s000G00ý000000000000
915 sil norm ..vzG................vvzG0 v z=
916 bwipe!
917endfunc
918
Bram Moolenaar5e59ea52022-07-01 22:26:20 +0100919func Test_spell_good_word_invalid()
920 " This was adding a word with a 0x02 byte, which causes havoc.
921 enew
922 norm o0
923 sil! norm rzzWs00/
924 2
925 sil! norm VzGprzzW
926 sil! norm z=
927
928 bwipe!
Bram Moolenaar5e59ea52022-07-01 22:26:20 +0100929endfunc
930
K.Takata2ebcc352022-07-14 17:25:14 +0100931func Test_spell_good_word_slash()
932 " This caused E1280.
933 new
934 norm afoo /
935 1
936 norm zG
937
938 bwipe!
939endfunc
940
Bram Moolenaard2c061d2017-06-22 21:42:49 +0200941func LoadAffAndDic(aff_contents, dic_contents)
942 set enc=latin1
943 set spellfile=
944 call writefile(a:aff_contents, "Xtest.aff")
945 call writefile(a:dic_contents, "Xtest.dic")
946 " Generate a .spl file from a .dic and .aff file.
947 mkspell! Xtest Xtest
948 " use that spell file
949 set spl=Xtest.latin1.spl spell
950endfunc
951
952func ListWords()
953 spelldump
954 %yank
955 quit
956 return split(@", "\n")
957endfunc
958
959func TestGoodBadBase()
960 exe '1;/^good:'
961 normal 0f:]s
962 let prevbad = ''
963 let result = []
964 while 1
965 let [bad, a] = spellbadword()
966 if bad == '' || bad == prevbad || bad == 'badend'
967 break
968 endif
969 let prevbad = bad
Bram Moolenaarf6ed61e2019-09-07 19:05:09 +0200970 let lst = bad->spellsuggest(3)
Bram Moolenaard2c061d2017-06-22 21:42:49 +0200971 normal mm
972
973 call add(result, [bad, lst])
974 normal `m]s
975 endwhile
976 return result
977endfunc
978
979func RunGoodBad(good, bad, expected_words, expected_bad_words)
980 bwipe!
981 call setline(1, ["good: ", a:good, a:bad, " badend "])
982 let words = ListWords()
983 call assert_equal(a:expected_words, words[1:-1])
984 let bad_words = TestGoodBadBase()
985 call assert_equal(a:expected_bad_words, bad_words)
986 bwipe!
987endfunc
988
Bram Moolenaar7751d1d2019-10-18 20:37:08 +0200989func Test_spell_screendump()
990 CheckScreendump
991
992 let lines =<< trim END
Luuk van Baale84c7732023-05-31 18:57:36 +0100993 call test_override('alloc_lines', 1)
Bram Moolenaar7751d1d2019-10-18 20:37:08 +0200994 call setline(1, [
995 \ "This is some text without any spell errors. Everything",
996 \ "should just be black, nothing wrong here.",
997 \ "",
998 \ "This line has a sepll error. and missing caps.",
999 \ "And and this is the the duplication.",
1000 \ "with missing caps here.",
1001 \ ])
1002 set spell spelllang=en_nz
1003 END
Bram Moolenaarf3ef0262022-10-05 13:29:15 +01001004 call writefile(lines, 'XtestSpell', 'D')
Bram Moolenaar7751d1d2019-10-18 20:37:08 +02001005 let buf = RunVimInTerminal('-S XtestSpell', {'rows': 8})
1006 call VerifyScreenDump(buf, 'Test_spell_1', {})
1007
1008 " clean up
1009 call StopVimInTerminal(buf)
Bram Moolenaar7751d1d2019-10-18 20:37:08 +02001010endfunc
1011
Christian Brabandtafa23d12022-08-09 12:25:10 +01001012func Test_spell_screendump_spellcap()
1013 CheckScreendump
1014
1015 let lines =<< trim END
Luuk van Baale84c7732023-05-31 18:57:36 +01001016 call test_override('alloc_lines', 1)
Christian Brabandtafa23d12022-08-09 12:25:10 +01001017 call setline(1, [
1018 \ " This line has a sepll error. and missing caps and trailing spaces. ",
1019 \ "another missing cap here.",
1020 \ "",
1021 \ "and here.",
1022 \ " ",
1023 \ "and here."
1024 \ ])
1025 set spell spelllang=en
1026 END
Bram Moolenaarf3ef0262022-10-05 13:29:15 +01001027 call writefile(lines, 'XtestSpellCap', 'D')
Christian Brabandtafa23d12022-08-09 12:25:10 +01001028 let buf = RunVimInTerminal('-S XtestSpellCap', {'rows': 8})
1029 call VerifyScreenDump(buf, 'Test_spell_2', {})
1030
Bram Moolenaaree09fcc2022-09-25 20:58:30 +01001031 " After adding word missing Cap in next line is updated
1032 call term_sendkeys(buf, "3GANot\<Esc>")
1033 call VerifyScreenDump(buf, 'Test_spell_3', {})
1034
Bram Moolenaar26f09ea2022-09-27 16:29:38 +01001035 " Deleting a full stop removes missing Cap in next line
Luuk van Baal2ac64972023-05-25 17:14:42 +01001036 call term_sendkeys(buf, "5Gdd\<C-L>k$x")
Bram Moolenaar26f09ea2022-09-27 16:29:38 +01001037 call VerifyScreenDump(buf, 'Test_spell_4', {})
1038
1039 " Undo also updates the next line (go to command line to remove message)
1040 call term_sendkeys(buf, "u:\<Esc>")
1041 call VerifyScreenDump(buf, 'Test_spell_5', {})
1042
Luuk van Baal2ac64972023-05-25 17:14:42 +01001043 " Folding an empty line does not remove Cap in next line
1044 call term_sendkeys(buf, "uzfk:\<Esc>")
1045 call VerifyScreenDump(buf, 'Test_spell_6', {})
1046
1047 " Folding the end of a sentence does not remove Cap in next line
1048 " and editing a line does not remove Cap in current line
1049 call term_sendkeys(buf, "Jzfkk$x")
1050 call VerifyScreenDump(buf, 'Test_spell_7', {})
1051
1052 " Cap is correctly applied in the first row of a window
1053 call term_sendkeys(buf, "\<C-E>\<C-L>")
1054 call VerifyScreenDump(buf, 'Test_spell_8', {})
1055
Luuk van Baale84c7732023-05-31 18:57:36 +01001056 " Adding an empty line does not remove Cap in "mod_bot" area
1057 call term_sendkeys(buf, "zbO\<Esc>")
1058 call VerifyScreenDump(buf, 'Test_spell_9', {})
1059
1060 " Multiple empty lines does not remove Cap in the line after
1061 call term_sendkeys(buf, "O\<Esc>\<C-L>")
1062 call VerifyScreenDump(buf, 'Test_spell_10', {})
1063
Christian Brabandtafa23d12022-08-09 12:25:10 +01001064 " clean up
1065 call StopVimInTerminal(buf)
Bram Moolenaarf3ef0262022-10-05 13:29:15 +01001066endfunc
1067
1068func Test_spell_compatible()
1069 CheckScreendump
1070
1071 let lines =<< trim END
Luuk van Baale84c7732023-05-31 18:57:36 +01001072 call test_override('alloc_lines', 1)
Bram Moolenaarf3ef0262022-10-05 13:29:15 +01001073 call setline(1, [
1074 \ "test "->repeat(20),
1075 \ "",
1076 \ "end",
1077 \ ])
1078 set spell cpo+=$
1079 END
1080 call writefile(lines, 'XtestSpellComp', 'D')
1081 let buf = RunVimInTerminal('-S XtestSpellComp', {'rows': 8})
1082
1083 call term_sendkeys(buf, "51|C")
1084 call VerifyScreenDump(buf, 'Test_spell_compatible_1', {})
1085
1086 call term_sendkeys(buf, "x")
1087 call VerifyScreenDump(buf, 'Test_spell_compatible_2', {})
1088
1089 " clean up
1090 call StopVimInTerminal(buf)
Christian Brabandtafa23d12022-08-09 12:25:10 +01001091endfunc
1092
Christian Brabandt73b2d372023-11-14 21:58:26 +01001093func Test_z_equal_with_large_count()
1094 split
1095 set spell
1096 call setline(1, "ff")
1097 norm 0z=337203685477580
1098 set nospell
1099 bwipe!
1100endfunc
1101
Bram Moolenaard2c061d2017-06-22 21:42:49 +02001102let g:test_data_aff1 = [
1103 \"SET ISO8859-1",
1104 \"TRY esianrtolcdugmphbyfvkwjkqxz-\xEB\xE9\xE8\xEA\xEF\xEE\xE4\xE0\xE2\xF6\xFC\xFB'ESIANRTOLCDUGMPHBYFVKWJKQXZ",
1105 \"",
1106 \"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",
1107 \"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",
1108 \"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",
1109 \"",
1110 \"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",
1111 \"SOFOTO ebctefghejklnnepkrstevvkesebctefghejklnnepkrstevvkeseeeeeeeceeeeeeeedneeeeeeeeeeepseeeeeeeeceeeeeeeedneeeeeeeeeeep?",
1112 \"",
1113 \"MIDWORD\t'-",
1114 \"",
1115 \"KEP =",
1116 \"RAR ?",
1117 \"BAD !",
1118 \"",
1119 \"PFX I N 1",
1120 \"PFX I 0 in .",
1121 \"",
1122 \"PFX O Y 1",
1123 \"PFX O 0 out .",
1124 \"",
1125 \"SFX S Y 2",
1126 \"SFX S 0 s [^s]",
1127 \"SFX S 0 es s",
1128 \"",
1129 \"SFX N N 3",
1130 \"SFX N 0 en [^n]",
1131 \"SFX N 0 nen n",
1132 \"SFX N 0 n .",
1133 \"",
1134 \"REP 3",
1135 \"REP g ch",
1136 \"REP ch g",
1137 \"REP svp s.v.p.",
1138 \"",
1139 \"MAP 9",
1140 \"MAP a\xE0\xE1\xE2\xE3\xE4\xE5",
1141 \"MAP e\xE8\xE9\xEA\xEB",
1142 \"MAP i\xEC\xED\xEE\xEF",
1143 \"MAP o\xF2\xF3\xF4\xF5\xF6",
1144 \"MAP u\xF9\xFA\xFB\xFC",
1145 \"MAP n\xF1",
1146 \"MAP c\xE7",
1147 \"MAP y\xFF\xFD",
1148 \"MAP s\xDF",
1149 \ ]
1150let g:test_data_dic1 = [
1151 \"123456",
1152 \"test/NO",
1153 \"# comment",
1154 \"wrong",
1155 \"Comment",
1156 \"OK",
1157 \"uk",
1158 \"put/ISO",
1159 \"the end",
1160 \"deol",
1161 \"d\xE9\xF4r",
1162 \ ]
1163let g:test_data_aff2 = [
1164 \"SET ISO8859-1",
1165 \"",
1166 \"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",
1167 \"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",
1168 \"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",
1169 \"",
1170 \"PFXPOSTPONE",
1171 \"",
1172 \"MIDWORD\t'-",
1173 \"",
1174 \"KEP =",
1175 \"RAR ?",
1176 \"BAD !",
1177 \"",
1178 \"PFX I N 1",
1179 \"PFX I 0 in .",
1180 \"",
1181 \"PFX O Y 1",
1182 \"PFX O 0 out [a-z]",
1183 \"",
1184 \"SFX S Y 2",
1185 \"SFX S 0 s [^s]",
1186 \"SFX S 0 es s",
1187 \"",
1188 \"SFX N N 3",
1189 \"SFX N 0 en [^n]",
1190 \"SFX N 0 nen n",
1191 \"SFX N 0 n .",
1192 \"",
1193 \"REP 3",
1194 \"REP g ch",
1195 \"REP ch g",
1196 \"REP svp s.v.p.",
1197 \"",
1198 \"MAP 9",
1199 \"MAP a\xE0\xE1\xE2\xE3\xE4\xE5",
1200 \"MAP e\xE8\xE9\xEA\xEB",
1201 \"MAP i\xEC\xED\xEE\xEF",
1202 \"MAP o\xF2\xF3\xF4\xF5\xF6",
1203 \"MAP u\xF9\xFA\xFB\xFC",
1204 \"MAP n\xF1",
1205 \"MAP c\xE7",
1206 \"MAP y\xFF\xFD",
1207 \"MAP s\xDF",
1208 \ ]
1209let g:test_data_aff3 = [
1210 \"SET ISO8859-1",
1211 \"",
1212 \"COMPOUNDMIN 3",
1213 \"COMPOUNDRULE m*",
1214 \"NEEDCOMPOUND x",
1215 \ ]
1216let g:test_data_dic3 = [
1217 \"1234",
1218 \"foo/m",
1219 \"bar/mx",
1220 \"m\xEF/m",
1221 \"la/mx",
1222 \ ]
1223let g:test_data_aff4 = [
1224 \"SET ISO8859-1",
1225 \"",
1226 \"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",
1227 \"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",
1228 \"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",
1229 \"",
1230 \"COMPOUNDRULE m+",
1231 \"COMPOUNDRULE sm*e",
1232 \"COMPOUNDRULE sm+",
1233 \"COMPOUNDMIN 3",
1234 \"COMPOUNDWORDMAX 3",
1235 \"COMPOUNDFORBIDFLAG t",
1236 \"",
1237 \"COMPOUNDSYLMAX 5",
1238 \"SYLLABLE a\xE1e\xE9i\xEDo\xF3\xF6\xF5u\xFA\xFC\xFBy/aa/au/ea/ee/ei/ie/oa/oe/oo/ou/uu/ui",
1239 \"",
1240 \"MAP 9",
1241 \"MAP a\xE0\xE1\xE2\xE3\xE4\xE5",
1242 \"MAP e\xE8\xE9\xEA\xEB",
1243 \"MAP i\xEC\xED\xEE\xEF",
1244 \"MAP o\xF2\xF3\xF4\xF5\xF6",
1245 \"MAP u\xF9\xFA\xFB\xFC",
1246 \"MAP n\xF1",
1247 \"MAP c\xE7",
1248 \"MAP y\xFF\xFD",
1249 \"MAP s\xDF",
1250 \"",
1251 \"NEEDAFFIX x",
1252 \"",
1253 \"PFXPOSTPONE",
1254 \"",
1255 \"MIDWORD '-",
1256 \"",
1257 \"SFX q N 1",
1258 \"SFX q 0 -ok .",
1259 \"",
1260 \"SFX a Y 2",
1261 \"SFX a 0 s .",
1262 \"SFX a 0 ize/t .",
1263 \"",
1264 \"PFX p N 1",
1265 \"PFX p 0 pre .",
1266 \"",
1267 \"PFX P N 1",
1268 \"PFX P 0 nou .",
1269 \ ]
1270let g:test_data_dic4 = [
1271 \"1234",
1272 \"word/mP",
1273 \"util/am",
1274 \"pro/xq",
1275 \"tomato/m",
1276 \"bork/mp",
1277 \"start/s",
1278 \"end/e",
1279 \ ]
1280let g:test_data_aff5 = [
1281 \"SET ISO8859-1",
1282 \"",
1283 \"FLAG long",
1284 \"",
1285 \"NEEDAFFIX !!",
1286 \"",
1287 \"COMPOUNDRULE ssmm*ee",
1288 \"",
1289 \"NEEDCOMPOUND xx",
1290 \"COMPOUNDPERMITFLAG pp",
1291 \"",
1292 \"SFX 13 Y 1",
1293 \"SFX 13 0 bork .",
1294 \"",
1295 \"SFX a1 Y 1",
1296 \"SFX a1 0 a1 .",
1297 \"",
1298 \"SFX a\xE9 Y 1",
1299 \"SFX a\xE9 0 a\xE9 .",
1300 \"",
1301 \"PFX zz Y 1",
1302 \"PFX zz 0 pre/pp .",
1303 \"",
1304 \"PFX yy Y 1",
1305 \"PFX yy 0 nou .",
1306 \ ]
1307let g:test_data_dic5 = [
1308 \"1234",
1309 \"foo/a1a\xE9!!",
1310 \"bar/zz13ee",
1311 \"start/ss",
1312 \"end/eeyy",
1313 \"middle/mmxx",
1314 \ ]
1315let g:test_data_aff6 = [
1316 \"SET ISO8859-1",
1317 \"",
1318 \"FLAG caplong",
1319 \"",
1320 \"NEEDAFFIX A!",
1321 \"",
1322 \"COMPOUNDRULE sMm*Ee",
1323 \"",
1324 \"NEEDCOMPOUND Xx",
1325 \"",
1326 \"COMPOUNDPERMITFLAG p",
1327 \"",
1328 \"SFX N3 Y 1",
1329 \"SFX N3 0 bork .",
1330 \"",
1331 \"SFX A1 Y 1",
1332 \"SFX A1 0 a1 .",
1333 \"",
1334 \"SFX A\xE9 Y 1",
1335 \"SFX A\xE9 0 a\xE9 .",
1336 \"",
1337 \"PFX Zz Y 1",
1338 \"PFX Zz 0 pre/p .",
1339 \ ]
1340let g:test_data_dic6 = [
1341 \"1234",
1342 \"mee/A1A\xE9A!",
1343 \"bar/ZzN3Ee",
1344 \"lead/s",
1345 \"end/Ee",
1346 \"middle/MmXx",
1347 \ ]
1348let g:test_data_aff7 = [
1349 \"SET ISO8859-1",
1350 \"",
1351 \"FLAG num",
1352 \"",
1353 \"NEEDAFFIX 9999",
1354 \"",
1355 \"COMPOUNDRULE 2,77*123",
1356 \"",
1357 \"NEEDCOMPOUND 1",
1358 \"COMPOUNDPERMITFLAG 432",
1359 \"",
1360 \"SFX 61003 Y 1",
1361 \"SFX 61003 0 meat .",
1362 \"",
Bram Moolenaar3d2a47c2019-11-07 20:48:42 +01001363 \"SFX 0 Y 1",
1364 \"SFX 0 0 zero .",
1365 \"",
Bram Moolenaard2c061d2017-06-22 21:42:49 +02001366 \"SFX 391 Y 1",
1367 \"SFX 391 0 a1 .",
1368 \"",
1369 \"SFX 111 Y 1",
1370 \"SFX 111 0 a\xE9 .",
1371 \"",
1372 \"PFX 17 Y 1",
1373 \"PFX 17 0 pre/432 .",
1374 \ ]
1375let g:test_data_dic7 = [
1376 \"1234",
Bram Moolenaar3d2a47c2019-11-07 20:48:42 +01001377 \"mee/0,391,111,9999",
Bram Moolenaard2c061d2017-06-22 21:42:49 +02001378 \"bar/17,61003,123",
1379 \"lead/2",
1380 \"tail/123",
1381 \"middle/77,1",
1382 \ ]
1383let g:test_data_aff8 = [
1384 \"SET ISO8859-1",
1385 \"",
1386 \"NOSPLITSUGS",
1387 \ ]
1388let g:test_data_dic8 = [
1389 \"1234",
1390 \"foo",
1391 \"bar",
1392 \"faabar",
1393 \ ]
1394let g:test_data_aff9 = [
1395 \ ]
1396let g:test_data_dic9 = [
1397 \"1234",
1398 \"foo",
1399 \"bar",
1400 \ ]
Bram Moolenaar37ff4cf2019-11-17 20:10:20 +01001401let g:test_data_aff10 = [
1402 \"COMPOUNDRULE se",
1403 \"COMPOUNDPERMITFLAG p",
1404 \"",
1405 \"SFX A Y 1",
1406 \"SFX A 0 able/Mp .",
1407 \"",
1408 \"SFX M Y 1",
1409 \"SFX M 0 s .",
1410 \ ]
1411let g:test_data_dic10 = [
1412 \"1234",
1413 \"drink/As",
1414 \"table/e",
1415 \ ]
Bram Moolenaard2c061d2017-06-22 21:42:49 +02001416let g:test_data_aff_sal = [
1417 \"SET ISO8859-1",
1418 \"TRY esianrtolcdugmphbyfvkwjkqxz-\xEB\xE9\xE8\xEA\xEF\xEE\xE4\xE0\xE2\xF6\xFC\xFB'ESIANRTOLCDUGMPHBYFVKWJKQXZ",
1419 \"",
1420 \"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",
1421 \"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",
1422 \"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",
1423 \"",
1424 \"MIDWORD\t'-",
1425 \"",
1426 \"KEP =",
1427 \"RAR ?",
1428 \"BAD !",
1429 \"",
1430 \"PFX I N 1",
1431 \"PFX I 0 in .",
1432 \"",
1433 \"PFX O Y 1",
1434 \"PFX O 0 out .",
1435 \"",
1436 \"SFX S Y 2",
1437 \"SFX S 0 s [^s]",
1438 \"SFX S 0 es s",
1439 \"",
1440 \"SFX N N 3",
1441 \"SFX N 0 en [^n]",
1442 \"SFX N 0 nen n",
1443 \"SFX N 0 n .",
1444 \"",
1445 \"REP 3",
1446 \"REP g ch",
1447 \"REP ch g",
1448 \"REP svp s.v.p.",
1449 \"",
1450 \"MAP 9",
1451 \"MAP a\xE0\xE1\xE2\xE3\xE4\xE5",
1452 \"MAP e\xE8\xE9\xEA\xEB",
1453 \"MAP i\xEC\xED\xEE\xEF",
1454 \"MAP o\xF2\xF3\xF4\xF5\xF6",
1455 \"MAP u\xF9\xFA\xFB\xFC",
1456 \"MAP n\xF1",
1457 \"MAP c\xE7",
1458 \"MAP y\xFF\xFD",
1459 \"MAP s\xDF",
1460 \"",
1461 \"SAL AH(AEIOUY)-^ *H",
1462 \"SAL AR(AEIOUY)-^ *R",
1463 \"SAL A(HR)^ *",
1464 \"SAL A^ *",
1465 \"SAL AH(AEIOUY)- H",
1466 \"SAL AR(AEIOUY)- R",
1467 \"SAL A(HR) _",
1468 \"SAL \xC0^ *",
1469 \"SAL \xC5^ *",
1470 \"SAL BB- _",
1471 \"SAL B B",
1472 \"SAL CQ- _",
1473 \"SAL CIA X",
1474 \"SAL CH X",
1475 \"SAL C(EIY)- S",
1476 \"SAL CK K",
1477 \"SAL COUGH^ KF",
1478 \"SAL CC< C",
1479 \"SAL C K",
1480 \"SAL DG(EIY) K",
1481 \"SAL DD- _",
1482 \"SAL D T",
1483 \"SAL \xC9< E",
1484 \"SAL EH(AEIOUY)-^ *H",
1485 \"SAL ER(AEIOUY)-^ *R",
1486 \"SAL E(HR)^ *",
1487 \"SAL ENOUGH^$ *NF",
1488 \"SAL E^ *",
1489 \"SAL EH(AEIOUY)- H",
1490 \"SAL ER(AEIOUY)- R",
1491 \"SAL E(HR) _",
1492 \"SAL FF- _",
1493 \"SAL F F",
1494 \"SAL GN^ N",
1495 \"SAL GN$ N",
1496 \"SAL GNS$ NS",
1497 \"SAL GNED$ N",
1498 \"SAL GH(AEIOUY)- K",
1499 \"SAL GH _",
1500 \"SAL GG9 K",
1501 \"SAL G K",
1502 \"SAL H H",
1503 \"SAL IH(AEIOUY)-^ *H",
1504 \"SAL IR(AEIOUY)-^ *R",
1505 \"SAL I(HR)^ *",
1506 \"SAL I^ *",
1507 \"SAL ING6 N",
1508 \"SAL IH(AEIOUY)- H",
1509 \"SAL IR(AEIOUY)- R",
1510 \"SAL I(HR) _",
1511 \"SAL J K",
1512 \"SAL KN^ N",
1513 \"SAL KK- _",
1514 \"SAL K K",
1515 \"SAL LAUGH^ LF",
1516 \"SAL LL- _",
1517 \"SAL L L",
1518 \"SAL MB$ M",
1519 \"SAL MM M",
1520 \"SAL M M",
1521 \"SAL NN- _",
1522 \"SAL N N",
1523 \"SAL OH(AEIOUY)-^ *H",
1524 \"SAL OR(AEIOUY)-^ *R",
1525 \"SAL O(HR)^ *",
1526 \"SAL O^ *",
1527 \"SAL OH(AEIOUY)- H",
1528 \"SAL OR(AEIOUY)- R",
1529 \"SAL O(HR) _",
1530 \"SAL PH F",
1531 \"SAL PN^ N",
1532 \"SAL PP- _",
1533 \"SAL P P",
1534 \"SAL Q K",
1535 \"SAL RH^ R",
1536 \"SAL ROUGH^ RF",
1537 \"SAL RR- _",
1538 \"SAL R R",
1539 \"SAL SCH(EOU)- SK",
1540 \"SAL SC(IEY)- S",
1541 \"SAL SH X",
1542 \"SAL SI(AO)- X",
1543 \"SAL SS- _",
1544 \"SAL S S",
1545 \"SAL TI(AO)- X",
1546 \"SAL TH @",
1547 \"SAL TCH-- _",
1548 \"SAL TOUGH^ TF",
1549 \"SAL TT- _",
1550 \"SAL T T",
1551 \"SAL UH(AEIOUY)-^ *H",
1552 \"SAL UR(AEIOUY)-^ *R",
1553 \"SAL U(HR)^ *",
1554 \"SAL U^ *",
1555 \"SAL UH(AEIOUY)- H",
1556 \"SAL UR(AEIOUY)- R",
1557 \"SAL U(HR) _",
1558 \"SAL V^ W",
1559 \"SAL V F",
1560 \"SAL WR^ R",
1561 \"SAL WH^ W",
1562 \"SAL W(AEIOU)- W",
1563 \"SAL X^ S",
1564 \"SAL X KS",
1565 \"SAL Y(AEIOU)- Y",
1566 \"SAL ZZ- _",
1567 \"SAL Z S",
1568 \ ]
Bram Moolenaar0e05de42020-03-25 22:23:46 +01001569
1570" vim: shiftwidth=2 sts=2 expandtab