From 736c743d8b2794cdb9823731afb937e2e3bf7174 Mon Sep 17 00:00:00 2001 From: Travis Jeffery Date: Sat, 18 Jan 2014 14:54:11 -0500 Subject: [PATCH] Cleanup #1111 --- bin/_mocha | 0 lib/runner.js | 39 ++++++++++++++++++++++++++------------- mocha.js | 40 +++++++++++++++++++++++++++------------- 3 files changed, 53 insertions(+), 26 deletions(-) mode change 100644 => 100755 bin/_mocha diff --git a/bin/_mocha b/bin/_mocha old mode 100644 new mode 100755 diff --git a/lib/runner.js b/lib/runner.js index 09ed198313..58f20a90a2 100644 --- a/lib/runner.js +++ b/lib/runner.js @@ -58,19 +58,7 @@ function Runner(suite) { this.on('test end', function(test){ self.checkGlobals(test); }); this.on('hook end', function(hook){ self.checkGlobals(hook); }); this.grep(/.*/); - var extraGlobals = []; - if (typeof(process) === 'object' && - typeof(process.versions) === 'object' && - typeof(process.versions.node) === 'string') { - var nodeVersion = process.versions.node.split('.').reduce(function(a, v) { - return a << 8 | v; - }); - // 'errno' was renamed to process._errno in v0.9.11. - if (nodeVersion < 0x00090B) { - extraGlobals.push('errno'); - } - } - this.globals(this.globalProps().concat(extraGlobals)); + this.globals(this.globalProps().concat(extraGlobals())); } /** @@ -650,3 +638,28 @@ function filterLeaks(ok, globals) { return matched.length == 0 && (!global.navigator || 'onerror' !== key); }); } + +/** + * Array of globals dependent on the environment. + * + * @return {Array} + * @api private + */ + + function extraGlobals() { + if (typeof(process) === 'object' && + typeof(process.version) === 'string') { + + var nodeVersion = process.version.split('.').reduce(function(a, v) { + return a << 8 | v; + }); + + // 'errno' was renamed to process._errno in v0.9.11. + + if (nodeVersion < 0x00090B) { + return ['errno']; + } + } + + return []; + } diff --git a/mocha.js b/mocha.js index 78947c6269..c8c9b9ffdf 100644 --- a/mocha.js +++ b/mocha.js @@ -4404,19 +4404,8 @@ function Runner(suite) { this.on('test end', function(test){ self.checkGlobals(test); }); this.on('hook end', function(hook){ self.checkGlobals(hook); }); this.grep(/.*/); - var extraGlobals = []; - if (typeof(process) === 'object' && - typeof(process.versions) === 'object' && - typeof(process.versions.node) === 'string') { - var nodeVersion = process.versions.node.split('.').reduce(function(a, v) { - return a << 8 | v; - }); - // 'errno' was renamed to process._errno in v0.9.11. - if (nodeVersion < 0x00090B) { - extraGlobals.push('errno'); - } - } - this.globals(this.globalProps().concat(extraGlobals)); + console.log(extraGlobals()); + this.globals(this.globalProps().concat(extraGlobals())); } /** @@ -5001,6 +4990,31 @@ function filterLeaks(ok, globals) { }); } +/** + * Array of globals dependent on the environment. + * + * @return {Array} + * @api private + */ + + function extraGlobals() { + if (typeof(process) === 'object' && + typeof(process.version) === 'string') { + + var nodeVersion = process.version.split('.').reduce(function(a, v) { + return a << 8 | v; + }); + + // 'errno' was renamed to process._errno in v0.9.11. + + if (nodeVersion < 0x00090B) { + return ['errno']; + } + } + + return []; + } + }); // module: runner.js require.register("suite.js", function(module, exports, require){