grouping.

This commit is contained in:
mattn
2010-03-01 14:48:32 +09:00
parent d2a98bbc0a
commit 71e739e770
2 changed files with 235 additions and 230 deletions

View File

@@ -1,24 +1,32 @@
so zencoding.vim
unlet! testcases | let testcases = eval(join(filter(split(substitute(join(readfile(expand('<sfile>')), "\n"), '.*\nfinish\n', '', ''), '\n', 1), "v:val !~ '^\"'")))
for n in range(len(testcases))
let testtitle = testcases[n]['name']
unlet! testgroups
let testgroups = eval(join(filter(split(substitute(join(readfile(expand('<sfile>')), "\n"), '.*\nfinish\n', '', ''), '\n', 1), "v:val !~ '^\"'")))
for testgroup in testgroups
echohl Visual | echon "[" testgroup.category."]\n" | echohl None
let tests = testgroup.tests
for n in range(len(tests))
let testtitle = tests[n].name
let testtitle = len(testtitle) < 57 ? (testtitle.repeat(' ', 57-len(testtitle))) : strpart(testtitle, 0, 57)
echon "testing #".printf("%03d", n+1)": ".testtitle." ... "
unlet! res | let res = ZenExpand(testcases[n]['query'], '')
if res == testcases[n]['result']
unlet! res | let res = ZenExpand(tests[n].query, '', 0)
if res == tests[n].result
echohl Title | echon "ok\n" | echohl None
else
echohl WarningMsg | echon "ng\n" | echohl None
echohl ErrorMsg | echo "failed test #".(n+1) | echohl None
echo " expect:".testcases[n]['result']
echo " expect:".tests[n].result
echo " got:".res
echo ""
endif
endfor
endfor
finish
[
{
'category': 'html',
'tests': [
{
'name': "html:xt>div#header>div#logo+ul#nav>li.item-$*5>a",
'query': "html:xt>div#header>div#logo+ul#nav>li.item-$*5>a",
@@ -55,18 +63,6 @@ finish
'type': "html",
'result': "<tm>\n\t<if>\n\t\t<div class=\"message\"></div>\n\t</if>\n</tm>\n",
},
{
'name': "@i",
'query': "@i",
'type': "css",
'result': "<@i></@i>\n",
},
{
'name': "req",
'query': "req",
'type': "perl",
'result': "<req></req>\n",
},
{
'name': "html:4t>div#wrapper>div#header+div#contents+div#footer",
'query': "html:4t>div#wrapper>div#header+div#contents+div#footer",
@@ -163,24 +159,6 @@ finish
'type': "html",
'result': "<a id=\"foo111\" href=\"\"></a>\n<a id=\"foo222\" href=\"\"></a>\n<a id=\"foo333\" href=\"\"></a>\n",
},
{
'name': "@i",
'query': "@i",
'type': "css",
'result': "<@i></@i>\n",
},
{
'name': "fs:n",
'query': "fs:n",
'type': "css",
'result': "<fs></fs>\n",
},
{
'name': "link:css",
'query': "link:css",
'type': "html",
'result': "<link media=\"all\" rel=\"stylesheet\" href=\"style.css\" type=\"text/css\" />\n",
},
{
'name': "ul+",
'query': "ul+",
@@ -235,5 +213,30 @@ finish
'type': "html",
'result': "<a id=\"foo\" href=\"\"></a>\n<a id=\"bar\" href=\"\"></a>\n<a id=\"foo\" href=\"\"></a>\n<a id=\"bar\" href=\"\"></a>\n<a id=\"foo\" href=\"\"></a>\n<a id=\"bar\" href=\"\"></a>\n<a id=\"foo\" href=\"\"></a>\n<a id=\"bar\" href=\"\"></a>\n<a id=\"foo\" href=\"\"></a>\n<a id=\"bar\" href=\"\"></a>\n<a id=\"foo\" href=\"\"></a>\n<a id=\"bar\" href=\"\"></a>\n",
},
],
},
{
'category': 'css',
'tests': [
{
'name': "@i",
'query': "@i",
'type': "css",
'result': "<@i></@i>\n",
},
{
'name': "link:css",
'query': "link:css",
'type': "html",
'result': "<link media=\"all\" rel=\"stylesheet\" href=\"style.css\" type=\"text/css\" />\n",
},
{
'name': "fs:n",
'query': "fs:n",
'type': "css",
'result': "<fs></fs>\n",
},
],
},
]
" vim:set et:

View File

@@ -1148,14 +1148,16 @@ function! s:zen_expand(mode) range
endif
endfunction
function! ZenExpand(abbr, type)
function! ZenExpand(abbr, type, orig)
let items = s:zen_parseIntoTree(a:abbr, a:type).child
let expand = ''
for item in items
let expand .= s:zen_toString(item, a:type)
endfor
if a:orig == 0
let expand = substitute(expand, '${lang}', s:zen_settings.lang, 'g')
let expand = substitute(expand, '|', '', 'g')
endif
return expand
endfunction