Merge pull request #19221 from zeertzjq/vim-8.2.1808

vim-patch:8.2.{1808,5098},9.0.0034
This commit is contained in:
zeertzjq
2022-07-04 18:59:27 +08:00
committed by GitHub
2 changed files with 85 additions and 7 deletions

View File

@@ -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)

View File

@@ -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