aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJan Edmund Lazo <jan.lazo@mail.utoronto.ca>2021-06-12 02:22:23 -0400
committerJan Edmund Lazo <jan.lazo@mail.utoronto.ca>2021-06-12 13:06:50 -0400
commit6a4685fb0e62dbd7955f8698e3aa82f885026036 (patch)
treef7167b901cd2fa667a4a835fe9153d5411b678ab
parent72b512bd530afe7937d5ed8a9b68da889669bf80 (diff)
downloadrneovim-6a4685fb0e62dbd7955f8698e3aa82f885026036.tar.gz
rneovim-6a4685fb0e62dbd7955f8698e3aa82f885026036.tar.bz2
rneovim-6a4685fb0e62dbd7955f8698e3aa82f885026036.zip
vim-patch:8.2.2896: spellfile functionality not fully tested
Problem: Spellfile functionality not fully tested. Solution: Add tests for CHECKCOMPOUNDPATTERN and COMMON. (Dominique Pellé, closes vim/vim#8270) https://github.com/vim/vim/commit/dc3275a1ac73b6c4d0c9d2e238ea80b477705b6f
-rw-r--r--src/nvim/testdir/test_spellfile.vim68
1 files changed, 68 insertions, 0 deletions
diff --git a/src/nvim/testdir/test_spellfile.vim b/src/nvim/testdir/test_spellfile.vim
index 53eca84e44..729467b556 100644
--- a/src/nvim/testdir/test_spellfile.vim
+++ b/src/nvim/testdir/test_spellfile.vim
@@ -170,3 +170,71 @@ func Test_spell_normal()
set spellfile=
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
+
+" vim: shiftwidth=2 sts=2 expandtab