]> git.ipfire.org Git - thirdparty/vim.git/commitdiff
patch 8.2.3213: NOCOMPOUNDSUGS entry in spell file not tested v8.2.3213
authorDominique Pelle <dominique.pelle@gmail.com>
Sat, 24 Jul 2021 18:51:13 +0000 (20:51 +0200)
committerBram Moolenaar <Bram@vim.org>
Sat, 24 Jul 2021 18:51:13 +0000 (20:51 +0200)
Problem:    NOCOMPOUNDSUGS entry in spell file not tested.
Solution:   Add a test. (Dominique PellĂ©, closes #8624)

src/testdir/test_spellfile.vim
src/version.c

index b7bb50198ff3279fd2c22f5fca1c31f95f599cf6..c0852e090f0cd6da00e5f14e20c829833baf705f 100644 (file)
@@ -943,6 +943,52 @@ func Test_spellfile_CHECKCOMPOUNDPATTERN()
   call delete('XtestCHECKCOMPOUNDPATTERN-utf8.spl')
 endfunc
 
+" Test NOCOMPOUNDSUGS (see :help spell-NOCOMPOUNDSUGS)
+func Test_spellfile_NOCOMPOUNDSUGS()
+  call writefile(['3',
+        \         'one/c',
+        \         'two/c',
+        \         'three/c'], 'XtestNOCOMPOUNDSUGS.dic')
+
+  " pass 0 tests without NOCOMPOUNDSUGS, pass 1 tests with NOCOMPOUNDSUGS
+  for pass in [0, 1]
+    if pass == 0
+      call writefile(['COMPOUNDFLAG c'], 'XtestNOCOMPOUNDSUGS.aff')
+    else
+      call writefile(['NOCOMPOUNDSUGS',
+          \           'COMPOUNDFLAG c'], 'XtestNOCOMPOUNDSUGS.aff')
+    endif
+
+    mkspell! XtestNOCOMPOUNDSUGS-utf8.spl XtestNOCOMPOUNDSUGS
+    set spell spelllang=XtestNOCOMPOUNDSUGS-utf8.spl
+
+    for goodword in ['one', 'two', 'three',
+          \          'oneone', 'onetwo',  'onethree',
+          \          'twoone', 'twotwo', 'twothree',
+          \          'threeone', 'threetwo', 'threethree',
+          \          'onetwothree', 'onethreetwo', 'twothreeone', 'oneoneone']
+      call assert_equal(['', ''], spellbadword(goodword), goodword)
+    endfor
+
+    for badword in ['four', 'onetwox', 'onexone']
+      call assert_equal([badword, 'bad'], spellbadword(badword))
+    endfor
+
+    if pass == 0
+      call assert_equal(['one', 'oneone'], spellsuggest('onne', 2))
+      call assert_equal(['onethree', 'one three'], spellsuggest('onethre', 2))
+    else
+      call assert_equal(['one', 'one one'], spellsuggest('onne', 2))
+      call assert_equal(['one three'], spellsuggest('onethre', 2))
+    endif
+  endfor
+
+  set spell& spelllang&
+  call delete('XtestNOCOMPOUNDSUGS.dic')
+  call delete('XtestNOCOMPOUNDSUGS.aff')
+  call delete('XtestNOCOMPOUNDSUGS-utf8.spl')
+endfunc
+
 " Test COMMON (better suggestions with common words, see :help spell-COMMON)
 func Test_spellfile_COMMON()
   call writefile(['7',
index 2b992dbfd4676149292f8bd290ce4fe394a6a020..d73bddb4fe82682cbfad17052030ee2f5dac8199 100644 (file)
@@ -755,6 +755,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    3213,
 /**/
     3212,
 /**/