blob: dd68e0c0908c4987e4553fadb33339ee6d8b9f4b [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 Moolenaar8c7ad362020-09-27 13:58:38 +0200146func Test_spelllang_inv_region()
147 set spell spelllang=en_xx
148 let messages = GetMessages()
149 call assert_equal('Warning: region xx not supported', messages[-1])
150 set spell& spelllang&
151endfunc
152
153func Test_compl_with_CTRL_X_CTRL_K_using_spell()
154 " When spell checking is enabled and 'dictionary' is empty,
155 " CTRL-X CTRL-K in insert mode completes using the spelling dictionary.
156 new
157 set spell spelllang=en dictionary=
158
159 set ignorecase
160 call feedkeys("Senglis\<c-x>\<c-k>\<esc>", 'tnx')
161 call assert_equal(['English'], getline(1, '$'))
162 call feedkeys("SEnglis\<c-x>\<c-k>\<esc>", 'tnx')
163 call assert_equal(['English'], getline(1, '$'))
164
165 set noignorecase
166 call feedkeys("Senglis\<c-x>\<c-k>\<esc>", 'tnx')
167 call assert_equal(['englis'], getline(1, '$'))
168 call feedkeys("SEnglis\<c-x>\<c-k>\<esc>", 'tnx')
169 call assert_equal(['English'], getline(1, '$'))
170
171 set spelllang=en_us
172 call feedkeys("Stheat\<c-x>\<c-k>\<esc>", 'tnx')
173 call assert_equal(['theater'], getline(1, '$'))
174 set spelllang=en_gb
175 call feedkeys("Stheat\<c-x>\<c-k>\<esc>", 'tnx')
176 " FIXME: commented out, expected theatre bug got theater. See issue #7025.
177 " call assert_equal(['theatre'], getline(1, '$'))
178
179 bwipe!
180 set spell& spelllang& dictionary& ignorecase&
181endfunc
182
Bram Moolenaar545cb792017-05-23 11:31:22 +0200183func Test_spellreall()
184 new
185 set spell
186 call assert_fails('spellrepall', 'E752:')
187 call setline(1, ['A speling mistake. The same speling mistake.',
Bram Moolenaard2c061d2017-06-22 21:42:49 +0200188 \ 'Another speling mistake.'])
Bram Moolenaar545cb792017-05-23 11:31:22 +0200189 call feedkeys(']s1z=', 'tx')
190 call assert_equal('A spelling mistake. The same speling mistake.', getline(1))
191 call assert_equal('Another speling mistake.', getline(2))
192 spellrepall
193 call assert_equal('A spelling mistake. The same spelling mistake.', getline(1))
194 call assert_equal('Another spelling mistake.', getline(2))
195 call assert_fails('spellrepall', 'E753:')
196 set spell&
197 bwipe!
198endfunc
Bram Moolenaard2c061d2017-06-22 21:42:49 +0200199
Bram Moolenaare9a8d1f2019-12-25 13:36:36 +0100200" Test spellsuggest({word} [, {max} [, {capital}]])
201func Test_spellsuggest()
Bram Moolenaar152e79e2020-06-10 15:32:08 +0200202 " Verify suggestions are given even when spell checking is not enabled.
Bram Moolenaare9a8d1f2019-12-25 13:36:36 +0100203 set nospell
Bram Moolenaar152e79e2020-06-10 15:32:08 +0200204 call assert_equal(['march', 'March'], spellsuggest('marrch', 2))
Bram Moolenaare9a8d1f2019-12-25 13:36:36 +0100205
206 set spell
207
208 " With 1 argument.
Bram Moolenaar76734052019-12-26 14:30:15 +0100209 call assert_equal(['march', 'March'], spellsuggest('marrch')[0:1])
Bram Moolenaare9a8d1f2019-12-25 13:36:36 +0100210
211 " With 2 arguments.
Bram Moolenaar76734052019-12-26 14:30:15 +0100212 call assert_equal(['march', 'March'], spellsuggest('marrch', 2))
Bram Moolenaare9a8d1f2019-12-25 13:36:36 +0100213
214 " With 3 arguments.
Bram Moolenaar76734052019-12-26 14:30:15 +0100215 call assert_equal(['march'], spellsuggest('marrch', 1, 0))
216 call assert_equal(['March'], spellsuggest('marrch', 1, 1))
Bram Moolenaare9a8d1f2019-12-25 13:36:36 +0100217
218 " Test with digits and hyphen.
219 call assert_equal('Carbon-14', spellsuggest('Carbon-15')[0])
220
221 " Comment taken from spellsuggest.c explains the following test cases:
222 "
223 " If there are more UPPER than lower case letters suggest an
224 " ALLCAP word. Otherwise, if the first letter is UPPER then
225 " suggest ONECAP. Exception: "ALl" most likely should be "All",
226 " require three upper case letters.
Bram Moolenaar76734052019-12-26 14:30:15 +0100227 call assert_equal(['THIRD', 'third'], spellsuggest('thIRD', 2))
228 call assert_equal(['third', 'THIRD'], spellsuggest('tHIrd', 2))
229 call assert_equal(['Third'], spellsuggest('THird', 1))
Bram Moolenaare9a8d1f2019-12-25 13:36:36 +0100230 call assert_equal(['All'], spellsuggest('ALl', 1))
231
Bram Moolenaar0e05de42020-03-25 22:23:46 +0100232 call assert_fails("call spellsuggest('maxch', [])", 'E745:')
233 call assert_fails("call spellsuggest('maxch', 2, [])", 'E745:')
234
Bram Moolenaar152e79e2020-06-10 15:32:08 +0200235 set spelllang=
236 call assert_fails("call spellsuggest('maxch')", 'E756:')
237 set spelllang&
238
Bram Moolenaare9a8d1f2019-12-25 13:36:36 +0100239 set spell&
240endfunc
241
242" Test 'spellsuggest' option with methods fast, best and double.
243func Test_spellsuggest_option_methods()
244 set spell
245
Bram Moolenaar76734052019-12-26 14:30:15 +0100246 for e in ['latin1', 'utf-8']
247 exe 'set encoding=' .. e
Bram Moolenaare9a8d1f2019-12-25 13:36:36 +0100248
Bram Moolenaar76734052019-12-26 14:30:15 +0100249 set spellsuggest=fast
250 call assert_equal(['Stick', 'Stitch'], spellsuggest('Stich', 2), e)
Bram Moolenaare9a8d1f2019-12-25 13:36:36 +0100251
Bram Moolenaar76734052019-12-26 14:30:15 +0100252 " With best or double option, "Stitch" should become the top suggestion
253 " because of better phonetic matching.
254 set spellsuggest=best
255 call assert_equal(['Stitch', 'Stick'], spellsuggest('Stich', 2), e)
Bram Moolenaare9a8d1f2019-12-25 13:36:36 +0100256
Bram Moolenaar76734052019-12-26 14:30:15 +0100257 set spellsuggest=double
258 call assert_equal(['Stitch', 'Stick'], spellsuggest('Stich', 2), e)
259 endfor
260
261 set spell& spellsuggest& encoding&
Bram Moolenaare9a8d1f2019-12-25 13:36:36 +0100262endfunc
263
264" Test 'spellsuggest' option with value file:{filename}
265func Test_spellsuggest_option_file()
266 set spell spellsuggest=file:Xspellsuggest
267 call writefile(['emacs/vim',
268 \ 'theribal/terrible',
269 \ 'teribal/terrrible',
270 \ 'terribal'],
271 \ 'Xspellsuggest')
272
273 call assert_equal(['vim'], spellsuggest('emacs', 2))
274 call assert_equal(['terrible'], spellsuggest('theribal',2))
275
276 " If the suggestion is misspelled (*terrrible* with 3 r),
277 " it should not be proposed.
278 " The entry for "terribal" should be ignored because of missing slash.
279 call assert_equal([], spellsuggest('teribal', 2))
280 call assert_equal([], spellsuggest('terribal', 2))
281
282 set spell spellsuggest=best,file:Xspellsuggest
283 call assert_equal(['vim', 'Emacs'], spellsuggest('emacs', 2))
284 call assert_equal(['terrible', 'tribal'], spellsuggest('theribal', 2))
285 call assert_equal(['tribal'], spellsuggest('teribal', 1))
286 call assert_equal(['tribal'], spellsuggest('terribal', 1))
287
288 call delete('Xspellsuggest')
289 call assert_fails("call spellsuggest('vim')", "E484: Can't open file Xspellsuggest")
290
291 set spellsuggest& spell&
292endfunc
293
294" Test 'spellsuggest' option with value {number}
295" to limit the number of suggestions
296func Test_spellsuggest_option_number()
297 set spell spellsuggest=2,best
298 new
299
300 " We limited the number of suggestions to 2, so selecting
301 " the 1st and 2nd suggestion should correct the word, but
302 " selecting a 3rd suggestion should do nothing.
Bram Moolenaar76734052019-12-26 14:30:15 +0100303 call setline(1, 'A baord')
304 norm $1z=
305 call assert_equal('A board', getline(1))
Bram Moolenaare9a8d1f2019-12-25 13:36:36 +0100306
Bram Moolenaar76734052019-12-26 14:30:15 +0100307 call setline(1, 'A baord')
308 norm $2z=
309 call assert_equal('A bard', getline(1))
Bram Moolenaare9a8d1f2019-12-25 13:36:36 +0100310
Bram Moolenaar76734052019-12-26 14:30:15 +0100311 call setline(1, 'A baord')
312 norm $3z=
313 call assert_equal('A baord', getline(1))
Bram Moolenaare9a8d1f2019-12-25 13:36:36 +0100314
Bram Moolenaar76734052019-12-26 14:30:15 +0100315 let a = execute('norm $z=')
Bram Moolenaare9a8d1f2019-12-25 13:36:36 +0100316 call assert_equal(
317 \ "\n"
Bram Moolenaar76734052019-12-26 14:30:15 +0100318 \ .. "Change \"baord\" to:\n"
319 \ .. " 1 \"board\"\n"
320 \ .. " 2 \"bard\"\n"
Bram Moolenaard281b7c2020-06-10 16:39:32 +0200321 \ .. "Type number and <Enter> or click with the mouse (q or empty cancels): ", a)
Bram Moolenaare9a8d1f2019-12-25 13:36:36 +0100322
323 set spell spellsuggest=0
Bram Moolenaar76734052019-12-26 14:30:15 +0100324 call assert_equal("\nSorry, no suggestions", execute('norm $z='))
Bram Moolenaare9a8d1f2019-12-25 13:36:36 +0100325
326 " Unlike z=, function spellsuggest(...) should not be affected by the
327 " max number of suggestions (2) set by the 'spellsuggest' option.
Bram Moolenaar76734052019-12-26 14:30:15 +0100328 call assert_equal(['board', 'bard', 'broad'], spellsuggest('baord', 3))
Bram Moolenaare9a8d1f2019-12-25 13:36:36 +0100329
330 set spellsuggest& spell&
331 bwipe!
332endfunc
333
334" Test 'spellsuggest' option with value expr:{expr}
335func Test_spellsuggest_option_expr()
336 " A silly 'spellsuggest' function which makes suggestions all uppercase
337 " and makes the score of each suggestion the length of the suggested word.
338 " So shorter suggestions are preferred.
339 func MySuggest()
340 let spellsuggest_save = &spellsuggest
Bram Moolenaar76734052019-12-26 14:30:15 +0100341 set spellsuggest=3,best
Bram Moolenaare9a8d1f2019-12-25 13:36:36 +0100342 let result = map(spellsuggest(v:val, 3), "[toupper(v:val), len(v:val)]")
343 let &spellsuggest = spellsuggest_save
344 return result
345 endfunc
346
Bram Moolenaar76734052019-12-26 14:30:15 +0100347 set spell spellsuggest=expr:MySuggest()
348 call assert_equal(['BARD', 'BOARD', 'BROAD'], spellsuggest('baord', 3))
Bram Moolenaare9a8d1f2019-12-25 13:36:36 +0100349
350 new
Bram Moolenaar76734052019-12-26 14:30:15 +0100351 call setline(1, 'baord')
Bram Moolenaare9a8d1f2019-12-25 13:36:36 +0100352 let a = execute('norm z=')
353 call assert_equal(
354 \ "\n"
Bram Moolenaar76734052019-12-26 14:30:15 +0100355 \ .. "Change \"baord\" to:\n"
356 \ .. " 1 \"BARD\"\n"
357 \ .. " 2 \"BOARD\"\n"
358 \ .. " 3 \"BROAD\"\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 " With verbose, z= should show the score i.e. word length with
362 " our SpellSuggest() function.
363 set verbose=1
364 let a = execute('norm z=')
365 call assert_equal(
366 \ "\n"
Bram Moolenaar76734052019-12-26 14:30:15 +0100367 \ .. "Change \"baord\" to:\n"
368 \ .. " 1 \"BARD\" (4 - 0)\n"
369 \ .. " 2 \"BOARD\" (5 - 0)\n"
370 \ .. " 3 \"BROAD\" (5 - 0)\n"
Bram Moolenaard281b7c2020-06-10 16:39:32 +0200371 \ .. "Type number and <Enter> or click with the mouse (q or empty cancels): ", a)
Bram Moolenaare9a8d1f2019-12-25 13:36:36 +0100372
373 set spell& spellsuggest& verbose&
374 bwipe!
375endfunc
376
Bram Moolenaar8dfcce32020-03-18 19:32:26 +0100377" Test for 'spellsuggest' expr errrors
378func Test_spellsuggest_expr_errors()
379 " 'spellsuggest'
380 func MySuggest()
381 return range(3)
382 endfunc
383 set spell spellsuggest=expr:MySuggest()
384 call assert_equal([], spellsuggest('baord', 3))
385
386 " Test for 'spellsuggest' expression returning a non-list value
387 func! MySuggest2()
388 return 'good'
389 endfunc
390 set spellsuggest=expr:MySuggest2()
391 call assert_equal([], spellsuggest('baord'))
392
393 " Test for 'spellsuggest' expression returning a list with dict values
394 func! MySuggest3()
395 return [[{}, {}]]
396 endfunc
397 set spellsuggest=expr:MySuggest3()
Bram Moolenaar9b7bf9e2020-07-11 22:14:59 +0200398 call assert_fails("call spellsuggest('baord')", 'E731:')
Bram Moolenaar8dfcce32020-03-18 19:32:26 +0100399
400 set nospell spellsuggest&
401 delfunc MySuggest
402 delfunc MySuggest2
403 delfunc MySuggest3
404endfunc
405
Bram Moolenaar9049b682018-08-31 22:26:53 +0200406func Test_spellinfo()
407 new
Bram Moolenaarc25e7022019-10-10 14:08:26 +0200408 let runtime = substitute($VIMRUNTIME, '\\', '/', 'g')
Bram Moolenaar9049b682018-08-31 22:26:53 +0200409
410 set enc=latin1 spell spelllang=en
Bram Moolenaarc25e7022019-10-10 14:08:26 +0200411 call assert_match("^\nfile: " .. runtime .. "/spell/en.latin1.spl\n$", execute('spellinfo'))
Bram Moolenaar9049b682018-08-31 22:26:53 +0200412
413 set enc=cp1250 spell spelllang=en
Bram Moolenaarc25e7022019-10-10 14:08:26 +0200414 call assert_match("^\nfile: " .. runtime .. "/spell/en.ascii.spl\n$", execute('spellinfo'))
Bram Moolenaar9049b682018-08-31 22:26:53 +0200415
Bram Moolenaar30276f22019-01-24 17:59:39 +0100416 set enc=utf-8 spell spelllang=en
Bram Moolenaarc25e7022019-10-10 14:08:26 +0200417 call assert_match("^\nfile: " .. runtime .. "/spell/en.utf-8.spl\n$", execute('spellinfo'))
Bram Moolenaar9049b682018-08-31 22:26:53 +0200418
419 set enc=latin1 spell spelllang=en_us,en_nz
420 call assert_match("^\n" .
Bram Moolenaarc25e7022019-10-10 14:08:26 +0200421 \ "file: " .. runtime .. "/spell/en.latin1.spl\n" .
422 \ "file: " .. runtime.. "/spell/en.latin1.spl\n$", execute('spellinfo'))
Bram Moolenaar9049b682018-08-31 22:26:53 +0200423
424 set spell spelllang=
425 call assert_fails('spellinfo', 'E756:')
426
427 set nospell spelllang=en
428 call assert_fails('spellinfo', 'E756:')
429
Bram Moolenaar8f130ed2019-04-10 22:15:19 +0200430 call assert_fails('set spelllang=foo/bar', 'E474:')
431 call assert_fails('set spelllang=foo\ bar', 'E474:')
432 call assert_fails("set spelllang=foo\\\nbar", 'E474:')
433 call assert_fails("set spelllang=foo\\\rbar", 'E474:')
434 call assert_fails("set spelllang=foo+bar", 'E474:')
435
Bram Moolenaar9049b682018-08-31 22:26:53 +0200436 set enc& spell& spelllang&
437 bwipe
438endfunc
439
Bram Moolenaard2c061d2017-06-22 21:42:49 +0200440func Test_zz_basic()
441 call LoadAffAndDic(g:test_data_aff1, g:test_data_dic1)
442 call RunGoodBad("wrong OK puts. Test the end",
443 \ "bad: inputs comment ok Ok. test d\xE9\xF4l end the",
444 \["Comment", "deol", "d\xE9\xF4r", "input", "OK", "output", "outputs", "outtest", "put", "puts",
445 \ "test", "testen", "testn", "the end", "uk", "wrong"],
446 \[
447 \ ["bad", ["put", "uk", "OK"]],
448 \ ["inputs", ["input", "puts", "outputs"]],
449 \ ["comment", ["Comment", "outtest", "the end"]],
450 \ ["ok", ["OK", "uk", "put"]],
451 \ ["Ok", ["OK", "Uk", "Put"]],
452 \ ["test", ["Test", "testn", "testen"]],
453 \ ["d\xE9\xF4l", ["deol", "d\xE9\xF4r", "test"]],
454 \ ["end", ["put", "uk", "test"]],
455 \ ["the", ["put", "uk", "test"]],
456 \ ]
457 \ )
458
459 call assert_equal("gebletegek", soundfold('goobledygoook'))
Bram Moolenaarf6ed61e2019-09-07 19:05:09 +0200460 call assert_equal("kepereneven", 'kóopërÿnôven'->soundfold())
Bram Moolenaard2c061d2017-06-22 21:42:49 +0200461 call assert_equal("everles gesvets etele", soundfold('oeverloos gezwets edale'))
462endfunc
463
464" Postponed prefixes
465func Test_zz_prefixes()
466 call LoadAffAndDic(g:test_data_aff2, g:test_data_dic1)
467 call RunGoodBad("puts",
468 \ "bad: inputs comment ok Ok end the. test d\xE9\xF4l",
469 \ ["Comment", "deol", "d\xE9\xF4r", "OK", "put", "input", "output", "puts", "outputs", "test", "outtest", "testen", "testn", "the end", "uk", "wrong"],
470 \ [
471 \ ["bad", ["put", "uk", "OK"]],
472 \ ["inputs", ["input", "puts", "outputs"]],
473 \ ["comment", ["Comment"]],
474 \ ["ok", ["OK", "uk", "put"]],
475 \ ["Ok", ["OK", "Uk", "Put"]],
476 \ ["end", ["put", "uk", "deol"]],
477 \ ["the", ["put", "uk", "test"]],
478 \ ["test", ["Test", "testn", "testen"]],
479 \ ["d\xE9\xF4l", ["deol", "d\xE9\xF4r", "test"]],
480 \ ])
481endfunc
482
483"Compound words
484func Test_zz_compound()
485 call LoadAffAndDic(g:test_data_aff3, g:test_data_dic3)
486 call RunGoodBad("foo m\xEF foobar foofoobar barfoo barbarfoo",
487 \ "bad: bar la foom\xEF barm\xEF m\xEFfoo m\xEFbar m\xEFm\xEF lala m\xEFla lam\xEF foola labar",
488 \ ["foo", "m\xEF"],
489 \ [
490 \ ["bad", ["foo", "m\xEF"]],
491 \ ["bar", ["barfoo", "foobar", "foo"]],
492 \ ["la", ["m\xEF", "foo"]],
493 \ ["foom\xEF", ["foo m\xEF", "foo", "foofoo"]],
494 \ ["barm\xEF", ["barfoo", "m\xEF", "barbar"]],
495 \ ["m\xEFfoo", ["m\xEF foo", "foo", "foofoo"]],
496 \ ["m\xEFbar", ["foobar", "barbar", "m\xEF"]],
497 \ ["m\xEFm\xEF", ["m\xEF m\xEF", "m\xEF"]],
498 \ ["lala", []],
499 \ ["m\xEFla", ["m\xEF", "m\xEF m\xEF"]],
500 \ ["lam\xEF", ["m\xEF", "m\xEF m\xEF"]],
501 \ ["foola", ["foo", "foobar", "foofoo"]],
502 \ ["labar", ["barbar", "foobar"]],
503 \ ])
504
505 call LoadAffAndDic(g:test_data_aff4, g:test_data_dic4)
506 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",
507 \ "bad: wordutilize pro borkborkborkborkborkbork tomatotomatotomato endstart endend startstart wordend wordstart preborkprebork preborkpreborkbork startwordwordwordwordend borkpreborkpreborkbork utilsbork startnouword",
508 \ ["bork", "prebork", "end", "pro-ok", "start", "tomato", "util", "utilize", "utils", "word", "nouword"],
509 \ [
510 \ ["bad", ["end", "bork", "word"]],
511 \ ["wordutilize", ["word utilize", "wordutils", "wordutil"]],
512 \ ["pro", ["bork", "word", "end"]],
513 \ ["borkborkborkborkborkbork", ["bork borkborkborkborkbork", "borkbork borkborkborkbork", "borkborkbork borkborkbork"]],
514 \ ["tomatotomatotomato", ["tomato tomatotomato", "tomatotomato tomato", "tomato tomato tomato"]],
515 \ ["endstart", ["end start", "start"]],
516 \ ["endend", ["end end", "end"]],
517 \ ["startstart", ["start start"]],
518 \ ["wordend", ["word end", "word", "wordword"]],
519 \ ["wordstart", ["word start", "bork start"]],
520 \ ["preborkprebork", ["prebork prebork", "preborkbork", "preborkborkbork"]],
521 \ ["preborkpreborkbork", ["prebork preborkbork", "preborkborkbork", "preborkborkborkbork"]],
522 \ ["startwordwordwordwordend", ["startwordwordwordword end", "startwordwordwordword", "start wordwordwordword end"]],
523 \ ["borkpreborkpreborkbork", ["bork preborkpreborkbork", "bork prebork preborkbork", "bork preborkprebork bork"]],
524 \ ["utilsbork", ["utilbork", "utils bork", "util bork"]],
525 \ ["startnouword", ["start nouword", "startword", "startborkword"]],
526 \ ])
527
528endfunc
529
530"Test affix flags with two characters
531func Test_zz_affix()
532 call LoadAffAndDic(g:test_data_aff5, g:test_data_dic5)
533 call RunGoodBad("fooa1 fooa\xE9 bar prebar barbork prebarbork startprebar start end startend startmiddleend nouend",
534 \ "bad: foo fooa2 prabar probarbirk middle startmiddle middleend endstart startprobar startnouend",
535 \ ["bar", "barbork", "end", "fooa1", "fooa\xE9", "nouend", "prebar", "prebarbork", "start"],
536 \ [
537 \ ["bad", ["bar", "end", "fooa1"]],
538 \ ["foo", ["fooa1", "fooa\xE9", "bar"]],
539 \ ["fooa2", ["fooa1", "fooa\xE9", "bar"]],
540 \ ["prabar", ["prebar", "bar", "bar bar"]],
541 \ ["probarbirk", ["prebarbork"]],
542 \ ["middle", []],
543 \ ["startmiddle", ["startmiddleend", "startmiddlebar"]],
544 \ ["middleend", []],
545 \ ["endstart", ["end start", "start"]],
546 \ ["startprobar", ["startprebar", "start prebar", "startbar"]],
547 \ ["startnouend", ["start nouend", "startend"]],
548 \ ])
549
550 call LoadAffAndDic(g:test_data_aff6, g:test_data_dic6)
551 call RunGoodBad("meea1 meea\xE9 bar prebar barbork prebarbork leadprebar lead end leadend leadmiddleend",
552 \ "bad: mee meea2 prabar probarbirk middle leadmiddle middleend endlead leadprobar",
553 \ ["bar", "barbork", "end", "lead", "meea1", "meea\xE9", "prebar", "prebarbork"],
554 \ [
555 \ ["bad", ["bar", "end", "lead"]],
556 \ ["mee", ["meea1", "meea\xE9", "bar"]],
557 \ ["meea2", ["meea1", "meea\xE9", "lead"]],
558 \ ["prabar", ["prebar", "bar", "leadbar"]],
559 \ ["probarbirk", ["prebarbork"]],
560 \ ["middle", []],
561 \ ["leadmiddle", ["leadmiddleend", "leadmiddlebar"]],
562 \ ["middleend", []],
563 \ ["endlead", ["end lead", "lead", "end end"]],
564 \ ["leadprobar", ["leadprebar", "lead prebar", "leadbar"]],
565 \ ])
566
567 call LoadAffAndDic(g:test_data_aff7, g:test_data_dic7)
Bram Moolenaar3d2a47c2019-11-07 20:48:42 +0100568 call RunGoodBad("meea1 meezero meea\xE9 bar prebar barmeat prebarmeat leadprebar lead tail leadtail leadmiddletail",
Bram Moolenaard2c061d2017-06-22 21:42:49 +0200569 \ "bad: mee meea2 prabar probarmaat middle leadmiddle middletail taillead leadprobar",
Bram Moolenaar3d2a47c2019-11-07 20:48:42 +0100570 \ ["bar", "barmeat", "lead", "meea1", "meea\xE9", "meezero", "prebar", "prebarmeat", "tail"],
Bram Moolenaard2c061d2017-06-22 21:42:49 +0200571 \ [
572 \ ["bad", ["bar", "lead", "tail"]],
573 \ ["mee", ["meea1", "meea\xE9", "bar"]],
574 \ ["meea2", ["meea1", "meea\xE9", "lead"]],
575 \ ["prabar", ["prebar", "bar", "leadbar"]],
576 \ ["probarmaat", ["prebarmeat"]],
577 \ ["middle", []],
578 \ ["leadmiddle", ["leadmiddlebar"]],
579 \ ["middletail", []],
580 \ ["taillead", ["tail lead", "tail"]],
581 \ ["leadprobar", ["leadprebar", "lead prebar", "leadbar"]],
582 \ ])
583endfunc
584
585func Test_zz_NOSLITSUGS()
586 call LoadAffAndDic(g:test_data_aff8, g:test_data_dic8)
587 call RunGoodBad("foo bar faabar", "bad: foobar barfoo",
588 \ ["bar", "faabar", "foo"],
589 \ [
590 \ ["bad", ["bar", "foo"]],
591 \ ["foobar", ["faabar", "foo bar", "bar"]],
592 \ ["barfoo", ["bar foo", "bar", "foo"]],
593 \ ])
594endfunc
595
596" Numbers
597func Test_zz_Numbers()
598 call LoadAffAndDic(g:test_data_aff9, g:test_data_dic9)
599 call RunGoodBad("0b1011 0777 1234 0x01ff", "",
600 \ ["bar", "foo"],
601 \ [
602 \ ])
603endfunc
604
Bram Moolenaar37ff4cf2019-11-17 20:10:20 +0100605" Affix flags
606func Test_zz_affix_flags()
607 call LoadAffAndDic(g:test_data_aff10, g:test_data_dic10)
608 call RunGoodBad("drink drinkable drinkables drinktable drinkabletable",
609 \ "bad: drinks drinkstable drinkablestable",
610 \ ["drink", "drinkable", "drinkables", "table"],
611 \ [['bad', []],
612 \ ['drinks', ['drink']],
613 \ ['drinkstable', ['drinktable', 'drinkable', 'drink table']],
614 \ ['drinkablestable', ['drinkabletable', 'drinkables table', 'drinkable table']],
615 \ ])
616endfunc
617
Bram Moolenaard2c061d2017-06-22 21:42:49 +0200618function FirstSpellWord()
619 call feedkeys("/^start:\n", 'tx')
620 normal ]smm
621 let [str, a] = spellbadword()
622 return str
623endfunc
624
625function SecondSpellWord()
626 normal `m]s
627 let [str, a] = spellbadword()
628 return str
629endfunc
630
631"Test with SAL instead of SOFO items; test automatic reloading
632func Test_zz_sal_and_addition()
633 set enc=latin1
634 set spellfile=
Bram Moolenaar1a0f2002017-07-28 15:38:10 +0200635 call writefile(g:test_data_dic1, "Xtest.dic")
Bram Moolenaard2c061d2017-06-22 21:42:49 +0200636 call writefile(g:test_data_aff_sal, "Xtest.aff")
637 mkspell! Xtest Xtest
638 set spl=Xtest.latin1.spl spell
639 call assert_equal('kbltykk', soundfold('goobledygoook'))
640 call assert_equal('kprnfn', soundfold('kóopërÿnôven'))
641 call assert_equal('*fls kswts tl', soundfold('oeverloos gezwets edale'))
642
643 "also use an addition file
644 call writefile(["/regions=usgbnz", "elequint/2", "elekwint/3"], "Xtest.latin1.add")
645 mkspell! Xtest.latin1.add.spl Xtest.latin1.add
646
647 bwipe!
648 call setline(1, ["start: elequint test elekwint test elekwent asdf"])
649
650 set spellfile=Xtest.latin1.add
651 call assert_equal("elekwent", FirstSpellWord())
652
653 set spl=Xtest_us.latin1.spl
654 call assert_equal("elequint", FirstSpellWord())
655 call assert_equal("elekwint", SecondSpellWord())
656
657 set spl=Xtest_gb.latin1.spl
658 call assert_equal("elekwint", FirstSpellWord())
659 call assert_equal("elekwent", SecondSpellWord())
660
661 set spl=Xtest_nz.latin1.spl
662 call assert_equal("elequint", FirstSpellWord())
663 call assert_equal("elekwent", SecondSpellWord())
664
665 set spl=Xtest_ca.latin1.spl
666 call assert_equal("elequint", FirstSpellWord())
667 call assert_equal("elekwint", SecondSpellWord())
668endfunc
669
Bram Moolenaar862f1e12019-04-10 22:33:41 +0200670func Test_spellfile_value()
671 set spellfile=Xdir/Xtest.latin1.add
672 set spellfile=Xdir/Xtest.utf-8.add,Xtest_other.add
673endfunc
674
Bram Moolenaaree03b942017-10-27 00:57:05 +0200675func Test_region_error()
676 messages clear
677 call writefile(["/regions=usgbnz", "elequint/0"], "Xtest.latin1.add")
678 mkspell! Xtest.latin1.add.spl Xtest.latin1.add
679 call assert_match('Invalid region nr in Xtest.latin1.add line 2: 0', execute('messages'))
680 call delete('Xtest.latin1.add')
681 call delete('Xtest.latin1.add.spl')
682endfunc
683
Bram Moolenaard2c061d2017-06-22 21:42:49 +0200684" Check using z= in new buffer (crash fixed by patch 7.4a.028).
685func Test_zeq_crash()
686 new
687 set maxmem=512 spell
688 call feedkeys('iasdz=:\"', 'tx')
689
690 bwipe!
691endfunc
692
Bram Moolenaar152e79e2020-06-10 15:32:08 +0200693" Check that z= works even when 'nospell' is set. This test uses one of the
694" tests in Test_spellsuggest_option_number() just to verify that z= basically
695" works and that "E756: Spell checking is not enabled" is not generated.
696func Test_zeq_nospell()
697 new
698 set nospell spellsuggest=1,best
699 call setline(1, 'A baord')
700 try
701 norm $1z=
702 call assert_equal('A board', getline(1))
703 catch
704 call assert_report("Caught exception: " . v:exception)
705 endtry
706 set spell& spellsuggest&
707 bwipe!
708endfunc
709
710" Check that "E756: Spell checking is not possible" is reported when z= is
711" executed and 'spelllang' is empty.
712func Test_zeq_no_spelllang()
713 new
714 set spelllang= spellsuggest=1,best
715 call setline(1, 'A baord')
716 call assert_fails('normal $1z=', 'E756:')
717 set spelllang& spellsuggest&
718 bwipe!
719endfunc
720
Bram Moolenaar5bcc5a12019-08-06 22:48:02 +0200721" Check handling a word longer than MAXWLEN.
722func Test_spell_long_word()
723 set enc=utf-8
724 new
725 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")
726 set spell spelllang=en
727 redraw
728 redraw!
729 bwipe!
730 set nospell
731endfunc
732
Bram Moolenaard2c061d2017-06-22 21:42:49 +0200733func LoadAffAndDic(aff_contents, dic_contents)
734 set enc=latin1
735 set spellfile=
736 call writefile(a:aff_contents, "Xtest.aff")
737 call writefile(a:dic_contents, "Xtest.dic")
738 " Generate a .spl file from a .dic and .aff file.
739 mkspell! Xtest Xtest
740 " use that spell file
741 set spl=Xtest.latin1.spl spell
742endfunc
743
744func ListWords()
745 spelldump
746 %yank
747 quit
748 return split(@", "\n")
749endfunc
750
751func TestGoodBadBase()
752 exe '1;/^good:'
753 normal 0f:]s
754 let prevbad = ''
755 let result = []
756 while 1
757 let [bad, a] = spellbadword()
758 if bad == '' || bad == prevbad || bad == 'badend'
759 break
760 endif
761 let prevbad = bad
Bram Moolenaarf6ed61e2019-09-07 19:05:09 +0200762 let lst = bad->spellsuggest(3)
Bram Moolenaard2c061d2017-06-22 21:42:49 +0200763 normal mm
764
765 call add(result, [bad, lst])
766 normal `m]s
767 endwhile
768 return result
769endfunc
770
771func RunGoodBad(good, bad, expected_words, expected_bad_words)
772 bwipe!
773 call setline(1, ["good: ", a:good, a:bad, " badend "])
774 let words = ListWords()
775 call assert_equal(a:expected_words, words[1:-1])
776 let bad_words = TestGoodBadBase()
777 call assert_equal(a:expected_bad_words, bad_words)
778 bwipe!
779endfunc
780
Bram Moolenaar7751d1d2019-10-18 20:37:08 +0200781func Test_spell_screendump()
782 CheckScreendump
783
784 let lines =<< trim END
785 call setline(1, [
786 \ "This is some text without any spell errors. Everything",
787 \ "should just be black, nothing wrong here.",
788 \ "",
789 \ "This line has a sepll error. and missing caps.",
790 \ "And and this is the the duplication.",
791 \ "with missing caps here.",
792 \ ])
793 set spell spelllang=en_nz
794 END
795 call writefile(lines, 'XtestSpell')
796 let buf = RunVimInTerminal('-S XtestSpell', {'rows': 8})
797 call VerifyScreenDump(buf, 'Test_spell_1', {})
798
799 " clean up
800 call StopVimInTerminal(buf)
801 call delete('XtestSpell')
802endfunc
803
Bram Moolenaard2c061d2017-06-22 21:42:49 +0200804let g:test_data_aff1 = [
805 \"SET ISO8859-1",
806 \"TRY esianrtolcdugmphbyfvkwjkqxz-\xEB\xE9\xE8\xEA\xEF\xEE\xE4\xE0\xE2\xF6\xFC\xFB'ESIANRTOLCDUGMPHBYFVKWJKQXZ",
807 \"",
808 \"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",
809 \"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",
810 \"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",
811 \"",
812 \"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",
813 \"SOFOTO ebctefghejklnnepkrstevvkesebctefghejklnnepkrstevvkeseeeeeeeceeeeeeeedneeeeeeeeeeepseeeeeeeeceeeeeeeedneeeeeeeeeeep?",
814 \"",
815 \"MIDWORD\t'-",
816 \"",
817 \"KEP =",
818 \"RAR ?",
819 \"BAD !",
820 \"",
821 \"PFX I N 1",
822 \"PFX I 0 in .",
823 \"",
824 \"PFX O Y 1",
825 \"PFX O 0 out .",
826 \"",
827 \"SFX S Y 2",
828 \"SFX S 0 s [^s]",
829 \"SFX S 0 es s",
830 \"",
831 \"SFX N N 3",
832 \"SFX N 0 en [^n]",
833 \"SFX N 0 nen n",
834 \"SFX N 0 n .",
835 \"",
836 \"REP 3",
837 \"REP g ch",
838 \"REP ch g",
839 \"REP svp s.v.p.",
840 \"",
841 \"MAP 9",
842 \"MAP a\xE0\xE1\xE2\xE3\xE4\xE5",
843 \"MAP e\xE8\xE9\xEA\xEB",
844 \"MAP i\xEC\xED\xEE\xEF",
845 \"MAP o\xF2\xF3\xF4\xF5\xF6",
846 \"MAP u\xF9\xFA\xFB\xFC",
847 \"MAP n\xF1",
848 \"MAP c\xE7",
849 \"MAP y\xFF\xFD",
850 \"MAP s\xDF",
851 \ ]
852let g:test_data_dic1 = [
853 \"123456",
854 \"test/NO",
855 \"# comment",
856 \"wrong",
857 \"Comment",
858 \"OK",
859 \"uk",
860 \"put/ISO",
861 \"the end",
862 \"deol",
863 \"d\xE9\xF4r",
864 \ ]
865let g:test_data_aff2 = [
866 \"SET ISO8859-1",
867 \"",
868 \"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",
869 \"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",
870 \"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",
871 \"",
872 \"PFXPOSTPONE",
873 \"",
874 \"MIDWORD\t'-",
875 \"",
876 \"KEP =",
877 \"RAR ?",
878 \"BAD !",
879 \"",
880 \"PFX I N 1",
881 \"PFX I 0 in .",
882 \"",
883 \"PFX O Y 1",
884 \"PFX O 0 out [a-z]",
885 \"",
886 \"SFX S Y 2",
887 \"SFX S 0 s [^s]",
888 \"SFX S 0 es s",
889 \"",
890 \"SFX N N 3",
891 \"SFX N 0 en [^n]",
892 \"SFX N 0 nen n",
893 \"SFX N 0 n .",
894 \"",
895 \"REP 3",
896 \"REP g ch",
897 \"REP ch g",
898 \"REP svp s.v.p.",
899 \"",
900 \"MAP 9",
901 \"MAP a\xE0\xE1\xE2\xE3\xE4\xE5",
902 \"MAP e\xE8\xE9\xEA\xEB",
903 \"MAP i\xEC\xED\xEE\xEF",
904 \"MAP o\xF2\xF3\xF4\xF5\xF6",
905 \"MAP u\xF9\xFA\xFB\xFC",
906 \"MAP n\xF1",
907 \"MAP c\xE7",
908 \"MAP y\xFF\xFD",
909 \"MAP s\xDF",
910 \ ]
911let g:test_data_aff3 = [
912 \"SET ISO8859-1",
913 \"",
914 \"COMPOUNDMIN 3",
915 \"COMPOUNDRULE m*",
916 \"NEEDCOMPOUND x",
917 \ ]
918let g:test_data_dic3 = [
919 \"1234",
920 \"foo/m",
921 \"bar/mx",
922 \"m\xEF/m",
923 \"la/mx",
924 \ ]
925let g:test_data_aff4 = [
926 \"SET ISO8859-1",
927 \"",
928 \"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",
929 \"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",
930 \"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",
931 \"",
932 \"COMPOUNDRULE m+",
933 \"COMPOUNDRULE sm*e",
934 \"COMPOUNDRULE sm+",
935 \"COMPOUNDMIN 3",
936 \"COMPOUNDWORDMAX 3",
937 \"COMPOUNDFORBIDFLAG t",
938 \"",
939 \"COMPOUNDSYLMAX 5",
940 \"SYLLABLE a\xE1e\xE9i\xEDo\xF3\xF6\xF5u\xFA\xFC\xFBy/aa/au/ea/ee/ei/ie/oa/oe/oo/ou/uu/ui",
941 \"",
942 \"MAP 9",
943 \"MAP a\xE0\xE1\xE2\xE3\xE4\xE5",
944 \"MAP e\xE8\xE9\xEA\xEB",
945 \"MAP i\xEC\xED\xEE\xEF",
946 \"MAP o\xF2\xF3\xF4\xF5\xF6",
947 \"MAP u\xF9\xFA\xFB\xFC",
948 \"MAP n\xF1",
949 \"MAP c\xE7",
950 \"MAP y\xFF\xFD",
951 \"MAP s\xDF",
952 \"",
953 \"NEEDAFFIX x",
954 \"",
955 \"PFXPOSTPONE",
956 \"",
957 \"MIDWORD '-",
958 \"",
959 \"SFX q N 1",
960 \"SFX q 0 -ok .",
961 \"",
962 \"SFX a Y 2",
963 \"SFX a 0 s .",
964 \"SFX a 0 ize/t .",
965 \"",
966 \"PFX p N 1",
967 \"PFX p 0 pre .",
968 \"",
969 \"PFX P N 1",
970 \"PFX P 0 nou .",
971 \ ]
972let g:test_data_dic4 = [
973 \"1234",
974 \"word/mP",
975 \"util/am",
976 \"pro/xq",
977 \"tomato/m",
978 \"bork/mp",
979 \"start/s",
980 \"end/e",
981 \ ]
982let g:test_data_aff5 = [
983 \"SET ISO8859-1",
984 \"",
985 \"FLAG long",
986 \"",
987 \"NEEDAFFIX !!",
988 \"",
989 \"COMPOUNDRULE ssmm*ee",
990 \"",
991 \"NEEDCOMPOUND xx",
992 \"COMPOUNDPERMITFLAG pp",
993 \"",
994 \"SFX 13 Y 1",
995 \"SFX 13 0 bork .",
996 \"",
997 \"SFX a1 Y 1",
998 \"SFX a1 0 a1 .",
999 \"",
1000 \"SFX a\xE9 Y 1",
1001 \"SFX a\xE9 0 a\xE9 .",
1002 \"",
1003 \"PFX zz Y 1",
1004 \"PFX zz 0 pre/pp .",
1005 \"",
1006 \"PFX yy Y 1",
1007 \"PFX yy 0 nou .",
1008 \ ]
1009let g:test_data_dic5 = [
1010 \"1234",
1011 \"foo/a1a\xE9!!",
1012 \"bar/zz13ee",
1013 \"start/ss",
1014 \"end/eeyy",
1015 \"middle/mmxx",
1016 \ ]
1017let g:test_data_aff6 = [
1018 \"SET ISO8859-1",
1019 \"",
1020 \"FLAG caplong",
1021 \"",
1022 \"NEEDAFFIX A!",
1023 \"",
1024 \"COMPOUNDRULE sMm*Ee",
1025 \"",
1026 \"NEEDCOMPOUND Xx",
1027 \"",
1028 \"COMPOUNDPERMITFLAG p",
1029 \"",
1030 \"SFX N3 Y 1",
1031 \"SFX N3 0 bork .",
1032 \"",
1033 \"SFX A1 Y 1",
1034 \"SFX A1 0 a1 .",
1035 \"",
1036 \"SFX A\xE9 Y 1",
1037 \"SFX A\xE9 0 a\xE9 .",
1038 \"",
1039 \"PFX Zz Y 1",
1040 \"PFX Zz 0 pre/p .",
1041 \ ]
1042let g:test_data_dic6 = [
1043 \"1234",
1044 \"mee/A1A\xE9A!",
1045 \"bar/ZzN3Ee",
1046 \"lead/s",
1047 \"end/Ee",
1048 \"middle/MmXx",
1049 \ ]
1050let g:test_data_aff7 = [
1051 \"SET ISO8859-1",
1052 \"",
1053 \"FLAG num",
1054 \"",
1055 \"NEEDAFFIX 9999",
1056 \"",
1057 \"COMPOUNDRULE 2,77*123",
1058 \"",
1059 \"NEEDCOMPOUND 1",
1060 \"COMPOUNDPERMITFLAG 432",
1061 \"",
1062 \"SFX 61003 Y 1",
1063 \"SFX 61003 0 meat .",
1064 \"",
Bram Moolenaar3d2a47c2019-11-07 20:48:42 +01001065 \"SFX 0 Y 1",
1066 \"SFX 0 0 zero .",
1067 \"",
Bram Moolenaard2c061d2017-06-22 21:42:49 +02001068 \"SFX 391 Y 1",
1069 \"SFX 391 0 a1 .",
1070 \"",
1071 \"SFX 111 Y 1",
1072 \"SFX 111 0 a\xE9 .",
1073 \"",
1074 \"PFX 17 Y 1",
1075 \"PFX 17 0 pre/432 .",
1076 \ ]
1077let g:test_data_dic7 = [
1078 \"1234",
Bram Moolenaar3d2a47c2019-11-07 20:48:42 +01001079 \"mee/0,391,111,9999",
Bram Moolenaard2c061d2017-06-22 21:42:49 +02001080 \"bar/17,61003,123",
1081 \"lead/2",
1082 \"tail/123",
1083 \"middle/77,1",
1084 \ ]
1085let g:test_data_aff8 = [
1086 \"SET ISO8859-1",
1087 \"",
1088 \"NOSPLITSUGS",
1089 \ ]
1090let g:test_data_dic8 = [
1091 \"1234",
1092 \"foo",
1093 \"bar",
1094 \"faabar",
1095 \ ]
1096let g:test_data_aff9 = [
1097 \ ]
1098let g:test_data_dic9 = [
1099 \"1234",
1100 \"foo",
1101 \"bar",
1102 \ ]
Bram Moolenaar37ff4cf2019-11-17 20:10:20 +01001103let g:test_data_aff10 = [
1104 \"COMPOUNDRULE se",
1105 \"COMPOUNDPERMITFLAG p",
1106 \"",
1107 \"SFX A Y 1",
1108 \"SFX A 0 able/Mp .",
1109 \"",
1110 \"SFX M Y 1",
1111 \"SFX M 0 s .",
1112 \ ]
1113let g:test_data_dic10 = [
1114 \"1234",
1115 \"drink/As",
1116 \"table/e",
1117 \ ]
Bram Moolenaard2c061d2017-06-22 21:42:49 +02001118let g:test_data_aff_sal = [
1119 \"SET ISO8859-1",
1120 \"TRY esianrtolcdugmphbyfvkwjkqxz-\xEB\xE9\xE8\xEA\xEF\xEE\xE4\xE0\xE2\xF6\xFC\xFB'ESIANRTOLCDUGMPHBYFVKWJKQXZ",
1121 \"",
1122 \"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",
1123 \"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",
1124 \"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",
1125 \"",
1126 \"MIDWORD\t'-",
1127 \"",
1128 \"KEP =",
1129 \"RAR ?",
1130 \"BAD !",
1131 \"",
1132 \"PFX I N 1",
1133 \"PFX I 0 in .",
1134 \"",
1135 \"PFX O Y 1",
1136 \"PFX O 0 out .",
1137 \"",
1138 \"SFX S Y 2",
1139 \"SFX S 0 s [^s]",
1140 \"SFX S 0 es s",
1141 \"",
1142 \"SFX N N 3",
1143 \"SFX N 0 en [^n]",
1144 \"SFX N 0 nen n",
1145 \"SFX N 0 n .",
1146 \"",
1147 \"REP 3",
1148 \"REP g ch",
1149 \"REP ch g",
1150 \"REP svp s.v.p.",
1151 \"",
1152 \"MAP 9",
1153 \"MAP a\xE0\xE1\xE2\xE3\xE4\xE5",
1154 \"MAP e\xE8\xE9\xEA\xEB",
1155 \"MAP i\xEC\xED\xEE\xEF",
1156 \"MAP o\xF2\xF3\xF4\xF5\xF6",
1157 \"MAP u\xF9\xFA\xFB\xFC",
1158 \"MAP n\xF1",
1159 \"MAP c\xE7",
1160 \"MAP y\xFF\xFD",
1161 \"MAP s\xDF",
1162 \"",
1163 \"SAL AH(AEIOUY)-^ *H",
1164 \"SAL AR(AEIOUY)-^ *R",
1165 \"SAL A(HR)^ *",
1166 \"SAL A^ *",
1167 \"SAL AH(AEIOUY)- H",
1168 \"SAL AR(AEIOUY)- R",
1169 \"SAL A(HR) _",
1170 \"SAL \xC0^ *",
1171 \"SAL \xC5^ *",
1172 \"SAL BB- _",
1173 \"SAL B B",
1174 \"SAL CQ- _",
1175 \"SAL CIA X",
1176 \"SAL CH X",
1177 \"SAL C(EIY)- S",
1178 \"SAL CK K",
1179 \"SAL COUGH^ KF",
1180 \"SAL CC< C",
1181 \"SAL C K",
1182 \"SAL DG(EIY) K",
1183 \"SAL DD- _",
1184 \"SAL D T",
1185 \"SAL \xC9< E",
1186 \"SAL EH(AEIOUY)-^ *H",
1187 \"SAL ER(AEIOUY)-^ *R",
1188 \"SAL E(HR)^ *",
1189 \"SAL ENOUGH^$ *NF",
1190 \"SAL E^ *",
1191 \"SAL EH(AEIOUY)- H",
1192 \"SAL ER(AEIOUY)- R",
1193 \"SAL E(HR) _",
1194 \"SAL FF- _",
1195 \"SAL F F",
1196 \"SAL GN^ N",
1197 \"SAL GN$ N",
1198 \"SAL GNS$ NS",
1199 \"SAL GNED$ N",
1200 \"SAL GH(AEIOUY)- K",
1201 \"SAL GH _",
1202 \"SAL GG9 K",
1203 \"SAL G K",
1204 \"SAL H H",
1205 \"SAL IH(AEIOUY)-^ *H",
1206 \"SAL IR(AEIOUY)-^ *R",
1207 \"SAL I(HR)^ *",
1208 \"SAL I^ *",
1209 \"SAL ING6 N",
1210 \"SAL IH(AEIOUY)- H",
1211 \"SAL IR(AEIOUY)- R",
1212 \"SAL I(HR) _",
1213 \"SAL J K",
1214 \"SAL KN^ N",
1215 \"SAL KK- _",
1216 \"SAL K K",
1217 \"SAL LAUGH^ LF",
1218 \"SAL LL- _",
1219 \"SAL L L",
1220 \"SAL MB$ M",
1221 \"SAL MM M",
1222 \"SAL M M",
1223 \"SAL NN- _",
1224 \"SAL N N",
1225 \"SAL OH(AEIOUY)-^ *H",
1226 \"SAL OR(AEIOUY)-^ *R",
1227 \"SAL O(HR)^ *",
1228 \"SAL O^ *",
1229 \"SAL OH(AEIOUY)- H",
1230 \"SAL OR(AEIOUY)- R",
1231 \"SAL O(HR) _",
1232 \"SAL PH F",
1233 \"SAL PN^ N",
1234 \"SAL PP- _",
1235 \"SAL P P",
1236 \"SAL Q K",
1237 \"SAL RH^ R",
1238 \"SAL ROUGH^ RF",
1239 \"SAL RR- _",
1240 \"SAL R R",
1241 \"SAL SCH(EOU)- SK",
1242 \"SAL SC(IEY)- S",
1243 \"SAL SH X",
1244 \"SAL SI(AO)- X",
1245 \"SAL SS- _",
1246 \"SAL S S",
1247 \"SAL TI(AO)- X",
1248 \"SAL TH @",
1249 \"SAL TCH-- _",
1250 \"SAL TOUGH^ TF",
1251 \"SAL TT- _",
1252 \"SAL T T",
1253 \"SAL UH(AEIOUY)-^ *H",
1254 \"SAL UR(AEIOUY)-^ *R",
1255 \"SAL U(HR)^ *",
1256 \"SAL U^ *",
1257 \"SAL UH(AEIOUY)- H",
1258 \"SAL UR(AEIOUY)- R",
1259 \"SAL U(HR) _",
1260 \"SAL V^ W",
1261 \"SAL V F",
1262 \"SAL WR^ R",
1263 \"SAL WH^ W",
1264 \"SAL W(AEIOU)- W",
1265 \"SAL X^ S",
1266 \"SAL X KS",
1267 \"SAL Y(AEIOU)- Y",
1268 \"SAL ZZ- _",
1269 \"SAL Z S",
1270 \ ]
Bram Moolenaar0e05de42020-03-25 22:23:46 +01001271
1272" vim: shiftwidth=2 sts=2 expandtab