stylus-source 0.15.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (113) hide show
  1. data/.DS_Store +0 -0
  2. data/README.md +3 -0
  3. data/lib/.DS_Store +0 -0
  4. data/lib/node_modules/cssom/.idea/CSSOM.iml +9 -0
  5. data/lib/node_modules/cssom/.idea/dictionaries/nv.xml +3 -0
  6. data/lib/node_modules/cssom/.idea/encodings.xml +5 -0
  7. data/lib/node_modules/cssom/.idea/misc.xml +17 -0
  8. data/lib/node_modules/cssom/.idea/modules.xml +9 -0
  9. data/lib/node_modules/cssom/.idea/projectCodeStyle.xml +82 -0
  10. data/lib/node_modules/cssom/.idea/vcs.xml +8 -0
  11. data/lib/node_modules/cssom/.idea/workspace.xml +467 -0
  12. data/lib/node_modules/cssom/.livereload +19 -0
  13. data/lib/node_modules/cssom/Jakefile +37 -0
  14. data/lib/node_modules/cssom/README.mdown +33 -0
  15. data/lib/node_modules/cssom/Rakefile +23 -0
  16. data/lib/node_modules/cssom/docs/.livereload +19 -0
  17. data/lib/node_modules/cssom/docs/bar.css +3 -0
  18. data/lib/node_modules/cssom/docs/demo.css +0 -0
  19. data/lib/node_modules/cssom/docs/foo.css +4 -0
  20. data/lib/node_modules/cssom/docs/parse.html +170 -0
  21. data/lib/node_modules/cssom/docs/parse2.html +431 -0
  22. data/lib/node_modules/cssom/index.html +100 -0
  23. data/lib/node_modules/cssom/lib/CSSImportRule.js +34 -0
  24. data/lib/node_modules/cssom/lib/CSSMediaRule.js +38 -0
  25. data/lib/node_modules/cssom/lib/CSSOM.js +3 -0
  26. data/lib/node_modules/cssom/lib/CSSRule.js +38 -0
  27. data/lib/node_modules/cssom/lib/CSSStyleDeclaration.js +130 -0
  28. data/lib/node_modules/cssom/lib/CSSStyleRule.js +187 -0
  29. data/lib/node_modules/cssom/lib/CSSStyleSheet.js +85 -0
  30. data/lib/node_modules/cssom/lib/MediaList.js +61 -0
  31. data/lib/node_modules/cssom/lib/StyleSheet.js +15 -0
  32. data/lib/node_modules/cssom/lib/clone.js +69 -0
  33. data/lib/node_modules/cssom/lib/index.js +10 -0
  34. data/lib/node_modules/cssom/lib/parse.js +195 -0
  35. data/lib/node_modules/cssom/media.html +17 -0
  36. data/lib/node_modules/cssom/package.json +30 -0
  37. data/lib/node_modules/cssom/plugins/toHTML.js +32 -0
  38. data/lib/node_modules/cssom/server/index.html +22 -0
  39. data/lib/node_modules/cssom/server/index.js +21 -0
  40. data/lib/node_modules/cssom/shorthands.html +21 -0
  41. data/lib/node_modules/cssom/test/CSSStyleDeclaration.test.js +35 -0
  42. data/lib/node_modules/cssom/test/CSSStyleRule.test.js +12 -0
  43. data/lib/node_modules/cssom/test/CSSStyleSheet.test.js +16 -0
  44. data/lib/node_modules/cssom/test/MediaList.test.js +21 -0
  45. data/lib/node_modules/cssom/test/clone.test.js +38 -0
  46. data/lib/node_modules/cssom/test/fixtures/dummy.css +3 -0
  47. data/lib/node_modules/cssom/test/helper.js +97 -0
  48. data/lib/node_modules/cssom/test/index.html +42 -0
  49. data/lib/node_modules/cssom/test/parse.test.js +346 -0
  50. data/lib/node_modules/cssom/test/vendor/qunit.css +189 -0
  51. data/lib/node_modules/cssom/test/vendor/qunit.js +1341 -0
  52. data/lib/node_modules/growl/History.md +16 -0
  53. data/lib/node_modules/growl/Readme.md +74 -0
  54. data/lib/node_modules/growl/lib/growl.js +82 -0
  55. data/lib/node_modules/growl/package.json +6 -0
  56. data/lib/node_modules/growl/test.js +17 -0
  57. data/lib/stylus/colors.js +156 -0
  58. data/lib/stylus/convert/css.js +130 -0
  59. data/lib/stylus/errors.js +58 -0
  60. data/lib/stylus/functions/image.js +120 -0
  61. data/lib/stylus/functions/index.js +722 -0
  62. data/lib/stylus/functions/index.styl +123 -0
  63. data/lib/stylus/functions/url.js +98 -0
  64. data/lib/stylus/lexer.js +728 -0
  65. data/lib/stylus/middleware.js +223 -0
  66. data/lib/stylus/nodes/arguments.js +65 -0
  67. data/lib/stylus/nodes/binop.js +54 -0
  68. data/lib/stylus/nodes/block.js +99 -0
  69. data/lib/stylus/nodes/boolean.js +103 -0
  70. data/lib/stylus/nodes/call.js +57 -0
  71. data/lib/stylus/nodes/charset.js +42 -0
  72. data/lib/stylus/nodes/comment.js +32 -0
  73. data/lib/stylus/nodes/each.js +56 -0
  74. data/lib/stylus/nodes/expression.js +168 -0
  75. data/lib/stylus/nodes/fontface.js +55 -0
  76. data/lib/stylus/nodes/function.js +104 -0
  77. data/lib/stylus/nodes/group.js +79 -0
  78. data/lib/stylus/nodes/hsla.js +256 -0
  79. data/lib/stylus/nodes/ident.js +127 -0
  80. data/lib/stylus/nodes/if.js +55 -0
  81. data/lib/stylus/nodes/import.js +30 -0
  82. data/lib/stylus/nodes/index.js +52 -0
  83. data/lib/stylus/nodes/jsliteral.js +32 -0
  84. data/lib/stylus/nodes/keyframes.js +78 -0
  85. data/lib/stylus/nodes/literal.js +92 -0
  86. data/lib/stylus/nodes/media.js +42 -0
  87. data/lib/stylus/nodes/node.js +209 -0
  88. data/lib/stylus/nodes/null.js +72 -0
  89. data/lib/stylus/nodes/page.js +43 -0
  90. data/lib/stylus/nodes/params.js +72 -0
  91. data/lib/stylus/nodes/property.js +72 -0
  92. data/lib/stylus/nodes/return.js +44 -0
  93. data/lib/stylus/nodes/rgba.js +335 -0
  94. data/lib/stylus/nodes/root.js +50 -0
  95. data/lib/stylus/nodes/selector.js +57 -0
  96. data/lib/stylus/nodes/string.js +120 -0
  97. data/lib/stylus/nodes/ternary.js +51 -0
  98. data/lib/stylus/nodes/unaryop.js +46 -0
  99. data/lib/stylus/nodes/unit.js +207 -0
  100. data/lib/stylus/parser.js +1514 -0
  101. data/lib/stylus/renderer.js +157 -0
  102. data/lib/stylus/source.rb +7 -0
  103. data/lib/stylus/stack/frame.js +66 -0
  104. data/lib/stylus/stack/index.js +146 -0
  105. data/lib/stylus/stack/scope.js +53 -0
  106. data/lib/stylus/stylus.js +102 -0
  107. data/lib/stylus/token.js +53 -0
  108. data/lib/stylus/utils.js +237 -0
  109. data/lib/stylus/visitor/compiler.js +472 -0
  110. data/lib/stylus/visitor/evaluator.js +1070 -0
  111. data/lib/stylus/visitor/index.js +31 -0
  112. data/stylus-source.gemspec +15 -0
  113. metadata +158 -0
@@ -0,0 +1,189 @@
1
+ /** Font Family and Sizes */
2
+
3
+ #qunit-wrapper {
4
+ font-family: "Helvetica Neue", Helvetica, sans-serif;
5
+ }
6
+
7
+ #qunit-testrunner-toolbar, #qunit-userAgent, #qunit-testresult, #qunit-tests li { font-size: small; }
8
+ #qunit-tests { font-size: smaller; }
9
+
10
+
11
+ /** Resets */
12
+
13
+ #qunit-wrapper, #qunit-tests, #qunit-tests ol, #qunit-header, #qunit-banner, #qunit-userAgent, #qunit-testresult {
14
+ margin: 0;
15
+ padding: 0;
16
+ }
17
+
18
+
19
+ /** Header */
20
+
21
+ #qunit-header {
22
+ font-family: "Helvetica Neue Light", "HelveticaNeue-Light", "Helvetica Neue", Helvetica, sans-serif;
23
+ padding: 0.5em 0 0.5em 1.3em;
24
+
25
+ color: #8699a4;
26
+ background-color: #0d3349;
27
+
28
+ font-size: 1.5em;
29
+ line-height: 1em;
30
+ font-weight: normal;
31
+ }
32
+
33
+ #qunit-header a {
34
+ text-decoration: none;
35
+ color: #c2ccd1;
36
+ }
37
+
38
+ #qunit-header a:hover,
39
+ #qunit-header a:focus {
40
+ color: #fff;
41
+ }
42
+
43
+ #qunit-banner.qunit-pass {
44
+ height: 3px;
45
+ }
46
+ #qunit-banner.qunit-fail {
47
+ height: 5px;
48
+ }
49
+
50
+ #qunit-testrunner-toolbar {
51
+ padding: 0 0 0.5em 2em;
52
+ }
53
+
54
+ #qunit-testrunner-toolbar label {
55
+ margin-right: 1em;
56
+ }
57
+
58
+ #qunit-userAgent {
59
+ padding: 0.5em 0 0.5em 2.5em;
60
+ font-weight: normal;
61
+ color: #666;
62
+ }
63
+
64
+
65
+ /** Tests: Pass/Fail */
66
+
67
+ #qunit-tests {
68
+ list-style-type: none;
69
+ background-color: #D2E0E6;
70
+ }
71
+
72
+ #qunit-tests li {
73
+ padding: 0.4em 0.5em 0.4em 2.5em;
74
+ }
75
+
76
+ #qunit-tests li strong {
77
+ font-weight: normal;
78
+ cursor: pointer;
79
+ }
80
+
81
+ #qunit-tests ol {
82
+ margin: 0.5em 0 1em;
83
+ background-color: #fff;
84
+ }
85
+
86
+ #qunit-tests table {
87
+ border-collapse: collapse;
88
+ margin-top: .2em;
89
+ }
90
+
91
+ #qunit-tests th {
92
+ text-align: right;
93
+ vertical-align: top;
94
+ padding: 0 .5em 0 0;
95
+ }
96
+
97
+ #qunit-tests td {
98
+ vertical-align: top;
99
+ }
100
+
101
+ #qunit-tests pre {
102
+ margin: 0;
103
+ white-space: pre-wrap;
104
+ word-wrap: break-word;
105
+ }
106
+
107
+ #qunit-tests del {
108
+ background-color: #e0f2be;
109
+ color: #374e0c;
110
+ text-decoration: none;
111
+ }
112
+
113
+ #qunit-tests ins {
114
+ background-color: #ffcaca;
115
+ color: #500;
116
+ text-decoration: none;
117
+ }
118
+
119
+ /*** Test Counts */
120
+
121
+ #qunit-tests b.passed { color: #5E740B; }
122
+ #qunit-tests b.failed {
123
+ color: #710909;
124
+ }
125
+ #qunit-tests li.fail .failed {
126
+ color: #E48989;
127
+ }
128
+ #qunit-tests li.fail .passed {
129
+ color: #E3C987;
130
+ }
131
+
132
+ #qunit-tests li li {
133
+ margin-left: 2.5em;
134
+ padding: 0.7em 0.5em 0.7em 0;
135
+ background-color: #fff;
136
+ border-bottom: none;
137
+ }
138
+
139
+ #qunit-tests b.counts {
140
+ font-weight: normal;
141
+ }
142
+
143
+ /*** Passing Styles */
144
+
145
+ #qunit-tests li li.pass {
146
+ color: #5E740B;
147
+ background-color: #fff;
148
+ }
149
+
150
+ #qunit-tests .pass { color: #2f3424; background-color: #d9dec3; }
151
+ #qunit-tests .pass .module-name { color: #636b51; }
152
+
153
+ #qunit-tests .pass .test-actual,
154
+ #qunit-tests .pass .test-expected { color: #999999; }
155
+
156
+ #qunit-banner.qunit-pass { background-color: #C6E746; }
157
+
158
+ /*** Failing Styles */
159
+
160
+ #qunit-tests li li.fail {
161
+ color: #710909;
162
+ background-color: #fff;
163
+ }
164
+
165
+ #qunit-tests .fail { color: #fff; background-color: #962323; }
166
+ #qunit-tests .fail .module-name,
167
+ #qunit-tests .fail .counts { color: #DEC1C1; }
168
+
169
+ #qunit-tests .fail .test-actual { color: #B72F2F; }
170
+ #qunit-tests .fail .test-expected { color: green; }
171
+
172
+ #qunit-banner.qunit-fail,
173
+ #qunit-testrunner-toolbar { color: #dec1c1; background-color: #962323; }
174
+
175
+
176
+ /** Footer */
177
+
178
+ #qunit-testresult {
179
+ padding: 0.5em 0.5em 0.5em 2.5em;
180
+ color: #333;
181
+ }
182
+
183
+ /** Fixture */
184
+
185
+ #qunit-fixture {
186
+ position: absolute;
187
+ top: -10000px;
188
+ left: -10000px;
189
+ }
@@ -0,0 +1,1341 @@
1
+ /*
2
+ * QUnit - A JavaScript Unit Testing Framework
3
+ *
4
+ * http://docs.jquery.com/QUnit
5
+ *
6
+ * Copyright (c) 2009 John Resig, Jörn Zaefferer
7
+ * Dual licensed under the MIT (MIT-LICENSE.txt)
8
+ * and GPL (GPL-LICENSE.txt) licenses.
9
+ */
10
+
11
+ (function(window) {
12
+
13
+ var defined = {
14
+ setTimeout: typeof window.setTimeout !== "undefined",
15
+ sessionStorage: (function() {
16
+ try {
17
+ return !!sessionStorage.getItem;
18
+ } catch(e){
19
+ return false;
20
+ }
21
+ })()
22
+ }
23
+
24
+ var testId = 0;
25
+
26
+ var Test = function(name, testName, expected, testEnvironmentArg, async, callback) {
27
+ this.name = name;
28
+ this.testName = testName;
29
+ this.expected = expected;
30
+ this.testEnvironmentArg = testEnvironmentArg;
31
+ this.async = async;
32
+ this.callback = callback;
33
+ this.assertions = [];
34
+ };
35
+ Test.prototype = {
36
+ init: function() {
37
+ var tests = id("qunit-tests");
38
+ if (tests) {
39
+ var b = document.createElement("strong");
40
+ b.innerHTML = "Running " + this.name;
41
+ var li = document.createElement("li");
42
+ li.appendChild( b );
43
+ li.id = this.id = "test-output" + testId++;
44
+ tests.appendChild( li );
45
+ }
46
+ },
47
+ setup: function() {
48
+ if (this.module != config.previousModule) {
49
+ if ( this.previousModule ) {
50
+ QUnit.moduleDone( this.module, config.moduleStats.bad, config.moduleStats.all );
51
+ }
52
+ config.previousModule = this.module;
53
+ config.moduleStats = { all: 0, bad: 0 };
54
+ QUnit.moduleStart( this.module, this.moduleTestEnvironment );
55
+ }
56
+
57
+ config.current = this;
58
+ this.testEnvironment = extend({
59
+ setup: function() {},
60
+ teardown: function() {}
61
+ }, this.moduleTestEnvironment);
62
+ if (this.testEnvironmentArg) {
63
+ extend(this.testEnvironment, this.testEnvironmentArg);
64
+ }
65
+
66
+ QUnit.testStart( this.testName, this.testEnvironment );
67
+
68
+ // allow utility functions to access the current test environment
69
+ // TODO why??
70
+ QUnit.current_testEnvironment = this.testEnvironment;
71
+
72
+ try {
73
+ if ( !config.pollution ) {
74
+ saveGlobal();
75
+ }
76
+
77
+ this.testEnvironment.setup.call(this.testEnvironment);
78
+ } catch(e) {
79
+ // TODO use testName instead of name for no-markup message?
80
+ QUnit.ok( false, "Setup failed on " + this.name + ": " + e.message );
81
+ }
82
+ },
83
+ run: function() {
84
+ if ( this.async ) {
85
+ QUnit.stop();
86
+ }
87
+
88
+ try {
89
+ this.callback.call(this.testEnvironment);
90
+ } catch(e) {
91
+ // TODO use testName instead of name for no-markup message?
92
+ fail("Test " + this.name + " died, exception and test follows", e, this.callback);
93
+ QUnit.ok( false, "Died on test #" + (this.assertions.length + 1) + ": " + e.message + " - " + QUnit.jsDump.parse(e) );
94
+ // else next test will carry the responsibility
95
+ saveGlobal();
96
+
97
+ // Restart the tests if they're blocking
98
+ if ( config.blocking ) {
99
+ start();
100
+ }
101
+ }
102
+ },
103
+ teardown: function() {
104
+ try {
105
+ checkPollution();
106
+ this.testEnvironment.teardown.call(this.testEnvironment);
107
+ } catch(e) {
108
+ // TODO use testName instead of name for no-markup message?
109
+ QUnit.ok( false, "Teardown failed on " + this.name + ": " + e.message );
110
+ }
111
+ },
112
+ finish: function() {
113
+ if ( this.expected && this.expected != this.assertions.length ) {
114
+ QUnit.ok( false, "Expected " + this.expected + " assertions, but " + this.assertions.length + " were run" );
115
+ }
116
+
117
+ var good = 0, bad = 0,
118
+ tests = id("qunit-tests");
119
+
120
+ config.stats.all += this.assertions.length;
121
+ config.moduleStats.all += this.assertions.length;
122
+
123
+ if ( tests ) {
124
+ var ol = document.createElement("ol");
125
+
126
+ for ( var i = 0; i < this.assertions.length; i++ ) {
127
+ var assertion = this.assertions[i];
128
+
129
+ var li = document.createElement("li");
130
+ li.className = assertion.result ? "pass" : "fail";
131
+ li.innerHTML = assertion.message || (assertion.result ? "okay" : "failed");
132
+ ol.appendChild( li );
133
+
134
+ if ( assertion.result ) {
135
+ good++;
136
+ } else {
137
+ bad++;
138
+ config.stats.bad++;
139
+ config.moduleStats.bad++;
140
+ }
141
+ }
142
+
143
+ // store result when possible
144
+ defined.sessionStorage && sessionStorage.setItem("qunit-" + this.testName, bad);
145
+
146
+ if (bad == 0) {
147
+ ol.style.display = "none";
148
+ }
149
+
150
+ var b = document.createElement("strong");
151
+ b.innerHTML = this.name + " <b class='counts'>(<b class='failed'>" + bad + "</b>, <b class='passed'>" + good + "</b>, " + this.assertions.length + ")</b>";
152
+
153
+ addEvent(b, "click", function() {
154
+ var next = b.nextSibling, display = next.style.display;
155
+ next.style.display = display === "none" ? "block" : "none";
156
+ });
157
+
158
+ addEvent(b, "dblclick", function(e) {
159
+ var target = e && e.target ? e.target : window.event.srcElement;
160
+ if ( target.nodeName.toLowerCase() == "span" || target.nodeName.toLowerCase() == "b" ) {
161
+ target = target.parentNode;
162
+ }
163
+ if ( window.location && target.nodeName.toLowerCase() === "strong" ) {
164
+ window.location.search = "?" + encodeURIComponent(getText([target]).replace(/\(.+\)$/, "").replace(/(^\s*|\s*$)/g, ""));
165
+ }
166
+ });
167
+
168
+ var li = id(this.id);
169
+ li.className = bad ? "fail" : "pass";
170
+ li.style.display = resultDisplayStyle(!bad);
171
+ li.removeChild( li.firstChild );
172
+ li.appendChild( b );
173
+ li.appendChild( ol );
174
+
175
+ if ( bad ) {
176
+ var toolbar = id("qunit-testrunner-toolbar");
177
+ if ( toolbar ) {
178
+ toolbar.style.display = "block";
179
+ id("qunit-filter-pass").disabled = null;
180
+ }
181
+ }
182
+
183
+ } else {
184
+ for ( var i = 0; i < this.assertions.length; i++ ) {
185
+ if ( !this.assertions[i].result ) {
186
+ bad++;
187
+ config.stats.bad++;
188
+ config.moduleStats.bad++;
189
+ }
190
+ }
191
+ }
192
+
193
+ try {
194
+ QUnit.reset();
195
+ } catch(e) {
196
+ // TODO use testName instead of name for no-markup message?
197
+ fail("reset() failed, following Test " + this.name + ", exception and reset fn follows", e, QUnit.reset);
198
+ }
199
+
200
+ QUnit.testDone( this.testName, bad, this.assertions.length );
201
+ },
202
+
203
+ queue: function() {
204
+ var test = this;
205
+ synchronize(function() {
206
+ test.init();
207
+ });
208
+ function run() {
209
+ // each of these can by async
210
+ synchronize(function() {
211
+ test.setup();
212
+ });
213
+ synchronize(function() {
214
+ test.run();
215
+ });
216
+ synchronize(function() {
217
+ test.teardown();
218
+ });
219
+ synchronize(function() {
220
+ test.finish();
221
+ });
222
+ }
223
+ // defer when previous test run passed, if storage is available
224
+ var bad = defined.sessionStorage && +sessionStorage.getItem("qunit-" + this.testName);
225
+ if (bad) {
226
+ run();
227
+ } else {
228
+ synchronize(run);
229
+ };
230
+ }
231
+
232
+ }
233
+
234
+ var QUnit = {
235
+
236
+ // call on start of module test to prepend name to all tests
237
+ module: function(name, testEnvironment) {
238
+ config.previousModule = config.currentModule;
239
+ config.currentModule = name;
240
+ config.currentModuleTestEnviroment = testEnvironment;
241
+ },
242
+
243
+ asyncTest: function(testName, expected, callback) {
244
+ if ( arguments.length === 2 ) {
245
+ callback = expected;
246
+ expected = 0;
247
+ }
248
+
249
+ QUnit.test(testName, expected, callback, true);
250
+ },
251
+
252
+ test: function(testName, expected, callback, async) {
253
+ var name = '<span class="test-name">' + testName + '</span>', testEnvironmentArg;
254
+
255
+ if ( arguments.length === 2 ) {
256
+ callback = expected;
257
+ expected = null;
258
+ }
259
+ // is 2nd argument a testEnvironment?
260
+ if ( expected && typeof expected === 'object') {
261
+ testEnvironmentArg = expected;
262
+ expected = null;
263
+ }
264
+
265
+ if ( config.currentModule ) {
266
+ name = '<span class="module-name">' + config.currentModule + "</span>: " + name;
267
+ }
268
+
269
+ if ( !validTest(config.currentModule + ": " + testName) ) {
270
+ return;
271
+ }
272
+
273
+ var test = new Test(name, testName, expected, testEnvironmentArg, async, callback);
274
+ test.previousModule = config.previousModule;
275
+ test.module = config.currentModule;
276
+ test.moduleTestEnvironment = config.currentModuleTestEnviroment;
277
+ test.queue();
278
+ },
279
+
280
+ /**
281
+ * Specify the number of expected assertions to gurantee that failed test (no assertions are run at all) don't slip through.
282
+ */
283
+ expect: function(asserts) {
284
+ config.current.expected = asserts;
285
+ },
286
+
287
+ /**
288
+ * Asserts true.
289
+ * @example ok( "asdfasdf".length > 5, "There must be at least 5 chars" );
290
+ */
291
+ ok: function(a, msg) {
292
+ a = !!a;
293
+ var details = {
294
+ result: a,
295
+ message: msg
296
+ };
297
+ msg = escapeHtml(msg);
298
+ QUnit.log(a, msg, details);
299
+ config.current.assertions.push({
300
+ result: a,
301
+ message: msg
302
+ });
303
+ },
304
+
305
+ /**
306
+ * Checks that the first two arguments are equal, with an optional message.
307
+ * Prints out both actual and expected values.
308
+ *
309
+ * Prefered to ok( actual == expected, message )
310
+ *
311
+ * @example equal( format("Received {0} bytes.", 2), "Received 2 bytes." );
312
+ *
313
+ * @param Object actual
314
+ * @param Object expected
315
+ * @param String message (optional)
316
+ */
317
+ equal: function(actual, expected, message) {
318
+ QUnit.push(expected == actual, actual, expected, message);
319
+ },
320
+
321
+ notEqual: function(actual, expected, message) {
322
+ QUnit.push(expected != actual, actual, expected, message);
323
+ },
324
+
325
+ deepEqual: function(actual, expected, message) {
326
+ QUnit.push(QUnit.equiv(actual, expected), actual, expected, message);
327
+ },
328
+
329
+ notDeepEqual: function(actual, expected, message) {
330
+ QUnit.push(!QUnit.equiv(actual, expected), actual, expected, message);
331
+ },
332
+
333
+ strictEqual: function(actual, expected, message) {
334
+ QUnit.push(expected === actual, actual, expected, message);
335
+ },
336
+
337
+ notStrictEqual: function(actual, expected, message) {
338
+ QUnit.push(expected !== actual, actual, expected, message);
339
+ },
340
+
341
+ raises: function(fn, message) {
342
+ try {
343
+ fn();
344
+ QUnit.ok( false, message );
345
+ }
346
+ catch (e) {
347
+ QUnit.ok( true, message );
348
+ }
349
+ },
350
+
351
+ start: function() {
352
+ // A slight delay, to avoid any current callbacks
353
+ if ( defined.setTimeout ) {
354
+ window.setTimeout(function() {
355
+ if ( config.timeout ) {
356
+ clearTimeout(config.timeout);
357
+ }
358
+
359
+ config.blocking = false;
360
+ process();
361
+ }, 13);
362
+ } else {
363
+ config.blocking = false;
364
+ process();
365
+ }
366
+ },
367
+
368
+ stop: function(timeout) {
369
+ config.blocking = true;
370
+
371
+ if ( timeout && defined.setTimeout ) {
372
+ config.timeout = window.setTimeout(function() {
373
+ QUnit.ok( false, "Test timed out" );
374
+ QUnit.start();
375
+ }, timeout);
376
+ }
377
+ }
378
+
379
+ };
380
+
381
+ // Backwards compatibility, deprecated
382
+ QUnit.equals = QUnit.equal;
383
+ QUnit.same = QUnit.deepEqual;
384
+
385
+ // Maintain internal state
386
+ var config = {
387
+ // The queue of tests to run
388
+ queue: [],
389
+
390
+ // block until document ready
391
+ blocking: true
392
+ };
393
+
394
+ // Load paramaters
395
+ (function() {
396
+ var location = window.location || { search: "", protocol: "file:" },
397
+ GETParams = location.search.slice(1).split('&');
398
+
399
+ for ( var i = 0; i < GETParams.length; i++ ) {
400
+ GETParams[i] = decodeURIComponent( GETParams[i] );
401
+ if ( GETParams[i] === "noglobals" ) {
402
+ GETParams.splice( i, 1 );
403
+ i--;
404
+ config.noglobals = true;
405
+ } else if ( GETParams[i].search('=') > -1 ) {
406
+ GETParams.splice( i, 1 );
407
+ i--;
408
+ }
409
+ }
410
+
411
+ // restrict modules/tests by get parameters
412
+ config.filters = GETParams;
413
+
414
+ // Figure out if we're running the tests from a server or not
415
+ QUnit.isLocal = !!(location.protocol === 'file:');
416
+ })();
417
+
418
+ // Expose the API as global variables, unless an 'exports'
419
+ // object exists, in that case we assume we're in CommonJS
420
+ if ( typeof exports === "undefined" || typeof require === "undefined" ) {
421
+ extend(window, QUnit);
422
+ window.QUnit = QUnit;
423
+ } else {
424
+ extend(exports, QUnit);
425
+ exports.QUnit = QUnit;
426
+ }
427
+
428
+ // define these after exposing globals to keep them in these QUnit namespace only
429
+ extend(QUnit, {
430
+ config: config,
431
+
432
+ // Initialize the configuration options
433
+ init: function() {
434
+ extend(config, {
435
+ stats: { all: 0, bad: 0 },
436
+ moduleStats: { all: 0, bad: 0 },
437
+ started: +new Date,
438
+ updateRate: 1000,
439
+ blocking: false,
440
+ autostart: true,
441
+ autorun: false,
442
+ filters: [],
443
+ queue: []
444
+ });
445
+
446
+ var tests = id("qunit-tests"),
447
+ banner = id("qunit-banner"),
448
+ result = id("qunit-testresult");
449
+
450
+ if ( tests ) {
451
+ tests.innerHTML = "";
452
+ }
453
+
454
+ if ( banner ) {
455
+ banner.className = "";
456
+ }
457
+
458
+ if ( result ) {
459
+ result.parentNode.removeChild( result );
460
+ }
461
+ },
462
+
463
+ /**
464
+ * Resets the test setup. Useful for tests that modify the DOM.
465
+ *
466
+ * If jQuery is available, uses jQuery's html(), otherwise just innerHTML.
467
+ */
468
+ reset: function() {
469
+ if ( window.jQuery ) {
470
+ jQuery( "#main, #qunit-fixture" ).html( config.fixture );
471
+ } else {
472
+ var main = id( 'main' ) || id( 'qunit-fixture' );
473
+ if ( main ) {
474
+ main.innerHTML = config.fixture;
475
+ }
476
+ }
477
+ },
478
+
479
+ /**
480
+ * Trigger an event on an element.
481
+ *
482
+ * @example triggerEvent( document.body, "click" );
483
+ *
484
+ * @param DOMElement elem
485
+ * @param String type
486
+ */
487
+ triggerEvent: function( elem, type, event ) {
488
+ if ( document.createEvent ) {
489
+ event = document.createEvent("MouseEvents");
490
+ event.initMouseEvent(type, true, true, elem.ownerDocument.defaultView,
491
+ 0, 0, 0, 0, 0, false, false, false, false, 0, null);
492
+ elem.dispatchEvent( event );
493
+
494
+ } else if ( elem.fireEvent ) {
495
+ elem.fireEvent("on"+type);
496
+ }
497
+ },
498
+
499
+ // Safe object type checking
500
+ is: function( type, obj ) {
501
+ return QUnit.objectType( obj ) == type;
502
+ },
503
+
504
+ objectType: function( obj ) {
505
+ if (typeof obj === "undefined") {
506
+ return "undefined";
507
+
508
+ // consider: typeof null === object
509
+ }
510
+ if (obj === null) {
511
+ return "null";
512
+ }
513
+
514
+ var type = Object.prototype.toString.call( obj )
515
+ .match(/^\[object\s(.*)\]$/)[1] || '';
516
+
517
+ switch (type) {
518
+ case 'Number':
519
+ if (isNaN(obj)) {
520
+ return "nan";
521
+ } else {
522
+ return "number";
523
+ }
524
+ case 'String':
525
+ case 'Boolean':
526
+ case 'Array':
527
+ case 'Date':
528
+ case 'RegExp':
529
+ case 'Function':
530
+ return type.toLowerCase();
531
+ }
532
+ if (typeof obj === "object") {
533
+ return "object";
534
+ }
535
+ return undefined;
536
+ },
537
+
538
+ push: function(result, actual, expected, message) {
539
+ var details = {
540
+ result: result,
541
+ message: message,
542
+ actual: actual,
543
+ expected: expected
544
+ };
545
+
546
+ message = escapeHtml(message) || (result ? "okay" : "failed");
547
+ message = '<span class="test-message">' + message + "</span>";
548
+ expected = escapeHtml(QUnit.jsDump.parse(expected));
549
+ actual = escapeHtml(QUnit.jsDump.parse(actual));
550
+ var output = message + '<table><tr class="test-expected"><th>Expected: </th><td><pre>' + expected + '</pre></td></tr>';
551
+ if (actual != expected) {
552
+ output += '<tr class="test-actual"><th>Result: </th><td><pre>' + actual + '</pre></td></tr>';
553
+ output += '<tr class="test-diff"><th>Diff: </th><td><pre>' + QUnit.diff(expected, actual) +'</pre></td></tr>';
554
+ }
555
+ if (!result) {
556
+ var source = sourceFromStacktrace();
557
+ if (source) {
558
+ details.source = source;
559
+ output += '<tr class="test-source"><th>Source: </th><td><pre>' + source +'</pre></td></tr>';
560
+ }
561
+ }
562
+ output += "</table>";
563
+
564
+ QUnit.log(result, message, details);
565
+
566
+ config.current.assertions.push({
567
+ result: !!result,
568
+ message: output
569
+ });
570
+ },
571
+
572
+ // Logging callbacks
573
+ begin: function() {},
574
+ done: function(failures, total) {},
575
+ log: function(result, message) {},
576
+ testStart: function(name, testEnvironment) {},
577
+ testDone: function(name, failures, total) {},
578
+ moduleStart: function(name, testEnvironment) {},
579
+ moduleDone: function(name, failures, total) {}
580
+ });
581
+
582
+ if ( typeof document === "undefined" || document.readyState === "complete" ) {
583
+ config.autorun = true;
584
+ }
585
+
586
+ addEvent(window, "load", function() {
587
+ QUnit.begin();
588
+
589
+ // Initialize the config, saving the execution queue
590
+ var oldconfig = extend({}, config);
591
+ QUnit.init();
592
+ extend(config, oldconfig);
593
+
594
+ config.blocking = false;
595
+
596
+ var userAgent = id("qunit-userAgent");
597
+ if ( userAgent ) {
598
+ userAgent.innerHTML = navigator.userAgent;
599
+ }
600
+ var banner = id("qunit-header");
601
+ if ( banner ) {
602
+ var paramsIndex = location.href.lastIndexOf(location.search);
603
+ if ( paramsIndex > -1 ) {
604
+ var mainPageLocation = location.href.slice(0, paramsIndex);
605
+ if ( mainPageLocation == location.href ) {
606
+ banner.innerHTML = '<a href=""> ' + banner.innerHTML + '</a> ';
607
+ } else {
608
+ var testName = decodeURIComponent(location.search.slice(1));
609
+ banner.innerHTML = '<a href="' + mainPageLocation + '">' + banner.innerHTML + '</a> &#8250; <a href="">' + testName + '</a>';
610
+ }
611
+ }
612
+ }
613
+
614
+ var toolbar = id("qunit-testrunner-toolbar");
615
+ if ( toolbar ) {
616
+ toolbar.style.display = "none";
617
+
618
+ var filter = document.createElement("input");
619
+ filter.type = "checkbox";
620
+ filter.id = "qunit-filter-pass";
621
+ filter.disabled = true;
622
+ addEvent( filter, "click", function() {
623
+ var li = document.getElementsByTagName("li");
624
+ for ( var i = 0; i < li.length; i++ ) {
625
+ if ( li[i].className.indexOf("pass") > -1 ) {
626
+ li[i].style.display = filter.checked ? "none" : "";
627
+ }
628
+ }
629
+ });
630
+ toolbar.appendChild( filter );
631
+
632
+ var label = document.createElement("label");
633
+ label.setAttribute("for", "qunit-filter-pass");
634
+ label.innerHTML = "Hide passed tests";
635
+ toolbar.appendChild( label );
636
+ }
637
+
638
+ var main = id('main') || id('qunit-fixture');
639
+ if ( main ) {
640
+ config.fixture = main.innerHTML;
641
+ }
642
+
643
+ if (config.autostart) {
644
+ QUnit.start();
645
+ }
646
+ });
647
+
648
+ function done() {
649
+ config.autorun = true;
650
+
651
+ // Log the last module results
652
+ if ( config.currentModule ) {
653
+ QUnit.moduleDone( config.currentModule, config.moduleStats.bad, config.moduleStats.all );
654
+ }
655
+
656
+ var banner = id("qunit-banner"),
657
+ tests = id("qunit-tests"),
658
+ html = ['Tests completed in ',
659
+ +new Date - config.started, ' milliseconds.<br/>',
660
+ '<span class="passed">', config.stats.all - config.stats.bad, '</span> tests of <span class="total">', config.stats.all, '</span> passed, <span class="failed">', config.stats.bad,'</span> failed.'].join('');
661
+
662
+ if ( banner ) {
663
+ banner.className = (config.stats.bad ? "qunit-fail" : "qunit-pass");
664
+ }
665
+
666
+ if ( tests ) {
667
+ var result = id("qunit-testresult");
668
+
669
+ if ( !result ) {
670
+ result = document.createElement("p");
671
+ result.id = "qunit-testresult";
672
+ result.className = "result";
673
+ tests.parentNode.insertBefore( result, tests.nextSibling );
674
+ }
675
+
676
+ result.innerHTML = html;
677
+ }
678
+
679
+ QUnit.done( config.stats.bad, config.stats.all );
680
+ }
681
+
682
+ function validTest( name ) {
683
+ var i = config.filters.length,
684
+ run = false;
685
+
686
+ if ( !i ) {
687
+ return true;
688
+ }
689
+
690
+ while ( i-- ) {
691
+ var filter = config.filters[i],
692
+ not = filter.charAt(0) == '!';
693
+
694
+ if ( not ) {
695
+ filter = filter.slice(1);
696
+ }
697
+
698
+ if ( name.indexOf(filter) !== -1 ) {
699
+ return !not;
700
+ }
701
+
702
+ if ( not ) {
703
+ run = true;
704
+ }
705
+ }
706
+
707
+ return run;
708
+ }
709
+
710
+ // so far supports only Firefox, Chrome and Opera (buggy)
711
+ // could be extended in the future to use something like https://github.com/csnover/TraceKit
712
+ function sourceFromStacktrace() {
713
+ try {
714
+ throw new Error();
715
+ } catch ( e ) {
716
+ if (e.stacktrace) {
717
+ // Opera
718
+ return e.stacktrace.split("\n")[6];
719
+ } else if (e.stack) {
720
+ // Firefox, Chrome
721
+ return e.stack.split("\n")[4];
722
+ }
723
+ }
724
+ }
725
+
726
+ function resultDisplayStyle(passed) {
727
+ return passed && id("qunit-filter-pass") && id("qunit-filter-pass").checked ? 'none' : '';
728
+ }
729
+
730
+ function escapeHtml(s) {
731
+ if (!s) {
732
+ return "";
733
+ }
734
+ s = s + "";
735
+ return s.replace(/[\&"<>\\]/g, function(s) {
736
+ switch(s) {
737
+ case "&": return "&amp;";
738
+ case "\\": return "\\\\";
739
+ case '"': return '\"';
740
+ case "<": return "&lt;";
741
+ case ">": return "&gt;";
742
+ default: return s;
743
+ }
744
+ });
745
+ }
746
+
747
+ function synchronize( callback ) {
748
+ config.queue.push( callback );
749
+
750
+ if ( config.autorun && !config.blocking ) {
751
+ process();
752
+ }
753
+ }
754
+
755
+ function process() {
756
+ var start = (new Date()).getTime();
757
+
758
+ while ( config.queue.length && !config.blocking ) {
759
+ if ( config.updateRate <= 0 || (((new Date()).getTime() - start) < config.updateRate) ) {
760
+ config.queue.shift()();
761
+ } else {
762
+ window.setTimeout( process, 13 );
763
+ break;
764
+ }
765
+ }
766
+ if (!config.blocking && !config.queue.length) {
767
+ done();
768
+ }
769
+ }
770
+
771
+ function saveGlobal() {
772
+ config.pollution = [];
773
+
774
+ if ( config.noglobals ) {
775
+ for ( var key in window ) {
776
+ config.pollution.push( key );
777
+ }
778
+ }
779
+ }
780
+
781
+ function checkPollution( name ) {
782
+ var old = config.pollution;
783
+ saveGlobal();
784
+
785
+ var newGlobals = diff( old, config.pollution );
786
+ if ( newGlobals.length > 0 ) {
787
+ ok( false, "Introduced global variable(s): " + newGlobals.join(", ") );
788
+ config.current.expected++;
789
+ }
790
+
791
+ var deletedGlobals = diff( config.pollution, old );
792
+ if ( deletedGlobals.length > 0 ) {
793
+ ok( false, "Deleted global variable(s): " + deletedGlobals.join(", ") );
794
+ config.current.expected++;
795
+ }
796
+ }
797
+
798
+ // returns a new Array with the elements that are in a but not in b
799
+ function diff( a, b ) {
800
+ var result = a.slice();
801
+ for ( var i = 0; i < result.length; i++ ) {
802
+ for ( var j = 0; j < b.length; j++ ) {
803
+ if ( result[i] === b[j] ) {
804
+ result.splice(i, 1);
805
+ i--;
806
+ break;
807
+ }
808
+ }
809
+ }
810
+ return result;
811
+ }
812
+
813
+ function fail(message, exception, callback) {
814
+ if ( typeof console !== "undefined" && console.error && console.warn ) {
815
+ console.error(message);
816
+ console.error(exception);
817
+ console.warn(callback.toString());
818
+
819
+ } else if ( window.opera && opera.postError ) {
820
+ opera.postError(message, exception, callback.toString);
821
+ }
822
+ }
823
+
824
+ function extend(a, b) {
825
+ for ( var prop in b ) {
826
+ a[prop] = b[prop];
827
+ }
828
+
829
+ return a;
830
+ }
831
+
832
+ function addEvent(elem, type, fn) {
833
+ if ( elem.addEventListener ) {
834
+ elem.addEventListener( type, fn, false );
835
+ } else if ( elem.attachEvent ) {
836
+ elem.attachEvent( "on" + type, fn );
837
+ } else {
838
+ fn();
839
+ }
840
+ }
841
+
842
+ function id(name) {
843
+ return !!(typeof document !== "undefined" && document && document.getElementById) &&
844
+ document.getElementById( name );
845
+ }
846
+
847
+ // Test for equality any JavaScript type.
848
+ // Discussions and reference: http://philrathe.com/articles/equiv
849
+ // Test suites: http://philrathe.com/tests/equiv
850
+ // Author: Philippe Rathé <prathe@gmail.com>
851
+ QUnit.equiv = function () {
852
+
853
+ var innerEquiv; // the real equiv function
854
+ var callers = []; // stack to decide between skip/abort functions
855
+ var parents = []; // stack to avoiding loops from circular referencing
856
+
857
+ // Call the o related callback with the given arguments.
858
+ function bindCallbacks(o, callbacks, args) {
859
+ var prop = QUnit.objectType(o);
860
+ if (prop) {
861
+ if (QUnit.objectType(callbacks[prop]) === "function") {
862
+ return callbacks[prop].apply(callbacks, args);
863
+ } else {
864
+ return callbacks[prop]; // or undefined
865
+ }
866
+ }
867
+ }
868
+
869
+ var callbacks = function () {
870
+
871
+ // for string, boolean, number and null
872
+ function useStrictEquality(b, a) {
873
+ if (b instanceof a.constructor || a instanceof b.constructor) {
874
+ // to catch short annotaion VS 'new' annotation of a declaration
875
+ // e.g. var i = 1;
876
+ // var j = new Number(1);
877
+ return a == b;
878
+ } else {
879
+ return a === b;
880
+ }
881
+ }
882
+
883
+ return {
884
+ "string": useStrictEquality,
885
+ "boolean": useStrictEquality,
886
+ "number": useStrictEquality,
887
+ "null": useStrictEquality,
888
+ "undefined": useStrictEquality,
889
+
890
+ "nan": function (b) {
891
+ return isNaN(b);
892
+ },
893
+
894
+ "date": function (b, a) {
895
+ return QUnit.objectType(b) === "date" && a.valueOf() === b.valueOf();
896
+ },
897
+
898
+ "regexp": function (b, a) {
899
+ return QUnit.objectType(b) === "regexp" &&
900
+ a.source === b.source && // the regex itself
901
+ a.global === b.global && // and its modifers (gmi) ...
902
+ a.ignoreCase === b.ignoreCase &&
903
+ a.multiline === b.multiline;
904
+ },
905
+
906
+ // - skip when the property is a method of an instance (OOP)
907
+ // - abort otherwise,
908
+ // initial === would have catch identical references anyway
909
+ "function": function () {
910
+ var caller = callers[callers.length - 1];
911
+ return caller !== Object &&
912
+ typeof caller !== "undefined";
913
+ },
914
+
915
+ "array": function (b, a) {
916
+ var i, j, loop;
917
+ var len;
918
+
919
+ // b could be an object literal here
920
+ if ( ! (QUnit.objectType(b) === "array")) {
921
+ return false;
922
+ }
923
+
924
+ len = a.length;
925
+ if (len !== b.length) { // safe and faster
926
+ return false;
927
+ }
928
+
929
+ //track reference to avoid circular references
930
+ parents.push(a);
931
+ for (i = 0; i < len; i++) {
932
+ loop = false;
933
+ for(j=0;j<parents.length;j++){
934
+ if(parents[j] === a[i]){
935
+ loop = true;//dont rewalk array
936
+ }
937
+ }
938
+ if (!loop && ! innerEquiv(a[i], b[i])) {
939
+ parents.pop();
940
+ return false;
941
+ }
942
+ }
943
+ parents.pop();
944
+ return true;
945
+ },
946
+
947
+ "object": function (b, a) {
948
+ var i, j, loop;
949
+ var eq = true; // unless we can proove it
950
+ var aProperties = [], bProperties = []; // collection of strings
951
+
952
+ // comparing constructors is more strict than using instanceof
953
+ if ( a.constructor !== b.constructor) {
954
+ return false;
955
+ }
956
+
957
+ // stack constructor before traversing properties
958
+ callers.push(a.constructor);
959
+ //track reference to avoid circular references
960
+ parents.push(a);
961
+
962
+ for (i in a) { // be strict: don't ensures hasOwnProperty and go deep
963
+ loop = false;
964
+ for(j=0;j<parents.length;j++){
965
+ if(parents[j] === a[i])
966
+ loop = true; //don't go down the same path twice
967
+ }
968
+ aProperties.push(i); // collect a's properties
969
+
970
+ if (!loop && ! innerEquiv(a[i], b[i])) {
971
+ eq = false;
972
+ break;
973
+ }
974
+ }
975
+
976
+ callers.pop(); // unstack, we are done
977
+ parents.pop();
978
+
979
+ for (i in b) {
980
+ bProperties.push(i); // collect b's properties
981
+ }
982
+
983
+ // Ensures identical properties name
984
+ return eq && innerEquiv(aProperties.sort(), bProperties.sort());
985
+ }
986
+ };
987
+ }();
988
+
989
+ innerEquiv = function () { // can take multiple arguments
990
+ var args = Array.prototype.slice.apply(arguments);
991
+ if (args.length < 2) {
992
+ return true; // end transition
993
+ }
994
+
995
+ return (function (a, b) {
996
+ if (a === b) {
997
+ return true; // catch the most you can
998
+ } else if (a === null || b === null || typeof a === "undefined" || typeof b === "undefined" || QUnit.objectType(a) !== QUnit.objectType(b)) {
999
+ return false; // don't lose time with error prone cases
1000
+ } else {
1001
+ return bindCallbacks(a, callbacks, [b, a]);
1002
+ }
1003
+
1004
+ // apply transition with (1..n) arguments
1005
+ })(args[0], args[1]) && arguments.callee.apply(this, args.splice(1, args.length -1));
1006
+ };
1007
+
1008
+ return innerEquiv;
1009
+
1010
+ }();
1011
+
1012
+ /**
1013
+ * jsDump
1014
+ * Copyright (c) 2008 Ariel Flesler - aflesler(at)gmail(dot)com | http://flesler.blogspot.com
1015
+ * Licensed under BSD (http://www.opensource.org/licenses/bsd-license.php)
1016
+ * Date: 5/15/2008
1017
+ * @projectDescription Advanced and extensible data dumping for Javascript.
1018
+ * @version 1.0.0
1019
+ * @author Ariel Flesler
1020
+ * @link {http://flesler.blogspot.com/2008/05/jsdump-pretty-dump-of-any-javascript.html}
1021
+ */
1022
+ QUnit.jsDump = (function() {
1023
+ function quote( str ) {
1024
+ return '"' + str.toString().replace(/"/g, '\\"') + '"';
1025
+ };
1026
+ function literal( o ) {
1027
+ return o + '';
1028
+ };
1029
+ function join( pre, arr, post ) {
1030
+ var s = jsDump.separator(),
1031
+ base = jsDump.indent(),
1032
+ inner = jsDump.indent(1);
1033
+ if ( arr.join )
1034
+ arr = arr.join( ',' + s + inner );
1035
+ if ( !arr )
1036
+ return pre + post;
1037
+ return [ pre, inner + arr, base + post ].join(s);
1038
+ };
1039
+ function array( arr ) {
1040
+ var i = arr.length, ret = Array(i);
1041
+ this.up();
1042
+ while ( i-- )
1043
+ ret[i] = this.parse( arr[i] );
1044
+ this.down();
1045
+ return join( '[', ret, ']' );
1046
+ };
1047
+
1048
+ var reName = /^function (\w+)/;
1049
+
1050
+ var jsDump = {
1051
+ parse:function( obj, type ) { //type is used mostly internally, you can fix a (custom)type in advance
1052
+ var parser = this.parsers[ type || this.typeOf(obj) ];
1053
+ type = typeof parser;
1054
+
1055
+ return type == 'function' ? parser.call( this, obj ) :
1056
+ type == 'string' ? parser :
1057
+ this.parsers.error;
1058
+ },
1059
+ typeOf:function( obj ) {
1060
+ var type;
1061
+ if ( obj === null ) {
1062
+ type = "null";
1063
+ } else if (typeof obj === "undefined") {
1064
+ type = "undefined";
1065
+ } else if (QUnit.is("RegExp", obj)) {
1066
+ type = "regexp";
1067
+ } else if (QUnit.is("Date", obj)) {
1068
+ type = "date";
1069
+ } else if (QUnit.is("Function", obj)) {
1070
+ type = "function";
1071
+ } else if (typeof obj.setInterval !== undefined && typeof obj.document !== "undefined" && typeof obj.nodeType === "undefined") {
1072
+ type = "window";
1073
+ } else if (obj.nodeType === 9) {
1074
+ type = "document";
1075
+ } else if (obj.nodeType) {
1076
+ type = "node";
1077
+ } else if (typeof obj === "object" && typeof obj.length === "number" && obj.length >= 0) {
1078
+ type = "array";
1079
+ } else {
1080
+ type = typeof obj;
1081
+ }
1082
+ return type;
1083
+ },
1084
+ separator:function() {
1085
+ return this.multiline ? this.HTML ? '<br />' : '\n' : this.HTML ? '&nbsp;' : ' ';
1086
+ },
1087
+ indent:function( extra ) {// extra can be a number, shortcut for increasing-calling-decreasing
1088
+ if ( !this.multiline )
1089
+ return '';
1090
+ var chr = this.indentChar;
1091
+ if ( this.HTML )
1092
+ chr = chr.replace(/\t/g,' ').replace(/ /g,'&nbsp;');
1093
+ return Array( this._depth_ + (extra||0) ).join(chr);
1094
+ },
1095
+ up:function( a ) {
1096
+ this._depth_ += a || 1;
1097
+ },
1098
+ down:function( a ) {
1099
+ this._depth_ -= a || 1;
1100
+ },
1101
+ setParser:function( name, parser ) {
1102
+ this.parsers[name] = parser;
1103
+ },
1104
+ // The next 3 are exposed so you can use them
1105
+ quote:quote,
1106
+ literal:literal,
1107
+ join:join,
1108
+ //
1109
+ _depth_: 1,
1110
+ // This is the list of parsers, to modify them, use jsDump.setParser
1111
+ parsers:{
1112
+ window: '[Window]',
1113
+ document: '[Document]',
1114
+ error:'[ERROR]', //when no parser is found, shouldn't happen
1115
+ unknown: '[Unknown]',
1116
+ 'null':'null',
1117
+ undefined:'undefined',
1118
+ 'function':function( fn ) {
1119
+ var ret = 'function',
1120
+ name = 'name' in fn ? fn.name : (reName.exec(fn)||[])[1];//functions never have name in IE
1121
+ if ( name )
1122
+ ret += ' ' + name;
1123
+ ret += '(';
1124
+
1125
+ ret = [ ret, QUnit.jsDump.parse( fn, 'functionArgs' ), '){'].join('');
1126
+ return join( ret, QUnit.jsDump.parse(fn,'functionCode'), '}' );
1127
+ },
1128
+ array: array,
1129
+ nodelist: array,
1130
+ arguments: array,
1131
+ object:function( map ) {
1132
+ var ret = [ ];
1133
+ QUnit.jsDump.up();
1134
+ for ( var key in map )
1135
+ ret.push( QUnit.jsDump.parse(key,'key') + ': ' + QUnit.jsDump.parse(map[key]) );
1136
+ QUnit.jsDump.down();
1137
+ return join( '{', ret, '}' );
1138
+ },
1139
+ node:function( node ) {
1140
+ var open = QUnit.jsDump.HTML ? '&lt;' : '<',
1141
+ close = QUnit.jsDump.HTML ? '&gt;' : '>';
1142
+
1143
+ var tag = node.nodeName.toLowerCase(),
1144
+ ret = open + tag;
1145
+
1146
+ for ( var a in QUnit.jsDump.DOMAttrs ) {
1147
+ var val = node[QUnit.jsDump.DOMAttrs[a]];
1148
+ if ( val )
1149
+ ret += ' ' + a + '=' + QUnit.jsDump.parse( val, 'attribute' );
1150
+ }
1151
+ return ret + close + open + '/' + tag + close;
1152
+ },
1153
+ functionArgs:function( fn ) {//function calls it internally, it's the arguments part of the function
1154
+ var l = fn.length;
1155
+ if ( !l ) return '';
1156
+
1157
+ var args = Array(l);
1158
+ while ( l-- )
1159
+ args[l] = String.fromCharCode(97+l);//97 is 'a'
1160
+ return ' ' + args.join(', ') + ' ';
1161
+ },
1162
+ key:quote, //object calls it internally, the key part of an item in a map
1163
+ functionCode:'[code]', //function calls it internally, it's the content of the function
1164
+ attribute:quote, //node calls it internally, it's an html attribute value
1165
+ string:quote,
1166
+ date:quote,
1167
+ regexp:literal, //regex
1168
+ number:literal,
1169
+ 'boolean':literal
1170
+ },
1171
+ DOMAttrs:{//attributes to dump from nodes, name=>realName
1172
+ id:'id',
1173
+ name:'name',
1174
+ 'class':'className'
1175
+ },
1176
+ HTML:false,//if true, entities are escaped ( <, >, \t, space and \n )
1177
+ indentChar:' ',//indentation unit
1178
+ multiline:true //if true, items in a collection, are separated by a \n, else just a space.
1179
+ };
1180
+
1181
+ return jsDump;
1182
+ })();
1183
+
1184
+ // from Sizzle.js
1185
+ function getText( elems ) {
1186
+ var ret = "", elem;
1187
+
1188
+ for ( var i = 0; elems[i]; i++ ) {
1189
+ elem = elems[i];
1190
+
1191
+ // Get the text from text nodes and CDATA nodes
1192
+ if ( elem.nodeType === 3 || elem.nodeType === 4 ) {
1193
+ ret += elem.nodeValue;
1194
+
1195
+ // Traverse everything else, except comment nodes
1196
+ } else if ( elem.nodeType !== 8 ) {
1197
+ ret += getText( elem.childNodes );
1198
+ }
1199
+ }
1200
+
1201
+ return ret;
1202
+ };
1203
+
1204
+ /*
1205
+ * Javascript Diff Algorithm
1206
+ * By John Resig (http://ejohn.org/)
1207
+ * Modified by Chu Alan "sprite"
1208
+ *
1209
+ * Released under the MIT license.
1210
+ *
1211
+ * More Info:
1212
+ * http://ejohn.org/projects/javascript-diff-algorithm/
1213
+ *
1214
+ * Usage: QUnit.diff(expected, actual)
1215
+ *
1216
+ * QUnit.diff("the quick brown fox jumped over", "the quick fox jumps over") == "the quick <del>brown </del> fox <del>jumped </del><ins>jumps </ins> over"
1217
+ */
1218
+ QUnit.diff = (function() {
1219
+ function diff(o, n){
1220
+ var ns = new Object();
1221
+ var os = new Object();
1222
+
1223
+ for (var i = 0; i < n.length; i++) {
1224
+ if (ns[n[i]] == null)
1225
+ ns[n[i]] = {
1226
+ rows: new Array(),
1227
+ o: null
1228
+ };
1229
+ ns[n[i]].rows.push(i);
1230
+ }
1231
+
1232
+ for (var i = 0; i < o.length; i++) {
1233
+ if (os[o[i]] == null)
1234
+ os[o[i]] = {
1235
+ rows: new Array(),
1236
+ n: null
1237
+ };
1238
+ os[o[i]].rows.push(i);
1239
+ }
1240
+
1241
+ for (var i in ns) {
1242
+ if (ns[i].rows.length == 1 && typeof(os[i]) != "undefined" && os[i].rows.length == 1) {
1243
+ n[ns[i].rows[0]] = {
1244
+ text: n[ns[i].rows[0]],
1245
+ row: os[i].rows[0]
1246
+ };
1247
+ o[os[i].rows[0]] = {
1248
+ text: o[os[i].rows[0]],
1249
+ row: ns[i].rows[0]
1250
+ };
1251
+ }
1252
+ }
1253
+
1254
+ for (var i = 0; i < n.length - 1; i++) {
1255
+ if (n[i].text != null && n[i + 1].text == null && n[i].row + 1 < o.length && o[n[i].row + 1].text == null &&
1256
+ n[i + 1] == o[n[i].row + 1]) {
1257
+ n[i + 1] = {
1258
+ text: n[i + 1],
1259
+ row: n[i].row + 1
1260
+ };
1261
+ o[n[i].row + 1] = {
1262
+ text: o[n[i].row + 1],
1263
+ row: i + 1
1264
+ };
1265
+ }
1266
+ }
1267
+
1268
+ for (var i = n.length - 1; i > 0; i--) {
1269
+ if (n[i].text != null && n[i - 1].text == null && n[i].row > 0 && o[n[i].row - 1].text == null &&
1270
+ n[i - 1] == o[n[i].row - 1]) {
1271
+ n[i - 1] = {
1272
+ text: n[i - 1],
1273
+ row: n[i].row - 1
1274
+ };
1275
+ o[n[i].row - 1] = {
1276
+ text: o[n[i].row - 1],
1277
+ row: i - 1
1278
+ };
1279
+ }
1280
+ }
1281
+
1282
+ return {
1283
+ o: o,
1284
+ n: n
1285
+ };
1286
+ }
1287
+
1288
+ return function(o, n){
1289
+ o = o.replace(/\s+$/, '');
1290
+ n = n.replace(/\s+$/, '');
1291
+ var out = diff(o == "" ? [] : o.split(/\s+/), n == "" ? [] : n.split(/\s+/));
1292
+
1293
+ var str = "";
1294
+
1295
+ var oSpace = o.match(/\s+/g);
1296
+ if (oSpace == null) {
1297
+ oSpace = [" "];
1298
+ }
1299
+ else {
1300
+ oSpace.push(" ");
1301
+ }
1302
+ var nSpace = n.match(/\s+/g);
1303
+ if (nSpace == null) {
1304
+ nSpace = [" "];
1305
+ }
1306
+ else {
1307
+ nSpace.push(" ");
1308
+ }
1309
+
1310
+ if (out.n.length == 0) {
1311
+ for (var i = 0; i < out.o.length; i++) {
1312
+ str += '<del>' + out.o[i] + oSpace[i] + "</del>";
1313
+ }
1314
+ }
1315
+ else {
1316
+ if (out.n[0].text == null) {
1317
+ for (n = 0; n < out.o.length && out.o[n].text == null; n++) {
1318
+ str += '<del>' + out.o[n] + oSpace[n] + "</del>";
1319
+ }
1320
+ }
1321
+
1322
+ for (var i = 0; i < out.n.length; i++) {
1323
+ if (out.n[i].text == null) {
1324
+ str += '<ins>' + out.n[i] + nSpace[i] + "</ins>";
1325
+ }
1326
+ else {
1327
+ var pre = "";
1328
+
1329
+ for (n = out.n[i].row + 1; n < out.o.length && out.o[n].text == null; n++) {
1330
+ pre += '<del>' + out.o[n] + oSpace[n] + "</del>";
1331
+ }
1332
+ str += " " + out.n[i].text + nSpace[i] + pre;
1333
+ }
1334
+ }
1335
+ }
1336
+
1337
+ return str;
1338
+ };
1339
+ })();
1340
+
1341
+ })(this);