Skip to content

Commit 872e451

Browse files
committed
patch 8.1.0200: spellbadword() not tested
Problem: spellbadword() not tested. Solution: Add a test. (Dominique Pelle, closes #3235)
1 parent 66ab916 commit 872e451

2 files changed

Lines changed: 43 additions & 0 deletions

File tree

src/testdir/test_spell.vim

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,47 @@ func Test_z_equal_on_invalid_utf8_word()
6868
bwipe!
6969
endfunc
7070

71+
" Test spellbadword() with argument
72+
func Test_spellbadword()
73+
set spell
74+
75+
call assert_equal(['bycycle', 'bad'], spellbadword('My bycycle.'))
76+
call assert_equal(['another', 'caps'], spellbadword('A sentence. another sentence'))
77+
78+
set spelllang=en
79+
call assert_equal(['', ''], spellbadword('centre'))
80+
call assert_equal(['', ''], spellbadword('center'))
81+
set spelllang=en_us
82+
call assert_equal(['centre', 'local'], spellbadword('centre'))
83+
call assert_equal(['', ''], spellbadword('center'))
84+
set spelllang=en_gb
85+
call assert_equal(['', ''], spellbadword('centre'))
86+
call assert_equal(['center', 'local'], spellbadword('center'))
87+
88+
" Create a small word list to test that spellbadword('...')
89+
" can return ['...', 'rare'].
90+
e Xwords
91+
insert
92+
foo
93+
foobar/?
94+
.
95+
w!
96+
mkspell! Xwords.spl Xwords
97+
set spelllang=Xwords.spl
98+
call assert_equal(['foobar', 'rare'], spellbadword('foo foobar'))
99+
100+
" Typo should not be detected without the 'spell' option.
101+
set spelllang=en_gb nospell
102+
call assert_equal(['', ''], spellbadword('centre'))
103+
call assert_equal(['', ''], spellbadword('My bycycle.'))
104+
call assert_equal(['', ''], spellbadword('A sentence. another sentence'))
105+
106+
call delete('Xwords.spl')
107+
call delete('Xwords')
108+
set spelllang&
109+
set spell&
110+
endfunc
111+
71112
func Test_spellreall()
72113
new
73114
set spell

src/version.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -789,6 +789,8 @@ static char *(features[]) =
789789

790790
static int included_patches[] =
791791
{ /* Add new patch number below this line */
792+
/**/
793+
200,
792794
/**/
793795
199,
794796
/**/

0 commit comments

Comments
 (0)