summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDominique Pelle <dominique.pelle@gmail.com>2021-05-28 18:32:12 +0200
committerBram Moolenaar <Bram@vim.org>2021-05-28 18:32:12 +0200
commitdc3275a1ac73b6c4d0c9d2e238ea80b477705b6f (patch)
treed0dd45fa291ee133f2719382bf3f9a702f7a9b00
parent4ac198c61cb3097d4839d5a697cc8b2b256ac575 (diff)
patch 8.2.2896: spellfile functionality not fully testedv8.2.2896
Problem: Spellfile functionality not fully tested. Solution: Add tests for CHECKCOMPOUNDPATTERN and COMMON. (Dominique Pellé, closes #8270)
-rw-r--r--src/testdir/test_spellfile.vim66
-rw-r--r--src/version.c2
2 files changed, 68 insertions, 0 deletions
diff --git a/src/testdir/test_spellfile.vim b/src/testdir/test_spellfile.vim
index 410553daf4..2497fd2ccd 100644
--- a/src/testdir/test_spellfile.vim
+++ b/src/testdir/test_spellfile.vim
@@ -842,6 +842,72 @@ func Test_spell_add_word()
%bw!
endfunc
+" Test CHECKCOMPOUNDPATTERN (see :help spell-CHECKCOMPOUNDPATTERN)
+func Test_spellfile_CHECKCOMPOUNDPATTERN()
+ call writefile(['4',
+ \ 'one/c',
+ \ 'two/c',
+ \ 'three/c',
+ \ 'four'], 'XtestCHECKCOMPOUNDPATTERN.dic')
+ " Forbid compound words where first word ends with 'wo' and second starts with 'on'.
+ call writefile(['CHECKCOMPOUNDPATTERN 1',
+ \ 'CHECKCOMPOUNDPATTERN wo on',
+ \ 'COMPOUNDFLAG c'], 'XtestCHECKCOMPOUNDPATTERN.aff')
+
+ let output = execute('mkspell! XtestCHECKCOMPOUNDPATTERN-utf8.spl XtestCHECKCOMPOUNDPATTERN')
+ set spell spelllang=XtestCHECKCOMPOUNDPATTERN-utf8.spl
+
+ " Check valid words with and without valid compounds.
+ for goodword in ['one', 'two', 'three', 'four',
+ \ 'oneone', 'onetwo', 'onethree',
+ \ 'twotwo', 'twothree',
+ \ 'threeone', 'threetwo', 'threethree',
+ \ 'onetwothree', 'onethreetwo', 'twothreeone', 'oneoneone']
+ call assert_equal(['', ''], spellbadword(goodword), goodword)
+ endfor
+
+ " Compounds 'twoone' or 'threetwoone' should be forbidden by CHECKCOMPOUNPATTERN.
+ " 'four' does not have the 'c' flag in *.aff file so no compound.
+ " 'five' is not in the *.dic file.
+ for badword in ['five', 'onetwox',
+ \ 'twoone', 'threetwoone',
+ \ 'fourone', 'onefour']
+ call assert_equal([badword, 'bad'], spellbadword(badword))
+ endfor
+
+ set spell& spelllang&
+ call delete('XtestCHECKCOMPOUNDPATTERN.dic')
+ call delete('XtestCHECKCOMPOUNDPATTERN.aff')
+ call delete('XtestCHECKCOMPOUNDPATTERN-utf8.spl')
+endfunc
+
+" Test COMMON (better suggestions with common words, see :help spell-COMMON)
+func Test_spellfile_COMMON()
+ call writefile(['7',
+ \ 'and',
+ \ 'ant',
+ \ 'end',
+ \ 'any',
+ \ 'tee',
+ \ 'the',
+ \ 'ted'], 'XtestCOMMON.dic')
+ call writefile(['COMMON the and'], 'XtestCOMMON.aff')
+
+ let output = execute('mkspell! XtestCOMMON-utf8.spl XtestCOMMON')
+ set spell spelllang=XtestCOMMON-utf8.spl
+
+ " COMMON words 'and' and 'the' should be the top suggestions.
+ call assert_equal(['and', 'ant'], spellsuggest('anr', 2))
+ call assert_equal(['and', 'end'], spellsuggest('ond', 2))
+ call assert_equal(['the', 'ted'], spellsuggest('tha', 2))
+ call assert_equal(['the', 'tee'], spellsuggest('dhe', 2))
+
+ set spell& spelllang&
+ call delete('XtestCOMMON.dic')
+ call delete('XtestCOMMON.aff')
+ call delete('XtestCOMMON-utf8.spl')
+endfunc
+
" When 'spellfile' is not set, adding a new good word will automatically set
" the 'spellfile'
func Test_init_spellfile()
diff --git a/src/version.c b/src/version.c
index 7c7e1136fe..b20a149fa7 100644
--- a/src/version.c
+++ b/src/version.c
@@ -751,6 +751,8 @@ static char *(features[]) =
static int included_patches[] =
{ /* Add new patch number below this line */
/**/
+ 2896,
+/**/
2895,
/**/
2894,