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