aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorzeertzjq <zeertzjq@outlook.com>2022-07-04 18:59:27 +0800
committerGitHub <noreply@github.com>2022-07-04 18:59:27 +0800
commitab5929e1b0f13b8750c8a97d41396ac9a0769e18 (patch)
tree2087ea58dbd46f6215e1e57f5ebe54416980af5d
parent436747752bf1016d93101de24e39e192a0b721b4 (diff)
parenta4160dd1052b20f4ea33be46b5ed7d6dee31dba7 (diff)
downloadrneovim-ab5929e1b0f13b8750c8a97d41396ac9a0769e18.tar.gz
rneovim-ab5929e1b0f13b8750c8a97d41396ac9a0769e18.tar.bz2
rneovim-ab5929e1b0f13b8750c8a97d41396ac9a0769e18.zip
Merge pull request #19221 from zeertzjq/vim-8.2.1808
vim-patch:8.2.{1808,5098},9.0.0034
-rw-r--r--src/nvim/testdir/test_spell.vim85
-rw-r--r--src/nvim/testdir/test_spell_utf8.vim7
2 files changed, 85 insertions, 7 deletions
diff --git a/src/nvim/testdir/test_spell.vim b/src/nvim/testdir/test_spell.vim
index b768dc1814..1db0a01bd8 100644
--- a/src/nvim/testdir/test_spell.vim
+++ b/src/nvim/testdir/test_spell.vim
@@ -16,6 +16,8 @@ func TearDown()
call delete('Xtest.latin1.add.spl')
call delete('Xtest.latin1.spl')
call delete('Xtest.latin1.sug')
+ " set 'encoding' to clear the word list
+ set encoding=utf-8
endfunc
func Test_wrap_search()
@@ -149,12 +151,88 @@ func Test_spell_file_missing()
augroup END
call assert_fails('set spell spelllang=ab_cd', 'E797:')
+ " clean up
+ augroup TestSpellFileMissing
+ autocmd! SpellFileMissing
+ augroup END
augroup! TestSpellFileMissing
unlet s:spell_file_missing
set spell& spelllang&
%bwipe!
endfunc
+func Test_spelldump()
+ " In case the spell file is not found avoid getting the download dialog, we
+ " would get stuck at the prompt.
+ let g:en_not_found = 0
+ augroup TestSpellFileMissing
+ au! SpellFileMissing * let g:en_not_found = 1
+ augroup END
+ set spell spelllang=en
+ spellrare! emacs
+ if g:en_not_found
+ call assert_report("Could not find English spell file")
+ else
+ spelldump
+
+ " Check assumption about region: 1: us, 2: au, 3: ca, 4: gb, 5: nz.
+ call assert_equal('/regions=usaucagbnz', getline(1))
+ call assert_notequal(0, search('^theater/1$')) " US English only.
+ call assert_notequal(0, search('^theatre/2345$')) " AU, CA, GB or NZ English.
+
+ call assert_notequal(0, search('^emacs/?$')) " ? for a rare word.
+ call assert_notequal(0, search('^the the/!$')) " ! for a wrong word.
+ endif
+
+ " clean up
+ unlet g:en_not_found
+ augroup TestSpellFileMissing
+ autocmd! SpellFileMissing
+ augroup END
+ augroup! TestSpellFileMissing
+ bwipe
+ set spell&
+endfunc
+
+func Test_spelldump_bang()
+ new
+ call setline(1, 'This is a sample sentence.')
+ redraw
+
+ " In case the spell file is not found avoid getting the download dialog, we
+ " would get stuck at the prompt.
+ let g:en_not_found = 0
+ augroup TestSpellFileMissing
+ au! SpellFileMissing * let g:en_not_found = 1
+ augroup END
+
+ set spell
+
+ if g:en_not_found
+ call assert_report("Could not find English spell file")
+ else
+ redraw
+ spelldump!
+
+ " :spelldump! includes the number of times a word was found while updating
+ " the screen.
+ " Common word count starts at 10, regular word count starts at 0.
+ call assert_notequal(0, search("^is\t11$")) " common word found once.
+ call assert_notequal(0, search("^the\t10$")) " common word never found.
+ call assert_notequal(0, search("^sample\t1$")) " regular word found once.
+ call assert_equal(0, search("^screen\t")) " regular word never found.
+ endif
+
+ " clean up
+ unlet g:en_not_found
+ augroup TestSpellFileMissing
+ autocmd! SpellFileMissing
+ augroup END
+ augroup! TestSpellFileMissing
+ %bwipe!
+ set spell&
+endfunc
+
func Test_spelllang_inv_region()
set spell spelllang=en_xx
let messages = GetMessages()
@@ -650,6 +728,10 @@ func Test_zz_sal_and_addition()
set spl=Xtest_ca.latin1.spl
call assert_equal("elequint", FirstSpellWord())
call assert_equal("elekwint", SecondSpellWord())
+
+ bwipe!
+ set spellfile=
+ set spl&
endfunc
func Test_spellfile_value()
@@ -733,9 +815,6 @@ func Test_spell_good_word_invalid()
sil! norm z=
bwipe!
- " clear the internal word list
- " set enc=latin1
- set enc=utf-8
endfunc
func LoadAffAndDic(aff_contents, dic_contents)
diff --git a/src/nvim/testdir/test_spell_utf8.vim b/src/nvim/testdir/test_spell_utf8.vim
index 2fd176557d..b7e3da37cb 100644
--- a/src/nvim/testdir/test_spell_utf8.vim
+++ b/src/nvim/testdir/test_spell_utf8.vim
@@ -13,6 +13,8 @@ func TearDown()
call delete('Xtest.utf-8.add.spl')
call delete('Xtest.utf-8.spl')
call delete('Xtest.utf-8.sug')
+ " set 'encoding' to clear the word list
+ set encoding=utf-8
endfunc
let g:test_data_aff1 = [
@@ -484,7 +486,6 @@ let g:test_data_aff_sal = [
\ ]
func LoadAffAndDic(aff_contents, dic_contents)
- set enc=utf-8
set spellfile=
call writefile(a:aff_contents, "Xtest.aff")
call writefile(a:dic_contents, "Xtest.dic")
@@ -760,6 +761,7 @@ func Test_spell_sal_and_addition()
call assert_equal("elequint", FirstSpellWord())
call assert_equal("elekwint", SecondSpellWord())
+ bwipe!
set spellfile=
set spl&
endfunc
@@ -803,8 +805,6 @@ func Test_word_index()
sil norm z=
bwipe!
- " clear the word list
- set enc=utf-8
call delete('Xtmpfile')
endfunc
@@ -817,7 +817,6 @@ func Test_check_empty_line()
sil! norm P]svc
norm P]s
- " TODO: should we clear the word list?
bwipe!
endfunc