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