تعرّف على كيفية اختبار تمارين Vim script على Exercism
يستخدم هذا المسار أداتين لتشغيل مجموعة الاختبارات وضمان اتباع أفضل الممارسات:
$ vim exercise.vim
:source %
:Vader exercise.vader
قد تختلف المسارات.
إذا أردت اختصارًا مريحًا للخطوات السابقة، ضع هذا في ملف vimrc الخاص بك:
function! s:exercism_tests()
if expand('%:e') == 'vim'
let testfile = printf('%s/%s.vader', expand('%:p:h'),
\ tr(expand('%:p:h:t'), '-', '_'))
if !filereadable(testfile)
echoerr 'File does not exist: '. testfile
return
endif
source %
execute 'Vader' testfile
else
let sourcefile = printf('%s/%s.vim', expand('%:p:h'),
\ tr(expand('%:p:h:t'), '-', '_'))
if !filereadable(sourcefile)
echoerr 'File does not exist: '. sourcefile
return
endif
execute 'source' sourcefile
Vader
endif
endfunction
autocmd BufRead *.{vader,vim}
\ command! -buffer Test call s:exercism_tests()
بعد ذلك، افتح أي ملف .vim أو .vader من مجلد تمرين وشغّل الأمر :Test.
$ vint .
لمزيد من المعلومات التفصيلية حول مسار Vim script، راجع صفحة المساعدة.