summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBram Moolenaar <Bram@vim.org>2019-12-26 14:30:15 +0100
committerBram Moolenaar <Bram@vim.org>2019-12-26 14:30:15 +0100
commit767340574b5a0c697e650b3bbc3a4af10e51cb89 (patch)
tree113a01445cdd36232ad7c0c2a1e0251b9056758a
parentec57ec692eb228ee061824a190d7c451f029c430 (diff)
downloadvim-git-767340574b5a0c697e650b3bbc3a4af10e51cb89.tar.gz
patch 8.2.0046: tests for spell suggestions are slowv8.2.0046
Problem: Tests for spell suggestions are slow. Solution: Use shorter words. Test with latin1 and utf-8 to cover more code. (Dominique Pelle, closes #5399)
-rw-r--r--src/testdir/test_spell.vim93
-rw-r--r--src/version.c2
2 files changed, 50 insertions, 45 deletions
diff --git a/src/testdir/test_spell.vim b/src/testdir/test_spell.vim
index 7080c203b..0ebf33adf 100644
--- a/src/testdir/test_spell.vim
+++ b/src/testdir/test_spell.vim
@@ -132,19 +132,19 @@ endfunc
func Test_spellsuggest()
" No suggestions when spell checking is not enabled.
set nospell
- call assert_equal([], spellsuggest('mercurry'))
+ call assert_equal([], spellsuggest('marrch'))
set spell
" With 1 argument.
- call assert_equal(['mercury', 'Mercury'], spellsuggest('mercurry')[0:1])
+ call assert_equal(['march', 'March'], spellsuggest('marrch')[0:1])
" With 2 arguments.
- call assert_equal(['mercury', 'Mercury'], spellsuggest('mercurry', 2))
+ call assert_equal(['march', 'March'], spellsuggest('marrch', 2))
" With 3 arguments.
- call assert_equal(['mercury'], spellsuggest('mercurry', 1, 0))
- call assert_equal(['Mercury'], spellsuggest('mercurry', 1, 1))
+ call assert_equal(['march'], spellsuggest('marrch', 1, 0))
+ call assert_equal(['March'], spellsuggest('marrch', 1, 1))
" Test with digits and hyphen.
call assert_equal('Carbon-14', spellsuggest('Carbon-15')[0])
@@ -155,9 +155,9 @@ func Test_spellsuggest()
" ALLCAP word. Otherwise, if the first letter is UPPER then
" suggest ONECAP. Exception: "ALl" most likely should be "All",
" require three upper case letters.
- call assert_equal(['MACARONI', 'macaroni'], spellsuggest('maCARONI', 2))
- call assert_equal(['macaroni', 'MACARONI'], spellsuggest('maCAroni', 2))
- call assert_equal(['Macaroni'], spellsuggest('MACAroni', 1))
+ call assert_equal(['THIRD', 'third'], spellsuggest('thIRD', 2))
+ call assert_equal(['third', 'THIRD'], spellsuggest('tHIrd', 2))
+ call assert_equal(['Third'], spellsuggest('THird', 1))
call assert_equal(['All'], spellsuggest('ALl', 1))
set spell&
@@ -167,18 +167,22 @@ endfunc
func Test_spellsuggest_option_methods()
set spell
- set spellsuggest=fast
- call assert_equal(['Keyword', 'Keyboard'], spellsuggest('Keybord', 2))
+ for e in ['latin1', 'utf-8']
+ exe 'set encoding=' .. e
- " With best or double option, "Keyboard" should become the top suggestion
- " because of better phonetic matching.
- set spellsuggest=best
- call assert_equal(['Keyboard', 'Keyword'], spellsuggest('Keybord', 2))
+ set spellsuggest=fast
+ call assert_equal(['Stick', 'Stitch'], spellsuggest('Stich', 2), e)
- set spellsuggest=double
- call assert_equal(['Keyboard', 'Keyword'], spellsuggest('Keybord', 2))
+ " With best or double option, "Stitch" should become the top suggestion
+ " because of better phonetic matching.
+ set spellsuggest=best
+ call assert_equal(['Stitch', 'Stick'], spellsuggest('Stich', 2), e)
+
+ set spellsuggest=double
+ call assert_equal(['Stitch', 'Stick'], spellsuggest('Stich', 2), e)
+ endfor
- set spell& spellsuggest&
+ set spell& spellsuggest& encoding&
endfunc
" Test 'spellsuggest' option with value file:{filename}
@@ -220,32 +224,32 @@ func Test_spellsuggest_option_number()
" We limited the number of suggestions to 2, so selecting
" the 1st and 2nd suggestion should correct the word, but
" selecting a 3rd suggestion should do nothing.
- call setline(1, 'Keybord')
- norm 1z=
- call assert_equal('Keyboard', getline(1))
+ call setline(1, 'A baord')
+ norm $1z=
+ call assert_equal('A board', getline(1))
- call setline(1, 'Keybord')
- norm 2z=
- call assert_equal('Keyword', getline(1))
+ call setline(1, 'A baord')
+ norm $2z=
+ call assert_equal('A bard', getline(1))
- call setline(1, 'Keybord')
- norm 3z=
- call assert_equal('Keybord', getline(1))
+ call setline(1, 'A baord')
+ norm $3z=
+ call assert_equal('A baord', getline(1))
- let a = execute('norm z=')
+ let a = execute('norm $z=')
call assert_equal(
\ "\n"
- \ .. "Change \"Keybord\" to:\n"
- \ .. " 1 \"Keyboard\"\n"
- \ .. " 2 \"Keyword\"\n"
+ \ .. "Change \"baord\" to:\n"
+ \ .. " 1 \"board\"\n"
+ \ .. " 2 \"bard\"\n"
\ .. "Type number and <Enter> or click with mouse (empty cancels): ", a)
set spell spellsuggest=0
- call assert_equal("\nSorry, no suggestions", execute('norm z='))
+ call assert_equal("\nSorry, no suggestions", execute('norm $z='))
" Unlike z=, function spellsuggest(...) should not be affected by the
" max number of suggestions (2) set by the 'spellsuggest' option.
- call assert_equal(['Keyboard', 'Keyword', 'Keyboards'], spellsuggest('Keybord', 3))
+ call assert_equal(['board', 'bard', 'broad'], spellsuggest('baord', 3))
set spellsuggest& spell&
bwipe!
@@ -258,25 +262,24 @@ func Test_spellsuggest_option_expr()
" So shorter suggestions are preferred.
func MySuggest()
let spellsuggest_save = &spellsuggest
- set spellsuggest=best
+ set spellsuggest=3,best
let result = map(spellsuggest(v:val, 3), "[toupper(v:val), len(v:val)]")
let &spellsuggest = spellsuggest_save
return result
endfunc
- set spell spellsuggest=3,expr:MySuggest()
- call assert_equal(['KEYWORD', 'KEYBOARD', 'KEYBOARDS'], spellsuggest('Keybord', 3))
- call assert_equal(['KEYWORD', 'KEYBOARD', 'KEYBOARDS'], spellsuggest('Keybord', 3))
+ set spell spellsuggest=expr:MySuggest()
+ call assert_equal(['BARD', 'BOARD', 'BROAD'], spellsuggest('baord', 3))
new
- call setline(1, 'Keybord')
+ call setline(1, 'baord')
let a = execute('norm z=')
call assert_equal(
\ "\n"
- \ .. "Change \"Keybord\" to:\n"
- \ .. " 1 \"KEYWORD\"\n"
- \ .. " 2 \"KEYBOARD\"\n"
- \ .. " 3 \"KEYBOARDS\"\n"
+ \ .. "Change \"baord\" to:\n"
+ \ .. " 1 \"BARD\"\n"
+ \ .. " 2 \"BOARD\"\n"
+ \ .. " 3 \"BROAD\"\n"
\ .. "Type number and <Enter> or click with mouse (empty cancels): ", a)
" With verbose, z= should show the score i.e. word length with
@@ -285,10 +288,10 @@ func Test_spellsuggest_option_expr()
let a = execute('norm z=')
call assert_equal(
\ "\n"
- \ .. "Change \"Keybord\" to:\n"
- \ .. " 1 \"KEYWORD\" (7 - 0)\n"
- \ .. " 2 \"KEYBOARD\" (8 - 0)\n"
- \ .. " 3 \"KEYBOARDS\" (9 - 0)\n"
+ \ .. "Change \"baord\" to:\n"
+ \ .. " 1 \"BARD\" (4 - 0)\n"
+ \ .. " 2 \"BOARD\" (5 - 0)\n"
+ \ .. " 3 \"BROAD\" (5 - 0)\n"
\ .. "Type number and <Enter> or click with mouse (empty cancels): ", a)
set spell& spellsuggest& verbose&
diff --git a/src/version.c b/src/version.c
index 4e7787859..0185a78c1 100644
--- a/src/version.c
+++ b/src/version.c
@@ -743,6 +743,8 @@ static char *(features[]) =
static int included_patches[] =
{ /* Add new patch number below this line */
/**/
+ 46,
+/**/
45,
/**/
44,