-
Notifications
You must be signed in to change notification settings - Fork 31
/
jqote.qunit.htm
119 lines (113 loc) · 4.58 KB
/
jqote.qunit.htm
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title>jQote2 QUnit Simple Test Suite // aefxx.com</title>
<link type="image/x-icon" href="favicon.ico" rel="Shortcut Icon">
<link rel="stylesheet" href="external/qunit.css" type="text/css"/>
<script src="external/jquery-1.4.2.min.js" type="text/javascript"></script>
<script src="external/qunit.js" type="text/javascript"></script>
<script src="jquery.jqote2.js" type="text/javascript"></script>
</head>
<body>
<h1 id="qunit-header">jQote2 QUnit Simple Test Suite</h1>
<h2 id="qunit-banner"></h2>
<h2 id="qunit-userAgent"></h2>
<ol id="qunit-tests"></ol>
<div id="dummy"></div>
<script type="text/javascript">
$(function() {
module('Core');
test('basic requirements', function() {
expect(6);
ok( $.fn.jqote, 'jQote2' );
ok( $.jqote, 'jQote2 static' );
ok( $.fn.jqoteapp, 'jQote2 append' );
ok( $.fn.jqotepre, 'jQote2 prepend' );
ok( $.fn.jqotesub, 'jQote2 substitute' );
ok( $.jqotec, 'jQote2 compile' );
});
module('Shorthand tag');
test('basic tests', function() {
expect(3);
equal($('#sb1').jqote({str: 'Hello World'}), 'Hello World');
equal($('#sb2').jqote({a: 25, b: 2}), '25 % 2 = 1');
equal($('#sb3').jqote({
a: function(b) {return 'Hello ' + b();},
b: function() {return 'Mr. O\'Brian';}
}), '"Hello Mr. O\'Brian"');
});
test('advanced tests', function() {
expect(2);
equal($('#sa1').jqote([{x: 0}]), '0123456789');
equal($('#sa2').jqote([{n: 7}]), '13');
});
module('Standard tag');
test('basic tests', function() {
expect(4);
equal($('#stdb1').jqote([{name: 'aefxx'}]), 'Hi, my name is aefxx.');
equal($('#stdb2').jqote([{a: 25, b: 2}]), '25 % 2 = 1');
equal($('#stdb3').jqote([{x: 3}]), 'IEEE 754');
equal($('#stdb4').jqote([{x: 3}]), 'GNU is Not Unix');
});
});
</script>
<script id="sb1" type="text/x-jqote-template">
<![CDATA[
<%= this.str %>
]]>
</script>
<script id="sb2" type="text/x-jqote-template">
<![CDATA[
<%= this.a %> % <%= this.b %> = <%= this.a % this.b %>
]]>
</script>
<script id="sb3" type="text/x-jqote-template">
<![CDATA[
"<%= this.a(this.b) %>"
]]>
</script>
<script id="sa1" type="text/x-jqote-template">
<![CDATA[
<%= this.x + ( j < 8 ? data[j+1] = {x: j+1, y: ''} : {y: '9'}).y %>
]]>
</script>
<script id="sa2" type="text/x-jqote-template">
<![CDATA[
<%= ( ( this.n === 0 ) ?
0 : ( this.n === 1 || this.n === 2 ) ?
1 : parseInt($.jqote(fn, {n: this.n-1}), 10) + parseInt($.jqote(fn, {n: this.n-2}), 10) )
%>
]]>
</script>
<script id="stdb1" type="text/x-jqote-template">
<![CDATA[
Hi, my name is <% out += this.name; %>.
]]>
</script>
<script id="stdb2" type="text/x-jqote-template">
<![CDATA[
<% out += this.a; %> % <% out += this.b; %> = <% if ( this.a % this.b ) %>1<% else %>0
]]>
</script>
<script id="stdb3" type="text/x-jqote-template">
<![CDATA[
I<% while ( this.x-- ) %>E<% ; %> 754
]]>
</script>
<script id="stdb4" type="text/x-jqote-template">
<![CDATA[
<% while ( this.x )
switch ( this.x-- ) {
case 3:
%>GNU is <%
break;
case 2:
%>Not <%
break;
default:
%>Unix<%
} %>
]]>
</script>
</body>
</html>