blob: 9dcd12c970a9f2194608438d4987a3ecea0a4fea [file] [log] [blame]
Christ van Willegen - van Noort8e4c4c72024-05-17 18:49:27 +02001" Test spell checking
2
Christ van Willegen - van Noort8e4c4c72024-05-17 18:49:27 +02003CheckFeature spell
4
5" Test spellbadword() with argument, specifically to move to "rare" words
6" in normal mode.
7func Test_spellrareword()
8 set spell
9
10 " Create a small word list to test that spellbadword('...')
11 " can return ['...', 'rare'].
12 let lines =<< trim END
Yegappan Lakshmanan4776e642024-05-19 09:06:50 +020013 foo
14 foobar/?
15 foobara/?
16 END
17 call writefile(lines, 'Xwords', 'D')
Christ van Willegen - van Noort8e4c4c72024-05-17 18:49:27 +020018
Yegappan Lakshmanan4776e642024-05-19 09:06:50 +020019 mkspell! Xwords.spl Xwords
20 set spelllang=Xwords.spl
21 call assert_equal(['foobar', 'rare'], spellbadword('foo foobar'))
Christ van Willegen - van Noort8e4c4c72024-05-17 18:49:27 +020022
23 new
24 call setline(1, ['foo', '', 'foo bar foo bar foobara foo foo foo foobar', '', 'End'])
25 set spell wrapscan
26 normal ]s
27 call assert_equal('foo', expand('<cword>'))
28 normal ]s
29 call assert_equal('bar', expand('<cword>'))
30
31 normal ]r
32 call assert_equal('foobara', expand('<cword>'))
33 normal ]r
34 call assert_equal('foobar', expand('<cword>'))
35 normal ]r
36 call assert_equal('foobara', expand('<cword>'))
37 normal 2]r
38 call assert_equal('foobara', expand('<cword>'))
39
40 normal [r
41 call assert_equal('foobar', expand('<cword>'))
42 normal [r
43 call assert_equal('foobara', expand('<cword>'))
44 normal [r
45 call assert_equal('foobar', expand('<cword>'))
46 normal 2[r
47 call assert_equal('foobar', expand('<cword>'))
48
49 bwipe!
50 set nospell
51
52 call delete('Xwords.spl')
53 set spelllang&
54 set spell&
55
56 " set 'encoding' to clear the word list
57 set encoding=utf-8
58endfunc
59
60" vim: shiftwidth=2 sts=2 expandtab