From bd5c64cd0ba67c3c7f929c99289d6cb3a3e6ac97 Mon Sep 17 00:00:00 2001 From: Johnathon Sanders Date: Wed, 17 Jun 2015 15:34:01 -0500 Subject: [PATCH 1/6] Upgrade to mocha 2.2.5 --- mocha | 2 +- vendor/assets/javascripts/mocha.js | 1559 +++++++++++++++++++++------- 2 files changed, 1156 insertions(+), 405 deletions(-) diff --git a/mocha b/mocha index 7fc565e..ebe9cea 160000 --- a/mocha +++ b/mocha @@ -1 +1 @@ -Subproject commit 7fc565ee3e225cb7a66bf39ae9c2c05b346675c1 +Subproject commit ebe9ceab96fc1a05d4c89b13c23824b94b01ec43 diff --git a/vendor/assets/javascripts/mocha.js b/vendor/assets/javascripts/mocha.js index 3dcdae6..a66348d 100644 --- a/vendor/assets/javascripts/mocha.js +++ b/vendor/assets/javascripts/mocha.js @@ -48,7 +48,6 @@ require.relative = function (parent) { require.register("browser/debug.js", function(module, exports, require){ - module.exports = function(type){ return function(){ } @@ -414,8 +413,22 @@ if (typeof module !== 'undefined') { }); // module: browser/diff.js -require.register("browser/events.js", function(module, exports, require){ +require.register("browser/escape-string-regexp.js", function(module, exports, require){ +'use strict'; + +var matchOperatorsRe = /[|\\{}()[\]^$+*?.]/g; + +module.exports = function (str) { + if (typeof str !== 'string') { + throw new TypeError('Expected a string'); + } + + return str.replace(matchOperatorsRe, '\\$&'); +}; + +}); // module: browser/escape-string-regexp.js +require.register("browser/events.js", function(module, exports, require){ /** * Module exports. */ @@ -593,12 +606,17 @@ EventEmitter.prototype.emit = function (name) { return true; }; + }); // module: browser/events.js require.register("browser/fs.js", function(module, exports, require){ }); // module: browser/fs.js +require.register("browser/glob.js", function(module, exports, require){ + +}); // module: browser/glob.js + require.register("browser/path.js", function(module, exports, require){ }); // module: browser/path.js @@ -700,28 +718,28 @@ Progress.prototype.draw = function(ctx){ , y = half , rad = half - 1 , fontSize = this._fontSize; - + ctx.font = fontSize + 'px ' + this._font; - + var angle = Math.PI * 2 * (percent / 100); ctx.clearRect(0, 0, size, size); - + // outer circle ctx.strokeStyle = '#9f9f9f'; ctx.beginPath(); ctx.arc(x, y, rad, 0, angle, false); ctx.stroke(); - + // inner circle ctx.strokeStyle = '#eee'; ctx.beginPath(); ctx.arc(x, y, rad - 1, 0, angle, true); ctx.stroke(); - + // text var text = this._text || (percent | 0) + '%' , w = ctx.measureText(text).width; - + ctx.fillText( text , x - w / 2 + 1 @@ -733,7 +751,6 @@ Progress.prototype.draw = function(ctx){ }); // module: browser/progress.js require.register("browser/tty.js", function(module, exports, require){ - exports.isatty = function(){ return true; }; @@ -750,7 +767,6 @@ exports.getWindowSize = function(){ }); // module: browser/tty.js require.register("context.js", function(module, exports, require){ - /** * Expose `Context`. */ @@ -788,10 +804,25 @@ Context.prototype.runnable = function(runnable){ */ Context.prototype.timeout = function(ms){ + if (arguments.length === 0) return this.runnable().timeout(); this.runnable().timeout(ms); return this; }; +/** + * Set test timeout `enabled`. + * + * @param {Boolean} enabled + * @return {Context} self + * @api private + */ + +Context.prototype.enableTimeouts = function (enabled) { + this.runnable().enableTimeouts(enabled); + return this; +}; + + /** * Set test slowness threshold `ms`. * @@ -805,6 +836,18 @@ Context.prototype.slow = function(ms){ return this; }; +/** + * Mark a test as skipped. + * + * @return {Context} self + * @api private + */ + +Context.prototype.skip = function(){ + this.runnable().skip(); + return this; +}; + /** * Inspect the context void of `._runnable`. * @@ -823,7 +866,6 @@ Context.prototype.inspect = function(){ }); // module: context.js require.register("hook.js", function(module, exports, require){ - /** * Module dependencies. */ @@ -880,14 +922,14 @@ Hook.prototype.error = function(err){ }); // module: hook.js require.register("interfaces/bdd.js", function(module, exports, require){ - /** * Module dependencies. */ var Suite = require('../suite') , Test = require('../test') - , utils = require('../utils'); + , utils = require('../utils') + , escapeRe = require('browser/escape-string-regexp'); /** * BDD-style interface: @@ -911,38 +953,13 @@ module.exports = function(suite){ suite.on('pre-require', function(context, file, mocha){ - /** - * Execute before running tests. - */ - - context.before = function(fn){ - suites[0].beforeAll(fn); - }; - - /** - * Execute after running tests. - */ - - context.after = function(fn){ - suites[0].afterAll(fn); - }; - - /** - * Execute before each test case. - */ - - context.beforeEach = function(fn){ - suites[0].beforeEach(fn); - }; - - /** - * Execute after each test case. - */ - - context.afterEach = function(fn){ - suites[0].afterEach(fn); - }; + var common = require('./common')(suites, context); + context.before = common.before; + context.after = common.after; + context.beforeEach = common.beforeEach; + context.afterEach = common.afterEach; + context.run = mocha.options.delay && common.runWithSuite(suite); /** * Describe a "suite" with the given `title` * and callback `fn` containing nested suites @@ -951,6 +968,7 @@ module.exports = function(suite){ context.describe = context.context = function(title, fn){ var suite = Suite.create(suites[0], title); + suite.file = file; suites.unshift(suite); fn.call(suite); suites.shift(); @@ -989,8 +1007,9 @@ module.exports = function(suite){ context.it = context.specify = function(title, fn){ var suite = suites[0]; - if (suite.pending) var fn = null; + if (suite.pending) fn = null; var test = new Test(title, fn); + test.file = file; suite.addTest(test); return test; }; @@ -1001,7 +1020,7 @@ module.exports = function(suite){ context.it.only = function(title, fn){ var test = context.it(title, fn); - var reString = '^' + utils.escapeRegexp(test.fullTitle()) + '$'; + var reString = '^' + escapeRe(test.fullTitle()) + '$'; mocha.grep(new RegExp(reString)); return test; }; @@ -1015,13 +1034,75 @@ module.exports = function(suite){ context.it.skip = function(title){ context.it(title); }; + }); }; }); // module: interfaces/bdd.js -require.register("interfaces/exports.js", function(module, exports, require){ +require.register("interfaces/common.js", function(module, exports, require){ +/** + * Functions common to more than one interface + * @module lib/interfaces/common + */ + +'use strict'; + +module.exports = function (suites, context) { + + return { + /** + * This is only present if flag --delay is passed into Mocha. It triggers + * root suite execution. Returns a function which runs the root suite. + */ + runWithSuite: function runWithSuite(suite) { + return function run() { + suite.run(); + }; + }, + + /** + * Execute before running tests. + */ + before: function (name, fn) { + suites[0].beforeAll(name, fn); + }, + + /** + * Execute after running tests. + */ + after: function (name, fn) { + suites[0].afterAll(name, fn); + }, + + /** + * Execute before each test case. + */ + beforeEach: function (name, fn) { + suites[0].beforeEach(name, fn); + }, + + /** + * Execute after each test case. + */ + afterEach: function (name, fn) { + suites[0].afterEach(name, fn); + }, + + test: { + /** + * Pending test case. + */ + skip: function (title) { + context.test(title); + } + } + } +}; +}); // module: interfaces/common.js + +require.register("interfaces/exports.js", function(module, exports, require){ /** * Module dependencies. */ @@ -1051,7 +1132,7 @@ module.exports = function(suite){ suite.on('require', visit); - function visit(obj) { + function visit(obj, file) { var suite; for (var key in obj) { if ('function' == typeof obj[key]) { @@ -1070,10 +1151,12 @@ module.exports = function(suite){ suites[0].afterEach(fn); break; default: - suites[0].addTest(new Test(key, fn)); + var test = new Test(key, fn); + test.file = file; + suites[0].addTest(test); } } else { - var suite = Suite.create(suites[0], key); + suite = Suite.create(suites[0], key); suites.unshift(suite); visit(obj[key]); suites.shift(); @@ -1085,7 +1168,6 @@ module.exports = function(suite){ }); // module: interfaces/exports.js require.register("interfaces/index.js", function(module, exports, require){ - exports.bdd = require('./bdd'); exports.tdd = require('./tdd'); exports.qunit = require('./qunit'); @@ -1094,13 +1176,13 @@ exports.exports = require('./exports'); }); // module: interfaces/index.js require.register("interfaces/qunit.js", function(module, exports, require){ - /** * Module dependencies. */ var Suite = require('../suite') , Test = require('../test') + , escapeRe = require('browser/escape-string-regexp') , utils = require('../utils'); /** @@ -1133,38 +1215,13 @@ module.exports = function(suite){ suite.on('pre-require', function(context, file, mocha){ - /** - * Execute before running tests. - */ - - context.before = function(fn){ - suites[0].beforeAll(fn); - }; - - /** - * Execute after running tests. - */ - - context.after = function(fn){ - suites[0].afterAll(fn); - }; - - /** - * Execute before each test case. - */ - - context.beforeEach = function(fn){ - suites[0].beforeEach(fn); - }; - - /** - * Execute after each test case. - */ - - context.afterEach = function(fn){ - suites[0].afterEach(fn); - }; + var common = require('./common')(suites, context); + context.before = common.before; + context.after = common.after; + context.beforeEach = common.beforeEach; + context.afterEach = common.afterEach; + context.run = mocha.options.delay && common.runWithSuite(suite); /** * Describe a "suite" with the given `title`. */ @@ -1172,6 +1229,7 @@ module.exports = function(suite){ context.suite = function(title){ if (suites.length > 1) suites.shift(); var suite = Suite.create(suites[0], title); + suite.file = file; suites.unshift(suite); return suite; }; @@ -1193,6 +1251,7 @@ module.exports = function(suite){ context.test = function(title, fn){ var test = new Test(title, fn); + test.file = file; suites[0].addTest(test); return test; }; @@ -1203,31 +1262,26 @@ module.exports = function(suite){ context.test.only = function(title, fn){ var test = context.test(title, fn); - var reString = '^' + utils.escapeRegexp(test.fullTitle()) + '$'; + var reString = '^' + escapeRe(test.fullTitle()) + '$'; mocha.grep(new RegExp(reString)); }; - /** - * Pending test case. - */ + context.test.skip = common.test.skip; - context.test.skip = function(title){ - context.test(title); - }; }); }; }); // module: interfaces/qunit.js require.register("interfaces/tdd.js", function(module, exports, require){ - /** * Module dependencies. */ var Suite = require('../suite') , Test = require('../test') - , utils = require('../utils');; + , escapeRe = require('browser/escape-string-regexp') + , utils = require('../utils'); /** * TDD-style interface: @@ -1259,38 +1313,13 @@ module.exports = function(suite){ suite.on('pre-require', function(context, file, mocha){ - /** - * Execute before each test case. - */ - - context.setup = function(fn){ - suites[0].beforeEach(fn); - }; - - /** - * Execute after each test case. - */ - - context.teardown = function(fn){ - suites[0].afterEach(fn); - }; - - /** - * Execute before the suite. - */ - - context.suiteSetup = function(fn){ - suites[0].beforeAll(fn); - }; - - /** - * Execute after the suite. - */ - - context.suiteTeardown = function(fn){ - suites[0].afterAll(fn); - }; + var common = require('./common')(suites, context); + context.setup = common.beforeEach; + context.teardown = common.afterEach; + context.suiteSetup = common.before; + context.suiteTeardown = common.after; + context.run = mocha.options.delay && common.runWithSuite(suite); /** * Describe a "suite" with the given `title` * and callback `fn` containing nested suites @@ -1299,6 +1328,7 @@ module.exports = function(suite){ context.suite = function(title, fn){ var suite = Suite.create(suites[0], title); + suite.file = file; suites.unshift(suite); fn.call(suite); suites.shift(); @@ -1333,8 +1363,9 @@ module.exports = function(suite){ context.test = function(title, fn){ var suite = suites[0]; - if (suite.pending) var fn = null; + if (suite.pending) fn = null; var test = new Test(title, fn); + test.file = file; suite.addTest(test); return test; }; @@ -1345,17 +1376,11 @@ module.exports = function(suite){ context.test.only = function(title, fn){ var test = context.test(title, fn); - var reString = '^' + utils.escapeRegexp(test.fullTitle()) + '$'; + var reString = '^' + escapeRe(test.fullTitle()) + '$'; mocha.grep(new RegExp(reString)); }; - /** - * Pending test case. - */ - - context.test.skip = function(title){ - context.test(title); - }; + context.test.skip = common.test.skip; }); }; @@ -1373,6 +1398,7 @@ require.register("mocha.js", function(module, exports, require){ */ var path = require('browser/path') + , escapeRe = require('browser/escape-string-regexp') , utils = require('./utils'); /** @@ -1381,6 +1407,16 @@ var path = require('browser/path') exports = module.exports = Mocha; +/** + * To require local UIs and reporters when running in node. + */ + +if (typeof process !== 'undefined' && typeof process.cwd === 'function') { + var join = path.join + , cwd = process.cwd(); + module.paths.push(cwd, join(cwd, 'node_modules')); +} + /** * Expose internals. */ @@ -1413,12 +1449,13 @@ function image(name) { * Options: * * - `ui` name "bdd", "tdd", "exports" etc - * - `reporter` reporter instance, defaults to `mocha.reporters.Dot` + * - `reporter` reporter instance, defaults to `mocha.reporters.spec` * - `globals` array of accepted globals * - `timeout` timeout in milliseconds * - `bail` bail on the first test failure * - `slow` milliseconds to wait before considering a test slow * - `ignoreLeaks` ignore global leaks + * - `fullTrace` display the full stack-trace on failing * - `grep` string or regexp to filter tests with * * @param {Object} options @@ -1429,13 +1466,15 @@ function Mocha(options) { options = options || {}; this.files = []; this.options = options; - this.grep(options.grep); + if (options.grep) this.grep(new RegExp(options.grep)); + if (options.fgrep) this.grep(options.fgrep); this.suite = new exports.Suite('', new exports.Context); this.ui(options.ui); this.bail(options.bail); - this.reporter(options.reporter); + this.reporter(options.reporter, options.reporterOptions); if (null != options.timeout) this.timeout(options.timeout); - this.useColors(options.useColors) + this.useColors(options.useColors); + if (options.enableTimeouts !== null) this.enableTimeouts(options.enableTimeouts); if (options.slow) this.slow(options.slow); this.suite.on('pre-require', function (context) { @@ -1451,6 +1490,7 @@ function Mocha(options) { exports.suite = context.suite || context.describe; exports.teardown = context.teardown || context.afterEach; exports.test = context.test || context.it; + exports.run = context.run; }); } @@ -1480,20 +1520,24 @@ Mocha.prototype.addFile = function(file){ }; /** - * Set reporter to `reporter`, defaults to "dot". + * Set reporter to `reporter`, defaults to "spec". * * @param {String|Function} reporter name or constructor + * @param {Object} reporterOptions optional options * @api public */ - -Mocha.prototype.reporter = function(reporter){ +Mocha.prototype.reporter = function(reporter, reporterOptions){ if ('function' == typeof reporter) { this._reporter = reporter; } else { - reporter = reporter || 'dot'; + reporter = reporter || 'spec'; var _reporter; - try { _reporter = require('./reporters/' + reporter); } catch (err) {}; - if (!_reporter) try { _reporter = require(reporter); } catch (err) {}; + try { _reporter = require('./reporters/' + reporter); } catch (err) {} + if (!_reporter) try { _reporter = require(reporter); } catch (err) { + err.message.indexOf('Cannot find module') !== -1 + ? console.warn('"' + reporter + '" reporter not found') + : console.warn('"' + reporter + '" reporter blew up with error:\n' + err.stack); + } if (!_reporter && reporter === 'teamcity') console.warn('The Teamcity reporter was moved to a package named ' + 'mocha-teamcity-reporter ' + @@ -1501,6 +1545,7 @@ Mocha.prototype.reporter = function(reporter){ if (!_reporter) throw new Error('invalid reporter "' + reporter + '"'); this._reporter = _reporter; } + this.options.reporterOptions = reporterOptions; return this; }; @@ -1514,7 +1559,7 @@ Mocha.prototype.reporter = function(reporter){ Mocha.prototype.ui = function(name){ name = name || 'bdd'; this._ui = exports.interfaces[name]; - if (!this._ui) try { this._ui = require(name); } catch (err) {}; + if (!this._ui) try { this._ui = require(name); } catch (err) {} if (!this._ui) throw new Error('invalid interface "' + name + '"'); this._ui = this._ui(this.suite); return this; @@ -1573,7 +1618,7 @@ Mocha.prototype._growl = function(runner, reporter) { Mocha.prototype.grep = function(re){ this.options.grep = 'string' == typeof re - ? new RegExp(utils.escapeRegexp(re)) + ? new RegExp(escapeRe(re)) : re; return this; }; @@ -1615,6 +1660,18 @@ Mocha.prototype.checkLeaks = function(){ return this; }; +/** + * Display long stack-trace on failing + * + * @return {Mocha} + * @api public + */ + +Mocha.prototype.fullTrace = function() { + this.options.fullStackTrace = true; + return this; +}; + /** * Enable growl support. * @@ -1649,9 +1706,9 @@ Mocha.prototype.globals = function(globals){ */ Mocha.prototype.useColors = function(colors){ - this.options.useColors = arguments.length && colors != undefined - ? colors - : true; + if (colors !== undefined) { + this.options.useColors = colors; + } return this; }; @@ -1696,6 +1753,21 @@ Mocha.prototype.slow = function(slow){ return this; }; +/** + * Enable timeouts. + * + * @param {Boolean} enabled + * @return {Mocha} + * @api public + */ + +Mocha.prototype.enableTimeouts = function(enabled) { + this.suite.enableTimeouts(arguments.length && enabled !== undefined + ? enabled + : true); + return this +}; + /** * Makes all tests async (accepting a callback) * @@ -1708,6 +1780,26 @@ Mocha.prototype.asyncOnly = function(){ return this; }; +/** + * Disable syntax highlighting (in browser). + * @returns {Mocha} + * @api public + */ +Mocha.prototype.noHighlighting = function() { + this.options.noHighlighting = true; + return this; +}; + +/** + * Delay root suite execution. + * @returns {Mocha} + * @api public + */ +Mocha.prototype.delay = function delay() { + this.options.delay = true; + return this; +}; + /** * Run tests and invoke `fn()` when complete. * @@ -1715,21 +1807,31 @@ Mocha.prototype.asyncOnly = function(){ * @return {Runner} * @api public */ - Mocha.prototype.run = function(fn){ if (this.files.length) this.loadFiles(); var suite = this.suite; var options = this.options; - var runner = new exports.Runner(suite); - var reporter = new this._reporter(runner); + options.files = this.files; + var runner = new exports.Runner(suite, options.delay); + var reporter = new this._reporter(runner, options); runner.ignoreLeaks = false !== options.ignoreLeaks; + runner.fullStackTrace = options.fullStackTrace; runner.asyncOnly = options.asyncOnly; if (options.grep) runner.grep(options.grep, options.invert); if (options.globals) runner.globals(options.globals); if (options.growl) this._growl(runner, reporter); - exports.reporters.Base.useColors = options.useColors; + if (options.useColors !== undefined) { + exports.reporters.Base.useColors = options.useColors; + } exports.reporters.Base.inlineDiffs = options.useInlineDiffs; - return runner.run(fn); + + function done(failures) { + if (reporter.done) { + reporter.done(failures, fn); + } else fn && fn(failures); + } + + return runner.run(done); }; }); // module: mocha.js @@ -1761,7 +1863,7 @@ var y = d * 365.25; module.exports = function(val, options){ options = options || {}; if ('string' == typeof val) return parse(val); - return options.long ? longFormat(val) : shortFormat(val); + return options['long'] ? longFormat(val) : shortFormat(val); }; /** @@ -1847,8 +1949,27 @@ function plural(ms, n, name) { }); // module: ms.js -require.register("reporters/base.js", function(module, exports, require){ +require.register("pending.js", function(module, exports, require){ + +/** + * Expose `Pending`. + */ + +module.exports = Pending; +/** + * Initialize a new `Pending` error with the given message. + * + * @param {String} message + */ + +function Pending(message) { + this.message = message; +} + +}); // module: pending.js + +require.register("reporters/base.js", function(module, exports, require){ /** * Module dependencies. */ @@ -1856,7 +1977,8 @@ require.register("reporters/base.js", function(module, exports, require){ var tty = require('browser/tty') , diff = require('browser/diff') , ms = require('../ms') - , utils = require('../utils'); + , utils = require('../utils') + , supportsColor = process.env ? require('supports-color') : null; /** * Save timer references to avoid Sinon interfering (see GH-237). @@ -1881,10 +2003,12 @@ var isatty = tty.isatty(1) && tty.isatty(2); exports = module.exports = Base; /** - * Enable coloring by default. + * Enable coloring by default, except in the browser interface. */ -exports.useColors = isatty || (process.env.MOCHA_COLORS !== undefined); +exports.useColors = process.env + ? (supportsColor || (process.env.MOCHA_COLORS !== undefined)) + : false; /** * Inline diffs instead of +/- @@ -1914,8 +2038,8 @@ exports.colors = { , 'green': 32 , 'light': 90 , 'diff gutter': 90 - , 'diff added': 42 - , 'diff removed': 41 + , 'diff added': 32 + , 'diff removed': 31 }; /** @@ -1948,7 +2072,7 @@ if ('win32' == process.platform) { */ var color = exports.color = function(type, str) { - if (!exports.useColors) return str; + if (!exports.useColors) return String(str); return '\u001b[' + exports.colors[type] + 'm' + str + '\u001b[0m'; }; @@ -2005,7 +2129,7 @@ exports.cursor = { */ exports.list = function(failures){ - console.error(); + console.log(); failures.forEach(function(test, i){ // format var fmt = color('error title', ' %s) %s:\n') @@ -2016,26 +2140,33 @@ exports.list = function(failures){ var err = test.err , message = err.message || '' , stack = err.stack || message - , index = stack.indexOf(message) + message.length - , msg = stack.slice(0, index) + , index = stack.indexOf(message) , actual = err.actual , expected = err.expected , escape = true; + if (index === -1) { + msg = message; + } else { + index += message.length; + msg = stack.slice(0, index); + // remove msg from stack + stack = stack.slice(index + 1); + } // uncaught if (err.uncaught) { msg = 'Uncaught ' + msg; } - // explicitly show diff - if (err.showDiff && sameType(actual, expected)) { + if (err.showDiff !== false && sameType(actual, expected) + && expected !== undefined) { + escape = false; - err.actual = actual = stringify(canonicalize(actual)); - err.expected = expected = stringify(canonicalize(expected)); - } + if (!(utils.isString(actual) && utils.isString(expected))) { + err.actual = actual = utils.stringify(actual); + err.expected = expected = utils.stringify(expected); + } - // actual / expected diff - if ('string' == typeof actual && 'string' == typeof expected) { fmt = color('error title', ' %s) %s:\n%s') + color('error stack', '\n%s\n'); var match = message.match(/^([^:]+): expected/); msg = '\n ' + color('error message', match ? match[1] : msg); @@ -2047,11 +2178,10 @@ exports.list = function(failures){ } } - // indent stack trace without msg - stack = stack.slice(index ? index + 1 : index) - .replace(/^/gm, ' '); + // indent stack trace + stack = stack.replace(/^/gm, ' '); - console.error(fmt, (i + 1), test.fullTitle(), msg, stack); + console.log(fmt, (i + 1), test.fullTitle(), msg, stack); }); }; @@ -2156,11 +2286,10 @@ Base.prototype.epilogue = function(){ if (stats.failures) { fmt = color('fail', ' %d failing'); - console.error(fmt, - stats.failures); + console.log(fmt, stats.failures); Base.list(this.failures); - console.error(); + console.log(); } console.log(); @@ -2238,7 +2367,7 @@ function unifiedDiff(err, escape) { function notBlank(line) { return line != null; } - msg = diff.createPatch('string', err.actual, err.expected); + var msg = diff.createPatch('string', err.actual, err.expected); var lines = msg.split('\n').splice(4); return '\n ' + colorLines('diff added', '+ expected') + ' ' @@ -2293,53 +2422,6 @@ function colorLines(name, str) { }).join('\n'); } -/** - * Stringify `obj`. - * - * @param {Object} obj - * @return {String} - * @api private - */ - -function stringify(obj) { - if (obj instanceof RegExp) return obj.toString(); - return JSON.stringify(obj, null, 2); -} - -/** - * Return a new object that has the keys in sorted order. - * @param {Object} obj - * @return {Object} - * @api private - */ - - function canonicalize(obj, stack) { - stack = stack || []; - - if (utils.indexOf(stack, obj) !== -1) return obj; - - var canonicalizedObj; - - if ('[object Array]' == {}.toString.call(obj)) { - stack.push(obj); - canonicalizedObj = utils.map(obj, function(item) { - return canonicalize(item, stack); - }); - stack.pop(); - } else if (typeof obj === 'object' && obj !== null) { - stack.push(obj); - canonicalizedObj = {}; - utils.forEach(utils.keys(obj).sort(), function(key) { - canonicalizedObj[key] = canonicalize(obj[key], stack); - }); - stack.pop(); - } else { - canonicalizedObj = obj; - } - - return canonicalizedObj; - } - /** * Check that a / b have the same type. * @@ -2355,11 +2437,9 @@ function sameType(a, b) { return a == b; } - }); // module: reporters/base.js require.register("reporters/doc.js", function(module, exports, require){ - /** * Module dependencies. */ @@ -2414,12 +2494,18 @@ function Doc(runner) { var code = utils.escape(utils.clean(test.fn.toString())); console.log('%s
%s
', indent(), code); }); + + runner.on('fail', function(test, err){ + console.log('%s
%s
', indent(), utils.escape(test.title)); + var code = utils.escape(utils.clean(test.fn.toString())); + console.log('%s
%s
', indent(), code); + console.log('%s
%s
', indent(), utils.escape(err)); + }); } }); // module: reporters/doc.js require.register("reporters/dot.js", function(module, exports, require){ - /** * Module dependencies. */ @@ -2446,13 +2532,14 @@ function Dot(runner) { var self = this , stats = this.stats , width = Base.window.width * .75 | 0 - , n = 0; + , n = -1; runner.on('start', function(){ - process.stdout.write('\n '); + process.stdout.write('\n'); }); runner.on('pending', function(test){ + if (++n % width == 0) process.stdout.write('\n '); process.stdout.write(color('pending', Base.symbols.dot)); }); @@ -2485,10 +2572,10 @@ F.prototype = Base.prototype; Dot.prototype = new F; Dot.prototype.constructor = Dot; + }); // module: reporters/dot.js require.register("reporters/html-cov.js", function(module, exports, require){ - /** * Module dependencies. */ @@ -2539,10 +2626,10 @@ function coverageClass(n) { if (n >= 25) return 'low'; return 'terrible'; } + }); // module: reporters/html-cov.js require.register("reporters/html.js", function(module, exports, require){ - /** * Module dependencies. */ @@ -2586,7 +2673,7 @@ var statsTemplate = '