1Tests for spell checking. vim: set ft=vim : 2 3STARTTEST 4:so small.vim 5:" 6:" Don't want to depend on the locale from the environment 7:set enc=latin1 8:e! 9:" 10:" Function to test .aff/.dic with list of good and bad words. 11:func TestOne(aff, dic) 12 set spellfile= 13 $put ='' 14 $put ='test '. a:aff . '-' . a:dic 15 " Generate a .spl file from a .dic and .aff file. 16 exe '1;/^' . a:aff . 'affstart/+1,/^' . a:aff . 'affend/-1w! Xtest.aff' 17 exe '1;/^' . a:dic . 'dicstart/+1,/^' . a:dic . 'dicend/-1w! Xtest.dic' 18 mkspell! Xtest Xtest 19 " use that spell file 20 set spl=Xtest.latin1.spl spell 21 " list all valid words 22 spelldump 23 %yank 24 quit 25 $put 26 $put ='-------' 27 " find all bad words and suggestions for them 28 exe '1;/^' . a:aff . 'good:' 29 normal 0f:]s 30 let prevbad = '' 31 while 1 32 let [bad, a] = spellbadword() 33 if bad == '' || bad == prevbad || bad == 'badend' 34 break 35 endif 36 let prevbad = bad 37 let lst = spellsuggest(bad, 3) 38 normal mm 39 $put =bad 40 $put =string(lst) 41 normal `m]s 42 endwhile 43endfunc 44:" 45:call TestOne('1', '1') 46:$put =soundfold('goobledygoook') 47:$put =soundfold('k�op�r�n�ven') 48:$put =soundfold('oeverloos gezwets edale') 49:" 50:" 51:" and now with SAL instead of SOFO items; test automatic reloading 52gg:/^affstart_sal/+1,/^affend_sal/-1w! Xtest.aff 53:mkspell! Xtest Xtest 54:$put =soundfold('goobledygoook') 55:$put =soundfold('k�op�r�n�ven') 56:$put =soundfold('oeverloos gezwets edale') 57:" 58:" also use an addition file 59gg:/^addstart/+1,/^addend/-1w! Xtest.latin1.add 60:mkspell! Xtest.latin1.add.spl Xtest.latin1.add 61:set spellfile=Xtest.latin1.add 62/^test2: 63]s:let [str, a] = spellbadword() 64:$put =str 65:set spl=Xtest_us.latin1.spl 66/^test2: 67]smm:let [str, a] = spellbadword() 68:$put =str 69`m]s:let [str, a] = spellbadword() 70:$put =str 71:set spl=Xtest_gb.latin1.spl 72/^test2: 73]smm:let [str, a] = spellbadword() 74:$put =str 75`m]s:let [str, a] = spellbadword() 76:$put =str 77:set spl=Xtest_nz.latin1.spl 78/^test2: 79]smm:let [str, a] = spellbadword() 80:$put =str 81`m]s:let [str, a] = spellbadword() 82:$put =str 83:set spl=Xtest_ca.latin1.spl 84/^test2: 85]smm:let [str, a] = spellbadword() 86:$put =str 87`m]s:let [str, a] = spellbadword() 88:$put =str 89:unlet str a 90:" 91:" Postponed prefixes 92:call TestOne('2', '1') 93:" 94:" Compound words 95:call TestOne('3', '3') 96:call TestOne('4', '4') 97:call TestOne('5', '5') 98:call TestOne('6', '6') 99:call TestOne('7', '7') 100:" 101:" NOSLITSUGS 102:call TestOne('8', '8') 103:" 104:" clean up for valgrind 105:delfunc TestOne 106:set spl= enc=latin1 107:" 108gg:/^test output:/,$wq! test.out 109ENDTEST 110 1111affstart 112SET ISO8859-1 113TRY esianrtolcdugmphbyfvkwjkqxz-������������'ESIANRTOLCDUGMPHBYFVKWJKQXZ 114 115FOL �������������������������������� 116LOW �������������������������������� 117UPP �������������������������������� 118 119SOFOFROM abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ������������������������������������������������������������� 120SOFOTO ebctefghejklnnepkrstevvkesebctefghejklnnepkrstevvkeseeeeeeeceeeeeeeedneeeeeeeeeeepseeeeeeeeceeeeeeeedneeeeeeeeeeep? 121 122MIDWORD '- 123 124KEP = 125RAR ? 126BAD ! 127 128PFX I N 1 129PFX I 0 in . 130 131PFX O Y 1 132PFX O 0 out . 133 134SFX S Y 2 135SFX S 0 s [^s] 136SFX S 0 es s 137 138SFX N N 3 139SFX N 0 en [^n] 140SFX N 0 nen n 141SFX N 0 n . 142 143REP 3 144REP g ch 145REP ch g 146REP svp s.v.p. 147 148MAP 9 149MAP a������ 150MAP e���� 151MAP i���� 152MAP o����� 153MAP u���� 154MAP n� 155MAP c� 156MAP y�� 157MAP s� 1581affend 159 1601good: wrong OK puts. Test the end 161bad: inputs comment ok Ok. test d��l end the 162badend 163 1641dicstart 165123456 166test/NO 167# comment 168wrong 169Comment 170OK 171uk 172put/ISO 173the end 174deol 175d��r 1761dicend 177 178affstart_sal 179SET ISO8859-1 180TRY esianrtolcdugmphbyfvkwjkqxz-������������'ESIANRTOLCDUGMPHBYFVKWJKQXZ 181 182FOL �������������������������������� 183LOW �������������������������������� 184UPP �������������������������������� 185 186MIDWORD '- 187 188KEP = 189RAR ? 190BAD ! 191 192PFX I N 1 193PFX I 0 in . 194 195PFX O Y 1 196PFX O 0 out . 197 198SFX S Y 2 199SFX S 0 s [^s] 200SFX S 0 es s 201 202SFX N N 3 203SFX N 0 en [^n] 204SFX N 0 nen n 205SFX N 0 n . 206 207REP 3 208REP g ch 209REP ch g 210REP svp s.v.p. 211 212MAP 9 213MAP a������ 214MAP e���� 215MAP i���� 216MAP o����� 217MAP u���� 218MAP n� 219MAP c� 220MAP y�� 221MAP s� 222 223SAL AH(AEIOUY)-^ *H 224SAL AR(AEIOUY)-^ *R 225SAL A(HR)^ * 226SAL A^ * 227SAL AH(AEIOUY)- H 228SAL AR(AEIOUY)- R 229SAL A(HR) _ 230SAL �^ * 231SAL �^ * 232SAL BB- _ 233SAL B B 234SAL CQ- _ 235SAL CIA X 236SAL CH X 237SAL C(EIY)- S 238SAL CK K 239SAL COUGH^ KF 240SAL CC< C 241SAL C K 242SAL DG(EIY) K 243SAL DD- _ 244SAL D T 245SAL �< E 246SAL EH(AEIOUY)-^ *H 247SAL ER(AEIOUY)-^ *R 248SAL E(HR)^ * 249SAL ENOUGH^$ *NF 250SAL E^ * 251SAL EH(AEIOUY)- H 252SAL ER(AEIOUY)- R 253SAL E(HR) _ 254SAL FF- _ 255SAL F F 256SAL GN^ N 257SAL GN$ N 258SAL GNS$ NS 259SAL GNED$ N 260SAL GH(AEIOUY)- K 261SAL GH _ 262SAL GG9 K 263SAL G K 264SAL H H 265SAL IH(AEIOUY)-^ *H 266SAL IR(AEIOUY)-^ *R 267SAL I(HR)^ * 268SAL I^ * 269SAL ING6 N 270SAL IH(AEIOUY)- H 271SAL IR(AEIOUY)- R 272SAL I(HR) _ 273SAL J K 274SAL KN^ N 275SAL KK- _ 276SAL K K 277SAL LAUGH^ LF 278SAL LL- _ 279SAL L L 280SAL MB$ M 281SAL MM M 282SAL M M 283SAL NN- _ 284SAL N N 285SAL OH(AEIOUY)-^ *H 286SAL OR(AEIOUY)-^ *R 287SAL O(HR)^ * 288SAL O^ * 289SAL OH(AEIOUY)- H 290SAL OR(AEIOUY)- R 291SAL O(HR) _ 292SAL PH F 293SAL PN^ N 294SAL PP- _ 295SAL P P 296SAL Q K 297SAL RH^ R 298SAL ROUGH^ RF 299SAL RR- _ 300SAL R R 301SAL SCH(EOU)- SK 302SAL SC(IEY)- S 303SAL SH X 304SAL SI(AO)- X 305SAL SS- _ 306SAL S S 307SAL TI(AO)- X 308SAL TH @ 309SAL TCH-- _ 310SAL TOUGH^ TF 311SAL TT- _ 312SAL T T 313SAL UH(AEIOUY)-^ *H 314SAL UR(AEIOUY)-^ *R 315SAL U(HR)^ * 316SAL U^ * 317SAL UH(AEIOUY)- H 318SAL UR(AEIOUY)- R 319SAL U(HR) _ 320SAL V^ W 321SAL V F 322SAL WR^ R 323SAL WH^ W 324SAL W(AEIOU)- W 325SAL X^ S 326SAL X KS 327SAL Y(AEIOU)- Y 328SAL ZZ- _ 329SAL Z S 330affend_sal 331 3322affstart 333SET ISO8859-1 334 335FOL �������������������������������� 336LOW �������������������������������� 337UPP �������������������������������� 338 339PFXPOSTPONE 340 341MIDWORD '- 342 343KEP = 344RAR ? 345BAD ! 346 347PFX I N 1 348PFX I 0 in . 349 350PFX O Y 1 351PFX O 0 out [a-z] 352 353SFX S Y 2 354SFX S 0 s [^s] 355SFX S 0 es s 356 357SFX N N 3 358SFX N 0 en [^n] 359SFX N 0 nen n 360SFX N 0 n . 361 362REP 3 363REP g ch 364REP ch g 365REP svp s.v.p. 366 367MAP 9 368MAP a������ 369MAP e���� 370MAP i���� 371MAP o����� 372MAP u���� 373MAP n� 374MAP c� 375MAP y�� 376MAP s� 3772affend 378 3792good: puts 380bad: inputs comment ok Ok end the. test d��l 381badend 382 383addstart 384/regions=usgbnz 385elequint/2 386elekwint/3 387addend 388 389test2: 390elequint test elekwint test elekwent asdf 391 392Test rules for compounding. 393 3943affstart 395SET ISO8859-1 396 397COMPOUNDMIN 3 398COMPOUNDRULE m* 399NEEDCOMPOUND x 4003affend 401 4023dicstart 4031234 404foo/m 405bar/mx 406m�/m 407la/mx 4083dicend 409 4103good: foo m� foobar foofoobar barfoo barbarfoo 411bad: bar la foom� barm� m�foo m�bar m�m� lala m�la lam� foola labar 412badend 413 414 415Tests for compounding. 416 4174affstart 418SET ISO8859-1 419 420FOL �������������������������������� 421LOW �������������������������������� 422UPP �������������������������������� 423 424COMPOUNDRULE m+ 425COMPOUNDRULE sm*e 426COMPOUNDRULE sm+ 427COMPOUNDMIN 3 428COMPOUNDWORDMAX 3 429COMPOUNDFORBIDFLAG t 430 431COMPOUNDSYLMAX 5 432SYLLABLE a�e�i�o���u���y/aa/au/ea/ee/ei/ie/oa/oe/oo/ou/uu/ui 433 434MAP 9 435MAP a������ 436MAP e���� 437MAP i���� 438MAP o����� 439MAP u���� 440MAP n� 441MAP c� 442MAP y�� 443MAP s� 444 445NEEDAFFIX x 446 447PFXPOSTPONE 448 449MIDWORD '- 450 451SFX q N 1 452SFX q 0 -ok . 453 454SFX a Y 2 455SFX a 0 s . 456SFX a 0 ize/t . 457 458PFX p N 1 459PFX p 0 pre . 460 461PFX P N 1 462PFX P 0 nou . 4634affend 464 4654dicstart 4661234 467word/mP 468util/am 469pro/xq 470tomato/m 471bork/mp 472start/s 473end/e 4744dicend 475 4764good: word util bork prebork start end wordutil wordutils pro-ok 477 bork borkbork borkborkbork borkborkborkbork borkborkborkborkbork 478 tomato tomatotomato startend startword startwordword startwordend 479 startwordwordend startwordwordwordend prebork preborkbork 480 preborkborkbork 481 nouword 482bad: wordutilize pro borkborkborkborkborkbork tomatotomatotomato 483 endstart endend startstart wordend wordstart 484 preborkprebork preborkpreborkbork 485 startwordwordwordwordend borkpreborkpreborkbork 486 utilsbork startnouword 487badend 488 489Test affix flags with two characters 490 4915affstart 492SET ISO8859-1 493 494FLAG long 495 496NEEDAFFIX !! 497 498COMPOUNDRULE ssmm*ee 499 500NEEDCOMPOUND xx 501COMPOUNDPERMITFLAG pp 502 503SFX 13 Y 1 504SFX 13 0 bork . 505 506SFX a1 Y 1 507SFX a1 0 a1 . 508 509SFX a� Y 1 510SFX a� 0 a� . 511 512PFX zz Y 1 513PFX zz 0 pre/pp . 514 515PFX yy Y 1 516PFX yy 0 nou . 5175affend 518 5195dicstart 5201234 521foo/a1a�!! 522bar/zz13ee 523start/ss 524end/eeyy 525middle/mmxx 5265dicend 527 5285good: fooa1 fooa� bar prebar barbork prebarbork startprebar 529 start end startend startmiddleend nouend 530bad: foo fooa2 prabar probarbirk middle startmiddle middleend endstart 531 startprobar startnouend 532badend 533 5346affstart 535SET ISO8859-1 536 537FLAG caplong 538 539NEEDAFFIX A! 540 541COMPOUNDRULE sMm*Ee 542 543NEEDCOMPOUND Xx 544 545COMPOUNDPERMITFLAG p 546 547SFX N3 Y 1 548SFX N3 0 bork . 549 550SFX A1 Y 1 551SFX A1 0 a1 . 552 553SFX A� Y 1 554SFX A� 0 a� . 555 556PFX Zz Y 1 557PFX Zz 0 pre/p . 5586affend 559 5606dicstart 5611234 562mee/A1A�A! 563bar/ZzN3Ee 564lead/s 565end/Ee 566middle/MmXx 5676dicend 568 5696good: meea1 meea� bar prebar barbork prebarbork leadprebar 570 lead end leadend leadmiddleend 571bad: mee meea2 prabar probarbirk middle leadmiddle middleend endlead 572 leadprobar 573badend 574 5757affstart 576SET ISO8859-1 577 578FLAG num 579 580NEEDAFFIX 9999 581 582COMPOUNDRULE 2,77*123 583 584NEEDCOMPOUND 1 585COMPOUNDPERMITFLAG 432 586 587SFX 61003 Y 1 588SFX 61003 0 meat . 589 590SFX 391 Y 1 591SFX 391 0 a1 . 592 593SFX 111 Y 1 594SFX 111 0 a� . 595 596PFX 17 Y 1 597PFX 17 0 pre/432 . 5987affend 599 6007dicstart 6011234 602mee/391,111,9999 603bar/17,61003,123 604lead/2 605tail/123 606middle/77,1 6077dicend 608 6097good: meea1 meea� bar prebar barmeat prebarmeat leadprebar 610 lead tail leadtail leadmiddletail 611bad: mee meea2 prabar probarmaat middle leadmiddle middletail taillead 612 leadprobar 613badend 614 615Test NOSLITSUGS 616 6178affstart 618SET ISO8859-1 619 620NOSPLITSUGS 6218affend 622 6238dicstart 6241234 625foo 626bar 627faabar 6288dicend 629 6308good: foo bar faabar 631bad: foobar barfoo 632badend 633 634 635test output: 636