mirror of
https://github.com/whoisclebs/lodash.git
synced 2026-02-10 19:07:49 +00:00
Avoid require('vm') if testing AMD.
This commit is contained in:
48
test/test.js
48
test/test.js
@@ -35,12 +35,11 @@
|
|||||||
var last = result[result.length - 1];
|
var last = result[result.length - 1];
|
||||||
result = (result.length > min && !/test(?:\.js)?$/.test(last)) ? last : '../lodash.js';
|
result = (result.length > min && !/test(?:\.js)?$/.test(last)) ? last : '../lodash.js';
|
||||||
|
|
||||||
try {
|
if (!amd) {
|
||||||
if (!amd) {
|
try {
|
||||||
return require('fs').realpathSync(result);
|
return require('fs').realpathSync(result);
|
||||||
}
|
} catch(e) { }
|
||||||
} catch(e) { }
|
}
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
}());
|
}());
|
||||||
|
|
||||||
@@ -185,25 +184,26 @@
|
|||||||
|
|
||||||
// add values from other realms
|
// add values from other realms
|
||||||
(function() {
|
(function() {
|
||||||
try {
|
if (!amd) {
|
||||||
_.extend(_, require('vm').runInNewContext([
|
try {
|
||||||
'({',
|
_.extend(_, require('vm').runInNewContext([
|
||||||
"'_arguments': (function() { return arguments; }(1, 2, 3)),",
|
'({',
|
||||||
"'_array': [1, 2, 3],",
|
"'_arguments': (function() { return arguments; }(1, 2, 3)),",
|
||||||
"'_boolean': new Boolean(false),",
|
"'_array': [1, 2, 3],",
|
||||||
"'_date': new Date,",
|
"'_boolean': new Boolean(false),",
|
||||||
"'_function': function() {},",
|
"'_date': new Date,",
|
||||||
"'_nan': NaN,",
|
"'_function': function() {},",
|
||||||
"'_null': null,",
|
"'_nan': NaN,",
|
||||||
"'_number': new Number(0),",
|
"'_null': null,",
|
||||||
"'_object': { 'a': 1, 'b': 2, 'c': 3 },",
|
"'_number': new Number(0),",
|
||||||
"'_regexp': /x/,",
|
"'_object': { 'a': 1, 'b': 2, 'c': 3 },",
|
||||||
"'_string': new String('a'),",
|
"'_regexp': /x/,",
|
||||||
"'_undefined': undefined,",
|
"'_string': new String('a'),",
|
||||||
'})'
|
"'_undefined': undefined,",
|
||||||
].join('\n')));
|
'})'
|
||||||
} catch(e) { }
|
].join('\n')));
|
||||||
|
} catch(e) { }
|
||||||
|
}
|
||||||
if (!_._object && document) {
|
if (!_._object && document) {
|
||||||
var iframe = document.createElement('iframe');
|
var iframe = document.createElement('iframe');
|
||||||
iframe.frameBorder = iframe.height = iframe.width = 0;
|
iframe.frameBorder = iframe.height = iframe.width = 0;
|
||||||
|
|||||||
Reference in New Issue
Block a user