test_spellrare.vim 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. " Test spell checking
  2. source check.vim
  3. CheckFeature spell
  4. " Test spellbadword() with argument, specifically to move to "rare" words
  5. " in normal mode.
  6. func Test_spellrareword()
  7. set spell
  8. " Create a small word list to test that spellbadword('...')
  9. " can return ['...', 'rare'].
  10. let lines =<< trim END
  11. foo
  12. foobar/?
  13. foobara/?
  14. END
  15. call writefile(lines, 'Xwords', 'D')
  16. mkspell! Xwords.spl Xwords
  17. set spelllang=Xwords.spl
  18. call assert_equal(['foobar', 'rare'], spellbadword('foo foobar'))
  19. new
  20. call setline(1, ['foo', '', 'foo bar foo bar foobara foo foo foo foobar', '', 'End'])
  21. set spell wrapscan
  22. normal ]s
  23. call assert_equal('foo', expand('<cword>'))
  24. normal ]s
  25. call assert_equal('bar', expand('<cword>'))
  26. normal ]r
  27. call assert_equal('foobara', expand('<cword>'))
  28. normal ]r
  29. call assert_equal('foobar', expand('<cword>'))
  30. normal ]r
  31. call assert_equal('foobara', expand('<cword>'))
  32. normal 2]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 [r
  39. call assert_equal('foobar', expand('<cword>'))
  40. normal 2[r
  41. call assert_equal('foobar', expand('<cword>'))
  42. bwipe!
  43. set nospell
  44. call delete('Xwords.spl')
  45. set spelllang&
  46. set spell&
  47. " set 'encoding' to clear the word list
  48. set encoding=utf-8
  49. endfunc
  50. " vim: shiftwidth=2 sts=2 expandtab