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