blob: 12f76efff8583a26b1c53e3af6b8bbc04a50c2af [file] [log] [blame]
Bram Moolenaard3f78dc2017-02-25 14:21:10 +01001" Test spell checking
Bram Moolenaar5bcc5a12019-08-06 22:48:02 +02002" Note: this file uses latin1 encoding, but is used with utf-8 encoding.
Bram Moolenaard3f78dc2017-02-25 14:21:10 +01003
Bram Moolenaarb46fecd2019-06-15 17:58:09 +02004source check.vim
5CheckFeature spell
Bram Moolenaard3f78dc2017-02-25 14:21:10 +01006
Bram Moolenaar7751d1d2019-10-18 20:37:08 +02007source screendump.vim
8
Bram Moolenaar1a0f2002017-07-28 15:38:10 +02009func TearDown()
10 set nospell
11 call delete('Xtest.aff')
12 call delete('Xtest.dic')
13 call delete('Xtest.latin1.add')
14 call delete('Xtest.latin1.add.spl')
15 call delete('Xtest.latin1.spl')
16 call delete('Xtest.latin1.sug')
17endfunc
18
Bram Moolenaard3f78dc2017-02-25 14:21:10 +010019func Test_wrap_search()
20 new
21 call setline(1, ['The', '', 'A plong line with two zpelling mistakes', '', 'End'])
22 set spell wrapscan
23 normal ]s
24 call assert_equal('plong', expand('<cword>'))
25 normal ]s
26 call assert_equal('zpelling', expand('<cword>'))
27 normal ]s
28 call assert_equal('plong', expand('<cword>'))
29 bwipe!
30 set nospell
31endfunc
Bram Moolenaar5b276aa2017-04-22 23:49:52 +020032
Bram Moolenaarb73fa622017-12-21 20:27:47 +010033func Test_curswant()
34 new
35 call setline(1, ['Another plong line', 'abcdefghijklmnopq'])
36 set spell wrapscan
37 normal 0]s
38 call assert_equal('plong', expand('<cword>'))
39 normal j
40 call assert_equal(9, getcurpos()[2])
41 normal 0[s
42 call assert_equal('plong', expand('<cword>'))
43 normal j
44 call assert_equal(9, getcurpos()[2])
45
46 normal 0]S
47 call assert_equal('plong', expand('<cword>'))
48 normal j
49 call assert_equal(9, getcurpos()[2])
50 normal 0[S
51 call assert_equal('plong', expand('<cword>'))
52 normal j
53 call assert_equal(9, getcurpos()[2])
54
55 normal 1G0
56 call assert_equal('plong', spellbadword()[0])
57 normal j
58 call assert_equal(9, getcurpos()[2])
59
60 bwipe!
61 set nospell
62endfunc
63
Bram Moolenaar5b276aa2017-04-22 23:49:52 +020064func Test_z_equal_on_invalid_utf8_word()
65 split
66 set spell
67 call setline(1, "\xff")
68 norm z=
69 set nospell
70 bwipe!
71endfunc
Bram Moolenaar545cb792017-05-23 11:31:22 +020072
Bram Moolenaar872e4512018-07-20 23:36:26 +020073" Test spellbadword() with argument
74func Test_spellbadword()
75 set spell
76
77 call assert_equal(['bycycle', 'bad'], spellbadword('My bycycle.'))
Bram Moolenaarf6ed61e2019-09-07 19:05:09 +020078 call assert_equal(['another', 'caps'], 'A sentence. another sentence'->spellbadword())
Bram Moolenaar872e4512018-07-20 23:36:26 +020079
Bram Moolenaar362b44b2020-06-10 21:47:00 +020080 call assert_equal(['TheCamelWord', 'bad'], 'TheCamelWord asdf'->spellbadword())
81 set spelloptions=camel
82 call assert_equal(['asdf', 'bad'], 'TheCamelWord asdf'->spellbadword())
83 set spelloptions=
84
Bram Moolenaar872e4512018-07-20 23:36:26 +020085 set spelllang=en
86 call assert_equal(['', ''], spellbadword('centre'))
87 call assert_equal(['', ''], spellbadword('center'))
88 set spelllang=en_us
89 call assert_equal(['centre', 'local'], spellbadword('centre'))
90 call assert_equal(['', ''], spellbadword('center'))
91 set spelllang=en_gb
92 call assert_equal(['', ''], spellbadword('centre'))
93 call assert_equal(['center', 'local'], spellbadword('center'))
94
95 " Create a small word list to test that spellbadword('...')
96 " can return ['...', 'rare'].
97 e Xwords
98 insert
99foo
100foobar/?
101.
102 w!
103 mkspell! Xwords.spl Xwords
104 set spelllang=Xwords.spl
105 call assert_equal(['foobar', 'rare'], spellbadword('foo foobar'))
106
Bram Moolenaar152e79e2020-06-10 15:32:08 +0200107 " Typo should be detected even without the 'spell' option.
Bram Moolenaar872e4512018-07-20 23:36:26 +0200108 set spelllang=en_gb nospell
109 call assert_equal(['', ''], spellbadword('centre'))
Bram Moolenaar152e79e2020-06-10 15:32:08 +0200110 call assert_equal(['bycycle', 'bad'], spellbadword('My bycycle.'))
111 call assert_equal(['another', 'caps'], spellbadword('A sentence. another sentence'))
112
113 set spelllang=
114 call assert_fails("call spellbadword('maxch')", 'E756:')
Bram Moolenaar96fdf432020-09-11 18:11:50 +0200115 call assert_fails("spelldump", 'E756:')
Bram Moolenaar872e4512018-07-20 23:36:26 +0200116
117 call delete('Xwords.spl')
118 call delete('Xwords')
119 set spelllang&
120 set spell&
121endfunc
122
Bram Moolenaard569a9e2020-09-28 23:13:15 +0200123func Test_spell_file_missing()
124 let s:spell_file_missing = 0
125 augroup TestSpellFileMissing
126 autocmd! SpellFileMissing * let s:spell_file_missing += 1
127 augroup END
128
129 set spell spelllang=ab_cd
130 let messages = GetMessages()
131 call assert_equal('Warning: Cannot find word list "ab.utf-8.spl" or "ab.ascii.spl"', messages[-1])
132 call assert_equal(1, s:spell_file_missing)
133
134 new XTestSpellFileMissing
135 augroup TestSpellFileMissing
136 autocmd! SpellFileMissing * bwipe
137 augroup END
138 call assert_fails('set spell spelllang=ab_cd', 'E797:')
139
140 augroup! TestSpellFileMissing
141 unlet s:spell_file_missing
142 set spell& spelllang&
143 %bwipe!
144endfunc
145
Bram Moolenaarf12f0022020-10-07 12:58:44 +0200146func Test_spelldump()
147 set spell spelllang=en
148 spellrare! emacs
149
150 spelldump
151
152 " Check assumption about region: 1: us, 2: au, 3: ca, 4: gb, 5: nz.
153 call assert_equal('/regions=usaucagbnz', getline(1))
154 call assert_notequal(0, search('^theater/1$')) " US English only.
155 call assert_notequal(0, search('^theatre/2345$')) " AU, CA, GB or NZ English.
156
157 call assert_notequal(0, search('^emacs/?$')) " ? for a rare word.
158 call assert_notequal(0, search('^the the/!$')) " ! for a wrong word.
159
160 bwipe
161 set spell&
162endfunc
163
164func Test_spelldump_bang()
165 new
166 call setline(1, 'This is a sample sentence.')
167 redraw
168 set spell
169 redraw
170 spelldump!
171
172 " :spelldump! includes the number of times a word was found while updating
173 " the screen.
174 " Common word count starts at 10, regular word count starts at 0.
175 call assert_notequal(0, search("^is\t11$")) " common word found once.
176 call assert_notequal(0, search("^the\t10$")) " common word never found.
177 call assert_notequal(0, search("^sample\t1$")) " regular word found once.
178 call assert_equal(0, search("^screen\t")) " regular word never found.
179
180 %bwipe!
181 set spell&
182endfunc
183
Bram Moolenaar8c7ad362020-09-27 13:58:38 +0200184func Test_spelllang_inv_region()
185 set spell spelllang=en_xx
186 let messages = GetMessages()
187 call assert_equal('Warning: region xx not supported', messages[-1])
188 set spell& spelllang&
189endfunc
190
191func Test_compl_with_CTRL_X_CTRL_K_using_spell()
192 " When spell checking is enabled and 'dictionary' is empty,
193 " CTRL-X CTRL-K in insert mode completes using the spelling dictionary.
194 new
195 set spell spelllang=en dictionary=
196
197 set ignorecase
198 call feedkeys("Senglis\<c-x>\<c-k>\<esc>", 'tnx')
199 call assert_equal(['English'], getline(1, '$'))
200 call feedkeys("SEnglis\<c-x>\<c-k>\<esc>", 'tnx')
201 call assert_equal(['English'], getline(1, '$'))
202
203 set noignorecase
204 call feedkeys("Senglis\<c-x>\<c-k>\<esc>", 'tnx')
205 call assert_equal(['englis'], getline(1, '$'))
206 call feedkeys("SEnglis\<c-x>\<c-k>\<esc>", 'tnx')
207 call assert_equal(['English'], getline(1, '$'))
208
209 set spelllang=en_us
210 call feedkeys("Stheat\<c-x>\<c-k>\<esc>", 'tnx')
211 call assert_equal(['theater'], getline(1, '$'))
212 set spelllang=en_gb
213 call feedkeys("Stheat\<c-x>\<c-k>\<esc>", 'tnx')
214 " FIXME: commented out, expected theatre bug got theater. See issue #7025.
215 " call assert_equal(['theatre'], getline(1, '$'))
216
217 bwipe!
218 set spell& spelllang& dictionary& ignorecase&
219endfunc
220
Bram Moolenaar545cb792017-05-23 11:31:22 +0200221func Test_spellreall()
222 new
223 set spell
224 call assert_fails('spellrepall', 'E752:')
225 call setline(1, ['A speling mistake. The same speling mistake.',
Bram Moolenaard2c061d2017-06-22 21:42:49 +0200226 \ 'Another speling mistake.'])
Bram Moolenaar545cb792017-05-23 11:31:22 +0200227 call feedkeys(']s1z=', 'tx')
228 call assert_equal('A spelling mistake. The same speling mistake.', getline(1))
229 call assert_equal('Another speling mistake.', getline(2))
230 spellrepall
231 call assert_equal('A spelling mistake. The same spelling mistake.', getline(1))
232 call assert_equal('Another spelling mistake.', getline(2))
233 call assert_fails('spellrepall', 'E753:')
234 set spell&
235 bwipe!
236endfunc
Bram Moolenaard2c061d2017-06-22 21:42:49 +0200237
Bram Moolenaare9a8d1f2019-12-25 13:36:36 +0100238" Test spellsuggest({word} [, {max} [, {capital}]])
239func Test_spellsuggest()
Bram Moolenaar152e79e2020-06-10 15:32:08 +0200240 " Verify suggestions are given even when spell checking is not enabled.
Bram Moolenaare9a8d1f2019-12-25 13:36:36 +0100241 set nospell
Bram Moolenaar152e79e2020-06-10 15:32:08 +0200242 call assert_equal(['march', 'March'], spellsuggest('marrch', 2))
Bram Moolenaare9a8d1f2019-12-25 13:36:36 +0100243
244 set spell
245
246 " With 1 argument.
Bram Moolenaar76734052019-12-26 14:30:15 +0100247 call assert_equal(['march', 'March'], spellsuggest('marrch')[0:1])
Bram Moolenaare9a8d1f2019-12-25 13:36:36 +0100248
249 " With 2 arguments.
Bram Moolenaar76734052019-12-26 14:30:15 +0100250 call assert_equal(['march', 'March'], spellsuggest('marrch', 2))
Bram Moolenaare9a8d1f2019-12-25 13:36:36 +0100251
252 " With 3 arguments.
Bram Moolenaar76734052019-12-26 14:30:15 +0100253 call assert_equal(['march'], spellsuggest('marrch', 1, 0))
254 call assert_equal(['March'], spellsuggest('marrch', 1, 1))
Bram Moolenaare9a8d1f2019-12-25 13:36:36 +0100255
256 " Test with digits and hyphen.
257 call assert_equal('Carbon-14', spellsuggest('Carbon-15')[0])
258
259 " Comment taken from spellsuggest.c explains the following test cases:
260 "
261 " If there are more UPPER than lower case letters suggest an
262 " ALLCAP word. Otherwise, if the first letter is UPPER then
263 " suggest ONECAP. Exception: "ALl" most likely should be "All",
264 " require three upper case letters.
Bram Moolenaar76734052019-12-26 14:30:15 +0100265 call assert_equal(['THIRD', 'third'], spellsuggest('thIRD', 2))
266 call assert_equal(['third', 'THIRD'], spellsuggest('tHIrd', 2))
267 call assert_equal(['Third'], spellsuggest('THird', 1))
Bram Moolenaare9a8d1f2019-12-25 13:36:36 +0100268 call assert_equal(['All'], spellsuggest('ALl', 1))
269
Dominique Pellef645ee42021-12-05 13:21:18 +0000270 " Special suggestion for repeated 'the the'.
271 call assert_inrange(0, 2, index(spellsuggest('the the', 3), 'the'))
272 call assert_inrange(0, 2, index(spellsuggest('the the', 3), 'the'))
273 call assert_inrange(0, 2, index(spellsuggest('The the', 3), 'The'))
274
Bram Moolenaar0e05de42020-03-25 22:23:46 +0100275 call assert_fails("call spellsuggest('maxch', [])", 'E745:')
276 call assert_fails("call spellsuggest('maxch', 2, [])", 'E745:')
277
Bram Moolenaar152e79e2020-06-10 15:32:08 +0200278 set spelllang=
279 call assert_fails("call spellsuggest('maxch')", 'E756:')
280 set spelllang&
281
Bram Moolenaare9a8d1f2019-12-25 13:36:36 +0100282 set spell&
283endfunc
284
285" Test 'spellsuggest' option with methods fast, best and double.
286func Test_spellsuggest_option_methods()
287 set spell
288
Bram Moolenaar76734052019-12-26 14:30:15 +0100289 for e in ['latin1', 'utf-8']
290 exe 'set encoding=' .. e
Bram Moolenaare9a8d1f2019-12-25 13:36:36 +0100291
Bram Moolenaar76734052019-12-26 14:30:15 +0100292 set spellsuggest=fast
293 call assert_equal(['Stick', 'Stitch'], spellsuggest('Stich', 2), e)
Bram Moolenaare9a8d1f2019-12-25 13:36:36 +0100294
Bram Moolenaar76734052019-12-26 14:30:15 +0100295 " With best or double option, "Stitch" should become the top suggestion
296 " because of better phonetic matching.
297 set spellsuggest=best
298 call assert_equal(['Stitch', 'Stick'], spellsuggest('Stich', 2), e)
Bram Moolenaare9a8d1f2019-12-25 13:36:36 +0100299
Bram Moolenaar76734052019-12-26 14:30:15 +0100300 set spellsuggest=double
301 call assert_equal(['Stitch', 'Stick'], spellsuggest('Stich', 2), e)
302 endfor
303
304 set spell& spellsuggest& encoding&
Bram Moolenaare9a8d1f2019-12-25 13:36:36 +0100305endfunc
306
307" Test 'spellsuggest' option with value file:{filename}
308func Test_spellsuggest_option_file()
309 set spell spellsuggest=file:Xspellsuggest
310 call writefile(['emacs/vim',
311 \ 'theribal/terrible',
312 \ 'teribal/terrrible',
313 \ 'terribal'],
314 \ 'Xspellsuggest')
315
316 call assert_equal(['vim'], spellsuggest('emacs', 2))
317 call assert_equal(['terrible'], spellsuggest('theribal',2))
318
319 " If the suggestion is misspelled (*terrrible* with 3 r),
320 " it should not be proposed.
321 " The entry for "terribal" should be ignored because of missing slash.
322 call assert_equal([], spellsuggest('teribal', 2))
323 call assert_equal([], spellsuggest('terribal', 2))
324
325 set spell spellsuggest=best,file:Xspellsuggest
326 call assert_equal(['vim', 'Emacs'], spellsuggest('emacs', 2))
327 call assert_equal(['terrible', 'tribal'], spellsuggest('theribal', 2))
328 call assert_equal(['tribal'], spellsuggest('teribal', 1))
329 call assert_equal(['tribal'], spellsuggest('terribal', 1))
330
331 call delete('Xspellsuggest')
332 call assert_fails("call spellsuggest('vim')", "E484: Can't open file Xspellsuggest")
333
334 set spellsuggest& spell&
335endfunc
336
337" Test 'spellsuggest' option with value {number}
338" to limit the number of suggestions
339func Test_spellsuggest_option_number()
340 set spell spellsuggest=2,best
341 new
342
343 " We limited the number of suggestions to 2, so selecting
344 " the 1st and 2nd suggestion should correct the word, but
345 " selecting a 3rd suggestion should do nothing.
Bram Moolenaar76734052019-12-26 14:30:15 +0100346 call setline(1, 'A baord')
347 norm $1z=
348 call assert_equal('A board', getline(1))
Bram Moolenaare9a8d1f2019-12-25 13:36:36 +0100349
Bram Moolenaar76734052019-12-26 14:30:15 +0100350 call setline(1, 'A baord')
351 norm $2z=
352 call assert_equal('A bard', getline(1))
Bram Moolenaare9a8d1f2019-12-25 13:36:36 +0100353
Bram Moolenaar76734052019-12-26 14:30:15 +0100354 call setline(1, 'A baord')
355 norm $3z=
356 call assert_equal('A baord', getline(1))
Bram Moolenaare9a8d1f2019-12-25 13:36:36 +0100357
Bram Moolenaar76734052019-12-26 14:30:15 +0100358 let a = execute('norm $z=')
Bram Moolenaare9a8d1f2019-12-25 13:36:36 +0100359 call assert_equal(
360 \ "\n"
Bram Moolenaar76734052019-12-26 14:30:15 +0100361 \ .. "Change \"baord\" to:\n"
362 \ .. " 1 \"board\"\n"
363 \ .. " 2 \"bard\"\n"
Bram Moolenaard281b7c2020-06-10 16:39:32 +0200364 \ .. "Type number and <Enter> or click with the mouse (q or empty cancels): ", a)
Bram Moolenaare9a8d1f2019-12-25 13:36:36 +0100365
366 set spell spellsuggest=0
Bram Moolenaar76734052019-12-26 14:30:15 +0100367 call assert_equal("\nSorry, no suggestions", execute('norm $z='))
Bram Moolenaare9a8d1f2019-12-25 13:36:36 +0100368
369 " Unlike z=, function spellsuggest(...) should not be affected by the
370 " max number of suggestions (2) set by the 'spellsuggest' option.
Bram Moolenaar76734052019-12-26 14:30:15 +0100371 call assert_equal(['board', 'bard', 'broad'], spellsuggest('baord', 3))
Bram Moolenaare9a8d1f2019-12-25 13:36:36 +0100372
373 set spellsuggest& spell&
374 bwipe!
375endfunc
376
377" Test 'spellsuggest' option with value expr:{expr}
378func Test_spellsuggest_option_expr()
379 " A silly 'spellsuggest' function which makes suggestions all uppercase
380 " and makes the score of each suggestion the length of the suggested word.
381 " So shorter suggestions are preferred.
382 func MySuggest()
383 let spellsuggest_save = &spellsuggest
Bram Moolenaar76734052019-12-26 14:30:15 +0100384 set spellsuggest=3,best
Bram Moolenaare9a8d1f2019-12-25 13:36:36 +0100385 let result = map(spellsuggest(v:val, 3), "[toupper(v:val), len(v:val)]")
386 let &spellsuggest = spellsuggest_save
387 return result
388 endfunc
389
Bram Moolenaar76734052019-12-26 14:30:15 +0100390 set spell spellsuggest=expr:MySuggest()
391 call assert_equal(['BARD', 'BOARD', 'BROAD'], spellsuggest('baord', 3))
Bram Moolenaare9a8d1f2019-12-25 13:36:36 +0100392
393 new
Bram Moolenaar76734052019-12-26 14:30:15 +0100394 call setline(1, 'baord')
Bram Moolenaare9a8d1f2019-12-25 13:36:36 +0100395 let a = execute('norm z=')
396 call assert_equal(
397 \ "\n"
Bram Moolenaar76734052019-12-26 14:30:15 +0100398 \ .. "Change \"baord\" to:\n"
399 \ .. " 1 \"BARD\"\n"
400 \ .. " 2 \"BOARD\"\n"
401 \ .. " 3 \"BROAD\"\n"
Bram Moolenaard281b7c2020-06-10 16:39:32 +0200402 \ .. "Type number and <Enter> or click with the mouse (q or empty cancels): ", a)
Bram Moolenaare9a8d1f2019-12-25 13:36:36 +0100403
404 " With verbose, z= should show the score i.e. word length with
405 " our SpellSuggest() function.
406 set verbose=1
407 let a = execute('norm z=')
408 call assert_equal(
409 \ "\n"
Bram Moolenaar76734052019-12-26 14:30:15 +0100410 \ .. "Change \"baord\" to:\n"
411 \ .. " 1 \"BARD\" (4 - 0)\n"
412 \ .. " 2 \"BOARD\" (5 - 0)\n"
413 \ .. " 3 \"BROAD\" (5 - 0)\n"
Bram Moolenaard281b7c2020-06-10 16:39:32 +0200414 \ .. "Type number and <Enter> or click with the mouse (q or empty cancels): ", a)
Bram Moolenaare9a8d1f2019-12-25 13:36:36 +0100415
416 set spell& spellsuggest& verbose&
417 bwipe!
418endfunc
419
Dominique Pelle81b573d2022-03-22 21:14:55 +0000420" Test for 'spellsuggest' expr errors
Bram Moolenaar8dfcce32020-03-18 19:32:26 +0100421func Test_spellsuggest_expr_errors()
422 " 'spellsuggest'
423 func MySuggest()
424 return range(3)
425 endfunc
426 set spell spellsuggest=expr:MySuggest()
427 call assert_equal([], spellsuggest('baord', 3))
428
429 " Test for 'spellsuggest' expression returning a non-list value
430 func! MySuggest2()
431 return 'good'
432 endfunc
433 set spellsuggest=expr:MySuggest2()
434 call assert_equal([], spellsuggest('baord'))
435
436 " Test for 'spellsuggest' expression returning a list with dict values
437 func! MySuggest3()
438 return [[{}, {}]]
439 endfunc
440 set spellsuggest=expr:MySuggest3()
Bram Moolenaar9b7bf9e2020-07-11 22:14:59 +0200441 call assert_fails("call spellsuggest('baord')", 'E731:')
Bram Moolenaar8dfcce32020-03-18 19:32:26 +0100442
443 set nospell spellsuggest&
444 delfunc MySuggest
445 delfunc MySuggest2
446 delfunc MySuggest3
447endfunc
448
Bram Moolenaar585ee072022-01-29 11:22:17 +0000449func Test_spellsuggest_timeout()
450 set spellsuggest=timeout:30
451 set spellsuggest=timeout:-123
452 set spellsuggest=timeout:999999
453 call assert_fails('set spellsuggest=timeout', 'E474:')
454 call assert_fails('set spellsuggest=timeout:x', 'E474:')
455 call assert_fails('set spellsuggest=timeout:-x', 'E474:')
456 call assert_fails('set spellsuggest=timeout:--9', 'E474:')
457endfunc
458
Bram Moolenaar5c686172022-03-13 20:12:25 +0000459func Test_spellsuggest_visual_end_of_line()
460 let enc_save = &encoding
461 set encoding=iso8859
462
463 " This was reading beyond the end of the line.
464 norm R00000000000
465 sil norm 0
466 sil! norm i00000)
467 sil! norm i00000)
468 call feedkeys("\<CR>")
469 norm z=
470
471 let &encoding = enc_save
472endfunc
473
Bram Moolenaar9049b682018-08-31 22:26:53 +0200474func Test_spellinfo()
475 new
Bram Moolenaarc25e7022019-10-10 14:08:26 +0200476 let runtime = substitute($VIMRUNTIME, '\\', '/', 'g')
Bram Moolenaar9049b682018-08-31 22:26:53 +0200477
478 set enc=latin1 spell spelllang=en
Bram Moolenaarc25e7022019-10-10 14:08:26 +0200479 call assert_match("^\nfile: " .. runtime .. "/spell/en.latin1.spl\n$", execute('spellinfo'))
Bram Moolenaar9049b682018-08-31 22:26:53 +0200480
481 set enc=cp1250 spell spelllang=en
Bram Moolenaarc25e7022019-10-10 14:08:26 +0200482 call assert_match("^\nfile: " .. runtime .. "/spell/en.ascii.spl\n$", execute('spellinfo'))
Bram Moolenaar9049b682018-08-31 22:26:53 +0200483
Bram Moolenaar30276f22019-01-24 17:59:39 +0100484 set enc=utf-8 spell spelllang=en
Bram Moolenaarc25e7022019-10-10 14:08:26 +0200485 call assert_match("^\nfile: " .. runtime .. "/spell/en.utf-8.spl\n$", execute('spellinfo'))
Bram Moolenaar9049b682018-08-31 22:26:53 +0200486
487 set enc=latin1 spell spelllang=en_us,en_nz
488 call assert_match("^\n" .
Bram Moolenaarc25e7022019-10-10 14:08:26 +0200489 \ "file: " .. runtime .. "/spell/en.latin1.spl\n" .
490 \ "file: " .. runtime.. "/spell/en.latin1.spl\n$", execute('spellinfo'))
Bram Moolenaar9049b682018-08-31 22:26:53 +0200491
492 set spell spelllang=
493 call assert_fails('spellinfo', 'E756:')
494
495 set nospell spelllang=en
496 call assert_fails('spellinfo', 'E756:')
497
Bram Moolenaar8f130ed2019-04-10 22:15:19 +0200498 call assert_fails('set spelllang=foo/bar', 'E474:')
499 call assert_fails('set spelllang=foo\ bar', 'E474:')
500 call assert_fails("set spelllang=foo\\\nbar", 'E474:')
501 call assert_fails("set spelllang=foo\\\rbar", 'E474:')
502 call assert_fails("set spelllang=foo+bar", 'E474:')
503
Bram Moolenaar9049b682018-08-31 22:26:53 +0200504 set enc& spell& spelllang&
505 bwipe
506endfunc
507
Bram Moolenaard2c061d2017-06-22 21:42:49 +0200508func Test_zz_basic()
509 call LoadAffAndDic(g:test_data_aff1, g:test_data_dic1)
510 call RunGoodBad("wrong OK puts. Test the end",
511 \ "bad: inputs comment ok Ok. test d\xE9\xF4l end the",
512 \["Comment", "deol", "d\xE9\xF4r", "input", "OK", "output", "outputs", "outtest", "put", "puts",
513 \ "test", "testen", "testn", "the end", "uk", "wrong"],
514 \[
515 \ ["bad", ["put", "uk", "OK"]],
516 \ ["inputs", ["input", "puts", "outputs"]],
517 \ ["comment", ["Comment", "outtest", "the end"]],
518 \ ["ok", ["OK", "uk", "put"]],
519 \ ["Ok", ["OK", "Uk", "Put"]],
520 \ ["test", ["Test", "testn", "testen"]],
521 \ ["d\xE9\xF4l", ["deol", "d\xE9\xF4r", "test"]],
522 \ ["end", ["put", "uk", "test"]],
523 \ ["the", ["put", "uk", "test"]],
524 \ ]
525 \ )
526
527 call assert_equal("gebletegek", soundfold('goobledygoook'))
Bram Moolenaarf6ed61e2019-09-07 19:05:09 +0200528 call assert_equal("kepereneven", 'kóopërÿnôven'->soundfold())
Bram Moolenaard2c061d2017-06-22 21:42:49 +0200529 call assert_equal("everles gesvets etele", soundfold('oeverloos gezwets edale'))
530endfunc
531
532" Postponed prefixes
533func Test_zz_prefixes()
534 call LoadAffAndDic(g:test_data_aff2, g:test_data_dic1)
535 call RunGoodBad("puts",
536 \ "bad: inputs comment ok Ok end the. test d\xE9\xF4l",
537 \ ["Comment", "deol", "d\xE9\xF4r", "OK", "put", "input", "output", "puts", "outputs", "test", "outtest", "testen", "testn", "the end", "uk", "wrong"],
538 \ [
539 \ ["bad", ["put", "uk", "OK"]],
540 \ ["inputs", ["input", "puts", "outputs"]],
541 \ ["comment", ["Comment"]],
542 \ ["ok", ["OK", "uk", "put"]],
543 \ ["Ok", ["OK", "Uk", "Put"]],
544 \ ["end", ["put", "uk", "deol"]],
545 \ ["the", ["put", "uk", "test"]],
546 \ ["test", ["Test", "testn", "testen"]],
547 \ ["d\xE9\xF4l", ["deol", "d\xE9\xF4r", "test"]],
548 \ ])
549endfunc
550
551"Compound words
552func Test_zz_compound()
553 call LoadAffAndDic(g:test_data_aff3, g:test_data_dic3)
554 call RunGoodBad("foo m\xEF foobar foofoobar barfoo barbarfoo",
555 \ "bad: bar la foom\xEF barm\xEF m\xEFfoo m\xEFbar m\xEFm\xEF lala m\xEFla lam\xEF foola labar",
556 \ ["foo", "m\xEF"],
557 \ [
558 \ ["bad", ["foo", "m\xEF"]],
559 \ ["bar", ["barfoo", "foobar", "foo"]],
560 \ ["la", ["m\xEF", "foo"]],
561 \ ["foom\xEF", ["foo m\xEF", "foo", "foofoo"]],
562 \ ["barm\xEF", ["barfoo", "m\xEF", "barbar"]],
563 \ ["m\xEFfoo", ["m\xEF foo", "foo", "foofoo"]],
564 \ ["m\xEFbar", ["foobar", "barbar", "m\xEF"]],
565 \ ["m\xEFm\xEF", ["m\xEF m\xEF", "m\xEF"]],
566 \ ["lala", []],
567 \ ["m\xEFla", ["m\xEF", "m\xEF m\xEF"]],
568 \ ["lam\xEF", ["m\xEF", "m\xEF m\xEF"]],
569 \ ["foola", ["foo", "foobar", "foofoo"]],
570 \ ["labar", ["barbar", "foobar"]],
571 \ ])
572
573 call LoadAffAndDic(g:test_data_aff4, g:test_data_dic4)
574 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",
575 \ "bad: wordutilize pro borkborkborkborkborkbork tomatotomatotomato endstart endend startstart wordend wordstart preborkprebork preborkpreborkbork startwordwordwordwordend borkpreborkpreborkbork utilsbork startnouword",
576 \ ["bork", "prebork", "end", "pro-ok", "start", "tomato", "util", "utilize", "utils", "word", "nouword"],
577 \ [
578 \ ["bad", ["end", "bork", "word"]],
579 \ ["wordutilize", ["word utilize", "wordutils", "wordutil"]],
580 \ ["pro", ["bork", "word", "end"]],
581 \ ["borkborkborkborkborkbork", ["bork borkborkborkborkbork", "borkbork borkborkborkbork", "borkborkbork borkborkbork"]],
582 \ ["tomatotomatotomato", ["tomato tomatotomato", "tomatotomato tomato", "tomato tomato tomato"]],
583 \ ["endstart", ["end start", "start"]],
584 \ ["endend", ["end end", "end"]],
585 \ ["startstart", ["start start"]],
586 \ ["wordend", ["word end", "word", "wordword"]],
587 \ ["wordstart", ["word start", "bork start"]],
588 \ ["preborkprebork", ["prebork prebork", "preborkbork", "preborkborkbork"]],
589 \ ["preborkpreborkbork", ["prebork preborkbork", "preborkborkbork", "preborkborkborkbork"]],
590 \ ["startwordwordwordwordend", ["startwordwordwordword end", "startwordwordwordword", "start wordwordwordword end"]],
591 \ ["borkpreborkpreborkbork", ["bork preborkpreborkbork", "bork prebork preborkbork", "bork preborkprebork bork"]],
592 \ ["utilsbork", ["utilbork", "utils bork", "util bork"]],
593 \ ["startnouword", ["start nouword", "startword", "startborkword"]],
594 \ ])
595
596endfunc
597
598"Test affix flags with two characters
599func Test_zz_affix()
600 call LoadAffAndDic(g:test_data_aff5, g:test_data_dic5)
601 call RunGoodBad("fooa1 fooa\xE9 bar prebar barbork prebarbork startprebar start end startend startmiddleend nouend",
602 \ "bad: foo fooa2 prabar probarbirk middle startmiddle middleend endstart startprobar startnouend",
603 \ ["bar", "barbork", "end", "fooa1", "fooa\xE9", "nouend", "prebar", "prebarbork", "start"],
604 \ [
605 \ ["bad", ["bar", "end", "fooa1"]],
606 \ ["foo", ["fooa1", "fooa\xE9", "bar"]],
607 \ ["fooa2", ["fooa1", "fooa\xE9", "bar"]],
608 \ ["prabar", ["prebar", "bar", "bar bar"]],
609 \ ["probarbirk", ["prebarbork"]],
610 \ ["middle", []],
611 \ ["startmiddle", ["startmiddleend", "startmiddlebar"]],
612 \ ["middleend", []],
613 \ ["endstart", ["end start", "start"]],
614 \ ["startprobar", ["startprebar", "start prebar", "startbar"]],
615 \ ["startnouend", ["start nouend", "startend"]],
616 \ ])
617
618 call LoadAffAndDic(g:test_data_aff6, g:test_data_dic6)
619 call RunGoodBad("meea1 meea\xE9 bar prebar barbork prebarbork leadprebar lead end leadend leadmiddleend",
620 \ "bad: mee meea2 prabar probarbirk middle leadmiddle middleend endlead leadprobar",
621 \ ["bar", "barbork", "end", "lead", "meea1", "meea\xE9", "prebar", "prebarbork"],
622 \ [
623 \ ["bad", ["bar", "end", "lead"]],
624 \ ["mee", ["meea1", "meea\xE9", "bar"]],
625 \ ["meea2", ["meea1", "meea\xE9", "lead"]],
626 \ ["prabar", ["prebar", "bar", "leadbar"]],
627 \ ["probarbirk", ["prebarbork"]],
628 \ ["middle", []],
629 \ ["leadmiddle", ["leadmiddleend", "leadmiddlebar"]],
630 \ ["middleend", []],
631 \ ["endlead", ["end lead", "lead", "end end"]],
632 \ ["leadprobar", ["leadprebar", "lead prebar", "leadbar"]],
633 \ ])
634
635 call LoadAffAndDic(g:test_data_aff7, g:test_data_dic7)
Bram Moolenaar3d2a47c2019-11-07 20:48:42 +0100636 call RunGoodBad("meea1 meezero meea\xE9 bar prebar barmeat prebarmeat leadprebar lead tail leadtail leadmiddletail",
Bram Moolenaard2c061d2017-06-22 21:42:49 +0200637 \ "bad: mee meea2 prabar probarmaat middle leadmiddle middletail taillead leadprobar",
Bram Moolenaar3d2a47c2019-11-07 20:48:42 +0100638 \ ["bar", "barmeat", "lead", "meea1", "meea\xE9", "meezero", "prebar", "prebarmeat", "tail"],
Bram Moolenaard2c061d2017-06-22 21:42:49 +0200639 \ [
640 \ ["bad", ["bar", "lead", "tail"]],
641 \ ["mee", ["meea1", "meea\xE9", "bar"]],
642 \ ["meea2", ["meea1", "meea\xE9", "lead"]],
643 \ ["prabar", ["prebar", "bar", "leadbar"]],
644 \ ["probarmaat", ["prebarmeat"]],
645 \ ["middle", []],
646 \ ["leadmiddle", ["leadmiddlebar"]],
647 \ ["middletail", []],
648 \ ["taillead", ["tail lead", "tail"]],
649 \ ["leadprobar", ["leadprebar", "lead prebar", "leadbar"]],
650 \ ])
651endfunc
652
653func Test_zz_NOSLITSUGS()
654 call LoadAffAndDic(g:test_data_aff8, g:test_data_dic8)
655 call RunGoodBad("foo bar faabar", "bad: foobar barfoo",
656 \ ["bar", "faabar", "foo"],
657 \ [
658 \ ["bad", ["bar", "foo"]],
659 \ ["foobar", ["faabar", "foo bar", "bar"]],
660 \ ["barfoo", ["bar foo", "bar", "foo"]],
661 \ ])
662endfunc
663
664" Numbers
665func Test_zz_Numbers()
666 call LoadAffAndDic(g:test_data_aff9, g:test_data_dic9)
667 call RunGoodBad("0b1011 0777 1234 0x01ff", "",
668 \ ["bar", "foo"],
669 \ [
670 \ ])
671endfunc
672
Bram Moolenaar37ff4cf2019-11-17 20:10:20 +0100673" Affix flags
674func Test_zz_affix_flags()
675 call LoadAffAndDic(g:test_data_aff10, g:test_data_dic10)
676 call RunGoodBad("drink drinkable drinkables drinktable drinkabletable",
677 \ "bad: drinks drinkstable drinkablestable",
678 \ ["drink", "drinkable", "drinkables", "table"],
679 \ [['bad', []],
680 \ ['drinks', ['drink']],
681 \ ['drinkstable', ['drinktable', 'drinkable', 'drink table']],
682 \ ['drinkablestable', ['drinkabletable', 'drinkables table', 'drinkable table']],
683 \ ])
684endfunc
685
Bram Moolenaard2c061d2017-06-22 21:42:49 +0200686function FirstSpellWord()
687 call feedkeys("/^start:\n", 'tx')
688 normal ]smm
689 let [str, a] = spellbadword()
690 return str
691endfunc
692
693function SecondSpellWord()
694 normal `m]s
695 let [str, a] = spellbadword()
696 return str
697endfunc
698
699"Test with SAL instead of SOFO items; test automatic reloading
700func Test_zz_sal_and_addition()
701 set enc=latin1
702 set spellfile=
Bram Moolenaar1a0f2002017-07-28 15:38:10 +0200703 call writefile(g:test_data_dic1, "Xtest.dic")
Bram Moolenaard2c061d2017-06-22 21:42:49 +0200704 call writefile(g:test_data_aff_sal, "Xtest.aff")
705 mkspell! Xtest Xtest
706 set spl=Xtest.latin1.spl spell
707 call assert_equal('kbltykk', soundfold('goobledygoook'))
708 call assert_equal('kprnfn', soundfold('kóopërÿnôven'))
709 call assert_equal('*fls kswts tl', soundfold('oeverloos gezwets edale'))
710
711 "also use an addition file
712 call writefile(["/regions=usgbnz", "elequint/2", "elekwint/3"], "Xtest.latin1.add")
713 mkspell! Xtest.latin1.add.spl Xtest.latin1.add
714
715 bwipe!
716 call setline(1, ["start: elequint test elekwint test elekwent asdf"])
717
718 set spellfile=Xtest.latin1.add
719 call assert_equal("elekwent", FirstSpellWord())
720
721 set spl=Xtest_us.latin1.spl
722 call assert_equal("elequint", FirstSpellWord())
723 call assert_equal("elekwint", SecondSpellWord())
724
725 set spl=Xtest_gb.latin1.spl
726 call assert_equal("elekwint", FirstSpellWord())
727 call assert_equal("elekwent", SecondSpellWord())
728
729 set spl=Xtest_nz.latin1.spl
730 call assert_equal("elequint", FirstSpellWord())
731 call assert_equal("elekwent", SecondSpellWord())
732
733 set spl=Xtest_ca.latin1.spl
734 call assert_equal("elequint", FirstSpellWord())
735 call assert_equal("elekwint", SecondSpellWord())
736endfunc
737
Bram Moolenaar862f1e12019-04-10 22:33:41 +0200738func Test_spellfile_value()
739 set spellfile=Xdir/Xtest.latin1.add
740 set spellfile=Xdir/Xtest.utf-8.add,Xtest_other.add
741endfunc
742
Bram Moolenaaree03b942017-10-27 00:57:05 +0200743func Test_region_error()
744 messages clear
745 call writefile(["/regions=usgbnz", "elequint/0"], "Xtest.latin1.add")
746 mkspell! Xtest.latin1.add.spl Xtest.latin1.add
747 call assert_match('Invalid region nr in Xtest.latin1.add line 2: 0', execute('messages'))
748 call delete('Xtest.latin1.add')
749 call delete('Xtest.latin1.add.spl')
750endfunc
751
Bram Moolenaard2c061d2017-06-22 21:42:49 +0200752" Check using z= in new buffer (crash fixed by patch 7.4a.028).
753func Test_zeq_crash()
754 new
755 set maxmem=512 spell
756 call feedkeys('iasdz=:\"', 'tx')
757
758 bwipe!
759endfunc
760
Bram Moolenaar152e79e2020-06-10 15:32:08 +0200761" Check that z= works even when 'nospell' is set. This test uses one of the
762" tests in Test_spellsuggest_option_number() just to verify that z= basically
763" works and that "E756: Spell checking is not enabled" is not generated.
764func Test_zeq_nospell()
765 new
766 set nospell spellsuggest=1,best
767 call setline(1, 'A baord')
768 try
769 norm $1z=
770 call assert_equal('A board', getline(1))
771 catch
772 call assert_report("Caught exception: " . v:exception)
773 endtry
774 set spell& spellsuggest&
775 bwipe!
776endfunc
777
778" Check that "E756: Spell checking is not possible" is reported when z= is
779" executed and 'spelllang' is empty.
780func Test_zeq_no_spelllang()
781 new
782 set spelllang= spellsuggest=1,best
783 call setline(1, 'A baord')
784 call assert_fails('normal $1z=', 'E756:')
785 set spelllang& spellsuggest&
786 bwipe!
787endfunc
788
Bram Moolenaar5bcc5a12019-08-06 22:48:02 +0200789" Check handling a word longer than MAXWLEN.
790func Test_spell_long_word()
791 set enc=utf-8
792 new
793 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")
794 set spell spelllang=en
795 redraw
796 redraw!
797 bwipe!
798 set nospell
799endfunc
800
Bram Moolenaar06f15412022-01-29 10:51:59 +0000801func Test_spellsuggest_too_deep()
802 " This was incrementing "depth" over MAXWLEN.
803 new
804 norm s000G00ý000000000000
805 sil norm ..vzG................vvzG0 v z=
806 bwipe!
807endfunc
808
Bram Moolenaard2c061d2017-06-22 21:42:49 +0200809func LoadAffAndDic(aff_contents, dic_contents)
810 set enc=latin1
811 set spellfile=
812 call writefile(a:aff_contents, "Xtest.aff")
813 call writefile(a:dic_contents, "Xtest.dic")
814 " Generate a .spl file from a .dic and .aff file.
815 mkspell! Xtest Xtest
816 " use that spell file
817 set spl=Xtest.latin1.spl spell
818endfunc
819
820func ListWords()
821 spelldump
822 %yank
823 quit
824 return split(@", "\n")
825endfunc
826
827func TestGoodBadBase()
828 exe '1;/^good:'
829 normal 0f:]s
830 let prevbad = ''
831 let result = []
832 while 1
833 let [bad, a] = spellbadword()
834 if bad == '' || bad == prevbad || bad == 'badend'
835 break
836 endif
837 let prevbad = bad
Bram Moolenaarf6ed61e2019-09-07 19:05:09 +0200838 let lst = bad->spellsuggest(3)
Bram Moolenaard2c061d2017-06-22 21:42:49 +0200839 normal mm
840
841 call add(result, [bad, lst])
842 normal `m]s
843 endwhile
844 return result
845endfunc
846
847func RunGoodBad(good, bad, expected_words, expected_bad_words)
848 bwipe!
849 call setline(1, ["good: ", a:good, a:bad, " badend "])
850 let words = ListWords()
851 call assert_equal(a:expected_words, words[1:-1])
852 let bad_words = TestGoodBadBase()
853 call assert_equal(a:expected_bad_words, bad_words)
854 bwipe!
855endfunc
856
Bram Moolenaar7751d1d2019-10-18 20:37:08 +0200857func Test_spell_screendump()
858 CheckScreendump
859
860 let lines =<< trim END
861 call setline(1, [
862 \ "This is some text without any spell errors. Everything",
863 \ "should just be black, nothing wrong here.",
864 \ "",
865 \ "This line has a sepll error. and missing caps.",
866 \ "And and this is the the duplication.",
867 \ "with missing caps here.",
868 \ ])
869 set spell spelllang=en_nz
870 END
871 call writefile(lines, 'XtestSpell')
872 let buf = RunVimInTerminal('-S XtestSpell', {'rows': 8})
873 call VerifyScreenDump(buf, 'Test_spell_1', {})
874
875 " clean up
876 call StopVimInTerminal(buf)
877 call delete('XtestSpell')
878endfunc
879
Bram Moolenaard2c061d2017-06-22 21:42:49 +0200880let g:test_data_aff1 = [
881 \"SET ISO8859-1",
882 \"TRY esianrtolcdugmphbyfvkwjkqxz-\xEB\xE9\xE8\xEA\xEF\xEE\xE4\xE0\xE2\xF6\xFC\xFB'ESIANRTOLCDUGMPHBYFVKWJKQXZ",
883 \"",
884 \"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",
885 \"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",
886 \"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",
887 \"",
888 \"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",
889 \"SOFOTO ebctefghejklnnepkrstevvkesebctefghejklnnepkrstevvkeseeeeeeeceeeeeeeedneeeeeeeeeeepseeeeeeeeceeeeeeeedneeeeeeeeeeep?",
890 \"",
891 \"MIDWORD\t'-",
892 \"",
893 \"KEP =",
894 \"RAR ?",
895 \"BAD !",
896 \"",
897 \"PFX I N 1",
898 \"PFX I 0 in .",
899 \"",
900 \"PFX O Y 1",
901 \"PFX O 0 out .",
902 \"",
903 \"SFX S Y 2",
904 \"SFX S 0 s [^s]",
905 \"SFX S 0 es s",
906 \"",
907 \"SFX N N 3",
908 \"SFX N 0 en [^n]",
909 \"SFX N 0 nen n",
910 \"SFX N 0 n .",
911 \"",
912 \"REP 3",
913 \"REP g ch",
914 \"REP ch g",
915 \"REP svp s.v.p.",
916 \"",
917 \"MAP 9",
918 \"MAP a\xE0\xE1\xE2\xE3\xE4\xE5",
919 \"MAP e\xE8\xE9\xEA\xEB",
920 \"MAP i\xEC\xED\xEE\xEF",
921 \"MAP o\xF2\xF3\xF4\xF5\xF6",
922 \"MAP u\xF9\xFA\xFB\xFC",
923 \"MAP n\xF1",
924 \"MAP c\xE7",
925 \"MAP y\xFF\xFD",
926 \"MAP s\xDF",
927 \ ]
928let g:test_data_dic1 = [
929 \"123456",
930 \"test/NO",
931 \"# comment",
932 \"wrong",
933 \"Comment",
934 \"OK",
935 \"uk",
936 \"put/ISO",
937 \"the end",
938 \"deol",
939 \"d\xE9\xF4r",
940 \ ]
941let g:test_data_aff2 = [
942 \"SET ISO8859-1",
943 \"",
944 \"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",
945 \"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",
946 \"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",
947 \"",
948 \"PFXPOSTPONE",
949 \"",
950 \"MIDWORD\t'-",
951 \"",
952 \"KEP =",
953 \"RAR ?",
954 \"BAD !",
955 \"",
956 \"PFX I N 1",
957 \"PFX I 0 in .",
958 \"",
959 \"PFX O Y 1",
960 \"PFX O 0 out [a-z]",
961 \"",
962 \"SFX S Y 2",
963 \"SFX S 0 s [^s]",
964 \"SFX S 0 es s",
965 \"",
966 \"SFX N N 3",
967 \"SFX N 0 en [^n]",
968 \"SFX N 0 nen n",
969 \"SFX N 0 n .",
970 \"",
971 \"REP 3",
972 \"REP g ch",
973 \"REP ch g",
974 \"REP svp s.v.p.",
975 \"",
976 \"MAP 9",
977 \"MAP a\xE0\xE1\xE2\xE3\xE4\xE5",
978 \"MAP e\xE8\xE9\xEA\xEB",
979 \"MAP i\xEC\xED\xEE\xEF",
980 \"MAP o\xF2\xF3\xF4\xF5\xF6",
981 \"MAP u\xF9\xFA\xFB\xFC",
982 \"MAP n\xF1",
983 \"MAP c\xE7",
984 \"MAP y\xFF\xFD",
985 \"MAP s\xDF",
986 \ ]
987let g:test_data_aff3 = [
988 \"SET ISO8859-1",
989 \"",
990 \"COMPOUNDMIN 3",
991 \"COMPOUNDRULE m*",
992 \"NEEDCOMPOUND x",
993 \ ]
994let g:test_data_dic3 = [
995 \"1234",
996 \"foo/m",
997 \"bar/mx",
998 \"m\xEF/m",
999 \"la/mx",
1000 \ ]
1001let g:test_data_aff4 = [
1002 \"SET ISO8859-1",
1003 \"",
1004 \"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",
1005 \"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",
1006 \"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",
1007 \"",
1008 \"COMPOUNDRULE m+",
1009 \"COMPOUNDRULE sm*e",
1010 \"COMPOUNDRULE sm+",
1011 \"COMPOUNDMIN 3",
1012 \"COMPOUNDWORDMAX 3",
1013 \"COMPOUNDFORBIDFLAG t",
1014 \"",
1015 \"COMPOUNDSYLMAX 5",
1016 \"SYLLABLE a\xE1e\xE9i\xEDo\xF3\xF6\xF5u\xFA\xFC\xFBy/aa/au/ea/ee/ei/ie/oa/oe/oo/ou/uu/ui",
1017 \"",
1018 \"MAP 9",
1019 \"MAP a\xE0\xE1\xE2\xE3\xE4\xE5",
1020 \"MAP e\xE8\xE9\xEA\xEB",
1021 \"MAP i\xEC\xED\xEE\xEF",
1022 \"MAP o\xF2\xF3\xF4\xF5\xF6",
1023 \"MAP u\xF9\xFA\xFB\xFC",
1024 \"MAP n\xF1",
1025 \"MAP c\xE7",
1026 \"MAP y\xFF\xFD",
1027 \"MAP s\xDF",
1028 \"",
1029 \"NEEDAFFIX x",
1030 \"",
1031 \"PFXPOSTPONE",
1032 \"",
1033 \"MIDWORD '-",
1034 \"",
1035 \"SFX q N 1",
1036 \"SFX q 0 -ok .",
1037 \"",
1038 \"SFX a Y 2",
1039 \"SFX a 0 s .",
1040 \"SFX a 0 ize/t .",
1041 \"",
1042 \"PFX p N 1",
1043 \"PFX p 0 pre .",
1044 \"",
1045 \"PFX P N 1",
1046 \"PFX P 0 nou .",
1047 \ ]
1048let g:test_data_dic4 = [
1049 \"1234",
1050 \"word/mP",
1051 \"util/am",
1052 \"pro/xq",
1053 \"tomato/m",
1054 \"bork/mp",
1055 \"start/s",
1056 \"end/e",
1057 \ ]
1058let g:test_data_aff5 = [
1059 \"SET ISO8859-1",
1060 \"",
1061 \"FLAG long",
1062 \"",
1063 \"NEEDAFFIX !!",
1064 \"",
1065 \"COMPOUNDRULE ssmm*ee",
1066 \"",
1067 \"NEEDCOMPOUND xx",
1068 \"COMPOUNDPERMITFLAG pp",
1069 \"",
1070 \"SFX 13 Y 1",
1071 \"SFX 13 0 bork .",
1072 \"",
1073 \"SFX a1 Y 1",
1074 \"SFX a1 0 a1 .",
1075 \"",
1076 \"SFX a\xE9 Y 1",
1077 \"SFX a\xE9 0 a\xE9 .",
1078 \"",
1079 \"PFX zz Y 1",
1080 \"PFX zz 0 pre/pp .",
1081 \"",
1082 \"PFX yy Y 1",
1083 \"PFX yy 0 nou .",
1084 \ ]
1085let g:test_data_dic5 = [
1086 \"1234",
1087 \"foo/a1a\xE9!!",
1088 \"bar/zz13ee",
1089 \"start/ss",
1090 \"end/eeyy",
1091 \"middle/mmxx",
1092 \ ]
1093let g:test_data_aff6 = [
1094 \"SET ISO8859-1",
1095 \"",
1096 \"FLAG caplong",
1097 \"",
1098 \"NEEDAFFIX A!",
1099 \"",
1100 \"COMPOUNDRULE sMm*Ee",
1101 \"",
1102 \"NEEDCOMPOUND Xx",
1103 \"",
1104 \"COMPOUNDPERMITFLAG p",
1105 \"",
1106 \"SFX N3 Y 1",
1107 \"SFX N3 0 bork .",
1108 \"",
1109 \"SFX A1 Y 1",
1110 \"SFX A1 0 a1 .",
1111 \"",
1112 \"SFX A\xE9 Y 1",
1113 \"SFX A\xE9 0 a\xE9 .",
1114 \"",
1115 \"PFX Zz Y 1",
1116 \"PFX Zz 0 pre/p .",
1117 \ ]
1118let g:test_data_dic6 = [
1119 \"1234",
1120 \"mee/A1A\xE9A!",
1121 \"bar/ZzN3Ee",
1122 \"lead/s",
1123 \"end/Ee",
1124 \"middle/MmXx",
1125 \ ]
1126let g:test_data_aff7 = [
1127 \"SET ISO8859-1",
1128 \"",
1129 \"FLAG num",
1130 \"",
1131 \"NEEDAFFIX 9999",
1132 \"",
1133 \"COMPOUNDRULE 2,77*123",
1134 \"",
1135 \"NEEDCOMPOUND 1",
1136 \"COMPOUNDPERMITFLAG 432",
1137 \"",
1138 \"SFX 61003 Y 1",
1139 \"SFX 61003 0 meat .",
1140 \"",
Bram Moolenaar3d2a47c2019-11-07 20:48:42 +01001141 \"SFX 0 Y 1",
1142 \"SFX 0 0 zero .",
1143 \"",
Bram Moolenaard2c061d2017-06-22 21:42:49 +02001144 \"SFX 391 Y 1",
1145 \"SFX 391 0 a1 .",
1146 \"",
1147 \"SFX 111 Y 1",
1148 \"SFX 111 0 a\xE9 .",
1149 \"",
1150 \"PFX 17 Y 1",
1151 \"PFX 17 0 pre/432 .",
1152 \ ]
1153let g:test_data_dic7 = [
1154 \"1234",
Bram Moolenaar3d2a47c2019-11-07 20:48:42 +01001155 \"mee/0,391,111,9999",
Bram Moolenaard2c061d2017-06-22 21:42:49 +02001156 \"bar/17,61003,123",
1157 \"lead/2",
1158 \"tail/123",
1159 \"middle/77,1",
1160 \ ]
1161let g:test_data_aff8 = [
1162 \"SET ISO8859-1",
1163 \"",
1164 \"NOSPLITSUGS",
1165 \ ]
1166let g:test_data_dic8 = [
1167 \"1234",
1168 \"foo",
1169 \"bar",
1170 \"faabar",
1171 \ ]
1172let g:test_data_aff9 = [
1173 \ ]
1174let g:test_data_dic9 = [
1175 \"1234",
1176 \"foo",
1177 \"bar",
1178 \ ]
Bram Moolenaar37ff4cf2019-11-17 20:10:20 +01001179let g:test_data_aff10 = [
1180 \"COMPOUNDRULE se",
1181 \"COMPOUNDPERMITFLAG p",
1182 \"",
1183 \"SFX A Y 1",
1184 \"SFX A 0 able/Mp .",
1185 \"",
1186 \"SFX M Y 1",
1187 \"SFX M 0 s .",
1188 \ ]
1189let g:test_data_dic10 = [
1190 \"1234",
1191 \"drink/As",
1192 \"table/e",
1193 \ ]
Bram Moolenaard2c061d2017-06-22 21:42:49 +02001194let g:test_data_aff_sal = [
1195 \"SET ISO8859-1",
1196 \"TRY esianrtolcdugmphbyfvkwjkqxz-\xEB\xE9\xE8\xEA\xEF\xEE\xE4\xE0\xE2\xF6\xFC\xFB'ESIANRTOLCDUGMPHBYFVKWJKQXZ",
1197 \"",
1198 \"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",
1199 \"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",
1200 \"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",
1201 \"",
1202 \"MIDWORD\t'-",
1203 \"",
1204 \"KEP =",
1205 \"RAR ?",
1206 \"BAD !",
1207 \"",
1208 \"PFX I N 1",
1209 \"PFX I 0 in .",
1210 \"",
1211 \"PFX O Y 1",
1212 \"PFX O 0 out .",
1213 \"",
1214 \"SFX S Y 2",
1215 \"SFX S 0 s [^s]",
1216 \"SFX S 0 es s",
1217 \"",
1218 \"SFX N N 3",
1219 \"SFX N 0 en [^n]",
1220 \"SFX N 0 nen n",
1221 \"SFX N 0 n .",
1222 \"",
1223 \"REP 3",
1224 \"REP g ch",
1225 \"REP ch g",
1226 \"REP svp s.v.p.",
1227 \"",
1228 \"MAP 9",
1229 \"MAP a\xE0\xE1\xE2\xE3\xE4\xE5",
1230 \"MAP e\xE8\xE9\xEA\xEB",
1231 \"MAP i\xEC\xED\xEE\xEF",
1232 \"MAP o\xF2\xF3\xF4\xF5\xF6",
1233 \"MAP u\xF9\xFA\xFB\xFC",
1234 \"MAP n\xF1",
1235 \"MAP c\xE7",
1236 \"MAP y\xFF\xFD",
1237 \"MAP s\xDF",
1238 \"",
1239 \"SAL AH(AEIOUY)-^ *H",
1240 \"SAL AR(AEIOUY)-^ *R",
1241 \"SAL A(HR)^ *",
1242 \"SAL A^ *",
1243 \"SAL AH(AEIOUY)- H",
1244 \"SAL AR(AEIOUY)- R",
1245 \"SAL A(HR) _",
1246 \"SAL \xC0^ *",
1247 \"SAL \xC5^ *",
1248 \"SAL BB- _",
1249 \"SAL B B",
1250 \"SAL CQ- _",
1251 \"SAL CIA X",
1252 \"SAL CH X",
1253 \"SAL C(EIY)- S",
1254 \"SAL CK K",
1255 \"SAL COUGH^ KF",
1256 \"SAL CC< C",
1257 \"SAL C K",
1258 \"SAL DG(EIY) K",
1259 \"SAL DD- _",
1260 \"SAL D T",
1261 \"SAL \xC9< E",
1262 \"SAL EH(AEIOUY)-^ *H",
1263 \"SAL ER(AEIOUY)-^ *R",
1264 \"SAL E(HR)^ *",
1265 \"SAL ENOUGH^$ *NF",
1266 \"SAL E^ *",
1267 \"SAL EH(AEIOUY)- H",
1268 \"SAL ER(AEIOUY)- R",
1269 \"SAL E(HR) _",
1270 \"SAL FF- _",
1271 \"SAL F F",
1272 \"SAL GN^ N",
1273 \"SAL GN$ N",
1274 \"SAL GNS$ NS",
1275 \"SAL GNED$ N",
1276 \"SAL GH(AEIOUY)- K",
1277 \"SAL GH _",
1278 \"SAL GG9 K",
1279 \"SAL G K",
1280 \"SAL H H",
1281 \"SAL IH(AEIOUY)-^ *H",
1282 \"SAL IR(AEIOUY)-^ *R",
1283 \"SAL I(HR)^ *",
1284 \"SAL I^ *",
1285 \"SAL ING6 N",
1286 \"SAL IH(AEIOUY)- H",
1287 \"SAL IR(AEIOUY)- R",
1288 \"SAL I(HR) _",
1289 \"SAL J K",
1290 \"SAL KN^ N",
1291 \"SAL KK- _",
1292 \"SAL K K",
1293 \"SAL LAUGH^ LF",
1294 \"SAL LL- _",
1295 \"SAL L L",
1296 \"SAL MB$ M",
1297 \"SAL MM M",
1298 \"SAL M M",
1299 \"SAL NN- _",
1300 \"SAL N N",
1301 \"SAL OH(AEIOUY)-^ *H",
1302 \"SAL OR(AEIOUY)-^ *R",
1303 \"SAL O(HR)^ *",
1304 \"SAL O^ *",
1305 \"SAL OH(AEIOUY)- H",
1306 \"SAL OR(AEIOUY)- R",
1307 \"SAL O(HR) _",
1308 \"SAL PH F",
1309 \"SAL PN^ N",
1310 \"SAL PP- _",
1311 \"SAL P P",
1312 \"SAL Q K",
1313 \"SAL RH^ R",
1314 \"SAL ROUGH^ RF",
1315 \"SAL RR- _",
1316 \"SAL R R",
1317 \"SAL SCH(EOU)- SK",
1318 \"SAL SC(IEY)- S",
1319 \"SAL SH X",
1320 \"SAL SI(AO)- X",
1321 \"SAL SS- _",
1322 \"SAL S S",
1323 \"SAL TI(AO)- X",
1324 \"SAL TH @",
1325 \"SAL TCH-- _",
1326 \"SAL TOUGH^ TF",
1327 \"SAL TT- _",
1328 \"SAL T T",
1329 \"SAL UH(AEIOUY)-^ *H",
1330 \"SAL UR(AEIOUY)-^ *R",
1331 \"SAL U(HR)^ *",
1332 \"SAL U^ *",
1333 \"SAL UH(AEIOUY)- H",
1334 \"SAL UR(AEIOUY)- R",
1335 \"SAL U(HR) _",
1336 \"SAL V^ W",
1337 \"SAL V F",
1338 \"SAL WR^ R",
1339 \"SAL WH^ W",
1340 \"SAL W(AEIOU)- W",
1341 \"SAL X^ S",
1342 \"SAL X KS",
1343 \"SAL Y(AEIOU)- Y",
1344 \"SAL ZZ- _",
1345 \"SAL Z S",
1346 \ ]
Bram Moolenaar0e05de42020-03-25 22:23:46 +01001347
1348" vim: shiftwidth=2 sts=2 expandtab