mirror of
https://github.com/whoisclebs/lodash.git
synced 2026-02-11 11:27:50 +00:00
Cleanup other realm tests.
This commit is contained in:
268
test/test.js
268
test/test.js
@@ -54,6 +54,7 @@
|
|||||||
objToString = objectProto.toString,
|
objToString = objectProto.toString,
|
||||||
params = root.arguments,
|
params = root.arguments,
|
||||||
push = arrayProto.push,
|
push = arrayProto.push,
|
||||||
|
realm = {},
|
||||||
Set = root.Set,
|
Set = root.Set,
|
||||||
slice = arrayProto.slice,
|
slice = arrayProto.slice,
|
||||||
Symbol = root.Symbol,
|
Symbol = root.Symbol,
|
||||||
@@ -447,27 +448,27 @@
|
|||||||
|
|
||||||
// Add other realm values from the `vm` module.
|
// Add other realm values from the `vm` module.
|
||||||
_.attempt(function() {
|
_.attempt(function() {
|
||||||
_.extend(_, require('vm').runInNewContext([
|
_.extend(realm, require('vm').runInNewContext([
|
||||||
'(function() {',
|
'(function() {',
|
||||||
' var root = this;',
|
' var root = this;',
|
||||||
'',
|
'',
|
||||||
' var object = {',
|
' var object = {',
|
||||||
" '_arguments': (function() { return arguments; }(1, 2, 3)),",
|
" 'arguments': (function() { return arguments; }(1, 2, 3)),",
|
||||||
" '_array': [1, 2, 3],",
|
" 'array': [1, 2, 3],",
|
||||||
" '_arrayBuffer': new (this.ArrayByffer || Object),",
|
" 'arrayBuffer': new (this.ArrayByffer || Object),",
|
||||||
" '_boolean': Object(false),",
|
" 'boolean': Object(false),",
|
||||||
" '_date': new Date,",
|
" 'date': new Date,",
|
||||||
" '_errors': [new Error, new EvalError, new RangeError, new ReferenceError, new SyntaxError, new TypeError, new URIError],",
|
" 'errors': [new Error, new EvalError, new RangeError, new ReferenceError, new SyntaxError, new TypeError, new URIError],",
|
||||||
" '_function': function() {},",
|
" 'function': function() {},",
|
||||||
" '_map': new (root.Map || Object),",
|
" 'map': new (root.Map || Object),",
|
||||||
" '_nan': NaN,",
|
" 'nan': NaN,",
|
||||||
" '_null': null,",
|
" 'null': null,",
|
||||||
" '_number': Object(0),",
|
" 'number': Object(0),",
|
||||||
" '_object': { 'a': 1, 'b': 2, 'c': 3 },",
|
" 'object': { 'a': 1, 'b': 2, 'c': 3 },",
|
||||||
" '_regexp': /x/,",
|
" 'regexp': /x/,",
|
||||||
" '_set': new (root.Set || Object),",
|
" 'set': new (root.Set || Object),",
|
||||||
" '_string': Object('a'),",
|
" 'string': Object('a'),",
|
||||||
" '_undefined': undefined",
|
" 'undefined': undefined",
|
||||||
' };',
|
' };',
|
||||||
'',
|
'',
|
||||||
" ['" + typedArrays.join("', '") + "'].forEach(function(type) {",
|
" ['" + typedArrays.join("', '") + "'].forEach(function(type) {",
|
||||||
@@ -484,6 +485,8 @@
|
|||||||
|
|
||||||
// Add other realm values from an iframe.
|
// Add other realm values from an iframe.
|
||||||
_.attempt(function() {
|
_.attempt(function() {
|
||||||
|
_._realm = realm;
|
||||||
|
|
||||||
var iframe = document.createElement('iframe');
|
var iframe = document.createElement('iframe');
|
||||||
iframe.frameBorder = iframe.height = iframe.width = 0;
|
iframe.frameBorder = iframe.height = iframe.width = 0;
|
||||||
body.appendChild(iframe);
|
body.appendChild(iframe);
|
||||||
@@ -491,35 +494,42 @@
|
|||||||
var idoc = (idoc = iframe.contentDocument || iframe.contentWindow).document || idoc;
|
var idoc = (idoc = iframe.contentDocument || iframe.contentWindow).document || idoc;
|
||||||
idoc.write([
|
idoc.write([
|
||||||
'<script>',
|
'<script>',
|
||||||
|
'var _ = parent._;',
|
||||||
|
'',
|
||||||
'var root = this;',
|
'var root = this;',
|
||||||
'',
|
'',
|
||||||
'parent._._arguments = (function() { return arguments; }(1, 2, 3));',
|
'var object = {',
|
||||||
'parent._._array = [1, 2, 3];',
|
" 'arguments': (function() { return arguments; }(1, 2, 3)),",
|
||||||
'parent._._arrayBuffer = new (this.ArrayByffer || Object);',
|
" 'array': [1, 2, 3],",
|
||||||
'parent._._boolean = Object(false);',
|
" 'arrayBuffer': new (this.ArrayByffer || Object),",
|
||||||
'parent._._date = new Date;',
|
" 'boolean': Object(false),",
|
||||||
"parent._._element = document.createElement('div');",
|
" 'date': new Date,",
|
||||||
'parent._._errors = [new Error, new EvalError, new RangeError, new ReferenceError, new SyntaxError, new TypeError, new URIError];',
|
" 'errors': [new Error, new EvalError, new RangeError, new ReferenceError, new SyntaxError, new TypeError, new URIError],",
|
||||||
'parent._._function = function() {};',
|
" 'function': function() {},",
|
||||||
'parent._._map = new (this.Map || Object);',
|
" 'map': new (root.Map || Object),",
|
||||||
'parent._._nan = NaN;',
|
" 'nan': NaN,",
|
||||||
'parent._._null = null;',
|
" 'null': null,",
|
||||||
'parent._._number = Object(0);',
|
" 'number': Object(0),",
|
||||||
"parent._._object = { 'a': 1, 'b': 2, 'c': 3 };",
|
" 'object': { 'a': 1, 'b': 2, 'c': 3 },",
|
||||||
'parent._._regexp = /x/;',
|
" 'regexp': /x/,",
|
||||||
'parent._._set = new (this.Set || Object);',
|
" 'set': new (root.Set || Object),",
|
||||||
"parent._._string = Object('a');",
|
" 'string': Object('a'),",
|
||||||
'parent._._undefined = undefined;',
|
" 'undefined': undefined",
|
||||||
|
'};',
|
||||||
'',
|
'',
|
||||||
"parent._.each(['" + typedArrays.join("', '") + "'], function(type) {",
|
"_.each(['" + typedArrays.join("', '") + "'], function(type) {",
|
||||||
' var Ctor = root[type];',
|
' var Ctor = root[type];',
|
||||||
' if (Ctor) {',
|
' if (Ctor) {',
|
||||||
" parent._['_' + type.toLowerCase()] = new Ctor(new ArrayBuffer(24));",
|
" object['_' + type.toLowerCase()] = new Ctor(new ArrayBuffer(24));",
|
||||||
' }',
|
' }',
|
||||||
'});',
|
'});',
|
||||||
|
'',
|
||||||
|
'_.extend(_._realm, object);',
|
||||||
'<\/script>'
|
'<\/script>'
|
||||||
].join('\n'));
|
].join('\n'));
|
||||||
|
|
||||||
idoc.close();
|
idoc.close();
|
||||||
|
delete _._realm;
|
||||||
});
|
});
|
||||||
|
|
||||||
// Add a web worker.
|
// Add a web worker.
|
||||||
@@ -534,11 +544,14 @@
|
|||||||
|
|
||||||
// Expose internal modules for better code coverage.
|
// Expose internal modules for better code coverage.
|
||||||
_.attempt(function() {
|
_.attempt(function() {
|
||||||
|
var path = require('path'),
|
||||||
|
basePath = path.dirname(filePath);
|
||||||
|
|
||||||
if (isModularize && !(amd || isNpm)) {
|
if (isModularize && !(amd || isNpm)) {
|
||||||
_.each(['internal/baseEach', 'internal/isIndex', 'internal/isIterateeCall',
|
_.each(['internal/baseEach', 'internal/isIndex',
|
||||||
'internal/isLength', 'function/flow', 'function/flowRight'], function(id) {
|
'internal/isIterateeCall', 'internal/isLength'], function(relPath) {
|
||||||
var func = require(id),
|
var func = require(path.join(basePath, relPath)),
|
||||||
funcName = _.last(id.split('/'));
|
funcName = path.basename(relPath);
|
||||||
|
|
||||||
_['_' + funcName] = func[funcName] || func['default'] || func;
|
_['_' + funcName] = func[funcName] || func['default'] || func;
|
||||||
});
|
});
|
||||||
@@ -1228,10 +1241,10 @@
|
|||||||
QUnit.test('should work with an error object from another realm', function(assert) {
|
QUnit.test('should work with an error object from another realm', function(assert) {
|
||||||
assert.expect(1);
|
assert.expect(1);
|
||||||
|
|
||||||
if (_._object) {
|
if (realm.errors) {
|
||||||
var expected = _.map(_._errors, _.constant(true));
|
var expected = _.map(realm.errors, _.constant(true));
|
||||||
|
|
||||||
var actual = _.map(_._errors, function(error) {
|
var actual = _.map(realm.errors, function(error) {
|
||||||
return _.attempt(function() { throw error; }) === error;
|
return _.attempt(function() { throw error; }) === error;
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -2002,7 +2015,6 @@
|
|||||||
set.add(1);
|
set.add(1);
|
||||||
set.add(2);
|
set.add(2);
|
||||||
}
|
}
|
||||||
|
|
||||||
var objects = {
|
var objects = {
|
||||||
'`arguments` objects': arguments,
|
'`arguments` objects': arguments,
|
||||||
'arrays': ['a', ''],
|
'arrays': ['a', ''],
|
||||||
@@ -2012,7 +2024,7 @@
|
|||||||
'Foo instances': new Foo,
|
'Foo instances': new Foo,
|
||||||
'objects': { 'a': 0, 'b': 1, 'c': 3 },
|
'objects': { 'a': 0, 'b': 1, 'c': 3 },
|
||||||
'objects with object values': { 'a': /a/, 'b': ['B'], 'c': { 'C': 1 } },
|
'objects with object values': { 'a': /a/, 'b': ['B'], 'c': { 'C': 1 } },
|
||||||
'objects from another document': _._object || {},
|
'objects from another document': realm.object || {},
|
||||||
'maps': map,
|
'maps': map,
|
||||||
'null values': null,
|
'null values': null,
|
||||||
'numbers': 3,
|
'numbers': 3,
|
||||||
@@ -2366,7 +2378,7 @@
|
|||||||
});
|
});
|
||||||
|
|
||||||
QUnit.test('`_.' + methodName + '` should support shortcut fusion', function(assert) {
|
QUnit.test('`_.' + methodName + '` should support shortcut fusion', function(assert) {
|
||||||
assert.expect(12);
|
assert.expect(6);
|
||||||
|
|
||||||
var filterCount,
|
var filterCount,
|
||||||
mapCount,
|
mapCount,
|
||||||
@@ -2387,28 +2399,20 @@
|
|||||||
take2 = _.curry(_.rearg(_.ary(_.take, 2), 1, 0), 2),
|
take2 = _.curry(_.rearg(_.ary(_.take, 2), 1, 0), 2),
|
||||||
take3 = (_.take = index ? take2 : take1, take2(2));
|
take3 = (_.take = index ? take2 : take1, take2(2));
|
||||||
|
|
||||||
_.times(2, function(index) {
|
var combined = isFlow
|
||||||
var fn = index ? _['_' + methodName] : func;
|
? func(map3, filter3, _.compact, take3)
|
||||||
if (!fn) {
|
: func(take3, _.compact, filter3, map3);
|
||||||
skipTest(assert, 3);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
var combined = isFlow
|
|
||||||
? fn(map3, filter3, _.compact, take3)
|
|
||||||
: fn(take3, _.compact, filter3, map3);
|
|
||||||
|
|
||||||
filterCount = mapCount = 0;
|
filterCount = mapCount = 0;
|
||||||
assert.deepEqual(combined(array), [4, 16]);
|
assert.deepEqual(combined(array), [4, 16]);
|
||||||
|
|
||||||
if (!isNpm && WeakMap && WeakMap.name) {
|
|
||||||
assert.strictEqual(filterCount, 5, 'filterCount');
|
|
||||||
assert.strictEqual(mapCount, 5, 'mapCount');
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
skipTest(assert, 2);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
|
if (!isNpm && WeakMap && WeakMap.name) {
|
||||||
|
assert.strictEqual(filterCount, 5, 'filterCount');
|
||||||
|
assert.strictEqual(mapCount, 5, 'mapCount');
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
skipTest(assert, 2);
|
||||||
|
}
|
||||||
_.filter = filter1;
|
_.filter = filter1;
|
||||||
_.map = map1;
|
_.map = map1;
|
||||||
_.take = take1;
|
_.take = take1;
|
||||||
@@ -7050,8 +7054,8 @@
|
|||||||
QUnit.test('should work with an `arguments` object from another realm', function(assert) {
|
QUnit.test('should work with an `arguments` object from another realm', function(assert) {
|
||||||
assert.expect(1);
|
assert.expect(1);
|
||||||
|
|
||||||
if (_._object) {
|
if (realm.arguments) {
|
||||||
assert.strictEqual(_.isArguments(_._arguments), true);
|
assert.strictEqual(_.isArguments(realm.arguments), true);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
skipTest(assert);
|
skipTest(assert);
|
||||||
@@ -7099,8 +7103,8 @@
|
|||||||
QUnit.test('should work with an array from another realm', function(assert) {
|
QUnit.test('should work with an array from another realm', function(assert) {
|
||||||
assert.expect(1);
|
assert.expect(1);
|
||||||
|
|
||||||
if (_._object) {
|
if (realm.array) {
|
||||||
assert.strictEqual(_.isArray(_._array), true);
|
assert.strictEqual(_.isArray(realm.array), true);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
skipTest(assert);
|
skipTest(assert);
|
||||||
@@ -7150,8 +7154,8 @@
|
|||||||
QUnit.test('should work with an array from another realm', function(assert) {
|
QUnit.test('should work with an array from another realm', function(assert) {
|
||||||
assert.expect(1);
|
assert.expect(1);
|
||||||
|
|
||||||
if (_._object) {
|
if (realm.object) {
|
||||||
var values = [_._arguments, _._array, _._string],
|
var values = [realm.arguments, realm.array, realm.string],
|
||||||
expected = _.map(values, _.constant(true)),
|
expected = _.map(values, _.constant(true)),
|
||||||
actual = _.map(values, _.isArrayLike);
|
actual = _.map(values, _.isArrayLike);
|
||||||
|
|
||||||
@@ -7206,8 +7210,8 @@
|
|||||||
QUnit.test('should work with a boolean from another realm', function(assert) {
|
QUnit.test('should work with a boolean from another realm', function(assert) {
|
||||||
assert.expect(1);
|
assert.expect(1);
|
||||||
|
|
||||||
if (_._object) {
|
if (realm.boolean) {
|
||||||
assert.strictEqual(_.isBoolean(_._boolean), true);
|
assert.strictEqual(_.isBoolean(realm.boolean), true);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
skipTest(assert);
|
skipTest(assert);
|
||||||
@@ -7255,8 +7259,8 @@
|
|||||||
QUnit.test('should work with a date object from another realm', function(assert) {
|
QUnit.test('should work with a date object from another realm', function(assert) {
|
||||||
assert.expect(1);
|
assert.expect(1);
|
||||||
|
|
||||||
if (_._object) {
|
if (realm.date) {
|
||||||
assert.strictEqual(_.isDate(_._date), true);
|
assert.strictEqual(_.isDate(realm.date), true);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
skipTest(assert);
|
skipTest(assert);
|
||||||
@@ -7317,8 +7321,8 @@
|
|||||||
QUnit.test('should work with a DOM element from another realm', function(assert) {
|
QUnit.test('should work with a DOM element from another realm', function(assert) {
|
||||||
assert.expect(1);
|
assert.expect(1);
|
||||||
|
|
||||||
if (_._element) {
|
if (realm.element) {
|
||||||
assert.strictEqual(_.isElement(_._element), true);
|
assert.strictEqual(_.isElement(realm.element), true);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
skipTest(assert);
|
skipTest(assert);
|
||||||
@@ -7961,11 +7965,11 @@
|
|||||||
QUnit.test('should return `true` for like-objects from different documents', function(assert) {
|
QUnit.test('should return `true` for like-objects from different documents', function(assert) {
|
||||||
assert.expect(4);
|
assert.expect(4);
|
||||||
|
|
||||||
if (_._object) {
|
if (realm.object) {
|
||||||
assert.strictEqual(_.isEqual({ 'a': 1, 'b': 2, 'c': 3 }, _._object), true);
|
assert.strictEqual(_.isEqual({ 'a': 1, 'b': 2, 'c': 3 }, realm.object), true);
|
||||||
assert.strictEqual(_.isEqual({ 'a': 1, 'b': 2, 'c': 2 }, _._object), false);
|
assert.strictEqual(_.isEqual({ 'a': 1, 'b': 2, 'c': 2 }, realm.object), false);
|
||||||
assert.strictEqual(_.isEqual([1, 2, 3], _._array), true);
|
assert.strictEqual(_.isEqual([1, 2, 3], realm.array), true);
|
||||||
assert.strictEqual(_.isEqual([1, 2, 2], _._array), false);
|
assert.strictEqual(_.isEqual([1, 2, 2], realm.array), false);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
skipTest(assert, 4);
|
skipTest(assert, 4);
|
||||||
@@ -8258,10 +8262,10 @@
|
|||||||
QUnit.test('should work with an error object from another realm', function(assert) {
|
QUnit.test('should work with an error object from another realm', function(assert) {
|
||||||
assert.expect(1);
|
assert.expect(1);
|
||||||
|
|
||||||
if (_._object) {
|
if (realm.errors) {
|
||||||
var expected = _.map(_._errors, _.constant(true));
|
var expected = _.map(realm.errors, _.constant(true));
|
||||||
|
|
||||||
var actual = _.map(_._errors, function(error) {
|
var actual = _.map(realm.errors, function(error) {
|
||||||
return _.isError(error) === true;
|
return _.isError(error) === true;
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -8418,8 +8422,8 @@
|
|||||||
QUnit.test('should work with a function from another realm', function(assert) {
|
QUnit.test('should work with a function from another realm', function(assert) {
|
||||||
assert.expect(1);
|
assert.expect(1);
|
||||||
|
|
||||||
if (_._object) {
|
if (realm.function) {
|
||||||
assert.strictEqual(_.isFunction(_._function), true);
|
assert.strictEqual(_.isFunction(realm.function), true);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
skipTest(assert);
|
skipTest(assert);
|
||||||
@@ -8933,8 +8937,8 @@
|
|||||||
QUnit.test('should work with `NaN` from another realm', function(assert) {
|
QUnit.test('should work with `NaN` from another realm', function(assert) {
|
||||||
assert.expect(1);
|
assert.expect(1);
|
||||||
|
|
||||||
if (_._object) {
|
if (realm.object) {
|
||||||
assert.strictEqual(_.isNaN(_._nan), true);
|
assert.strictEqual(_.isNaN(realm.nan), true);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
skipTest(assert);
|
skipTest(assert);
|
||||||
@@ -8996,14 +9000,14 @@
|
|||||||
QUnit.test('should work with native functions from another realm', function(assert) {
|
QUnit.test('should work with native functions from another realm', function(assert) {
|
||||||
assert.expect(2);
|
assert.expect(2);
|
||||||
|
|
||||||
if (_._element) {
|
if (realm.element) {
|
||||||
assert.strictEqual(_.isNative(_._element.cloneNode), true);
|
assert.strictEqual(_.isNative(realm.element.cloneNode), true);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
skipTest(assert);
|
skipTest(assert);
|
||||||
}
|
}
|
||||||
if (_._object) {
|
if (realm.object) {
|
||||||
assert.strictEqual(_.isNative(_._object.valueOf), true);
|
assert.strictEqual(_.isNative(realm.object.valueOf), true);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
skipTest(assert);
|
skipTest(assert);
|
||||||
@@ -9052,8 +9056,8 @@
|
|||||||
QUnit.test('should work with nulls from another realm', function(assert) {
|
QUnit.test('should work with nulls from another realm', function(assert) {
|
||||||
assert.expect(1);
|
assert.expect(1);
|
||||||
|
|
||||||
if (_._object) {
|
if (realm.object) {
|
||||||
assert.strictEqual(_.isNull(_._null), true);
|
assert.strictEqual(_.isNull(realm.null), true);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
skipTest(assert);
|
skipTest(assert);
|
||||||
@@ -9106,9 +9110,9 @@
|
|||||||
QUnit.test('should work with nulls from another realm', function(assert) {
|
QUnit.test('should work with nulls from another realm', function(assert) {
|
||||||
assert.expect(2);
|
assert.expect(2);
|
||||||
|
|
||||||
if (_._object) {
|
if (realm.object) {
|
||||||
assert.strictEqual(_.isNil(_._null), true);
|
assert.strictEqual(_.isNil(realm.null), true);
|
||||||
assert.strictEqual(_.isNil(_._undefined), true);
|
assert.strictEqual(_.isNil(realm.undefined), true);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
skipTest(assert, 2);
|
skipTest(assert, 2);
|
||||||
@@ -9157,8 +9161,8 @@
|
|||||||
QUnit.test('should work with numbers from another realm', function(assert) {
|
QUnit.test('should work with numbers from another realm', function(assert) {
|
||||||
assert.expect(1);
|
assert.expect(1);
|
||||||
|
|
||||||
if (_._object) {
|
if (realm.number) {
|
||||||
assert.strictEqual(_.isNumber(_._number), true);
|
assert.strictEqual(_.isNumber(realm.number), true);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
skipTest(assert);
|
skipTest(assert);
|
||||||
@@ -9218,20 +9222,20 @@
|
|||||||
QUnit.test('should work with objects from another realm', function(assert) {
|
QUnit.test('should work with objects from another realm', function(assert) {
|
||||||
assert.expect(8);
|
assert.expect(8);
|
||||||
|
|
||||||
if (_._element) {
|
if (realm.element) {
|
||||||
assert.strictEqual(_.isObject(_._element), true);
|
assert.strictEqual(_.isObject(realm.element), true);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
skipTest(assert);
|
skipTest(assert);
|
||||||
}
|
}
|
||||||
if (_._object) {
|
if (realm.object) {
|
||||||
assert.strictEqual(_.isObject(_._object), true);
|
assert.strictEqual(_.isObject(realm.boolean), true);
|
||||||
assert.strictEqual(_.isObject(_._boolean), true);
|
assert.strictEqual(_.isObject(realm.date), true);
|
||||||
assert.strictEqual(_.isObject(_._date), true);
|
assert.strictEqual(_.isObject(realm.function), true);
|
||||||
assert.strictEqual(_.isObject(_._function), true);
|
assert.strictEqual(_.isObject(realm.number), true);
|
||||||
assert.strictEqual(_.isObject(_._number), true);
|
assert.strictEqual(_.isObject(realm.object), true);
|
||||||
assert.strictEqual(_.isObject(_._regexp), true);
|
assert.strictEqual(_.isObject(realm.regexp), true);
|
||||||
assert.strictEqual(_.isObject(_._string), true);
|
assert.strictEqual(_.isObject(realm.string), true);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
skipTest(assert, 7);
|
skipTest(assert, 7);
|
||||||
@@ -9293,13 +9297,13 @@
|
|||||||
QUnit.test('should work with objects from another realm', function(assert) {
|
QUnit.test('should work with objects from another realm', function(assert) {
|
||||||
assert.expect(6);
|
assert.expect(6);
|
||||||
|
|
||||||
if (_._object) {
|
if (realm.object) {
|
||||||
assert.strictEqual(_.isObjectLike(_._object), true);
|
assert.strictEqual(_.isObjectLike(realm.boolean), true);
|
||||||
assert.strictEqual(_.isObjectLike(_._boolean), true);
|
assert.strictEqual(_.isObjectLike(realm.date), true);
|
||||||
assert.strictEqual(_.isObjectLike(_._date), true);
|
assert.strictEqual(_.isObjectLike(realm.number), true);
|
||||||
assert.strictEqual(_.isObjectLike(_._number), true);
|
assert.strictEqual(_.isObjectLike(realm.object), true);
|
||||||
assert.strictEqual(_.isObjectLike(_._regexp), true);
|
assert.strictEqual(_.isObjectLike(realm.regexp), true);
|
||||||
assert.strictEqual(_.isObjectLike(_._string), true);
|
assert.strictEqual(_.isObjectLike(realm.string), true);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
skipTest(assert, 6);
|
skipTest(assert, 6);
|
||||||
@@ -9396,8 +9400,8 @@
|
|||||||
QUnit.test('should work with objects from another realm', function(assert) {
|
QUnit.test('should work with objects from another realm', function(assert) {
|
||||||
assert.expect(1);
|
assert.expect(1);
|
||||||
|
|
||||||
if (_._object) {
|
if (realm.object) {
|
||||||
assert.strictEqual(_.isPlainObject(_._object), true);
|
assert.strictEqual(_.isPlainObject(realm.object), true);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
skipTest(assert);
|
skipTest(assert);
|
||||||
@@ -9446,8 +9450,8 @@
|
|||||||
QUnit.test('should work with regexes from another realm', function(assert) {
|
QUnit.test('should work with regexes from another realm', function(assert) {
|
||||||
assert.expect(1);
|
assert.expect(1);
|
||||||
|
|
||||||
if (_._object) {
|
if (realm.regexp) {
|
||||||
assert.strictEqual(_.isRegExp(_._regexp), true);
|
assert.strictEqual(_.isRegExp(realm.regexp), true);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
skipTest(assert);
|
skipTest(assert);
|
||||||
@@ -9496,8 +9500,8 @@
|
|||||||
QUnit.test('should work with strings from another realm', function(assert) {
|
QUnit.test('should work with strings from another realm', function(assert) {
|
||||||
assert.expect(1);
|
assert.expect(1);
|
||||||
|
|
||||||
if (_._object) {
|
if (realm.string) {
|
||||||
assert.strictEqual(_.isString(_._string), true);
|
assert.strictEqual(_.isString(realm.string), true);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
skipTest(assert);
|
skipTest(assert);
|
||||||
@@ -9555,17 +9559,15 @@
|
|||||||
QUnit.test('should work with typed arrays from another realm', function(assert) {
|
QUnit.test('should work with typed arrays from another realm', function(assert) {
|
||||||
assert.expect(1);
|
assert.expect(1);
|
||||||
|
|
||||||
if (_._object) {
|
if (realm.object) {
|
||||||
var props = _.map(typedArrays, function(type) {
|
var props = _.invoke(typedArrays, 'toLowerCase');
|
||||||
return '_' + type.toLowerCase();
|
|
||||||
});
|
|
||||||
|
|
||||||
var expected = _.map(props, function(key) {
|
var expected = _.map(props, function(key) {
|
||||||
return key in _;
|
return key in realm;
|
||||||
});
|
});
|
||||||
|
|
||||||
var actual = _.map(props, function(key) {
|
var actual = _.map(props, function(key) {
|
||||||
var value = _[key];
|
var value = realm[key];
|
||||||
return value ? _.isTypedArray(value) : false;
|
return value ? _.isTypedArray(value) : false;
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -9619,8 +9621,8 @@
|
|||||||
QUnit.test('should work with `undefined` from another realm', function(assert) {
|
QUnit.test('should work with `undefined` from another realm', function(assert) {
|
||||||
assert.expect(1);
|
assert.expect(1);
|
||||||
|
|
||||||
if (_._object) {
|
if (realm.object) {
|
||||||
assert.strictEqual(_.isUndefined(_._undefined), true);
|
assert.strictEqual(_.isUndefined(realm.undefined), true);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
skipTest(assert);
|
skipTest(assert);
|
||||||
@@ -13219,7 +13221,7 @@
|
|||||||
QUnit.test('should work with a `root` of `this`', function(assert) {
|
QUnit.test('should work with a `root` of `this`', function(assert) {
|
||||||
assert.expect(2);
|
assert.expect(2);
|
||||||
|
|
||||||
if (!isModularize && !document && _._object) {
|
if (!isModularize && !document && realm.object) {
|
||||||
var fs = require('fs'),
|
var fs = require('fs'),
|
||||||
vm = require('vm'),
|
vm = require('vm'),
|
||||||
expected = {},
|
expected = {},
|
||||||
|
|||||||
Reference in New Issue
Block a user