Skip to content

Commit

Permalink
Fix test/test.js in lodash-node and carry fixes over to perf/perf.js.
Browse files Browse the repository at this point in the history
  • Loading branch information
jdalton committed Jan 29, 2014
1 parent f36c7fb commit 7fb5377
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 23 deletions.
43 changes: 22 additions & 21 deletions perf/perf.js
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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._,
Expand Down Expand Up @@ -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');

Expand All @@ -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 });

Expand Down
8 changes: 6 additions & 2 deletions test/test.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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 */
Expand Down

0 comments on commit 7fb5377

Please sign in to comment.