konacha 2.1.0 → 2.2.0
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.
- data/.travis.yml +8 -1
- data/Gemfile-rails4 +7 -0
- data/History.md +4 -0
- data/README.md +5 -2
- data/Rakefile +4 -0
- data/app/views/konacha/specs/parent.html.erb +1 -1
- data/config.ru +2 -0
- data/config/routes.rb +1 -1
- data/konacha.gemspec +6 -4
- data/spec/dummy/config/application.rb +1 -0
- data/spec/dummy/config/environments/development.rb +2 -2
- data/spec/dummy/config/initializers/secret_token.rb +12 -0
- data/spec/error_handling_spec.rb +1 -1
- data/spec/runner_spec.rb +101 -85
- data/spec/server_spec.rb +1 -1
- data/spec/spec_helper.rb +3 -2
- data/spec/views/specs/iframe.html.erb_spec.rb +6 -5
- data/spec/views/specs/parent.html.erb_spec.rb +20 -0
- data/vendor/assets/javascripts/chai.js +212 -52
- data/vendor/assets/javascripts/mocha.js +372 -32
- data/vendor/assets/stylesheets/mocha.css +8 -4
- metadata +48 -13
@@ -58,6 +58,293 @@ module.exports = function(type){
|
|
58
58
|
}); // module: browser/debug.js
|
59
59
|
|
60
60
|
require.register("browser/diff.js", function(module, exports, require){
|
61
|
+
/* See license.txt for terms of usage */
|
62
|
+
|
63
|
+
/*
|
64
|
+
* Text diff implementation.
|
65
|
+
*
|
66
|
+
* This library supports the following APIS:
|
67
|
+
* JsDiff.diffChars: Character by character diff
|
68
|
+
* JsDiff.diffWords: Word (as defined by \b regex) diff which ignores whitespace
|
69
|
+
* JsDiff.diffLines: Line based diff
|
70
|
+
*
|
71
|
+
* JsDiff.diffCss: Diff targeted at CSS content
|
72
|
+
*
|
73
|
+
* These methods are based on the implementation proposed in
|
74
|
+
* "An O(ND) Difference Algorithm and its Variations" (Myers, 1986).
|
75
|
+
* http://citeseerx.ist.psu.edu/viewdoc/summary?doi=10.1.1.4.6927
|
76
|
+
*/
|
77
|
+
var JsDiff = (function() {
|
78
|
+
function clonePath(path) {
|
79
|
+
return { newPos: path.newPos, components: path.components.slice(0) };
|
80
|
+
}
|
81
|
+
function removeEmpty(array) {
|
82
|
+
var ret = [];
|
83
|
+
for (var i = 0; i < array.length; i++) {
|
84
|
+
if (array[i]) {
|
85
|
+
ret.push(array[i]);
|
86
|
+
}
|
87
|
+
}
|
88
|
+
return ret;
|
89
|
+
}
|
90
|
+
function escapeHTML(s) {
|
91
|
+
var n = s;
|
92
|
+
n = n.replace(/&/g, "&");
|
93
|
+
n = n.replace(/</g, "<");
|
94
|
+
n = n.replace(/>/g, ">");
|
95
|
+
n = n.replace(/"/g, """);
|
96
|
+
|
97
|
+
return n;
|
98
|
+
}
|
99
|
+
|
100
|
+
|
101
|
+
var fbDiff = function(ignoreWhitespace) {
|
102
|
+
this.ignoreWhitespace = ignoreWhitespace;
|
103
|
+
};
|
104
|
+
fbDiff.prototype = {
|
105
|
+
diff: function(oldString, newString) {
|
106
|
+
// Handle the identity case (this is due to unrolling editLength == 0
|
107
|
+
if (newString == oldString) {
|
108
|
+
return [{ value: newString }];
|
109
|
+
}
|
110
|
+
if (!newString) {
|
111
|
+
return [{ value: oldString, removed: true }];
|
112
|
+
}
|
113
|
+
if (!oldString) {
|
114
|
+
return [{ value: newString, added: true }];
|
115
|
+
}
|
116
|
+
|
117
|
+
newString = this.tokenize(newString);
|
118
|
+
oldString = this.tokenize(oldString);
|
119
|
+
|
120
|
+
var newLen = newString.length, oldLen = oldString.length;
|
121
|
+
var maxEditLength = newLen + oldLen;
|
122
|
+
var bestPath = [{ newPos: -1, components: [] }];
|
123
|
+
|
124
|
+
// Seed editLength = 0
|
125
|
+
var oldPos = this.extractCommon(bestPath[0], newString, oldString, 0);
|
126
|
+
if (bestPath[0].newPos+1 >= newLen && oldPos+1 >= oldLen) {
|
127
|
+
return bestPath[0].components;
|
128
|
+
}
|
129
|
+
|
130
|
+
for (var editLength = 1; editLength <= maxEditLength; editLength++) {
|
131
|
+
for (var diagonalPath = -1*editLength; diagonalPath <= editLength; diagonalPath+=2) {
|
132
|
+
var basePath;
|
133
|
+
var addPath = bestPath[diagonalPath-1],
|
134
|
+
removePath = bestPath[diagonalPath+1];
|
135
|
+
oldPos = (removePath ? removePath.newPos : 0) - diagonalPath;
|
136
|
+
if (addPath) {
|
137
|
+
// No one else is going to attempt to use this value, clear it
|
138
|
+
bestPath[diagonalPath-1] = undefined;
|
139
|
+
}
|
140
|
+
|
141
|
+
var canAdd = addPath && addPath.newPos+1 < newLen;
|
142
|
+
var canRemove = removePath && 0 <= oldPos && oldPos < oldLen;
|
143
|
+
if (!canAdd && !canRemove) {
|
144
|
+
bestPath[diagonalPath] = undefined;
|
145
|
+
continue;
|
146
|
+
}
|
147
|
+
|
148
|
+
// Select the diagonal that we want to branch from. We select the prior
|
149
|
+
// path whose position in the new string is the farthest from the origin
|
150
|
+
// and does not pass the bounds of the diff graph
|
151
|
+
if (!canAdd || (canRemove && addPath.newPos < removePath.newPos)) {
|
152
|
+
basePath = clonePath(removePath);
|
153
|
+
this.pushComponent(basePath.components, oldString[oldPos], undefined, true);
|
154
|
+
} else {
|
155
|
+
basePath = clonePath(addPath);
|
156
|
+
basePath.newPos++;
|
157
|
+
this.pushComponent(basePath.components, newString[basePath.newPos], true, undefined);
|
158
|
+
}
|
159
|
+
|
160
|
+
var oldPos = this.extractCommon(basePath, newString, oldString, diagonalPath);
|
161
|
+
|
162
|
+
if (basePath.newPos+1 >= newLen && oldPos+1 >= oldLen) {
|
163
|
+
return basePath.components;
|
164
|
+
} else {
|
165
|
+
bestPath[diagonalPath] = basePath;
|
166
|
+
}
|
167
|
+
}
|
168
|
+
}
|
169
|
+
},
|
170
|
+
|
171
|
+
pushComponent: function(components, value, added, removed) {
|
172
|
+
var last = components[components.length-1];
|
173
|
+
if (last && last.added === added && last.removed === removed) {
|
174
|
+
// We need to clone here as the component clone operation is just
|
175
|
+
// as shallow array clone
|
176
|
+
components[components.length-1] =
|
177
|
+
{value: this.join(last.value, value), added: added, removed: removed };
|
178
|
+
} else {
|
179
|
+
components.push({value: value, added: added, removed: removed });
|
180
|
+
}
|
181
|
+
},
|
182
|
+
extractCommon: function(basePath, newString, oldString, diagonalPath) {
|
183
|
+
var newLen = newString.length,
|
184
|
+
oldLen = oldString.length,
|
185
|
+
newPos = basePath.newPos,
|
186
|
+
oldPos = newPos - diagonalPath;
|
187
|
+
while (newPos+1 < newLen && oldPos+1 < oldLen && this.equals(newString[newPos+1], oldString[oldPos+1])) {
|
188
|
+
newPos++;
|
189
|
+
oldPos++;
|
190
|
+
|
191
|
+
this.pushComponent(basePath.components, newString[newPos], undefined, undefined);
|
192
|
+
}
|
193
|
+
basePath.newPos = newPos;
|
194
|
+
return oldPos;
|
195
|
+
},
|
196
|
+
|
197
|
+
equals: function(left, right) {
|
198
|
+
var reWhitespace = /\S/;
|
199
|
+
if (this.ignoreWhitespace && !reWhitespace.test(left) && !reWhitespace.test(right)) {
|
200
|
+
return true;
|
201
|
+
} else {
|
202
|
+
return left == right;
|
203
|
+
}
|
204
|
+
},
|
205
|
+
join: function(left, right) {
|
206
|
+
return left + right;
|
207
|
+
},
|
208
|
+
tokenize: function(value) {
|
209
|
+
return value;
|
210
|
+
}
|
211
|
+
};
|
212
|
+
|
213
|
+
var CharDiff = new fbDiff();
|
214
|
+
|
215
|
+
var WordDiff = new fbDiff(true);
|
216
|
+
WordDiff.tokenize = function(value) {
|
217
|
+
return removeEmpty(value.split(/(\s+|\b)/));
|
218
|
+
};
|
219
|
+
|
220
|
+
var CssDiff = new fbDiff(true);
|
221
|
+
CssDiff.tokenize = function(value) {
|
222
|
+
return removeEmpty(value.split(/([{}:;,]|\s+)/));
|
223
|
+
};
|
224
|
+
|
225
|
+
var LineDiff = new fbDiff();
|
226
|
+
LineDiff.tokenize = function(value) {
|
227
|
+
return value.split(/^/m);
|
228
|
+
};
|
229
|
+
|
230
|
+
return {
|
231
|
+
diffChars: function(oldStr, newStr) { return CharDiff.diff(oldStr, newStr); },
|
232
|
+
diffWords: function(oldStr, newStr) { return WordDiff.diff(oldStr, newStr); },
|
233
|
+
diffLines: function(oldStr, newStr) { return LineDiff.diff(oldStr, newStr); },
|
234
|
+
|
235
|
+
diffCss: function(oldStr, newStr) { return CssDiff.diff(oldStr, newStr); },
|
236
|
+
|
237
|
+
createPatch: function(fileName, oldStr, newStr, oldHeader, newHeader) {
|
238
|
+
var ret = [];
|
239
|
+
|
240
|
+
ret.push("Index: " + fileName);
|
241
|
+
ret.push("===================================================================");
|
242
|
+
ret.push("--- " + fileName + (typeof oldHeader === "undefined" ? "" : "\t" + oldHeader));
|
243
|
+
ret.push("+++ " + fileName + (typeof newHeader === "undefined" ? "" : "\t" + newHeader));
|
244
|
+
|
245
|
+
var diff = LineDiff.diff(oldStr, newStr);
|
246
|
+
if (!diff[diff.length-1].value) {
|
247
|
+
diff.pop(); // Remove trailing newline add
|
248
|
+
}
|
249
|
+
diff.push({value: "", lines: []}); // Append an empty value to make cleanup easier
|
250
|
+
|
251
|
+
function contextLines(lines) {
|
252
|
+
return lines.map(function(entry) { return ' ' + entry; });
|
253
|
+
}
|
254
|
+
function eofNL(curRange, i, current) {
|
255
|
+
var last = diff[diff.length-2],
|
256
|
+
isLast = i === diff.length-2,
|
257
|
+
isLastOfType = i === diff.length-3 && (current.added === !last.added || current.removed === !last.removed);
|
258
|
+
|
259
|
+
// Figure out if this is the last line for the given file and missing NL
|
260
|
+
if (!/\n$/.test(current.value) && (isLast || isLastOfType)) {
|
261
|
+
curRange.push('\');
|
262
|
+
}
|
263
|
+
}
|
264
|
+
|
265
|
+
var oldRangeStart = 0, newRangeStart = 0, curRange = [],
|
266
|
+
oldLine = 1, newLine = 1;
|
267
|
+
for (var i = 0; i < diff.length; i++) {
|
268
|
+
var current = diff[i],
|
269
|
+
lines = current.lines || current.value.replace(/\n$/, "").split("\n");
|
270
|
+
current.lines = lines;
|
271
|
+
|
272
|
+
if (current.added || current.removed) {
|
273
|
+
if (!oldRangeStart) {
|
274
|
+
var prev = diff[i-1];
|
275
|
+
oldRangeStart = oldLine;
|
276
|
+
newRangeStart = newLine;
|
277
|
+
|
278
|
+
if (prev) {
|
279
|
+
curRange = contextLines(prev.lines.slice(-4));
|
280
|
+
oldRangeStart -= curRange.length;
|
281
|
+
newRangeStart -= curRange.length;
|
282
|
+
}
|
283
|
+
}
|
284
|
+
curRange.push.apply(curRange, lines.map(function(entry) { return (current.added?"+":"-") + entry; }));
|
285
|
+
eofNL(curRange, i, current);
|
286
|
+
|
287
|
+
if (current.added) {
|
288
|
+
newLine += lines.length;
|
289
|
+
} else {
|
290
|
+
oldLine += lines.length;
|
291
|
+
}
|
292
|
+
} else {
|
293
|
+
if (oldRangeStart) {
|
294
|
+
// Close out any changes that have been output (or join overlapping)
|
295
|
+
if (lines.length <= 8 && i < diff.length-2) {
|
296
|
+
// Overlapping
|
297
|
+
curRange.push.apply(curRange, contextLines(lines));
|
298
|
+
} else {
|
299
|
+
// end the range and output
|
300
|
+
var contextSize = Math.min(lines.length, 4);
|
301
|
+
ret.push(
|
302
|
+
"@@ -" + oldRangeStart + "," + (oldLine-oldRangeStart+contextSize)
|
303
|
+
+ " +" + newRangeStart + "," + (newLine-newRangeStart+contextSize)
|
304
|
+
+ " @@");
|
305
|
+
ret.push.apply(ret, curRange);
|
306
|
+
ret.push.apply(ret, contextLines(lines.slice(0, contextSize)));
|
307
|
+
if (lines.length <= 4) {
|
308
|
+
eofNL(ret, i, current);
|
309
|
+
}
|
310
|
+
|
311
|
+
oldRangeStart = 0; newRangeStart = 0; curRange = [];
|
312
|
+
}
|
313
|
+
}
|
314
|
+
oldLine += lines.length;
|
315
|
+
newLine += lines.length;
|
316
|
+
}
|
317
|
+
}
|
318
|
+
|
319
|
+
return ret.join('\n') + '\n';
|
320
|
+
},
|
321
|
+
|
322
|
+
convertChangesToXML: function(changes){
|
323
|
+
var ret = [];
|
324
|
+
for ( var i = 0; i < changes.length; i++) {
|
325
|
+
var change = changes[i];
|
326
|
+
if (change.added) {
|
327
|
+
ret.push("<ins>");
|
328
|
+
} else if (change.removed) {
|
329
|
+
ret.push("<del>");
|
330
|
+
}
|
331
|
+
|
332
|
+
ret.push(escapeHTML(change.value));
|
333
|
+
|
334
|
+
if (change.added) {
|
335
|
+
ret.push("</ins>");
|
336
|
+
} else if (change.removed) {
|
337
|
+
ret.push("</del>");
|
338
|
+
}
|
339
|
+
}
|
340
|
+
return ret.join("");
|
341
|
+
}
|
342
|
+
};
|
343
|
+
})();
|
344
|
+
|
345
|
+
if (typeof module !== "undefined") {
|
346
|
+
module.exports = JsDiff;
|
347
|
+
}
|
61
348
|
|
62
349
|
}); // module: browser/diff.js
|
63
350
|
|
@@ -494,7 +781,9 @@ function Hook(title, fn) {
|
|
494
781
|
* Inherit from `Runnable.prototype`.
|
495
782
|
*/
|
496
783
|
|
497
|
-
|
784
|
+
function F(){};
|
785
|
+
F.prototype = Runnable.prototype;
|
786
|
+
Hook.prototype = new F;
|
498
787
|
Hook.prototype.constructor = Hook;
|
499
788
|
|
500
789
|
|
@@ -1005,6 +1294,7 @@ function image(name) {
|
|
1005
1294
|
* - `reporter` reporter instance, defaults to `mocha.reporters.Dot`
|
1006
1295
|
* - `globals` array of accepted globals
|
1007
1296
|
* - `timeout` timeout in milliseconds
|
1297
|
+
* - `bail` bail on the first test failure
|
1008
1298
|
* - `slow` milliseconds to wait before considering a test slow
|
1009
1299
|
* - `ignoreLeaks` ignore global leaks
|
1010
1300
|
* - `grep` string or regexp to filter tests with
|
@@ -1020,11 +1310,25 @@ function Mocha(options) {
|
|
1020
1310
|
this.grep(options.grep);
|
1021
1311
|
this.suite = new exports.Suite('', new exports.Context);
|
1022
1312
|
this.ui(options.ui);
|
1313
|
+
this.bail(options.bail);
|
1023
1314
|
this.reporter(options.reporter);
|
1024
1315
|
if (options.timeout) this.timeout(options.timeout);
|
1025
1316
|
if (options.slow) this.slow(options.slow);
|
1026
1317
|
}
|
1027
1318
|
|
1319
|
+
/**
|
1320
|
+
* Enable or disable bailing on the first failure.
|
1321
|
+
*
|
1322
|
+
* @param {Boolean} [bail]
|
1323
|
+
* @api public
|
1324
|
+
*/
|
1325
|
+
|
1326
|
+
Mocha.prototype.bail = function(bail){
|
1327
|
+
if (0 == arguments.length) bail = true;
|
1328
|
+
this.suite.bail(bail);
|
1329
|
+
return this;
|
1330
|
+
};
|
1331
|
+
|
1028
1332
|
/**
|
1029
1333
|
* Add test `file`.
|
1030
1334
|
*
|
@@ -1040,7 +1344,7 @@ Mocha.prototype.addFile = function(file){
|
|
1040
1344
|
/**
|
1041
1345
|
* Set reporter to `reporter`, defaults to "dot".
|
1042
1346
|
*
|
1043
|
-
* @param {String|Function} reporter name
|
1347
|
+
* @param {String|Function} reporter name or constructor
|
1044
1348
|
* @api public
|
1045
1349
|
*/
|
1046
1350
|
|
@@ -1408,7 +1712,7 @@ exports.colors = {
|
|
1408
1712
|
*/
|
1409
1713
|
|
1410
1714
|
exports.symbols = {
|
1411
|
-
ok: '
|
1715
|
+
ok: '✓',
|
1412
1716
|
err: '✖',
|
1413
1717
|
dot: '․'
|
1414
1718
|
};
|
@@ -1651,7 +1955,7 @@ Base.prototype.epilogue = function(){
|
|
1651
1955
|
}
|
1652
1956
|
|
1653
1957
|
// pass
|
1654
|
-
fmt = color('bright pass', '
|
1958
|
+
fmt = color('bright pass', ' ')
|
1655
1959
|
+ color('green', ' %d %s complete')
|
1656
1960
|
+ color('light', ' (%s)');
|
1657
1961
|
|
@@ -1662,7 +1966,7 @@ Base.prototype.epilogue = function(){
|
|
1662
1966
|
|
1663
1967
|
// pending
|
1664
1968
|
if (stats.pending) {
|
1665
|
-
fmt = color('pending', '
|
1969
|
+
fmt = color('pending', ' ')
|
1666
1970
|
+ color('pending', ' %d %s pending');
|
1667
1971
|
|
1668
1972
|
console.log(fmt, stats.pending, pluralize(stats.pending));
|
@@ -1846,7 +2150,9 @@ function Dot(runner) {
|
|
1846
2150
|
* Inherit from `Base.prototype`.
|
1847
2151
|
*/
|
1848
2152
|
|
1849
|
-
|
2153
|
+
function F(){};
|
2154
|
+
F.prototype = Base.prototype;
|
2155
|
+
Dot.prototype = new F;
|
1850
2156
|
Dot.prototype.constructor = Dot;
|
1851
2157
|
|
1852
2158
|
}); // module: reporters/dot.js
|
@@ -2024,7 +2330,7 @@ function HTML(runner, root) {
|
|
2024
2330
|
});
|
2025
2331
|
|
2026
2332
|
runner.on('fail', function(test, err){
|
2027
|
-
if ('hook' == test.type
|
2333
|
+
if ('hook' == test.type) runner.emit('test end', test);
|
2028
2334
|
});
|
2029
2335
|
|
2030
2336
|
runner.on('test end', function(test){
|
@@ -2073,7 +2379,7 @@ function HTML(runner, root) {
|
|
2073
2379
|
|
2074
2380
|
on(h2, 'click', function(){
|
2075
2381
|
pre.style.display = 'none' == pre.style.display
|
2076
|
-
? '
|
2382
|
+
? 'block'
|
2077
2383
|
: 'none';
|
2078
2384
|
});
|
2079
2385
|
|
@@ -2578,7 +2884,9 @@ function Landing(runner) {
|
|
2578
2884
|
* Inherit from `Base.prototype`.
|
2579
2885
|
*/
|
2580
2886
|
|
2581
|
-
|
2887
|
+
function F(){};
|
2888
|
+
F.prototype = Base.prototype;
|
2889
|
+
Landing.prototype = new F;
|
2582
2890
|
Landing.prototype.constructor = Landing;
|
2583
2891
|
|
2584
2892
|
}); // module: reporters/landing.js
|
@@ -2647,7 +2955,9 @@ function List(runner) {
|
|
2647
2955
|
* Inherit from `Base.prototype`.
|
2648
2956
|
*/
|
2649
2957
|
|
2650
|
-
|
2958
|
+
function F(){};
|
2959
|
+
F.prototype = Base.prototype;
|
2960
|
+
List.prototype = new F;
|
2651
2961
|
List.prototype.constructor = List;
|
2652
2962
|
|
2653
2963
|
|
@@ -2679,7 +2989,6 @@ function Markdown(runner) {
|
|
2679
2989
|
|
2680
2990
|
var self = this
|
2681
2991
|
, stats = this.stats
|
2682
|
-
, total = runner.total
|
2683
2992
|
, level = 0
|
2684
2993
|
, buf = '';
|
2685
2994
|
|
@@ -2786,7 +3095,9 @@ function Min(runner) {
|
|
2786
3095
|
* Inherit from `Base.prototype`.
|
2787
3096
|
*/
|
2788
3097
|
|
2789
|
-
|
3098
|
+
function F(){};
|
3099
|
+
F.prototype = Base.prototype;
|
3100
|
+
Min.prototype = new F;
|
2790
3101
|
Min.prototype.constructor = Min;
|
2791
3102
|
|
2792
3103
|
}); // module: reporters/min.js
|
@@ -3050,7 +3361,9 @@ function write(string) {
|
|
3050
3361
|
* Inherit from `Base.prototype`.
|
3051
3362
|
*/
|
3052
3363
|
|
3053
|
-
|
3364
|
+
function F(){};
|
3365
|
+
F.prototype = Base.prototype;
|
3366
|
+
NyanCat.prototype = new F;
|
3054
3367
|
NyanCat.prototype.constructor = NyanCat;
|
3055
3368
|
|
3056
3369
|
|
@@ -3142,7 +3455,9 @@ function Progress(runner, options) {
|
|
3142
3455
|
* Inherit from `Base.prototype`.
|
3143
3456
|
*/
|
3144
3457
|
|
3145
|
-
|
3458
|
+
function F(){};
|
3459
|
+
F.prototype = Base.prototype;
|
3460
|
+
Progress.prototype = new F;
|
3146
3461
|
Progress.prototype.constructor = Progress;
|
3147
3462
|
|
3148
3463
|
|
@@ -3235,7 +3550,9 @@ function Spec(runner) {
|
|
3235
3550
|
* Inherit from `Base.prototype`.
|
3236
3551
|
*/
|
3237
3552
|
|
3238
|
-
|
3553
|
+
function F(){};
|
3554
|
+
F.prototype = Base.prototype;
|
3555
|
+
Spec.prototype = new F;
|
3239
3556
|
Spec.prototype.constructor = Spec;
|
3240
3557
|
|
3241
3558
|
|
@@ -3269,7 +3586,9 @@ function TAP(runner) {
|
|
3269
3586
|
|
3270
3587
|
var self = this
|
3271
3588
|
, stats = this.stats
|
3272
|
-
, n = 1
|
3589
|
+
, n = 1
|
3590
|
+
, passes = 0
|
3591
|
+
, failures = 0;
|
3273
3592
|
|
3274
3593
|
runner.on('start', function(){
|
3275
3594
|
var total = runner.grepTotal(runner.suite);
|
@@ -3285,12 +3604,20 @@ function TAP(runner) {
|
|
3285
3604
|
});
|
3286
3605
|
|
3287
3606
|
runner.on('pass', function(test){
|
3607
|
+
passes++;
|
3288
3608
|
console.log('ok %d %s', n, title(test));
|
3289
3609
|
});
|
3290
3610
|
|
3291
3611
|
runner.on('fail', function(test, err){
|
3612
|
+
failures++;
|
3292
3613
|
console.log('not ok %d %s', n, title(test));
|
3293
|
-
console.log(err.stack.replace(/^/gm, ' '));
|
3614
|
+
if (err.stack) console.log(err.stack.replace(/^/gm, ' '));
|
3615
|
+
});
|
3616
|
+
|
3617
|
+
runner.on('end', function(){
|
3618
|
+
console.log('# tests ' + (passes + failures));
|
3619
|
+
console.log('# pass ' + passes);
|
3620
|
+
console.log('# fail ' + failures);
|
3294
3621
|
});
|
3295
3622
|
}
|
3296
3623
|
|
@@ -3444,7 +3771,9 @@ function XUnit(runner) {
|
|
3444
3771
|
* Inherit from `Base.prototype`.
|
3445
3772
|
*/
|
3446
3773
|
|
3447
|
-
|
3774
|
+
function F(){};
|
3775
|
+
F.prototype = Base.prototype;
|
3776
|
+
XUnit.prototype = new F;
|
3448
3777
|
XUnit.prototype.constructor = XUnit;
|
3449
3778
|
|
3450
3779
|
|
@@ -3552,7 +3881,9 @@ function Runnable(title, fn) {
|
|
3552
3881
|
* Inherit from `EventEmitter.prototype`.
|
3553
3882
|
*/
|
3554
3883
|
|
3555
|
-
|
3884
|
+
function F(){};
|
3885
|
+
F.prototype = EventEmitter.prototype;
|
3886
|
+
Runnable.prototype = new F;
|
3556
3887
|
Runnable.prototype.constructor = Runnable;
|
3557
3888
|
|
3558
3889
|
|
@@ -3697,7 +4028,7 @@ Runnable.prototype.run = function(fn){
|
|
3697
4028
|
if (this.async) {
|
3698
4029
|
try {
|
3699
4030
|
this.fn.call(ctx, function(err){
|
3700
|
-
if (toString.call(err) === "[object Error]") return done(err);
|
4031
|
+
if (err instanceof Error || toString.call(err) === "[object Error]") return done(err);
|
3701
4032
|
if (null != err) return done(new Error('done() invoked with non-Error: ' + err));
|
3702
4033
|
done();
|
3703
4034
|
});
|
@@ -3791,7 +4122,9 @@ function Runner(suite) {
|
|
3791
4122
|
* Inherit from `EventEmitter.prototype`.
|
3792
4123
|
*/
|
3793
4124
|
|
3794
|
-
|
4125
|
+
function F(){};
|
4126
|
+
F.prototype = EventEmitter.prototype;
|
4127
|
+
Runner.prototype = new F;
|
3795
4128
|
Runner.prototype.constructor = Runner;
|
3796
4129
|
|
3797
4130
|
|
@@ -3847,7 +4180,7 @@ Runner.prototype.globalProps = function() {
|
|
3847
4180
|
|
3848
4181
|
// non-enumerables
|
3849
4182
|
for (var i = 0; i < globals.length; ++i) {
|
3850
|
-
if (~
|
4183
|
+
if (~utils.indexOf(props, globals[i])) continue;
|
3851
4184
|
props.push(globals[i]);
|
3852
4185
|
}
|
3853
4186
|
|
@@ -3909,9 +4242,11 @@ Runner.prototype.checkGlobals = function(test){
|
|
3909
4242
|
Runner.prototype.fail = function(test, err){
|
3910
4243
|
++this.failures;
|
3911
4244
|
test.state = 'failed';
|
4245
|
+
|
3912
4246
|
if ('string' == typeof err) {
|
3913
4247
|
err = new Error('the string "' + err + '" was thrown, throw an Error :)');
|
3914
4248
|
}
|
4249
|
+
|
3915
4250
|
this.emit('fail', test, err);
|
3916
4251
|
};
|
3917
4252
|
|
@@ -4213,15 +4548,12 @@ Runner.prototype.run = function(fn){
|
|
4213
4548
|
|
4214
4549
|
debug('start');
|
4215
4550
|
|
4216
|
-
// uncaught callback
|
4217
|
-
function uncaught(err) {
|
4218
|
-
self.uncaught(err);
|
4219
|
-
}
|
4220
|
-
|
4221
4551
|
// callback
|
4222
4552
|
this.on('end', function(){
|
4223
4553
|
debug('end');
|
4224
|
-
process.removeListener('uncaughtException',
|
4554
|
+
process.removeListener('uncaughtException', function(err){
|
4555
|
+
self.uncaught(err);
|
4556
|
+
});
|
4225
4557
|
fn(self.failures);
|
4226
4558
|
});
|
4227
4559
|
|
@@ -4233,7 +4565,9 @@ Runner.prototype.run = function(fn){
|
|
4233
4565
|
});
|
4234
4566
|
|
4235
4567
|
// uncaught exception
|
4236
|
-
process.on('uncaughtException',
|
4568
|
+
process.on('uncaughtException', function(err){
|
4569
|
+
self.uncaught(err);
|
4570
|
+
});
|
4237
4571
|
|
4238
4572
|
return this;
|
4239
4573
|
};
|
@@ -4330,7 +4664,9 @@ function Suite(title, ctx) {
|
|
4330
4664
|
* Inherit from `EventEmitter.prototype`.
|
4331
4665
|
*/
|
4332
4666
|
|
4333
|
-
|
4667
|
+
function F(){};
|
4668
|
+
F.prototype = EventEmitter.prototype;
|
4669
|
+
Suite.prototype = new F;
|
4334
4670
|
Suite.prototype.constructor = Suite;
|
4335
4671
|
|
4336
4672
|
|
@@ -4595,7 +4931,9 @@ function Test(title, fn) {
|
|
4595
4931
|
* Inherit from `Runnable.prototype`.
|
4596
4932
|
*/
|
4597
4933
|
|
4598
|
-
|
4934
|
+
function F(){};
|
4935
|
+
F.prototype = Runnable.prototype;
|
4936
|
+
Test.prototype = new F;
|
4599
4937
|
Test.prototype.constructor = Test;
|
4600
4938
|
|
4601
4939
|
|
@@ -4944,7 +5282,9 @@ process.removeListener = function(e){
|
|
4944
5282
|
|
4945
5283
|
process.on = function(e, fn){
|
4946
5284
|
if ('uncaughtException' == e) {
|
4947
|
-
window.onerror =
|
5285
|
+
window.onerror = function(err, url, line){
|
5286
|
+
fn(new Error(err + ' (' + url + ':' + line + ')'));
|
5287
|
+
};
|
4948
5288
|
}
|
4949
5289
|
};
|
4950
5290
|
|