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