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

View File

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