forked from VimPlug/emmet-vim
modify test suite.
This commit is contained in:
62
unittest.vim
62
unittest.vim
@@ -1,7 +1,4 @@
|
|||||||
if exists('g:user_zen_settings')
|
let s:sfile = expand('<sfile>')
|
||||||
let s:old_user_zen_settings = g:user_zen_settings
|
|
||||||
let g:user_zen_settings = { 'indentation': "\t" }
|
|
||||||
endif
|
|
||||||
|
|
||||||
function! s:reload(d)
|
function! s:reload(d)
|
||||||
exe "so" a:d."/plugin/zencoding.vim"
|
exe "so" a:d."/plugin/zencoding.vim"
|
||||||
@@ -71,17 +68,23 @@ function! s:show_ng(no, expect, got)
|
|||||||
throw "stop"
|
throw "stop"
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
function! s:test()
|
function! s:test(...)
|
||||||
unlet! testgroups
|
let type = get(a:000, 0, '')
|
||||||
let testgroups = eval(join(filter(split(substitute(join(readfile(expand('%')), "\n"), '.*\nfinish\n', '', ''), '\n', 1), "v:val !~ '^\"'")))
|
let name = get(a:000, 1, '')
|
||||||
|
let index = get(a:000, 2, '')
|
||||||
|
|
||||||
|
let testgroups = eval(join(filter(split(substitute(join(readfile(s:sfile), "\n"), '.*\nfinish\n', '', ''), '\n', 1), "v:val !~ '^\"'")))
|
||||||
for testgroup in testgroups
|
for testgroup in testgroups
|
||||||
|
if len(type) > 0 && testgroup.type != type | continue | endif
|
||||||
call s:show_type(testgroup.type)
|
call s:show_type(testgroup.type)
|
||||||
let type = testgroup.type
|
let type = testgroup.type
|
||||||
for category in testgroup.categories
|
for category in testgroup.categories
|
||||||
|
if len(name) > 0 && substitute(category.name,' ','_','g') != name | continue | endif
|
||||||
call s:show_category(category.name)
|
call s:show_category(category.name)
|
||||||
let tests = category.tests
|
let tests = category.tests
|
||||||
let start = reltime()
|
let start = reltime()
|
||||||
for n in range(len(tests))
|
for n in range(len(tests))
|
||||||
|
if len(index) > 0 && n != index | continue | endif
|
||||||
let query = tests[n].query
|
let query = tests[n].query
|
||||||
let result = tests[n].result
|
let result = tests[n].result
|
||||||
if has_key(tests[n], 'skip') && tests[n].skip != 0
|
if has_key(tests[n], 'skip') && tests[n].skip != 0
|
||||||
@@ -130,20 +133,41 @@ function! s:test()
|
|||||||
endfor
|
endfor
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
try
|
function! s:do_tests(...)
|
||||||
let oldmore = &more
|
try
|
||||||
let &more = 0
|
if exists('g:user_zen_settings')
|
||||||
call s:test()
|
let s:old_user_zen_settings = g:user_zen_settings
|
||||||
catch
|
let g:user_zen_settings = { 'indentation': "\t" }
|
||||||
finally
|
endif
|
||||||
let &more=oldmore
|
let oldmore = &more
|
||||||
endtry
|
let &more = 0
|
||||||
|
call call('s:test', a:000)
|
||||||
|
echo "done"
|
||||||
|
catch
|
||||||
|
echoerr v:exception
|
||||||
|
finally
|
||||||
|
let &more=oldmore
|
||||||
|
if exists('g:user_zen_settings')
|
||||||
|
let g:user_zen_settings = s:old_user_zen_settings
|
||||||
|
endif
|
||||||
|
endtry
|
||||||
|
endfunction
|
||||||
|
|
||||||
if exists('g:user_zen_settings')
|
function! g:zencoding_unittest_complete(arglead, cmdline, cmdpos)
|
||||||
let g:user_zen_settings = s:old_user_zen_settings
|
let args = split(a:cmdline, '\s\+', 1)
|
||||||
endif
|
let testgroups = eval(join(filter(split(substitute(join(readfile(s:sfile), "\n"), '.*\nfinish\n', '', ''), '\n', 1), "v:val !~ '^\"'")))
|
||||||
|
try
|
||||||
|
if len(args) == 2
|
||||||
|
return filter(map(testgroups, 'v:val.type'), 'stridx(v:val,args[1])!=-1')
|
||||||
|
elseif len(args) == 3
|
||||||
|
return map(filter(testgroups, 'v:val.type==args[1]')[0].categories, 'substitute(v:val.name," ","_","g")')
|
||||||
|
endif
|
||||||
|
catch
|
||||||
|
endtry
|
||||||
|
return []
|
||||||
|
endfunction
|
||||||
|
|
||||||
echo "done"
|
command! -nargs=* -complete=customlist,g:zencoding_unittest_complete ZenCodingUnitTest call s:do_tests(<f-args>)
|
||||||
|
|
||||||
finish
|
finish
|
||||||
[
|
[
|
||||||
|
|||||||
Reference in New Issue
Block a user