@@ -410,6 +410,24 @@ func Test_sugfile_format_error()
410410 call assert_fails (" let s = spellsuggest('abc')" , ' E782:' )
411411 set nospell spelllang &
412412
413+ " invalid suggest word count in SUGTABLE
414+ set encoding = utf- 8
415+ call writefile (0z56494D7375670100000000000000440000000022 , sugfile)
416+ set runtimepath = ./Xtest
417+ set spelllang = Xtest
418+ set spell
419+ call assert_fails (" let s = spellsuggest('abc')" , ' E782:' )
420+ set nospell spelllang &
421+
422+ " missing sugline in SUGTABLE
423+ set encoding = utf- 8
424+ call writefile (0z56494D7375670100000000000000440000000000000005 , sugfile)
425+ set runtimepath = ./Xtest
426+ set spelllang = Xtest
427+ set spell
428+ call assert_fails (" let s = spellsuggest('abc')" , ' E782:' )
429+ set nospell spelllang &
430+
413431 let &rtp = save_rtp
414432 call delete (' Xtest' , ' rf' )
415433endfunc
@@ -512,25 +530,29 @@ endfunc
512530
513531" Tests for :mkspell with a .dic and .aff file
514532func Test_aff_file_format_error ()
533+ " FIXME: For some reason, the :mkspell command below doesn't fail on the
534+ " MS-Windows CI build. Disable this test on MS-Windows for now.
535+ CheckNotMSWindows
536+
515537 " No word count in .dic file
516538 call writefile ([], ' Xtest.dic' )
517539 call writefile ([], ' Xtest.aff' )
518540 call assert_fails (' mkspell! Xtest.spl Xtest' , ' E760:' )
519541
520- " Invalid encoding in .aff file
542+ " create a .dic file for the tests below
521543 call writefile ([' 1' , ' work' ], ' Xtest.dic' )
544+
545+ " Invalid encoding in .aff file
522546 call writefile ([' # comment' , ' SET Xinvalidencoding' ], ' Xtest.aff' )
523547 let output = execute (' mkspell! Xtest.spl Xtest' )
524548 call assert_match (' Conversion in Xtest.aff not supported: from xinvalidencoding' , output)
525549
526550 " Invalid flag in .aff file
527- call writefile ([' 1' , ' work' ], ' Xtest.dic' )
528551 call writefile ([' FLAG xxx' ], ' Xtest.aff' )
529552 let output = execute (' mkspell! Xtest.spl Xtest' )
530553 call assert_match (' Invalid value for FLAG in Xtest.aff line 1: xxx' , output)
531554
532555 " set FLAGS after using flag for an affix
533- call writefile ([' 1' , ' work' ], ' Xtest.dic' )
534556 call writefile ([' SFX L Y 1' , ' SFX L 0 re [^x]' , ' FLAG long' ], ' Xtest.aff' )
535557 let output = execute (' mkspell! Xtest.spl Xtest' )
536558 call assert_match (' FLAG after using flags in Xtest.aff line 3: long' , output)
@@ -558,153 +580,139 @@ func Test_aff_file_format_error()
558580 let &encoding = save_encoding
559581
560582 " COMPOUNDFORBIDFLAG flag after PFX in an affix file
561- call writefile ([' 1' , ' work' ], ' Xtest.dic' )
562583 call writefile ([' PFX L Y 1' , ' PFX L 0 re x' , ' COMPOUNDFLAG c' , ' COMPOUNDFORBIDFLAG x' ],
563584 \ ' Xtest.aff' )
564585 let output = execute (' mkspell! Xtest.spl Xtest' )
565586 call assert_match (' Defining COMPOUNDFORBIDFLAG after PFX item may give wrong results in Xtest.aff line 4' , output)
566587
567588 " COMPOUNDPERMITFLAG flag after PFX in an affix file
568- call writefile ([' 1' , ' work' ], ' Xtest.dic' )
569589 call writefile ([' PFX L Y 1' , ' PFX L 0 re x' , ' COMPOUNDPERMITFLAG c' ],
570590 \ ' Xtest.aff' )
571591 let output = execute (' mkspell! Xtest.spl Xtest' )
572592 call assert_match (' Defining COMPOUNDPERMITFLAG after PFX item may give wrong results in Xtest.aff line 3' , output)
573593
574594 " Wrong COMPOUNDRULES flag value in an affix file
575- call writefile ([' 1' , ' work' ], ' Xtest.dic' )
576595 call writefile ([' COMPOUNDRULES a' ], ' Xtest.aff' )
577596 let output = execute (' mkspell! Xtest.spl Xtest' )
578597 call assert_match (' Wrong COMPOUNDRULES value in Xtest.aff line 1: a' , output)
579598
580599 " Wrong COMPOUNDWORDMAX flag value in an affix file
581- call writefile ([' 1' , ' work' ], ' Xtest.dic' )
582600 call writefile ([' COMPOUNDWORDMAX 0' ], ' Xtest.aff' )
583601 let output = execute (' mkspell! Xtest.spl Xtest' )
584602 call assert_match (' Wrong COMPOUNDWORDMAX value in Xtest.aff line 1: 0' , output)
585603
586604 " Wrong COMPOUNDMIN flag value in an affix file
587- call writefile ([' 1' , ' work' ], ' Xtest.dic' )
588605 call writefile ([' COMPOUNDMIN 0' ], ' Xtest.aff' )
589606 let output = execute (' mkspell! Xtest.spl Xtest' )
590607 call assert_match (' Wrong COMPOUNDMIN value in Xtest.aff line 1: 0' , output)
591608
592609 " Wrong COMPOUNDSYLMAX flag value in an affix file
593- call writefile ([' 1' , ' work' ], ' Xtest.dic' )
594610 call writefile ([' COMPOUNDSYLMAX 0' ], ' Xtest.aff' )
595611 let output = execute (' mkspell! Xtest.spl Xtest' )
596612 call assert_match (' Wrong COMPOUNDSYLMAX value in Xtest.aff line 1: 0' , output)
597613
598614 " Wrong CHECKCOMPOUNDPATTERN flag value in an affix file
599- call writefile ([' 1' , ' work' ], ' Xtest.dic' )
600615 call writefile ([' CHECKCOMPOUNDPATTERN 0' ], ' Xtest.aff' )
601616 let output = execute (' mkspell! Xtest.spl Xtest' )
602617 call assert_match (' Wrong CHECKCOMPOUNDPATTERN value in Xtest.aff line 1: 0' , output)
603618
604619 " Duplicate affix entry in an affix file
605- call writefile ([' 1' , ' work' ], ' Xtest.dic' )
606620 call writefile ([' PFX L Y 1' , ' PFX L 0 re x' , ' PFX L Y 1' , ' PFX L 0 re x' ],
607621 \ ' Xtest.aff' )
608622 let output = execute (' mkspell! Xtest.spl Xtest' )
609623 call assert_match (' Duplicate affix in Xtest.aff line 3: L' , output)
610624
611625 " Duplicate affix entry in an affix file
612- call writefile ([' 1' , ' work' ], ' Xtest.dic' )
613626 call writefile ([' PFX L Y 1' , ' PFX L Y 1' ], ' Xtest.aff' )
614627 let output = execute (' mkspell! Xtest.spl Xtest' )
615628 call assert_match (' Unrecognized or duplicate item in Xtest.aff line 2: PFX' , output)
616629
617630 " Different combining flags in an affix file
618- call writefile ([' 1' , ' work' ], ' Xtest.dic' )
619631 call writefile ([' PFX L Y 1' , ' PFX L 0 re x' , ' PFX L N 1' ], ' Xtest.aff' )
620632 let output = execute (' mkspell! Xtest.spl Xtest' )
621633 call assert_match (' Different combining flag in continued affix block in Xtest.aff line 3' , output)
622634
623635 " Try to reuse a affix used for BAD flag
624- call writefile ([' 1' , ' work' ], ' Xtest.dic' )
625636 call writefile ([' BAD x' , ' PFX x Y 1' , ' PFX x 0 re x' ], ' Xtest.aff' )
626637 let output = execute (' mkspell! Xtest.spl Xtest' )
627638 call assert_match (' Affix also used for BAD/RARE/KEEPCASE/NEEDAFFIX/NEEDCOMPOUND/NOSUGGEST in Xtest.aff line 2: x' , output)
628639
629640 " Trailing characters in an affix entry
630- call writefile ([' 1' , ' work' ], ' Xtest.dic' )
631641 call writefile ([' PFX L Y 1 Test' , ' PFX L 0 re x' ], ' Xtest.aff' )
632642 let output = execute (' mkspell! Xtest.spl Xtest' )
633643 call assert_match (' Trailing text in Xtest.aff line 1: Test' , output)
634644
635645 " Trailing characters in an affix entry
636- call writefile ([' 1' , ' work' ], ' Xtest.dic' )
637646 call writefile ([' PFX L Y 1' , ' PFX L 0 re x Test' ], ' Xtest.aff' )
638647 let output = execute (' mkspell! Xtest.spl Xtest' )
639648 call assert_match (' Trailing text in Xtest.aff line 2: Test' , output)
640649
641650 " Incorrect combine flag in an affix entry
642- call writefile ([' 1' , ' work' ], ' Xtest.dic' )
643651 call writefile ([' PFX L X 1' , ' PFX L 0 re x' ], ' Xtest.aff' )
644652 let output = execute (' mkspell! Xtest.spl Xtest' )
645653 call assert_match (' Expected Y or N in Xtest.aff line 1: X' , output)
646654
647655 " Invalid count for REP item
648- call writefile ([' 1' , ' work' ], ' Xtest.dic' )
649656 call writefile ([' REP a' ], ' Xtest.aff' )
650657 let output = execute (' mkspell! Xtest.spl Xtest' )
651658 call assert_match (' Expected REP(SAL) count in Xtest.aff line 1' , output)
652659
653660 " Trailing characters in REP item
654- call writefile ([' 1' , ' work' ], ' Xtest.dic' )
655661 call writefile ([' REP 1' , ' REP f ph test' ], ' Xtest.aff' )
656662 let output = execute (' mkspell! Xtest.spl Xtest' )
657663 call assert_match (' Trailing text in Xtest.aff line 2: test' , output)
658664
659665 " Invalid count for MAP item
660- call writefile ([' 1' , ' work' ], ' Xtest.dic' )
661666 call writefile ([' MAP a' ], ' Xtest.aff' )
662667 let output = execute (' mkspell! Xtest.spl Xtest' )
663668 call assert_match (' Expected MAP count in Xtest.aff line 1' , output)
664669
665670 " Duplicate character in a MAP item
666- call writefile ([' 1' , ' work' ], ' Xtest.dic' )
667671 call writefile ([' MAP 2' , ' MAP xx' , ' MAP yy' ], ' Xtest.aff' )
668672 let output = execute (' mkspell! Xtest.spl Xtest' )
669673 call assert_match (' Duplicate character in MAP in Xtest.aff line 2' , output)
670674
671675 " Use COMPOUNDSYLMAX without SYLLABLE
672- call writefile ([' 1' , ' work' ], ' Xtest.dic' )
673676 call writefile ([' COMPOUNDSYLMAX 2' ], ' Xtest.aff' )
674677 let output = execute (' mkspell! Xtest.spl Xtest' )
675678 call assert_match (' COMPOUNDSYLMAX used without SYLLABLE' , output)
676679
677680 " Missing SOFOTO
678- call writefile ([' 1' , ' work' ], ' Xtest.dic' )
679681 call writefile ([' SOFOFROM abcdef' ], ' Xtest.aff' )
680682 let output = execute (' mkspell! Xtest.spl Xtest' )
681683 call assert_match (' Missing SOFOTO line in Xtest.aff' , output)
682684
683- " FIXME: The following test causes a heap overflow with the ASAN build
684- " " Both SAL and SOFOFROM/SOFOTO items
685- " call writefile(['1', 'work'], 'Xtest.dic')
686- " call writefile(['SOFOFROM abcd', 'SOFOTO ABCD', 'SAL CIA X'], 'Xtest.aff')
687- " let output = execute('mkspell! Xtest.spl Xtest')
688- " call assert_match('Both SAL and SOFO lines in Xtest.aff', output)
685+ " Length of SOFOFROM and SOFOTO differ
686+ call writefile ([' SOFOFROM abcde' , ' SOFOTO ABCD' ], ' Xtest.aff' )
687+ call assert_fails (' mkspell! Xtest.spl Xtest' , ' E759:' )
688+
689+ " Both SAL and SOFOFROM/SOFOTO items
690+ call writefile ([' SOFOFROM abcd' , ' SOFOTO ABCD' , ' SAL CIA X' ], ' Xtest.aff' )
691+ let output = execute (' mkspell! Xtest.spl Xtest' )
692+ call assert_match (' Both SAL and SOFO lines in Xtest.aff' , output)
689693
690694 " use an alphabet flag when FLAG is num
691- call writefile ([' 1' , ' work' ], ' Xtest.dic' )
692695 call writefile ([' FLAG num' , ' SFX L Y 1' , ' SFX L 0 re [^x]' ], ' Xtest.aff' )
693696 let output = execute (' mkspell! Xtest.spl Xtest' )
694697 call assert_match (' Flag is not a number in Xtest.aff line 2: L' , output)
695698
696699 " use number and alphabet flag when FLAG is num
697- call writefile ([' 1' , ' work' ], ' Xtest.dic' )
698700 call writefile ([' FLAG num' , ' SFX 4f Y 1' , ' SFX 4f 0 re [^x]' ], ' Xtest.aff' )
699701 let output = execute (' mkspell! Xtest.spl Xtest' )
700702 call assert_match (' Affix name too long in Xtest.aff line 2: 4f' , output)
701703
702704 " use a single character flag when FLAG is long
703- call writefile ([' 1' , ' work' ], ' Xtest.dic' )
704705 call writefile ([' FLAG long' , ' SFX L Y 1' , ' SFX L 0 re [^x]' ], ' Xtest.aff' )
705706 let output = execute (' mkspell! Xtest.spl Xtest' )
706707 call assert_match (' Illegal flag in Xtest.aff line 2: L' , output)
707708
709+ " duplicate word in the .dic file
710+ call writefile ([' 2' , ' good' , ' good' , ' good' ], ' Xtest.dic' )
711+ call writefile ([' NAME vim' ], ' Xtest.aff' )
712+ let output = execute (' mkspell! Xtest.spl Xtest' )
713+ call assert_match (' First duplicate word in Xtest.dic line 3: good' , output)
714+ call assert_match (' 2 duplicate word(s) in Xtest.dic' , output)
715+
708716 call delete (' Xtest.dic' )
709717 call delete (' Xtest.aff' )
710718 call delete (' Xtest.spl' )
@@ -747,4 +755,14 @@ func Test_init_spellfile()
747755 % bw !
748756endfunc
749757
758+ " Test for the 'mkspellmem' option
759+ func Test_mkspellmem_opt ()
760+ call assert_fails (' set mkspellmem=1000' , ' E474:' )
761+ call assert_fails (' set mkspellmem=1000,' , ' E474:' )
762+ call assert_fails (' set mkspellmem=1000,50' , ' E474:' )
763+ call assert_fails (' set mkspellmem=1000,50,' , ' E474:' )
764+ call assert_fails (' set mkspellmem=1000,50,10,' , ' E474:' )
765+ call assert_fails (' set mkspellmem=1000,50,0' , ' E474:' )
766+ endfunc
767+
750768" vim: shiftwidth = 2 sts = 2 expandtab
0 commit comments