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