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