mocha 1.7.3 → 1.8.2
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.
- package/History.md +87 -58
- package/LICENSE +2 -2
- package/Makefile +4 -1
- package/_mocha.js +363 -22
- package/bin/_mocha +9 -11
- package/component.json +16 -0
- package/lib/browser/diff.js +287 -0
- package/lib/mocha.js +16 -1
- package/lib/reporters/html.js +1 -1
- package/lib/reporters/markdown.js +0 -1
- package/lib/reporters/tap.js +12 -2
- package/lib/runnable.js +1 -1
- package/lib/runner.js +11 -6
- package/lib/template.html +1 -0
- package/mocha.css +18 -4
- package/mocha.js +367 -25
- package/package.json +37 -23
- package/test.js +9 -33
package/mocha.js
CHANGED
|
@@ -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
|
|
|
@@ -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
|
|
@@ -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
|
});
|
|
@@ -3735,7 +4066,8 @@ var EventEmitter = require('browser/events').EventEmitter
|
|
|
3735
4066
|
, utils = require('./utils')
|
|
3736
4067
|
, filter = utils.filter
|
|
3737
4068
|
, keys = utils.keys
|
|
3738
|
-
, noop = function(){}
|
|
4069
|
+
, noop = function(){}
|
|
4070
|
+
, immediately = global.setImmediate || process.nextTick;
|
|
3739
4071
|
|
|
3740
4072
|
/**
|
|
3741
4073
|
* Non-enumerable globals.
|
|
@@ -3791,7 +4123,9 @@ function Runner(suite) {
|
|
|
3791
4123
|
* Inherit from `EventEmitter.prototype`.
|
|
3792
4124
|
*/
|
|
3793
4125
|
|
|
3794
|
-
|
|
4126
|
+
function F(){};
|
|
4127
|
+
F.prototype = EventEmitter.prototype;
|
|
4128
|
+
Runner.prototype = new F;
|
|
3795
4129
|
Runner.prototype.constructor = Runner;
|
|
3796
4130
|
|
|
3797
4131
|
|
|
@@ -3847,7 +4181,7 @@ Runner.prototype.globalProps = function() {
|
|
|
3847
4181
|
|
|
3848
4182
|
// non-enumerables
|
|
3849
4183
|
for (var i = 0; i < globals.length; ++i) {
|
|
3850
|
-
if (~
|
|
4184
|
+
if (~utils.indexOf(props, globals[i])) continue;
|
|
3851
4185
|
props.push(globals[i]);
|
|
3852
4186
|
}
|
|
3853
4187
|
|
|
@@ -3913,7 +4247,7 @@ Runner.prototype.fail = function(test, err){
|
|
|
3913
4247
|
if ('string' == typeof err) {
|
|
3914
4248
|
err = new Error('the string "' + err + '" was thrown, throw an Error :)');
|
|
3915
4249
|
}
|
|
3916
|
-
|
|
4250
|
+
|
|
3917
4251
|
this.emit('fail', test, err);
|
|
3918
4252
|
};
|
|
3919
4253
|
|
|
@@ -3970,7 +4304,7 @@ Runner.prototype.hook = function(name, fn){
|
|
|
3970
4304
|
});
|
|
3971
4305
|
}
|
|
3972
4306
|
|
|
3973
|
-
|
|
4307
|
+
immediately(function(){
|
|
3974
4308
|
next(0);
|
|
3975
4309
|
});
|
|
3976
4310
|
};
|
|
@@ -4213,12 +4547,16 @@ Runner.prototype.run = function(fn){
|
|
|
4213
4547
|
var self = this
|
|
4214
4548
|
, fn = fn || function(){};
|
|
4215
4549
|
|
|
4550
|
+
function uncaught(err){
|
|
4551
|
+
self.uncaught(err);
|
|
4552
|
+
}
|
|
4553
|
+
|
|
4216
4554
|
debug('start');
|
|
4217
4555
|
|
|
4218
4556
|
// callback
|
|
4219
4557
|
this.on('end', function(){
|
|
4220
4558
|
debug('end');
|
|
4221
|
-
process.removeListener('uncaughtException',
|
|
4559
|
+
process.removeListener('uncaughtException', uncaught);
|
|
4222
4560
|
fn(self.failures);
|
|
4223
4561
|
});
|
|
4224
4562
|
|
|
@@ -4230,7 +4568,7 @@ Runner.prototype.run = function(fn){
|
|
|
4230
4568
|
});
|
|
4231
4569
|
|
|
4232
4570
|
// uncaught exception
|
|
4233
|
-
process.on('uncaughtException',
|
|
4571
|
+
process.on('uncaughtException', uncaught);
|
|
4234
4572
|
|
|
4235
4573
|
return this;
|
|
4236
4574
|
};
|
|
@@ -4327,7 +4665,9 @@ function Suite(title, ctx) {
|
|
|
4327
4665
|
* Inherit from `EventEmitter.prototype`.
|
|
4328
4666
|
*/
|
|
4329
4667
|
|
|
4330
|
-
|
|
4668
|
+
function F(){};
|
|
4669
|
+
F.prototype = EventEmitter.prototype;
|
|
4670
|
+
Suite.prototype = new F;
|
|
4331
4671
|
Suite.prototype.constructor = Suite;
|
|
4332
4672
|
|
|
4333
4673
|
|
|
@@ -4592,7 +4932,9 @@ function Test(title, fn) {
|
|
|
4592
4932
|
* Inherit from `Runnable.prototype`.
|
|
4593
4933
|
*/
|
|
4594
4934
|
|
|
4595
|
-
|
|
4935
|
+
function F(){};
|
|
4936
|
+
F.prototype = Runnable.prototype;
|
|
4937
|
+
Test.prototype = new F;
|
|
4596
4938
|
Test.prototype.constructor = Test;
|
|
4597
4939
|
|
|
4598
4940
|
|
package/package.json
CHANGED
|
@@ -1,27 +1,41 @@
|
|
|
1
1
|
{
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
,
|
|
2
|
+
"name": "mocha",
|
|
3
|
+
"version": "1.8.2",
|
|
4
|
+
"description": "simple, flexible, fun test framework",
|
|
5
|
+
"keywords": [
|
|
6
|
+
"mocha",
|
|
7
|
+
"test",
|
|
8
|
+
"bdd",
|
|
9
|
+
"tdd",
|
|
10
|
+
"tap"
|
|
11
|
+
],
|
|
12
|
+
"author": "TJ Holowaychuk <tj@vision-media.ca>",
|
|
13
|
+
"repository": {
|
|
14
|
+
"type": "git",
|
|
15
|
+
"url": "git://github.com/visionmedia/mocha.git"
|
|
16
|
+
},
|
|
17
|
+
"main": "./index",
|
|
18
|
+
"bin": {
|
|
19
|
+
"mocha": "./bin/mocha",
|
|
20
|
+
"_mocha": "./bin/_mocha"
|
|
21
|
+
},
|
|
22
|
+
"engines": {
|
|
23
|
+
"node": ">= 0.4.x"
|
|
24
|
+
},
|
|
25
|
+
"scripts": {
|
|
12
26
|
"test": "make test-all"
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
27
|
+
},
|
|
28
|
+
"dependencies": {
|
|
29
|
+
"commander": "0.6.1",
|
|
30
|
+
"growl": "1.7.x",
|
|
31
|
+
"jade": "0.26.3",
|
|
32
|
+
"diff": "1.0.2",
|
|
33
|
+
"debug": "*",
|
|
34
|
+
"mkdirp": "0.3.3",
|
|
35
|
+
"ms": "0.3.0"
|
|
36
|
+
},
|
|
37
|
+
"devDependencies": {
|
|
38
|
+
"should": "*",
|
|
39
|
+
"coffee-script": "1.2"
|
|
26
40
|
}
|
|
27
41
|
}
|
package/test.js
CHANGED
|
@@ -1,38 +1,14 @@
|
|
|
1
|
-
//
|
|
2
|
-
// describe('something', function(){
|
|
3
|
-
// it('should work', function(){
|
|
4
|
-
// 'foo bar'.should.equal('bar');
|
|
5
|
-
// })
|
|
6
|
-
// })
|
|
7
|
-
//
|
|
8
|
-
// describe('something', function(){
|
|
9
|
-
// it('should work', function(){
|
|
10
|
-
// 'foo\nbar\nbaz\nraz\r\n jaz\nsomething\nelse'.should.equal('foo\nbar\nbaz\nraz\r\njaz\nsmething\nelse');
|
|
11
|
-
// })
|
|
12
|
-
// })
|
|
13
1
|
|
|
14
|
-
describe('
|
|
15
|
-
|
|
16
|
-
|
|
2
|
+
describe('somethinf', function(){
|
|
3
|
+
it('should fail', function(){
|
|
4
|
+
test()
|
|
17
5
|
})
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
it('should foo', function(){
|
|
22
|
-
|
|
23
|
-
})
|
|
24
|
-
|
|
25
|
-
it('should bar', function(){
|
|
26
|
-
|
|
27
|
-
})
|
|
28
|
-
})
|
|
29
|
-
})
|
|
30
|
-
|
|
31
|
-
it('should foo', function(){
|
|
32
|
-
|
|
6
|
+
|
|
7
|
+
it('should pass', function(){
|
|
8
|
+
|
|
33
9
|
})
|
|
34
10
|
|
|
35
|
-
it('should
|
|
36
|
-
|
|
11
|
+
it('should pass again', function(){
|
|
12
|
+
|
|
37
13
|
})
|
|
38
|
-
})
|
|
14
|
+
})
|