Patch 8.2.2902
Problem: Spellfile functionality not fully tested.
Solution: Add tests for CIRCUMFIX, NOBREAK and others. (Dominique Pellé,
closes #8283)
Files: src/testdir/test_spellfile.vim
*** ../vim-8.2.2901/src/testdir/test_spellfile.vim 2021-05-28
18:32:08.646074589 +0200
--- src/testdir/test_spellfile.vim 2021-05-29 17:27:37.713750829 +0200
***************
*** 583,588 ****
--- 583,595 ----
call assert_fails('mkspell! Xtest.spl Xtest.dic', 'E17:')
call delete('Xtest.spl', 'rf')
+ " can't write the .spl file as its directory does not exist
+ call writefile([], 'Xtest.aff')
+ call writefile([], 'Xtest.dic')
+ call assert_fails('mkspell DOES_NOT_EXIT/Xtest.spl Xtest.dic', 'E484:')
+ call delete('Xtest.aff')
+ call delete('Xtest.dic')
+
call assert_fails('mkspell en en_US abc_xyz', 'E755:')
endfunc
***************
*** 842,847 ****
--- 849,895 ----
%bw!
endfunc
+ func Test_spellfile_verbose()
+ call writefile(['1', 'one'], 'XtestVerbose.dic')
+ call writefile([], 'XtestVerbose.aff')
+ mkspell! XtestVerbose-utf8.spl XtestVerbose
+ set spell
+
+ " First time: the spl file should be read.
+ let a = execute('3verbose set spelllang=XtestVerbose-utf8.spl')
+ call assert_match('Reading spell file "XtestVerbose-utf8.spl"', a)
+
+ " Second time time: the spl file should not be read (already read).
+ let a = execute('3verbose set spelllang=XtestVerbose-utf8.spl')
+ call assert_notmatch('Reading spell file "XtestVerbose-utf8.spl"', a)
+
+ set spell& spelllang&
+ call delete('XtestVerbose.dic')
+ call delete('XtestVerbose.aff')
+ call delete('XtestVerbose-utf8.spl')
+ endfunc
+
+ " Test NOBREAK (see :help spell-NOBREAK)
+ func Test_NOBREAK()
+ call writefile(['3', 'one', 'two', 'three' ], 'XtestNOBREAK.dic')
+ call writefile(['NOBREAK' ], 'XtestNOBREAK.aff')
+
+ mkspell! XtestNOBREAK-utf8.spl XtestNOBREAK
+ set spell spelllang=XtestNOBREAK-utf8.spl
+
+ call assert_equal(['', ''], spellbadword('One two three onetwo onetwothree
threetwoone'))
+
+ call assert_equal(['x', 'bad'], spellbadword('x'))
+ call assert_equal(['y', 'bad'], spellbadword('yone'))
+ call assert_equal(['z', 'bad'], spellbadword('onez'))
+ call assert_equal(['zero', 'bad'], spellbadword('Onetwozerothree'))
+
+ set spell& spelllang&
+ call delete('XtestNOBREAK.dic')
+ call delete('XtestNOBREAK.aff')
+ call delete('XtestNOBREAK-utf8.spl')
+ endfunc
+
" Test CHECKCOMPOUNDPATTERN (see :help spell-CHECKCOMPOUNDPATTERN)
func Test_spellfile_CHECKCOMPOUNDPATTERN()
call writefile(['4',
***************
*** 854,860 ****
\ '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.
--- 902,908 ----
\ 'CHECKCOMPOUNDPATTERN wo on',
\ 'COMPOUNDFLAG c'], 'XtestCHECKCOMPOUNDPATTERN.aff')
! mkspell! XtestCHECKCOMPOUNDPATTERN-utf8.spl XtestCHECKCOMPOUNDPATTERN
set spell spelllang=XtestCHECKCOMPOUNDPATTERN-utf8.spl
" Check valid words with and without valid compounds.
***************
*** 893,899 ****
\ '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.
--- 941,947 ----
\ 'ted'], 'XtestCOMMON.dic')
call writefile(['COMMON the and'], 'XtestCOMMON.aff')
! mkspell! XtestCOMMON-utf8.spl XtestCOMMON
set spell spelllang=XtestCOMMON-utf8.spl
" COMMON words 'and' and 'the' should be the top suggestions.
***************
*** 908,913 ****
--- 956,1004 ----
call delete('XtestCOMMON-utf8.spl')
endfunc
+ " Test CIRCUMFIX (see: :help spell-CIRCUMFIX)
+ func Test_spellfile_CIRCUMFIX()
+ " Example taken verbatim from
https://github.com/hunspell/hunspell/tree/master/tests
+ call writefile(['1',
+ \ 'nagy/C po:adj'], 'XtestCIRCUMFIX.dic')
+ call writefile(['# circumfixes: ~ obligate prefix/suffix combinations',
+ \ '# superlative in Hungarian: leg- (prefix) AND -bb
(suffix)',
+ \ '',
+ \ 'CIRCUMFIX X',
+ \ '',
+ \ 'PFX A Y 1',
+ \ 'PFX A 0 leg/X .',
+ \ '',
+ \ 'PFX B Y 1',
+ \ 'PFX B 0 legesleg/X .',
+ \ '',
+ \ 'SFX C Y 3',
+ \ 'SFX C 0 obb . is:COMPARATIVE',
+ \ 'SFX C 0 obb/AX . is:SUPERLATIVE',
+ \ 'SFX C 0 obb/BX . is:SUPERSUPERLATIVE'],
'XtestCIRCUMFIX.aff')
+
+ mkspell! XtestCIRCUMFIX-utf8.spl XtestCIRCUMFIX
+ set spell spelllang=XtestCIRCUMFIX-utf8.spl
+
+ " From https://catalog.ldc.upenn.edu/docs/LDC2008T01/acta04.pdf:
+ " Hungarian English
+ " --------- -------
+ " nagy great
+ " nagyobb greater
+ " legnagyobb greatest
+ " legeslegnagyob most greatest
+ call assert_equal(['', ''], spellbadword('nagy nagyobb legnagyobb
legeslegnagyobb'))
+
+ for badword in ['legnagy', 'legeslegnagy', 'legobb', 'legeslegobb']
+ call assert_equal([badword, 'bad'], spellbadword(badword))
+ endfor
+
+ set spell& spelllang&
+ call delete('XtestCIRCUMFIX.dic')
+ call delete('XtestCIRCUMFIX.aff')
+ call delete('XtestCIRCUMFIX-utf8.spl')
+ endfunc
+
" When 'spellfile' is not set, adding a new good word will automatically set
" the 'spellfile'
func Test_init_spellfile()
*** ../vim-8.2.2901/src/version.c 2021-05-29 16:30:08.674611431 +0200
--- src/version.c 2021-05-29 17:29:19.741492674 +0200
***************
*** 752,753 ****
--- 752,755 ----
{ /* Add new patch number below this line */
+ /**/
+ 2902,
/**/
--
Time flies like an arrow.
Fruit flies like a banana.
/// Bram Moolenaar -- [email protected] -- http://www.Moolenaar.net \\\
/// \\\
\\\ sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ ///
\\\ help me help AIDS victims -- http://ICCF-Holland.org ///
--
--
You received this message from the "vim_dev" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php
---
You received this message because you are subscribed to the Google Groups
"vim_dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/vim_dev/202105291530.14TFU4g91544044%40masaka.moolenaar.net.