neovim

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

test_plugin_tutor.vim (1447B)


      1 " Test for the new-tutor plugin
      2 
      3 source screendump.vim
      4 source check.vim
      5 source script_util.vim
      6 
      7 func SetUp()
      8  set nocompatible
      9  runtime plugin/tutor.vim
     10 endfunc
     11 
     12 func Test_auto_enable_interactive()
     13  Tutor
     14  call assert_equal('nowrite', &buftype)
     15  call assert_match('tutor#EnableInteractive', b:undo_ftplugin)
     16 
     17  edit Xtutor/Xtest.tutor
     18  call assert_true(empty(&buftype))
     19  call assert_match('tutor#EnableInteractive', b:undo_ftplugin)
     20 endfunc
     21 
     22 func Test_tutor_link()
     23  let tutor_files = globpath($VIMRUNTIME, 'tutor/**/*.tutor', 0, 1)
     24  let pattern = '\[.\{-}@tutor:\zs[^)\]]*\ze[)\]]'
     25 
     26  for tutor_file in tutor_files
     27    let lang = fnamemodify(tutor_file, ':h:t')
     28    if lang == 'tutor'
     29      let lang = 'en'
     30    endif
     31 
     32    let text = readfile(tutor_file)
     33    let links = matchstrlist(text, pattern)->map({_, v -> v.text})
     34    for link in links
     35      call assert_true(tutor#GlobTutorials(link, lang)->len() > 0)
     36    endfor
     37  endfor
     38 endfunc
     39 
     40 func Test_mark()
     41  CheckScreendump
     42  call writefile([
     43  \ 'set nocompatible',
     44  \ 'runtime plugin/tutor.vim',
     45  \ 'Tutor tutor',
     46  \ 'set statusline=',
     47  \ ], 'Xtest_plugin_tutor_mark', 'D')
     48  let buf = RunVimInTerminal('-S Xtest_plugin_tutor_mark', {'rows': 20, 'cols': 78})
     49  call term_sendkeys(buf, ":240\<CR>")
     50  call WaitForAssert({-> assert_match('Bot$', term_getline(buf, 20))})
     51  call VerifyScreenDump(buf, 'Test_plugin_tutor_mark_1', {})
     52 
     53  " clean up
     54  call StopVimInTerminal(buf)
     55 endfunc