Fix test/test.js in lodash-node and carry fixes over to perf/perf.js.

This commit is contained in:
John-David Dalton
2014-01-29 08:54:38 -08:00
parent 973bc21f37
commit 8cdd6cd131
2 changed files with 28 additions and 23 deletions

View File

@@ -15,14 +15,6 @@
params = root.arguments,
system = root.system;
/** Detect if running in Java */
var isJava = !document && !!root.java;
/** Use a single "load" function */
var load = (typeof require == 'function' && !amd)
? require
: (isJava && root.load) || noop;
/** The file path of the Lo-Dash file to test */
var filePath = (function() {
var min = 0,
@@ -44,12 +36,33 @@
if (!amd) {
try {
return require.resolve(result);
result = require('fs').realpathSync(result);
} catch(e) { }
try {
result = require.resolve(result);
} catch(e) { }
}
return result;
}());
/** The `ui` object */
var ui = root.ui || (root.ui = {
'buildPath': basename(filePath, '.js'),
'otherPath': 'underscore'
});
/** Detect if in a browser environment */
var isBrowser = isHostType(root, 'document') && isHostType(root, 'navigator');
/** Detect if in a Java environment */
var isJava = !isBrowser && /Java/.test(toString.call(root.java));
/** Use a single "load" function */
var load = (typeof require == 'function' && !amd)
? require
: (isJava && root.load) || noop;
/** Load Lo-Dash */
var lodash = root.lodash || (root.lodash = (
lodash = load(filePath) || root._,
@@ -92,12 +105,6 @@
/** Used to resolve a value's internal [[Class]] */
var toString = Object.prototype.toString;
/** The `ui` object */
var ui = root.ui || (root.ui = {
'buildPath': basename(filePath, '.js'),
'otherPath': 'underscore'
});
/** The Lo-Dash build basename */
var buildName = root.buildName = basename(ui.buildPath, '.js');
@@ -107,12 +114,6 @@
return result + (result == buildName ? ' (2)' : '');
}());
/** Detect if in a browser environment */
var isBrowser = isHostType(root, 'document') && isHostType(root, 'navigator');
/** Detect Java environment */
var isJava = !isBrowser && /Java/.test(toString.call(root.java));
/** Add `console.log()` support for Narwhal, Rhino, and RingoJS */
var console = root.console || (root.console = { 'log': root.print });

View File

@@ -49,7 +49,11 @@
if (!amd) {
try {
return require.resolve(result);
result = require('fs').realpathSync(result);
} catch(e) { }
try {
result = require.resolve(result);
} catch(e) { }
}
return result;
@@ -65,7 +69,7 @@
/** The basename of the Lo-Dash file to test */
var basename = /[\w.-]+$/.exec(filePath)[0];
/** Detect if running in Java */
/** Detect if in a Java environment */
var isJava = !document && !!root.java;
/** Used to indicate testing a modularized build */