var t = template;

module('template.js');
QUnit.test( "template", function( assert ) {
    assert.ok(typeof t('') === 'function', '编译');

    var tpl1 = '<div>123</div>';
    assert.ok(t(tpl1, {}) === tpl1, "简单html");

    var tpl2 = '<div><%=name%></div>';
    assert.ok(t(tpl2, {name: 123}) === '<div>123</div>', '输出简答变量');
    var tpl2 = '<div><%=html%></div>';
    assert.ok(t(tpl2, {html: '<div id="test">'}) === '<div>&lt;div id=&quot;test&quot;&gt;</div>', '输出html');
    var tpl2 = '<div><%:h=html%></div>';
    assert.ok(t(tpl2, {html: '<div id="test">'}) === '<div>&lt;div id=&quot;test&quot;&gt;</div>', '输出html');

    var tpl3 = '<div><%:=text%></div>';
    assert.ok(t(tpl3, {text: '<div>'}) === '<div><div></div>', '输出变量');

    var tpl3 = '<%:u=url%>';
    assert.ok(t(tpl3, {url: 'http://yanhaijing.com?page=颜海镜'}) === 'http://yanhaijing.com?page=%E9%A2%9C%E6%B5%B7%E9%95%9C', '输出url');

    var tpl = '<%var name = 123;%><%=name%>';
    console.log(t(tpl, {}));
    assert.ok(t(tpl, {}) === '123', '自定义变量');

    var tpl = '<%for(var i = 0; i < 2; i++) {%>a<%}%>';
    assert.ok(t(tpl, {}) === 'aa', 'for语句');

    var tpl = '<%if (1) {%>a<%}%>';
    assert.ok(t(tpl, {}) === 'a', 'if语句');

    var tpl = '<%var a = 3;while(a--) {%>a<%}%>';
    assert.ok(t(tpl, {}) === 'aaa', 'while语句');
});

QUnit.test( "template.config", function( assert ) {
    var tpl = '<#=name%>';
    t.config({sTag: '<#'});
    assert.ok(t(tpl, {name: 123}) === '123', 'sTag');

    var tpl = '<%=name#>';
    t.config({sTag: '<%', eTag: '#>'});
    assert.ok(t(tpl, {name: 123}) === '123', 'eTag');

    var tpl = '<div>  </div>';
    t.config({sTag: '<%', eTag: '%>', compress: true});
    assert.ok(t(tpl, {}) === '<div> </div>', 'compress');

    //测试escape
    var tpl = '<%=html%>';
    t.config({sTag: '<%', eTag: '%>', compress: false, escape: false});
    assert.ok(t(tpl, {html: '<div>'}) === '<div>', 'escape');
});
@@ -315,24 +315,25 @@
  '%E8%BE%93%E5%87%BA%E7%AE%80%E7%AD%94%E5%8F%98%E9%87%8F');%0A
+%0A
     var tpl2
@@ -469,16 +469,21 @@
 html');%0A
+    %0A
     var 
@@ -958,31 +958,101 @@
     
-console.log(t(tpl, %7B%7D))
+assert.ok(t(tpl, %7B%7D) === '123', 'var name= 123; %E8%87%AA%E5%AE%9A%E4%B9%89%E5%8F%98%E9%87%8F');%0A%0A    var tpl = '%3C%25var a = 1%25%3E%3C%25=a%25%3E'
 ;%0A  
@@ -1084,19 +1084,22 @@
 = '1
-23
 ', '
-%E8%87%AA%E5%AE%9A%E4%B9%89%E5%8F%98%E9%87%8F
+%E7%9C%81%E7%95%A5%E7%BB%93%E5%B0%BE%E5%88%86%E5%8F%B7%E4%B8%8D%E4%BC%9A%E6%8A%A5%E9%94%99
 ');%0A
@@ -1120,33 +1120,13 @@
  '%3C%25
-for(var i = 0; i %3C 2; i++
+if (1
 ) %7B%25
@@ -1170,16 +1170,14 @@
 = 'a
-a
 ', '
+i
 f
-or
 %E8%AF%AD%E5%8F%A5')
@@ -1188,37 +1188,57 @@
    var tpl = '%3C%25
-if (1
+for(var i = 0; i %3C 2; i++
 ) %7B%25%3Ea%3C%25%7D%25%3E';%0A  
@@ -1258,38 +1258,40 @@
 (tpl, %7B%7D) === 'a
+a
 ', '
-i
 f
+or
 %E8%AF%AD%E5%8F%A5');%0A%0A    var t
@@ -1378,16 +1378,90 @@
 ile%E8%AF%AD%E5%8F%A5');
+%0A%0A    var tpl = '%3C%25=a%25%3E';%0A    assert.ok(t(tpl, %7B%7D) === '', '%E5%BC%95%E7%94%A8%E7%A9%BA%E5%8F%98%E9%87%8F%E8%BF%94%E5%9B%9E%E7%A9%BA%E5%AD%97%E7%AC%A6%E4%B8%B2');
 %0A%7D);%0A%0AQU
@@ -2063,12 +2063,13 @@
 scape');%0A%7D);
+%0A

add test case