blob: e6f535be14604784b20998b390604a8220ba22a7 [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
Bram Moolenaar8dfcce32020-03-18 19:32:26 +0100420" Test for 'spellsuggest' expr errrors
421func 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 Moolenaar9049b682018-08-31 22:26:53 +0200459func Test_spellinfo()
460 new
Bram Moolenaarc25e7022019-10-10 14:08:26 +0200461 let runtime = substitute($VIMRUNTIME, '\\', '/', 'g')
Bram Moolenaar9049b682018-08-31 22:26:53 +0200462
463 set enc=latin1 spell spelllang=en
Bram Moolenaarc25e7022019-10-10 14:08:26 +0200464 call assert_match("^\nfile: " .. runtime .. "/spell/en.latin1.spl\n$", execute('spellinfo'))
Bram Moolenaar9049b682018-08-31 22:26:53 +0200465
466 set enc=cp1250 spell spelllang=en
Bram Moolenaarc25e7022019-10-10 14:08:26 +0200467 call assert_match("^\nfile: " .. runtime .. "/spell/en.ascii.spl\n$", execute('spellinfo'))
Bram Moolenaar9049b682018-08-31 22:26:53 +0200468
Bram Moolenaar30276f22019-01-24 17:59:39 +0100469 set enc=utf-8 spell spelllang=en
Bram Moolenaarc25e7022019-10-10 14:08:26 +0200470 call assert_match("^\nfile: " .. runtime .. "/spell/en.utf-8.spl\n$", execute('spellinfo'))
Bram Moolenaar9049b682018-08-31 22:26:53 +0200471
472 set enc=latin1 spell spelllang=en_us,en_nz
473 call assert_match("^\n" .
Bram Moolenaarc25e7022019-10-10 14:08:26 +0200474 \ "file: " .. runtime .. "/spell/en.latin1.spl\n" .
475 \ "file: " .. runtime.. "/spell/en.latin1.spl\n$", execute('spellinfo'))
Bram Moolenaar9049b682018-08-31 22:26:53 +0200476
477 set spell spelllang=
478 call assert_fails('spellinfo', 'E756:')
479
480 set nospell spelllang=en
481 call assert_fails('spellinfo', 'E756:')
482
Bram Moolenaar8f130ed2019-04-10 22:15:19 +0200483 call assert_fails('set spelllang=foo/bar', 'E474:')
484 call assert_fails('set spelllang=foo\ bar', 'E474:')
485 call assert_fails("set spelllang=foo\\\nbar", 'E474:')
486 call assert_fails("set spelllang=foo\\\rbar", 'E474:')
487 call assert_fails("set spelllang=foo+bar", 'E474:')
488
Bram Moolenaar9049b682018-08-31 22:26:53 +0200489 set enc& spell& spelllang&
490 bwipe
491endfunc
492
Bram Moolenaard2c061d2017-06-22 21:42:49 +0200493func Test_zz_basic()
494 call LoadAffAndDic(g:test_data_aff1, g:test_data_dic1)
495 call RunGoodBad("wrong OK puts. Test the end",
496 \ "bad: inputs comment ok Ok. test d\xE9\xF4l end the",
497 \["Comment", "deol", "d\xE9\xF4r", "input", "OK", "output", "outputs", "outtest", "put", "puts",
498 \ "test", "testen", "testn", "the end", "uk", "wrong"],
499 \[
500 \ ["bad", ["put", "uk", "OK"]],
501 \ ["inputs", ["input", "puts", "outputs"]],
502 \ ["comment", ["Comment", "outtest", "the end"]],
503 \ ["ok", ["OK", "uk", "put"]],
504 \ ["Ok", ["OK", "Uk", "Put"]],
505 \ ["test", ["Test", "testn", "testen"]],
506 \ ["d\xE9\xF4l", ["deol", "d\xE9\xF4r", "test"]],
507 \ ["end", ["put", "uk", "test"]],
508 \ ["the", ["put", "uk", "test"]],
509 \ ]
510 \ )
511
512 call assert_equal("gebletegek", soundfold('goobledygoook'))
Bram Moolenaarf6ed61e2019-09-07 19:05:09 +0200513 call assert_equal("kepereneven", 'kóopërÿnôven'->soundfold())
Bram Moolenaard2c061d2017-06-22 21:42:49 +0200514 call assert_equal("everles gesvets etele", soundfold('oeverloos gezwets edale'))
515endfunc
516
517" Postponed prefixes
518func Test_zz_prefixes()
519 call LoadAffAndDic(g:test_data_aff2, g:test_data_dic1)
520 call RunGoodBad("puts",
521 \ "bad: inputs comment ok Ok end the. test d\xE9\xF4l",
522 \ ["Comment", "deol", "d\xE9\xF4r", "OK", "put", "input", "output", "puts", "outputs", "test", "outtest", "testen", "testn", "the end", "uk", "wrong"],
523 \ [
524 \ ["bad", ["put", "uk", "OK"]],
525 \ ["inputs", ["input", "puts", "outputs"]],
526 \ ["comment", ["Comment"]],
527 \ ["ok", ["OK", "uk", "put"]],
528 \ ["Ok", ["OK", "Uk", "Put"]],
529 \ ["end", ["put", "uk", "deol"]],
530 \ ["the", ["put", "uk", "test"]],
531 \ ["test", ["Test", "testn", "testen"]],
532 \ ["d\xE9\xF4l", ["deol", "d\xE9\xF4r", "test"]],
533 \ ])
534endfunc
535
536"Compound words
537func Test_zz_compound()
538 call LoadAffAndDic(g:test_data_aff3, g:test_data_dic3)
539 call RunGoodBad("foo m\xEF foobar foofoobar barfoo barbarfoo",
540 \ "bad: bar la foom\xEF barm\xEF m\xEFfoo m\xEFbar m\xEFm\xEF lala m\xEFla lam\xEF foola labar",
541 \ ["foo", "m\xEF"],
542 \ [
543 \ ["bad", ["foo", "m\xEF"]],
544 \ ["bar", ["barfoo", "foobar", "foo"]],
545 \ ["la", ["m\xEF", "foo"]],
546 \ ["foom\xEF", ["foo m\xEF", "foo", "foofoo"]],
547 \ ["barm\xEF", ["barfoo", "m\xEF", "barbar"]],
548 \ ["m\xEFfoo", ["m\xEF foo", "foo", "foofoo"]],
549 \ ["m\xEFbar", ["foobar", "barbar", "m\xEF"]],
550 \ ["m\xEFm\xEF", ["m\xEF m\xEF", "m\xEF"]],
551 \ ["lala", []],
552 \ ["m\xEFla", ["m\xEF", "m\xEF m\xEF"]],
553 \ ["lam\xEF", ["m\xEF", "m\xEF m\xEF"]],
554 \ ["foola", ["foo", "foobar", "foofoo"]],
555 \ ["labar", ["barbar", "foobar"]],
556 \ ])
557
558 call LoadAffAndDic(g:test_data_aff4, g:test_data_dic4)
559 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",
560 \ "bad: wordutilize pro borkborkborkborkborkbork tomatotomatotomato endstart endend startstart wordend wordstart preborkprebork preborkpreborkbork startwordwordwordwordend borkpreborkpreborkbork utilsbork startnouword",
561 \ ["bork", "prebork", "end", "pro-ok", "start", "tomato", "util", "utilize", "utils", "word", "nouword"],
562 \ [
563 \ ["bad", ["end", "bork", "word"]],
564 \ ["wordutilize", ["word utilize", "wordutils", "wordutil"]],
565 \ ["pro", ["bork", "word", "end"]],
566 \ ["borkborkborkborkborkbork", ["bork borkborkborkborkbork", "borkbork borkborkborkbork", "borkborkbork borkborkbork"]],
567 \ ["tomatotomatotomato", ["tomato tomatotomato", "tomatotomato tomato", "tomato tomato tomato"]],
568 \ ["endstart", ["end start", "start"]],
569 \ ["endend", ["end end", "end"]],
570 \ ["startstart", ["start start"]],
571 \ ["wordend", ["word end", "word", "wordword"]],
572 \ ["wordstart", ["word start", "bork start"]],
573 \ ["preborkprebork", ["prebork prebork", "preborkbork", "preborkborkbork"]],
574 \ ["preborkpreborkbork", ["prebork preborkbork", "preborkborkbork", "preborkborkborkbork"]],
575 \ ["startwordwordwordwordend", ["startwordwordwordword end", "startwordwordwordword", "start wordwordwordword end"]],
576 \ ["borkpreborkpreborkbork", ["bork preborkpreborkbork", "bork prebork preborkbork", "bork preborkprebork bork"]],
577 \ ["utilsbork", ["utilbork", "utils bork", "util bork"]],
578 \ ["startnouword", ["start nouword", "startword", "startborkword"]],
579 \ ])
580
581endfunc
582
583"Test affix flags with two characters
584func Test_zz_affix()
585 call LoadAffAndDic(g:test_data_aff5, g:test_data_dic5)
586 call RunGoodBad("fooa1 fooa\xE9 bar prebar barbork prebarbork startprebar start end startend startmiddleend nouend",
587 \ "bad: foo fooa2 prabar probarbirk middle startmiddle middleend endstart startprobar startnouend",
588 \ ["bar", "barbork", "end", "fooa1", "fooa\xE9", "nouend", "prebar", "prebarbork", "start"],
589 \ [
590 \ ["bad", ["bar", "end", "fooa1"]],
591 \ ["foo", ["fooa1", "fooa\xE9", "bar"]],
592 \ ["fooa2", ["fooa1", "fooa\xE9", "bar"]],
593 \ ["prabar", ["prebar", "bar", "bar bar"]],
594 \ ["probarbirk", ["prebarbork"]],
595 \ ["middle", []],
596 \ ["startmiddle", ["startmiddleend", "startmiddlebar"]],
597 \ ["middleend", []],
598 \ ["endstart", ["end start", "start"]],
599 \ ["startprobar", ["startprebar", "start prebar", "startbar"]],
600 \ ["startnouend", ["start nouend", "startend"]],
601 \ ])
602
603 call LoadAffAndDic(g:test_data_aff6, g:test_data_dic6)
604 call RunGoodBad("meea1 meea\xE9 bar prebar barbork prebarbork leadprebar lead end leadend leadmiddleend",
605 \ "bad: mee meea2 prabar probarbirk middle leadmiddle middleend endlead leadprobar",
606 \ ["bar", "barbork", "end", "lead", "meea1", "meea\xE9", "prebar", "prebarbork"],
607 \ [
608 \ ["bad", ["bar", "end", "lead"]],
609 \ ["mee", ["meea1", "meea\xE9", "bar"]],
610 \ ["meea2", ["meea1", "meea\xE9", "lead"]],
611 \ ["prabar", ["prebar", "bar", "leadbar"]],
612 \ ["probarbirk", ["prebarbork"]],
613 \ ["middle", []],
614 \ ["leadmiddle", ["leadmiddleend", "leadmiddlebar"]],
615 \ ["middleend", []],
616 \ ["endlead", ["end lead", "lead", "end end"]],
617 \ ["leadprobar", ["leadprebar", "lead prebar", "leadbar"]],
618 \ ])
619
620 call LoadAffAndDic(g:test_data_aff7, g:test_data_dic7)
Bram Moolenaar3d2a47c2019-11-07 20:48:42 +0100621 call RunGoodBad("meea1 meezero meea\xE9 bar prebar barmeat prebarmeat leadprebar lead tail leadtail leadmiddletail",
Bram Moolenaard2c061d2017-06-22 21:42:49 +0200622 \ "bad: mee meea2 prabar probarmaat middle leadmiddle middletail taillead leadprobar",
Bram Moolenaar3d2a47c2019-11-07 20:48:42 +0100623 \ ["bar", "barmeat", "lead", "meea1", "meea\xE9", "meezero", "prebar", "prebarmeat", "tail"],
Bram Moolenaard2c061d2017-06-22 21:42:49 +0200624 \ [
625 \ ["bad", ["bar", "lead", "tail"]],
626 \ ["mee", ["meea1", "meea\xE9", "bar"]],
627 \ ["meea2", ["meea1", "meea\xE9", "lead"]],
628 \ ["prabar", ["prebar", "bar", "leadbar"]],
629 \ ["probarmaat", ["prebarmeat"]],
630 \ ["middle", []],
631 \ ["leadmiddle", ["leadmiddlebar"]],
632 \ ["middletail", []],
633 \ ["taillead", ["tail lead", "tail"]],
634 \ ["leadprobar", ["leadprebar", "lead prebar", "leadbar"]],
635 \ ])
636endfunc
637
638func Test_zz_NOSLITSUGS()
639 call LoadAffAndDic(g:test_data_aff8, g:test_data_dic8)
640 call RunGoodBad("foo bar faabar", "bad: foobar barfoo",
641 \ ["bar", "faabar", "foo"],
642 \ [
643 \ ["bad", ["bar", "foo"]],
644 \ ["foobar", ["faabar", "foo bar", "bar"]],
645 \ ["barfoo", ["bar foo", "bar", "foo"]],
646 \ ])
647endfunc
648
649" Numbers
650func Test_zz_Numbers()
651 call LoadAffAndDic(g:test_data_aff9, g:test_data_dic9)
652 call RunGoodBad("0b1011 0777 1234 0x01ff", "",
653 \ ["bar", "foo"],
654 \ [
655 \ ])
656endfunc
657
Bram Moolenaar37ff4cf2019-11-17 20:10:20 +0100658" Affix flags
659func Test_zz_affix_flags()
660 call LoadAffAndDic(g:test_data_aff10, g:test_data_dic10)
661 call RunGoodBad("drink drinkable drinkables drinktable drinkabletable",
662 \ "bad: drinks drinkstable drinkablestable",
663 \ ["drink", "drinkable", "drinkables", "table"],
664 \ [['bad', []],
665 \ ['drinks', ['drink']],
666 \ ['drinkstable', ['drinktable', 'drinkable', 'drink table']],
667 \ ['drinkablestable', ['drinkabletable', 'drinkables table', 'drinkable table']],
668 \ ])
669endfunc
670
Bram Moolenaard2c061d2017-06-22 21:42:49 +0200671function FirstSpellWord()
672 call feedkeys("/^start:\n", 'tx')
673 normal ]smm
674 let [str, a] = spellbadword()
675 return str
676endfunc
677
678function SecondSpellWord()
679 normal `m]s
680 let [str, a] = spellbadword()
681 return str
682endfunc
683
684"Test with SAL instead of SOFO items; test automatic reloading
685func Test_zz_sal_and_addition()
686 set enc=latin1
687 set spellfile=
Bram Moolenaar1a0f2002017-07-28 15:38:10 +0200688 call writefile(g:test_data_dic1, "Xtest.dic")
Bram Moolenaard2c061d2017-06-22 21:42:49 +0200689 call writefile(g:test_data_aff_sal, "Xtest.aff")
690 mkspell! Xtest Xtest
691 set spl=Xtest.latin1.spl spell
692 call assert_equal('kbltykk', soundfold('goobledygoook'))
693 call assert_equal('kprnfn', soundfold('kóopërÿnôven'))
694 call assert_equal('*fls kswts tl', soundfold('oeverloos gezwets edale'))
695
696 "also use an addition file
697 call writefile(["/regions=usgbnz", "elequint/2", "elekwint/3"], "Xtest.latin1.add")
698 mkspell! Xtest.latin1.add.spl Xtest.latin1.add
699
700 bwipe!
701 call setline(1, ["start: elequint test elekwint test elekwent asdf"])
702
703 set spellfile=Xtest.latin1.add
704 call assert_equal("elekwent", FirstSpellWord())
705
706 set spl=Xtest_us.latin1.spl
707 call assert_equal("elequint", FirstSpellWord())
708 call assert_equal("elekwint", SecondSpellWord())
709
710 set spl=Xtest_gb.latin1.spl
711 call assert_equal("elekwint", FirstSpellWord())
712 call assert_equal("elekwent", SecondSpellWord())
713
714 set spl=Xtest_nz.latin1.spl
715 call assert_equal("elequint", FirstSpellWord())
716 call assert_equal("elekwent", SecondSpellWord())
717
718 set spl=Xtest_ca.latin1.spl
719 call assert_equal("elequint", FirstSpellWord())
720 call assert_equal("elekwint", SecondSpellWord())
721endfunc
722
Bram Moolenaar862f1e12019-04-10 22:33:41 +0200723func Test_spellfile_value()
724 set spellfile=Xdir/Xtest.latin1.add
725 set spellfile=Xdir/Xtest.utf-8.add,Xtest_other.add
726endfunc
727
Bram Moolenaaree03b942017-10-27 00:57:05 +0200728func Test_region_error()
729 messages clear
730 call writefile(["/regions=usgbnz", "elequint/0"], "Xtest.latin1.add")
731 mkspell! Xtest.latin1.add.spl Xtest.latin1.add
732 call assert_match('Invalid region nr in Xtest.latin1.add line 2: 0', execute('messages'))
733 call delete('Xtest.latin1.add')
734 call delete('Xtest.latin1.add.spl')
735endfunc
736
Bram Moolenaard2c061d2017-06-22 21:42:49 +0200737" Check using z= in new buffer (crash fixed by patch 7.4a.028).
738func Test_zeq_crash()
739 new
740 set maxmem=512 spell
741 call feedkeys('iasdz=:\"', 'tx')
742
743 bwipe!
744endfunc
745
Bram Moolenaar152e79e2020-06-10 15:32:08 +0200746" Check that z= works even when 'nospell' is set. This test uses one of the
747" tests in Test_spellsuggest_option_number() just to verify that z= basically
748" works and that "E756: Spell checking is not enabled" is not generated.
749func Test_zeq_nospell()
750 new
751 set nospell spellsuggest=1,best
752 call setline(1, 'A baord')
753 try
754 norm $1z=
755 call assert_equal('A board', getline(1))
756 catch
757 call assert_report("Caught exception: " . v:exception)
758 endtry
759 set spell& spellsuggest&
760 bwipe!
761endfunc
762
763" Check that "E756: Spell checking is not possible" is reported when z= is
764" executed and 'spelllang' is empty.
765func Test_zeq_no_spelllang()
766 new
767 set spelllang= spellsuggest=1,best
768 call setline(1, 'A baord')
769 call assert_fails('normal $1z=', 'E756:')
770 set spelllang& spellsuggest&
771 bwipe!
772endfunc
773
Bram Moolenaar5bcc5a12019-08-06 22:48:02 +0200774" Check handling a word longer than MAXWLEN.
775func Test_spell_long_word()
776 set enc=utf-8
777 new
778 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")
779 set spell spelllang=en
780 redraw
781 redraw!
782 bwipe!
783 set nospell
784endfunc
785
Bram Moolenaar06f15412022-01-29 10:51:59 +0000786func Test_spellsuggest_too_deep()
787 " This was incrementing "depth" over MAXWLEN.
788 new
789 norm s000G00ý000000000000
790 sil norm ..vzG................vvzG0 v z=
791 bwipe!
792endfunc
793
Bram Moolenaard2c061d2017-06-22 21:42:49 +0200794func LoadAffAndDic(aff_contents, dic_contents)
795 set enc=latin1
796 set spellfile=
797 call writefile(a:aff_contents, "Xtest.aff")
798 call writefile(a:dic_contents, "Xtest.dic")
799 " Generate a .spl file from a .dic and .aff file.
800 mkspell! Xtest Xtest
801 " use that spell file
802 set spl=Xtest.latin1.spl spell
803endfunc
804
805func ListWords()
806 spelldump
807 %yank
808 quit
809 return split(@", "\n")
810endfunc
811
812func TestGoodBadBase()
813 exe '1;/^good:'
814 normal 0f:]s
815 let prevbad = ''
816 let result = []
817 while 1
818 let [bad, a] = spellbadword()
819 if bad == '' || bad == prevbad || bad == 'badend'
820 break
821 endif
822 let prevbad = bad
Bram Moolenaarf6ed61e2019-09-07 19:05:09 +0200823 let lst = bad->spellsuggest(3)
Bram Moolenaard2c061d2017-06-22 21:42:49 +0200824 normal mm
825
826 call add(result, [bad, lst])
827 normal `m]s
828 endwhile
829 return result
830endfunc
831
832func RunGoodBad(good, bad, expected_words, expected_bad_words)
833 bwipe!
834 call setline(1, ["good: ", a:good, a:bad, " badend "])
835 let words = ListWords()
836 call assert_equal(a:expected_words, words[1:-1])
837 let bad_words = TestGoodBadBase()
838 call assert_equal(a:expected_bad_words, bad_words)
839 bwipe!
840endfunc
841
Bram Moolenaar7751d1d2019-10-18 20:37:08 +0200842func Test_spell_screendump()
843 CheckScreendump
844
845 let lines =<< trim END
846 call setline(1, [
847 \ "This is some text without any spell errors. Everything",
848 \ "should just be black, nothing wrong here.",
849 \ "",
850 \ "This line has a sepll error. and missing caps.",
851 \ "And and this is the the duplication.",
852 \ "with missing caps here.",
853 \ ])
854 set spell spelllang=en_nz
855 END
856 call writefile(lines, 'XtestSpell')
857 let buf = RunVimInTerminal('-S XtestSpell', {'rows': 8})
858 call VerifyScreenDump(buf, 'Test_spell_1', {})
859
860 " clean up
861 call StopVimInTerminal(buf)
862 call delete('XtestSpell')
863endfunc
864
Bram Moolenaar15d98902021-11-04 15:46:05 +0000865func Test_spell_single_word()
866 new
867 silent! norm 0R00
868 spell! ßÂ
869 silent 0norm 0r$ Dvz=
870 bwipe!
871endfunc
872
Bram Moolenaard2c061d2017-06-22 21:42:49 +0200873let g:test_data_aff1 = [
874 \"SET ISO8859-1",
875 \"TRY esianrtolcdugmphbyfvkwjkqxz-\xEB\xE9\xE8\xEA\xEF\xEE\xE4\xE0\xE2\xF6\xFC\xFB'ESIANRTOLCDUGMPHBYFVKWJKQXZ",
876 \"",
877 \"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",
878 \"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",
879 \"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",
880 \"",
881 \"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",
882 \"SOFOTO ebctefghejklnnepkrstevvkesebctefghejklnnepkrstevvkeseeeeeeeceeeeeeeedneeeeeeeeeeepseeeeeeeeceeeeeeeedneeeeeeeeeeep?",
883 \"",
884 \"MIDWORD\t'-",
885 \"",
886 \"KEP =",
887 \"RAR ?",
888 \"BAD !",
889 \"",
890 \"PFX I N 1",
891 \"PFX I 0 in .",
892 \"",
893 \"PFX O Y 1",
894 \"PFX O 0 out .",
895 \"",
896 \"SFX S Y 2",
897 \"SFX S 0 s [^s]",
898 \"SFX S 0 es s",
899 \"",
900 \"SFX N N 3",
901 \"SFX N 0 en [^n]",
902 \"SFX N 0 nen n",
903 \"SFX N 0 n .",
904 \"",
905 \"REP 3",
906 \"REP g ch",
907 \"REP ch g",
908 \"REP svp s.v.p.",
909 \"",
910 \"MAP 9",
911 \"MAP a\xE0\xE1\xE2\xE3\xE4\xE5",
912 \"MAP e\xE8\xE9\xEA\xEB",
913 \"MAP i\xEC\xED\xEE\xEF",
914 \"MAP o\xF2\xF3\xF4\xF5\xF6",
915 \"MAP u\xF9\xFA\xFB\xFC",
916 \"MAP n\xF1",
917 \"MAP c\xE7",
918 \"MAP y\xFF\xFD",
919 \"MAP s\xDF",
920 \ ]
921let g:test_data_dic1 = [
922 \"123456",
923 \"test/NO",
924 \"# comment",
925 \"wrong",
926 \"Comment",
927 \"OK",
928 \"uk",
929 \"put/ISO",
930 \"the end",
931 \"deol",
932 \"d\xE9\xF4r",
933 \ ]
934let g:test_data_aff2 = [
935 \"SET ISO8859-1",
936 \"",
937 \"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",
938 \"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",
939 \"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",
940 \"",
941 \"PFXPOSTPONE",
942 \"",
943 \"MIDWORD\t'-",
944 \"",
945 \"KEP =",
946 \"RAR ?",
947 \"BAD !",
948 \"",
949 \"PFX I N 1",
950 \"PFX I 0 in .",
951 \"",
952 \"PFX O Y 1",
953 \"PFX O 0 out [a-z]",
954 \"",
955 \"SFX S Y 2",
956 \"SFX S 0 s [^s]",
957 \"SFX S 0 es s",
958 \"",
959 \"SFX N N 3",
960 \"SFX N 0 en [^n]",
961 \"SFX N 0 nen n",
962 \"SFX N 0 n .",
963 \"",
964 \"REP 3",
965 \"REP g ch",
966 \"REP ch g",
967 \"REP svp s.v.p.",
968 \"",
969 \"MAP 9",
970 \"MAP a\xE0\xE1\xE2\xE3\xE4\xE5",
971 \"MAP e\xE8\xE9\xEA\xEB",
972 \"MAP i\xEC\xED\xEE\xEF",
973 \"MAP o\xF2\xF3\xF4\xF5\xF6",
974 \"MAP u\xF9\xFA\xFB\xFC",
975 \"MAP n\xF1",
976 \"MAP c\xE7",
977 \"MAP y\xFF\xFD",
978 \"MAP s\xDF",
979 \ ]
980let g:test_data_aff3 = [
981 \"SET ISO8859-1",
982 \"",
983 \"COMPOUNDMIN 3",
984 \"COMPOUNDRULE m*",
985 \"NEEDCOMPOUND x",
986 \ ]
987let g:test_data_dic3 = [
988 \"1234",
989 \"foo/m",
990 \"bar/mx",
991 \"m\xEF/m",
992 \"la/mx",
993 \ ]
994let g:test_data_aff4 = [
995 \"SET ISO8859-1",
996 \"",
997 \"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",
998 \"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",
999 \"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",
1000 \"",
1001 \"COMPOUNDRULE m+",
1002 \"COMPOUNDRULE sm*e",
1003 \"COMPOUNDRULE sm+",
1004 \"COMPOUNDMIN 3",
1005 \"COMPOUNDWORDMAX 3",
1006 \"COMPOUNDFORBIDFLAG t",
1007 \"",
1008 \"COMPOUNDSYLMAX 5",
1009 \"SYLLABLE a\xE1e\xE9i\xEDo\xF3\xF6\xF5u\xFA\xFC\xFBy/aa/au/ea/ee/ei/ie/oa/oe/oo/ou/uu/ui",
1010 \"",
1011 \"MAP 9",
1012 \"MAP a\xE0\xE1\xE2\xE3\xE4\xE5",
1013 \"MAP e\xE8\xE9\xEA\xEB",
1014 \"MAP i\xEC\xED\xEE\xEF",
1015 \"MAP o\xF2\xF3\xF4\xF5\xF6",
1016 \"MAP u\xF9\xFA\xFB\xFC",
1017 \"MAP n\xF1",
1018 \"MAP c\xE7",
1019 \"MAP y\xFF\xFD",
1020 \"MAP s\xDF",
1021 \"",
1022 \"NEEDAFFIX x",
1023 \"",
1024 \"PFXPOSTPONE",
1025 \"",
1026 \"MIDWORD '-",
1027 \"",
1028 \"SFX q N 1",
1029 \"SFX q 0 -ok .",
1030 \"",
1031 \"SFX a Y 2",
1032 \"SFX a 0 s .",
1033 \"SFX a 0 ize/t .",
1034 \"",
1035 \"PFX p N 1",
1036 \"PFX p 0 pre .",
1037 \"",
1038 \"PFX P N 1",
1039 \"PFX P 0 nou .",
1040 \ ]
1041let g:test_data_dic4 = [
1042 \"1234",
1043 \"word/mP",
1044 \"util/am",
1045 \"pro/xq",
1046 \"tomato/m",
1047 \"bork/mp",
1048 \"start/s",
1049 \"end/e",
1050 \ ]
1051let g:test_data_aff5 = [
1052 \"SET ISO8859-1",
1053 \"",
1054 \"FLAG long",
1055 \"",
1056 \"NEEDAFFIX !!",
1057 \"",
1058 \"COMPOUNDRULE ssmm*ee",
1059 \"",
1060 \"NEEDCOMPOUND xx",
1061 \"COMPOUNDPERMITFLAG pp",
1062 \"",
1063 \"SFX 13 Y 1",
1064 \"SFX 13 0 bork .",
1065 \"",
1066 \"SFX a1 Y 1",
1067 \"SFX a1 0 a1 .",
1068 \"",
1069 \"SFX a\xE9 Y 1",
1070 \"SFX a\xE9 0 a\xE9 .",
1071 \"",
1072 \"PFX zz Y 1",
1073 \"PFX zz 0 pre/pp .",
1074 \"",
1075 \"PFX yy Y 1",
1076 \"PFX yy 0 nou .",
1077 \ ]
1078let g:test_data_dic5 = [
1079 \"1234",
1080 \"foo/a1a\xE9!!",
1081 \"bar/zz13ee",
1082 \"start/ss",
1083 \"end/eeyy",
1084 \"middle/mmxx",
1085 \ ]
1086let g:test_data_aff6 = [
1087 \"SET ISO8859-1",
1088 \"",
1089 \"FLAG caplong",
1090 \"",
1091 \"NEEDAFFIX A!",
1092 \"",
1093 \"COMPOUNDRULE sMm*Ee",
1094 \"",
1095 \"NEEDCOMPOUND Xx",
1096 \"",
1097 \"COMPOUNDPERMITFLAG p",
1098 \"",
1099 \"SFX N3 Y 1",
1100 \"SFX N3 0 bork .",
1101 \"",
1102 \"SFX A1 Y 1",
1103 \"SFX A1 0 a1 .",
1104 \"",
1105 \"SFX A\xE9 Y 1",
1106 \"SFX A\xE9 0 a\xE9 .",
1107 \"",
1108 \"PFX Zz Y 1",
1109 \"PFX Zz 0 pre/p .",
1110 \ ]
1111let g:test_data_dic6 = [
1112 \"1234",
1113 \"mee/A1A\xE9A!",
1114 \"bar/ZzN3Ee",
1115 \"lead/s",
1116 \"end/Ee",
1117 \"middle/MmXx",
1118 \ ]
1119let g:test_data_aff7 = [
1120 \"SET ISO8859-1",
1121 \"",
1122 \"FLAG num",
1123 \"",
1124 \"NEEDAFFIX 9999",
1125 \"",
1126 \"COMPOUNDRULE 2,77*123",
1127 \"",
1128 \"NEEDCOMPOUND 1",
1129 \"COMPOUNDPERMITFLAG 432",
1130 \"",
1131 \"SFX 61003 Y 1",
1132 \"SFX 61003 0 meat .",
1133 \"",
Bram Moolenaar3d2a47c2019-11-07 20:48:42 +01001134 \"SFX 0 Y 1",
1135 \"SFX 0 0 zero .",
1136 \"",
Bram Moolenaard2c061d2017-06-22 21:42:49 +02001137 \"SFX 391 Y 1",
1138 \"SFX 391 0 a1 .",
1139 \"",
1140 \"SFX 111 Y 1",
1141 \"SFX 111 0 a\xE9 .",
1142 \"",
1143 \"PFX 17 Y 1",
1144 \"PFX 17 0 pre/432 .",
1145 \ ]
1146let g:test_data_dic7 = [
1147 \"1234",
Bram Moolenaar3d2a47c2019-11-07 20:48:42 +01001148 \"mee/0,391,111,9999",
Bram Moolenaard2c061d2017-06-22 21:42:49 +02001149 \"bar/17,61003,123",
1150 \"lead/2",
1151 \"tail/123",
1152 \"middle/77,1",
1153 \ ]
1154let g:test_data_aff8 = [
1155 \"SET ISO8859-1",
1156 \"",
1157 \"NOSPLITSUGS",
1158 \ ]
1159let g:test_data_dic8 = [
1160 \"1234",
1161 \"foo",
1162 \"bar",
1163 \"faabar",
1164 \ ]
1165let g:test_data_aff9 = [
1166 \ ]
1167let g:test_data_dic9 = [
1168 \"1234",
1169 \"foo",
1170 \"bar",
1171 \ ]
Bram Moolenaar37ff4cf2019-11-17 20:10:20 +01001172let g:test_data_aff10 = [
1173 \"COMPOUNDRULE se",
1174 \"COMPOUNDPERMITFLAG p",
1175 \"",
1176 \"SFX A Y 1",
1177 \"SFX A 0 able/Mp .",
1178 \"",
1179 \"SFX M Y 1",
1180 \"SFX M 0 s .",
1181 \ ]
1182let g:test_data_dic10 = [
1183 \"1234",
1184 \"drink/As",
1185 \"table/e",
1186 \ ]
Bram Moolenaard2c061d2017-06-22 21:42:49 +02001187let g:test_data_aff_sal = [
1188 \"SET ISO8859-1",
1189 \"TRY esianrtolcdugmphbyfvkwjkqxz-\xEB\xE9\xE8\xEA\xEF\xEE\xE4\xE0\xE2\xF6\xFC\xFB'ESIANRTOLCDUGMPHBYFVKWJKQXZ",
1190 \"",
1191 \"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",
1192 \"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",
1193 \"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",
1194 \"",
1195 \"MIDWORD\t'-",
1196 \"",
1197 \"KEP =",
1198 \"RAR ?",
1199 \"BAD !",
1200 \"",
1201 \"PFX I N 1",
1202 \"PFX I 0 in .",
1203 \"",
1204 \"PFX O Y 1",
1205 \"PFX O 0 out .",
1206 \"",
1207 \"SFX S Y 2",
1208 \"SFX S 0 s [^s]",
1209 \"SFX S 0 es s",
1210 \"",
1211 \"SFX N N 3",
1212 \"SFX N 0 en [^n]",
1213 \"SFX N 0 nen n",
1214 \"SFX N 0 n .",
1215 \"",
1216 \"REP 3",
1217 \"REP g ch",
1218 \"REP ch g",
1219 \"REP svp s.v.p.",
1220 \"",
1221 \"MAP 9",
1222 \"MAP a\xE0\xE1\xE2\xE3\xE4\xE5",
1223 \"MAP e\xE8\xE9\xEA\xEB",
1224 \"MAP i\xEC\xED\xEE\xEF",
1225 \"MAP o\xF2\xF3\xF4\xF5\xF6",
1226 \"MAP u\xF9\xFA\xFB\xFC",
1227 \"MAP n\xF1",
1228 \"MAP c\xE7",
1229 \"MAP y\xFF\xFD",
1230 \"MAP s\xDF",
1231 \"",
1232 \"SAL AH(AEIOUY)-^ *H",
1233 \"SAL AR(AEIOUY)-^ *R",
1234 \"SAL A(HR)^ *",
1235 \"SAL A^ *",
1236 \"SAL AH(AEIOUY)- H",
1237 \"SAL AR(AEIOUY)- R",
1238 \"SAL A(HR) _",
1239 \"SAL \xC0^ *",
1240 \"SAL \xC5^ *",
1241 \"SAL BB- _",
1242 \"SAL B B",
1243 \"SAL CQ- _",
1244 \"SAL CIA X",
1245 \"SAL CH X",
1246 \"SAL C(EIY)- S",
1247 \"SAL CK K",
1248 \"SAL COUGH^ KF",
1249 \"SAL CC< C",
1250 \"SAL C K",
1251 \"SAL DG(EIY) K",
1252 \"SAL DD- _",
1253 \"SAL D T",
1254 \"SAL \xC9< E",
1255 \"SAL EH(AEIOUY)-^ *H",
1256 \"SAL ER(AEIOUY)-^ *R",
1257 \"SAL E(HR)^ *",
1258 \"SAL ENOUGH^$ *NF",
1259 \"SAL E^ *",
1260 \"SAL EH(AEIOUY)- H",
1261 \"SAL ER(AEIOUY)- R",
1262 \"SAL E(HR) _",
1263 \"SAL FF- _",
1264 \"SAL F F",
1265 \"SAL GN^ N",
1266 \"SAL GN$ N",
1267 \"SAL GNS$ NS",
1268 \"SAL GNED$ N",
1269 \"SAL GH(AEIOUY)- K",
1270 \"SAL GH _",
1271 \"SAL GG9 K",
1272 \"SAL G K",
1273 \"SAL H H",
1274 \"SAL IH(AEIOUY)-^ *H",
1275 \"SAL IR(AEIOUY)-^ *R",
1276 \"SAL I(HR)^ *",
1277 \"SAL I^ *",
1278 \"SAL ING6 N",
1279 \"SAL IH(AEIOUY)- H",
1280 \"SAL IR(AEIOUY)- R",
1281 \"SAL I(HR) _",
1282 \"SAL J K",
1283 \"SAL KN^ N",
1284 \"SAL KK- _",
1285 \"SAL K K",
1286 \"SAL LAUGH^ LF",
1287 \"SAL LL- _",
1288 \"SAL L L",
1289 \"SAL MB$ M",
1290 \"SAL MM M",
1291 \"SAL M M",
1292 \"SAL NN- _",
1293 \"SAL N N",
1294 \"SAL OH(AEIOUY)-^ *H",
1295 \"SAL OR(AEIOUY)-^ *R",
1296 \"SAL O(HR)^ *",
1297 \"SAL O^ *",
1298 \"SAL OH(AEIOUY)- H",
1299 \"SAL OR(AEIOUY)- R",
1300 \"SAL O(HR) _",
1301 \"SAL PH F",
1302 \"SAL PN^ N",
1303 \"SAL PP- _",
1304 \"SAL P P",
1305 \"SAL Q K",
1306 \"SAL RH^ R",
1307 \"SAL ROUGH^ RF",
1308 \"SAL RR- _",
1309 \"SAL R R",
1310 \"SAL SCH(EOU)- SK",
1311 \"SAL SC(IEY)- S",
1312 \"SAL SH X",
1313 \"SAL SI(AO)- X",
1314 \"SAL SS- _",
1315 \"SAL S S",
1316 \"SAL TI(AO)- X",
1317 \"SAL TH @",
1318 \"SAL TCH-- _",
1319 \"SAL TOUGH^ TF",
1320 \"SAL TT- _",
1321 \"SAL T T",
1322 \"SAL UH(AEIOUY)-^ *H",
1323 \"SAL UR(AEIOUY)-^ *R",
1324 \"SAL U(HR)^ *",
1325 \"SAL U^ *",
1326 \"SAL UH(AEIOUY)- H",
1327 \"SAL UR(AEIOUY)- R",
1328 \"SAL U(HR) _",
1329 \"SAL V^ W",
1330 \"SAL V F",
1331 \"SAL WR^ R",
1332 \"SAL WH^ W",
1333 \"SAL W(AEIOU)- W",
1334 \"SAL X^ S",
1335 \"SAL X KS",
1336 \"SAL Y(AEIOU)- Y",
1337 \"SAL ZZ- _",
1338 \"SAL Z S",
1339 \ ]
Bram Moolenaar0e05de42020-03-25 22:23:46 +01001340
1341" vim: shiftwidth=2 sts=2 expandtab