spell 0.3.0 → 0.8.1

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 (54) hide show
  1. package/README.md +38 -145
  2. package/package.json +24 -21
  3. package/.npmignore +0 -4
  4. package/.travis.yml +0 -6
  5. package/LICENSE +0 -14
  6. package/spell.js +0 -347
  7. package/test/css/mocha.css +0 -110
  8. package/test/index.html +0 -34
  9. package/test/lib/JSONStream/.npmignore +0 -3
  10. package/test/lib/JSONStream/bench.js +0 -35
  11. package/test/lib/JSONStream/examples/all_docs.js +0 -13
  12. package/test/lib/JSONStream/index.js +0 -118
  13. package/test/lib/JSONStream/package.json +0 -13
  14. package/test/lib/JSONStream/readme.markdown +0 -120
  15. package/test/lib/JSONStream/test/fixtures/all_docs_include.json +0 -4245
  16. package/test/lib/JSONStream/test/fixtures/all_npm.json +0 -4030
  17. package/test/lib/JSONStream/test/parsejson.js +0 -25
  18. package/test/lib/JSONStream/test/stringify.js +0 -41
  19. package/test/lib/JSONStream/test/test.js +0 -35
  20. package/test/lib/JSONStream/test/test2.js +0 -29
  21. package/test/lib/JSONStream/test/two-ways.js +0 -41
  22. package/test/lib/jquery-1.7.1.min.js +0 -4
  23. package/test/lib/json2.js +0 -487
  24. package/test/lib/mocha-0.3.6.js +0 -2672
  25. package/test/lib/request/LICENSE +0 -55
  26. package/test/lib/request/README.md +0 -285
  27. package/test/lib/request/main.js +0 -618
  28. package/test/lib/request/mimetypes.js +0 -146
  29. package/test/lib/request/oauth.js +0 -34
  30. package/test/lib/request/package.json +0 -15
  31. package/test/lib/request/tests/googledoodle.png +0 -0
  32. package/test/lib/request/tests/run.sh +0 -6
  33. package/test/lib/request/tests/server.js +0 -57
  34. package/test/lib/request/tests/test-body.js +0 -90
  35. package/test/lib/request/tests/test-cookie.js +0 -29
  36. package/test/lib/request/tests/test-cookiejar.js +0 -90
  37. package/test/lib/request/tests/test-errors.js +0 -30
  38. package/test/lib/request/tests/test-oauth.js +0 -109
  39. package/test/lib/request/tests/test-pipes.js +0 -167
  40. package/test/lib/request/tests/test-proxy.js +0 -39
  41. package/test/lib/request/tests/test-timeout.js +0 -87
  42. package/test/lib/request/uuid.js +0 -19
  43. package/test/lib/request/vendor/cookie/index.js +0 -55
  44. package/test/lib/request/vendor/cookie/jar.js +0 -72
  45. package/test/perf.js +0 -44
  46. package/test/resources/big.js +0 -9
  47. package/test/resources/big.json +0 -29159
  48. package/test/resources/big.txt +0 -128457
  49. package/test/resources/big_browser.js +0 -29159
  50. package/test/resources/npm.js +0 -26
  51. package/test/resources/npm.json +0 -84701
  52. package/test/resources/perf1.js +0 -144
  53. package/test/resources/perf2.js +0 -366
  54. package/test/spell.js +0 -295
@@ -1,2672 +0,0 @@
1
- ;(function(){
2
-
3
-
4
- // CommonJS require()
5
-
6
- function require(p){
7
- var path = require.resolve(p)
8
- , mod = require.modules[path];
9
- if (!mod) throw new Error('failed to require "' + p + '"');
10
- if (!mod.exports) {
11
- mod.exports = {};
12
- mod.call(mod.exports, mod, mod.exports, require.relative(path));
13
- }
14
- return mod.exports;
15
- }
16
-
17
- require.modules = {};
18
-
19
- require.resolve = function (path){
20
- var orig = path
21
- , reg = path + '.js'
22
- , index = path + '/index.js';
23
- return require.modules[reg] && reg
24
- || require.modules[index] && index
25
- || orig;
26
- };
27
-
28
- require.register = function (path, fn){
29
- require.modules[path] = fn;
30
- };
31
-
32
- require.relative = function (parent) {
33
- return function(p){
34
- if ('.' != p[0]) return require(p);
35
-
36
- var path = parent.split('/')
37
- , segs = p.split('/');
38
- path.pop();
39
-
40
- for (var i = 0; i < segs.length; i++) {
41
- var seg = segs[i];
42
- if ('..' == seg) path.pop();
43
- else if ('.' != seg) path.push(seg);
44
- }
45
-
46
- return require(path.join('/'));
47
- };
48
- };
49
-
50
-
51
- require.register("browser/debug.js", function(module, exports, require){
52
-
53
- module.exports = function(type){
54
- return function(){
55
-
56
- }
57
- };
58
- }); // module: browser/debug.js
59
-
60
- require.register("browser/events.js", function(module, exports, require){
61
-
62
- /**
63
- * Module exports.
64
- */
65
-
66
- exports.EventEmitter = EventEmitter;
67
-
68
- /**
69
- * Check if `obj` is an array.
70
- */
71
-
72
- function isArray(obj) {
73
- return '[object Array]' == {}.toString.call(obj);
74
- }
75
-
76
- /**
77
- * Event emitter constructor.
78
- *
79
- * @api public.
80
- */
81
-
82
- function EventEmitter(){};
83
-
84
- /**
85
- * Adds a listener.
86
- *
87
- * @api public
88
- */
89
-
90
- EventEmitter.prototype.on = function (name, fn) {
91
- if (!this.$events) {
92
- this.$events = {};
93
- }
94
-
95
- if (!this.$events[name]) {
96
- this.$events[name] = fn;
97
- } else if (isArray(this.$events[name])) {
98
- this.$events[name].push(fn);
99
- } else {
100
- this.$events[name] = [this.$events[name], fn];
101
- }
102
-
103
- return this;
104
- };
105
-
106
- EventEmitter.prototype.addListener = EventEmitter.prototype.on;
107
-
108
- /**
109
- * Adds a volatile listener.
110
- *
111
- * @api public
112
- */
113
-
114
- EventEmitter.prototype.once = function (name, fn) {
115
- var self = this;
116
-
117
- function on () {
118
- self.removeListener(name, on);
119
- fn.apply(this, arguments);
120
- };
121
-
122
- on.listener = fn;
123
- this.on(name, on);
124
-
125
- return this;
126
- };
127
-
128
- /**
129
- * Removes a listener.
130
- *
131
- * @api public
132
- */
133
-
134
- EventEmitter.prototype.removeListener = function (name, fn) {
135
- if (this.$events && this.$events[name]) {
136
- var list = this.$events[name];
137
-
138
- if (isArray(list)) {
139
- var pos = -1;
140
-
141
- for (var i = 0, l = list.length; i < l; i++) {
142
- if (list[i] === fn || (list[i].listener && list[i].listener === fn)) {
143
- pos = i;
144
- break;
145
- }
146
- }
147
-
148
- if (pos < 0) {
149
- return this;
150
- }
151
-
152
- list.splice(pos, 1);
153
-
154
- if (!list.length) {
155
- delete this.$events[name];
156
- }
157
- } else if (list === fn || (list.listener && list.listener === fn)) {
158
- delete this.$events[name];
159
- }
160
- }
161
-
162
- return this;
163
- };
164
-
165
- /**
166
- * Removes all listeners for an event.
167
- *
168
- * @api public
169
- */
170
-
171
- EventEmitter.prototype.removeAllListeners = function (name) {
172
- if (name === undefined) {
173
- this.$events = {};
174
- return this;
175
- }
176
-
177
- if (this.$events && this.$events[name]) {
178
- this.$events[name] = null;
179
- }
180
-
181
- return this;
182
- };
183
-
184
- /**
185
- * Gets all listeners for a certain event.
186
- *
187
- * @api publci
188
- */
189
-
190
- EventEmitter.prototype.listeners = function (name) {
191
- if (!this.$events) {
192
- this.$events = {};
193
- }
194
-
195
- if (!this.$events[name]) {
196
- this.$events[name] = [];
197
- }
198
-
199
- if (!isArray(this.$events[name])) {
200
- this.$events[name] = [this.$events[name]];
201
- }
202
-
203
- return this.$events[name];
204
- };
205
-
206
- /**
207
- * Emits an event.
208
- *
209
- * @api public
210
- */
211
-
212
- EventEmitter.prototype.emit = function (name) {
213
- if (!this.$events) {
214
- return false;
215
- }
216
-
217
- var handler = this.$events[name];
218
-
219
- if (!handler) {
220
- return false;
221
- }
222
-
223
- var args = [].slice.call(arguments, 1);
224
-
225
- if ('function' == typeof handler) {
226
- handler.apply(this, args);
227
- } else if (isArray(handler)) {
228
- var listeners = handler.slice();
229
-
230
- for (var i = 0, l = listeners.length; i < l; i++) {
231
- listeners[i].apply(this, args);
232
- }
233
- } else {
234
- return false;
235
- }
236
-
237
- return true;
238
- };
239
- }); // module: browser/events.js
240
-
241
- require.register("browser/fs.js", function(module, exports, require){
242
-
243
- }); // module: browser/fs.js
244
-
245
- require.register("browser/progress.js", function(module, exports, require){
246
-
247
- /**
248
- * Expose `Progress`.
249
- */
250
-
251
- module.exports = Progress;
252
-
253
- /**
254
- * Initialize a new `Progress` indicator.
255
- */
256
-
257
- function Progress() {
258
- this.percent = 0;
259
- this.size(0);
260
- this.fontSize(12);
261
- this.font('helvetica, arial, sans-serif');
262
- }
263
-
264
- /**
265
- * Set progress size to `n`.
266
- *
267
- * @param {Number} n
268
- * @return {Progress} for chaining
269
- * @api public
270
- */
271
-
272
- Progress.prototype.size = function(n){
273
- this._size = n;
274
- return this;
275
- };
276
-
277
- /**
278
- * Set text to `str`.
279
- *
280
- * @param {String} str
281
- * @return {Progress} for chaining
282
- * @api public
283
- */
284
-
285
- Progress.prototype.text = function(str){
286
- this._text = str;
287
- return this;
288
- };
289
-
290
- /**
291
- * Set font size to `n`.
292
- *
293
- * @param {Number} n
294
- * @return {Progress} for chaining
295
- * @api public
296
- */
297
-
298
- Progress.prototype.fontSize = function(n){
299
- this._fontSize = n;
300
- return this;
301
- };
302
-
303
- /**
304
- * Set font `family`.
305
- *
306
- * @param {String} family
307
- * @return {Progress} for chaining
308
- */
309
-
310
- Progress.prototype.font = function(family){
311
- this._font = family;
312
- return this;
313
- };
314
-
315
- /**
316
- * Update percentage to `n`.
317
- *
318
- * @param {Number} n
319
- * @return {Progress} for chaining
320
- */
321
-
322
- Progress.prototype.update = function(n){
323
- this.percent = n;
324
- return this;
325
- };
326
-
327
- /**
328
- * Draw on `ctx`.
329
- *
330
- * @param {CanvasRenderingContext2d} ctx
331
- * @return {Progress} for chaining
332
- */
333
-
334
- Progress.prototype.draw = function(ctx){
335
- var percent = Math.min(this.percent, 100)
336
- , size = this._size
337
- , half = size / 2
338
- , x = half
339
- , y = half
340
- , rad = half - 1
341
- , fontSize = this._fontSize;
342
-
343
- ctx.font = fontSize + 'px ' + this._font;
344
-
345
- var angle = Math.PI * 2 * (percent / 100);
346
- ctx.clearRect(0, 0, size, size);
347
-
348
- // outer circle
349
- ctx.strokeStyle = '#9f9f9f';
350
- ctx.beginPath();
351
- ctx.arc(x, y, rad, 0, angle, false);
352
- ctx.stroke();
353
-
354
- // inner circle
355
- ctx.strokeStyle = '#eee';
356
- ctx.beginPath();
357
- ctx.arc(x, y, rad - 1, 0, angle, true);
358
- ctx.stroke();
359
-
360
- // text
361
- var text = this._text || (percent | 0) + '%'
362
- , w = ctx.measureText(text).width;
363
-
364
- ctx.fillText(
365
- text
366
- , x - w / 2 + 1
367
- , y + fontSize / 2 - 1);
368
-
369
- return this;
370
- };
371
-
372
- }); // module: browser/progress.js
373
-
374
- require.register("browser/tty.js", function(module, exports, require){
375
-
376
- exports.isatty = function(){
377
- return true;
378
- };
379
-
380
- exports.getWindowSize = function(){
381
- return [window.innerHeight, window.innerWidth];
382
- };
383
- }); // module: browser/tty.js
384
-
385
- require.register("hook.js", function(module, exports, require){
386
-
387
- /**
388
- * Module dependencies.
389
- */
390
-
391
- var Runnable = require('./runnable');
392
-
393
- /**
394
- * Expose `Hook`.
395
- */
396
-
397
- module.exports = Hook;
398
-
399
- /**
400
- * Initialize a new `Hook` with the given `title` and callback `fn`.
401
- *
402
- * @param {String} title
403
- * @param {Function} fn
404
- * @api private
405
- */
406
-
407
- function Hook(title, fn) {
408
- Runnable.call(this, title, fn);
409
- }
410
-
411
- /**
412
- * Inherit from `Runnable.prototype`.
413
- */
414
-
415
- Hook.prototype = new Runnable;
416
- Hook.prototype.constructor = Hook;
417
-
418
-
419
- }); // module: hook.js
420
-
421
- require.register("interfaces/bdd.js", function(module, exports, require){
422
-
423
- /**
424
- * Module dependencies.
425
- */
426
-
427
- var Suite = require('../suite')
428
- , Test = require('../test');
429
-
430
- /**
431
- * BDD-style interface:
432
- *
433
- * describe('Array', function(){
434
- * describe('#indexOf()', function(){
435
- * it('should return -1 when not present', function(){
436
- *
437
- * });
438
- *
439
- * it('should return the index when present', function(){
440
- *
441
- * });
442
- * });
443
- * });
444
- *
445
- */
446
-
447
- module.exports = function(suite){
448
- var suites = [suite];
449
-
450
- suite.on('pre-require', function(context){
451
-
452
- /**
453
- * Execute before running tests.
454
- */
455
-
456
- context.before = function(fn){
457
- suites[0].beforeAll(fn);
458
- };
459
-
460
- /**
461
- * Execute after running tests.
462
- */
463
-
464
- context.after = function(fn){
465
- suites[0].afterAll(fn);
466
- };
467
-
468
- /**
469
- * Execute before each test case.
470
- */
471
-
472
- context.beforeEach = function(fn){
473
- suites[0].beforeEach(fn);
474
- };
475
-
476
- /**
477
- * Execute after each test case.
478
- */
479
-
480
- context.afterEach = function(fn){
481
- suites[0].afterEach(fn);
482
- };
483
-
484
- /**
485
- * Describe a "suite" with the given `title`
486
- * and callback `fn` containing nested suites
487
- * and/or tests.
488
- */
489
-
490
- context.describe = function(title, fn){
491
- var suite = Suite.create(suites[0], title);
492
- suites.unshift(suite);
493
- fn();
494
- suites.shift();
495
- };
496
-
497
- /**
498
- * Describe a specification or test-case
499
- * with the given `title` and callback `fn`
500
- * acting as a thunk.
501
- */
502
-
503
- context.it = function(title, fn){
504
- suites[0].addTest(new Test(title, fn));
505
- };
506
- });
507
- };
508
-
509
- }); // module: interfaces/bdd.js
510
-
511
- require.register("interfaces/exports.js", function(module, exports, require){
512
-
513
- /**
514
- * Module dependencies.
515
- */
516
-
517
- var Suite = require('../suite')
518
- , Test = require('../test');
519
-
520
- /**
521
- * TDD-style interface:
522
- *
523
- * exports.Array = {
524
- * '#indexOf()': {
525
- * 'should return -1 when the value is not present': function(){
526
- *
527
- * },
528
- *
529
- * 'should return the correct index when the value is present': function(){
530
- *
531
- * }
532
- * }
533
- * };
534
- *
535
- */
536
-
537
- module.exports = function(suite){
538
- var suites = [suite];
539
-
540
- suite.on('require', visit);
541
-
542
- function visit(obj) {
543
- var suite;
544
- for (var key in obj) {
545
- if ('function' == typeof obj[key]) {
546
- var fn = obj[key];
547
- switch (key) {
548
- case 'before':
549
- suites[0].beforeAll(fn);
550
- break;
551
- case 'after':
552
- suites[0].afterAll(fn);
553
- break;
554
- case 'beforeEach':
555
- suites[0].beforeEach(fn);
556
- break;
557
- case 'afterEach':
558
- suites[0].afterEach(fn);
559
- break;
560
- default:
561
- suites[0].addTest(new Test(key, fn));
562
- }
563
- } else {
564
- var suite = Suite.create(suites[0], key);
565
- suites.unshift(suite);
566
- visit(obj[key]);
567
- suites.shift();
568
- }
569
- }
570
- }
571
- };
572
- }); // module: interfaces/exports.js
573
-
574
- require.register("interfaces/index.js", function(module, exports, require){
575
-
576
- exports.bdd = require('./bdd');
577
- exports.tdd = require('./tdd');
578
- exports.exports = require('./exports');
579
- }); // module: interfaces/index.js
580
-
581
- require.register("interfaces/tdd.js", function(module, exports, require){
582
-
583
- /**
584
- * Module dependencies.
585
- */
586
-
587
- var Suite = require('../suite')
588
- , Test = require('../test');
589
-
590
- /**
591
- * TDD-style interface:
592
- *
593
- * suite('Array', function(){
594
- * suite('#indexOf()', function(){
595
- * suiteSetup(function(){
596
- *
597
- * });
598
- *
599
- * test('should return -1 when not present', function(){
600
- *
601
- * });
602
- *
603
- * test('should return the index when present', function(){
604
- *
605
- * });
606
- *
607
- * suiteTeardown(function(){
608
- *
609
- * });
610
- * });
611
- * });
612
- *
613
- */
614
-
615
- module.exports = function(suite){
616
- var suites = [suite];
617
-
618
- suite.on('pre-require', function(context){
619
-
620
- /**
621
- * Execute before each test case.
622
- */
623
-
624
- context.setup = function(fn){
625
- suites[0].beforeEach(fn);
626
- };
627
-
628
- /**
629
- * Execute after each test case.
630
- */
631
-
632
- context.teardown = function(fn){
633
- suites[0].afterEach(fn);
634
- };
635
-
636
- /**
637
- * Execute before the suite.
638
- */
639
-
640
- context.suiteSetup = function(fn){
641
- suites[0].beforeAll(fn);
642
- };
643
-
644
- /**
645
- * Execute after the suite.
646
- */
647
-
648
- context.suiteTeardown = function(fn){
649
- suites[0].afterAll(fn);
650
- };
651
-
652
- /**
653
- * Describe a "suite" with the given `title`
654
- * and callback `fn` containing nested suites
655
- * and/or tests.
656
- */
657
-
658
- context.suite = function(title, fn){
659
- var suite = Suite.create(suites[0], title);
660
- suites.unshift(suite);
661
- fn();
662
- suites.shift();
663
- };
664
-
665
- /**
666
- * Describe a specification or test-case
667
- * with the given `title` and callback `fn`
668
- * acting as a thunk.
669
- */
670
-
671
- context.test = function(title, fn){
672
- suites[0].addTest(new Test(title, fn));
673
- };
674
- });
675
- };
676
-
677
- }); // module: interfaces/tdd.js
678
-
679
- require.register("mocha.js", function(module, exports, require){
680
-
681
- /*!
682
- * mocha
683
- * Copyright(c) 2011 TJ Holowaychuk <tj@vision-media.ca>
684
- * MIT Licensed
685
- */
686
-
687
- /**
688
- * Library version.
689
- */
690
-
691
- exports.version = '0.3.6';
692
-
693
- exports.interfaces = require('./interfaces');
694
- exports.reporters = require('./reporters');
695
- exports.Runnable = require('./runnable');
696
- exports.Runner = require('./runner');
697
- exports.Suite = require('./suite');
698
- exports.Hook = require('./hook');
699
- exports.Test = require('./test');
700
- exports.watch = require('./watch');
701
- }); // module: mocha.js
702
-
703
- require.register("reporters/base.js", function(module, exports, require){
704
-
705
- /**
706
- * Module dependencies.
707
- */
708
-
709
- var tty = require('browser/tty');
710
-
711
- /**
712
- * Check if both stdio streams are associated with a tty.
713
- */
714
-
715
- var isatty = tty.isatty(1) && tty.isatty(2);
716
-
717
- /**
718
- * Expose `Base`.
719
- */
720
-
721
- exports = module.exports = Base;
722
-
723
- /**
724
- * Enable coloring by default.
725
- */
726
-
727
- exports.useColors = isatty;
728
-
729
- /**
730
- * Default color map.
731
- */
732
-
733
- exports.colors = {
734
- 'pass': 90
735
- , 'fail': 31
736
- , 'bright pass': 92
737
- , 'bright fail': 91
738
- , 'bright yellow': 93
739
- , 'pending': 36
740
- , 'suite': 0
741
- , 'error title': 0
742
- , 'error message': 31
743
- , 'error stack': 90
744
- , 'checkmark': 32
745
- , 'fast': 90
746
- , 'medium': 33
747
- , 'slow': 31
748
- , 'green': 32
749
- , 'light': 90
750
- };
751
-
752
- /**
753
- * Color `str` with the given `type`,
754
- * allowing colors to be disabled,
755
- * as well as user-defined color
756
- * schemes.
757
- *
758
- * @param {String} type
759
- * @param {String} str
760
- * @return {String}
761
- * @api private
762
- */
763
-
764
- var color = exports.color = function(type, str) {
765
- if (!exports.useColors) return str;
766
- return '\033[' + exports.colors[type] + 'm' + str + '\033[0m';
767
- };
768
-
769
- /**
770
- * Expose term window size, with some
771
- * defaults for when stderr is not a tty.
772
- */
773
-
774
- exports.window = {
775
- width: isatty
776
- ? process.stdout.getWindowSize
777
- ? process.stdout.getWindowSize(1)[0]
778
- : tty.getWindowSize()[1]
779
- : 75
780
- };
781
-
782
- /**
783
- * Expose some basic cursor interactions
784
- * that are common among reporters.
785
- */
786
-
787
- exports.cursor = {
788
- hide: function(){
789
- process.stdout.write('\033[?25l');
790
- },
791
-
792
- show: function(){
793
- process.stdout.write('\033[?25h');
794
- }
795
- };
796
-
797
- /**
798
- * A test is considered slow if it
799
- * exceeds the following value in milliseconds.
800
- */
801
-
802
- exports.slow = 75;
803
-
804
- /**
805
- * Outut the given `failures` as a list.
806
- *
807
- * @param {Array} failures
808
- * @api public
809
- */
810
-
811
- exports.list = function(failures){
812
- console.error();
813
- failures.forEach(function(test, i){
814
- // format
815
- var fmt = color('error title', ' %s) %s:\n')
816
- + color('error message', ' %s')
817
- + color('error stack', '\n%s\n');
818
-
819
- // msg
820
- var err = test.err
821
- , stack = err.stack
822
- , message = err.message || ''
823
- , index = stack.indexOf(message) + message.length
824
- , msg = stack.slice(0, index);
825
-
826
- // indent stack trace without msg
827
- stack = stack.slice(index + 1)
828
- .replace(/^/gm, ' ');
829
-
830
- console.error(fmt, i, test.fullTitle(), msg, stack);
831
- });
832
- };
833
-
834
- /**
835
- * Initialize a new `Base` reporter.
836
- *
837
- * All other reporters generally
838
- * inherit from this reporter, providing
839
- * stats such as test duration, number
840
- * of tests passed / failed etc.
841
- *
842
- * @param {Runner} runner
843
- * @api public
844
- */
845
-
846
- function Base(runner) {
847
- var self = this
848
- , stats = this.stats = { suites: 0, tests: 0, passes: 0, failures: 0 }
849
- , failures = this.failures = [];
850
-
851
- if (!runner) return;
852
- this.runner = runner;
853
-
854
- runner.on('start', function(){
855
- stats.start = new Date;
856
- });
857
-
858
- runner.on('suite', function(suite){
859
- stats.suites = stats.suites || 0;
860
- stats.suites++;
861
- });
862
-
863
- runner.on('test end', function(test){
864
- stats.tests = stats.tests || 0;
865
- stats.tests++;
866
- });
867
-
868
- runner.on('pass', function(test){
869
- stats.passes = stats.passes || 0;
870
-
871
- var medium = exports.slow / 2;
872
- test.speed = test.duration > exports.slow
873
- ? 'slow'
874
- : test.duration > medium
875
- ? 'medium'
876
- : 'fast';
877
-
878
- stats.passes++;
879
- });
880
-
881
- runner.on('fail', function(test, err){
882
- stats.failures = stats.failures || 0;
883
- stats.failures++;
884
- test.err = err;
885
- failures.push(test);
886
- });
887
-
888
- runner.on('end', function(){
889
- stats.end = new Date;
890
- stats.duration = new Date - stats.start;
891
- });
892
- }
893
-
894
- /**
895
- * Output common epilogue used by many of
896
- * the bundled reporters.
897
- *
898
- * @api public
899
- */
900
-
901
- Base.prototype.epilogue = function(){
902
- var stats = this.stats
903
- , fmt;
904
-
905
- console.log();
906
-
907
- // failure
908
- if (stats.failures) {
909
- fmt = color('bright fail', ' ✖')
910
- + color('fail', ' %d of %d tests failed')
911
- + color('light', ':')
912
-
913
- console.error(fmt, stats.failures, this.runner.total);
914
- Base.list(this.failures);
915
- console.error();
916
- return;
917
- }
918
-
919
- // pass
920
- fmt = color('bright pass', ' ✔')
921
- + color('green', ' %d tests complete')
922
- + color('light', ' (%dms)');
923
-
924
- console.log(fmt, stats.tests || 0, stats.duration);
925
- console.log();
926
- };
927
-
928
- }); // module: reporters/base.js
929
-
930
- require.register("reporters/doc.js", function(module, exports, require){
931
-
932
- /**
933
- * Module dependencies.
934
- */
935
-
936
- var Base = require('./base')
937
- , utils = require('../utils');
938
-
939
- /**
940
- * Expose `Doc`.
941
- */
942
-
943
- exports = module.exports = Doc;
944
-
945
- /**
946
- * Initialize a new `Doc` reporter.
947
- *
948
- * @param {Runner} runner
949
- * @api public
950
- */
951
-
952
- function Doc(runner) {
953
- Base.call(this, runner);
954
-
955
- var self = this
956
- , stats = this.stats
957
- , total = runner.total
958
- , indents = 2;
959
-
960
- function indent() {
961
- return Array(indents).join(' ');
962
- }
963
-
964
- runner.on('suite', function(suite){
965
- if (suite.root) return;
966
- ++indents;
967
- console.log('%s<section class="suite">', indent());
968
- ++indents;
969
- console.log('%s<h1>%s</h1>', indent(), suite.title);
970
- console.log('%s<dl>', indent());
971
- });
972
-
973
- runner.on('suite end', function(suite){
974
- if (suite.root) return;
975
- console.log('%s</dl>', indent());
976
- --indents;
977
- console.log('%s</section>', indent());
978
- --indents;
979
- });
980
-
981
- runner.on('pass', function(test){
982
- console.log('%s <dt>%s</dt>', indent(), test.title);
983
- var code = utils.escape(clean(test.fn.toString()));
984
- console.log('%s <dd><pre><code>%s</code></pre></dd>', indent(), code);
985
- });
986
- }
987
-
988
- /**
989
- * Strip the function definition from `str`,
990
- * and re-indent for pre whitespace.
991
- */
992
-
993
- function clean(str) {
994
- str = str
995
- .replace(/^function *\(.*\) *{/, '')
996
- .replace(/\s+\}$/, '');
997
-
998
- var spaces = str.match(/^\n?( *)/)[1].length
999
- , re = new RegExp('^ {' + spaces + '}', 'gm');
1000
-
1001
- str = str.replace(re, '');
1002
-
1003
- return str;
1004
- }
1005
- }); // module: reporters/doc.js
1006
-
1007
- require.register("reporters/dot.js", function(module, exports, require){
1008
-
1009
- /**
1010
- * Module dependencies.
1011
- */
1012
-
1013
- var Base = require('./base')
1014
- , color = Base.color;
1015
-
1016
- /**
1017
- * Expose `Dot`.
1018
- */
1019
-
1020
- exports = module.exports = Dot;
1021
-
1022
- /**
1023
- * Initialize a new `Dot` matrix test reporter.
1024
- *
1025
- * @param {Runner} runner
1026
- * @api public
1027
- */
1028
-
1029
- function Dot(runner) {
1030
- Base.call(this, runner);
1031
-
1032
- var self = this
1033
- , stats = this.stats
1034
- , width = Base.window.width * .75 | 0
1035
- , n = 0;
1036
-
1037
- runner.on('start', function(){
1038
- process.stdout.write('\n ');
1039
- });
1040
-
1041
- runner.on('pending', function(test){
1042
- process.stdout.write(color('pending', '.'));
1043
- });
1044
-
1045
- runner.on('pass', function(test){
1046
- if (++n % width == 0) process.stdout.write('\n ');
1047
- if ('slow' == test.speed) {
1048
- process.stdout.write(color('bright yellow', '.'));
1049
- } else {
1050
- process.stdout.write(color(test.speed, '.'));
1051
- }
1052
- });
1053
-
1054
- runner.on('fail', function(test, err){
1055
- if (++n % width == 0) process.stdout.write('\n ');
1056
- process.stdout.write(color('fail', '.'));
1057
- });
1058
-
1059
- runner.on('end', function(){
1060
- console.log();
1061
- self.epilogue();
1062
- });
1063
- }
1064
-
1065
- /**
1066
- * Inherit from `Base.prototype`.
1067
- */
1068
-
1069
- Dot.prototype = new Base;
1070
- Dot.prototype.constructor = Dot;
1071
-
1072
- }); // module: reporters/dot.js
1073
-
1074
- require.register("reporters/html.js", function(module, exports, require){
1075
-
1076
- /**
1077
- * Module dependencies.
1078
- */
1079
-
1080
- var Base = require('./base')
1081
- , utils = require('../utils')
1082
- , Progress = require('../browser/progress');
1083
-
1084
- /**
1085
- * Expose `Doc`.
1086
- */
1087
-
1088
- exports = module.exports = HTML;
1089
-
1090
- /**
1091
- * Stats template.
1092
- */
1093
-
1094
- var statsTemplate = '<ul id="stats">'
1095
- + '<li class="progress"><canvas width="50" height="50"></canvas></li>'
1096
- + '<li class="passes">passes: <em>0</em></li>'
1097
- + '<li class="failures">failures: <em>0</em></li>'
1098
- + '<li class="duration">duration: <em>0</em>s</li>'
1099
- + '</ul>';
1100
-
1101
- /**
1102
- * Initialize a new `Doc` reporter.
1103
- *
1104
- * @param {Runner} runner
1105
- * @api public
1106
- */
1107
-
1108
- function HTML(runner) {
1109
- Base.call(this, runner);
1110
-
1111
- // TODO: clean up
1112
-
1113
- var self = this
1114
- , stats = this.stats
1115
- , total = runner.total
1116
- , root = $('#mocha')
1117
- , stack = [root]
1118
- , stat = $(statsTemplate).appendTo(root)
1119
- , canvas = stat.find('canvas').get(0)
1120
- , ctx = canvas.getContext('2d')
1121
- , progress = new Progress;
1122
-
1123
- if (!root.length) return error('#mocha div missing, add it to your document');
1124
- progress.size(50);
1125
-
1126
- runner.on('suite', function(suite){
1127
- if (suite.root) return;
1128
-
1129
- // suite
1130
- var el = $('<div class="suite"><h1>' + suite.title + '</h1></div>');
1131
-
1132
- // container
1133
- stack[0].append(el);
1134
- stack.unshift($('<div>'));
1135
- el.append(stack[0]);
1136
- });
1137
-
1138
- runner.on('suite end', function(suite){
1139
- if (suite.root) return;
1140
- stack.shift();
1141
- });
1142
-
1143
- runner.on('test end', function(test){
1144
- // TODO: add to stats
1145
- var percent = stats.tests / total * 100 | 0;
1146
-
1147
- // update progress bar
1148
- progress.update(percent).draw(ctx);
1149
-
1150
- // update stats
1151
- var ms = new Date - stats.start;
1152
- stat.find('.passes em').text(stats.passes);
1153
- stat.find('.failures em').text(stats.failures);
1154
- stat.find('.duration em').text((ms / 1000).toFixed(2));
1155
-
1156
- // test
1157
- if (test.passed) {
1158
- var el = $('<div class="test pass"><h2>' + test.title + '</h2></div>')
1159
- } else if (test.pending) {
1160
- var el = $('<div class="test pass pending"><h2>' + test.title + '</h2></div>')
1161
- } else {
1162
- var el = $('<div class="test fail"><h2>' + test.title + '</h2></div>');
1163
- var str = test.err.stack || test.err;
1164
- var err = $('<pre class="error">' + str + '</pre>');
1165
- el.append(err);
1166
- }
1167
-
1168
- // toggle code
1169
- el.find('h2').toggle(function(){
1170
- pre.slideDown('fast');
1171
- }, function(){
1172
- pre.slideUp('fast');
1173
- });
1174
-
1175
- // code
1176
- // TODO: defer
1177
- if (!test.pending) {
1178
- var code = utils.escape(clean(test.fn.toString()));
1179
- var pre = $('<pre><code>' + code + '</code></pre>');
1180
- pre.appendTo(el).hide();
1181
- }
1182
- stack[0].append(el);
1183
- });
1184
- }
1185
-
1186
- function error(msg) {
1187
- $('<div id="error">' + msg + '</div>').appendTo('body');
1188
- }
1189
-
1190
- /**
1191
- * Strip the function definition from `str`,
1192
- * and re-indent for pre whitespace.
1193
- */
1194
-
1195
- function clean(str) {
1196
- str = str
1197
- .replace(/^function *\(.*\) *{/, '')
1198
- .replace(/\s+\}$/, '');
1199
-
1200
- var spaces = str.match(/^\n?( *)/)[1].length
1201
- , re = new RegExp('^ {' + spaces + '}', 'gm');
1202
-
1203
- str = str
1204
- .replace(re, '')
1205
- .replace(/^\s+/, '');
1206
-
1207
- return str;
1208
- }
1209
- }); // module: reporters/html.js
1210
-
1211
- require.register("reporters/index.js", function(module, exports, require){
1212
-
1213
- exports.Base = require('./base');
1214
- exports.Dot = require('./dot');
1215
- exports.Doc = require('./doc');
1216
- exports.TAP = require('./tap');
1217
- exports.JSON = require('./json');
1218
- exports.HTML = require('./html');
1219
- exports.List = require('./list');
1220
- exports.Spec = require('./spec');
1221
- exports.Progress = require('./progress');
1222
- exports.Landing = require('./landing');
1223
- exports.JSONStream = require('./json-stream');
1224
-
1225
- }); // module: reporters/index.js
1226
-
1227
- require.register("reporters/json-stream.js", function(module, exports, require){
1228
-
1229
- /**
1230
- * Module dependencies.
1231
- */
1232
-
1233
- var Base = require('./base')
1234
- , color = Base.color;
1235
-
1236
- /**
1237
- * Expose `List`.
1238
- */
1239
-
1240
- exports = module.exports = List;
1241
-
1242
- /**
1243
- * Initialize a new `List` test reporter.
1244
- *
1245
- * @param {Runner} runner
1246
- * @api public
1247
- */
1248
-
1249
- function List(runner) {
1250
- Base.call(this, runner);
1251
-
1252
- var self = this
1253
- , stats = this.stats
1254
- , total = runner.total;
1255
-
1256
- runner.on('start', function(){
1257
- console.log(JSON.stringify(['start', { total: total }]));
1258
- });
1259
-
1260
- runner.on('pass', function(test){
1261
- console.log(JSON.stringify(['pass', clean(test)]));
1262
- });
1263
-
1264
- runner.on('fail', function(test, err){
1265
- console.log(JSON.stringify(['fail', clean(test)]));
1266
- });
1267
-
1268
- runner.on('end', function(){
1269
- process.stdout.write(JSON.stringify(['end', self.stats]));
1270
- });
1271
- }
1272
-
1273
- /**
1274
- * Return a plain-object representation of `test`
1275
- * free of cyclic properties etc.
1276
- *
1277
- * @param {Object} test
1278
- * @return {Object}
1279
- * @api private
1280
- */
1281
-
1282
- function clean(test) {
1283
- return {
1284
- title: test.title
1285
- , fullTitle: test.fullTitle()
1286
- , duration: test.duration
1287
- }
1288
- }
1289
- }); // module: reporters/json-stream.js
1290
-
1291
- require.register("reporters/json.js", function(module, exports, require){
1292
-
1293
- /**
1294
- * Module dependencies.
1295
- */
1296
-
1297
- var Base = require('./base')
1298
- , cursor = Base.cursor
1299
- , color = Base.color;
1300
-
1301
- /**
1302
- * Expose `JSON`.
1303
- */
1304
-
1305
- exports = module.exports = JSONReporter;
1306
-
1307
- /**
1308
- * Initialize a new `JSON` reporter.
1309
- *
1310
- * @param {Runner} runner
1311
- * @api public
1312
- */
1313
-
1314
- function JSONReporter(runner) {
1315
- var self = this;
1316
- Base.call(this, runner);
1317
-
1318
- var tests = []
1319
- , failures = []
1320
- , passes = [];
1321
-
1322
- runner.on('test end', function(test){
1323
- tests.push(test);
1324
- });
1325
-
1326
- runner.on('pass', function(test){
1327
- passes.push(test);
1328
- });
1329
-
1330
- runner.on('fail', function(test){
1331
- failures.push(test);
1332
- });
1333
-
1334
- runner.on('end', function(){
1335
- var obj = {
1336
- stats: self.stats
1337
- , tests: tests.map(clean)
1338
- , failures: failures.map(clean)
1339
- , passes: passes.map(clean)
1340
- };
1341
-
1342
- process.stdout.write(JSON.stringify(obj));
1343
- });
1344
- }
1345
-
1346
- /**
1347
- * Return a plain-object representation of `test`
1348
- * free of cyclic properties etc.
1349
- *
1350
- * @param {Object} test
1351
- * @return {Object}
1352
- * @api private
1353
- */
1354
-
1355
- function clean(test) {
1356
- return {
1357
- title: test.title
1358
- , fullTitle: test.fullTitle()
1359
- , duration: test.duration
1360
- }
1361
- }
1362
- }); // module: reporters/json.js
1363
-
1364
- require.register("reporters/landing.js", function(module, exports, require){
1365
-
1366
- /**
1367
- * Module dependencies.
1368
- */
1369
-
1370
- var Base = require('./base')
1371
- , cursor = Base.cursor
1372
- , color = Base.color;
1373
-
1374
- /**
1375
- * Expose `Landing`.
1376
- */
1377
-
1378
- exports = module.exports = Landing;
1379
-
1380
- /**
1381
- * Airplane color.
1382
- */
1383
-
1384
- Base.colors.plane = 0;
1385
-
1386
- /**
1387
- * Airplane crash color.
1388
- */
1389
-
1390
- Base.colors['plane crash'] = 31;
1391
-
1392
- /**
1393
- * Runway color.
1394
- */
1395
-
1396
- Base.colors.runway = 90;
1397
-
1398
- /**
1399
- * Initialize a new `Landing` reporter.
1400
- *
1401
- * @param {Runner} runner
1402
- * @api public
1403
- */
1404
-
1405
- function Landing(runner) {
1406
- Base.call(this, runner);
1407
-
1408
- var self = this
1409
- , stats = this.stats
1410
- , width = Base.window.width * .75 | 0
1411
- , total = runner.total
1412
- , stream = process.stdout
1413
- , plane = color('plane', '✈')
1414
- , crashed = -1
1415
- , n = 0;
1416
-
1417
- function runway() {
1418
- var buf = Array(width).join('-');
1419
- return ' ' + color('runway', buf);
1420
- }
1421
-
1422
- runner.on('start', function(){
1423
- stream.write('\n ');
1424
- cursor.hide();
1425
- });
1426
-
1427
- runner.on('test end', function(test){
1428
- // check if the plane crashed
1429
- var col = -1 == crashed
1430
- ? width * ++n / total | 0
1431
- : crashed;
1432
-
1433
- // show the crash
1434
- if (test.failed) {
1435
- plane = color('plane crash', '✈');
1436
- crashed = col;
1437
- }
1438
-
1439
- // render landing strip
1440
- stream.write('\033[4F\n\n');
1441
- stream.write(runway());
1442
- stream.write('\n ');
1443
- stream.write(color('runway', Array(col).join('⋅')));
1444
- stream.write(plane)
1445
- stream.write(color('runway', Array(width - col).join('⋅') + '\n'));
1446
- stream.write(runway());
1447
- stream.write('\033[0m');
1448
- });
1449
-
1450
- runner.on('end', function(){
1451
- cursor.show();
1452
- console.log();
1453
- self.epilogue();
1454
- });
1455
- }
1456
-
1457
- /**
1458
- * Inherit from `Base.prototype`.
1459
- */
1460
-
1461
- Landing.prototype = new Base;
1462
- Landing.prototype.constructor = Landing;
1463
-
1464
- }); // module: reporters/landing.js
1465
-
1466
- require.register("reporters/list.js", function(module, exports, require){
1467
-
1468
- /**
1469
- * Module dependencies.
1470
- */
1471
-
1472
- var Base = require('./base')
1473
- , color = Base.color;
1474
-
1475
- /**
1476
- * Expose `List`.
1477
- */
1478
-
1479
- exports = module.exports = List;
1480
-
1481
- /**
1482
- * Initialize a new `List` test reporter.
1483
- *
1484
- * @param {Runner} runner
1485
- * @api public
1486
- */
1487
-
1488
- function List(runner) {
1489
- Base.call(this, runner);
1490
-
1491
- var self = this
1492
- , stats = this.stats
1493
- , n = 0;
1494
-
1495
- runner.on('start', function(){
1496
- console.log();
1497
- });
1498
-
1499
- runner.on('test', function(test){
1500
- process.stdout.write(color('pass', ' ' + test.fullTitle() + ': '));
1501
- });
1502
-
1503
- runner.on('pending', function(test){
1504
- var fmt = color('checkmark', ' -')
1505
- + color('pending', ' %s');
1506
- console.log(fmt, test.fullTitle());
1507
- });
1508
-
1509
- runner.on('pass', function(test){
1510
- var fmt = color('checkmark', ' ✓')
1511
- + color('pass', ' %s: ')
1512
- + color(test.speed, '%dms');
1513
- console.log('\r' + fmt, test.fullTitle(), test.duration);
1514
- });
1515
-
1516
- runner.on('fail', function(test, err){
1517
- console.log('\r' + color('fail', ' %d) %s'), n++, test.fullTitle());
1518
- });
1519
-
1520
- runner.on('end', self.epilogue.bind(self));
1521
- }
1522
-
1523
- /**
1524
- * Inherit from `Base.prototype`.
1525
- */
1526
-
1527
- List.prototype = new Base;
1528
- List.prototype.constructor = List;
1529
-
1530
- }); // module: reporters/list.js
1531
-
1532
- require.register("reporters/progress.js", function(module, exports, require){
1533
-
1534
- /**
1535
- * Module dependencies.
1536
- */
1537
-
1538
- var Base = require('./base')
1539
- , cursor = Base.cursor
1540
- , color = Base.color;
1541
-
1542
- /**
1543
- * Expose `Progress`.
1544
- */
1545
-
1546
- exports = module.exports = Progress;
1547
-
1548
- /**
1549
- * General progress bar color.
1550
- */
1551
-
1552
- Base.colors.progress = 90;
1553
-
1554
- /**
1555
- * Initialize a new `Progress` bar test reporter.
1556
- *
1557
- * @param {Runner} runner
1558
- * @param {Object} options
1559
- * @api public
1560
- */
1561
-
1562
- function Progress(runner, options) {
1563
- Base.call(this, runner);
1564
-
1565
- var self = this
1566
- , options = options || {}
1567
- , stats = this.stats
1568
- , width = Base.window.width * .50 | 0
1569
- , total = runner.total
1570
- , complete = 0
1571
- , max = Math.max;
1572
-
1573
- // default chars
1574
- options.open = options.open || '[';
1575
- options.complete = options.complete || '▬';
1576
- options.incomplete = options.incomplete || '⋅';
1577
- options.close = options.close || ']';
1578
- options.verbose = false;
1579
-
1580
- // tests started
1581
- runner.on('start', function(){
1582
- console.log();
1583
- cursor.hide();
1584
- });
1585
-
1586
- // tests complete
1587
- runner.on('test end', function(){
1588
- var incomplete = total - complete
1589
- , percent = complete++ / total
1590
- , n = width * percent | 0
1591
- , i = width - n;
1592
-
1593
- process.stdout.write('\r\033[J');
1594
- process.stdout.write(color('progress', ' ' + options.open));
1595
- process.stdout.write(Array(n).join(options.complete));
1596
- process.stdout.write(Array(i).join(options.incomplete));
1597
- process.stdout.write(color('progress', options.close));
1598
- if (options.verbose) {
1599
- process.stdout.write(color('progress', ' ' + complete + ' of ' + total));
1600
- }
1601
- });
1602
-
1603
- // tests are complete, output some stats
1604
- // and the failures if any
1605
- runner.on('end', function(){
1606
- cursor.show();
1607
- console.log();
1608
- self.epilogue();
1609
- });
1610
- }
1611
-
1612
- /**
1613
- * Inherit from `Base.prototype`.
1614
- */
1615
-
1616
- Progress.prototype = new Base;
1617
- Progress.prototype.constructor = Progress;
1618
-
1619
- }); // module: reporters/progress.js
1620
-
1621
- require.register("reporters/spec.js", function(module, exports, require){
1622
-
1623
- /**
1624
- * Module dependencies.
1625
- */
1626
-
1627
- var Base = require('./base')
1628
- , color = Base.color;
1629
-
1630
- /**
1631
- * Expose `Spec`.
1632
- */
1633
-
1634
- exports = module.exports = Spec;
1635
-
1636
- /**
1637
- * Initialize a new `Spec` test reporter.
1638
- *
1639
- * @param {Runner} runner
1640
- * @api public
1641
- */
1642
-
1643
- function Spec(runner) {
1644
- Base.call(this, runner);
1645
-
1646
- var self = this
1647
- , stats = this.stats
1648
- , indents = 0
1649
- , n = 0;
1650
-
1651
- function indent() {
1652
- return Array(indents).join(' ')
1653
- }
1654
-
1655
- runner.on('start', function(){
1656
- console.log();
1657
- });
1658
-
1659
- runner.on('suite', function(suite){
1660
- ++indents;
1661
- console.log(color('suite', '%s%s'), indent(), suite.title);
1662
- });
1663
-
1664
- runner.on('suite end', function(suite){
1665
- --indents;
1666
- if (1 == indents) console.log();
1667
- });
1668
-
1669
- runner.on('test', function(test){
1670
- process.stdout.write(indent() + color('pass', ' ◦ ' + test.title + ': '));
1671
- });
1672
-
1673
- runner.on('pending', function(test){
1674
- var fmt = indent() + color('pending', ' - %s');
1675
- console.log(fmt, test.title);
1676
- });
1677
-
1678
- runner.on('pass', function(test){
1679
- if ('fast' == test.speed) {
1680
- var fmt = indent()
1681
- + color('checkmark', ' ✓')
1682
- + color('pass', ' %s ');
1683
- console.log('\r' + fmt, test.title);
1684
- } else {
1685
- var fmt = indent()
1686
- + color('checkmark', ' ✓')
1687
- + color('pass', ' %s ')
1688
- + color(test.speed, '(%dms)');
1689
- console.log('\r' + fmt, test.title, test.duration);
1690
- }
1691
- });
1692
-
1693
- runner.on('fail', function(test, err){
1694
- console.log('\r' + indent() + color('fail', ' %d) %s'), n++, test.title);
1695
- });
1696
-
1697
- runner.on('end', self.epilogue.bind(self));
1698
- }
1699
-
1700
- /**
1701
- * Inherit from `Base.prototype`.
1702
- */
1703
-
1704
- Spec.prototype = new Base;
1705
- Spec.prototype.constructor = Spec;
1706
-
1707
- }); // module: reporters/spec.js
1708
-
1709
- require.register("reporters/tap.js", function(module, exports, require){
1710
-
1711
- /**
1712
- * Module dependencies.
1713
- */
1714
-
1715
- var Base = require('./base')
1716
- , cursor = Base.cursor
1717
- , color = Base.color;
1718
-
1719
- /**
1720
- * Expose `TAP`.
1721
- */
1722
-
1723
- exports = module.exports = TAP;
1724
-
1725
- /**
1726
- * Initialize a new `TAP` reporter.
1727
- *
1728
- * @param {Runner} runner
1729
- * @api public
1730
- */
1731
-
1732
- function TAP(runner) {
1733
- Base.call(this, runner);
1734
-
1735
- var self = this
1736
- , stats = this.stats
1737
- , total = runner.total
1738
- , n = 1;
1739
-
1740
- runner.on('start', function(){
1741
- console.log('%d..%d', 1, total);
1742
- });
1743
-
1744
- runner.on('test end', function(){
1745
- ++n;
1746
- });
1747
-
1748
- runner.on('pass', function(test){
1749
- console.log('ok %d %s', n, test.fullTitle());
1750
- });
1751
-
1752
- runner.on('fail', function(test, err){
1753
- console.log('not ok %d %s', n, test.fullTitle());
1754
- console.log(err.stack.replace(/^/gm, ' '));
1755
- });
1756
- }
1757
- }); // module: reporters/tap.js
1758
-
1759
- require.register("runnable.js", function(module, exports, require){
1760
-
1761
- /**
1762
- * Module dependencies.
1763
- */
1764
-
1765
- var EventEmitter = require('browser/events').EventEmitter
1766
- , debug = require('browser/debug')('runnable');
1767
-
1768
- /**
1769
- * Expose `Runnable`.
1770
- */
1771
-
1772
- module.exports = Runnable;
1773
-
1774
- /**
1775
- * Initialize a new `Runnable` with the given `title` and callback `fn`.
1776
- *
1777
- * @param {String} title
1778
- * @param {Function} fn
1779
- * @api private
1780
- */
1781
-
1782
- function Runnable(title, fn) {
1783
- this.title = title;
1784
- this.fn = fn;
1785
- this.async = fn && fn.length;
1786
- this.sync = ! this.async;
1787
- this._timeout = 2000;
1788
- }
1789
-
1790
- /**
1791
- * Inherit from `EventEmitter.prototype`.
1792
- */
1793
-
1794
- Runnable.prototype = new EventEmitter;
1795
- Runnable.prototype.constructor = Runnable;
1796
-
1797
-
1798
- /**
1799
- * Set & get timeout `ms`.
1800
- *
1801
- * @param {Number} ms
1802
- * @return {Runnable|Number} ms or self
1803
- * @api private
1804
- */
1805
-
1806
- Runnable.prototype.timeout = function(ms){
1807
- if (0 == arguments.length) return this._timeout;
1808
- debug('timeout %d', ms);
1809
- this._timeout = ms;
1810
- return this;
1811
- };
1812
-
1813
- /**
1814
- * Return the full title generated by recursively
1815
- * concatenating the parent's full title.
1816
- *
1817
- * @return {String}
1818
- * @api public
1819
- */
1820
-
1821
- Runnable.prototype.fullTitle = function(){
1822
- return this.parent.fullTitle() + ' ' + this.title;
1823
- };
1824
-
1825
- /**
1826
- * Clear the timeout.
1827
- *
1828
- * @api private
1829
- */
1830
-
1831
- Runnable.prototype.clearTimeout = function(){
1832
- clearTimeout(this.timer);
1833
- };
1834
-
1835
- /**
1836
- * Run the test and invoke `fn(err)`.
1837
- *
1838
- * @param {Function} fn
1839
- * @api private
1840
- */
1841
-
1842
- Runnable.prototype.run = function(fn){
1843
- var self = this
1844
- , ms = this.timeout()
1845
- , start = new Date
1846
- , finished
1847
- , emitted;
1848
-
1849
- // timeout
1850
- if (this.async) {
1851
- this.timer = setTimeout(function(){
1852
- done(new Error('timeout of ' + ms + 'ms exceeded'));
1853
- }, ms);
1854
- }
1855
-
1856
- // called multiple times
1857
- function multiple() {
1858
- if (emitted) return;
1859
- emitted = true;
1860
- self.emit('error', new Error('done() called multiple times'));
1861
- }
1862
-
1863
- // finished
1864
- function done(err) {
1865
- if (finished) return multiple();
1866
- self.clearTimeout();
1867
- self.duration = new Date - start;
1868
- finished = true;
1869
- fn(err);
1870
- }
1871
-
1872
- // async
1873
- if (this.async) {
1874
- try {
1875
- this.fn(function(err){
1876
- if (err instanceof Error) return done(err);
1877
- done();
1878
- });
1879
- } catch (err) {
1880
- done(err);
1881
- }
1882
- return;
1883
- }
1884
-
1885
- // sync
1886
- try {
1887
- if (!this.pending) this.fn();
1888
- this.duration = new Date - start;
1889
- fn();
1890
- } catch (err) {
1891
- fn(err);
1892
- }
1893
- };
1894
-
1895
- }); // module: runnable.js
1896
-
1897
- require.register("runner.js", function(module, exports, require){
1898
-
1899
- /**
1900
- * Module dependencies.
1901
- */
1902
-
1903
- var EventEmitter = require('browser/events').EventEmitter
1904
- , debug = require('browser/debug')('runner')
1905
- , Test = require('./test')
1906
- , noop = function(){};
1907
-
1908
- /**
1909
- * Expose `Runner`.
1910
- */
1911
-
1912
- module.exports = Runner;
1913
-
1914
- /**
1915
- * Initialize a `Runner` for the given `suite`.
1916
- *
1917
- * Events:
1918
- *
1919
- * - `start` execution started
1920
- * - `end` execution complete
1921
- * - `suite` (suite) test suite execution started
1922
- * - `suite end` (suite) all tests (and sub-suites) have finished
1923
- * - `test` (test) test execution started
1924
- * - `test end` (test) test completed
1925
- * - `hook` (hook) hook execution started
1926
- * - `hook end` (hook) hook complete
1927
- * - `pass` (test) test passed
1928
- * - `fail` (test, err) test failed
1929
- *
1930
- * @api public
1931
- */
1932
-
1933
- function Runner(suite) {
1934
- var self = this;
1935
- this._globals = [];
1936
- this.suite = suite;
1937
- this.total = suite.total();
1938
- this.failures = 0;
1939
- this.on('test end', function(test){ self.checkGlobals(test); });
1940
- this.on('hook end', function(hook){ self.checkGlobals(hook); });
1941
- this.grep(/.*/);
1942
- this.globals(Object.keys(global).concat(['errno']));
1943
- }
1944
-
1945
- /**
1946
- * Inherit from `EventEmitter.prototype`.
1947
- */
1948
-
1949
- Runner.prototype = new EventEmitter;
1950
- Runner.prototype.constructor = Runner;
1951
-
1952
-
1953
- /**
1954
- * Run tests with full titles matching `re`.
1955
- *
1956
- * @param {RegExp} re
1957
- * @return {Runner} for chaining
1958
- * @api public
1959
- */
1960
-
1961
- Runner.prototype.grep = function(re){
1962
- debug('grep %s', re);
1963
- this._grep = re;
1964
- return this;
1965
- };
1966
-
1967
- /**
1968
- * Allow the given `arr` of globals.
1969
- *
1970
- * @param {Array} arr
1971
- * @return {Runner} for chaining
1972
- * @api public
1973
- */
1974
-
1975
- Runner.prototype.globals = function(arr){
1976
- debug('globals %j', arr);
1977
- arr.forEach(function(arr){
1978
- this._globals.push(arr);
1979
- }, this);
1980
- return this;
1981
- };
1982
-
1983
- /**
1984
- * Check for global variable leaks.
1985
- *
1986
- * @api private
1987
- */
1988
-
1989
- Runner.prototype.checkGlobals = function(test){
1990
- if (this.ignoreLeaks) return;
1991
-
1992
- var leaks = Object.keys(global).filter(function(key){
1993
- return !~this._globals.indexOf(key);
1994
- }, this);
1995
-
1996
- this._globals = this._globals.concat(leaks);
1997
-
1998
- if (leaks.length > 1) {
1999
- this.fail(test, new Error('global leaks detected: ' + leaks.join(', ') + ''));
2000
- } else if (leaks.length) {
2001
- this.fail(test, new Error('global leak detected: ' + leaks[0]));
2002
- }
2003
- };
2004
-
2005
- /**
2006
- * Fail the given `test`.
2007
- *
2008
- * @param {Test} test
2009
- * @param {Error} err
2010
- * @api private
2011
- */
2012
-
2013
- Runner.prototype.fail = function(test, err){
2014
- ++this.failures;
2015
- test.failed = true;
2016
- this.emit('fail', test, err);
2017
- };
2018
-
2019
- /**
2020
- * Fail the given `hook` with `err`.
2021
- *
2022
- * Hook failures (currently) hard-end due
2023
- * to that fact that a failing hook will
2024
- * surely cause subsequent tests to fail,
2025
- * causing jumbled reporting.
2026
- *
2027
- * @param {Hook} hook
2028
- * @param {Error} err
2029
- * @api private
2030
- */
2031
-
2032
- Runner.prototype.failHook = function(hook, err){
2033
- ++this.failures;
2034
- this.fail(hook, err);
2035
- this.emit('end');
2036
- };
2037
-
2038
- /**
2039
- * Run hook `name` callbacks and then invoke `fn()`.
2040
- *
2041
- * @param {String} name
2042
- * @param {Function} function
2043
- * @api private
2044
- */
2045
-
2046
- Runner.prototype.hook = function(name, fn){
2047
- var suite = this.suite
2048
- , hooks = suite['_' + name]
2049
- , ms = suite._timeout
2050
- , self = this
2051
- , timer;
2052
-
2053
- function next(i) {
2054
- var hook = hooks[i];
2055
- if (!hook) return fn();
2056
- self.currentRunnable = hook;
2057
-
2058
- self.emit('hook', hook);
2059
-
2060
- hook.on('error', function(err){
2061
- self.failHook(hook, err);
2062
- });
2063
-
2064
- hook.run(function(err){
2065
- hook.removeAllListeners('error');
2066
- if (err) return self.failHook(hook, err);
2067
- self.emit('hook end', hook);
2068
- next(++i);
2069
- });
2070
- }
2071
-
2072
- process.nextTick(function(){
2073
- next(0);
2074
- });
2075
- };
2076
-
2077
- /**
2078
- * Run hook `name` for the given array of `suites`
2079
- * in order, and callback `fn(err)`.
2080
- *
2081
- * @param {String} name
2082
- * @param {Array} suites
2083
- * @param {Function} fn
2084
- * @api private
2085
- */
2086
-
2087
- Runner.prototype.hooks = function(name, suites, fn){
2088
- var self = this
2089
- , orig = this.suite;
2090
-
2091
- function next(suite) {
2092
- self.suite = suite;
2093
-
2094
- if (!suite) {
2095
- self.suite = orig;
2096
- return fn();
2097
- }
2098
-
2099
- self.hook(name, function(err){
2100
- if (err) {
2101
- self.suite = orig;
2102
- return fn(err);
2103
- }
2104
-
2105
- next(suites.pop());
2106
- });
2107
- }
2108
-
2109
- next(suites.pop());
2110
- };
2111
-
2112
- /**
2113
- * Run hooks from the top level down.
2114
- *
2115
- * @param {String} name
2116
- * @param {Function} fn
2117
- * @api private
2118
- */
2119
-
2120
- Runner.prototype.hookUp = function(name, fn){
2121
- var suites = [this.suite].concat(this.parents()).reverse();
2122
- this.hooks(name, suites, fn);
2123
- };
2124
-
2125
- /**
2126
- * Run hooks from the bottom up.
2127
- *
2128
- * @param {String} name
2129
- * @param {Function} fn
2130
- * @api private
2131
- */
2132
-
2133
- Runner.prototype.hookDown = function(name, fn){
2134
- var suites = [this.suite].concat(this.parents());
2135
- this.hooks(name, suites, fn);
2136
- };
2137
-
2138
- /**
2139
- * Return an array of parent Suites from
2140
- * closest to furthest.
2141
- *
2142
- * @return {Array}
2143
- * @api private
2144
- */
2145
-
2146
- Runner.prototype.parents = function(){
2147
- var suite = this.suite
2148
- , suites = [];
2149
- while (suite = suite.parent) suites.push(suite);
2150
- return suites;
2151
- };
2152
-
2153
- /**
2154
- * Run the current test and callback `fn(err)`.
2155
- *
2156
- * @param {Function} fn
2157
- * @api private
2158
- */
2159
-
2160
- Runner.prototype.runTest = function(fn){
2161
- var test = this.test
2162
- , self = this;
2163
-
2164
- try {
2165
- test.on('error', function(err){
2166
- self.fail(test, err);
2167
- });
2168
- test.run(fn);
2169
- } catch (err) {
2170
- fn(err);
2171
- }
2172
- };
2173
-
2174
- /**
2175
- * Run tests in the given `suite` and invoke
2176
- * the callback `fn()` when complete.
2177
- *
2178
- * @param {Suite} suite
2179
- * @param {Function} fn
2180
- * @api private
2181
- */
2182
-
2183
- Runner.prototype.runTests = function(suite, fn){
2184
- var self = this
2185
- , tests = suite.tests
2186
- , test;
2187
-
2188
- function next(err) {
2189
- // next test
2190
- test = tests.shift();
2191
-
2192
- // all done
2193
- if (!test) return fn();
2194
-
2195
- // grep
2196
- if (!self._grep.test(test.fullTitle())) return next();
2197
-
2198
- // pending
2199
- if (test.pending) {
2200
- self.emit('pending', test);
2201
- self.emit('test end', test);
2202
- return next();
2203
- }
2204
-
2205
- // execute test and hook(s)
2206
- self.emit('test', self.test = self.currentRunnable = test);
2207
- self.hookDown('beforeEach', function(){
2208
- self.runTest(function(err){
2209
- if (err) {
2210
- self.fail(test, err);
2211
- self.emit('test end', test);
2212
- return self.hookUp('afterEach', next);
2213
- }
2214
-
2215
- self.emit('pass', test);
2216
- test.passed = true;
2217
- self.emit('test end', test);
2218
- self.hookUp('afterEach', next);
2219
- });
2220
- });
2221
- }
2222
-
2223
- next();
2224
- };
2225
-
2226
- /**
2227
- * Run the given `suite` and invoke the
2228
- * callback `fn()` when complete.
2229
- *
2230
- * @param {Suite} suite
2231
- * @param {Function} fn
2232
- * @api private
2233
- */
2234
-
2235
- Runner.prototype.runSuite = function(suite, fn){
2236
- var self = this
2237
- , i = 0;
2238
-
2239
- debug('run suite %s', suite.fullTitle());
2240
- this.emit('suite', this.suite = suite);
2241
-
2242
- function next() {
2243
- var curr = suite.suites[i++];
2244
- if (!curr) return done();
2245
- self.runSuite(curr, next);
2246
- }
2247
-
2248
- function done() {
2249
- self.suite = suite;
2250
- self.hook('afterAll', function(){
2251
- self.emit('suite end', suite);
2252
- fn();
2253
- });
2254
- }
2255
-
2256
- this.hook('beforeAll', function(){
2257
- self.runTests(suite, next);
2258
- });
2259
- };
2260
-
2261
- /**
2262
- * Run the root suite and invoke `fn(failures)`
2263
- * on completion.
2264
- *
2265
- * @param {Function} fn
2266
- * @return {Runner} for chaining
2267
- * @api public
2268
- */
2269
-
2270
- Runner.prototype.run = function(fn){
2271
- var self = this
2272
- , fn = fn || function(){};
2273
-
2274
- debug('start');
2275
-
2276
- // callback
2277
- self.on('end', function(){
2278
- debug('end');
2279
- process.removeListener('uncaughtException', uncaught);
2280
- fn(self.failures);
2281
- });
2282
-
2283
- // run suites
2284
- this.emit('start');
2285
- this.runSuite(this.suite, function(){
2286
- debug('finished running');
2287
- self.emit('end');
2288
- });
2289
-
2290
- // uncaught exception
2291
- function uncaught(err){
2292
- debug('uncaught exception');
2293
- self.currentRunnable.clearTimeout();
2294
- self.fail(self.currentRunnable, err);
2295
- self.emit('test end', self.test);
2296
- self.emit('end');
2297
- }
2298
-
2299
- process.on('uncaughtException', uncaught);
2300
-
2301
- return this;
2302
- };
2303
-
2304
- }); // module: runner.js
2305
-
2306
- require.register("suite.js", function(module, exports, require){
2307
-
2308
- /**
2309
- * Module dependencies.
2310
- */
2311
-
2312
- var EventEmitter = require('browser/events').EventEmitter
2313
- , debug = require('browser/debug')('suite')
2314
- , Hook = require('./hook');
2315
-
2316
- /**
2317
- * Expose `Suite`.
2318
- */
2319
-
2320
- exports = module.exports = Suite;
2321
-
2322
- /**
2323
- * Create a new `Suite` with the given `title`
2324
- * and parent `Suite`. When a suite with the
2325
- * same title is already present, that suite
2326
- * is returned to provide nicer reporter
2327
- * and more flexible meta-testing.
2328
- *
2329
- * @param {Suite} parent
2330
- * @param {String} title
2331
- * @return {Suite}
2332
- * @api public
2333
- */
2334
-
2335
- exports.create = function(parent, title){
2336
- var suite = new Suite(title);
2337
- suite.parent = parent;
2338
- title = suite.fullTitle();
2339
- parent.addSuite(suite);
2340
- return suite;
2341
- };
2342
-
2343
- /**
2344
- * Initialize a new `Suite` with the given `title`.
2345
- *
2346
- * @param {String} title
2347
- * @api private
2348
- */
2349
-
2350
- function Suite(title) {
2351
- this.title = title;
2352
- this.suites = [];
2353
- this.tests = [];
2354
- this._beforeEach = [];
2355
- this._beforeAll = [];
2356
- this._afterEach = [];
2357
- this._afterAll = [];
2358
- this.root = !title;
2359
- this._timeout = 2000;
2360
- }
2361
-
2362
- /**
2363
- * Inherit from `EventEmitter.prototype`.
2364
- */
2365
-
2366
- Suite.prototype = new EventEmitter;
2367
- Suite.prototype.constructor = Suite;
2368
-
2369
-
2370
- /**
2371
- * Return a clone of this `Suite`.
2372
- *
2373
- * @return {Suite}
2374
- * @api private
2375
- */
2376
-
2377
- Suite.prototype.clone = function(){
2378
- var suite = new Suite(this.title);
2379
- debug('clone');
2380
- suite.timeout(this.timeout());
2381
- return suite;
2382
- };
2383
-
2384
- /**
2385
- * Set timeout `ms` or short-hand such as "2s".
2386
- *
2387
- * @param {Number|String} ms
2388
- * @return {Suite|Number} for chaining
2389
- * @api private
2390
- */
2391
-
2392
- Suite.prototype.timeout = function(ms){
2393
- if (0 == arguments.length) return this._timeout;
2394
- if (String(ms).match(/s$/)) ms = parseFloat(ms) * 1000;
2395
- debug('timeout %d', ms);
2396
- this._timeout = parseInt(ms, 10);
2397
- return this;
2398
- };
2399
-
2400
- /**
2401
- * Run `fn(test[, done])` before running tests.
2402
- *
2403
- * @param {Function} fn
2404
- * @return {Suite} for chaining
2405
- * @api private
2406
- */
2407
-
2408
- Suite.prototype.beforeAll = function(fn){
2409
- var hook = new Hook('"before all" hook', fn);
2410
- hook.parent = this;
2411
- hook.timeout(this.timeout());
2412
- this._beforeAll.push(hook);
2413
- this.emit('beforeAll', hook);
2414
- return this;
2415
- };
2416
-
2417
- /**
2418
- * Run `fn(test[, done])` after running tests.
2419
- *
2420
- * @param {Function} fn
2421
- * @return {Suite} for chaining
2422
- * @api private
2423
- */
2424
-
2425
- Suite.prototype.afterAll = function(fn){
2426
- var hook = new Hook('"after all" hook', fn);
2427
- hook.parent = this;
2428
- hook.timeout(this.timeout());
2429
- this._afterAll.push(hook);
2430
- this.emit('afterAll', hook);
2431
- return this;
2432
- };
2433
-
2434
- /**
2435
- * Run `fn(test[, done])` before each test case.
2436
- *
2437
- * @param {Function} fn
2438
- * @return {Suite} for chaining
2439
- * @api private
2440
- */
2441
-
2442
- Suite.prototype.beforeEach = function(fn){
2443
- var hook = new Hook('"before each" hook', fn);
2444
- hook.parent = this;
2445
- hook.timeout(this.timeout());
2446
- this._beforeEach.push(hook);
2447
- this.emit('beforeEach', hook);
2448
- return this;
2449
- };
2450
-
2451
- /**
2452
- * Run `fn(test[, done])` after each test case.
2453
- *
2454
- * @param {Function} fn
2455
- * @return {Suite} for chaining
2456
- * @api private
2457
- */
2458
-
2459
- Suite.prototype.afterEach = function(fn){
2460
- var hook = new Hook('"after each" hook', fn);
2461
- hook.parent = this;
2462
- hook.timeout(this.timeout());
2463
- this._afterEach.push(hook);
2464
- this.emit('afterEach', hook);
2465
- return this;
2466
- };
2467
-
2468
- /**
2469
- * Add a test `suite`.
2470
- *
2471
- * @param {Suite} suite
2472
- * @return {Suite} for chaining
2473
- * @api private
2474
- */
2475
-
2476
- Suite.prototype.addSuite = function(suite){
2477
- suite.parent = this;
2478
- suite.timeout(this.timeout());
2479
- this.suites.push(suite);
2480
- this.emit('suite', suite);
2481
- return this;
2482
- };
2483
-
2484
- /**
2485
- * Add a `test` to this suite.
2486
- *
2487
- * @param {Test} test
2488
- * @return {Suite} for chaining
2489
- * @api private
2490
- */
2491
-
2492
- Suite.prototype.addTest = function(test){
2493
- test.parent = this;
2494
- test.timeout(this.timeout());
2495
- this.tests.push(test);
2496
- this.emit('test', test);
2497
- return this;
2498
- };
2499
-
2500
- /**
2501
- * Return the full title generated by recursively
2502
- * concatenating the parent's full title.
2503
- *
2504
- * @return {String}
2505
- * @api public
2506
- */
2507
-
2508
- Suite.prototype.fullTitle = function(){
2509
- if (this.parent) {
2510
- var full = this.parent.fullTitle();
2511
- if (full) return full + ' ' + this.title;
2512
- }
2513
- return this.title;
2514
- };
2515
-
2516
- /**
2517
- * Return the total number of tests.
2518
- *
2519
- * @return {Number}
2520
- * @api public
2521
- */
2522
-
2523
- Suite.prototype.total = function(){
2524
- return this.suites.reduce(function(sum, suite){
2525
- return sum + suite.total();
2526
- }, 0) + this.tests.length;
2527
- };
2528
-
2529
- }); // module: suite.js
2530
-
2531
- require.register("test.js", function(module, exports, require){
2532
-
2533
- /**
2534
- * Module dependencies.
2535
- */
2536
-
2537
- var Runnable = require('./runnable');
2538
-
2539
- /**
2540
- * Expose `Test`.
2541
- */
2542
-
2543
- module.exports = Test;
2544
-
2545
- /**
2546
- * Initialize a new `Test` with the given `title` and callback `fn`.
2547
- *
2548
- * @param {String} title
2549
- * @param {Function} fn
2550
- * @api private
2551
- */
2552
-
2553
- function Test(title, fn) {
2554
- Runnable.call(this, title, fn);
2555
- this.pending = !fn;
2556
- }
2557
-
2558
- /**
2559
- * Inherit from `Runnable.prototype`.
2560
- */
2561
-
2562
- Test.prototype = new Runnable;
2563
- Test.prototype.constructor = Test;
2564
-
2565
-
2566
- }); // module: test.js
2567
-
2568
- require.register("utils.js", function(module, exports, require){
2569
-
2570
- /**
2571
- * Escape special characters in the given string of html.
2572
- *
2573
- * @param {String} html
2574
- * @return {String}
2575
- * @api private
2576
- */
2577
-
2578
- exports.escape = function(html) {
2579
- return String(html)
2580
- .replace(/&/g, '&amp;')
2581
- .replace(/"/g, '&quot;')
2582
- .replace(/</g, '&lt;')
2583
- .replace(/>/g, '&gt;');
2584
- };
2585
- }); // module: utils.js
2586
-
2587
- require.register("watch.js", function(module, exports, require){
2588
-
2589
- /**
2590
- * Module dependencies.
2591
- */
2592
-
2593
- var fs = require('browser/fs')
2594
- , debug = require('browser/debug')('watch');
2595
-
2596
- module.exports = function(paths, fn){
2597
- var options = { interval: 100 };
2598
- paths.forEach(function(path){
2599
- debug('watch %s', path);
2600
- fs.watchFile(path, options, function(curr, prev){
2601
- if (prev.mtime < curr.mtime) fn(path);
2602
- });
2603
- });
2604
- };
2605
- }); // module: watch.js
2606
-
2607
- /**
2608
- * Node shims.
2609
- *
2610
- * These are meant only to allow
2611
- * mocha.js to run untouched, not
2612
- * to allow running node code in
2613
- * the browser.
2614
- */
2615
-
2616
- process = {};
2617
- process.exit = function(status){};
2618
- process.stdout = {};
2619
- global = this;
2620
-
2621
- process.nextTick = function(fn){ fn(); };
2622
-
2623
- process.removeListener = function(ev){
2624
- if ('uncaughtException' == ev) {
2625
- window.onerror = null;
2626
- }
2627
- };
2628
-
2629
- process.on = function(ev, fn){
2630
- if ('uncaughtException' == ev) {
2631
- window.onerror = fn;
2632
- }
2633
- };
2634
-
2635
- mocha = require('mocha');
2636
-
2637
- // boot
2638
- ;(function(){
2639
- var suite = new mocha.Suite;
2640
- var Reporter = mocha.reporters.HTML;
2641
-
2642
- function parse(qs) {
2643
- return qs
2644
- .replace('?', '')
2645
- .split('&')
2646
- .reduce(function(obj, pair){
2647
- var i = pair.indexOf('=')
2648
- , key = pair.slice(0, i)
2649
- , val = pair.slice(++i);
2650
-
2651
- obj[key] = decodeURIComponent(val);
2652
- return obj;
2653
- }, {});
2654
- }
2655
-
2656
- mocha.setup = function(ui){
2657
- ui = mocha.interfaces[ui];
2658
- if (!ui) throw new Error('invalid mocha interface "' + ui + '"');
2659
- ui(suite);
2660
- suite.emit('pre-require', global);
2661
- };
2662
-
2663
- mocha.run = function(){
2664
- suite.emit('run');
2665
- var runner = new mocha.Runner(suite);
2666
- var reporter = new Reporter(runner);
2667
- var query = parse(window.location.search || "");
2668
- if (query.grep) runner.grep(new RegExp(query.grep));
2669
- return runner.run();
2670
- };
2671
- })();
2672
- })();