comparison src/testdir/test_spellfile.vim @ 24758:857881ec1cb5 v8.2.2917

patch 8.2.2917: spellfile functionality not fully tested Commit: https://github.com/vim/vim/commit/bb162367ac77db877586086d7456685f2aeb8754 Author: Dominique Pelle <dominique.pelle@gmail.com> Date: Mon May 31 20:04:07 2021 +0200 patch 8.2.2917: spellfile functionality not fully tested Problem: Spellfile functionality not fully tested. Solution: Add tests for SFX with removal of characters, spelling suggestions with NOBREAK and others. (Dominique Pell?, closes #8293)
author Bram Moolenaar <Bram@vim.org>
date Mon, 31 May 2021 20:15:02 +0200
parents 71ace849e9f1
children 202bc982008b
comparison
equal deleted inserted replaced
24757:5754851476d7 24758:857881ec1cb5
679 " Wrong CHECKCOMPOUNDPATTERN flag value in an affix file 679 " Wrong CHECKCOMPOUNDPATTERN flag value in an affix file
680 call writefile(['CHECKCOMPOUNDPATTERN 0'], 'Xtest.aff') 680 call writefile(['CHECKCOMPOUNDPATTERN 0'], 'Xtest.aff')
681 let output = execute('mkspell! Xtest.spl Xtest') 681 let output = execute('mkspell! Xtest.spl Xtest')
682 call assert_match('Wrong CHECKCOMPOUNDPATTERN value in Xtest.aff line 1: 0', output) 682 call assert_match('Wrong CHECKCOMPOUNDPATTERN value in Xtest.aff line 1: 0', output)
683 683
684 " Both compounding and NOBREAK specified
685 call writefile(['COMPOUNDFLAG c', 'NOBREAK'], 'Xtest.aff')
686 let output = execute('mkspell! Xtest.spl Xtest')
687 call assert_match('Warning: both compounding and NOBREAK specified', output)
688
684 " Duplicate affix entry in an affix file 689 " Duplicate affix entry in an affix file
685 call writefile(['PFX L Y 1', 'PFX L 0 re x', 'PFX L Y 1', 'PFX L 0 re x'], 690 call writefile(['PFX L Y 1', 'PFX L 0 re x', 'PFX L Y 1', 'PFX L 0 re x'],
686 \ 'Xtest.aff') 691 \ 'Xtest.aff')
687 let output = execute('mkspell! Xtest.spl Xtest') 692 let output = execute('mkspell! Xtest.spl Xtest')
688 call assert_match('Duplicate affix in Xtest.aff line 3: L', output) 693 call assert_match('Duplicate affix in Xtest.aff line 3: L', output)
882 call assert_equal(['x', 'bad'], spellbadword('x')) 887 call assert_equal(['x', 'bad'], spellbadword('x'))
883 call assert_equal(['y', 'bad'], spellbadword('yone')) 888 call assert_equal(['y', 'bad'], spellbadword('yone'))
884 call assert_equal(['z', 'bad'], spellbadword('onez')) 889 call assert_equal(['z', 'bad'], spellbadword('onez'))
885 call assert_equal(['zero', 'bad'], spellbadword('Onetwozerothree')) 890 call assert_equal(['zero', 'bad'], spellbadword('Onetwozerothree'))
886 891
892 new
893 call setline(1, 'Onetwwothree')
894 norm! fw1z=
895 call assert_equal('Onetwothree', getline(1))
896 call setline(1, 'Onetwothre')
897 norm! fh1z=
898 call assert_equal('Onetwothree', getline(1))
899
900 bw!
887 set spell& spelllang& 901 set spell& spelllang&
888 call delete('XtestNOBREAK.dic') 902 call delete('XtestNOBREAK.dic')
889 call delete('XtestNOBREAK.aff') 903 call delete('XtestNOBREAK.aff')
890 call delete('XtestNOBREAK-utf8.spl') 904 call delete('XtestNOBREAK-utf8.spl')
891 endfunc 905 endfunc
997 call delete('XtestCIRCUMFIX.dic') 1011 call delete('XtestCIRCUMFIX.dic')
998 call delete('XtestCIRCUMFIX.aff') 1012 call delete('XtestCIRCUMFIX.aff')
999 call delete('XtestCIRCUMFIX-utf8.spl') 1013 call delete('XtestCIRCUMFIX-utf8.spl')
1000 endfunc 1014 endfunc
1001 1015
1016 " Test SFX that strips/chops characters
1017 func Test_spellfile_SFX_strip()
1018 " Simplified conjugation of Italian verbs ending in -are (first conjugation).
1019 call writefile(['SFX A Y 4',
1020 \ 'SFX A are iamo [^icg]are',
1021 \ 'SFX A are hiamo [cg]are',
1022 \ 'SFX A re mo iare',
1023 \ 'SFX A re vamo are'],
1024 \ 'XtestSFX.aff')
1025 " Examples of Italian verbs:
1026 " - cantare = to sing
1027 " - cercare = to search
1028 " - odiare = to hate
1029 call writefile(['3', 'cantare/A', 'cercare/A', 'odiare/A'], 'XtestSFX.dic')
1030
1031 mkspell! XtestSFX-utf8.spl XtestSFX
1032 set spell spelllang=XtestSFX-utf8.spl
1033
1034 " To sing, we're singing, we were singing.
1035 call assert_equal(['', ''], spellbadword('cantare cantiamo cantavamo'))
1036
1037 " To search, we're searching, we were searching.
1038 call assert_equal(['', ''], spellbadword('cercare cerchiamo cercavamo'))
1039
1040 " To hate, we hate, we were hating.
1041 call assert_equal(['', ''], spellbadword('odiare odiamo odiavamo'))
1042
1043 for badword in ['canthiamo', 'cerciamo', 'cantarevamo', 'odiiamo']
1044 call assert_equal([badword, 'bad'], spellbadword(badword))
1045 endfor
1046
1047 call assert_equal(['cantiamo'], spellsuggest('canthiamo', 1))
1048 call assert_equal(['cerchiamo'], spellsuggest('cerciamo', 1))
1049 call assert_equal(['cantavamo'], spellsuggest('cantarevamo', 1))
1050 call assert_equal(['odiamo'], spellsuggest('odiiamo', 1))
1051
1052 set spell& spelllang&
1053 call delete('XtestSFX.dic')
1054 call delete('XtestSFX.aff')
1055 call delete('XtestSFX-utf8.spl')
1056 endfunc
1057
1002 " When 'spellfile' is not set, adding a new good word will automatically set 1058 " When 'spellfile' is not set, adding a new good word will automatically set
1003 " the 'spellfile' 1059 " the 'spellfile'
1004 func Test_init_spellfile() 1060 func Test_init_spellfile()
1005 let save_rtp = &rtp 1061 let save_rtp = &rtp
1006 let save_encoding = &encoding 1062 let save_encoding = &encoding