Bram Moolenaar | d3f78dc | 2017-02-25 14:21:10 +0100 | [diff] [blame] | 1 | " Test spell checking |
Bram Moolenaar | 5bcc5a1 | 2019-08-06 22:48:02 +0200 | [diff] [blame] | 2 | " Note: this file uses latin1 encoding, but is used with utf-8 encoding. |
Bram Moolenaar | d3f78dc | 2017-02-25 14:21:10 +0100 | [diff] [blame] | 3 | |
Bram Moolenaar | b46fecd | 2019-06-15 17:58:09 +0200 | [diff] [blame] | 4 | source check.vim |
| 5 | CheckFeature spell |
Bram Moolenaar | d3f78dc | 2017-02-25 14:21:10 +0100 | [diff] [blame] | 6 | |
Bram Moolenaar | 7751d1d | 2019-10-18 20:37:08 +0200 | [diff] [blame] | 7 | source screendump.vim |
| 8 | |
Bram Moolenaar | 1a0f200 | 2017-07-28 15:38:10 +0200 | [diff] [blame] | 9 | func 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') |
zeertzjq | 288ed23 | 2022-07-04 11:03:07 +0100 | [diff] [blame] | 17 | " set 'encoding' to clear the word list |
| 18 | set encoding=utf-8 |
Bram Moolenaar | 1a0f200 | 2017-07-28 15:38:10 +0200 | [diff] [blame] | 19 | endfunc |
| 20 | |
Bram Moolenaar | d3f78dc | 2017-02-25 14:21:10 +0100 | [diff] [blame] | 21 | func Test_wrap_search() |
| 22 | new |
| 23 | call setline(1, ['The', '', 'A plong line with two zpelling mistakes', '', 'End']) |
| 24 | set spell wrapscan |
| 25 | normal ]s |
| 26 | call assert_equal('plong', expand('<cword>')) |
| 27 | normal ]s |
| 28 | call assert_equal('zpelling', expand('<cword>')) |
| 29 | normal ]s |
| 30 | call assert_equal('plong', expand('<cword>')) |
| 31 | bwipe! |
| 32 | set nospell |
| 33 | endfunc |
Bram Moolenaar | 5b276aa | 2017-04-22 23:49:52 +0200 | [diff] [blame] | 34 | |
Bram Moolenaar | b73fa62 | 2017-12-21 20:27:47 +0100 | [diff] [blame] | 35 | func Test_curswant() |
| 36 | new |
| 37 | call setline(1, ['Another plong line', 'abcdefghijklmnopq']) |
| 38 | set spell wrapscan |
| 39 | normal 0]s |
| 40 | call assert_equal('plong', expand('<cword>')) |
| 41 | normal j |
| 42 | call assert_equal(9, getcurpos()[2]) |
| 43 | normal 0[s |
| 44 | call assert_equal('plong', expand('<cword>')) |
| 45 | normal j |
| 46 | call assert_equal(9, getcurpos()[2]) |
| 47 | |
| 48 | normal 0]S |
| 49 | call assert_equal('plong', expand('<cword>')) |
| 50 | normal j |
| 51 | call assert_equal(9, getcurpos()[2]) |
| 52 | normal 0[S |
| 53 | call assert_equal('plong', expand('<cword>')) |
| 54 | normal j |
| 55 | call assert_equal(9, getcurpos()[2]) |
| 56 | |
| 57 | normal 1G0 |
| 58 | call assert_equal('plong', spellbadword()[0]) |
| 59 | normal j |
| 60 | call assert_equal(9, getcurpos()[2]) |
| 61 | |
| 62 | bwipe! |
| 63 | set nospell |
| 64 | endfunc |
| 65 | |
Bram Moolenaar | 5b276aa | 2017-04-22 23:49:52 +0200 | [diff] [blame] | 66 | func Test_z_equal_on_invalid_utf8_word() |
| 67 | split |
| 68 | set spell |
| 69 | call setline(1, "\xff") |
| 70 | norm z= |
| 71 | set nospell |
| 72 | bwipe! |
| 73 | endfunc |
Bram Moolenaar | 545cb79 | 2017-05-23 11:31:22 +0200 | [diff] [blame] | 74 | |
Bram Moolenaar | 156d391 | 2022-06-18 14:09:08 +0100 | [diff] [blame] | 75 | func Test_z_equal_on_single_character() |
| 76 | " this was decrementing the index below zero |
| 77 | new |
| 78 | norm a0\Ê |
| 79 | norm zW |
| 80 | norm z= |
| 81 | |
| 82 | bwipe! |
| 83 | endfunc |
| 84 | |
Bram Moolenaar | 872e451 | 2018-07-20 23:36:26 +0200 | [diff] [blame] | 85 | " Test spellbadword() with argument |
| 86 | func Test_spellbadword() |
| 87 | set spell |
| 88 | |
| 89 | call assert_equal(['bycycle', 'bad'], spellbadword('My bycycle.')) |
Bram Moolenaar | f6ed61e | 2019-09-07 19:05:09 +0200 | [diff] [blame] | 90 | call assert_equal(['another', 'caps'], 'A sentence. another sentence'->spellbadword()) |
Bram Moolenaar | 872e451 | 2018-07-20 23:36:26 +0200 | [diff] [blame] | 91 | |
Bram Moolenaar | 362b44b | 2020-06-10 21:47:00 +0200 | [diff] [blame] | 92 | call assert_equal(['TheCamelWord', 'bad'], 'TheCamelWord asdf'->spellbadword()) |
| 93 | set spelloptions=camel |
| 94 | call assert_equal(['asdf', 'bad'], 'TheCamelWord asdf'->spellbadword()) |
| 95 | set spelloptions= |
| 96 | |
Bram Moolenaar | 872e451 | 2018-07-20 23:36:26 +0200 | [diff] [blame] | 97 | set spelllang=en |
| 98 | call assert_equal(['', ''], spellbadword('centre')) |
| 99 | call assert_equal(['', ''], spellbadword('center')) |
| 100 | set spelllang=en_us |
| 101 | call assert_equal(['centre', 'local'], spellbadword('centre')) |
| 102 | call assert_equal(['', ''], spellbadword('center')) |
| 103 | set spelllang=en_gb |
| 104 | call assert_equal(['', ''], spellbadword('centre')) |
| 105 | call assert_equal(['center', 'local'], spellbadword('center')) |
| 106 | |
| 107 | " Create a small word list to test that spellbadword('...') |
| 108 | " can return ['...', 'rare']. |
| 109 | e Xwords |
| 110 | insert |
| 111 | foo |
| 112 | foobar/? |
| 113 | . |
| 114 | w! |
| 115 | mkspell! Xwords.spl Xwords |
| 116 | set spelllang=Xwords.spl |
| 117 | call assert_equal(['foobar', 'rare'], spellbadword('foo foobar')) |
| 118 | |
Bram Moolenaar | 152e79e | 2020-06-10 15:32:08 +0200 | [diff] [blame] | 119 | " Typo should be detected even without the 'spell' option. |
Bram Moolenaar | 872e451 | 2018-07-20 23:36:26 +0200 | [diff] [blame] | 120 | set spelllang=en_gb nospell |
| 121 | call assert_equal(['', ''], spellbadword('centre')) |
Bram Moolenaar | 152e79e | 2020-06-10 15:32:08 +0200 | [diff] [blame] | 122 | call assert_equal(['bycycle', 'bad'], spellbadword('My bycycle.')) |
| 123 | call assert_equal(['another', 'caps'], spellbadword('A sentence. another sentence')) |
| 124 | |
| 125 | set spelllang= |
| 126 | call assert_fails("call spellbadword('maxch')", 'E756:') |
Bram Moolenaar | 96fdf43 | 2020-09-11 18:11:50 +0200 | [diff] [blame] | 127 | call assert_fails("spelldump", 'E756:') |
Bram Moolenaar | 872e451 | 2018-07-20 23:36:26 +0200 | [diff] [blame] | 128 | |
| 129 | call delete('Xwords.spl') |
| 130 | call delete('Xwords') |
| 131 | set spelllang& |
| 132 | set spell& |
| 133 | endfunc |
| 134 | |
Bram Moolenaar | d569a9e | 2020-09-28 23:13:15 +0200 | [diff] [blame] | 135 | func Test_spell_file_missing() |
| 136 | let s:spell_file_missing = 0 |
| 137 | augroup TestSpellFileMissing |
| 138 | autocmd! SpellFileMissing * let s:spell_file_missing += 1 |
| 139 | augroup END |
| 140 | |
| 141 | set spell spelllang=ab_cd |
| 142 | let messages = GetMessages() |
| 143 | call assert_equal('Warning: Cannot find word list "ab.utf-8.spl" or "ab.ascii.spl"', messages[-1]) |
| 144 | call assert_equal(1, s:spell_file_missing) |
| 145 | |
| 146 | new XTestSpellFileMissing |
| 147 | augroup TestSpellFileMissing |
| 148 | autocmd! SpellFileMissing * bwipe |
| 149 | augroup END |
| 150 | call assert_fails('set spell spelllang=ab_cd', 'E797:') |
| 151 | |
Bram Moolenaar | fc9f0fd | 2022-06-15 16:57:44 +0100 | [diff] [blame] | 152 | " clean up |
| 153 | augroup TestSpellFileMissing |
| 154 | autocmd! SpellFileMissing |
| 155 | augroup END |
Bram Moolenaar | d569a9e | 2020-09-28 23:13:15 +0200 | [diff] [blame] | 156 | augroup! TestSpellFileMissing |
| 157 | unlet s:spell_file_missing |
| 158 | set spell& spelllang& |
| 159 | %bwipe! |
| 160 | endfunc |
| 161 | |
Bram Moolenaar | f12f002 | 2020-10-07 12:58:44 +0200 | [diff] [blame] | 162 | func Test_spelldump() |
Bram Moolenaar | fc9f0fd | 2022-06-15 16:57:44 +0100 | [diff] [blame] | 163 | " In case the spell file is not found avoid getting the download dialog, we |
| 164 | " would get stuck at the prompt. |
| 165 | let g:en_not_found = 0 |
| 166 | augroup TestSpellFileMissing |
| 167 | au! SpellFileMissing * let g:en_not_found = 1 |
| 168 | augroup END |
Bram Moolenaar | f12f002 | 2020-10-07 12:58:44 +0200 | [diff] [blame] | 169 | set spell spelllang=en |
| 170 | spellrare! emacs |
Bram Moolenaar | fc9f0fd | 2022-06-15 16:57:44 +0100 | [diff] [blame] | 171 | if g:en_not_found |
| 172 | call assert_report("Could not find English spell file") |
| 173 | else |
| 174 | spelldump |
Bram Moolenaar | f12f002 | 2020-10-07 12:58:44 +0200 | [diff] [blame] | 175 | |
Bram Moolenaar | fc9f0fd | 2022-06-15 16:57:44 +0100 | [diff] [blame] | 176 | " Check assumption about region: 1: us, 2: au, 3: ca, 4: gb, 5: nz. |
| 177 | call assert_equal('/regions=usaucagbnz', getline(1)) |
| 178 | call assert_notequal(0, search('^theater/1$')) " US English only. |
| 179 | call assert_notequal(0, search('^theatre/2345$')) " AU, CA, GB or NZ English. |
Bram Moolenaar | f12f002 | 2020-10-07 12:58:44 +0200 | [diff] [blame] | 180 | |
Bram Moolenaar | fc9f0fd | 2022-06-15 16:57:44 +0100 | [diff] [blame] | 181 | call assert_notequal(0, search('^emacs/?$')) " ? for a rare word. |
| 182 | call assert_notequal(0, search('^the the/!$')) " ! for a wrong word. |
| 183 | endif |
Bram Moolenaar | f12f002 | 2020-10-07 12:58:44 +0200 | [diff] [blame] | 184 | |
Bram Moolenaar | fc9f0fd | 2022-06-15 16:57:44 +0100 | [diff] [blame] | 185 | " clean up |
| 186 | unlet g:en_not_found |
| 187 | augroup TestSpellFileMissing |
| 188 | autocmd! SpellFileMissing |
| 189 | augroup END |
| 190 | augroup! TestSpellFileMissing |
Bram Moolenaar | f12f002 | 2020-10-07 12:58:44 +0200 | [diff] [blame] | 191 | bwipe |
| 192 | set spell& |
| 193 | endfunc |
| 194 | |
| 195 | func Test_spelldump_bang() |
| 196 | new |
| 197 | call setline(1, 'This is a sample sentence.') |
| 198 | redraw |
Bram Moolenaar | fc9f0fd | 2022-06-15 16:57:44 +0100 | [diff] [blame] | 199 | |
| 200 | " In case the spell file is not found avoid getting the download dialog, we |
| 201 | " would get stuck at the prompt. |
| 202 | let g:en_not_found = 0 |
| 203 | augroup TestSpellFileMissing |
| 204 | au! SpellFileMissing * let g:en_not_found = 1 |
| 205 | augroup END |
| 206 | |
Bram Moolenaar | f12f002 | 2020-10-07 12:58:44 +0200 | [diff] [blame] | 207 | set spell |
Bram Moolenaar | f12f002 | 2020-10-07 12:58:44 +0200 | [diff] [blame] | 208 | |
Bram Moolenaar | fc9f0fd | 2022-06-15 16:57:44 +0100 | [diff] [blame] | 209 | if g:en_not_found |
| 210 | call assert_report("Could not find English spell file") |
| 211 | else |
| 212 | redraw |
| 213 | spelldump! |
Bram Moolenaar | f12f002 | 2020-10-07 12:58:44 +0200 | [diff] [blame] | 214 | |
Bram Moolenaar | fc9f0fd | 2022-06-15 16:57:44 +0100 | [diff] [blame] | 215 | " :spelldump! includes the number of times a word was found while updating |
| 216 | " the screen. |
| 217 | " Common word count starts at 10, regular word count starts at 0. |
| 218 | call assert_notequal(0, search("^is\t11$")) " common word found once. |
| 219 | call assert_notequal(0, search("^the\t10$")) " common word never found. |
| 220 | call assert_notequal(0, search("^sample\t1$")) " regular word found once. |
| 221 | call assert_equal(0, search("^screen\t")) " regular word never found. |
| 222 | endif |
| 223 | |
| 224 | " clean up |
| 225 | unlet g:en_not_found |
| 226 | augroup TestSpellFileMissing |
| 227 | autocmd! SpellFileMissing |
| 228 | augroup END |
| 229 | augroup! TestSpellFileMissing |
Bram Moolenaar | f12f002 | 2020-10-07 12:58:44 +0200 | [diff] [blame] | 230 | %bwipe! |
| 231 | set spell& |
| 232 | endfunc |
| 233 | |
Bram Moolenaar | 8c7ad36 | 2020-09-27 13:58:38 +0200 | [diff] [blame] | 234 | func Test_spelllang_inv_region() |
| 235 | set spell spelllang=en_xx |
| 236 | let messages = GetMessages() |
| 237 | call assert_equal('Warning: region xx not supported', messages[-1]) |
| 238 | set spell& spelllang& |
| 239 | endfunc |
| 240 | |
| 241 | func Test_compl_with_CTRL_X_CTRL_K_using_spell() |
| 242 | " When spell checking is enabled and 'dictionary' is empty, |
| 243 | " CTRL-X CTRL-K in insert mode completes using the spelling dictionary. |
| 244 | new |
| 245 | set spell spelllang=en dictionary= |
| 246 | |
| 247 | set ignorecase |
| 248 | call feedkeys("Senglis\<c-x>\<c-k>\<esc>", 'tnx') |
| 249 | call assert_equal(['English'], getline(1, '$')) |
| 250 | call feedkeys("SEnglis\<c-x>\<c-k>\<esc>", 'tnx') |
| 251 | call assert_equal(['English'], getline(1, '$')) |
| 252 | |
| 253 | set noignorecase |
| 254 | call feedkeys("Senglis\<c-x>\<c-k>\<esc>", 'tnx') |
| 255 | call assert_equal(['englis'], getline(1, '$')) |
| 256 | call feedkeys("SEnglis\<c-x>\<c-k>\<esc>", 'tnx') |
| 257 | call assert_equal(['English'], getline(1, '$')) |
| 258 | |
| 259 | set spelllang=en_us |
| 260 | call feedkeys("Stheat\<c-x>\<c-k>\<esc>", 'tnx') |
| 261 | call assert_equal(['theater'], getline(1, '$')) |
| 262 | set spelllang=en_gb |
| 263 | call feedkeys("Stheat\<c-x>\<c-k>\<esc>", 'tnx') |
| 264 | " FIXME: commented out, expected theatre bug got theater. See issue #7025. |
| 265 | " call assert_equal(['theatre'], getline(1, '$')) |
| 266 | |
| 267 | bwipe! |
| 268 | set spell& spelllang& dictionary& ignorecase& |
| 269 | endfunc |
| 270 | |
Bram Moolenaar | 545cb79 | 2017-05-23 11:31:22 +0200 | [diff] [blame] | 271 | func Test_spellreall() |
| 272 | new |
| 273 | set spell |
| 274 | call assert_fails('spellrepall', 'E752:') |
| 275 | call setline(1, ['A speling mistake. The same speling mistake.', |
Bram Moolenaar | d2c061d | 2017-06-22 21:42:49 +0200 | [diff] [blame] | 276 | \ 'Another speling mistake.']) |
Bram Moolenaar | 545cb79 | 2017-05-23 11:31:22 +0200 | [diff] [blame] | 277 | call feedkeys(']s1z=', 'tx') |
| 278 | call assert_equal('A spelling mistake. The same speling mistake.', getline(1)) |
| 279 | call assert_equal('Another speling mistake.', getline(2)) |
| 280 | spellrepall |
| 281 | call assert_equal('A spelling mistake. The same spelling mistake.', getline(1)) |
| 282 | call assert_equal('Another spelling mistake.', getline(2)) |
| 283 | call assert_fails('spellrepall', 'E753:') |
| 284 | set spell& |
| 285 | bwipe! |
| 286 | endfunc |
Bram Moolenaar | d2c061d | 2017-06-22 21:42:49 +0200 | [diff] [blame] | 287 | |
Bram Moolenaar | 54e5fed | 2022-07-04 13:37:07 +0100 | [diff] [blame] | 288 | func Test_spell_dump_word_length() |
| 289 | " this was running over MAXWLEN |
| 290 | new |
| 291 | noremap 0 0a0zW0000000 |
| 292 | sil! norm 0z=0 |
| 293 | sil norm 0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 |
| 294 | sil! norm 0z=0 |
| 295 | |
| 296 | bwipe! |
| 297 | nunmap 0 |
| 298 | endfunc |
| 299 | |
Bram Moolenaar | e9a8d1f | 2019-12-25 13:36:36 +0100 | [diff] [blame] | 300 | " Test spellsuggest({word} [, {max} [, {capital}]]) |
| 301 | func Test_spellsuggest() |
Bram Moolenaar | 152e79e | 2020-06-10 15:32:08 +0200 | [diff] [blame] | 302 | " Verify suggestions are given even when spell checking is not enabled. |
Bram Moolenaar | e9a8d1f | 2019-12-25 13:36:36 +0100 | [diff] [blame] | 303 | set nospell |
Bram Moolenaar | 152e79e | 2020-06-10 15:32:08 +0200 | [diff] [blame] | 304 | call assert_equal(['march', 'March'], spellsuggest('marrch', 2)) |
Bram Moolenaar | e9a8d1f | 2019-12-25 13:36:36 +0100 | [diff] [blame] | 305 | |
| 306 | set spell |
| 307 | |
| 308 | " With 1 argument. |
Bram Moolenaar | 7673405 | 2019-12-26 14:30:15 +0100 | [diff] [blame] | 309 | call assert_equal(['march', 'March'], spellsuggest('marrch')[0:1]) |
Bram Moolenaar | e9a8d1f | 2019-12-25 13:36:36 +0100 | [diff] [blame] | 310 | |
| 311 | " With 2 arguments. |
Bram Moolenaar | 7673405 | 2019-12-26 14:30:15 +0100 | [diff] [blame] | 312 | call assert_equal(['march', 'March'], spellsuggest('marrch', 2)) |
Bram Moolenaar | e9a8d1f | 2019-12-25 13:36:36 +0100 | [diff] [blame] | 313 | |
| 314 | " With 3 arguments. |
Bram Moolenaar | 7673405 | 2019-12-26 14:30:15 +0100 | [diff] [blame] | 315 | call assert_equal(['march'], spellsuggest('marrch', 1, 0)) |
| 316 | call assert_equal(['March'], spellsuggest('marrch', 1, 1)) |
Bram Moolenaar | e9a8d1f | 2019-12-25 13:36:36 +0100 | [diff] [blame] | 317 | |
| 318 | " Test with digits and hyphen. |
| 319 | call assert_equal('Carbon-14', spellsuggest('Carbon-15')[0]) |
| 320 | |
| 321 | " Comment taken from spellsuggest.c explains the following test cases: |
| 322 | " |
| 323 | " If there are more UPPER than lower case letters suggest an |
| 324 | " ALLCAP word. Otherwise, if the first letter is UPPER then |
| 325 | " suggest ONECAP. Exception: "ALl" most likely should be "All", |
| 326 | " require three upper case letters. |
Bram Moolenaar | 7673405 | 2019-12-26 14:30:15 +0100 | [diff] [blame] | 327 | call assert_equal(['THIRD', 'third'], spellsuggest('thIRD', 2)) |
| 328 | call assert_equal(['third', 'THIRD'], spellsuggest('tHIrd', 2)) |
| 329 | call assert_equal(['Third'], spellsuggest('THird', 1)) |
Bram Moolenaar | e9a8d1f | 2019-12-25 13:36:36 +0100 | [diff] [blame] | 330 | call assert_equal(['All'], spellsuggest('ALl', 1)) |
| 331 | |
Dominique Pelle | f645ee4 | 2021-12-05 13:21:18 +0000 | [diff] [blame] | 332 | " Special suggestion for repeated 'the the'. |
| 333 | call assert_inrange(0, 2, index(spellsuggest('the the', 3), 'the')) |
| 334 | call assert_inrange(0, 2, index(spellsuggest('the the', 3), 'the')) |
| 335 | call assert_inrange(0, 2, index(spellsuggest('The the', 3), 'The')) |
| 336 | |
Bram Moolenaar | 0e05de4 | 2020-03-25 22:23:46 +0100 | [diff] [blame] | 337 | call assert_fails("call spellsuggest('maxch', [])", 'E745:') |
| 338 | call assert_fails("call spellsuggest('maxch', 2, [])", 'E745:') |
| 339 | |
Bram Moolenaar | 152e79e | 2020-06-10 15:32:08 +0200 | [diff] [blame] | 340 | set spelllang= |
| 341 | call assert_fails("call spellsuggest('maxch')", 'E756:') |
| 342 | set spelllang& |
| 343 | |
Bram Moolenaar | e9a8d1f | 2019-12-25 13:36:36 +0100 | [diff] [blame] | 344 | set spell& |
| 345 | endfunc |
| 346 | |
| 347 | " Test 'spellsuggest' option with methods fast, best and double. |
| 348 | func Test_spellsuggest_option_methods() |
| 349 | set spell |
| 350 | |
Bram Moolenaar | 7673405 | 2019-12-26 14:30:15 +0100 | [diff] [blame] | 351 | for e in ['latin1', 'utf-8'] |
| 352 | exe 'set encoding=' .. e |
Bram Moolenaar | e9a8d1f | 2019-12-25 13:36:36 +0100 | [diff] [blame] | 353 | |
Bram Moolenaar | 7673405 | 2019-12-26 14:30:15 +0100 | [diff] [blame] | 354 | set spellsuggest=fast |
| 355 | call assert_equal(['Stick', 'Stitch'], spellsuggest('Stich', 2), e) |
Bram Moolenaar | e9a8d1f | 2019-12-25 13:36:36 +0100 | [diff] [blame] | 356 | |
Bram Moolenaar | 7673405 | 2019-12-26 14:30:15 +0100 | [diff] [blame] | 357 | " With best or double option, "Stitch" should become the top suggestion |
| 358 | " because of better phonetic matching. |
| 359 | set spellsuggest=best |
| 360 | call assert_equal(['Stitch', 'Stick'], spellsuggest('Stich', 2), e) |
Bram Moolenaar | e9a8d1f | 2019-12-25 13:36:36 +0100 | [diff] [blame] | 361 | |
Bram Moolenaar | 7673405 | 2019-12-26 14:30:15 +0100 | [diff] [blame] | 362 | set spellsuggest=double |
| 363 | call assert_equal(['Stitch', 'Stick'], spellsuggest('Stich', 2), e) |
| 364 | endfor |
| 365 | |
| 366 | set spell& spellsuggest& encoding& |
Bram Moolenaar | e9a8d1f | 2019-12-25 13:36:36 +0100 | [diff] [blame] | 367 | endfunc |
| 368 | |
| 369 | " Test 'spellsuggest' option with value file:{filename} |
| 370 | func Test_spellsuggest_option_file() |
| 371 | set spell spellsuggest=file:Xspellsuggest |
| 372 | call writefile(['emacs/vim', |
| 373 | \ 'theribal/terrible', |
| 374 | \ 'teribal/terrrible', |
| 375 | \ 'terribal'], |
| 376 | \ 'Xspellsuggest') |
| 377 | |
| 378 | call assert_equal(['vim'], spellsuggest('emacs', 2)) |
| 379 | call assert_equal(['terrible'], spellsuggest('theribal',2)) |
| 380 | |
| 381 | " If the suggestion is misspelled (*terrrible* with 3 r), |
| 382 | " it should not be proposed. |
| 383 | " The entry for "terribal" should be ignored because of missing slash. |
| 384 | call assert_equal([], spellsuggest('teribal', 2)) |
| 385 | call assert_equal([], spellsuggest('terribal', 2)) |
| 386 | |
| 387 | set spell spellsuggest=best,file:Xspellsuggest |
| 388 | call assert_equal(['vim', 'Emacs'], spellsuggest('emacs', 2)) |
| 389 | call assert_equal(['terrible', 'tribal'], spellsuggest('theribal', 2)) |
| 390 | call assert_equal(['tribal'], spellsuggest('teribal', 1)) |
| 391 | call assert_equal(['tribal'], spellsuggest('terribal', 1)) |
| 392 | |
| 393 | call delete('Xspellsuggest') |
| 394 | call assert_fails("call spellsuggest('vim')", "E484: Can't open file Xspellsuggest") |
| 395 | |
| 396 | set spellsuggest& spell& |
| 397 | endfunc |
| 398 | |
| 399 | " Test 'spellsuggest' option with value {number} |
| 400 | " to limit the number of suggestions |
| 401 | func Test_spellsuggest_option_number() |
| 402 | set spell spellsuggest=2,best |
| 403 | new |
| 404 | |
| 405 | " We limited the number of suggestions to 2, so selecting |
| 406 | " the 1st and 2nd suggestion should correct the word, but |
| 407 | " selecting a 3rd suggestion should do nothing. |
Bram Moolenaar | 7673405 | 2019-12-26 14:30:15 +0100 | [diff] [blame] | 408 | call setline(1, 'A baord') |
| 409 | norm $1z= |
| 410 | call assert_equal('A board', getline(1)) |
Bram Moolenaar | e9a8d1f | 2019-12-25 13:36:36 +0100 | [diff] [blame] | 411 | |
Bram Moolenaar | 7673405 | 2019-12-26 14:30:15 +0100 | [diff] [blame] | 412 | call setline(1, 'A baord') |
| 413 | norm $2z= |
| 414 | call assert_equal('A bard', getline(1)) |
Bram Moolenaar | e9a8d1f | 2019-12-25 13:36:36 +0100 | [diff] [blame] | 415 | |
Bram Moolenaar | 7673405 | 2019-12-26 14:30:15 +0100 | [diff] [blame] | 416 | call setline(1, 'A baord') |
| 417 | norm $3z= |
| 418 | call assert_equal('A baord', getline(1)) |
Bram Moolenaar | e9a8d1f | 2019-12-25 13:36:36 +0100 | [diff] [blame] | 419 | |
Bram Moolenaar | 7673405 | 2019-12-26 14:30:15 +0100 | [diff] [blame] | 420 | let a = execute('norm $z=') |
Bram Moolenaar | e9a8d1f | 2019-12-25 13:36:36 +0100 | [diff] [blame] | 421 | call assert_equal( |
| 422 | \ "\n" |
Bram Moolenaar | 7673405 | 2019-12-26 14:30:15 +0100 | [diff] [blame] | 423 | \ .. "Change \"baord\" to:\n" |
| 424 | \ .. " 1 \"board\"\n" |
| 425 | \ .. " 2 \"bard\"\n" |
Bram Moolenaar | d281b7c | 2020-06-10 16:39:32 +0200 | [diff] [blame] | 426 | \ .. "Type number and <Enter> or click with the mouse (q or empty cancels): ", a) |
Bram Moolenaar | e9a8d1f | 2019-12-25 13:36:36 +0100 | [diff] [blame] | 427 | |
| 428 | set spell spellsuggest=0 |
Bram Moolenaar | 7673405 | 2019-12-26 14:30:15 +0100 | [diff] [blame] | 429 | call assert_equal("\nSorry, no suggestions", execute('norm $z=')) |
Bram Moolenaar | e9a8d1f | 2019-12-25 13:36:36 +0100 | [diff] [blame] | 430 | |
| 431 | " Unlike z=, function spellsuggest(...) should not be affected by the |
| 432 | " max number of suggestions (2) set by the 'spellsuggest' option. |
Bram Moolenaar | 7673405 | 2019-12-26 14:30:15 +0100 | [diff] [blame] | 433 | call assert_equal(['board', 'bard', 'broad'], spellsuggest('baord', 3)) |
Bram Moolenaar | e9a8d1f | 2019-12-25 13:36:36 +0100 | [diff] [blame] | 434 | |
| 435 | set spellsuggest& spell& |
| 436 | bwipe! |
| 437 | endfunc |
| 438 | |
| 439 | " Test 'spellsuggest' option with value expr:{expr} |
| 440 | func Test_spellsuggest_option_expr() |
| 441 | " A silly 'spellsuggest' function which makes suggestions all uppercase |
| 442 | " and makes the score of each suggestion the length of the suggested word. |
| 443 | " So shorter suggestions are preferred. |
| 444 | func MySuggest() |
| 445 | let spellsuggest_save = &spellsuggest |
Bram Moolenaar | 7673405 | 2019-12-26 14:30:15 +0100 | [diff] [blame] | 446 | set spellsuggest=3,best |
Bram Moolenaar | e9a8d1f | 2019-12-25 13:36:36 +0100 | [diff] [blame] | 447 | let result = map(spellsuggest(v:val, 3), "[toupper(v:val), len(v:val)]") |
| 448 | let &spellsuggest = spellsuggest_save |
| 449 | return result |
| 450 | endfunc |
| 451 | |
Bram Moolenaar | 7673405 | 2019-12-26 14:30:15 +0100 | [diff] [blame] | 452 | set spell spellsuggest=expr:MySuggest() |
| 453 | call assert_equal(['BARD', 'BOARD', 'BROAD'], spellsuggest('baord', 3)) |
Bram Moolenaar | e9a8d1f | 2019-12-25 13:36:36 +0100 | [diff] [blame] | 454 | |
| 455 | new |
Bram Moolenaar | 7673405 | 2019-12-26 14:30:15 +0100 | [diff] [blame] | 456 | call setline(1, 'baord') |
Bram Moolenaar | e9a8d1f | 2019-12-25 13:36:36 +0100 | [diff] [blame] | 457 | let a = execute('norm z=') |
| 458 | call assert_equal( |
| 459 | \ "\n" |
Bram Moolenaar | 7673405 | 2019-12-26 14:30:15 +0100 | [diff] [blame] | 460 | \ .. "Change \"baord\" to:\n" |
| 461 | \ .. " 1 \"BARD\"\n" |
| 462 | \ .. " 2 \"BOARD\"\n" |
| 463 | \ .. " 3 \"BROAD\"\n" |
Bram Moolenaar | d281b7c | 2020-06-10 16:39:32 +0200 | [diff] [blame] | 464 | \ .. "Type number and <Enter> or click with the mouse (q or empty cancels): ", a) |
Bram Moolenaar | e9a8d1f | 2019-12-25 13:36:36 +0100 | [diff] [blame] | 465 | |
| 466 | " With verbose, z= should show the score i.e. word length with |
| 467 | " our SpellSuggest() function. |
| 468 | set verbose=1 |
| 469 | let a = execute('norm z=') |
| 470 | call assert_equal( |
| 471 | \ "\n" |
Bram Moolenaar | 7673405 | 2019-12-26 14:30:15 +0100 | [diff] [blame] | 472 | \ .. "Change \"baord\" to:\n" |
| 473 | \ .. " 1 \"BARD\" (4 - 0)\n" |
| 474 | \ .. " 2 \"BOARD\" (5 - 0)\n" |
| 475 | \ .. " 3 \"BROAD\" (5 - 0)\n" |
Bram Moolenaar | d281b7c | 2020-06-10 16:39:32 +0200 | [diff] [blame] | 476 | \ .. "Type number and <Enter> or click with the mouse (q or empty cancels): ", a) |
Bram Moolenaar | e9a8d1f | 2019-12-25 13:36:36 +0100 | [diff] [blame] | 477 | |
| 478 | set spell& spellsuggest& verbose& |
| 479 | bwipe! |
| 480 | endfunc |
| 481 | |
Dominique Pelle | 81b573d | 2022-03-22 21:14:55 +0000 | [diff] [blame] | 482 | " Test for 'spellsuggest' expr errors |
Bram Moolenaar | 8dfcce3 | 2020-03-18 19:32:26 +0100 | [diff] [blame] | 483 | func Test_spellsuggest_expr_errors() |
| 484 | " 'spellsuggest' |
| 485 | func MySuggest() |
| 486 | return range(3) |
| 487 | endfunc |
| 488 | set spell spellsuggest=expr:MySuggest() |
| 489 | call assert_equal([], spellsuggest('baord', 3)) |
| 490 | |
| 491 | " Test for 'spellsuggest' expression returning a non-list value |
| 492 | func! MySuggest2() |
| 493 | return 'good' |
| 494 | endfunc |
| 495 | set spellsuggest=expr:MySuggest2() |
| 496 | call assert_equal([], spellsuggest('baord')) |
| 497 | |
| 498 | " Test for 'spellsuggest' expression returning a list with dict values |
| 499 | func! MySuggest3() |
| 500 | return [[{}, {}]] |
| 501 | endfunc |
| 502 | set spellsuggest=expr:MySuggest3() |
Bram Moolenaar | 9b7bf9e | 2020-07-11 22:14:59 +0200 | [diff] [blame] | 503 | call assert_fails("call spellsuggest('baord')", 'E731:') |
Bram Moolenaar | 8dfcce3 | 2020-03-18 19:32:26 +0100 | [diff] [blame] | 504 | |
| 505 | set nospell spellsuggest& |
| 506 | delfunc MySuggest |
| 507 | delfunc MySuggest2 |
| 508 | delfunc MySuggest3 |
| 509 | endfunc |
| 510 | |
Bram Moolenaar | 585ee07 | 2022-01-29 11:22:17 +0000 | [diff] [blame] | 511 | func Test_spellsuggest_timeout() |
| 512 | set spellsuggest=timeout:30 |
| 513 | set spellsuggest=timeout:-123 |
| 514 | set spellsuggest=timeout:999999 |
| 515 | call assert_fails('set spellsuggest=timeout', 'E474:') |
| 516 | call assert_fails('set spellsuggest=timeout:x', 'E474:') |
| 517 | call assert_fails('set spellsuggest=timeout:-x', 'E474:') |
| 518 | call assert_fails('set spellsuggest=timeout:--9', 'E474:') |
| 519 | endfunc |
| 520 | |
Bram Moolenaar | 5c68617 | 2022-03-13 20:12:25 +0000 | [diff] [blame] | 521 | func Test_spellsuggest_visual_end_of_line() |
| 522 | let enc_save = &encoding |
| 523 | set encoding=iso8859 |
| 524 | |
| 525 | " This was reading beyond the end of the line. |
| 526 | norm R00000000000 |
| 527 | sil norm 0 |
| 528 | sil! norm i00000) |
| 529 | sil! norm i00000) |
| 530 | call feedkeys("\<CR>") |
| 531 | norm z= |
| 532 | |
| 533 | let &encoding = enc_save |
| 534 | endfunc |
| 535 | |
Bram Moolenaar | 9049b68 | 2018-08-31 22:26:53 +0200 | [diff] [blame] | 536 | func Test_spellinfo() |
| 537 | new |
Bram Moolenaar | c25e702 | 2019-10-10 14:08:26 +0200 | [diff] [blame] | 538 | let runtime = substitute($VIMRUNTIME, '\\', '/', 'g') |
Bram Moolenaar | 9049b68 | 2018-08-31 22:26:53 +0200 | [diff] [blame] | 539 | |
| 540 | set enc=latin1 spell spelllang=en |
Bram Moolenaar | c25e702 | 2019-10-10 14:08:26 +0200 | [diff] [blame] | 541 | call assert_match("^\nfile: " .. runtime .. "/spell/en.latin1.spl\n$", execute('spellinfo')) |
Bram Moolenaar | 9049b68 | 2018-08-31 22:26:53 +0200 | [diff] [blame] | 542 | |
| 543 | set enc=cp1250 spell spelllang=en |
Bram Moolenaar | c25e702 | 2019-10-10 14:08:26 +0200 | [diff] [blame] | 544 | call assert_match("^\nfile: " .. runtime .. "/spell/en.ascii.spl\n$", execute('spellinfo')) |
Bram Moolenaar | 9049b68 | 2018-08-31 22:26:53 +0200 | [diff] [blame] | 545 | |
Bram Moolenaar | 30276f2 | 2019-01-24 17:59:39 +0100 | [diff] [blame] | 546 | set enc=utf-8 spell spelllang=en |
Bram Moolenaar | c25e702 | 2019-10-10 14:08:26 +0200 | [diff] [blame] | 547 | call assert_match("^\nfile: " .. runtime .. "/spell/en.utf-8.spl\n$", execute('spellinfo')) |
Bram Moolenaar | 9049b68 | 2018-08-31 22:26:53 +0200 | [diff] [blame] | 548 | |
| 549 | set enc=latin1 spell spelllang=en_us,en_nz |
| 550 | call assert_match("^\n" . |
Bram Moolenaar | c25e702 | 2019-10-10 14:08:26 +0200 | [diff] [blame] | 551 | \ "file: " .. runtime .. "/spell/en.latin1.spl\n" . |
| 552 | \ "file: " .. runtime.. "/spell/en.latin1.spl\n$", execute('spellinfo')) |
Bram Moolenaar | 9049b68 | 2018-08-31 22:26:53 +0200 | [diff] [blame] | 553 | |
| 554 | set spell spelllang= |
| 555 | call assert_fails('spellinfo', 'E756:') |
| 556 | |
| 557 | set nospell spelllang=en |
| 558 | call assert_fails('spellinfo', 'E756:') |
| 559 | |
Bram Moolenaar | 8f130ed | 2019-04-10 22:15:19 +0200 | [diff] [blame] | 560 | call assert_fails('set spelllang=foo/bar', 'E474:') |
| 561 | call assert_fails('set spelllang=foo\ bar', 'E474:') |
| 562 | call assert_fails("set spelllang=foo\\\nbar", 'E474:') |
| 563 | call assert_fails("set spelllang=foo\\\rbar", 'E474:') |
| 564 | call assert_fails("set spelllang=foo+bar", 'E474:') |
| 565 | |
Bram Moolenaar | 9049b68 | 2018-08-31 22:26:53 +0200 | [diff] [blame] | 566 | set enc& spell& spelllang& |
| 567 | bwipe |
| 568 | endfunc |
| 569 | |
Bram Moolenaar | d2c061d | 2017-06-22 21:42:49 +0200 | [diff] [blame] | 570 | func Test_zz_basic() |
| 571 | call LoadAffAndDic(g:test_data_aff1, g:test_data_dic1) |
| 572 | call RunGoodBad("wrong OK puts. Test the end", |
| 573 | \ "bad: inputs comment ok Ok. test d\xE9\xF4l end the", |
| 574 | \["Comment", "deol", "d\xE9\xF4r", "input", "OK", "output", "outputs", "outtest", "put", "puts", |
| 575 | \ "test", "testen", "testn", "the end", "uk", "wrong"], |
| 576 | \[ |
| 577 | \ ["bad", ["put", "uk", "OK"]], |
| 578 | \ ["inputs", ["input", "puts", "outputs"]], |
| 579 | \ ["comment", ["Comment", "outtest", "the end"]], |
| 580 | \ ["ok", ["OK", "uk", "put"]], |
| 581 | \ ["Ok", ["OK", "Uk", "Put"]], |
| 582 | \ ["test", ["Test", "testn", "testen"]], |
| 583 | \ ["d\xE9\xF4l", ["deol", "d\xE9\xF4r", "test"]], |
| 584 | \ ["end", ["put", "uk", "test"]], |
| 585 | \ ["the", ["put", "uk", "test"]], |
| 586 | \ ] |
| 587 | \ ) |
| 588 | |
| 589 | call assert_equal("gebletegek", soundfold('goobledygoook')) |
Bram Moolenaar | f6ed61e | 2019-09-07 19:05:09 +0200 | [diff] [blame] | 590 | call assert_equal("kepereneven", 'kóopërÿnôven'->soundfold()) |
Bram Moolenaar | d2c061d | 2017-06-22 21:42:49 +0200 | [diff] [blame] | 591 | call assert_equal("everles gesvets etele", soundfold('oeverloos gezwets edale')) |
| 592 | endfunc |
| 593 | |
| 594 | " Postponed prefixes |
| 595 | func Test_zz_prefixes() |
| 596 | call LoadAffAndDic(g:test_data_aff2, g:test_data_dic1) |
| 597 | call RunGoodBad("puts", |
| 598 | \ "bad: inputs comment ok Ok end the. test d\xE9\xF4l", |
| 599 | \ ["Comment", "deol", "d\xE9\xF4r", "OK", "put", "input", "output", "puts", "outputs", "test", "outtest", "testen", "testn", "the end", "uk", "wrong"], |
| 600 | \ [ |
| 601 | \ ["bad", ["put", "uk", "OK"]], |
| 602 | \ ["inputs", ["input", "puts", "outputs"]], |
| 603 | \ ["comment", ["Comment"]], |
| 604 | \ ["ok", ["OK", "uk", "put"]], |
| 605 | \ ["Ok", ["OK", "Uk", "Put"]], |
| 606 | \ ["end", ["put", "uk", "deol"]], |
| 607 | \ ["the", ["put", "uk", "test"]], |
| 608 | \ ["test", ["Test", "testn", "testen"]], |
| 609 | \ ["d\xE9\xF4l", ["deol", "d\xE9\xF4r", "test"]], |
| 610 | \ ]) |
| 611 | endfunc |
| 612 | |
| 613 | "Compound words |
| 614 | func Test_zz_compound() |
| 615 | call LoadAffAndDic(g:test_data_aff3, g:test_data_dic3) |
| 616 | call RunGoodBad("foo m\xEF foobar foofoobar barfoo barbarfoo", |
| 617 | \ "bad: bar la foom\xEF barm\xEF m\xEFfoo m\xEFbar m\xEFm\xEF lala m\xEFla lam\xEF foola labar", |
| 618 | \ ["foo", "m\xEF"], |
| 619 | \ [ |
| 620 | \ ["bad", ["foo", "m\xEF"]], |
| 621 | \ ["bar", ["barfoo", "foobar", "foo"]], |
| 622 | \ ["la", ["m\xEF", "foo"]], |
| 623 | \ ["foom\xEF", ["foo m\xEF", "foo", "foofoo"]], |
| 624 | \ ["barm\xEF", ["barfoo", "m\xEF", "barbar"]], |
| 625 | \ ["m\xEFfoo", ["m\xEF foo", "foo", "foofoo"]], |
| 626 | \ ["m\xEFbar", ["foobar", "barbar", "m\xEF"]], |
| 627 | \ ["m\xEFm\xEF", ["m\xEF m\xEF", "m\xEF"]], |
| 628 | \ ["lala", []], |
| 629 | \ ["m\xEFla", ["m\xEF", "m\xEF m\xEF"]], |
| 630 | \ ["lam\xEF", ["m\xEF", "m\xEF m\xEF"]], |
| 631 | \ ["foola", ["foo", "foobar", "foofoo"]], |
| 632 | \ ["labar", ["barbar", "foobar"]], |
| 633 | \ ]) |
| 634 | |
| 635 | call LoadAffAndDic(g:test_data_aff4, g:test_data_dic4) |
| 636 | 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", |
| 637 | \ "bad: wordutilize pro borkborkborkborkborkbork tomatotomatotomato endstart endend startstart wordend wordstart preborkprebork preborkpreborkbork startwordwordwordwordend borkpreborkpreborkbork utilsbork startnouword", |
| 638 | \ ["bork", "prebork", "end", "pro-ok", "start", "tomato", "util", "utilize", "utils", "word", "nouword"], |
| 639 | \ [ |
| 640 | \ ["bad", ["end", "bork", "word"]], |
| 641 | \ ["wordutilize", ["word utilize", "wordutils", "wordutil"]], |
| 642 | \ ["pro", ["bork", "word", "end"]], |
| 643 | \ ["borkborkborkborkborkbork", ["bork borkborkborkborkbork", "borkbork borkborkborkbork", "borkborkbork borkborkbork"]], |
| 644 | \ ["tomatotomatotomato", ["tomato tomatotomato", "tomatotomato tomato", "tomato tomato tomato"]], |
| 645 | \ ["endstart", ["end start", "start"]], |
| 646 | \ ["endend", ["end end", "end"]], |
| 647 | \ ["startstart", ["start start"]], |
| 648 | \ ["wordend", ["word end", "word", "wordword"]], |
| 649 | \ ["wordstart", ["word start", "bork start"]], |
| 650 | \ ["preborkprebork", ["prebork prebork", "preborkbork", "preborkborkbork"]], |
| 651 | \ ["preborkpreborkbork", ["prebork preborkbork", "preborkborkbork", "preborkborkborkbork"]], |
| 652 | \ ["startwordwordwordwordend", ["startwordwordwordword end", "startwordwordwordword", "start wordwordwordword end"]], |
| 653 | \ ["borkpreborkpreborkbork", ["bork preborkpreborkbork", "bork prebork preborkbork", "bork preborkprebork bork"]], |
| 654 | \ ["utilsbork", ["utilbork", "utils bork", "util bork"]], |
| 655 | \ ["startnouword", ["start nouword", "startword", "startborkword"]], |
| 656 | \ ]) |
| 657 | |
| 658 | endfunc |
| 659 | |
| 660 | "Test affix flags with two characters |
| 661 | func Test_zz_affix() |
| 662 | call LoadAffAndDic(g:test_data_aff5, g:test_data_dic5) |
| 663 | call RunGoodBad("fooa1 fooa\xE9 bar prebar barbork prebarbork startprebar start end startend startmiddleend nouend", |
| 664 | \ "bad: foo fooa2 prabar probarbirk middle startmiddle middleend endstart startprobar startnouend", |
| 665 | \ ["bar", "barbork", "end", "fooa1", "fooa\xE9", "nouend", "prebar", "prebarbork", "start"], |
| 666 | \ [ |
| 667 | \ ["bad", ["bar", "end", "fooa1"]], |
| 668 | \ ["foo", ["fooa1", "fooa\xE9", "bar"]], |
| 669 | \ ["fooa2", ["fooa1", "fooa\xE9", "bar"]], |
| 670 | \ ["prabar", ["prebar", "bar", "bar bar"]], |
| 671 | \ ["probarbirk", ["prebarbork"]], |
| 672 | \ ["middle", []], |
| 673 | \ ["startmiddle", ["startmiddleend", "startmiddlebar"]], |
| 674 | \ ["middleend", []], |
| 675 | \ ["endstart", ["end start", "start"]], |
| 676 | \ ["startprobar", ["startprebar", "start prebar", "startbar"]], |
| 677 | \ ["startnouend", ["start nouend", "startend"]], |
| 678 | \ ]) |
| 679 | |
| 680 | call LoadAffAndDic(g:test_data_aff6, g:test_data_dic6) |
| 681 | call RunGoodBad("meea1 meea\xE9 bar prebar barbork prebarbork leadprebar lead end leadend leadmiddleend", |
| 682 | \ "bad: mee meea2 prabar probarbirk middle leadmiddle middleend endlead leadprobar", |
| 683 | \ ["bar", "barbork", "end", "lead", "meea1", "meea\xE9", "prebar", "prebarbork"], |
| 684 | \ [ |
| 685 | \ ["bad", ["bar", "end", "lead"]], |
| 686 | \ ["mee", ["meea1", "meea\xE9", "bar"]], |
| 687 | \ ["meea2", ["meea1", "meea\xE9", "lead"]], |
| 688 | \ ["prabar", ["prebar", "bar", "leadbar"]], |
| 689 | \ ["probarbirk", ["prebarbork"]], |
| 690 | \ ["middle", []], |
| 691 | \ ["leadmiddle", ["leadmiddleend", "leadmiddlebar"]], |
| 692 | \ ["middleend", []], |
| 693 | \ ["endlead", ["end lead", "lead", "end end"]], |
| 694 | \ ["leadprobar", ["leadprebar", "lead prebar", "leadbar"]], |
| 695 | \ ]) |
| 696 | |
| 697 | call LoadAffAndDic(g:test_data_aff7, g:test_data_dic7) |
Bram Moolenaar | 3d2a47c | 2019-11-07 20:48:42 +0100 | [diff] [blame] | 698 | call RunGoodBad("meea1 meezero meea\xE9 bar prebar barmeat prebarmeat leadprebar lead tail leadtail leadmiddletail", |
Bram Moolenaar | d2c061d | 2017-06-22 21:42:49 +0200 | [diff] [blame] | 699 | \ "bad: mee meea2 prabar probarmaat middle leadmiddle middletail taillead leadprobar", |
Bram Moolenaar | 3d2a47c | 2019-11-07 20:48:42 +0100 | [diff] [blame] | 700 | \ ["bar", "barmeat", "lead", "meea1", "meea\xE9", "meezero", "prebar", "prebarmeat", "tail"], |
Bram Moolenaar | d2c061d | 2017-06-22 21:42:49 +0200 | [diff] [blame] | 701 | \ [ |
| 702 | \ ["bad", ["bar", "lead", "tail"]], |
| 703 | \ ["mee", ["meea1", "meea\xE9", "bar"]], |
| 704 | \ ["meea2", ["meea1", "meea\xE9", "lead"]], |
| 705 | \ ["prabar", ["prebar", "bar", "leadbar"]], |
| 706 | \ ["probarmaat", ["prebarmeat"]], |
| 707 | \ ["middle", []], |
| 708 | \ ["leadmiddle", ["leadmiddlebar"]], |
| 709 | \ ["middletail", []], |
| 710 | \ ["taillead", ["tail lead", "tail"]], |
| 711 | \ ["leadprobar", ["leadprebar", "lead prebar", "leadbar"]], |
| 712 | \ ]) |
| 713 | endfunc |
| 714 | |
| 715 | func Test_zz_NOSLITSUGS() |
| 716 | call LoadAffAndDic(g:test_data_aff8, g:test_data_dic8) |
| 717 | call RunGoodBad("foo bar faabar", "bad: foobar barfoo", |
| 718 | \ ["bar", "faabar", "foo"], |
| 719 | \ [ |
| 720 | \ ["bad", ["bar", "foo"]], |
| 721 | \ ["foobar", ["faabar", "foo bar", "bar"]], |
| 722 | \ ["barfoo", ["bar foo", "bar", "foo"]], |
| 723 | \ ]) |
| 724 | endfunc |
| 725 | |
| 726 | " Numbers |
| 727 | func Test_zz_Numbers() |
| 728 | call LoadAffAndDic(g:test_data_aff9, g:test_data_dic9) |
| 729 | call RunGoodBad("0b1011 0777 1234 0x01ff", "", |
| 730 | \ ["bar", "foo"], |
| 731 | \ [ |
| 732 | \ ]) |
| 733 | endfunc |
| 734 | |
Bram Moolenaar | 37ff4cf | 2019-11-17 20:10:20 +0100 | [diff] [blame] | 735 | " Affix flags |
| 736 | func Test_zz_affix_flags() |
| 737 | call LoadAffAndDic(g:test_data_aff10, g:test_data_dic10) |
| 738 | call RunGoodBad("drink drinkable drinkables drinktable drinkabletable", |
| 739 | \ "bad: drinks drinkstable drinkablestable", |
| 740 | \ ["drink", "drinkable", "drinkables", "table"], |
| 741 | \ [['bad', []], |
| 742 | \ ['drinks', ['drink']], |
| 743 | \ ['drinkstable', ['drinktable', 'drinkable', 'drink table']], |
| 744 | \ ['drinkablestable', ['drinkabletable', 'drinkables table', 'drinkable table']], |
| 745 | \ ]) |
| 746 | endfunc |
| 747 | |
Bram Moolenaar | d2c061d | 2017-06-22 21:42:49 +0200 | [diff] [blame] | 748 | function FirstSpellWord() |
| 749 | call feedkeys("/^start:\n", 'tx') |
| 750 | normal ]smm |
| 751 | let [str, a] = spellbadword() |
| 752 | return str |
| 753 | endfunc |
| 754 | |
| 755 | function SecondSpellWord() |
| 756 | normal `m]s |
| 757 | let [str, a] = spellbadword() |
| 758 | return str |
| 759 | endfunc |
| 760 | |
| 761 | "Test with SAL instead of SOFO items; test automatic reloading |
| 762 | func Test_zz_sal_and_addition() |
| 763 | set enc=latin1 |
| 764 | set spellfile= |
Bram Moolenaar | 1a0f200 | 2017-07-28 15:38:10 +0200 | [diff] [blame] | 765 | call writefile(g:test_data_dic1, "Xtest.dic") |
Bram Moolenaar | d2c061d | 2017-06-22 21:42:49 +0200 | [diff] [blame] | 766 | call writefile(g:test_data_aff_sal, "Xtest.aff") |
| 767 | mkspell! Xtest Xtest |
| 768 | set spl=Xtest.latin1.spl spell |
| 769 | call assert_equal('kbltykk', soundfold('goobledygoook')) |
| 770 | call assert_equal('kprnfn', soundfold('kóopërÿnôven')) |
| 771 | call assert_equal('*fls kswts tl', soundfold('oeverloos gezwets edale')) |
| 772 | |
| 773 | "also use an addition file |
| 774 | call writefile(["/regions=usgbnz", "elequint/2", "elekwint/3"], "Xtest.latin1.add") |
| 775 | mkspell! Xtest.latin1.add.spl Xtest.latin1.add |
| 776 | |
| 777 | bwipe! |
| 778 | call setline(1, ["start: elequint test elekwint test elekwent asdf"]) |
| 779 | |
| 780 | set spellfile=Xtest.latin1.add |
| 781 | call assert_equal("elekwent", FirstSpellWord()) |
| 782 | |
| 783 | set spl=Xtest_us.latin1.spl |
| 784 | call assert_equal("elequint", FirstSpellWord()) |
| 785 | call assert_equal("elekwint", SecondSpellWord()) |
| 786 | |
| 787 | set spl=Xtest_gb.latin1.spl |
| 788 | call assert_equal("elekwint", FirstSpellWord()) |
| 789 | call assert_equal("elekwent", SecondSpellWord()) |
| 790 | |
| 791 | set spl=Xtest_nz.latin1.spl |
| 792 | call assert_equal("elequint", FirstSpellWord()) |
| 793 | call assert_equal("elekwent", SecondSpellWord()) |
| 794 | |
| 795 | set spl=Xtest_ca.latin1.spl |
| 796 | call assert_equal("elequint", FirstSpellWord()) |
| 797 | call assert_equal("elekwint", SecondSpellWord()) |
zeertzjq | 288ed23 | 2022-07-04 11:03:07 +0100 | [diff] [blame] | 798 | |
| 799 | bwipe! |
| 800 | set spellfile= |
| 801 | set spl& |
Bram Moolenaar | d2c061d | 2017-06-22 21:42:49 +0200 | [diff] [blame] | 802 | endfunc |
| 803 | |
Bram Moolenaar | 862f1e1 | 2019-04-10 22:33:41 +0200 | [diff] [blame] | 804 | func Test_spellfile_value() |
| 805 | set spellfile=Xdir/Xtest.latin1.add |
| 806 | set spellfile=Xdir/Xtest.utf-8.add,Xtest_other.add |
| 807 | endfunc |
| 808 | |
Bram Moolenaar | ee03b94 | 2017-10-27 00:57:05 +0200 | [diff] [blame] | 809 | func Test_region_error() |
| 810 | messages clear |
| 811 | call writefile(["/regions=usgbnz", "elequint/0"], "Xtest.latin1.add") |
| 812 | mkspell! Xtest.latin1.add.spl Xtest.latin1.add |
| 813 | call assert_match('Invalid region nr in Xtest.latin1.add line 2: 0', execute('messages')) |
| 814 | call delete('Xtest.latin1.add') |
| 815 | call delete('Xtest.latin1.add.spl') |
| 816 | endfunc |
| 817 | |
Bram Moolenaar | d2c061d | 2017-06-22 21:42:49 +0200 | [diff] [blame] | 818 | " Check using z= in new buffer (crash fixed by patch 7.4a.028). |
| 819 | func Test_zeq_crash() |
| 820 | new |
| 821 | set maxmem=512 spell |
| 822 | call feedkeys('iasdz=:\"', 'tx') |
| 823 | |
| 824 | bwipe! |
| 825 | endfunc |
| 826 | |
Bram Moolenaar | 152e79e | 2020-06-10 15:32:08 +0200 | [diff] [blame] | 827 | " Check that z= works even when 'nospell' is set. This test uses one of the |
| 828 | " tests in Test_spellsuggest_option_number() just to verify that z= basically |
| 829 | " works and that "E756: Spell checking is not enabled" is not generated. |
| 830 | func Test_zeq_nospell() |
| 831 | new |
| 832 | set nospell spellsuggest=1,best |
| 833 | call setline(1, 'A baord') |
| 834 | try |
| 835 | norm $1z= |
| 836 | call assert_equal('A board', getline(1)) |
| 837 | catch |
| 838 | call assert_report("Caught exception: " . v:exception) |
| 839 | endtry |
| 840 | set spell& spellsuggest& |
| 841 | bwipe! |
| 842 | endfunc |
| 843 | |
| 844 | " Check that "E756: Spell checking is not possible" is reported when z= is |
| 845 | " executed and 'spelllang' is empty. |
| 846 | func Test_zeq_no_spelllang() |
| 847 | new |
| 848 | set spelllang= spellsuggest=1,best |
| 849 | call setline(1, 'A baord') |
| 850 | call assert_fails('normal $1z=', 'E756:') |
| 851 | set spelllang& spellsuggest& |
| 852 | bwipe! |
| 853 | endfunc |
| 854 | |
Bram Moolenaar | 5bcc5a1 | 2019-08-06 22:48:02 +0200 | [diff] [blame] | 855 | " Check handling a word longer than MAXWLEN. |
| 856 | func Test_spell_long_word() |
| 857 | set enc=utf-8 |
| 858 | new |
| 859 | 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") |
| 860 | set spell spelllang=en |
| 861 | redraw |
| 862 | redraw! |
| 863 | bwipe! |
| 864 | set nospell |
| 865 | endfunc |
| 866 | |
Bram Moolenaar | 06f1541 | 2022-01-29 10:51:59 +0000 | [diff] [blame] | 867 | func Test_spellsuggest_too_deep() |
| 868 | " This was incrementing "depth" over MAXWLEN. |
| 869 | new |
| 870 | norm s000G00ý000000000000 |
| 871 | sil norm ..vzG................vvzG0 v z= |
| 872 | bwipe! |
| 873 | endfunc |
| 874 | |
Bram Moolenaar | 5e59ea5 | 2022-07-01 22:26:20 +0100 | [diff] [blame] | 875 | func Test_spell_good_word_invalid() |
| 876 | " This was adding a word with a 0x02 byte, which causes havoc. |
| 877 | enew |
| 878 | norm o0 |
| 879 | sil! norm rzzWs00/ |
| 880 | 2 |
| 881 | sil! norm VzGprzzW |
| 882 | sil! norm z= |
| 883 | |
| 884 | bwipe! |
Bram Moolenaar | 5e59ea5 | 2022-07-01 22:26:20 +0100 | [diff] [blame] | 885 | endfunc |
| 886 | |
K.Takata | 2ebcc35 | 2022-07-14 17:25:14 +0100 | [diff] [blame] | 887 | func Test_spell_good_word_slash() |
| 888 | " This caused E1280. |
| 889 | new |
| 890 | norm afoo / |
| 891 | 1 |
| 892 | norm zG |
| 893 | |
| 894 | bwipe! |
| 895 | endfunc |
| 896 | |
Bram Moolenaar | d2c061d | 2017-06-22 21:42:49 +0200 | [diff] [blame] | 897 | func LoadAffAndDic(aff_contents, dic_contents) |
| 898 | set enc=latin1 |
| 899 | set spellfile= |
| 900 | call writefile(a:aff_contents, "Xtest.aff") |
| 901 | call writefile(a:dic_contents, "Xtest.dic") |
| 902 | " Generate a .spl file from a .dic and .aff file. |
| 903 | mkspell! Xtest Xtest |
| 904 | " use that spell file |
| 905 | set spl=Xtest.latin1.spl spell |
| 906 | endfunc |
| 907 | |
| 908 | func ListWords() |
| 909 | spelldump |
| 910 | %yank |
| 911 | quit |
| 912 | return split(@", "\n") |
| 913 | endfunc |
| 914 | |
| 915 | func TestGoodBadBase() |
| 916 | exe '1;/^good:' |
| 917 | normal 0f:]s |
| 918 | let prevbad = '' |
| 919 | let result = [] |
| 920 | while 1 |
| 921 | let [bad, a] = spellbadword() |
| 922 | if bad == '' || bad == prevbad || bad == 'badend' |
| 923 | break |
| 924 | endif |
| 925 | let prevbad = bad |
Bram Moolenaar | f6ed61e | 2019-09-07 19:05:09 +0200 | [diff] [blame] | 926 | let lst = bad->spellsuggest(3) |
Bram Moolenaar | d2c061d | 2017-06-22 21:42:49 +0200 | [diff] [blame] | 927 | normal mm |
| 928 | |
| 929 | call add(result, [bad, lst]) |
| 930 | normal `m]s |
| 931 | endwhile |
| 932 | return result |
| 933 | endfunc |
| 934 | |
| 935 | func RunGoodBad(good, bad, expected_words, expected_bad_words) |
| 936 | bwipe! |
| 937 | call setline(1, ["good: ", a:good, a:bad, " badend "]) |
| 938 | let words = ListWords() |
| 939 | call assert_equal(a:expected_words, words[1:-1]) |
| 940 | let bad_words = TestGoodBadBase() |
| 941 | call assert_equal(a:expected_bad_words, bad_words) |
| 942 | bwipe! |
| 943 | endfunc |
| 944 | |
Bram Moolenaar | 7751d1d | 2019-10-18 20:37:08 +0200 | [diff] [blame] | 945 | func Test_spell_screendump() |
| 946 | CheckScreendump |
| 947 | |
| 948 | let lines =<< trim END |
| 949 | call setline(1, [ |
| 950 | \ "This is some text without any spell errors. Everything", |
| 951 | \ "should just be black, nothing wrong here.", |
| 952 | \ "", |
| 953 | \ "This line has a sepll error. and missing caps.", |
| 954 | \ "And and this is the the duplication.", |
| 955 | \ "with missing caps here.", |
| 956 | \ ]) |
| 957 | set spell spelllang=en_nz |
| 958 | END |
| 959 | call writefile(lines, 'XtestSpell') |
| 960 | let buf = RunVimInTerminal('-S XtestSpell', {'rows': 8}) |
| 961 | call VerifyScreenDump(buf, 'Test_spell_1', {}) |
| 962 | |
| 963 | " clean up |
| 964 | call StopVimInTerminal(buf) |
| 965 | call delete('XtestSpell') |
| 966 | endfunc |
| 967 | |
Christian Brabandt | afa23d1 | 2022-08-09 12:25:10 +0100 | [diff] [blame] | 968 | func Test_spell_screendump_spellcap() |
| 969 | CheckScreendump |
| 970 | |
| 971 | let lines =<< trim END |
| 972 | call setline(1, [ |
| 973 | \ " This line has a sepll error. and missing caps and trailing spaces. ", |
| 974 | \ "another missing cap here.", |
| 975 | \ "", |
| 976 | \ "and here.", |
| 977 | \ " ", |
| 978 | \ "and here." |
| 979 | \ ]) |
| 980 | set spell spelllang=en |
| 981 | END |
| 982 | call writefile(lines, 'XtestSpellCap') |
| 983 | let buf = RunVimInTerminal('-S XtestSpellCap', {'rows': 8}) |
| 984 | call VerifyScreenDump(buf, 'Test_spell_2', {}) |
| 985 | |
Bram Moolenaar | ee09fcc | 2022-09-25 20:58:30 +0100 | [diff] [blame] | 986 | " After adding word missing Cap in next line is updated |
| 987 | call term_sendkeys(buf, "3GANot\<Esc>") |
| 988 | call VerifyScreenDump(buf, 'Test_spell_3', {}) |
| 989 | |
Christian Brabandt | afa23d1 | 2022-08-09 12:25:10 +0100 | [diff] [blame] | 990 | " clean up |
| 991 | call StopVimInTerminal(buf) |
| 992 | call delete('XtestSpellCap') |
| 993 | endfunc |
| 994 | |
Bram Moolenaar | d2c061d | 2017-06-22 21:42:49 +0200 | [diff] [blame] | 995 | let g:test_data_aff1 = [ |
| 996 | \"SET ISO8859-1", |
| 997 | \"TRY esianrtolcdugmphbyfvkwjkqxz-\xEB\xE9\xE8\xEA\xEF\xEE\xE4\xE0\xE2\xF6\xFC\xFB'ESIANRTOLCDUGMPHBYFVKWJKQXZ", |
| 998 | \"", |
| 999 | \"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", |
| 1000 | \"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", |
| 1001 | \"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", |
| 1002 | \"", |
| 1003 | \"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", |
| 1004 | \"SOFOTO ebctefghejklnnepkrstevvkesebctefghejklnnepkrstevvkeseeeeeeeceeeeeeeedneeeeeeeeeeepseeeeeeeeceeeeeeeedneeeeeeeeeeep?", |
| 1005 | \"", |
| 1006 | \"MIDWORD\t'-", |
| 1007 | \"", |
| 1008 | \"KEP =", |
| 1009 | \"RAR ?", |
| 1010 | \"BAD !", |
| 1011 | \"", |
| 1012 | \"PFX I N 1", |
| 1013 | \"PFX I 0 in .", |
| 1014 | \"", |
| 1015 | \"PFX O Y 1", |
| 1016 | \"PFX O 0 out .", |
| 1017 | \"", |
| 1018 | \"SFX S Y 2", |
| 1019 | \"SFX S 0 s [^s]", |
| 1020 | \"SFX S 0 es s", |
| 1021 | \"", |
| 1022 | \"SFX N N 3", |
| 1023 | \"SFX N 0 en [^n]", |
| 1024 | \"SFX N 0 nen n", |
| 1025 | \"SFX N 0 n .", |
| 1026 | \"", |
| 1027 | \"REP 3", |
| 1028 | \"REP g ch", |
| 1029 | \"REP ch g", |
| 1030 | \"REP svp s.v.p.", |
| 1031 | \"", |
| 1032 | \"MAP 9", |
| 1033 | \"MAP a\xE0\xE1\xE2\xE3\xE4\xE5", |
| 1034 | \"MAP e\xE8\xE9\xEA\xEB", |
| 1035 | \"MAP i\xEC\xED\xEE\xEF", |
| 1036 | \"MAP o\xF2\xF3\xF4\xF5\xF6", |
| 1037 | \"MAP u\xF9\xFA\xFB\xFC", |
| 1038 | \"MAP n\xF1", |
| 1039 | \"MAP c\xE7", |
| 1040 | \"MAP y\xFF\xFD", |
| 1041 | \"MAP s\xDF", |
| 1042 | \ ] |
| 1043 | let g:test_data_dic1 = [ |
| 1044 | \"123456", |
| 1045 | \"test/NO", |
| 1046 | \"# comment", |
| 1047 | \"wrong", |
| 1048 | \"Comment", |
| 1049 | \"OK", |
| 1050 | \"uk", |
| 1051 | \"put/ISO", |
| 1052 | \"the end", |
| 1053 | \"deol", |
| 1054 | \"d\xE9\xF4r", |
| 1055 | \ ] |
| 1056 | let g:test_data_aff2 = [ |
| 1057 | \"SET ISO8859-1", |
| 1058 | \"", |
| 1059 | \"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", |
| 1060 | \"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", |
| 1061 | \"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", |
| 1062 | \"", |
| 1063 | \"PFXPOSTPONE", |
| 1064 | \"", |
| 1065 | \"MIDWORD\t'-", |
| 1066 | \"", |
| 1067 | \"KEP =", |
| 1068 | \"RAR ?", |
| 1069 | \"BAD !", |
| 1070 | \"", |
| 1071 | \"PFX I N 1", |
| 1072 | \"PFX I 0 in .", |
| 1073 | \"", |
| 1074 | \"PFX O Y 1", |
| 1075 | \"PFX O 0 out [a-z]", |
| 1076 | \"", |
| 1077 | \"SFX S Y 2", |
| 1078 | \"SFX S 0 s [^s]", |
| 1079 | \"SFX S 0 es s", |
| 1080 | \"", |
| 1081 | \"SFX N N 3", |
| 1082 | \"SFX N 0 en [^n]", |
| 1083 | \"SFX N 0 nen n", |
| 1084 | \"SFX N 0 n .", |
| 1085 | \"", |
| 1086 | \"REP 3", |
| 1087 | \"REP g ch", |
| 1088 | \"REP ch g", |
| 1089 | \"REP svp s.v.p.", |
| 1090 | \"", |
| 1091 | \"MAP 9", |
| 1092 | \"MAP a\xE0\xE1\xE2\xE3\xE4\xE5", |
| 1093 | \"MAP e\xE8\xE9\xEA\xEB", |
| 1094 | \"MAP i\xEC\xED\xEE\xEF", |
| 1095 | \"MAP o\xF2\xF3\xF4\xF5\xF6", |
| 1096 | \"MAP u\xF9\xFA\xFB\xFC", |
| 1097 | \"MAP n\xF1", |
| 1098 | \"MAP c\xE7", |
| 1099 | \"MAP y\xFF\xFD", |
| 1100 | \"MAP s\xDF", |
| 1101 | \ ] |
| 1102 | let g:test_data_aff3 = [ |
| 1103 | \"SET ISO8859-1", |
| 1104 | \"", |
| 1105 | \"COMPOUNDMIN 3", |
| 1106 | \"COMPOUNDRULE m*", |
| 1107 | \"NEEDCOMPOUND x", |
| 1108 | \ ] |
| 1109 | let g:test_data_dic3 = [ |
| 1110 | \"1234", |
| 1111 | \"foo/m", |
| 1112 | \"bar/mx", |
| 1113 | \"m\xEF/m", |
| 1114 | \"la/mx", |
| 1115 | \ ] |
| 1116 | let g:test_data_aff4 = [ |
| 1117 | \"SET ISO8859-1", |
| 1118 | \"", |
| 1119 | \"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", |
| 1120 | \"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", |
| 1121 | \"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", |
| 1122 | \"", |
| 1123 | \"COMPOUNDRULE m+", |
| 1124 | \"COMPOUNDRULE sm*e", |
| 1125 | \"COMPOUNDRULE sm+", |
| 1126 | \"COMPOUNDMIN 3", |
| 1127 | \"COMPOUNDWORDMAX 3", |
| 1128 | \"COMPOUNDFORBIDFLAG t", |
| 1129 | \"", |
| 1130 | \"COMPOUNDSYLMAX 5", |
| 1131 | \"SYLLABLE a\xE1e\xE9i\xEDo\xF3\xF6\xF5u\xFA\xFC\xFBy/aa/au/ea/ee/ei/ie/oa/oe/oo/ou/uu/ui", |
| 1132 | \"", |
| 1133 | \"MAP 9", |
| 1134 | \"MAP a\xE0\xE1\xE2\xE3\xE4\xE5", |
| 1135 | \"MAP e\xE8\xE9\xEA\xEB", |
| 1136 | \"MAP i\xEC\xED\xEE\xEF", |
| 1137 | \"MAP o\xF2\xF3\xF4\xF5\xF6", |
| 1138 | \"MAP u\xF9\xFA\xFB\xFC", |
| 1139 | \"MAP n\xF1", |
| 1140 | \"MAP c\xE7", |
| 1141 | \"MAP y\xFF\xFD", |
| 1142 | \"MAP s\xDF", |
| 1143 | \"", |
| 1144 | \"NEEDAFFIX x", |
| 1145 | \"", |
| 1146 | \"PFXPOSTPONE", |
| 1147 | \"", |
| 1148 | \"MIDWORD '-", |
| 1149 | \"", |
| 1150 | \"SFX q N 1", |
| 1151 | \"SFX q 0 -ok .", |
| 1152 | \"", |
| 1153 | \"SFX a Y 2", |
| 1154 | \"SFX a 0 s .", |
| 1155 | \"SFX a 0 ize/t .", |
| 1156 | \"", |
| 1157 | \"PFX p N 1", |
| 1158 | \"PFX p 0 pre .", |
| 1159 | \"", |
| 1160 | \"PFX P N 1", |
| 1161 | \"PFX P 0 nou .", |
| 1162 | \ ] |
| 1163 | let g:test_data_dic4 = [ |
| 1164 | \"1234", |
| 1165 | \"word/mP", |
| 1166 | \"util/am", |
| 1167 | \"pro/xq", |
| 1168 | \"tomato/m", |
| 1169 | \"bork/mp", |
| 1170 | \"start/s", |
| 1171 | \"end/e", |
| 1172 | \ ] |
| 1173 | let g:test_data_aff5 = [ |
| 1174 | \"SET ISO8859-1", |
| 1175 | \"", |
| 1176 | \"FLAG long", |
| 1177 | \"", |
| 1178 | \"NEEDAFFIX !!", |
| 1179 | \"", |
| 1180 | \"COMPOUNDRULE ssmm*ee", |
| 1181 | \"", |
| 1182 | \"NEEDCOMPOUND xx", |
| 1183 | \"COMPOUNDPERMITFLAG pp", |
| 1184 | \"", |
| 1185 | \"SFX 13 Y 1", |
| 1186 | \"SFX 13 0 bork .", |
| 1187 | \"", |
| 1188 | \"SFX a1 Y 1", |
| 1189 | \"SFX a1 0 a1 .", |
| 1190 | \"", |
| 1191 | \"SFX a\xE9 Y 1", |
| 1192 | \"SFX a\xE9 0 a\xE9 .", |
| 1193 | \"", |
| 1194 | \"PFX zz Y 1", |
| 1195 | \"PFX zz 0 pre/pp .", |
| 1196 | \"", |
| 1197 | \"PFX yy Y 1", |
| 1198 | \"PFX yy 0 nou .", |
| 1199 | \ ] |
| 1200 | let g:test_data_dic5 = [ |
| 1201 | \"1234", |
| 1202 | \"foo/a1a\xE9!!", |
| 1203 | \"bar/zz13ee", |
| 1204 | \"start/ss", |
| 1205 | \"end/eeyy", |
| 1206 | \"middle/mmxx", |
| 1207 | \ ] |
| 1208 | let g:test_data_aff6 = [ |
| 1209 | \"SET ISO8859-1", |
| 1210 | \"", |
| 1211 | \"FLAG caplong", |
| 1212 | \"", |
| 1213 | \"NEEDAFFIX A!", |
| 1214 | \"", |
| 1215 | \"COMPOUNDRULE sMm*Ee", |
| 1216 | \"", |
| 1217 | \"NEEDCOMPOUND Xx", |
| 1218 | \"", |
| 1219 | \"COMPOUNDPERMITFLAG p", |
| 1220 | \"", |
| 1221 | \"SFX N3 Y 1", |
| 1222 | \"SFX N3 0 bork .", |
| 1223 | \"", |
| 1224 | \"SFX A1 Y 1", |
| 1225 | \"SFX A1 0 a1 .", |
| 1226 | \"", |
| 1227 | \"SFX A\xE9 Y 1", |
| 1228 | \"SFX A\xE9 0 a\xE9 .", |
| 1229 | \"", |
| 1230 | \"PFX Zz Y 1", |
| 1231 | \"PFX Zz 0 pre/p .", |
| 1232 | \ ] |
| 1233 | let g:test_data_dic6 = [ |
| 1234 | \"1234", |
| 1235 | \"mee/A1A\xE9A!", |
| 1236 | \"bar/ZzN3Ee", |
| 1237 | \"lead/s", |
| 1238 | \"end/Ee", |
| 1239 | \"middle/MmXx", |
| 1240 | \ ] |
| 1241 | let g:test_data_aff7 = [ |
| 1242 | \"SET ISO8859-1", |
| 1243 | \"", |
| 1244 | \"FLAG num", |
| 1245 | \"", |
| 1246 | \"NEEDAFFIX 9999", |
| 1247 | \"", |
| 1248 | \"COMPOUNDRULE 2,77*123", |
| 1249 | \"", |
| 1250 | \"NEEDCOMPOUND 1", |
| 1251 | \"COMPOUNDPERMITFLAG 432", |
| 1252 | \"", |
| 1253 | \"SFX 61003 Y 1", |
| 1254 | \"SFX 61003 0 meat .", |
| 1255 | \"", |
Bram Moolenaar | 3d2a47c | 2019-11-07 20:48:42 +0100 | [diff] [blame] | 1256 | \"SFX 0 Y 1", |
| 1257 | \"SFX 0 0 zero .", |
| 1258 | \"", |
Bram Moolenaar | d2c061d | 2017-06-22 21:42:49 +0200 | [diff] [blame] | 1259 | \"SFX 391 Y 1", |
| 1260 | \"SFX 391 0 a1 .", |
| 1261 | \"", |
| 1262 | \"SFX 111 Y 1", |
| 1263 | \"SFX 111 0 a\xE9 .", |
| 1264 | \"", |
| 1265 | \"PFX 17 Y 1", |
| 1266 | \"PFX 17 0 pre/432 .", |
| 1267 | \ ] |
| 1268 | let g:test_data_dic7 = [ |
| 1269 | \"1234", |
Bram Moolenaar | 3d2a47c | 2019-11-07 20:48:42 +0100 | [diff] [blame] | 1270 | \"mee/0,391,111,9999", |
Bram Moolenaar | d2c061d | 2017-06-22 21:42:49 +0200 | [diff] [blame] | 1271 | \"bar/17,61003,123", |
| 1272 | \"lead/2", |
| 1273 | \"tail/123", |
| 1274 | \"middle/77,1", |
| 1275 | \ ] |
| 1276 | let g:test_data_aff8 = [ |
| 1277 | \"SET ISO8859-1", |
| 1278 | \"", |
| 1279 | \"NOSPLITSUGS", |
| 1280 | \ ] |
| 1281 | let g:test_data_dic8 = [ |
| 1282 | \"1234", |
| 1283 | \"foo", |
| 1284 | \"bar", |
| 1285 | \"faabar", |
| 1286 | \ ] |
| 1287 | let g:test_data_aff9 = [ |
| 1288 | \ ] |
| 1289 | let g:test_data_dic9 = [ |
| 1290 | \"1234", |
| 1291 | \"foo", |
| 1292 | \"bar", |
| 1293 | \ ] |
Bram Moolenaar | 37ff4cf | 2019-11-17 20:10:20 +0100 | [diff] [blame] | 1294 | let g:test_data_aff10 = [ |
| 1295 | \"COMPOUNDRULE se", |
| 1296 | \"COMPOUNDPERMITFLAG p", |
| 1297 | \"", |
| 1298 | \"SFX A Y 1", |
| 1299 | \"SFX A 0 able/Mp .", |
| 1300 | \"", |
| 1301 | \"SFX M Y 1", |
| 1302 | \"SFX M 0 s .", |
| 1303 | \ ] |
| 1304 | let g:test_data_dic10 = [ |
| 1305 | \"1234", |
| 1306 | \"drink/As", |
| 1307 | \"table/e", |
| 1308 | \ ] |
Bram Moolenaar | d2c061d | 2017-06-22 21:42:49 +0200 | [diff] [blame] | 1309 | let g:test_data_aff_sal = [ |
| 1310 | \"SET ISO8859-1", |
| 1311 | \"TRY esianrtolcdugmphbyfvkwjkqxz-\xEB\xE9\xE8\xEA\xEF\xEE\xE4\xE0\xE2\xF6\xFC\xFB'ESIANRTOLCDUGMPHBYFVKWJKQXZ", |
| 1312 | \"", |
| 1313 | \"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", |
| 1314 | \"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", |
| 1315 | \"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", |
| 1316 | \"", |
| 1317 | \"MIDWORD\t'-", |
| 1318 | \"", |
| 1319 | \"KEP =", |
| 1320 | \"RAR ?", |
| 1321 | \"BAD !", |
| 1322 | \"", |
| 1323 | \"PFX I N 1", |
| 1324 | \"PFX I 0 in .", |
| 1325 | \"", |
| 1326 | \"PFX O Y 1", |
| 1327 | \"PFX O 0 out .", |
| 1328 | \"", |
| 1329 | \"SFX S Y 2", |
| 1330 | \"SFX S 0 s [^s]", |
| 1331 | \"SFX S 0 es s", |
| 1332 | \"", |
| 1333 | \"SFX N N 3", |
| 1334 | \"SFX N 0 en [^n]", |
| 1335 | \"SFX N 0 nen n", |
| 1336 | \"SFX N 0 n .", |
| 1337 | \"", |
| 1338 | \"REP 3", |
| 1339 | \"REP g ch", |
| 1340 | \"REP ch g", |
| 1341 | \"REP svp s.v.p.", |
| 1342 | \"", |
| 1343 | \"MAP 9", |
| 1344 | \"MAP a\xE0\xE1\xE2\xE3\xE4\xE5", |
| 1345 | \"MAP e\xE8\xE9\xEA\xEB", |
| 1346 | \"MAP i\xEC\xED\xEE\xEF", |
| 1347 | \"MAP o\xF2\xF3\xF4\xF5\xF6", |
| 1348 | \"MAP u\xF9\xFA\xFB\xFC", |
| 1349 | \"MAP n\xF1", |
| 1350 | \"MAP c\xE7", |
| 1351 | \"MAP y\xFF\xFD", |
| 1352 | \"MAP s\xDF", |
| 1353 | \"", |
| 1354 | \"SAL AH(AEIOUY)-^ *H", |
| 1355 | \"SAL AR(AEIOUY)-^ *R", |
| 1356 | \"SAL A(HR)^ *", |
| 1357 | \"SAL A^ *", |
| 1358 | \"SAL AH(AEIOUY)- H", |
| 1359 | \"SAL AR(AEIOUY)- R", |
| 1360 | \"SAL A(HR) _", |
| 1361 | \"SAL \xC0^ *", |
| 1362 | \"SAL \xC5^ *", |
| 1363 | \"SAL BB- _", |
| 1364 | \"SAL B B", |
| 1365 | \"SAL CQ- _", |
| 1366 | \"SAL CIA X", |
| 1367 | \"SAL CH X", |
| 1368 | \"SAL C(EIY)- S", |
| 1369 | \"SAL CK K", |
| 1370 | \"SAL COUGH^ KF", |
| 1371 | \"SAL CC< C", |
| 1372 | \"SAL C K", |
| 1373 | \"SAL DG(EIY) K", |
| 1374 | \"SAL DD- _", |
| 1375 | \"SAL D T", |
| 1376 | \"SAL \xC9< E", |
| 1377 | \"SAL EH(AEIOUY)-^ *H", |
| 1378 | \"SAL ER(AEIOUY)-^ *R", |
| 1379 | \"SAL E(HR)^ *", |
| 1380 | \"SAL ENOUGH^$ *NF", |
| 1381 | \"SAL E^ *", |
| 1382 | \"SAL EH(AEIOUY)- H", |
| 1383 | \"SAL ER(AEIOUY)- R", |
| 1384 | \"SAL E(HR) _", |
| 1385 | \"SAL FF- _", |
| 1386 | \"SAL F F", |
| 1387 | \"SAL GN^ N", |
| 1388 | \"SAL GN$ N", |
| 1389 | \"SAL GNS$ NS", |
| 1390 | \"SAL GNED$ N", |
| 1391 | \"SAL GH(AEIOUY)- K", |
| 1392 | \"SAL GH _", |
| 1393 | \"SAL GG9 K", |
| 1394 | \"SAL G K", |
| 1395 | \"SAL H H", |
| 1396 | \"SAL IH(AEIOUY)-^ *H", |
| 1397 | \"SAL IR(AEIOUY)-^ *R", |
| 1398 | \"SAL I(HR)^ *", |
| 1399 | \"SAL I^ *", |
| 1400 | \"SAL ING6 N", |
| 1401 | \"SAL IH(AEIOUY)- H", |
| 1402 | \"SAL IR(AEIOUY)- R", |
| 1403 | \"SAL I(HR) _", |
| 1404 | \"SAL J K", |
| 1405 | \"SAL KN^ N", |
| 1406 | \"SAL KK- _", |
| 1407 | \"SAL K K", |
| 1408 | \"SAL LAUGH^ LF", |
| 1409 | \"SAL LL- _", |
| 1410 | \"SAL L L", |
| 1411 | \"SAL MB$ M", |
| 1412 | \"SAL MM M", |
| 1413 | \"SAL M M", |
| 1414 | \"SAL NN- _", |
| 1415 | \"SAL N N", |
| 1416 | \"SAL OH(AEIOUY)-^ *H", |
| 1417 | \"SAL OR(AEIOUY)-^ *R", |
| 1418 | \"SAL O(HR)^ *", |
| 1419 | \"SAL O^ *", |
| 1420 | \"SAL OH(AEIOUY)- H", |
| 1421 | \"SAL OR(AEIOUY)- R", |
| 1422 | \"SAL O(HR) _", |
| 1423 | \"SAL PH F", |
| 1424 | \"SAL PN^ N", |
| 1425 | \"SAL PP- _", |
| 1426 | \"SAL P P", |
| 1427 | \"SAL Q K", |
| 1428 | \"SAL RH^ R", |
| 1429 | \"SAL ROUGH^ RF", |
| 1430 | \"SAL RR- _", |
| 1431 | \"SAL R R", |
| 1432 | \"SAL SCH(EOU)- SK", |
| 1433 | \"SAL SC(IEY)- S", |
| 1434 | \"SAL SH X", |
| 1435 | \"SAL SI(AO)- X", |
| 1436 | \"SAL SS- _", |
| 1437 | \"SAL S S", |
| 1438 | \"SAL TI(AO)- X", |
| 1439 | \"SAL TH @", |
| 1440 | \"SAL TCH-- _", |
| 1441 | \"SAL TOUGH^ TF", |
| 1442 | \"SAL TT- _", |
| 1443 | \"SAL T T", |
| 1444 | \"SAL UH(AEIOUY)-^ *H", |
| 1445 | \"SAL UR(AEIOUY)-^ *R", |
| 1446 | \"SAL U(HR)^ *", |
| 1447 | \"SAL U^ *", |
| 1448 | \"SAL UH(AEIOUY)- H", |
| 1449 | \"SAL UR(AEIOUY)- R", |
| 1450 | \"SAL U(HR) _", |
| 1451 | \"SAL V^ W", |
| 1452 | \"SAL V F", |
| 1453 | \"SAL WR^ R", |
| 1454 | \"SAL WH^ W", |
| 1455 | \"SAL W(AEIOU)- W", |
| 1456 | \"SAL X^ S", |
| 1457 | \"SAL X KS", |
| 1458 | \"SAL Y(AEIOU)- Y", |
| 1459 | \"SAL ZZ- _", |
| 1460 | \"SAL Z S", |
| 1461 | \ ] |
Bram Moolenaar | 0e05de4 | 2020-03-25 22:23:46 +0100 | [diff] [blame] | 1462 | |
| 1463 | " vim: shiftwidth=2 sts=2 expandtab |