From d9c63507f89c616df21d6f840fedce3431c53f16 Mon Sep 17 00:00:00 2001 From: zeertzjq Date: Mon, 4 Jul 2022 18:37:27 +0800 Subject: vim-patch:8.2.1808: no test coverage for ":spelldump!" MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Problem: No test coverage for ":spelldump!". Solution: Add a test. (Dominique Pellé, closes vim/vim#7089) https://github.com/vim/vim/commit/f12f0022e6698831681f0931a4e7e5298f6ef0d8 --- src/nvim/testdir/test_spell.vim | 38 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) (limited to 'src') diff --git a/src/nvim/testdir/test_spell.vim b/src/nvim/testdir/test_spell.vim index b768dc1814..61e000c8da 100644 --- a/src/nvim/testdir/test_spell.vim +++ b/src/nvim/testdir/test_spell.vim @@ -155,6 +155,44 @@ func Test_spell_file_missing() %bwipe! endfunc +func Test_spelldump() + set spell spelllang=en + spellrare! emacs + + 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. + + bwipe + set spell& +endfunc + +func Test_spelldump_bang() + new + call setline(1, 'This is a sample sentence.') + redraw + set spell + 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. + + %bwipe! + set spell& +endfunc + func Test_spelllang_inv_region() set spell spelllang=en_xx let messages = GetMessages() -- cgit From 08aba02ad7646e4a21ba3dfe63dbaf3c58f75406 Mon Sep 17 00:00:00 2001 From: zeertzjq Date: Mon, 4 Jul 2022 18:37:42 +0800 Subject: vim-patch:8.2.5098: spelldump test sometimes hangs Problem: Spelldump test sometimes hangs. Solution: Catch the problem of the spell file not being found to avoid hanging in the download dialog. https://github.com/vim/vim/commit/fc9f0fd6d18c03d6420f84ebb374a373c830fbad --- src/nvim/testdir/test_spell.vim | 72 +++++++++++++++++++++++++++++++---------- 1 file changed, 55 insertions(+), 17 deletions(-) (limited to 'src') diff --git a/src/nvim/testdir/test_spell.vim b/src/nvim/testdir/test_spell.vim index 61e000c8da..f3aaf43100 100644 --- a/src/nvim/testdir/test_spell.vim +++ b/src/nvim/testdir/test_spell.vim @@ -149,6 +149,10 @@ 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& @@ -156,19 +160,34 @@ func Test_spell_file_missing() 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 - 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. + " 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. + 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 @@ -177,18 +196,37 @@ 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 - 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. + 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 -- cgit From a4160dd1052b20f4ea33be46b5ed7d6dee31dba7 Mon Sep 17 00:00:00 2001 From: zeertzjq Date: Mon, 4 Jul 2022 18:38:00 +0800 Subject: vim-patch:9.0.0034: spell tests do not always clear the word list Problem: Spell tests do not always clear the word list. Solution: Clear the word list in TearDown(). (closes vim/vim#10659) https://github.com/vim/vim/commit/288ed23e3929ff55a8ae30db0ba3f57b6f119dc8 --- src/nvim/testdir/test_spell.vim | 9 ++++++--- src/nvim/testdir/test_spell_utf8.vim | 7 +++---- 2 files changed, 9 insertions(+), 7 deletions(-) (limited to 'src') diff --git a/src/nvim/testdir/test_spell.vim b/src/nvim/testdir/test_spell.vim index f3aaf43100..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() @@ -726,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() @@ -809,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 -- cgit