Phạm Bình An | 13bea58 | 2025-05-12 20:39:24 +0200 | [diff] [blame] | 1 | " Test for the new-tutor plugin |
| 2 | |
| 3 | func SetUp() |
| 4 | set nocompatible |
| 5 | runtime plugin/tutor.vim |
| 6 | endfunc |
| 7 | |
| 8 | func 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) |
| 16 | endfunc |
Phạm Bình An | e8302da | 2025-05-22 22:53:28 +0200 | [diff] [blame] | 17 | |
| 18 | func 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 |
| 34 | endfunc |