mocha 2.3.2 → 2.3.3

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 CHANGED
@@ -1,9 +1,35 @@
1
+ 2.3.3 / 2015-09-19
2
+ ==================
3
+
4
+ * [#1875] - Fix Markdown reporter exceeds maximum call stack size ([@danielstjules])
5
+ * [#1864] - Fix xunit missing output with --reporter-options output ([@danielstjules])
6
+ * [#1846] - Support all harmony flags ([@danielstjules])
7
+ * Fix fragile xunit reporter spec ([@danielstjules])
8
+ * [#1669] - Fix catch uncaught errors outside test suite execution ([@danielstjules])
9
+ * [#1868] - Revert jade to support npm < v1.3.7 ([@danielstjules])
10
+ * [#1766] - Don't remove modules/components from stack trace in the browser ([@danielstjules])
11
+ * [#1798] - Fix correctly attribute mutiple done err with hooks ([@danielstjules])
12
+ * Fix use utils.reduce for IE8 compatibility ([@wsw0108])
13
+ * Some linting errors fixed by [@danielstjules]
14
+ * Call the inspect() function if message is not set ([@kevinburke])
15
+
16
+ [#1875]: https://github.com/mochajs/mocha/issues/1875
17
+ [#1864]: https://github.com/mochajs/mocha/issues/1864
18
+ [#1846]: https://github.com/mochajs/mocha/issues/1846
19
+ [#1669]: https://github.com/mochajs/mocha/issues/1669
20
+ [#1868]: https://github.com/mochajs/mocha/issues/1868
21
+ [#1766]: https://github.com/mochajs/mocha/issues/1766
22
+ [#1798]: https://github.com/mochajs/mocha/issues/1798
23
+ [@danielstjules]: https://github.com/danielstjules
24
+ [@wsw0108]: https://github.com/wsw0108
25
+ [@kevinburke]: https://github.com/kevinburke
26
+
1
27
  2.3.2 / 2015-09-07
2
28
  ==================
3
29
  * [#1868] - Fix compatibility with older versions of NPM ([@boneskull])
4
30
 
5
31
  [#1868]: https://github.com/mochajs/mocha/issues/1868
6
-
32
+
7
33
  2.3.1 / 2015-09-06
8
34
  ==================
9
35
 
@@ -23,7 +49,7 @@
23
49
  * [#1230] - More descriptive beforeEach/afterEach messages ([@duncanbeevers])
24
50
  * [#1787] - Scope loading behaviour instead of using early return ([@aryeguy])
25
51
  * [#1789] - Fix: html-runner crashing ([@sunesimonsen])
26
- * [#1749] - Fix maximum call stack error on large amount of tests ([@tinganho])
52
+ * [#1749] - Fix maximum call stack error on large amount of tests ([@tinganho])
27
53
  * [#1230] - Decorate failed hook titles with test title ([@duncanbeevers])
28
54
  * [#1260] - Build using Browserify ([@ndhoule])
29
55
  * [#1728] - Don't use `__proto__` ([@ndhoule])
@@ -32,7 +58,7 @@
32
58
  * [#1766] - Fix overly aggressive stack suppression ([@moll])
33
59
  * [#1752] - Avoid potential infinite loop ([@gsilk])
34
60
  * [#1761] - Fix problems running under PhantomJS ([@chromakode])
35
- * [#1700] - Fix more problems running under PhantomJS ([@jbnicolai])
61
+ * [#1700] - Fix more problems running under PhantomJS ([@jbnicolai])
36
62
  * [#1774] - Support escaped spaces in CLI options ([@adamgruber])
37
63
  * [#1687] - Fix HTML reporter links with special chars ([@benvinegar])
38
64
  * [#1359] - Adopt code style and enforce it using ESLint ([@ndhoule] w/ assist from [@jbnicolai] & [@boneskull])
package/bin/_mocha CHANGED
@@ -81,16 +81,8 @@ program
81
81
  .option('--compilers <ext>:<module>,...', 'use the given module(s) to compile files', list, [])
82
82
  .option('--debug-brk', "enable node's debugger breaking on the first line")
83
83
  .option('--globals <names>', 'allow the given comma-delimited global [names]', list, [])
84
- .option('--harmony', 'enable all harmony features (except typeof)')
85
84
  .option('--es_staging', 'enable all staged features')
86
- .option('--harmony-collections', 'enable harmony collections (sets, maps, and weak maps)')
87
- .option('--harmony-generators', 'enable harmony generators')
88
- .option('--harmony-proxies', 'enable harmony proxies')
89
- .option('--harmony_shipping', 'enable all shipped harmony fetaures (iojs)')
90
- .option('--harmony_arrow_functions', 'enable "harmony arrow functions" (iojs)')
91
- .option('--harmony_rest_parameters', 'enable "harmony rest parameters" (iojs)')
92
- .option('--harmony_proxies', 'enable "harmony proxies" (iojs)')
93
- .option('--harmony_classes', 'enable "harmony classes" (iojs)')
85
+ .option('--harmony<_classes,_generators,...>', 'all node --harmony* flags are available')
94
86
  .option('--inline-diffs', 'display actual/expected differences inline within each string')
95
87
  .option('--interfaces', 'display available interfaces')
96
88
  .option('--no-deprecation', 'silence deprecation warnings')
package/bin/mocha CHANGED
@@ -34,24 +34,7 @@ process.argv.slice(2).forEach(function(arg){
34
34
  args.unshift('--expose-gc');
35
35
  break;
36
36
  case '--gc-global':
37
- case '--harmony':
38
37
  case '--es_staging':
39
- case '--harmony_arrays':
40
- case '--harmony_array_includes':
41
- case '--harmony_arrow_functions':
42
- case '--harmony_classes':
43
- case '--harmony-collections':
44
- case '--harmony_collections':
45
- case '--harmony-generators':
46
- case '--harmony_generators':
47
- case '--harmony_modules':
48
- case '--harmony-proxies':
49
- case '--harmony_proxies':
50
- case '--harmony_regexps':
51
- case '--harmony_shipping':
52
- case '--harmony_sloppy':
53
- case '--harmony_rest_parameters':
54
- case '--harmony_unicode':
55
38
  case '--no-deprecation':
56
39
  case '--prof':
57
40
  case '--throw-deprecation':
@@ -60,7 +43,8 @@ process.argv.slice(2).forEach(function(arg){
60
43
  args.unshift(arg);
61
44
  break;
62
45
  default:
63
- if (0 == arg.indexOf('--trace')) args.unshift(arg);
46
+ if (0 == arg.indexOf('--harmony')) args.unshift(arg);
47
+ else if (0 == arg.indexOf('--trace')) args.unshift(arg);
64
48
  else if (0 == arg.indexOf('--max-old-space-size')) args.unshift(arg);
65
49
  else args.push(arg);
66
50
  break;
package/lib/mocha.js CHANGED
@@ -85,7 +85,7 @@ function Mocha(options) {
85
85
  this.ui(options.ui);
86
86
  this.bail(options.bail);
87
87
  this.reporter(options.reporter, options.reporterOptions);
88
- if (options.timeout != null) {
88
+ if (typeof options.timeout !== 'undefined' && options.timeout !== null) {
89
89
  this.timeout(options.timeout);
90
90
  }
91
91
  this.useColors(options.useColors);
@@ -169,7 +169,14 @@ exports.list = function(failures) {
169
169
  // msg
170
170
  var msg;
171
171
  var err = test.err;
172
- var message = err.message || '';
172
+ var message;
173
+ if (err.message) {
174
+ message = err.message;
175
+ } else if (typeof err.inspect === 'function') {
176
+ message = err.inspect() + '';
177
+ } else {
178
+ message = '';
179
+ }
173
180
  var stack = err.stack || message;
174
181
  var index = stack.indexOf(message);
175
182
  var actual = err.actual;
@@ -401,7 +408,7 @@ function unifiedDiff(err, escape) {
401
408
  return indent + line;
402
409
  }
403
410
  function notBlank(line) {
404
- return line != null;
411
+ return typeof line !== 'undefined' && line !== null;
405
412
  }
406
413
  var msg = diff.createPatch('string', err.actual, err.expected);
407
414
  var lines = msg.split('\n').splice(4);
@@ -38,7 +38,7 @@ function Markdown(runner) {
38
38
  var key = SUITE_PREFIX + suite.title;
39
39
 
40
40
  obj = obj[key] = obj[key] || { suite: suite };
41
- suite.suites.forEach(function() {
41
+ suite.suites.forEach(function(suite) {
42
42
  mapTOC(suite, obj);
43
43
  });
44
44
 
@@ -17,7 +17,7 @@ html
17
17
  .misses= cov.misses
18
18
 
19
19
  #files
20
- each file in cov.files
20
+ for file in cov.files
21
21
  .file
22
22
  h2(id=file.filename)= file.filename
23
23
  #stats(class=coverageClass(file.coverage))
@@ -33,7 +33,7 @@ html
33
33
  th Hits
34
34
  th Source
35
35
  tbody
36
- each line, number in file.source
36
+ for line, number in file.source
37
37
  if line.coverage > 0
38
38
  tr.hit
39
39
  td.line= number
@@ -1,12 +1,12 @@
1
1
  #menu
2
2
  li
3
3
  a(href='#overview') overview
4
- each file in cov.files
4
+ for file in cov.files
5
5
  li
6
6
  span.cov(class=coverageClass(file.coverage)) #{file.coverage | 0}
7
7
  a(href='##{file.filename}')
8
- - var segments = file.filename.split('/')
9
- - var basename = segments.pop()
8
+ segments = file.filename.split('/')
9
+ basename = segments.pop()
10
10
  if segments.length
11
11
  span.dirname= segments.join('/') + '/'
12
12
  span.basename= basename
@@ -77,6 +77,11 @@ function XUnit(runner, options) {
77
77
  });
78
78
  }
79
79
 
80
+ /**
81
+ * Inherit from `Base.prototype`.
82
+ */
83
+ inherits(XUnit, Base);
84
+
80
85
  /**
81
86
  * Override done to close the stream (if it's a file).
82
87
  *
@@ -93,11 +98,6 @@ XUnit.prototype.done = function(failures, fn) {
93
98
  }
94
99
  };
95
100
 
96
- /**
97
- * Inherit from `Base.prototype`.
98
- */
99
- inherits(XUnit, Base);
100
-
101
101
  /**
102
102
  * Write out the given line.
103
103
  *
package/lib/runner.js CHANGED
@@ -7,6 +7,7 @@ var Pending = require('./pending');
7
7
  var utils = require('./utils');
8
8
  var inherits = utils.inherits;
9
9
  var debug = require('debug')('mocha:runner');
10
+ var Runnable = require('./runnable');
10
11
  var filter = utils.filter;
11
12
  var indexOf = utils.indexOf;
12
13
  var keys = utils.keys;
@@ -64,6 +65,7 @@ function Runner(suite, delay) {
64
65
  this._abort = false;
65
66
  this._delay = delay;
66
67
  this.suite = suite;
68
+ this.started = false;
67
69
  this.total = suite.total();
68
70
  this.failures = 0;
69
71
  this.on('test end', function(test) {
@@ -286,12 +288,13 @@ Runner.prototype.hook = function(name, fn) {
286
288
 
287
289
  self.emit('hook', hook);
288
290
 
289
- hook.on('error', function(err) {
290
- self.failHook(hook, err);
291
- });
291
+ if (!hook.listeners('error').length) {
292
+ hook.on('error', function(err) {
293
+ self.failHook(hook, err);
294
+ });
295
+ }
292
296
 
293
297
  hook.run(function(err) {
294
- hook.removeAllListeners('error');
295
298
  var testError = hook.error();
296
299
  if (testError) {
297
300
  self.fail(self.test, testError);
@@ -386,7 +389,8 @@ Runner.prototype.hookDown = function(name, fn) {
386
389
  Runner.prototype.parents = function() {
387
390
  var suite = this.suite;
388
391
  var suites = [];
389
- while (suite = suite.parent) {
392
+ while (suite.parent) {
393
+ suite = suite.parent;
390
394
  suites.push(suite);
391
395
  }
392
396
  return suites;
@@ -652,7 +656,20 @@ Runner.prototype.uncaught = function(err) {
652
656
  err.uncaught = true;
653
657
 
654
658
  var runnable = this.currentRunnable;
659
+
655
660
  if (!runnable) {
661
+ runnable = new Runnable('Uncaught error outside test suite');
662
+ runnable.parent = this.suite;
663
+
664
+ if (this.started) {
665
+ this.fail(runnable, err);
666
+ } else {
667
+ // Can't recover from this failure
668
+ this.emit('start');
669
+ this.fail(runnable, err);
670
+ this.emit('end');
671
+ }
672
+
656
673
  return;
657
674
  }
658
675
 
@@ -711,6 +728,7 @@ Runner.prototype.run = function(fn) {
711
728
  }
712
729
 
713
730
  function start() {
731
+ self.started = true;
714
732
  self.emit('start');
715
733
  self.runSuite(rootSuite, function() {
716
734
  debug('finished running');
@@ -806,7 +824,8 @@ function filterLeaks(ok, globals) {
806
824
  */
807
825
  function extraGlobals() {
808
826
  if (typeof process === 'object' && typeof process.version === 'string') {
809
- var nodeVersion = process.version.split('.').reduce(function(a, v) {
827
+ var parts = process.version.split('.');
828
+ var nodeVersion = utils.reduce(parts, function(a, v) {
810
829
  return a << 8 | v;
811
830
  });
812
831
 
package/lib/utils.js CHANGED
@@ -689,7 +689,7 @@ exports.getError = function(err) {
689
689
  * @description
690
690
  * When invoking this function you get a filter function that get the Error.stack as an input,
691
691
  * and return a prettify output.
692
- * (i.e: strip Mocha, node_modules, bower and componentJS from stack trace).
692
+ * (i.e: strip Mocha and internal node functions from stack trace).
693
693
  * @returns {Function}
694
694
  */
695
695
  exports.stackTraceFilter = function() {
@@ -701,14 +701,10 @@ exports.stackTraceFilter = function() {
701
701
  : (typeof location === 'undefined' ? window.location : location).href.replace(/\/[^\/]*$/, '/');
702
702
 
703
703
  function isMochaInternal(line) {
704
- return (~line.indexOf('node_modules' + slash + 'mocha'))
705
- || (~line.indexOf('components' + slash + 'mochajs'))
706
- || (~line.indexOf('components' + slash + 'mocha'));
707
- }
708
-
709
- // node_modules, bower, componentJS
710
- function isBrowserModule(line) {
711
- return (~line.indexOf('node_modules')) || (~line.indexOf('components'));
704
+ return (~line.indexOf('node_modules' + slash + 'mocha' + slash))
705
+ || (~line.indexOf('components' + slash + 'mochajs' + slash))
706
+ || (~line.indexOf('components' + slash + 'mocha' + slash))
707
+ || (~line.indexOf(slash + 'mocha.js'));
712
708
  }
713
709
 
714
710
  function isNodeInternal(line) {
@@ -724,11 +720,11 @@ exports.stackTraceFilter = function() {
724
720
  stack = stack.split('\n');
725
721
 
726
722
  stack = exports.reduce(stack, function(list, line) {
727
- if (is.node && (isMochaInternal(line) || isNodeInternal(line))) {
723
+ if (isMochaInternal(line)) {
728
724
  return list;
729
725
  }
730
726
 
731
- if (is.browser && (isBrowserModule(line))) {
727
+ if (is.node && isNodeInternal(line)) {
732
728
  return list;
733
729
  }
734
730
 
package/mocha.js CHANGED
@@ -1029,7 +1029,7 @@ function Mocha(options) {
1029
1029
  this.ui(options.ui);
1030
1030
  this.bail(options.bail);
1031
1031
  this.reporter(options.reporter, options.reporterOptions);
1032
- if (options.timeout != null) {
1032
+ if (typeof options.timeout !== 'undefined' && options.timeout !== null) {
1033
1033
  this.timeout(options.timeout);
1034
1034
  }
1035
1035
  this.useColors(options.useColors);
@@ -1751,7 +1751,14 @@ exports.list = function(failures) {
1751
1751
  // msg
1752
1752
  var msg;
1753
1753
  var err = test.err;
1754
- var message = err.message || '';
1754
+ var message;
1755
+ if (err.message) {
1756
+ message = err.message;
1757
+ } else if (typeof err.inspect === 'function') {
1758
+ message = err.inspect() + '';
1759
+ } else {
1760
+ message = '';
1761
+ }
1755
1762
  var stack = err.stack || message;
1756
1763
  var index = stack.indexOf(message);
1757
1764
  var actual = err.actual;
@@ -1983,7 +1990,7 @@ function unifiedDiff(err, escape) {
1983
1990
  return indent + line;
1984
1991
  }
1985
1992
  function notBlank(line) {
1986
- return line != null;
1993
+ return typeof line !== 'undefined' && line !== null;
1987
1994
  }
1988
1995
  var msg = diff.createPatch('string', err.actual, err.expected);
1989
1996
  var lines = msg.split('\n').splice(4);
@@ -3120,7 +3127,7 @@ function Markdown(runner) {
3120
3127
  var key = SUITE_PREFIX + suite.title;
3121
3128
 
3122
3129
  obj = obj[key] = obj[key] || { suite: suite };
3123
- suite.suites.forEach(function() {
3130
+ suite.suites.forEach(function(suite) {
3124
3131
  mapTOC(suite, obj);
3125
3132
  });
3126
3133
 
@@ -3813,6 +3820,11 @@ function XUnit(runner, options) {
3813
3820
  });
3814
3821
  }
3815
3822
 
3823
+ /**
3824
+ * Inherit from `Base.prototype`.
3825
+ */
3826
+ inherits(XUnit, Base);
3827
+
3816
3828
  /**
3817
3829
  * Override done to close the stream (if it's a file).
3818
3830
  *
@@ -3829,11 +3841,6 @@ XUnit.prototype.done = function(failures, fn) {
3829
3841
  }
3830
3842
  };
3831
3843
 
3832
- /**
3833
- * Inherit from `Base.prototype`.
3834
- */
3835
- inherits(XUnit, Base);
3836
-
3837
3844
  /**
3838
3845
  * Write out the given line.
3839
3846
  *
@@ -4240,6 +4247,7 @@ var Pending = require('./pending');
4240
4247
  var utils = require('./utils');
4241
4248
  var inherits = utils.inherits;
4242
4249
  var debug = require('debug')('mocha:runner');
4250
+ var Runnable = require('./runnable');
4243
4251
  var filter = utils.filter;
4244
4252
  var indexOf = utils.indexOf;
4245
4253
  var keys = utils.keys;
@@ -4297,6 +4305,7 @@ function Runner(suite, delay) {
4297
4305
  this._abort = false;
4298
4306
  this._delay = delay;
4299
4307
  this.suite = suite;
4308
+ this.started = false;
4300
4309
  this.total = suite.total();
4301
4310
  this.failures = 0;
4302
4311
  this.on('test end', function(test) {
@@ -4519,12 +4528,13 @@ Runner.prototype.hook = function(name, fn) {
4519
4528
 
4520
4529
  self.emit('hook', hook);
4521
4530
 
4522
- hook.on('error', function(err) {
4523
- self.failHook(hook, err);
4524
- });
4531
+ if (!hook.listeners('error').length) {
4532
+ hook.on('error', function(err) {
4533
+ self.failHook(hook, err);
4534
+ });
4535
+ }
4525
4536
 
4526
4537
  hook.run(function(err) {
4527
- hook.removeAllListeners('error');
4528
4538
  var testError = hook.error();
4529
4539
  if (testError) {
4530
4540
  self.fail(self.test, testError);
@@ -4619,7 +4629,8 @@ Runner.prototype.hookDown = function(name, fn) {
4619
4629
  Runner.prototype.parents = function() {
4620
4630
  var suite = this.suite;
4621
4631
  var suites = [];
4622
- while (suite = suite.parent) {
4632
+ while (suite.parent) {
4633
+ suite = suite.parent;
4623
4634
  suites.push(suite);
4624
4635
  }
4625
4636
  return suites;
@@ -4885,7 +4896,20 @@ Runner.prototype.uncaught = function(err) {
4885
4896
  err.uncaught = true;
4886
4897
 
4887
4898
  var runnable = this.currentRunnable;
4899
+
4888
4900
  if (!runnable) {
4901
+ runnable = new Runnable('Uncaught error outside test suite');
4902
+ runnable.parent = this.suite;
4903
+
4904
+ if (this.started) {
4905
+ this.fail(runnable, err);
4906
+ } else {
4907
+ // Can't recover from this failure
4908
+ this.emit('start');
4909
+ this.fail(runnable, err);
4910
+ this.emit('end');
4911
+ }
4912
+
4889
4913
  return;
4890
4914
  }
4891
4915
 
@@ -4944,6 +4968,7 @@ Runner.prototype.run = function(fn) {
4944
4968
  }
4945
4969
 
4946
4970
  function start() {
4971
+ self.started = true;
4947
4972
  self.emit('start');
4948
4973
  self.runSuite(rootSuite, function() {
4949
4974
  debug('finished running');
@@ -5039,7 +5064,8 @@ function filterLeaks(ok, globals) {
5039
5064
  */
5040
5065
  function extraGlobals() {
5041
5066
  if (typeof process === 'object' && typeof process.version === 'string') {
5042
- var nodeVersion = process.version.split('.').reduce(function(a, v) {
5067
+ var parts = process.version.split('.');
5068
+ var nodeVersion = utils.reduce(parts, function(a, v) {
5043
5069
  return a << 8 | v;
5044
5070
  });
5045
5071
 
@@ -5054,7 +5080,7 @@ function extraGlobals() {
5054
5080
  }
5055
5081
 
5056
5082
  }).call(this,require('_process'),typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {})
5057
- },{"./pending":16,"./utils":39,"_process":51,"debug":2,"events":3}],37:[function(require,module,exports){
5083
+ },{"./pending":16,"./runnable":35,"./utils":39,"_process":51,"debug":2,"events":3}],37:[function(require,module,exports){
5058
5084
  /**
5059
5085
  * Module dependencies.
5060
5086
  */
@@ -6146,7 +6172,7 @@ exports.getError = function(err) {
6146
6172
  * @description
6147
6173
  * When invoking this function you get a filter function that get the Error.stack as an input,
6148
6174
  * and return a prettify output.
6149
- * (i.e: strip Mocha, node_modules, bower and componentJS from stack trace).
6175
+ * (i.e: strip Mocha and internal node functions from stack trace).
6150
6176
  * @returns {Function}
6151
6177
  */
6152
6178
  exports.stackTraceFilter = function() {
@@ -6158,14 +6184,10 @@ exports.stackTraceFilter = function() {
6158
6184
  : (typeof location === 'undefined' ? window.location : location).href.replace(/\/[^\/]*$/, '/');
6159
6185
 
6160
6186
  function isMochaInternal(line) {
6161
- return (~line.indexOf('node_modules' + slash + 'mocha'))
6162
- || (~line.indexOf('components' + slash + 'mochajs'))
6163
- || (~line.indexOf('components' + slash + 'mocha'));
6164
- }
6165
-
6166
- // node_modules, bower, componentJS
6167
- function isBrowserModule(line) {
6168
- return (~line.indexOf('node_modules')) || (~line.indexOf('components'));
6187
+ return (~line.indexOf('node_modules' + slash + 'mocha' + slash))
6188
+ || (~line.indexOf('components' + slash + 'mochajs' + slash))
6189
+ || (~line.indexOf('components' + slash + 'mocha' + slash))
6190
+ || (~line.indexOf(slash + 'mocha.js'));
6169
6191
  }
6170
6192
 
6171
6193
  function isNodeInternal(line) {
@@ -6181,11 +6203,11 @@ exports.stackTraceFilter = function() {
6181
6203
  stack = stack.split('\n');
6182
6204
 
6183
6205
  stack = exports.reduce(stack, function(list, line) {
6184
- if (is.node && (isMochaInternal(line) || isNodeInternal(line))) {
6206
+ if (isMochaInternal(line)) {
6185
6207
  return list;
6186
6208
  }
6187
6209
 
6188
- if (is.browser && (isBrowserModule(line))) {
6210
+ if (is.node && isNodeInternal(line)) {
6189
6211
  return list;
6190
6212
  }
6191
6213
 
@@ -6259,28 +6281,35 @@ var rootParent = {}
6259
6281
  * Browsers that support typed arrays are IE 10+, Firefox 4+, Chrome 7+, Safari 5.1+,
6260
6282
  * Opera 11.6+, iOS 4.2+.
6261
6283
  *
6284
+ * Due to various browser bugs, sometimes the Object implementation will be used even
6285
+ * when the browser supports typed arrays.
6286
+ *
6262
6287
  * Note:
6263
6288
  *
6264
- * - Implementation must support adding new properties to `Uint8Array` instances.
6265
- * Firefox 4-29 lacked support, fixed in Firefox 30+.
6266
- * See: https://bugzilla.mozilla.org/show_bug.cgi?id=695438.
6289
+ * - Firefox 4-29 lacks support for adding new properties to `Uint8Array` instances,
6290
+ * See: https://bugzilla.mozilla.org/show_bug.cgi?id=695438.
6267
6291
  *
6268
- * - Chrome 9-10 is missing the `TypedArray.prototype.subarray` function.
6292
+ * - Safari 5-7 lacks support for changing the `Object.prototype.constructor` property
6293
+ * on objects.
6269
6294
  *
6270
- * - IE10 has a broken `TypedArray.prototype.subarray` function which returns arrays of
6271
- * incorrect length in some situations.
6295
+ * - Chrome 9-10 is missing the `TypedArray.prototype.subarray` function.
6272
6296
  *
6273
- * We detect these buggy browsers and set `Buffer.TYPED_ARRAY_SUPPORT` to `false` so they will
6274
- * get the Object implementation, which is slower but will work correctly.
6297
+ * - IE10 has a broken `TypedArray.prototype.subarray` function which returns arrays of
6298
+ * incorrect length in some situations.
6299
+
6300
+ * We detect these buggy browsers and set `Buffer.TYPED_ARRAY_SUPPORT` to `false` so they
6301
+ * get the Object implementation, which is slower but behaves correctly.
6275
6302
  */
6276
6303
  Buffer.TYPED_ARRAY_SUPPORT = (function () {
6304
+ function Bar () {}
6277
6305
  try {
6278
- var buf = new ArrayBuffer(0)
6279
- var arr = new Uint8Array(buf)
6306
+ var arr = new Uint8Array(1)
6280
6307
  arr.foo = function () { return 42 }
6308
+ arr.constructor = Bar
6281
6309
  return arr.foo() === 42 && // typed array instances can be augmented
6310
+ arr.constructor === Bar && // constructor can be set
6282
6311
  typeof arr.subarray === 'function' && // chrome 9-10 lack `subarray`
6283
- new Uint8Array(1).subarray(1, 1).byteLength === 0 // ie10 has broken `subarray`
6312
+ arr.subarray(1, 1).byteLength === 0 // ie10 has broken `subarray`
6284
6313
  } catch (e) {
6285
6314
  return false
6286
6315
  }
@@ -6358,8 +6387,13 @@ function fromObject (that, object) {
6358
6387
  throw new TypeError('must start with number, buffer, array or string')
6359
6388
  }
6360
6389
 
6361
- if (typeof ArrayBuffer !== 'undefined' && object.buffer instanceof ArrayBuffer) {
6362
- return fromTypedArray(that, object)
6390
+ if (typeof ArrayBuffer !== 'undefined') {
6391
+ if (object.buffer instanceof ArrayBuffer) {
6392
+ return fromTypedArray(that, object)
6393
+ }
6394
+ if (object instanceof ArrayBuffer) {
6395
+ return fromArrayBuffer(that, object)
6396
+ }
6363
6397
  }
6364
6398
 
6365
6399
  if (object.length) return fromArrayLike(that, object)
@@ -6396,6 +6430,18 @@ function fromTypedArray (that, array) {
6396
6430
  return that
6397
6431
  }
6398
6432
 
6433
+ function fromArrayBuffer (that, array) {
6434
+ if (Buffer.TYPED_ARRAY_SUPPORT) {
6435
+ // Return an augmented `Uint8Array` instance, for best performance
6436
+ array.byteLength
6437
+ that = Buffer._augment(new Uint8Array(array))
6438
+ } else {
6439
+ // Fallback: Return an object instance of the Buffer class
6440
+ that = fromTypedArray(that, new Uint8Array(array))
6441
+ }
6442
+ return that
6443
+ }
6444
+
6399
6445
  function fromArrayLike (that, array) {
6400
6446
  var length = checked(array.length) | 0
6401
6447
  that = allocate(that, length)
@@ -6513,8 +6559,6 @@ Buffer.concat = function concat (list, length) {
6513
6559
 
6514
6560
  if (list.length === 0) {
6515
6561
  return new Buffer(0)
6516
- } else if (list.length === 1) {
6517
- return list[0]
6518
6562
  }
6519
6563
 
6520
6564
  var i
@@ -6689,13 +6733,13 @@ Buffer.prototype.indexOf = function indexOf (val, byteOffset) {
6689
6733
  throw new TypeError('val must be string, number or Buffer')
6690
6734
  }
6691
6735
 
6692
- // `get` will be removed in Node 0.13+
6736
+ // `get` is deprecated
6693
6737
  Buffer.prototype.get = function get (offset) {
6694
6738
  console.log('.get() is deprecated. Access using array indexes instead.')
6695
6739
  return this.readUInt8(offset)
6696
6740
  }
6697
6741
 
6698
- // `set` will be removed in Node 0.13+
6742
+ // `set` is deprecated
6699
6743
  Buffer.prototype.set = function set (v, offset) {
6700
6744
  console.log('.set() is deprecated. Access using array indexes instead.')
6701
6745
  return this.writeUInt8(v, offset)
@@ -6836,20 +6880,99 @@ function base64Slice (buf, start, end) {
6836
6880
  }
6837
6881
 
6838
6882
  function utf8Slice (buf, start, end) {
6839
- var res = ''
6840
- var tmp = ''
6841
6883
  end = Math.min(buf.length, end)
6884
+ var res = []
6885
+
6886
+ var i = start
6887
+ while (i < end) {
6888
+ var firstByte = buf[i]
6889
+ var codePoint = null
6890
+ var bytesPerSequence = (firstByte > 0xEF) ? 4
6891
+ : (firstByte > 0xDF) ? 3
6892
+ : (firstByte > 0xBF) ? 2
6893
+ : 1
6894
+
6895
+ if (i + bytesPerSequence <= end) {
6896
+ var secondByte, thirdByte, fourthByte, tempCodePoint
6897
+
6898
+ switch (bytesPerSequence) {
6899
+ case 1:
6900
+ if (firstByte < 0x80) {
6901
+ codePoint = firstByte
6902
+ }
6903
+ break
6904
+ case 2:
6905
+ secondByte = buf[i + 1]
6906
+ if ((secondByte & 0xC0) === 0x80) {
6907
+ tempCodePoint = (firstByte & 0x1F) << 0x6 | (secondByte & 0x3F)
6908
+ if (tempCodePoint > 0x7F) {
6909
+ codePoint = tempCodePoint
6910
+ }
6911
+ }
6912
+ break
6913
+ case 3:
6914
+ secondByte = buf[i + 1]
6915
+ thirdByte = buf[i + 2]
6916
+ if ((secondByte & 0xC0) === 0x80 && (thirdByte & 0xC0) === 0x80) {
6917
+ tempCodePoint = (firstByte & 0xF) << 0xC | (secondByte & 0x3F) << 0x6 | (thirdByte & 0x3F)
6918
+ if (tempCodePoint > 0x7FF && (tempCodePoint < 0xD800 || tempCodePoint > 0xDFFF)) {
6919
+ codePoint = tempCodePoint
6920
+ }
6921
+ }
6922
+ break
6923
+ case 4:
6924
+ secondByte = buf[i + 1]
6925
+ thirdByte = buf[i + 2]
6926
+ fourthByte = buf[i + 3]
6927
+ if ((secondByte & 0xC0) === 0x80 && (thirdByte & 0xC0) === 0x80 && (fourthByte & 0xC0) === 0x80) {
6928
+ tempCodePoint = (firstByte & 0xF) << 0x12 | (secondByte & 0x3F) << 0xC | (thirdByte & 0x3F) << 0x6 | (fourthByte & 0x3F)
6929
+ if (tempCodePoint > 0xFFFF && tempCodePoint < 0x110000) {
6930
+ codePoint = tempCodePoint
6931
+ }
6932
+ }
6933
+ }
6934
+ }
6842
6935
 
6843
- for (var i = start; i < end; i++) {
6844
- if (buf[i] <= 0x7F) {
6845
- res += decodeUtf8Char(tmp) + String.fromCharCode(buf[i])
6846
- tmp = ''
6847
- } else {
6848
- tmp += '%' + buf[i].toString(16)
6936
+ if (codePoint === null) {
6937
+ // we did not generate a valid codePoint so insert a
6938
+ // replacement char (U+FFFD) and advance only 1 byte
6939
+ codePoint = 0xFFFD
6940
+ bytesPerSequence = 1
6941
+ } else if (codePoint > 0xFFFF) {
6942
+ // encode to utf16 (surrogate pair dance)
6943
+ codePoint -= 0x10000
6944
+ res.push(codePoint >>> 10 & 0x3FF | 0xD800)
6945
+ codePoint = 0xDC00 | codePoint & 0x3FF
6849
6946
  }
6947
+
6948
+ res.push(codePoint)
6949
+ i += bytesPerSequence
6850
6950
  }
6851
6951
 
6852
- return res + decodeUtf8Char(tmp)
6952
+ return decodeCodePointsArray(res)
6953
+ }
6954
+
6955
+ // Based on http://stackoverflow.com/a/22747272/680742, the browser with
6956
+ // the lowest limit is Chrome, with 0x10000 args.
6957
+ // We go 1 magnitude less, for safety
6958
+ var MAX_ARGUMENTS_LENGTH = 0x1000
6959
+
6960
+ function decodeCodePointsArray (codePoints) {
6961
+ var len = codePoints.length
6962
+ if (len <= MAX_ARGUMENTS_LENGTH) {
6963
+ return String.fromCharCode.apply(String, codePoints) // avoid extra slice()
6964
+ }
6965
+
6966
+ // Decode in chunks to avoid "call stack size exceeded".
6967
+ var res = ''
6968
+ var i = 0
6969
+ while (i < len) {
6970
+ res += String.fromCharCode.apply(
6971
+ String,
6972
+ codePoints.slice(i, i += MAX_ARGUMENTS_LENGTH)
6973
+ )
6974
+ }
6975
+ return res
6853
6976
  }
6854
6977
 
6855
6978
  function asciiSlice (buf, start, end) {
@@ -7384,9 +7507,16 @@ Buffer.prototype.copy = function copy (target, targetStart, start, end) {
7384
7507
  }
7385
7508
 
7386
7509
  var len = end - start
7510
+ var i
7387
7511
 
7388
- if (len < 1000 || !Buffer.TYPED_ARRAY_SUPPORT) {
7389
- for (var i = 0; i < len; i++) {
7512
+ if (this === target && start < targetStart && targetStart < end) {
7513
+ // descending copy from end
7514
+ for (i = len - 1; i >= 0; i--) {
7515
+ target[i + targetStart] = this[i + start]
7516
+ }
7517
+ } else if (len < 1000 || !Buffer.TYPED_ARRAY_SUPPORT) {
7518
+ // ascending copy from start
7519
+ for (i = 0; i < len; i++) {
7390
7520
  target[i + targetStart] = this[i + start]
7391
7521
  }
7392
7522
  } else {
@@ -7462,7 +7592,7 @@ Buffer._augment = function _augment (arr) {
7462
7592
  // save reference to original Uint8Array set method before overwriting
7463
7593
  arr._set = arr.set
7464
7594
 
7465
- // deprecated, will be removed in node 0.13+
7595
+ // deprecated
7466
7596
  arr.get = BP.get
7467
7597
  arr.set = BP.set
7468
7598
 
@@ -7518,7 +7648,7 @@ Buffer._augment = function _augment (arr) {
7518
7648
  return arr
7519
7649
  }
7520
7650
 
7521
- var INVALID_BASE64_RE = /[^+\/0-9A-z\-]/g
7651
+ var INVALID_BASE64_RE = /[^+\/0-9A-Za-z-_]/g
7522
7652
 
7523
7653
  function base64clean (str) {
7524
7654
  // Node strips out invalid characters like \n and \t from the string, base64-js does not
@@ -7548,28 +7678,15 @@ function utf8ToBytes (string, units) {
7548
7678
  var length = string.length
7549
7679
  var leadSurrogate = null
7550
7680
  var bytes = []
7551
- var i = 0
7552
7681
 
7553
- for (; i < length; i++) {
7682
+ for (var i = 0; i < length; i++) {
7554
7683
  codePoint = string.charCodeAt(i)
7555
7684
 
7556
7685
  // is surrogate component
7557
7686
  if (codePoint > 0xD7FF && codePoint < 0xE000) {
7558
7687
  // last char was a lead
7559
- if (leadSurrogate) {
7560
- // 2 leads in a row
7561
- if (codePoint < 0xDC00) {
7562
- if ((units -= 3) > -1) bytes.push(0xEF, 0xBF, 0xBD)
7563
- leadSurrogate = codePoint
7564
- continue
7565
- } else {
7566
- // valid surrogate pair
7567
- codePoint = leadSurrogate - 0xD800 << 10 | codePoint - 0xDC00 | 0x10000
7568
- leadSurrogate = null
7569
- }
7570
- } else {
7688
+ if (!leadSurrogate) {
7571
7689
  // no lead yet
7572
-
7573
7690
  if (codePoint > 0xDBFF) {
7574
7691
  // unexpected trail
7575
7692
  if ((units -= 3) > -1) bytes.push(0xEF, 0xBF, 0xBD)
@@ -7578,18 +7695,30 @@ function utf8ToBytes (string, units) {
7578
7695
  // unpaired lead
7579
7696
  if ((units -= 3) > -1) bytes.push(0xEF, 0xBF, 0xBD)
7580
7697
  continue
7581
- } else {
7582
- // valid lead
7583
- leadSurrogate = codePoint
7584
- continue
7585
7698
  }
7699
+
7700
+ // valid lead
7701
+ leadSurrogate = codePoint
7702
+
7703
+ continue
7586
7704
  }
7705
+
7706
+ // 2 leads in a row
7707
+ if (codePoint < 0xDC00) {
7708
+ if ((units -= 3) > -1) bytes.push(0xEF, 0xBF, 0xBD)
7709
+ leadSurrogate = codePoint
7710
+ continue
7711
+ }
7712
+
7713
+ // valid surrogate pair
7714
+ codePoint = leadSurrogate - 0xD800 << 10 | codePoint - 0xDC00 | 0x10000
7587
7715
  } else if (leadSurrogate) {
7588
7716
  // valid bmp char, but last char was a lead
7589
7717
  if ((units -= 3) > -1) bytes.push(0xEF, 0xBF, 0xBD)
7590
- leadSurrogate = null
7591
7718
  }
7592
7719
 
7720
+ leadSurrogate = null
7721
+
7593
7722
  // encode utf8
7594
7723
  if (codePoint < 0x80) {
7595
7724
  if ((units -= 1) < 0) break
@@ -7607,7 +7736,7 @@ function utf8ToBytes (string, units) {
7607
7736
  codePoint >> 0x6 & 0x3F | 0x80,
7608
7737
  codePoint & 0x3F | 0x80
7609
7738
  )
7610
- } else if (codePoint < 0x200000) {
7739
+ } else if (codePoint < 0x110000) {
7611
7740
  if ((units -= 4) < 0) break
7612
7741
  bytes.push(
7613
7742
  codePoint >> 0x12 | 0xF0,
@@ -7660,14 +7789,6 @@ function blitBuffer (src, dst, offset, length) {
7660
7789
  return i
7661
7790
  }
7662
7791
 
7663
- function decodeUtf8Char (str) {
7664
- try {
7665
- return decodeURIComponent(str)
7666
- } catch (err) {
7667
- return String.fromCharCode(0xFFFD) // UTF 8 invalid char
7668
- }
7669
- }
7670
-
7671
7792
  },{"base64-js":44,"ieee754":45,"is-array":46}],44:[function(require,module,exports){
7672
7793
  var lookup = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/';
7673
7794
 
@@ -8328,7 +8449,9 @@ function drainQueue() {
8328
8449
  currentQueue = queue;
8329
8450
  queue = [];
8330
8451
  while (++queueIndex < len) {
8331
- currentQueue[queueIndex].run();
8452
+ if (currentQueue) {
8453
+ currentQueue[queueIndex].run();
8454
+ }
8332
8455
  }
8333
8456
  queueIndex = -1;
8334
8457
  len = queue.length;
@@ -8380,7 +8503,6 @@ process.binding = function (name) {
8380
8503
  throw new Error('process.binding is not supported');
8381
8504
  };
8382
8505
 
8383
- // TODO(shtylman)
8384
8506
  process.cwd = function () { return '/' };
8385
8507
  process.chdir = function (dir) {
8386
8508
  throw new Error('process.chdir is not supported');
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "mocha",
3
- "version": "2.3.2",
3
+ "version": "2.3.3",
4
4
  "description": "simple, flexible, fun test framework",
5
5
  "keywords": [
6
6
  "mocha",
@@ -280,7 +280,7 @@
280
280
  "escape-string-regexp": "1.0.2",
281
281
  "glob": "3.2.3",
282
282
  "growl": "1.8.1",
283
- "jade": "1.11.0",
283
+ "jade": "0.26.3",
284
284
  "mkdirp": "0.5.0",
285
285
  "supports-color": "1.2.0"
286
286
  },