Skip to content

Commit bb16236

Browse files
dpellebrammool
authored andcommitted
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)
1 parent 2ac7184 commit bb16236

2 files changed

Lines changed: 58 additions & 0 deletions

File tree

src/testdir/test_spellfile.vim

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -681,6 +681,11 @@ func Test_aff_file_format_error()
681681
let output = execute('mkspell! Xtest.spl Xtest')
682682
call assert_match('Wrong CHECKCOMPOUNDPATTERN value in Xtest.aff line 1: 0', output)
683683

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+
684689
" Duplicate affix entry in an affix file
685690
call writefile(['PFX L Y 1', 'PFX L 0 re x', 'PFX L Y 1', 'PFX L 0 re x'],
686691
\ 'Xtest.aff')
@@ -884,6 +889,15 @@ func Test_NOBREAK()
884889
call assert_equal(['z', 'bad'], spellbadword('onez'))
885890
call assert_equal(['zero', 'bad'], spellbadword('Onetwozerothree'))
886891

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!
887901
set spell& spelllang&
888902
call delete('XtestNOBREAK.dic')
889903
call delete('XtestNOBREAK.aff')
@@ -999,6 +1013,48 @@ func Test_spellfile_CIRCUMFIX()
9991013
call delete('XtestCIRCUMFIX-utf8.spl')
10001014
endfunc
10011015

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+
10021058
" When 'spellfile' is not set, adding a new good word will automatically set
10031059
" the 'spellfile'
10041060
func Test_init_spellfile()

src/version.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -750,6 +750,8 @@ static char *(features[]) =
750750

751751
static int included_patches[] =
752752
{ /* Add new patch number below this line */
753+
/**/
754+
2917,
753755
/**/
754756
2916,
755757
/**/

0 commit comments

Comments
 (0)