if exists('g:user_zen_settings') let s:old_user_zen_settings = g:user_zen_settings let g:user_zen_settings = { 'indentation': "\t" } endif function! s:reload(d) exe "so" a:d."/plugin/zencoding.vim" for f in split(globpath(a:d, 'autoload/**/*.vim'), "\n") silent! exe "so" f endfor endfunction call s:reload(expand(':h')) function! s:show_category(category) echohl MatchParen | echon "[" a:category "]\n" | echohl None echo "\r" endfunction function! s:show_title(no, title) let width = &columns - 23 echohl ModeMsg | echon "\rtesting #".printf("%03d", a:no) echohl None | echon ": " . (len(a:title) < width ? (a:title.repeat(' ', width-len(a:title))) : strpart(a:title, 0, width)) . ' ... ' endfunction function! s:show_skip(no, title) let width = &columns - 23 echohl WarningMsg | echon "\rskipped #".printf("%03d", a:no) echohl None | echon ": " . (len(a:title) < width ? (a:title.repeat(' ', width-len(a:title))) : strpart(a:title, 0, width)) . ' ... ' echo "" endfunction function! s:show_ok() echohl Title | echon "ok\n" | echohl None 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 set more 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 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 echo a:expect[c :-1] break endif endif endfor echo "" throw "stop" endfunction function! s:testExpandAbbr() unlet! testgroups let testgroups = eval(join(filter(split(substitute(join(readfile(expand('%')), "\n"), '.*\nfinish\n', '', ''), '\n', 1), "v:val !~ '^\"'"))) for testgroup in testgroups call s:show_category(testgroup.category) let tests = testgroup.tests let start = reltime() for n in range(len(tests)) let type = tests[n].type let name = tests[n].name let query = tests[n].query let result = tests[n].result if has_key(tests[n], 'skip') && tests[n].skip != 0 call s:show_skip(n+1, name) continue endif if stridx(query, '$$$$') != -1 silent! 1new silent! exe "setlocal ft=".type silent! let key = matchstr(query, '.*\$\$\$\$\zs.*\ze\$\$\$\$') if len(key) > 0 exe printf('let key = "%s"', key) else let key = "\," endif silent! let query = substitute(query, '\$\$\$\$.*\$\$\$\$', '$$$$', '') silent! call setline(1, query) let cmd = "normal gg0/\\$\\$\\$\\$\ri\\\\".key if stridx(result, '$$$$') != -1 let cmd .= '$$$$' endif silent! exe cmd unlet! res | let res = join(getline(1, line('$')), "\n") silent! bw! call s:show_title(n+1, name) else call s:show_title(n+1, name) unlet! res | let res = zencoding#ExpandWord(query, type, 0) endif if stridx(result, '$$$$') != -1 if res ==# result call s:show_ok() else call s:show_ng(n+1, result, res) endif else if res ==# result call s:show_ok() else call s:show_ng(n+1, result, res) endif endif endfor echo "past:".reltimestr(reltime(start))."\n" endfor endfunction function! s:testImageSize() call s:show_category("image size") silent! 1new silent! call setline(1, "img[src=http://mattn.kaoriya.net/images/logo.png]") silent! let start = reltime() silent! exe "silent! normal A\,\i" silent! let line = getline(1) silent! bw! let expect = '' call s:show_title(1, "existing image") if line == expect call s:show_ok() else call s:show_ng(1, expect, line) endif silent! 1new silent! call setline(1, "img[src=/logo.png]") silent! let start = reltime() silent! exe "silent! normal A\,\i" silent! let line = getline(1) silent! bw! let expect = '' call s:show_title(2, "not existing image") if line == expect call s:show_ok() else call s:show_ng(2, expect, line) endif echo "past:".reltimestr(reltime(start))."\n" endfunction function! s:testMoveNextPrev() silent! 1new silent! call setline(1, "") silent! call setline(2, "") silent! call setline(3, "") let start = reltime() exe "silent! normal gg0\n\n\n" let pos = getpos(".") let line = substitute(getline("."), '\n", }, { 'name': "div#wrapper", 'query': "div#wrapper", 'type': "html", 'result': "
\n", }, { 'name': "div.box", 'query': "div.box", 'type': "html", 'result': "
\n", }, { 'name': "a[title=TITLE]", 'query': "a[title=TITLE]", 'type': "html", 'result': "\n", }, { 'name': "div#wrapper.box", 'query': "div#wrapper.box", 'type': "html", 'result': "
\n", }, { 'name': "div#wrapper.box.current", 'query': "div#wrapper.box.current", 'type': "html", 'result': "
\n", }, { 'name': "div#wrapper.box.current[title=TITLE rel]", 'query': "div#wrapper.box.current[title=TITLE rel]", 'type': "html", 'result': "
\n", }, { 'name': "div#main+div#sub", 'query': "div#main+div#sub", 'type': "html", 'result': "
\n
\n", }, { 'name': "div#main>div#sub", 'query': "div#main>div#sub", 'type': "html", 'result': "
\n\t
\n
\n", }, { '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", 'type': "html", 'result': "\n\n\n\t\n\t\n\n\n\t
\n\t\t
\n\t\t
    \n\t\t\t
  • \n\t\t\t
  • \n\t\t\t
  • \n\t\t\t
  • \n\t\t\t
  • \n\t\t
\n\t
\n\t\n\n", }, { 'name': "ol>li*2", 'query': "ol>li*2", 'type': "html", 'result': "
    \n\t
  1. \n\t
  2. \n
\n", }, { 'name': "a", 'query': "a", 'type': "html", 'result': "\n", }, { 'name': "obj", 'query': "obj", 'type': "html", 'result': "\n", }, { 'name': "cc:ie6>p+blockquote#sample$.so.many.classes*2", 'query': "cc:ie6>p+blockquote#sample$.so.many.classes*2", 'type': "html", 'result': "", }, { 'name': "tm>if>div.message", 'query': "tm>if>div.message", 'type': "html", 'result': "\n\t\n\t\t
\n\t
\n
\n", }, { 'name': "html:4t>div#wrapper>div#header+div#contents+div#footer", 'query': "html:4t>div#wrapper>div#header+div#contents+div#footer", 'type': "html", 'result': "\n\n\n\t\n\t\n\n\n\t
\n\t\t
\n\t\t
\n\t\t
\n\t
\n\t\n\n", }, { 'name': "a[href=http://www.google.com/].foo#hoge", 'query': "a[href=http://www.google.com/].foo#hoge", 'type': "html", 'result': "\n", }, { 'name': "a[href=http://www.google.com/]{Google}", 'query': "a[href=http://www.google.com/]{Google}", 'type': "html", 'result': "Google\n", }, { 'name': "{ZenCoding}", 'query': "{ZenCoding}", 'type': "html", 'result': "ZenCoding", }, { 'name': "a+b", 'query': "a+b", 'type': "html", 'result': "\n\n", }, { 'name': "a>b>ib>i\n", }, { 'name': "a>b>i<b>i<\n\n", }, { 'name': "blockquote>b>i<b>i<\n\n", }, { 'name': "a[href=foo][class=bar]", 'query': "a[href=foo][class=bar]", 'type': "html", 'result': "\n", }, { 'name': "a[a=b][b=c=d][e]{foo}*2", 'query': "a[a=b][b=c=d][e]{foo}*2", 'type': "html", 'result': "foo\nfoo\n", }, { 'name': "a[a=b][b=c=d][e]*2{foo}", 'query': "a[a=b][b=c=d][e]*2{foo}", 'type': "html", 'result': "\n\nfoo", }, { 'name': "a*2{foo}a", 'query': "a*2{foo}a", 'type': "html", 'result': "\n\nfoo\n", }, { 'name': "a{foo}*2>b", 'query': "a{foo}*2>b", 'type': "html", 'result': "foo\nfoo\n", }, { 'name': "a*2{foo}>b", 'query': "a*2{foo}>b", 'type': "html", 'result': "\n\nfoo", }, { 'name': "table>tr>td.name#foo+td*3", 'query': "table>tr>td.name#foo+td*3", 'type': "html", 'result': "\n\t\n\t\t\n\t\t\n\t\t\n\t\t\n\t\n
\n", }, { 'name': "div#header + div#footer", 'query': "div#header + div#footer", 'type': "html", 'result': "
\n
\n", }, { 'name': "#header + div#footer", 'query': "#header + div#footer", 'type': "html", 'result': "
\n
\n", }, { 'name': "#header > ul > li < p{Footer}", 'query': "#header > ul > li < p{Footer}", 'type': "html", 'result': "
\n\t
    \n\t\t
  • \n\t
\n\t

Footer

\n
\n", }, { 'name': "a#foo$$$*3", 'query': "a#foo$$$*3", 'type': "html", 'result': "\n\n\n", }, { 'name': "ul+", 'query': "ul+", 'type': "html", 'result': "
    \n\t
  • \n
\n", }, { 'name': "table+", 'query': "table+", 'type': "html", 'result': "\n\t\n\t\t\n\t\n
\n", }, { 'name': "#header>li<#content", 'query': "#header>li<#content", 'type': "html", 'result': "
\n\t
  • \n
    \n
    \n", }, { 'name': "(#header>li)<#content", 'query': "(#header>li)<#content", 'type': "html", 'result': "
    \n\t
  • \n
    \n
    \n", }, { 'name': "a>b>i<b>i<\n
    \n", }, { 'name': "(#header>h1)+#content+#footer", 'query': "(#header>h1)+#content+#footer", 'type': "html", 'result': "
    \n\t

    \n
    \n
    \n
    \n", }, { 'name': "(#header>h1)+(#content>(#main>h2+div#entry$.section*5>(h3>a)+div>p*3+ul+)+(#utilities))+(#footer>address)", 'query': "(#header>h1)+(#content>(#main>h2+div#entry$.section*5>(h3>a)+div>p*3+ul+)+(#utilities))+(#footer>address)", 'type': "html", 'result': "
    \n\t

    \n
    \n
    \n\t
    \n\t\t

    \n\t\t
    \n\t\t\t

    \n\t\t\t
    \n\t\t\t\t

    \n\t\t\t\t

    \n\t\t\t\t

    \n\t\t\t\t
      \n\t\t\t\t\t
    • \n\t\t\t\t
    \n\t\t\t
    \n\t\t
    \n\t\t
    \n\t\t\t

    \n\t\t\t
    \n\t\t\t\t

    \n\t\t\t\t

    \n\t\t\t\t

    \n\t\t\t\t
      \n\t\t\t\t\t
    • \n\t\t\t\t
    \n\t\t\t
    \n\t\t
    \n\t\t
    \n\t\t\t

    \n\t\t\t
    \n\t\t\t\t

    \n\t\t\t\t

    \n\t\t\t\t

    \n\t\t\t\t
      \n\t\t\t\t\t
    • \n\t\t\t\t
    \n\t\t\t
    \n\t\t
    \n\t\t
    \n\t\t\t

    \n\t\t\t
    \n\t\t\t\t

    \n\t\t\t\t

    \n\t\t\t\t

    \n\t\t\t\t
      \n\t\t\t\t\t
    • \n\t\t\t\t
    \n\t\t\t
    \n\t\t
    \n\t\t
    \n\t\t\t

    \n\t\t\t
    \n\t\t\t\t

    \n\t\t\t\t

    \n\t\t\t\t

    \n\t\t\t\t
      \n\t\t\t\t\t
    • \n\t\t\t\t
    \n\t\t\t
    \n\t\t
    \n\t
    \n\t
    \n
    \n
    \n\t
    \n
    \n", }, { 'name': "(div>(ul*2)*2)+(#utilities)", 'query': "(div>(ul*2)*2)+(#utilities)", 'type': "html", 'result': "
    \n\t
      \n\t
        \n\t
          \n\t
            \n
            \n
            \n", }, { 'name': "table>(tr>td*3)*4", 'query': "table>(tr>td*3)*4", 'type': "html", 'result': "\n\t\n\t\t\n\t\t\n\t\t\n\t\n\t\n\t\t\n\t\t\n\t\t\n\t\n\t\n\t\t\n\t\t\n\t\t\n\t\n\t\n\t\t\n\t\t\n\t\t\n\t\n
            \n", }, { 'name': "(((a#foo+a#bar)*2)*3)", 'query': "(((a#foo+a#bar)*2)*3)", 'type': "html", 'result': "\n\n\n\n\n\n\n\n\n\n\n\n", }, { 'name': "div#box$*3>h3+p*2", 'query': "div#box$*3>h3+p*2", 'type': "html", 'result': "
            \n\t

            \n\t

            \n\t

            \n
            \n
            \n\t

            \n\t

            \n\t

            \n
            \n
            \n\t

            \n\t

            \n\t

            \n
            \n" }, { 'name': "div#box.foo$$$.bar$$$*3", 'query': "div#box.foo$$$.bar$$$*3", 'type': "html", 'result': "
            \n
            \n
            \n", }, { 'name': "div#box$*3>h3+p.bar*2|e", 'query': "div#box$*3>h3+p.bar*2|e", 'type': "html", 'result': "<div id=\"box1\">\n\t&lt;h3&gt;&lt;/h3&gt;\n\t&lt;p class=\"bar\"&gt;&lt;/p&gt;\n\t&lt;p class=\"bar\"&gt;&lt;/p&gt;\n</div>\n<div id=\"box2\">\n\t&lt;h3&gt;&lt;/h3&gt;\n\t&lt;p class=\"bar\"&gt;&lt;/p&gt;\n\t&lt;p class=\"bar\"&gt;&lt;/p&gt;\n</div>\n<div id=\"box3\">\n\t&lt;h3&gt;&lt;/h3&gt;\n\t&lt;p class=\"bar\"&gt;&lt;/p&gt;\n\t&lt;p class=\"bar\"&gt;&lt;/p&gt;\n</div>\n", }, { 'name': "div>div#page>p.title+p|c", 'query': "div>div#page>p.title+p|c", 'type': "html", 'result': "
            \n\t\n\t
            \n\t\t\n\t\t

            \n\t\t\n\t\t

            \n\t
            \n\t\n
            \n", }, { 'name': "link:css", 'query': "link:css", 'type': "html", 'result': "\n", }, { 'name': "a[title=\"Hello', world\" rel]", 'query': "a[title=\"Hello', world\" rel]", 'type': "html", 'result': "\n", }, { 'name': "div>a#foo{bar}", 'query': "div>a#foo{bar}", 'type': "html", 'result': "\n", }, { 'name': ".content{Hello!}", 'query': ".content{Hello!}", 'type': "html", 'result': "
            Hello!
            \n", }, { 'name': "div.logo+(div#navigation)+(div#links)", 'query': "div.logo+(div#navigation)+(div#links)", 'type': "html", 'result': "
            \n
            \n
            \n", }, { 'name': "h1{header}+{Text}+a[href=http://link.org]{linktext}+{again some text}+a[href=http://anoterlink.org]{click me!}+{some final text}", 'query': "h1{header}+{Text}+a[href=http://link.org]{linktext}+{again some text}+a[href=http://anoterlink.org]{click me!}+{some final text}", 'type': "html", 'result': "

            header

            \nTextlinktext\nagain some textclick me!\nsome final text", }, { 'name': "a{&}+div{&&}", 'query': "a{&}+div{&&}", 'type': "html", 'result': "&\n
            &&
            \n", }, { 'name': "span$$$$\\,$$$$", 'query': "span$$$$\\,$$$$", 'type': "html", 'result': "", }, { 'name': "foo span$$$$\\,$$$$", 'query': "foo span$$$$\\,$$$$", 'type': "html", 'result': "foo ", }, { 'name': "foo span$$$$\\,$$$$ bar", 'query': "foo span$$$$\\,$$$$ bar", 'type': "html", 'result': "foo bar", }, { 'name': "foo $$$$\\ve\\,p\\$$$$bar baz", 'query': "foo $$$$\\ve\\,p\\$$$$bar baz", 'type': "html", 'result': "foo

            bar

            baz", }, { 'name': "foo $$$$\\vee\\,p\\$$$$bar baz", 'query': "foo $$$$\\vee\\,p\\$$$$bar baz", 'type': "html", 'result': "foo

            bar baz

            ", }, { 'name': "f div.boxes>article.box2>header>(hgroup>h2{aaa}+h3{bbb})+p{ccc}$$$$", 'query': "f div.boxes>article.box2>header>(hgroup>h2{aaa}+h3{bbb})+p{ccc}$$$$", 'type': "html", 'result': "f
            \n\t
            \n\t\t
            \n\t\t\t
            \n\t\t\t\t

            aaa

            \n\t\t\t\t

            bbb

            \n\t\t\t
            \n\t\t\t

            ccc

            \n\t\t
            \n\t
            \n
            ", }, { 'name': "div.boxes>(div.box2>section>h2{a}+p{b})+(div.box1>section>h2{c}+p{d}+p{e}+(bq>h2{f}+h3{g})+p{h})", 'query': "div.boxes>(div.box2>section>h2{a}+p{b})+(div.box1>section>h2{c}+p{d}+p{e}+(bq>h2{f}+h3{g})+p{h})", 'type': "html", 'result': "
            \n\t
            \n\t\t
            \n\t\t\t

            a

            \n\t\t\t

            b

            \n\t\t
            \n\t
            \n\t
            \n\t\t
            \n\t\t\t

            c

            \n\t\t\t

            d

            \n\t\t\t

            e

            \n\t\t\t
            \n\t\t\t\t

            f

            \n\t\t\t\t

            g

            \n\t\t\t
            \n\t\t\t

            h

            \n\t\t
            \n\t
            \n
            \n", }, ], }, { 'category': 'css', 'tests': [ { 'name': "@i", 'query': "@i", 'type': "css", 'result': "@import url();", }, { 'name': "fs:n", 'query': "fs:n", 'type': "css", 'result': "font-style: normal;", }, { 'name': "fl:l|fc", 'query': "fl:l|fc", 'type': "css", 'result': "float: left;", }, { 'name': "bg+$$$$", 'query': "bg+$$$$", 'type': "css", 'result': "background: #FFF url($$$$) 0 0 no-repeat;", }, ], }, { 'category': 'haml', 'tests': [ { 'name': "div>p+ul#foo>li.bar$[foo=bar][bar=baz]*3>{baz}", 'query': "div>p+ul#foo>li.bar$[foo=bar][bar=baz]*3>{baz}", 'type': "haml", 'result': "%div\n %p\n %ul#foo\n %li.bar1{ :foo => \"bar\", :bar => \"baz\" } baz\n %li.bar2{ :foo => \"bar\", :bar => \"baz\" } baz\n %li.bar3{ :foo => \"bar\", :bar => \"baz\" } baz\n", }, { 'name': "div>p+ul#foo>li.bar$[foo=bar][bar=baz]*3>{baz}|haml", 'query': "div>p+ul#foo>li.bar$[foo=bar][bar=baz]*3>{baz}|haml", 'type': "html", 'result': "%div\n %p\n %ul#foo\n %li.bar1{ :foo => \"bar\", :bar => \"baz\" } baz\n %li.bar2{ :foo => \"bar\", :bar => \"baz\" } baz\n %li.bar3{ :foo => \"bar\", :bar => \"baz\" } baz\n", }, { 'name': "a*3|haml", 'query': "a*3|haml", 'type': "haml", 'result': "%a{ :href => \"\" }\n%a{ :href => \"\" }\n%a{ :href => \"\" }\n", }, { 'name': ".content{Hello!}|haml", 'query': ".content{Hello!}|haml", 'type': "haml", 'result': "%div.content Hello!\n", }, ], }, { 'category': 'slim', 'tests': [ { 'name': "div>p+ul#foo>li.bar$[foo=bar][bar=baz]*3>{baz}", 'query': "div>p+ul#foo>li.bar$[foo=bar][bar=baz]*3>{baz}", 'type': "slim", 'result': "div\n p\n ul id=\"foo\"\n li foo=\"bar\" bar=\"baz\" class=\"bar1\"\n | baz\n li foo=\"bar\" bar=\"baz\" class=\"bar2\"\n | baz\n li foo=\"bar\" bar=\"baz\" class=\"bar3\"\n | baz\n", }, { 'name': "div>p+ul#foo>li.bar$[foo=bar][bar=baz]*3>{baz}|slim", 'query': "div>p+ul#foo>li.bar$[foo=bar][bar=baz]*3>{baz}|slim", 'type': "html", 'result': "div\n p\n ul id=\"foo\"\n li foo=\"bar\" bar=\"baz\" class=\"bar1\"\n | baz\n li foo=\"bar\" bar=\"baz\" class=\"bar2\"\n | baz\n li foo=\"bar\" bar=\"baz\" class=\"bar3\"\n | baz\n", }, { 'name': "a*3|slim", 'query': "a*3|slim", 'type': "slim", 'result': "a href=\"\"\na href=\"\"\na href=\"\"\n", }, { 'name': ".content{Hello!}|slim", 'query': ".content{Hello!}|slim", 'type': "slim", 'result': "div class=\"content\"\n | Hello!\n", }, ], }, { 'category': 'xsl', 'tests': [ { 'name': "vari", 'query': "vari", 'type': "xsl", 'result': "\n", }, { 'name': "ap>wp", 'query': "ap>wp", 'type': "xsl", 'result': "\n\t\n\n", }, ], }, { 'category': 'xsd', 'tests': [ { 'name': "w3c", 'query': "xsd:w3c", 'type': "xsd", 'result': "\n\n\t\n", }, ], }, { 'category': 'mustache', 'tests': [ { 'name': "div#{{foo}}", 'query': "div#{{foo}}", 'type': "mustache", 'result': "
            \n", }, { 'name': "div.{{foo}}", 'query': "div.{{foo}}", 'type': "mustache", 'result': "
            \n", }, ], }, ] " vim:set et: