blob: a3a9621cb0fff8a83a21a3282f9a25b629f295a9 [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
Bram Moolenaar0e05de42020-03-25 22:23:46 +0100270 call assert_fails("call spellsuggest('maxch', [])", 'E745:')
271 call assert_fails("call spellsuggest('maxch', 2, [])", 'E745:')
272
Bram Moolenaar152e79e2020-06-10 15:32:08 +0200273 set spelllang=
274 call assert_fails("call spellsuggest('maxch')", 'E756:')
275 set spelllang&
276
Bram Moolenaare9a8d1f2019-12-25 13:36:36 +0100277 set spell&
278endfunc
279
280" Test 'spellsuggest' option with methods fast, best and double.
281func Test_spellsuggest_option_methods()
282 set spell
283
Bram Moolenaar76734052019-12-26 14:30:15 +0100284 for e in ['latin1', 'utf-8']
285 exe 'set encoding=' .. e
Bram Moolenaare9a8d1f2019-12-25 13:36:36 +0100286
Bram Moolenaar76734052019-12-26 14:30:15 +0100287 set spellsuggest=fast
288 call assert_equal(['Stick', 'Stitch'], spellsuggest('Stich', 2), e)
Bram Moolenaare9a8d1f2019-12-25 13:36:36 +0100289
Bram Moolenaar76734052019-12-26 14:30:15 +0100290 " With best or double option, "Stitch" should become the top suggestion
291 " because of better phonetic matching.
292 set spellsuggest=best
293 call assert_equal(['Stitch', 'Stick'], spellsuggest('Stich', 2), e)
Bram Moolenaare9a8d1f2019-12-25 13:36:36 +0100294
Bram Moolenaar76734052019-12-26 14:30:15 +0100295 set spellsuggest=double
296 call assert_equal(['Stitch', 'Stick'], spellsuggest('Stich', 2), e)
297 endfor
298
299 set spell& spellsuggest& encoding&
Bram Moolenaare9a8d1f2019-12-25 13:36:36 +0100300endfunc
301
302" Test 'spellsuggest' option with value file:{filename}
303func Test_spellsuggest_option_file()
304 set spell spellsuggest=file:Xspellsuggest
305 call writefile(['emacs/vim',
306 \ 'theribal/terrible',
307 \ 'teribal/terrrible',
308 \ 'terribal'],
309 \ 'Xspellsuggest')
310
311 call assert_equal(['vim'], spellsuggest('emacs', 2))
312 call assert_equal(['terrible'], spellsuggest('theribal',2))
313
314 " If the suggestion is misspelled (*terrrible* with 3 r),
315 " it should not be proposed.
316 " The entry for "terribal" should be ignored because of missing slash.
317 call assert_equal([], spellsuggest('teribal', 2))
318 call assert_equal([], spellsuggest('terribal', 2))
319
320 set spell spellsuggest=best,file:Xspellsuggest
321 call assert_equal(['vim', 'Emacs'], spellsuggest('emacs', 2))
322 call assert_equal(['terrible', 'tribal'], spellsuggest('theribal', 2))
323 call assert_equal(['tribal'], spellsuggest('teribal', 1))
324 call assert_equal(['tribal'], spellsuggest('terribal', 1))
325
326 call delete('Xspellsuggest')
327 call assert_fails("call spellsuggest('vim')", "E484: Can't open file Xspellsuggest")
328
329 set spellsuggest& spell&
330endfunc
331
332" Test 'spellsuggest' option with value {number}
333" to limit the number of suggestions
334func Test_spellsuggest_option_number()
335 set spell spellsuggest=2,best
336 new
337
338 " We limited the number of suggestions to 2, so selecting
339 " the 1st and 2nd suggestion should correct the word, but
340 " selecting a 3rd suggestion should do nothing.
Bram Moolenaar76734052019-12-26 14:30:15 +0100341 call setline(1, 'A baord')
342 norm $1z=
343 call assert_equal('A board', getline(1))
Bram Moolenaare9a8d1f2019-12-25 13:36:36 +0100344
Bram Moolenaar76734052019-12-26 14:30:15 +0100345 call setline(1, 'A baord')
346 norm $2z=
347 call assert_equal('A bard', getline(1))
Bram Moolenaare9a8d1f2019-12-25 13:36:36 +0100348
Bram Moolenaar76734052019-12-26 14:30:15 +0100349 call setline(1, 'A baord')
350 norm $3z=
351 call assert_equal('A baord', getline(1))
Bram Moolenaare9a8d1f2019-12-25 13:36:36 +0100352
Bram Moolenaar76734052019-12-26 14:30:15 +0100353 let a = execute('norm $z=')
Bram Moolenaare9a8d1f2019-12-25 13:36:36 +0100354 call assert_equal(
355 \ "\n"
Bram Moolenaar76734052019-12-26 14:30:15 +0100356 \ .. "Change \"baord\" to:\n"
357 \ .. " 1 \"board\"\n"
358 \ .. " 2 \"bard\"\n"
Bram Moolenaard281b7c2020-06-10 16:39:32 +0200359 \ .. "Type number and <Enter> or click with the mouse (q or empty cancels): ", a)
Bram Moolenaare9a8d1f2019-12-25 13:36:36 +0100360
361 set spell spellsuggest=0
Bram Moolenaar76734052019-12-26 14:30:15 +0100362 call assert_equal("\nSorry, no suggestions", execute('norm $z='))
Bram Moolenaare9a8d1f2019-12-25 13:36:36 +0100363
364 " Unlike z=, function spellsuggest(...) should not be affected by the
365 " max number of suggestions (2) set by the 'spellsuggest' option.
Bram Moolenaar76734052019-12-26 14:30:15 +0100366 call assert_equal(['board', 'bard', 'broad'], spellsuggest('baord', 3))
Bram Moolenaare9a8d1f2019-12-25 13:36:36 +0100367
368 set spellsuggest& spell&
369 bwipe!
370endfunc
371
372" Test 'spellsuggest' option with value expr:{expr}
373func Test_spellsuggest_option_expr()
374 " A silly 'spellsuggest' function which makes suggestions all uppercase
375 " and makes the score of each suggestion the length of the suggested word.
376 " So shorter suggestions are preferred.
377 func MySuggest()
378 let spellsuggest_save = &spellsuggest
Bram Moolenaar76734052019-12-26 14:30:15 +0100379 set spellsuggest=3,best
Bram Moolenaare9a8d1f2019-12-25 13:36:36 +0100380 let result = map(spellsuggest(v:val, 3), "[toupper(v:val), len(v:val)]")
381 let &spellsuggest = spellsuggest_save
382 return result
383 endfunc
384
Bram Moolenaar76734052019-12-26 14:30:15 +0100385 set spell spellsuggest=expr:MySuggest()
386 call assert_equal(['BARD', 'BOARD', 'BROAD'], spellsuggest('baord', 3))
Bram Moolenaare9a8d1f2019-12-25 13:36:36 +0100387
388 new
Bram Moolenaar76734052019-12-26 14:30:15 +0100389 call setline(1, 'baord')
Bram Moolenaare9a8d1f2019-12-25 13:36:36 +0100390 let a = execute('norm z=')
391 call assert_equal(
392 \ "\n"
Bram Moolenaar76734052019-12-26 14:30:15 +0100393 \ .. "Change \"baord\" to:\n"
394 \ .. " 1 \"BARD\"\n"
395 \ .. " 2 \"BOARD\"\n"
396 \ .. " 3 \"BROAD\"\n"
Bram Moolenaard281b7c2020-06-10 16:39:32 +0200397 \ .. "Type number and <Enter> or click with the mouse (q or empty cancels): ", a)
Bram Moolenaare9a8d1f2019-12-25 13:36:36 +0100398
399 " With verbose, z= should show the score i.e. word length with
400 " our SpellSuggest() function.
401 set verbose=1
402 let a = execute('norm z=')
403 call assert_equal(
404 \ "\n"
Bram Moolenaar76734052019-12-26 14:30:15 +0100405 \ .. "Change \"baord\" to:\n"
406 \ .. " 1 \"BARD\" (4 - 0)\n"
407 \ .. " 2 \"BOARD\" (5 - 0)\n"
408 \ .. " 3 \"BROAD\" (5 - 0)\n"
Bram Moolenaard281b7c2020-06-10 16:39:32 +0200409 \ .. "Type number and <Enter> or click with the mouse (q or empty cancels): ", a)
Bram Moolenaare9a8d1f2019-12-25 13:36:36 +0100410
411 set spell& spellsuggest& verbose&
412 bwipe!
413endfunc
414
Bram Moolenaar8dfcce32020-03-18 19:32:26 +0100415" Test for 'spellsuggest' expr errrors
416func Test_spellsuggest_expr_errors()
417 " 'spellsuggest'
418 func MySuggest()
419 return range(3)
420 endfunc
421 set spell spellsuggest=expr:MySuggest()
422 call assert_equal([], spellsuggest('baord', 3))
423
424 " Test for 'spellsuggest' expression returning a non-list value
425 func! MySuggest2()
426 return 'good'
427 endfunc
428 set spellsuggest=expr:MySuggest2()
429 call assert_equal([], spellsuggest('baord'))
430
431 " Test for 'spellsuggest' expression returning a list with dict values
432 func! MySuggest3()
433 return [[{}, {}]]
434 endfunc
435 set spellsuggest=expr:MySuggest3()
Bram Moolenaar9b7bf9e2020-07-11 22:14:59 +0200436 call assert_fails("call spellsuggest('baord')", 'E731:')
Bram Moolenaar8dfcce32020-03-18 19:32:26 +0100437
438 set nospell spellsuggest&
439 delfunc MySuggest
440 delfunc MySuggest2
441 delfunc MySuggest3
442endfunc
443
Bram Moolenaar9049b682018-08-31 22:26:53 +0200444func Test_spellinfo()
445 new
Bram Moolenaarc25e7022019-10-10 14:08:26 +0200446 let runtime = substitute($VIMRUNTIME, '\\', '/', 'g')
Bram Moolenaar9049b682018-08-31 22:26:53 +0200447
448 set enc=latin1 spell spelllang=en
Bram Moolenaarc25e7022019-10-10 14:08:26 +0200449 call assert_match("^\nfile: " .. runtime .. "/spell/en.latin1.spl\n$", execute('spellinfo'))
Bram Moolenaar9049b682018-08-31 22:26:53 +0200450
451 set enc=cp1250 spell spelllang=en
Bram Moolenaarc25e7022019-10-10 14:08:26 +0200452 call assert_match("^\nfile: " .. runtime .. "/spell/en.ascii.spl\n$", execute('spellinfo'))
Bram Moolenaar9049b682018-08-31 22:26:53 +0200453
Bram Moolenaar30276f22019-01-24 17:59:39 +0100454 set enc=utf-8 spell spelllang=en
Bram Moolenaarc25e7022019-10-10 14:08:26 +0200455 call assert_match("^\nfile: " .. runtime .. "/spell/en.utf-8.spl\n$", execute('spellinfo'))
Bram Moolenaar9049b682018-08-31 22:26:53 +0200456
457 set enc=latin1 spell spelllang=en_us,en_nz
458 call assert_match("^\n" .
Bram Moolenaarc25e7022019-10-10 14:08:26 +0200459 \ "file: " .. runtime .. "/spell/en.latin1.spl\n" .
460 \ "file: " .. runtime.. "/spell/en.latin1.spl\n$", execute('spellinfo'))
Bram Moolenaar9049b682018-08-31 22:26:53 +0200461
462 set spell spelllang=
463 call assert_fails('spellinfo', 'E756:')
464
465 set nospell spelllang=en
466 call assert_fails('spellinfo', 'E756:')
467
Bram Moolenaar8f130ed2019-04-10 22:15:19 +0200468 call assert_fails('set spelllang=foo/bar', 'E474:')
469 call assert_fails('set spelllang=foo\ bar', 'E474:')
470 call assert_fails("set spelllang=foo\\\nbar", 'E474:')
471 call assert_fails("set spelllang=foo\\\rbar", 'E474:')
472 call assert_fails("set spelllang=foo+bar", 'E474:')
473
Bram Moolenaar9049b682018-08-31 22:26:53 +0200474 set enc& spell& spelllang&
475 bwipe
476endfunc
477
Bram Moolenaard2c061d2017-06-22 21:42:49 +0200478func Test_zz_basic()
479 call LoadAffAndDic(g:test_data_aff1, g:test_data_dic1)
480 call RunGoodBad("wrong OK puts. Test the end",
481 \ "bad: inputs comment ok Ok. test d\xE9\xF4l end the",
482 \["Comment", "deol", "d\xE9\xF4r", "input", "OK", "output", "outputs", "outtest", "put", "puts",
483 \ "test", "testen", "testn", "the end", "uk", "wrong"],
484 \[
485 \ ["bad", ["put", "uk", "OK"]],
486 \ ["inputs", ["input", "puts", "outputs"]],
487 \ ["comment", ["Comment", "outtest", "the end"]],
488 \ ["ok", ["OK", "uk", "put"]],
489 \ ["Ok", ["OK", "Uk", "Put"]],
490 \ ["test", ["Test", "testn", "testen"]],
491 \ ["d\xE9\xF4l", ["deol", "d\xE9\xF4r", "test"]],
492 \ ["end", ["put", "uk", "test"]],
493 \ ["the", ["put", "uk", "test"]],
494 \ ]
495 \ )
496
497 call assert_equal("gebletegek", soundfold('goobledygoook'))
Bram Moolenaarf6ed61e2019-09-07 19:05:09 +0200498 call assert_equal("kepereneven", 'kóopërÿnôven'->soundfold())
Bram Moolenaard2c061d2017-06-22 21:42:49 +0200499 call assert_equal("everles gesvets etele", soundfold('oeverloos gezwets edale'))
500endfunc
501
502" Postponed prefixes
503func Test_zz_prefixes()
504 call LoadAffAndDic(g:test_data_aff2, g:test_data_dic1)
505 call RunGoodBad("puts",
506 \ "bad: inputs comment ok Ok end the. test d\xE9\xF4l",
507 \ ["Comment", "deol", "d\xE9\xF4r", "OK", "put", "input", "output", "puts", "outputs", "test", "outtest", "testen", "testn", "the end", "uk", "wrong"],
508 \ [
509 \ ["bad", ["put", "uk", "OK"]],
510 \ ["inputs", ["input", "puts", "outputs"]],
511 \ ["comment", ["Comment"]],
512 \ ["ok", ["OK", "uk", "put"]],
513 \ ["Ok", ["OK", "Uk", "Put"]],
514 \ ["end", ["put", "uk", "deol"]],
515 \ ["the", ["put", "uk", "test"]],
516 \ ["test", ["Test", "testn", "testen"]],
517 \ ["d\xE9\xF4l", ["deol", "d\xE9\xF4r", "test"]],
518 \ ])
519endfunc
520
521"Compound words
522func Test_zz_compound()
523 call LoadAffAndDic(g:test_data_aff3, g:test_data_dic3)
524 call RunGoodBad("foo m\xEF foobar foofoobar barfoo barbarfoo",
525 \ "bad: bar la foom\xEF barm\xEF m\xEFfoo m\xEFbar m\xEFm\xEF lala m\xEFla lam\xEF foola labar",
526 \ ["foo", "m\xEF"],
527 \ [
528 \ ["bad", ["foo", "m\xEF"]],
529 \ ["bar", ["barfoo", "foobar", "foo"]],
530 \ ["la", ["m\xEF", "foo"]],
531 \ ["foom\xEF", ["foo m\xEF", "foo", "foofoo"]],
532 \ ["barm\xEF", ["barfoo", "m\xEF", "barbar"]],
533 \ ["m\xEFfoo", ["m\xEF foo", "foo", "foofoo"]],
534 \ ["m\xEFbar", ["foobar", "barbar", "m\xEF"]],
535 \ ["m\xEFm\xEF", ["m\xEF m\xEF", "m\xEF"]],
536 \ ["lala", []],
537 \ ["m\xEFla", ["m\xEF", "m\xEF m\xEF"]],
538 \ ["lam\xEF", ["m\xEF", "m\xEF m\xEF"]],
539 \ ["foola", ["foo", "foobar", "foofoo"]],
540 \ ["labar", ["barbar", "foobar"]],
541 \ ])
542
543 call LoadAffAndDic(g:test_data_aff4, g:test_data_dic4)
544 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",
545 \ "bad: wordutilize pro borkborkborkborkborkbork tomatotomatotomato endstart endend startstart wordend wordstart preborkprebork preborkpreborkbork startwordwordwordwordend borkpreborkpreborkbork utilsbork startnouword",
546 \ ["bork", "prebork", "end", "pro-ok", "start", "tomato", "util", "utilize", "utils", "word", "nouword"],
547 \ [
548 \ ["bad", ["end", "bork", "word"]],
549 \ ["wordutilize", ["word utilize", "wordutils", "wordutil"]],
550 \ ["pro", ["bork", "word", "end"]],
551 \ ["borkborkborkborkborkbork", ["bork borkborkborkborkbork", "borkbork borkborkborkbork", "borkborkbork borkborkbork"]],
552 \ ["tomatotomatotomato", ["tomato tomatotomato", "tomatotomato tomato", "tomato tomato tomato"]],
553 \ ["endstart", ["end start", "start"]],
554 \ ["endend", ["end end", "end"]],
555 \ ["startstart", ["start start"]],
556 \ ["wordend", ["word end", "word", "wordword"]],
557 \ ["wordstart", ["word start", "bork start"]],
558 \ ["preborkprebork", ["prebork prebork", "preborkbork", "preborkborkbork"]],
559 \ ["preborkpreborkbork", ["prebork preborkbork", "preborkborkbork", "preborkborkborkbork"]],
560 \ ["startwordwordwordwordend", ["startwordwordwordword end", "startwordwordwordword", "start wordwordwordword end"]],
561 \ ["borkpreborkpreborkbork", ["bork preborkpreborkbork", "bork prebork preborkbork", "bork preborkprebork bork"]],
562 \ ["utilsbork", ["utilbork", "utils bork", "util bork"]],
563 \ ["startnouword", ["start nouword", "startword", "startborkword"]],
564 \ ])
565
566endfunc
567
568"Test affix flags with two characters
569func Test_zz_affix()
570 call LoadAffAndDic(g:test_data_aff5, g:test_data_dic5)
571 call RunGoodBad("fooa1 fooa\xE9 bar prebar barbork prebarbork startprebar start end startend startmiddleend nouend",
572 \ "bad: foo fooa2 prabar probarbirk middle startmiddle middleend endstart startprobar startnouend",
573 \ ["bar", "barbork", "end", "fooa1", "fooa\xE9", "nouend", "prebar", "prebarbork", "start"],
574 \ [
575 \ ["bad", ["bar", "end", "fooa1"]],
576 \ ["foo", ["fooa1", "fooa\xE9", "bar"]],
577 \ ["fooa2", ["fooa1", "fooa\xE9", "bar"]],
578 \ ["prabar", ["prebar", "bar", "bar bar"]],
579 \ ["probarbirk", ["prebarbork"]],
580 \ ["middle", []],
581 \ ["startmiddle", ["startmiddleend", "startmiddlebar"]],
582 \ ["middleend", []],
583 \ ["endstart", ["end start", "start"]],
584 \ ["startprobar", ["startprebar", "start prebar", "startbar"]],
585 \ ["startnouend", ["start nouend", "startend"]],
586 \ ])
587
588 call LoadAffAndDic(g:test_data_aff6, g:test_data_dic6)
589 call RunGoodBad("meea1 meea\xE9 bar prebar barbork prebarbork leadprebar lead end leadend leadmiddleend",
590 \ "bad: mee meea2 prabar probarbirk middle leadmiddle middleend endlead leadprobar",
591 \ ["bar", "barbork", "end", "lead", "meea1", "meea\xE9", "prebar", "prebarbork"],
592 \ [
593 \ ["bad", ["bar", "end", "lead"]],
594 \ ["mee", ["meea1", "meea\xE9", "bar"]],
595 \ ["meea2", ["meea1", "meea\xE9", "lead"]],
596 \ ["prabar", ["prebar", "bar", "leadbar"]],
597 \ ["probarbirk", ["prebarbork"]],
598 \ ["middle", []],
599 \ ["leadmiddle", ["leadmiddleend", "leadmiddlebar"]],
600 \ ["middleend", []],
601 \ ["endlead", ["end lead", "lead", "end end"]],
602 \ ["leadprobar", ["leadprebar", "lead prebar", "leadbar"]],
603 \ ])
604
605 call LoadAffAndDic(g:test_data_aff7, g:test_data_dic7)
Bram Moolenaar3d2a47c2019-11-07 20:48:42 +0100606 call RunGoodBad("meea1 meezero meea\xE9 bar prebar barmeat prebarmeat leadprebar lead tail leadtail leadmiddletail",
Bram Moolenaard2c061d2017-06-22 21:42:49 +0200607 \ "bad: mee meea2 prabar probarmaat middle leadmiddle middletail taillead leadprobar",
Bram Moolenaar3d2a47c2019-11-07 20:48:42 +0100608 \ ["bar", "barmeat", "lead", "meea1", "meea\xE9", "meezero", "prebar", "prebarmeat", "tail"],
Bram Moolenaard2c061d2017-06-22 21:42:49 +0200609 \ [
610 \ ["bad", ["bar", "lead", "tail"]],
611 \ ["mee", ["meea1", "meea\xE9", "bar"]],
612 \ ["meea2", ["meea1", "meea\xE9", "lead"]],
613 \ ["prabar", ["prebar", "bar", "leadbar"]],
614 \ ["probarmaat", ["prebarmeat"]],
615 \ ["middle", []],
616 \ ["leadmiddle", ["leadmiddlebar"]],
617 \ ["middletail", []],
618 \ ["taillead", ["tail lead", "tail"]],
619 \ ["leadprobar", ["leadprebar", "lead prebar", "leadbar"]],
620 \ ])
621endfunc
622
623func Test_zz_NOSLITSUGS()
624 call LoadAffAndDic(g:test_data_aff8, g:test_data_dic8)
625 call RunGoodBad("foo bar faabar", "bad: foobar barfoo",
626 \ ["bar", "faabar", "foo"],
627 \ [
628 \ ["bad", ["bar", "foo"]],
629 \ ["foobar", ["faabar", "foo bar", "bar"]],
630 \ ["barfoo", ["bar foo", "bar", "foo"]],
631 \ ])
632endfunc
633
634" Numbers
635func Test_zz_Numbers()
636 call LoadAffAndDic(g:test_data_aff9, g:test_data_dic9)
637 call RunGoodBad("0b1011 0777 1234 0x01ff", "",
638 \ ["bar", "foo"],
639 \ [
640 \ ])
641endfunc
642
Bram Moolenaar37ff4cf2019-11-17 20:10:20 +0100643" Affix flags
644func Test_zz_affix_flags()
645 call LoadAffAndDic(g:test_data_aff10, g:test_data_dic10)
646 call RunGoodBad("drink drinkable drinkables drinktable drinkabletable",
647 \ "bad: drinks drinkstable drinkablestable",
648 \ ["drink", "drinkable", "drinkables", "table"],
649 \ [['bad', []],
650 \ ['drinks', ['drink']],
651 \ ['drinkstable', ['drinktable', 'drinkable', 'drink table']],
652 \ ['drinkablestable', ['drinkabletable', 'drinkables table', 'drinkable table']],
653 \ ])
654endfunc
655
Bram Moolenaard2c061d2017-06-22 21:42:49 +0200656function FirstSpellWord()
657 call feedkeys("/^start:\n", 'tx')
658 normal ]smm
659 let [str, a] = spellbadword()
660 return str
661endfunc
662
663function SecondSpellWord()
664 normal `m]s
665 let [str, a] = spellbadword()
666 return str
667endfunc
668
669"Test with SAL instead of SOFO items; test automatic reloading
670func Test_zz_sal_and_addition()
671 set enc=latin1
672 set spellfile=
Bram Moolenaar1a0f2002017-07-28 15:38:10 +0200673 call writefile(g:test_data_dic1, "Xtest.dic")
Bram Moolenaard2c061d2017-06-22 21:42:49 +0200674 call writefile(g:test_data_aff_sal, "Xtest.aff")
675 mkspell! Xtest Xtest
676 set spl=Xtest.latin1.spl spell
677 call assert_equal('kbltykk', soundfold('goobledygoook'))
678 call assert_equal('kprnfn', soundfold('kóopërÿnôven'))
679 call assert_equal('*fls kswts tl', soundfold('oeverloos gezwets edale'))
680
681 "also use an addition file
682 call writefile(["/regions=usgbnz", "elequint/2", "elekwint/3"], "Xtest.latin1.add")
683 mkspell! Xtest.latin1.add.spl Xtest.latin1.add
684
685 bwipe!
686 call setline(1, ["start: elequint test elekwint test elekwent asdf"])
687
688 set spellfile=Xtest.latin1.add
689 call assert_equal("elekwent", FirstSpellWord())
690
691 set spl=Xtest_us.latin1.spl
692 call assert_equal("elequint", FirstSpellWord())
693 call assert_equal("elekwint", SecondSpellWord())
694
695 set spl=Xtest_gb.latin1.spl
696 call assert_equal("elekwint", FirstSpellWord())
697 call assert_equal("elekwent", SecondSpellWord())
698
699 set spl=Xtest_nz.latin1.spl
700 call assert_equal("elequint", FirstSpellWord())
701 call assert_equal("elekwent", SecondSpellWord())
702
703 set spl=Xtest_ca.latin1.spl
704 call assert_equal("elequint", FirstSpellWord())
705 call assert_equal("elekwint", SecondSpellWord())
706endfunc
707
Bram Moolenaar862f1e12019-04-10 22:33:41 +0200708func Test_spellfile_value()
709 set spellfile=Xdir/Xtest.latin1.add
710 set spellfile=Xdir/Xtest.utf-8.add,Xtest_other.add
711endfunc
712
Bram Moolenaaree03b942017-10-27 00:57:05 +0200713func Test_region_error()
714 messages clear
715 call writefile(["/regions=usgbnz", "elequint/0"], "Xtest.latin1.add")
716 mkspell! Xtest.latin1.add.spl Xtest.latin1.add
717 call assert_match('Invalid region nr in Xtest.latin1.add line 2: 0', execute('messages'))
718 call delete('Xtest.latin1.add')
719 call delete('Xtest.latin1.add.spl')
720endfunc
721
Bram Moolenaard2c061d2017-06-22 21:42:49 +0200722" Check using z= in new buffer (crash fixed by patch 7.4a.028).
723func Test_zeq_crash()
724 new
725 set maxmem=512 spell
726 call feedkeys('iasdz=:\"', 'tx')
727
728 bwipe!
729endfunc
730
Bram Moolenaar152e79e2020-06-10 15:32:08 +0200731" Check that z= works even when 'nospell' is set. This test uses one of the
732" tests in Test_spellsuggest_option_number() just to verify that z= basically
733" works and that "E756: Spell checking is not enabled" is not generated.
734func Test_zeq_nospell()
735 new
736 set nospell spellsuggest=1,best
737 call setline(1, 'A baord')
738 try
739 norm $1z=
740 call assert_equal('A board', getline(1))
741 catch
742 call assert_report("Caught exception: " . v:exception)
743 endtry
744 set spell& spellsuggest&
745 bwipe!
746endfunc
747
748" Check that "E756: Spell checking is not possible" is reported when z= is
749" executed and 'spelllang' is empty.
750func Test_zeq_no_spelllang()
751 new
752 set spelllang= spellsuggest=1,best
753 call setline(1, 'A baord')
754 call assert_fails('normal $1z=', 'E756:')
755 set spelllang& spellsuggest&
756 bwipe!
757endfunc
758
Bram Moolenaar5bcc5a12019-08-06 22:48:02 +0200759" Check handling a word longer than MAXWLEN.
760func Test_spell_long_word()
761 set enc=utf-8
762 new
763 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")
764 set spell spelllang=en
765 redraw
766 redraw!
767 bwipe!
768 set nospell
769endfunc
770
Bram Moolenaard2c061d2017-06-22 21:42:49 +0200771func LoadAffAndDic(aff_contents, dic_contents)
772 set enc=latin1
773 set spellfile=
774 call writefile(a:aff_contents, "Xtest.aff")
775 call writefile(a:dic_contents, "Xtest.dic")
776 " Generate a .spl file from a .dic and .aff file.
777 mkspell! Xtest Xtest
778 " use that spell file
779 set spl=Xtest.latin1.spl spell
780endfunc
781
782func ListWords()
783 spelldump
784 %yank
785 quit
786 return split(@", "\n")
787endfunc
788
789func TestGoodBadBase()
790 exe '1;/^good:'
791 normal 0f:]s
792 let prevbad = ''
793 let result = []
794 while 1
795 let [bad, a] = spellbadword()
796 if bad == '' || bad == prevbad || bad == 'badend'
797 break
798 endif
799 let prevbad = bad
Bram Moolenaarf6ed61e2019-09-07 19:05:09 +0200800 let lst = bad->spellsuggest(3)
Bram Moolenaard2c061d2017-06-22 21:42:49 +0200801 normal mm
802
803 call add(result, [bad, lst])
804 normal `m]s
805 endwhile
806 return result
807endfunc
808
809func RunGoodBad(good, bad, expected_words, expected_bad_words)
810 bwipe!
811 call setline(1, ["good: ", a:good, a:bad, " badend "])
812 let words = ListWords()
813 call assert_equal(a:expected_words, words[1:-1])
814 let bad_words = TestGoodBadBase()
815 call assert_equal(a:expected_bad_words, bad_words)
816 bwipe!
817endfunc
818
Bram Moolenaar7751d1d2019-10-18 20:37:08 +0200819func Test_spell_screendump()
820 CheckScreendump
821
822 let lines =<< trim END
823 call setline(1, [
824 \ "This is some text without any spell errors. Everything",
825 \ "should just be black, nothing wrong here.",
826 \ "",
827 \ "This line has a sepll error. and missing caps.",
828 \ "And and this is the the duplication.",
829 \ "with missing caps here.",
830 \ ])
831 set spell spelllang=en_nz
832 END
833 call writefile(lines, 'XtestSpell')
834 let buf = RunVimInTerminal('-S XtestSpell', {'rows': 8})
835 call VerifyScreenDump(buf, 'Test_spell_1', {})
836
837 " clean up
838 call StopVimInTerminal(buf)
839 call delete('XtestSpell')
840endfunc
841
Bram Moolenaard2c061d2017-06-22 21:42:49 +0200842let g:test_data_aff1 = [
843 \"SET ISO8859-1",
844 \"TRY esianrtolcdugmphbyfvkwjkqxz-\xEB\xE9\xE8\xEA\xEF\xEE\xE4\xE0\xE2\xF6\xFC\xFB'ESIANRTOLCDUGMPHBYFVKWJKQXZ",
845 \"",
846 \"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",
847 \"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",
848 \"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",
849 \"",
850 \"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",
851 \"SOFOTO ebctefghejklnnepkrstevvkesebctefghejklnnepkrstevvkeseeeeeeeceeeeeeeedneeeeeeeeeeepseeeeeeeeceeeeeeeedneeeeeeeeeeep?",
852 \"",
853 \"MIDWORD\t'-",
854 \"",
855 \"KEP =",
856 \"RAR ?",
857 \"BAD !",
858 \"",
859 \"PFX I N 1",
860 \"PFX I 0 in .",
861 \"",
862 \"PFX O Y 1",
863 \"PFX O 0 out .",
864 \"",
865 \"SFX S Y 2",
866 \"SFX S 0 s [^s]",
867 \"SFX S 0 es s",
868 \"",
869 \"SFX N N 3",
870 \"SFX N 0 en [^n]",
871 \"SFX N 0 nen n",
872 \"SFX N 0 n .",
873 \"",
874 \"REP 3",
875 \"REP g ch",
876 \"REP ch g",
877 \"REP svp s.v.p.",
878 \"",
879 \"MAP 9",
880 \"MAP a\xE0\xE1\xE2\xE3\xE4\xE5",
881 \"MAP e\xE8\xE9\xEA\xEB",
882 \"MAP i\xEC\xED\xEE\xEF",
883 \"MAP o\xF2\xF3\xF4\xF5\xF6",
884 \"MAP u\xF9\xFA\xFB\xFC",
885 \"MAP n\xF1",
886 \"MAP c\xE7",
887 \"MAP y\xFF\xFD",
888 \"MAP s\xDF",
889 \ ]
890let g:test_data_dic1 = [
891 \"123456",
892 \"test/NO",
893 \"# comment",
894 \"wrong",
895 \"Comment",
896 \"OK",
897 \"uk",
898 \"put/ISO",
899 \"the end",
900 \"deol",
901 \"d\xE9\xF4r",
902 \ ]
903let g:test_data_aff2 = [
904 \"SET ISO8859-1",
905 \"",
906 \"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",
907 \"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",
908 \"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",
909 \"",
910 \"PFXPOSTPONE",
911 \"",
912 \"MIDWORD\t'-",
913 \"",
914 \"KEP =",
915 \"RAR ?",
916 \"BAD !",
917 \"",
918 \"PFX I N 1",
919 \"PFX I 0 in .",
920 \"",
921 \"PFX O Y 1",
922 \"PFX O 0 out [a-z]",
923 \"",
924 \"SFX S Y 2",
925 \"SFX S 0 s [^s]",
926 \"SFX S 0 es s",
927 \"",
928 \"SFX N N 3",
929 \"SFX N 0 en [^n]",
930 \"SFX N 0 nen n",
931 \"SFX N 0 n .",
932 \"",
933 \"REP 3",
934 \"REP g ch",
935 \"REP ch g",
936 \"REP svp s.v.p.",
937 \"",
938 \"MAP 9",
939 \"MAP a\xE0\xE1\xE2\xE3\xE4\xE5",
940 \"MAP e\xE8\xE9\xEA\xEB",
941 \"MAP i\xEC\xED\xEE\xEF",
942 \"MAP o\xF2\xF3\xF4\xF5\xF6",
943 \"MAP u\xF9\xFA\xFB\xFC",
944 \"MAP n\xF1",
945 \"MAP c\xE7",
946 \"MAP y\xFF\xFD",
947 \"MAP s\xDF",
948 \ ]
949let g:test_data_aff3 = [
950 \"SET ISO8859-1",
951 \"",
952 \"COMPOUNDMIN 3",
953 \"COMPOUNDRULE m*",
954 \"NEEDCOMPOUND x",
955 \ ]
956let g:test_data_dic3 = [
957 \"1234",
958 \"foo/m",
959 \"bar/mx",
960 \"m\xEF/m",
961 \"la/mx",
962 \ ]
963let g:test_data_aff4 = [
964 \"SET ISO8859-1",
965 \"",
966 \"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",
967 \"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",
968 \"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",
969 \"",
970 \"COMPOUNDRULE m+",
971 \"COMPOUNDRULE sm*e",
972 \"COMPOUNDRULE sm+",
973 \"COMPOUNDMIN 3",
974 \"COMPOUNDWORDMAX 3",
975 \"COMPOUNDFORBIDFLAG t",
976 \"",
977 \"COMPOUNDSYLMAX 5",
978 \"SYLLABLE a\xE1e\xE9i\xEDo\xF3\xF6\xF5u\xFA\xFC\xFBy/aa/au/ea/ee/ei/ie/oa/oe/oo/ou/uu/ui",
979 \"",
980 \"MAP 9",
981 \"MAP a\xE0\xE1\xE2\xE3\xE4\xE5",
982 \"MAP e\xE8\xE9\xEA\xEB",
983 \"MAP i\xEC\xED\xEE\xEF",
984 \"MAP o\xF2\xF3\xF4\xF5\xF6",
985 \"MAP u\xF9\xFA\xFB\xFC",
986 \"MAP n\xF1",
987 \"MAP c\xE7",
988 \"MAP y\xFF\xFD",
989 \"MAP s\xDF",
990 \"",
991 \"NEEDAFFIX x",
992 \"",
993 \"PFXPOSTPONE",
994 \"",
995 \"MIDWORD '-",
996 \"",
997 \"SFX q N 1",
998 \"SFX q 0 -ok .",
999 \"",
1000 \"SFX a Y 2",
1001 \"SFX a 0 s .",
1002 \"SFX a 0 ize/t .",
1003 \"",
1004 \"PFX p N 1",
1005 \"PFX p 0 pre .",
1006 \"",
1007 \"PFX P N 1",
1008 \"PFX P 0 nou .",
1009 \ ]
1010let g:test_data_dic4 = [
1011 \"1234",
1012 \"word/mP",
1013 \"util/am",
1014 \"pro/xq",
1015 \"tomato/m",
1016 \"bork/mp",
1017 \"start/s",
1018 \"end/e",
1019 \ ]
1020let g:test_data_aff5 = [
1021 \"SET ISO8859-1",
1022 \"",
1023 \"FLAG long",
1024 \"",
1025 \"NEEDAFFIX !!",
1026 \"",
1027 \"COMPOUNDRULE ssmm*ee",
1028 \"",
1029 \"NEEDCOMPOUND xx",
1030 \"COMPOUNDPERMITFLAG pp",
1031 \"",
1032 \"SFX 13 Y 1",
1033 \"SFX 13 0 bork .",
1034 \"",
1035 \"SFX a1 Y 1",
1036 \"SFX a1 0 a1 .",
1037 \"",
1038 \"SFX a\xE9 Y 1",
1039 \"SFX a\xE9 0 a\xE9 .",
1040 \"",
1041 \"PFX zz Y 1",
1042 \"PFX zz 0 pre/pp .",
1043 \"",
1044 \"PFX yy Y 1",
1045 \"PFX yy 0 nou .",
1046 \ ]
1047let g:test_data_dic5 = [
1048 \"1234",
1049 \"foo/a1a\xE9!!",
1050 \"bar/zz13ee",
1051 \"start/ss",
1052 \"end/eeyy",
1053 \"middle/mmxx",
1054 \ ]
1055let g:test_data_aff6 = [
1056 \"SET ISO8859-1",
1057 \"",
1058 \"FLAG caplong",
1059 \"",
1060 \"NEEDAFFIX A!",
1061 \"",
1062 \"COMPOUNDRULE sMm*Ee",
1063 \"",
1064 \"NEEDCOMPOUND Xx",
1065 \"",
1066 \"COMPOUNDPERMITFLAG p",
1067 \"",
1068 \"SFX N3 Y 1",
1069 \"SFX N3 0 bork .",
1070 \"",
1071 \"SFX A1 Y 1",
1072 \"SFX A1 0 a1 .",
1073 \"",
1074 \"SFX A\xE9 Y 1",
1075 \"SFX A\xE9 0 a\xE9 .",
1076 \"",
1077 \"PFX Zz Y 1",
1078 \"PFX Zz 0 pre/p .",
1079 \ ]
1080let g:test_data_dic6 = [
1081 \"1234",
1082 \"mee/A1A\xE9A!",
1083 \"bar/ZzN3Ee",
1084 \"lead/s",
1085 \"end/Ee",
1086 \"middle/MmXx",
1087 \ ]
1088let g:test_data_aff7 = [
1089 \"SET ISO8859-1",
1090 \"",
1091 \"FLAG num",
1092 \"",
1093 \"NEEDAFFIX 9999",
1094 \"",
1095 \"COMPOUNDRULE 2,77*123",
1096 \"",
1097 \"NEEDCOMPOUND 1",
1098 \"COMPOUNDPERMITFLAG 432",
1099 \"",
1100 \"SFX 61003 Y 1",
1101 \"SFX 61003 0 meat .",
1102 \"",
Bram Moolenaar3d2a47c2019-11-07 20:48:42 +01001103 \"SFX 0 Y 1",
1104 \"SFX 0 0 zero .",
1105 \"",
Bram Moolenaard2c061d2017-06-22 21:42:49 +02001106 \"SFX 391 Y 1",
1107 \"SFX 391 0 a1 .",
1108 \"",
1109 \"SFX 111 Y 1",
1110 \"SFX 111 0 a\xE9 .",
1111 \"",
1112 \"PFX 17 Y 1",
1113 \"PFX 17 0 pre/432 .",
1114 \ ]
1115let g:test_data_dic7 = [
1116 \"1234",
Bram Moolenaar3d2a47c2019-11-07 20:48:42 +01001117 \"mee/0,391,111,9999",
Bram Moolenaard2c061d2017-06-22 21:42:49 +02001118 \"bar/17,61003,123",
1119 \"lead/2",
1120 \"tail/123",
1121 \"middle/77,1",
1122 \ ]
1123let g:test_data_aff8 = [
1124 \"SET ISO8859-1",
1125 \"",
1126 \"NOSPLITSUGS",
1127 \ ]
1128let g:test_data_dic8 = [
1129 \"1234",
1130 \"foo",
1131 \"bar",
1132 \"faabar",
1133 \ ]
1134let g:test_data_aff9 = [
1135 \ ]
1136let g:test_data_dic9 = [
1137 \"1234",
1138 \"foo",
1139 \"bar",
1140 \ ]
Bram Moolenaar37ff4cf2019-11-17 20:10:20 +01001141let g:test_data_aff10 = [
1142 \"COMPOUNDRULE se",
1143 \"COMPOUNDPERMITFLAG p",
1144 \"",
1145 \"SFX A Y 1",
1146 \"SFX A 0 able/Mp .",
1147 \"",
1148 \"SFX M Y 1",
1149 \"SFX M 0 s .",
1150 \ ]
1151let g:test_data_dic10 = [
1152 \"1234",
1153 \"drink/As",
1154 \"table/e",
1155 \ ]
Bram Moolenaard2c061d2017-06-22 21:42:49 +02001156let g:test_data_aff_sal = [
1157 \"SET ISO8859-1",
1158 \"TRY esianrtolcdugmphbyfvkwjkqxz-\xEB\xE9\xE8\xEA\xEF\xEE\xE4\xE0\xE2\xF6\xFC\xFB'ESIANRTOLCDUGMPHBYFVKWJKQXZ",
1159 \"",
1160 \"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",
1161 \"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",
1162 \"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",
1163 \"",
1164 \"MIDWORD\t'-",
1165 \"",
1166 \"KEP =",
1167 \"RAR ?",
1168 \"BAD !",
1169 \"",
1170 \"PFX I N 1",
1171 \"PFX I 0 in .",
1172 \"",
1173 \"PFX O Y 1",
1174 \"PFX O 0 out .",
1175 \"",
1176 \"SFX S Y 2",
1177 \"SFX S 0 s [^s]",
1178 \"SFX S 0 es s",
1179 \"",
1180 \"SFX N N 3",
1181 \"SFX N 0 en [^n]",
1182 \"SFX N 0 nen n",
1183 \"SFX N 0 n .",
1184 \"",
1185 \"REP 3",
1186 \"REP g ch",
1187 \"REP ch g",
1188 \"REP svp s.v.p.",
1189 \"",
1190 \"MAP 9",
1191 \"MAP a\xE0\xE1\xE2\xE3\xE4\xE5",
1192 \"MAP e\xE8\xE9\xEA\xEB",
1193 \"MAP i\xEC\xED\xEE\xEF",
1194 \"MAP o\xF2\xF3\xF4\xF5\xF6",
1195 \"MAP u\xF9\xFA\xFB\xFC",
1196 \"MAP n\xF1",
1197 \"MAP c\xE7",
1198 \"MAP y\xFF\xFD",
1199 \"MAP s\xDF",
1200 \"",
1201 \"SAL AH(AEIOUY)-^ *H",
1202 \"SAL AR(AEIOUY)-^ *R",
1203 \"SAL A(HR)^ *",
1204 \"SAL A^ *",
1205 \"SAL AH(AEIOUY)- H",
1206 \"SAL AR(AEIOUY)- R",
1207 \"SAL A(HR) _",
1208 \"SAL \xC0^ *",
1209 \"SAL \xC5^ *",
1210 \"SAL BB- _",
1211 \"SAL B B",
1212 \"SAL CQ- _",
1213 \"SAL CIA X",
1214 \"SAL CH X",
1215 \"SAL C(EIY)- S",
1216 \"SAL CK K",
1217 \"SAL COUGH^ KF",
1218 \"SAL CC< C",
1219 \"SAL C K",
1220 \"SAL DG(EIY) K",
1221 \"SAL DD- _",
1222 \"SAL D T",
1223 \"SAL \xC9< E",
1224 \"SAL EH(AEIOUY)-^ *H",
1225 \"SAL ER(AEIOUY)-^ *R",
1226 \"SAL E(HR)^ *",
1227 \"SAL ENOUGH^$ *NF",
1228 \"SAL E^ *",
1229 \"SAL EH(AEIOUY)- H",
1230 \"SAL ER(AEIOUY)- R",
1231 \"SAL E(HR) _",
1232 \"SAL FF- _",
1233 \"SAL F F",
1234 \"SAL GN^ N",
1235 \"SAL GN$ N",
1236 \"SAL GNS$ NS",
1237 \"SAL GNED$ N",
1238 \"SAL GH(AEIOUY)- K",
1239 \"SAL GH _",
1240 \"SAL GG9 K",
1241 \"SAL G K",
1242 \"SAL H H",
1243 \"SAL IH(AEIOUY)-^ *H",
1244 \"SAL IR(AEIOUY)-^ *R",
1245 \"SAL I(HR)^ *",
1246 \"SAL I^ *",
1247 \"SAL ING6 N",
1248 \"SAL IH(AEIOUY)- H",
1249 \"SAL IR(AEIOUY)- R",
1250 \"SAL I(HR) _",
1251 \"SAL J K",
1252 \"SAL KN^ N",
1253 \"SAL KK- _",
1254 \"SAL K K",
1255 \"SAL LAUGH^ LF",
1256 \"SAL LL- _",
1257 \"SAL L L",
1258 \"SAL MB$ M",
1259 \"SAL MM M",
1260 \"SAL M M",
1261 \"SAL NN- _",
1262 \"SAL N N",
1263 \"SAL OH(AEIOUY)-^ *H",
1264 \"SAL OR(AEIOUY)-^ *R",
1265 \"SAL O(HR)^ *",
1266 \"SAL O^ *",
1267 \"SAL OH(AEIOUY)- H",
1268 \"SAL OR(AEIOUY)- R",
1269 \"SAL O(HR) _",
1270 \"SAL PH F",
1271 \"SAL PN^ N",
1272 \"SAL PP- _",
1273 \"SAL P P",
1274 \"SAL Q K",
1275 \"SAL RH^ R",
1276 \"SAL ROUGH^ RF",
1277 \"SAL RR- _",
1278 \"SAL R R",
1279 \"SAL SCH(EOU)- SK",
1280 \"SAL SC(IEY)- S",
1281 \"SAL SH X",
1282 \"SAL SI(AO)- X",
1283 \"SAL SS- _",
1284 \"SAL S S",
1285 \"SAL TI(AO)- X",
1286 \"SAL TH @",
1287 \"SAL TCH-- _",
1288 \"SAL TOUGH^ TF",
1289 \"SAL TT- _",
1290 \"SAL T T",
1291 \"SAL UH(AEIOUY)-^ *H",
1292 \"SAL UR(AEIOUY)-^ *R",
1293 \"SAL U(HR)^ *",
1294 \"SAL U^ *",
1295 \"SAL UH(AEIOUY)- H",
1296 \"SAL UR(AEIOUY)- R",
1297 \"SAL U(HR) _",
1298 \"SAL V^ W",
1299 \"SAL V F",
1300 \"SAL WR^ R",
1301 \"SAL WH^ W",
1302 \"SAL W(AEIOU)- W",
1303 \"SAL X^ S",
1304 \"SAL X KS",
1305 \"SAL Y(AEIOU)- Y",
1306 \"SAL ZZ- _",
1307 \"SAL Z S",
1308 \ ]
Bram Moolenaar0e05de42020-03-25 22:23:46 +01001309
1310" vim: shiftwidth=2 sts=2 expandtab