mirror of
https://github.com/macvim-dev/macvim.git
synced 2026-02-05 11:33:15 +01:00
Problem: tests: too many imports in the test suite Solution: Clean up the imported scripts Most tests make use of check.vim, so let's just source it once in runtest.vim instead of having each test manually source it. runtest.vim already sources shared.vim, which again sources view_util.vim, so we don't need to source those two common dependencies in all the other tests And then check.vim sources term_util.vim already, so we can in addition drop sourcing it explicitly in each single test script. Note: test_expand_func.vim had to be updated to account for the changed number of sourced files. And finally check.vim uses line-continuation so let's also explicitly enable line continuation via the 'cpo' option value. related: #17677 Signed-off-by: Christian Brabandt <cb@256bit.org>
71 lines
1.6 KiB
VimL
71 lines
1.6 KiB
VimL
" Tests for Vim :TOhtml
|
|
|
|
func s:setup_basic(src_name)
|
|
let lines =<< trim END
|
|
#include <stdio.h>
|
|
#include <stdlib.h>
|
|
|
|
int isprime(int n)
|
|
{
|
|
if (n <= 1)
|
|
return 0;
|
|
|
|
for (int i = 2; i <= n / 2; i++)
|
|
if (n % i == 0)
|
|
return 0;
|
|
|
|
return 1;
|
|
}
|
|
|
|
int main(int argc, char *argv[])
|
|
{
|
|
int n = 7;
|
|
|
|
printf("%d is %s prime\n", n, isprime(n) ? "a" : "not a");
|
|
|
|
return 0;
|
|
}
|
|
END
|
|
call writefile(lines, a:src_name)
|
|
exe 'edit ' . a:src_name
|
|
TOhtml
|
|
write
|
|
endfunc
|
|
|
|
func s:cleanup_basic(src_name)
|
|
call delete(a:src_name)
|
|
call delete(a:src_name . ".html")
|
|
endfunc
|
|
|
|
source $VIMRUNTIME/plugin/tohtml.vim
|
|
|
|
func Test_tohtml_basic()
|
|
let src_name = "Test_tohtml_basic.c"
|
|
call s:setup_basic(src_name)
|
|
let expected = readfile("samples/" . src_name . ".html")
|
|
let actual = readfile(src_name . ".html")
|
|
call assert_equal(expected[0:3], actual[0:3])
|
|
" Ignore the title
|
|
call assert_equal(expected[5:11], actual[5:11])
|
|
" Ignore pre and body css
|
|
call assert_equal(expected[14:], actual[14:])
|
|
call s:cleanup_basic(src_name)
|
|
endfunc
|
|
|
|
func Test_tohtml_basic_no_css()
|
|
let g:html_use_css = 0
|
|
let src_name = "Test_tohtml_basic_no_css.c"
|
|
call s:setup_basic(src_name)
|
|
let expected = readfile("samples/" . src_name . ".html")
|
|
let actual = readfile(src_name . ".html")
|
|
call assert_equal(expected[0:3], actual[0:3])
|
|
" Ignore the title
|
|
call assert_equal(expected[5:10], actual[5:10])
|
|
" Ignore body's inline css
|
|
call assert_equal(expected[12:], actual[12:])
|
|
call s:cleanup_basic(src_name)
|
|
unlet g:html_use_css
|
|
endfunc
|
|
|
|
" vim: shiftwidth=2 sts=2 expandtab
|