]> granicus.if.org Git - vim/commitdiff
patch 8.1.0200: spellbadword() not tested v8.1.0200
authorBram Moolenaar <Bram@vim.org>
Fri, 20 Jul 2018 21:36:26 +0000 (23:36 +0200)
committerBram Moolenaar <Bram@vim.org>
Fri, 20 Jul 2018 21:36:26 +0000 (23:36 +0200)
Problem:    spellbadword() not tested.
Solution:   Add a test. (Dominique Pelle, closes #3235)

src/testdir/test_spell.vim
src/version.c

index 3e8ba1defa320854d2b2e5fa9d50fdfcbc32c3a4..d9d8f6062e7a842d46ba59fa75c2a0394f9d87e8 100644 (file)
@@ -68,6 +68,47 @@ func Test_z_equal_on_invalid_utf8_word()
   bwipe!
 endfunc
 
+" Test spellbadword() with argument
+func Test_spellbadword()
+  set spell
+
+  call assert_equal(['bycycle', 'bad'],  spellbadword('My bycycle.'))
+  call assert_equal(['another', 'caps'], spellbadword('A sentence. another sentence'))
+
+  set spelllang=en
+  call assert_equal(['', ''],            spellbadword('centre'))
+  call assert_equal(['', ''],            spellbadword('center'))
+  set spelllang=en_us
+  call assert_equal(['centre', 'local'], spellbadword('centre'))
+  call assert_equal(['', ''],            spellbadword('center'))
+  set spelllang=en_gb
+  call assert_equal(['', ''],            spellbadword('centre'))
+  call assert_equal(['center', 'local'], spellbadword('center'))
+
+  " Create a small word list to test that spellbadword('...')
+  " can return ['...', 'rare'].
+  e Xwords
+  insert
+foo
+foobar/?
+.
+   w!
+   mkspell! Xwords.spl Xwords
+   set spelllang=Xwords.spl
+   call assert_equal(['foobar', 'rare'], spellbadword('foo foobar'))
+
+  " Typo should not be detected 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 delete('Xwords.spl')
+  call delete('Xwords')
+  set spelllang&
+  set spell&
+endfunc
+
 func Test_spellreall()
   new
   set spell
index f5996d8bd13cabd98abdbe7f6dc8a678fa8f4589..2d5a1310f43f37fe48e9f4e820306de51a1a4b3a 100644 (file)
@@ -789,6 +789,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    200,
 /**/
     199,
 /**/