Christ van Willegen - van Noort | 8e4c4c7 | 2024-05-17 18:49:27 +0200 | [diff] [blame] | 1 | " Test spell checking |
| 2 | |
Christ van Willegen - van Noort | 8e4c4c7 | 2024-05-17 18:49:27 +0200 | [diff] [blame] | 3 | CheckFeature spell |
| 4 | |
| 5 | " Test spellbadword() with argument, specifically to move to "rare" words |
| 6 | " in normal mode. |
| 7 | func 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 Lakshmanan | 4776e64 | 2024-05-19 09:06:50 +0200 | [diff] [blame] | 13 | foo |
| 14 | foobar/? |
| 15 | foobara/? |
| 16 | END |
| 17 | call writefile(lines, 'Xwords', 'D') |
Christ van Willegen - van Noort | 8e4c4c7 | 2024-05-17 18:49:27 +0200 | [diff] [blame] | 18 | |
Yegappan Lakshmanan | 4776e64 | 2024-05-19 09:06:50 +0200 | [diff] [blame] | 19 | mkspell! Xwords.spl Xwords |
| 20 | set spelllang=Xwords.spl |
| 21 | call assert_equal(['foobar', 'rare'], spellbadword('foo foobar')) |
Christ van Willegen - van Noort | 8e4c4c7 | 2024-05-17 18:49:27 +0200 | [diff] [blame] | 22 | |
| 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 |
| 58 | endfunc |
| 59 | |
| 60 | " vim: shiftwidth=2 sts=2 expandtab |