blob: 3dc46fd16e8103daeb63e57dc36e9e348d5b7d59 [file] [log] [blame]
Phạm Bình An13bea582025-05-12 20:39:24 +02001" Test for the new-tutor plugin
2
3func SetUp()
4 set nocompatible
5 runtime plugin/tutor.vim
6endfunc
7
8func Test_auto_enable_interactive()
9 Tutor
10 call assert_equal('nofile', &buftype)
11 call assert_match('tutor#EnableInteractive', b:undo_ftplugin)
12
13 edit Xtutor/Xtest.tutor
14 call assert_true(empty(&buftype))
15 call assert_match('tutor#EnableInteractive', b:undo_ftplugin)
16endfunc
Phạm Bình Ane8302da2025-05-22 22:53:28 +020017
18func Test_tutor_link()
19 let tutor_files = globpath($VIMRUNTIME, 'tutor/**/*.tutor', 0, 1)
20 let pattern = '\[.\{-}@tutor:\zs[^)\]]*\ze[)\]]'
21
22 for tutor_file in tutor_files
23 let lang = fnamemodify(tutor_file, ':h:t')
24 if lang == 'tutor'
25 let lang = 'en'
26 endif
27
28 let text = readfile(tutor_file)
29 let links = matchstrlist(text, pattern)->map({_, v -> v.text})
30 for link in links
31 call assert_true(tutor#GlobTutorials(link, lang)->len() > 0)
32 endfor
33 endfor
34endfunc