aboutsummaryrefslogtreecommitdiff
path: root/src/nvim/testdir
diff options
context:
space:
mode:
authorJan Edmund Lazo <jan.lazo@mail.utoronto.ca>2021-06-11 22:43:22 -0400
committerJan Edmund Lazo <jan.lazo@mail.utoronto.ca>2021-06-12 13:06:50 -0400
commit72b512bd530afe7937d5ed8a9b68da889669bf80 (patch)
treee84aa74823c0847b1934f5cca7517d5db6b3d0a3 /src/nvim/testdir
parent82d1c29bfd652c74fad8b9a4d403ffdf45c05321 (diff)
downloadrneovim-72b512bd530afe7937d5ed8a9b68da889669bf80.tar.gz
rneovim-72b512bd530afe7937d5ed8a9b68da889669bf80.tar.bz2
rneovim-72b512bd530afe7937d5ed8a9b68da889669bf80.zip
vim-patch:8.2.0945: cannot use "z=" when 'spell' is off
Problem: Cannot use "z=" when 'spell' is off. Solution: Make "z=" work even when 'spell' is off. (Christian Brabandt, Gary Johnson, closes vim/vim#6227) https://github.com/vim/vim/commit/152e79e94bb935e75b866bd55479648cde11066a
Diffstat (limited to 'src/nvim/testdir')
-rw-r--r--src/nvim/testdir/test_spell.vim48
1 files changed, 43 insertions, 5 deletions
diff --git a/src/nvim/testdir/test_spell.vim b/src/nvim/testdir/test_spell.vim
index 78b37df098..e525d06ea2 100644
--- a/src/nvim/testdir/test_spell.vim
+++ b/src/nvim/testdir/test_spell.vim
@@ -106,11 +106,14 @@ foobar/?
set spelllang=Xwords.spl
call assert_equal(['foobar', 'rare'], spellbadword('foo foobar'))
- " Typo should not be detected without the 'spell' option.
+ " Typo should be detected even without the 'spell' option.
set spelllang=en_gb nospell
call assert_equal(['', ''], spellbadword('centre'))
- call assert_equal(['', ''], spellbadword('My bycycle.'))
- call assert_equal(['', ''], spellbadword('A sentence. another sentence'))
+ call assert_equal(['bycycle', 'bad'], spellbadword('My bycycle.'))
+ call assert_equal(['another', 'caps'], spellbadword('A sentence. another sentence'))
+
+ set spelllang=
+ call assert_fails("call spellbadword('maxch')", 'E756:')
call delete('Xwords.spl')
call delete('Xwords')
@@ -174,9 +177,9 @@ endfunc
" Test spellsuggest({word} [, {max} [, {capital}]])
func Test_spellsuggest()
- " No suggestions when spell checking is not enabled.
+ " Verify suggestions are given even when spell checking is not enabled.
set nospell
- call assert_equal([], spellsuggest('marrch'))
+ call assert_equal(['march', 'March'], spellsuggest('marrch', 2))
set spell
@@ -204,6 +207,13 @@ func Test_spellsuggest()
call assert_equal(['Third'], spellsuggest('THird', 1))
call assert_equal(['All'], spellsuggest('ALl', 1))
+ call assert_fails("call spellsuggest('maxch', [])", 'E745:')
+ call assert_fails("call spellsuggest('maxch', 2, [])", 'E745:')
+
+ set spelllang=
+ call assert_fails("call spellsuggest('maxch')", 'E756:')
+ set spelllang&
+
set spell&
endfunc
@@ -631,6 +641,34 @@ func Test_zeq_crash()
bwipe!
endfunc
+" Check that z= works even when 'nospell' is set. This test uses one of the
+" tests in Test_spellsuggest_option_number() just to verify that z= basically
+" works and that "E756: Spell checking is not enabled" is not generated.
+func Test_zeq_nospell()
+ new
+ set nospell spellsuggest=1,best
+ call setline(1, 'A baord')
+ try
+ norm $1z=
+ call assert_equal('A board', getline(1))
+ catch
+ call assert_report("Caught exception: " . v:exception)
+ endtry
+ set spell& spellsuggest&
+ bwipe!
+endfunc
+
+" Check that "E756: Spell checking is not possible" is reported when z= is
+" executed and 'spelllang' is empty.
+func Test_zeq_no_spelllang()
+ new
+ set spelllang= spellsuggest=1,best
+ call setline(1, 'A baord')
+ call assert_fails('normal $1z=', 'E756:')
+ set spelllang& spellsuggest&
+ bwipe!
+endfunc
+
" Check handling a word longer than MAXWLEN.
func Test_spell_long_word()
set enc=utf-8