mirror of
https://github.com/whoisclebs/lodash.git
synced 2026-02-10 10:57:49 +00:00
Add support for loading different Lo-Dash builds in test.js for Narwhal, Rhino, and Ringo.
Former-commit-id: 936b2f246540b2456c78a6087266ba9d39f48f91
This commit is contained in:
41
test/test.js
41
test/test.js
@@ -1,12 +1,36 @@
|
|||||||
;(function(window, undefined) {
|
;(function(window, undefined) {
|
||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
/** The `lodash` basename */
|
/** Detect free variable `global` and use it as `window` */
|
||||||
var basename = 'lodash.js';
|
var freeGlobal = typeof global == 'object' && global;
|
||||||
|
if (freeGlobal.global === freeGlobal) {
|
||||||
|
window = freeGlobal;
|
||||||
|
}
|
||||||
|
|
||||||
/** Use a single load function */
|
/** Use a single load function */
|
||||||
var load = typeof require == 'function' ? require : window.load;
|
var load = typeof require == 'function' ? require : window.load;
|
||||||
|
|
||||||
|
/** The file path of the Lo-Dash file to test */
|
||||||
|
var filePath = (function() {
|
||||||
|
var min = 0;
|
||||||
|
var result = window.system
|
||||||
|
? (min = 1, system.args)
|
||||||
|
: (window.process ? (min = 2, process.argv) : window.arguments);
|
||||||
|
|
||||||
|
result = result.length > min
|
||||||
|
? result[result.length - 1]
|
||||||
|
: '../lodash.js';
|
||||||
|
|
||||||
|
try {
|
||||||
|
result = require('fs').realpathSync(result);
|
||||||
|
} catch(e) { }
|
||||||
|
|
||||||
|
return result;
|
||||||
|
}());
|
||||||
|
|
||||||
|
/** The basename of the Lo-Dash file to test */
|
||||||
|
var basename = /[\w.-]+$/.exec(filePath)[0];
|
||||||
|
|
||||||
/** The `platform` object to check */
|
/** The `platform` object to check */
|
||||||
var platform =
|
var platform =
|
||||||
window.platform ||
|
window.platform ||
|
||||||
@@ -24,17 +48,10 @@
|
|||||||
);
|
);
|
||||||
|
|
||||||
/** The `lodash` function to test */
|
/** The `lodash` function to test */
|
||||||
var _ = (function() {
|
var _ = window._ || (
|
||||||
try {
|
_ = load(filePath) || window._,
|
||||||
var filePath = require('fs').realpathSync(process.argv[2]);
|
|
||||||
basename = require('path').basename(filePath);
|
|
||||||
} catch(e) { }
|
|
||||||
|
|
||||||
return window._ || (
|
|
||||||
_ = load(filePath || '../lodash.js') || window._,
|
|
||||||
_._ || _
|
_._ || _
|
||||||
);
|
);
|
||||||
}());
|
|
||||||
|
|
||||||
/** Used to pass falsey values to methods */
|
/** Used to pass falsey values to methods */
|
||||||
var falsey = [
|
var falsey = [
|
||||||
@@ -2692,4 +2709,4 @@
|
|||||||
if (!window.document) {
|
if (!window.document) {
|
||||||
QUnit.start();
|
QUnit.start();
|
||||||
}
|
}
|
||||||
}(typeof global == 'object' && global || this));
|
}(this));
|
||||||
|
|||||||
Reference in New Issue
Block a user