stylus-source 0.31.0 → 0.32.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (143) hide show
  1. checksums.yaml +7 -0
  2. data/VERSION +1 -1
  3. data/vendor/lib/nodes/unit.js +1 -1
  4. data/vendor/lib/parser.js +0 -1
  5. data/vendor/lib/renderer.js +2 -0
  6. data/vendor/lib/visitor/compiler.js +6 -0
  7. data/vendor/node_modules/cssom/README.mdown +34 -0
  8. data/vendor/node_modules/cssom/package.json +2 -1
  9. data/vendor/node_modules/debug/History.md +15 -0
  10. data/vendor/node_modules/debug/Readme.md +3 -18
  11. data/vendor/node_modules/debug/component.json +9 -0
  12. data/vendor/node_modules/debug/debug.js +10 -2
  13. data/vendor/node_modules/debug/index.js +5 -2
  14. data/vendor/node_modules/debug/lib/debug.js +5 -6
  15. data/vendor/node_modules/debug/package.json +11 -6
  16. data/vendor/node_modules/mkdirp/package.json +6 -9
  17. data/vendor/node_modules/mkdirp/{README.markdown → readme.markdown} +26 -24
  18. data/vendor/node_modules/mocha/History.md +140 -58
  19. data/vendor/node_modules/mocha/LICENSE +2 -2
  20. data/vendor/node_modules/mocha/Makefile +20 -5
  21. data/vendor/node_modules/mocha/Readme.md +110 -22
  22. data/vendor/node_modules/mocha/_mocha.js +574 -182
  23. data/vendor/node_modules/mocha/bin/_mocha +39 -22
  24. data/vendor/node_modules/mocha/bin/mocha +6 -2
  25. data/vendor/node_modules/mocha/component.json +16 -0
  26. data/vendor/node_modules/mocha/lib/browser/debug.js +1 -2
  27. data/vendor/node_modules/mocha/lib/browser/diff.js +287 -0
  28. data/vendor/node_modules/mocha/lib/browser/tty.js +7 -2
  29. data/vendor/node_modules/mocha/lib/hook.js +0 -1
  30. data/vendor/node_modules/mocha/lib/interfaces/bdd.js +3 -3
  31. data/vendor/node_modules/mocha/lib/interfaces/exports.js +5 -5
  32. data/vendor/node_modules/mocha/lib/interfaces/qunit.js +38 -9
  33. data/vendor/node_modules/mocha/lib/interfaces/tdd.js +15 -2
  34. data/vendor/node_modules/mocha/lib/mocha.js +20 -4
  35. data/vendor/node_modules/mocha/lib/reporters/base.js +57 -37
  36. data/vendor/node_modules/mocha/lib/reporters/html.js +2 -4
  37. data/vendor/node_modules/mocha/lib/reporters/json-stream.js +4 -14
  38. data/vendor/node_modules/mocha/lib/reporters/json.js +9 -19
  39. data/vendor/node_modules/mocha/lib/reporters/markdown.js +0 -1
  40. data/vendor/node_modules/mocha/lib/reporters/min.js +2 -2
  41. data/vendor/node_modules/mocha/lib/reporters/nyan.js +33 -39
  42. data/vendor/node_modules/mocha/lib/reporters/tap.js +12 -2
  43. data/vendor/node_modules/mocha/lib/reporters/templates/coverage.jade +3 -3
  44. data/vendor/node_modules/mocha/lib/reporters/templates/menu.jade +1 -1
  45. data/vendor/node_modules/mocha/lib/reporters/xunit.js +4 -4
  46. data/vendor/node_modules/mocha/lib/runnable.js +7 -9
  47. data/vendor/node_modules/mocha/lib/runner.js +24 -9
  48. data/vendor/node_modules/mocha/lib/template.html +2 -1
  49. data/vendor/node_modules/mocha/lib/utils.js +3 -3
  50. data/vendor/node_modules/mocha/mocha.css +37 -13
  51. data/vendor/node_modules/mocha/mocha.js +661 -253
  52. data/vendor/node_modules/mocha/node_modules/commander/package.json +5 -1
  53. data/vendor/node_modules/mocha/node_modules/diff/package.json +5 -1
  54. data/vendor/node_modules/mocha/node_modules/glob/LICENSE +27 -0
  55. data/vendor/node_modules/mocha/node_modules/glob/README.md +250 -0
  56. data/vendor/node_modules/mocha/node_modules/glob/examples/g.js +9 -0
  57. data/vendor/node_modules/mocha/node_modules/glob/examples/usr-local.js +9 -0
  58. data/vendor/node_modules/mocha/node_modules/glob/glob.js +675 -0
  59. data/vendor/node_modules/mocha/node_modules/glob/node_modules/graceful-fs/LICENSE +27 -0
  60. data/vendor/node_modules/mocha/node_modules/glob/node_modules/graceful-fs/README.md +33 -0
  61. data/vendor/node_modules/mocha/node_modules/glob/node_modules/graceful-fs/graceful-fs.js +442 -0
  62. data/vendor/node_modules/mocha/node_modules/glob/node_modules/graceful-fs/package.json +49 -0
  63. data/vendor/node_modules/mocha/node_modules/glob/node_modules/graceful-fs/test/open.js +46 -0
  64. data/vendor/node_modules/mocha/node_modules/glob/node_modules/graceful-fs/test/ulimit.js +158 -0
  65. data/vendor/node_modules/mocha/node_modules/glob/node_modules/inherits/README.md +51 -0
  66. data/vendor/node_modules/mocha/node_modules/glob/node_modules/inherits/inherits.js +29 -0
  67. data/vendor/node_modules/mocha/node_modules/glob/node_modules/inherits/package.json +26 -0
  68. data/vendor/node_modules/mocha/node_modules/glob/node_modules/minimatch/LICENSE +23 -0
  69. data/vendor/node_modules/mocha/node_modules/glob/node_modules/minimatch/README.md +218 -0
  70. data/vendor/node_modules/mocha/node_modules/glob/node_modules/minimatch/minimatch.js +1079 -0
  71. data/vendor/node_modules/mocha/node_modules/glob/node_modules/minimatch/node_modules/lru-cache/AUTHORS +8 -0
  72. data/vendor/node_modules/mocha/node_modules/glob/node_modules/minimatch/node_modules/lru-cache/LICENSE +23 -0
  73. data/vendor/node_modules/mocha/node_modules/glob/node_modules/minimatch/node_modules/lru-cache/README.md +97 -0
  74. data/vendor/node_modules/mocha/node_modules/glob/node_modules/minimatch/node_modules/lru-cache/lib/lru-cache.js +257 -0
  75. data/vendor/node_modules/mocha/node_modules/glob/node_modules/minimatch/node_modules/lru-cache/package.json +59 -0
  76. data/vendor/node_modules/mocha/node_modules/glob/node_modules/minimatch/node_modules/lru-cache/s.js +25 -0
  77. data/vendor/node_modules/mocha/node_modules/glob/node_modules/minimatch/node_modules/lru-cache/test/basic.js +329 -0
  78. data/vendor/node_modules/mocha/node_modules/glob/node_modules/minimatch/node_modules/lru-cache/test/foreach.js +52 -0
  79. data/vendor/node_modules/mocha/node_modules/glob/node_modules/minimatch/node_modules/lru-cache/test/memory-leak.js +50 -0
  80. data/vendor/node_modules/mocha/node_modules/glob/node_modules/minimatch/node_modules/sigmund/LICENSE +27 -0
  81. data/vendor/node_modules/mocha/node_modules/glob/node_modules/minimatch/node_modules/sigmund/README.md +53 -0
  82. data/vendor/node_modules/mocha/node_modules/glob/node_modules/minimatch/node_modules/sigmund/bench.js +283 -0
  83. data/vendor/node_modules/mocha/node_modules/glob/node_modules/minimatch/node_modules/sigmund/package.json +38 -0
  84. data/vendor/node_modules/mocha/node_modules/glob/node_modules/minimatch/node_modules/sigmund/sigmund.js +39 -0
  85. data/vendor/node_modules/mocha/node_modules/glob/node_modules/minimatch/node_modules/sigmund/test/basic.js +24 -0
  86. data/vendor/node_modules/mocha/node_modules/glob/node_modules/minimatch/package.json +36 -0
  87. data/vendor/node_modules/mocha/node_modules/glob/node_modules/minimatch/test/basic.js +399 -0
  88. data/vendor/node_modules/mocha/node_modules/glob/node_modules/minimatch/test/brace-expand.js +33 -0
  89. data/vendor/node_modules/mocha/node_modules/glob/node_modules/minimatch/test/caching.js +14 -0
  90. data/vendor/node_modules/mocha/node_modules/glob/node_modules/minimatch/test/defaults.js +274 -0
  91. data/vendor/node_modules/mocha/node_modules/glob/package.json +40 -0
  92. data/vendor/node_modules/mocha/node_modules/glob/test/00-setup.js +176 -0
  93. data/vendor/node_modules/mocha/node_modules/glob/test/bash-comparison.js +63 -0
  94. data/vendor/node_modules/mocha/node_modules/glob/test/bash-results.json +350 -0
  95. data/vendor/node_modules/mocha/node_modules/glob/test/cwd-test.js +55 -0
  96. data/vendor/node_modules/mocha/node_modules/glob/test/globstar-match.js +19 -0
  97. data/vendor/node_modules/mocha/node_modules/glob/test/mark.js +74 -0
  98. data/vendor/node_modules/mocha/node_modules/glob/test/nocase-nomagic.js +113 -0
  99. data/vendor/node_modules/mocha/node_modules/glob/test/pause-resume.js +73 -0
  100. data/vendor/node_modules/mocha/node_modules/glob/test/root-nomount.js +39 -0
  101. data/vendor/node_modules/mocha/node_modules/glob/test/root.js +46 -0
  102. data/vendor/node_modules/mocha/node_modules/glob/test/stat.js +32 -0
  103. data/vendor/node_modules/mocha/node_modules/glob/test/zz-cleanup.js +11 -0
  104. data/vendor/node_modules/mocha/node_modules/growl/History.md +5 -0
  105. data/vendor/node_modules/mocha/node_modules/growl/lib/growl.js +2 -0
  106. data/vendor/node_modules/mocha/node_modules/growl/package.json +7 -3
  107. data/vendor/node_modules/mocha/node_modules/jade/node_modules/mkdirp/package.json +5 -1
  108. data/vendor/node_modules/mocha/node_modules/jade/package.json +5 -1
  109. data/vendor/node_modules/mocha/node_modules/ms/package.json +5 -1
  110. data/vendor/node_modules/mocha/package.json +13 -7
  111. data/vendor/node_modules/mocha/test.js +10 -21
  112. data/vendor/node_modules/should/History.md +5 -0
  113. data/vendor/node_modules/should/Readme.md +172 -172
  114. data/vendor/node_modules/should/lib/eql.js +2 -0
  115. data/vendor/node_modules/should/lib/should.js +4 -3
  116. data/vendor/node_modules/should/package.json +8 -4
  117. data/vendor/node_modules/should/test/should.test.js +27 -0
  118. data/vendor/package.json +1 -1
  119. metadata +61 -35
  120. data/vendor/node_modules/debug/Makefile +0 -4
  121. data/vendor/node_modules/debug/debug.component.js +0 -120
  122. data/vendor/node_modules/debug/head.js +0 -1
  123. data/vendor/node_modules/debug/tail.js +0 -4
  124. data/vendor/node_modules/mocha/node_modules/mkdirp/LICENSE +0 -21
  125. data/vendor/node_modules/mocha/node_modules/mkdirp/README.markdown +0 -61
  126. data/vendor/node_modules/mocha/node_modules/mkdirp/examples/pow.js +0 -6
  127. data/vendor/node_modules/mocha/node_modules/mkdirp/examples/pow.js.orig +0 -6
  128. data/vendor/node_modules/mocha/node_modules/mkdirp/examples/pow.js.rej +0 -19
  129. data/vendor/node_modules/mocha/node_modules/mkdirp/index.js +0 -94
  130. data/vendor/node_modules/mocha/node_modules/mkdirp/package.json +0 -33
  131. data/vendor/node_modules/mocha/node_modules/mkdirp/test/chmod.js +0 -38
  132. data/vendor/node_modules/mocha/node_modules/mkdirp/test/clobber.js +0 -37
  133. data/vendor/node_modules/mocha/node_modules/mkdirp/test/mkdirp.js +0 -28
  134. data/vendor/node_modules/mocha/node_modules/mkdirp/test/perm.js +0 -32
  135. data/vendor/node_modules/mocha/node_modules/mkdirp/test/perm_sync.js +0 -39
  136. data/vendor/node_modules/mocha/node_modules/mkdirp/test/race.js +0 -41
  137. data/vendor/node_modules/mocha/node_modules/mkdirp/test/rel.js +0 -32
  138. data/vendor/node_modules/mocha/node_modules/mkdirp/test/return.js +0 -25
  139. data/vendor/node_modules/mocha/node_modules/mkdirp/test/return_sync.js +0 -24
  140. data/vendor/node_modules/mocha/node_modules/mkdirp/test/root.js +0 -18
  141. data/vendor/node_modules/mocha/node_modules/mkdirp/test/sync.js +0 -32
  142. data/vendor/node_modules/mocha/node_modules/mkdirp/test/umask.js +0 -28
  143. data/vendor/node_modules/mocha/node_modules/mkdirp/test/umask_sync.js +0 -32
@@ -52,6 +52,7 @@ function image(name) {
52
52
  * - `reporter` reporter instance, defaults to `mocha.reporters.Dot`
53
53
  * - `globals` array of accepted globals
54
54
  * - `timeout` timeout in milliseconds
55
+ * - `bail` bail on the first test failure
55
56
  * - `slow` milliseconds to wait before considering a test slow
56
57
  * - `ignoreLeaks` ignore global leaks
57
58
  * - `grep` string or regexp to filter tests with
@@ -67,11 +68,25 @@ function Mocha(options) {
67
68
  this.grep(options.grep);
68
69
  this.suite = new exports.Suite('', new exports.Context);
69
70
  this.ui(options.ui);
71
+ this.bail(options.bail);
70
72
  this.reporter(options.reporter);
71
73
  if (options.timeout) this.timeout(options.timeout);
72
74
  if (options.slow) this.slow(options.slow);
73
75
  }
74
76
 
77
+ /**
78
+ * Enable or disable bailing on the first failure.
79
+ *
80
+ * @param {Boolean} [bail]
81
+ * @api public
82
+ */
83
+
84
+ Mocha.prototype.bail = function(bail){
85
+ if (0 == arguments.length) bail = true;
86
+ this.suite.bail(bail);
87
+ return this;
88
+ };
89
+
75
90
  /**
76
91
  * Add test `file`.
77
92
  *
@@ -87,7 +102,7 @@ Mocha.prototype.addFile = function(file){
87
102
  /**
88
103
  * Set reporter to `reporter`, defaults to "dot".
89
104
  *
90
- * @param {String|Function} reporter name of a reporter or a reporter constructor
105
+ * @param {String|Function} reporter name or constructor
91
106
  * @api public
92
107
  */
93
108
 
@@ -194,12 +209,13 @@ Mocha.prototype.invert = function(){
194
209
  /**
195
210
  * Ignore global leaks.
196
211
  *
212
+ * @param {Boolean} ignore
197
213
  * @return {Mocha}
198
214
  * @api public
199
215
  */
200
216
 
201
- Mocha.prototype.ignoreLeaks = function(){
202
- this.options.ignoreLeaks = true;
217
+ Mocha.prototype.ignoreLeaks = function(ignore){
218
+ this.options.ignoreLeaks = !!ignore;
203
219
  return this;
204
220
  };
205
221
 
@@ -292,7 +308,7 @@ Mocha.prototype.run = function(fn){
292
308
  var options = this.options;
293
309
  var runner = new exports.Runner(suite);
294
310
  var reporter = new this._reporter(runner);
295
- runner.ignoreLeaks = options.ignoreLeaks;
311
+ runner.ignoreLeaks = false !== options.ignoreLeaks;
296
312
  runner.asyncOnly = options.asyncOnly;
297
313
  if (options.grep) runner.grep(options.grep, options.invert);
298
314
  if (options.globals) runner.globals(options.globals);
@@ -64,7 +64,7 @@ exports.colors = {
64
64
  /**
65
65
  * Default symbol map.
66
66
  */
67
-
67
+
68
68
  exports.symbols = {
69
69
  ok: '✓',
70
70
  err: '✖',
@@ -161,19 +161,21 @@ exports.list = function(failures){
161
161
  , expected = err.expected
162
162
  , escape = true;
163
163
 
164
+ // uncaught
165
+ if (err.uncaught) {
166
+ msg = 'Uncaught ' + msg;
167
+ }
168
+
164
169
  // explicitly show diff
165
- if (err.showDiff) {
170
+ if (err.showDiff && sameType(actual, expected)) {
166
171
  escape = false;
167
- err.actual = actual = JSON.stringify(actual, null, 2);
168
- err.expected = expected = JSON.stringify(expected, null, 2);
172
+ err.actual = actual = stringify(actual);
173
+ err.expected = expected = stringify(expected);
169
174
  }
170
175
 
171
176
  // actual / expected diff
172
177
  if ('string' == typeof actual && 'string' == typeof expected) {
173
- var len = Math.max(actual.length, expected.length);
174
-
175
- if (len < 20) msg = errorDiff(err, 'Chars', escape);
176
- else msg = errorDiff(err, 'Words', escape);
178
+ msg = errorDiff(err, 'Words', escape);
177
179
 
178
180
  // linenos
179
181
  var lines = msg.split('\n');
@@ -282,48 +284,38 @@ function Base(runner) {
282
284
  */
283
285
 
284
286
  Base.prototype.epilogue = function(){
285
- var stats = this.stats
286
- , fmt
287
- , tests;
287
+ var stats = this.stats;
288
+ var tests;
289
+ var fmt;
288
290
 
289
291
  console.log();
290
292
 
291
- function pluralize(n) {
292
- return 1 == n ? 'test' : 'tests';
293
- }
294
-
295
- // failure
296
- if (stats.failures) {
297
- fmt = color('bright fail', ' ' + exports.symbols.err)
298
- + color('fail', ' %d of %d %s failed')
299
- + color('light', ':')
300
-
301
- console.error(fmt,
302
- stats.failures,
303
- this.runner.total,
304
- pluralize(this.runner.total));
305
-
306
- Base.list(this.failures);
307
- console.error();
308
- return;
309
- }
310
-
311
- // pass
293
+ // passes
312
294
  fmt = color('bright pass', ' ')
313
- + color('green', ' %d %s complete')
295
+ + color('green', ' %d passing')
314
296
  + color('light', ' (%s)');
315
297
 
316
298
  console.log(fmt,
317
- stats.tests || 0,
318
- pluralize(stats.tests),
299
+ stats.passes || 0,
319
300
  ms(stats.duration));
320
301
 
321
302
  // pending
322
303
  if (stats.pending) {
323
304
  fmt = color('pending', ' ')
324
- + color('pending', ' %d %s pending');
305
+ + color('pending', ' %d pending');
325
306
 
326
- console.log(fmt, stats.pending, pluralize(stats.pending));
307
+ console.log(fmt, stats.pending);
308
+ }
309
+
310
+ // failures
311
+ if (stats.failures) {
312
+ fmt = color('fail', ' %d failing');
313
+
314
+ console.error(fmt,
315
+ stats.failures);
316
+
317
+ Base.list(this.failures);
318
+ console.error();
327
319
  }
328
320
 
329
321
  console.log();
@@ -379,3 +371,31 @@ function colorLines(name, str) {
379
371
  return color(name, str);
380
372
  }).join('\n');
381
373
  }
374
+
375
+ /**
376
+ * Stringify `obj`.
377
+ *
378
+ * @param {Mixed} obj
379
+ * @return {String}
380
+ * @api private
381
+ */
382
+
383
+ function stringify(obj) {
384
+ if (obj instanceof RegExp) return obj.toString();
385
+ return JSON.stringify(obj, null, 2);
386
+ }
387
+
388
+ /**
389
+ * Check that a / b have the same type.
390
+ *
391
+ * @param {Object} a
392
+ * @param {Object} b
393
+ * @return {Boolean}
394
+ * @api private
395
+ */
396
+
397
+ function sameType(a, b) {
398
+ a = Object.prototype.toString.call(a);
399
+ b = Object.prototype.toString.call(b);
400
+ return a == b;
401
+ }
@@ -116,12 +116,10 @@ function HTML(runner, root) {
116
116
  });
117
117
 
118
118
  runner.on('fail', function(test, err){
119
- if ('hook' == test.type || err.uncaught) runner.emit('test end', test);
119
+ if ('hook' == test.type) runner.emit('test end', test);
120
120
  });
121
121
 
122
122
  runner.on('test end', function(test){
123
- window.scrollTo(0, document.body.scrollHeight);
124
-
125
123
  // TODO: add to stats
126
124
  var percent = stats.tests / this.total * 100 | 0;
127
125
  if (progress) progress.update(percent).draw(ctx);
@@ -165,7 +163,7 @@ function HTML(runner, root) {
165
163
 
166
164
  on(h2, 'click', function(){
167
165
  pre.style.display = 'none' == pre.style.display
168
- ? 'inline-block'
166
+ ? 'block'
169
167
  : 'none';
170
168
  });
171
169
 
@@ -35,7 +35,6 @@ function List(runner) {
35
35
  });
36
36
 
37
37
  runner.on('fail', function(test, err){
38
- test.error = err;
39
38
  console.log(JSON.stringify(['fail', clean(test)]));
40
39
  });
41
40
 
@@ -54,18 +53,9 @@ function List(runner) {
54
53
  */
55
54
 
56
55
  function clean(test) {
57
- var obj = {
58
- title: test.title,
59
- fullTitle: test.fullTitle(),
60
- duration: test.duration
61
- };
62
-
63
- if (test.error) {
64
- obj.error = {
65
- message: test.error.message,
66
- stack: test.error.stack
67
- };
56
+ return {
57
+ title: test.title
58
+ , fullTitle: test.fullTitle()
59
+ , duration: test.duration
68
60
  }
69
-
70
- return obj;
71
61
  }
@@ -36,17 +36,16 @@ function JSONReporter(runner) {
36
36
  passes.push(test);
37
37
  });
38
38
 
39
- runner.on('fail', function(test, err){
40
- test.error = err;
39
+ runner.on('fail', function(test){
41
40
  failures.push(test);
42
41
  });
43
42
 
44
43
  runner.on('end', function(){
45
44
  var obj = {
46
- stats: self.stats,
47
- tests: tests.map(clean),
48
- failures: failures.map(clean),
49
- passes: passes.map(clean)
45
+ stats: self.stats
46
+ , tests: tests.map(clean)
47
+ , failures: failures.map(clean)
48
+ , passes: passes.map(clean)
50
49
  };
51
50
 
52
51
  process.stdout.write(JSON.stringify(obj, null, 2));
@@ -63,18 +62,9 @@ function JSONReporter(runner) {
63
62
  */
64
63
 
65
64
  function clean(test) {
66
- var obj = {
67
- title: test.title,
68
- fullTitle: test.fullTitle(),
69
- duration: test.duration
70
- };
71
-
72
- if (test.error) {
73
- obj.error = {
74
- message: test.error.message,
75
- stack: test.error.stack
76
- };
65
+ return {
66
+ title: test.title
67
+ , fullTitle: test.fullTitle()
68
+ , duration: test.duration
77
69
  }
78
-
79
- return obj;
80
70
  }
@@ -23,7 +23,6 @@ function Markdown(runner) {
23
23
 
24
24
  var self = this
25
25
  , stats = this.stats
26
- , total = runner.total
27
26
  , level = 0
28
27
  , buf = '';
29
28
 
@@ -20,7 +20,7 @@ exports = module.exports = Min;
20
20
 
21
21
  function Min(runner) {
22
22
  Base.call(this, runner);
23
-
23
+
24
24
  runner.on('start', function(){
25
25
  // clear screen
26
26
  process.stdout.write('\u001b[2J');
@@ -35,4 +35,4 @@ function Min(runner) {
35
35
  * Inherit from `Base.prototype`.
36
36
  */
37
37
 
38
- Min.prototype.__proto__ = Base.prototype;
38
+ Min.prototype.__proto__ = Base.prototype;
@@ -1,4 +1,3 @@
1
-
2
1
  /**
3
2
  * Module dependencies.
4
3
  */
@@ -144,44 +143,39 @@ NyanCat.prototype.drawRainbow = function(){
144
143
  NyanCat.prototype.drawNyanCat = function(status) {
145
144
  var self = this;
146
145
  var startWidth = this.scoreboardWidth + this.trajectories[0].length;
147
-
148
- [0, 1, 2, 3].forEach(function(index) {
149
- write('\u001b[' + startWidth + 'C');
150
-
151
- switch (index) {
152
- case 0:
153
- write('_,------,');
154
- write('\n');
155
- break;
156
- case 1:
157
- var padding = self.tick ? ' ' : ' ';
158
- write('_|' + padding + '/\\_/\\ ');
159
- write('\n');
160
- break;
161
- case 2:
162
- var padding = self.tick ? '_' : '__';
163
- var tail = self.tick ? '~' : '^';
164
- var face;
165
- switch (status) {
166
- case 'pass':
167
- face = '( ^ .^)';
168
- break;
169
- case 'fail':
170
- face = '( o .o)';
171
- break;
172
- default:
173
- face = '( - .-)';
174
- }
175
- write(tail + '|' + padding + face + ' ');
176
- write('\n');
177
- break;
178
- case 3:
179
- var padding = self.tick ? ' ' : ' ';
180
- write(padding + '"" "" ');
181
- write('\n');
182
- break;
183
- }
184
- });
146
+ var color = '\u001b[' + startWidth + 'C';
147
+ var padding = '';
148
+
149
+ write(color);
150
+ write('_,------,');
151
+ write('\n');
152
+
153
+ write(color);
154
+ padding = self.tick ? ' ' : ' ';
155
+ write('_|' + padding + '/\\_/\\ ');
156
+ write('\n');
157
+
158
+ write(color);
159
+ padding = self.tick ? '_' : '__';
160
+ var tail = self.tick ? '~' : '^';
161
+ var face;
162
+ switch (status) {
163
+ case 'pass':
164
+ face = '( ^ .^)';
165
+ break;
166
+ case 'fail':
167
+ face = '( o .o)';
168
+ break;
169
+ default:
170
+ face = '( - .-)';
171
+ }
172
+ write(tail + '|' + padding + face + ' ');
173
+ write('\n');
174
+
175
+ write(color);
176
+ padding = self.tick ? ' ' : ' ';
177
+ write(padding + '"" "" ');
178
+ write('\n');
185
179
 
186
180
  this.cursorUp(this.numberOfLines);
187
181
  };
@@ -25,7 +25,9 @@ function TAP(runner) {
25
25
 
26
26
  var self = this
27
27
  , stats = this.stats
28
- , n = 1;
28
+ , n = 1
29
+ , passes = 0
30
+ , failures = 0;
29
31
 
30
32
  runner.on('start', function(){
31
33
  var total = runner.grepTotal(runner.suite);
@@ -41,12 +43,20 @@ function TAP(runner) {
41
43
  });
42
44
 
43
45
  runner.on('pass', function(test){
46
+ passes++;
44
47
  console.log('ok %d %s', n, title(test));
45
48
  });
46
49
 
47
50
  runner.on('fail', function(test, err){
51
+ failures++;
48
52
  console.log('not ok %d %s', n, title(test));
49
- console.log(err.stack.replace(/^/gm, ' '));
53
+ if (err.stack) console.log(err.stack.replace(/^/gm, ' '));
54
+ });
55
+
56
+ runner.on('end', function(){
57
+ console.log('# tests ' + (passes + failures));
58
+ console.log('# pass ' + passes);
59
+ console.log('# fail ' + failures);
50
60
  });
51
61
  }
52
62
 
@@ -34,12 +34,12 @@ html
34
34
  tbody
35
35
  for line, number in file.source
36
36
  if line.coverage > 0
37
- tr.hit
37
+ tr.hit
38
38
  td.line= number
39
39
  td.hits= line.coverage
40
40
  td.source= line.source
41
41
  else if 0 === line.coverage
42
- tr.miss
42
+ tr.miss
43
43
  td.line= number
44
44
  td.hits 0
45
45
  td.source= line.source
@@ -47,4 +47,4 @@ html
47
47
  tr
48
48
  td.line= number
49
49
  td.hits
50
- td.source= line.source || ' '
50
+ td.source= line.source || ' '
@@ -10,4 +10,4 @@
10
10
  if segments.length
11
11
  span.dirname= segments.join('/') + '/'
12
12
  span.basename= basename
13
- a#logo(href='http://visionmedia.github.com/mocha/') m
13
+ a#logo(href='http://visionmedia.github.io/mocha/') m
@@ -39,7 +39,7 @@ function XUnit(runner) {
39
39
  runner.on('pass', function(test){
40
40
  tests.push(test);
41
41
  });
42
-
42
+
43
43
  runner.on('fail', function(test){
44
44
  tests.push(test);
45
45
  });
@@ -50,13 +50,13 @@ function XUnit(runner) {
50
50
  , tests: stats.tests
51
51
  , failures: stats.failures
52
52
  , errors: stats.failures
53
- , skip: stats.tests - stats.failures - stats.passes
53
+ , skipped: stats.tests - stats.failures - stats.passes
54
54
  , timestamp: (new Date).toUTCString()
55
- , time: stats.duration / 1000
55
+ , time: (stats.duration / 1000) || 0
56
56
  }, false));
57
57
 
58
58
  tests.forEach(test);
59
- console.log('</testsuite>');
59
+ console.log('</testsuite>');
60
60
  });
61
61
  }
62
62
 
@@ -131,16 +131,14 @@ Runnable.prototype.inspect = function(){
131
131
  */
132
132
 
133
133
  Runnable.prototype.resetTimeout = function(){
134
- var self = this
135
- , ms = this.timeout();
134
+ var self = this;
135
+ var ms = this.timeout() || 1e9;
136
136
 
137
137
  this.clearTimeout();
138
- if (ms) {
139
- this.timer = setTimeout(function(){
140
- self.callback(new Error('timeout of ' + ms + 'ms exceeded'));
141
- self.timedOut = true;
142
- }, ms);
143
- }
138
+ this.timer = setTimeout(function(){
139
+ self.callback(new Error('timeout of ' + ms + 'ms exceeded'));
140
+ self.timedOut = true;
141
+ }, ms);
144
142
  };
145
143
 
146
144
  /**
@@ -194,7 +192,7 @@ Runnable.prototype.run = function(fn){
194
192
  if (this.async) {
195
193
  try {
196
194
  this.fn.call(ctx, function(err){
197
- if (toString.call(err) === "[object Error]") return done(err);
195
+ if (err instanceof Error || toString.call(err) === "[object Error]") return done(err);
198
196
  if (null != err) return done(new Error('done() invoked with non-Error: ' + err));
199
197
  done();
200
198
  });
@@ -1,4 +1,3 @@
1
-
2
1
  /**
3
2
  * Module dependencies.
4
3
  */
@@ -8,8 +7,7 @@ var EventEmitter = require('events').EventEmitter
8
7
  , Test = require('./test')
9
8
  , utils = require('./utils')
10
9
  , filter = utils.filter
11
- , keys = utils.keys
12
- , noop = function(){};
10
+ , keys = utils.keys;
13
11
 
14
12
  /**
15
13
  * Non-enumerable globals.
@@ -45,6 +43,7 @@ module.exports = Runner;
45
43
  * - `hook end` (hook) hook complete
46
44
  * - `pass` (test) test passed
47
45
  * - `fail` (test, err) test failed
46
+ * - `pending` (test) test pending
48
47
  *
49
48
  * @api public
50
49
  */
@@ -61,6 +60,15 @@ function Runner(suite) {
61
60
  this.globals(this.globalProps().concat(['errno']));
62
61
  }
63
62
 
63
+ /**
64
+ * Wrapper for setImmediate, process.nextTick, or browser polyfill.
65
+ *
66
+ * @param {Function} fn
67
+ * @api private
68
+ */
69
+
70
+ Runner.immediately = global.setImmediate || process.nextTick;
71
+
64
72
  /**
65
73
  * Inherit from `EventEmitter.prototype`.
66
74
  */
@@ -119,7 +127,7 @@ Runner.prototype.globalProps = function() {
119
127
 
120
128
  // non-enumerables
121
129
  for (var i = 0; i < globals.length; ++i) {
122
- if (~props.indexOf(globals[i])) continue;
130
+ if (~utils.indexOf(props, globals[i])) continue;
123
131
  props.push(globals[i]);
124
132
  }
125
133
 
@@ -181,9 +189,11 @@ Runner.prototype.checkGlobals = function(test){
181
189
  Runner.prototype.fail = function(test, err){
182
190
  ++this.failures;
183
191
  test.state = 'failed';
192
+
184
193
  if ('string' == typeof err) {
185
194
  err = new Error('the string "' + err + '" was thrown, throw an Error :)');
186
195
  }
196
+
187
197
  this.emit('fail', test, err);
188
198
  };
189
199
 
@@ -222,8 +232,11 @@ Runner.prototype.hook = function(name, fn){
222
232
  function next(i) {
223
233
  var hook = hooks[i];
224
234
  if (!hook) return fn();
235
+ if (self.failures && suite.bail()) return fn();
225
236
  self.currentRunnable = hook;
226
237
 
238
+ hook.ctx.currentTest = self.test;
239
+
227
240
  self.emit('hook', hook);
228
241
 
229
242
  hook.on('error', function(err){
@@ -236,11 +249,12 @@ Runner.prototype.hook = function(name, fn){
236
249
  if (testError) self.fail(self.test, testError);
237
250
  if (err) return self.failHook(hook, err);
238
251
  self.emit('hook end', hook);
252
+ delete hook.ctx.currentTest;
239
253
  next(++i);
240
254
  });
241
255
  }
242
256
 
243
- process.nextTick(function(){
257
+ Runner.immediately(function(){
244
258
  next(0);
245
259
  });
246
260
  };
@@ -483,13 +497,12 @@ Runner.prototype.run = function(fn){
483
497
  var self = this
484
498
  , fn = fn || function(){};
485
499
 
486
- debug('start');
487
-
488
- // uncaught callback
489
- function uncaught(err) {
500
+ function uncaught(err){
490
501
  self.uncaught(err);
491
502
  }
492
503
 
504
+ debug('start');
505
+
493
506
  // callback
494
507
  this.on('end', function(){
495
508
  debug('end');
@@ -521,6 +534,8 @@ Runner.prototype.run = function(fn){
521
534
 
522
535
  function filterLeaks(ok, globals) {
523
536
  return filter(globals, function(key){
537
+ // Firefox and Chrome exposes iframes as index inside the window object
538
+ if (/^d+/.test(key)) return false;
524
539
  var matched = filter(ok, function(ok){
525
540
  if (~ok.indexOf('*')) return 0 == key.indexOf(ok.split('*')[0]);
526
541
  // Opera and IE expose global variables for HTML element IDs (issue #243)
@@ -3,13 +3,14 @@
3
3
  <head>
4
4
  <title>Mocha</title>
5
5
  <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
6
+ <meta name="viewport" content="width=device-width, initial-scale=1.0">
6
7
  <link rel="stylesheet" href="mocha.css" />
7
8
  </head>
8
9
  <body>
9
10
  <div id="mocha"></div>
10
11
  <script src="mocha.js"></script>
11
12
  <script>mocha.setup('bdd')</script>
12
- <script src="my-tests.js"></script>
13
+ <script src="tests.js"></script>
13
14
  <script>
14
15
  mocha.run();
15
16
  </script>
@@ -63,7 +63,7 @@ exports.indexOf = function(arr, obj, start){
63
63
 
64
64
  /**
65
65
  * Array#reduce (<=IE8)
66
- *
66
+ *
67
67
  * @param {Array} array
68
68
  * @param {Function} fn
69
69
  * @param {Object} initial value
@@ -196,8 +196,8 @@ exports.clean = function(str) {
196
196
  .replace(/^function *\(.*\) *{/, '')
197
197
  .replace(/\s+\}$/, '');
198
198
 
199
- var spaces = str.match(/^\n?( *)/)[1].length
200
- , re = new RegExp('^ {' + spaces + '}', 'gm');
199
+ var whitespace = str.match(/^\n?(\s*)/)[1]
200
+ , re = new RegExp('^' + whitespace, 'gm');
201
201
 
202
202
  str = str.replace(re, '');
203
203