mirror of
https://github.com/mattn/emmet-vim.git
synced 2025-12-06 10:44:24 +08:00
Fixes tests
This commit is contained in:
54
unittest.vim
54
unittest.vim
@@ -2,28 +2,28 @@
|
||||
let s:sfile = expand('<sfile>')
|
||||
|
||||
function! s:reload(d)
|
||||
exe "so" a:d."/plugin/emmet.vim"
|
||||
exe 'so' a:d.'/plugin/emmet.vim'
|
||||
for f in split(globpath(a:d, 'autoload/**/*.vim'), "\n")
|
||||
silent! exe "so" f
|
||||
silent! exe 'so' f
|
||||
endfor
|
||||
endfunction
|
||||
|
||||
function! s:show_type(type)
|
||||
echohl Search | echon "[" a:type "]\n" | echohl None
|
||||
echohl Search | echon '[' a:type "]\n" | echohl None
|
||||
echo "\r"
|
||||
endfunction
|
||||
|
||||
function! s:show_category(category)
|
||||
echohl MatchParen | echon "[" a:category "]\n" | echohl None
|
||||
echohl MatchParen | echon '[' a:category "]\n" | echohl None
|
||||
echo "\r"
|
||||
endfunction
|
||||
|
||||
function! s:show_pass(pass)
|
||||
echohl Title | echo "pass".a:pass."\n" | echohl None
|
||||
echohl Title | echo 'pass'.a:pass."\n" | echohl None
|
||||
endfunction
|
||||
|
||||
function! s:show_done()
|
||||
echohl IncSearch | echo "done" | echohl None
|
||||
echohl IncSearch | echo 'done' | echohl None
|
||||
endfunction
|
||||
|
||||
function! s:escape(str)
|
||||
@@ -36,43 +36,43 @@ endfunction
|
||||
function! s:show_title(no, title)
|
||||
let title = s:escape(a:title)
|
||||
let width = &columns - 23
|
||||
echohl MoreMsg | echon "\rtesting #".printf("%03d", a:no)
|
||||
echohl None | echon ": " . (len(title) < width ? (title.repeat(' ', width-len(title))) : strpart(title, 0, width)) . ' ... '
|
||||
echohl MoreMsg | echon "\rtesting #".printf('%03d', a:no)
|
||||
echohl None | echon ': ' . (len(title) < width ? (title.repeat(' ', width-len(title))) : strpart(title, 0, width)) . ' ... '
|
||||
endfunction
|
||||
|
||||
function! s:show_skip(no, title)
|
||||
let title = s:escape(a:title)
|
||||
let width = &columns - 23
|
||||
echohl WarningMsg | echon "\rskipped #".printf("%03d", a:no)
|
||||
echohl None | echon ": " . (len(title) < width ? (title.repeat(' ', width-len(title))) : strpart(title, 0, width)) . ' ... '
|
||||
echo ""
|
||||
echohl WarningMsg | echon "\rskipped #".printf('%03d', a:no)
|
||||
echohl None | echon ': ' . (len(title) < width ? (title.repeat(' ', width-len(title))) : strpart(title, 0, width)) . ' ... '
|
||||
echo ''
|
||||
endfunction
|
||||
|
||||
function! s:show_ok()
|
||||
echohl Title | echon "ok\n" | echohl None
|
||||
echo ""
|
||||
echo ''
|
||||
endfunction
|
||||
|
||||
function! s:show_ng(no, expect, got)
|
||||
echohl WarningMsg | echon "ng\n" | echohl None
|
||||
echohl ErrorMsg | echo "failed test #".a:no | echohl None
|
||||
echohl ErrorMsg | echo 'failed test #'.a:no | echohl None
|
||||
set more
|
||||
echohl WarningMsg | echo printf("expect(%d):", len(a:expect)) | echohl None
|
||||
echohl WarningMsg | echo printf('expect(%d):', len(a:expect)) | echohl None
|
||||
echo join(split(a:expect, "\n", 1), "|\n")
|
||||
echohl WarningMsg | echo printf("got(%d):", len(a:got)) | echohl None
|
||||
echohl WarningMsg | echo printf('got(%d):', len(a:got)) | echohl None
|
||||
echo join(split(a:got, "\n", 1), "|\n")
|
||||
let cs = split(a:expect, '\zs')
|
||||
for c in range(len(cs))
|
||||
if c < len(a:got)
|
||||
if a:expect[c] != a:got[c]
|
||||
echohl WarningMsg | echo "differ at:" | echohl None
|
||||
echohl WarningMsg | echo 'differ at:' | echohl None
|
||||
echo a:expect[c :-1]
|
||||
break
|
||||
endif
|
||||
endif
|
||||
endfor
|
||||
echo ""
|
||||
throw "stop"
|
||||
echo ''
|
||||
throw 'stop'
|
||||
endfunction
|
||||
|
||||
function! s:test(...)
|
||||
@@ -107,7 +107,7 @@ function! s:test(...)
|
||||
endfor
|
||||
if stridx(query, '$$$$') != -1
|
||||
silent! 1new
|
||||
silent! exe "setlocal ft=".testgroup.type
|
||||
silent! exe 'setlocal ft='.testgroup.type
|
||||
silent! let key = matchstr(query, '.*\$\$\$\$\zs.*\ze\$\$\$\$')
|
||||
if len(key) > 0
|
||||
exe printf('let key = "%s"', key)
|
||||
@@ -159,7 +159,7 @@ function! s:do_tests(...)
|
||||
if exists('g:user_emmet_settings')
|
||||
let s:old_user_emmet_settings = g:user_emmet_settings
|
||||
endif
|
||||
let g:user_emmet_settings = { 'indentation': "\t" }
|
||||
let g:user_emmet_settings = {'variables': {'indentation': "\t", 'use_selection': 1}}
|
||||
let oldmore = &more
|
||||
call s:reload(fnamemodify(s:sfile, ':h'))
|
||||
let &more = 0
|
||||
@@ -656,11 +656,11 @@ finish
|
||||
},
|
||||
{
|
||||
'query': "{bg+$$$$}",
|
||||
'result': "{background: #FFF url($$$$) 0 0 no-repeat;}",
|
||||
'result': "{background: $$$$#fff url() 0 0 no-repeat;}",
|
||||
},
|
||||
{
|
||||
'query': "{bg+!$$$$}",
|
||||
'result': "{background: #FFF url($$$$) 0 0 no-repeat !important;}",
|
||||
'result': "{background: $$$$#fff url() 0 0 no-repeat !important;}",
|
||||
},
|
||||
{
|
||||
'query': "{m$$$$}",
|
||||
@@ -712,11 +712,11 @@ finish
|
||||
},
|
||||
{
|
||||
'query': "{(bg+)+c$$$$}",
|
||||
'result': "{background: #FFF url($$$$) 0 0 no-repeat;\ncolor: #000;}",
|
||||
'result': "{background: $$$$#fff url() 0 0 no-repeat;\ncolor: #000;}",
|
||||
},
|
||||
{
|
||||
'query': "{m0+bgi+bg++p0$$$$}",
|
||||
'result': "{margin: 0;\nbackground-image: url($$$$);\nbackground: #FFF url() 0 0 no-repeat;\npadding: 0;}",
|
||||
'result': "{margin: 0;\nbackground-image: url($$$$);\nbackground: #fff url() 0 0 no-repeat;\npadding: 0;}",
|
||||
},
|
||||
{
|
||||
'query': "{borle$$$$}",
|
||||
@@ -920,11 +920,11 @@ finish
|
||||
},
|
||||
{
|
||||
'query': "{bg+$$$$}",
|
||||
'result': "{background: #FFF url($$$$) 0 0 no-repeat;}",
|
||||
'result': "{background: $$$$#fff url() 0 0 no-repeat;}",
|
||||
},
|
||||
{
|
||||
'query': "{bg+!$$$$}",
|
||||
'result': "{background: #FFF url($$$$) 0 0 no-repeat !important;}",
|
||||
'result': "{background: $$$$#fff url() 0 0 no-repeat !important;}",
|
||||
},
|
||||
{
|
||||
'query': "{m$$$$}",
|
||||
@@ -976,7 +976,7 @@ finish
|
||||
},
|
||||
{
|
||||
'query': "{(bg+)+c$$$$}",
|
||||
'result': "{background: #FFF url($$$$) 0 0 no-repeat;\ncolor: #000;}",
|
||||
'result': "{background: $$$$#fff url() 0 0 no-repeat;\ncolor: #000;}",
|
||||
},
|
||||
],
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user