neovim

Neovim text editor
git clone https://git.dasho.dev/neovim.git
Log | Files | Refs | README

test_spellrare.vim (1436B)


      1 " Test spell checking
      2 
      3 source check.vim
      4 CheckFeature spell
      5 
      6 " Test spellbadword() with argument, specifically to move to "rare" words
      7 " in normal mode.
      8 func 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
     14    foo
     15    foobar/?
     16    foobara/?
     17  END
     18  call writefile(lines, 'Xwords', 'D')
     19 
     20  mkspell! Xwords.spl Xwords
     21  set spelllang=Xwords.spl
     22  call assert_equal(['foobar', 'rare'], spellbadword('foo foobar'))
     23 
     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
     59 endfunc
     60 
     61 " vim: shiftwidth=2 sts=2 expandtab