mirror of
https://github.com/whoisclebs/lodash.git
synced 2026-02-06 01:47:48 +00:00
Add bizarro _.create test.
This commit is contained in:
@@ -85,9 +85,9 @@
|
|||||||
setProperty(Object, '_create', Object.create);
|
setProperty(Object, '_create', Object.create);
|
||||||
setProperty(Object, 'create', (function() {
|
setProperty(Object, 'create', (function() {
|
||||||
function object() {}
|
function object() {}
|
||||||
return function(prototype) {
|
return function(proto) {
|
||||||
if (prototype === Object(prototype)) {
|
if (proto === Object(proto)) {
|
||||||
object.prototype = prototype;
|
object.prototype = proto;
|
||||||
var result = new object;
|
var result = new object;
|
||||||
object.prototype = undefined;
|
object.prototype = undefined;
|
||||||
}
|
}
|
||||||
|
|||||||
18
test/test.js
18
test/test.js
@@ -520,9 +520,9 @@
|
|||||||
// Set bad shims.
|
// Set bad shims.
|
||||||
setProperty(Object, 'create', (function() {
|
setProperty(Object, 'create', (function() {
|
||||||
function object() {}
|
function object() {}
|
||||||
return function(prototype) {
|
return function(proto) {
|
||||||
if (lodashStable.isObject(prototype)) {
|
if (lodashStable.isObject(proto)) {
|
||||||
object.prototype = prototype;
|
object.prototype = proto;
|
||||||
var result = new object;
|
var result = new object;
|
||||||
object.prototype = undefined;
|
object.prototype = undefined;
|
||||||
}
|
}
|
||||||
@@ -823,7 +823,7 @@
|
|||||||
});
|
});
|
||||||
|
|
||||||
QUnit.test('should avoid non-native built-ins', function(assert) {
|
QUnit.test('should avoid non-native built-ins', function(assert) {
|
||||||
assert.expect(7);
|
assert.expect(8);
|
||||||
|
|
||||||
function message(lodashMethod, nativeMethod) {
|
function message(lodashMethod, nativeMethod) {
|
||||||
return '`' + lodashMethod + '` should avoid overwritten native `' + nativeMethod + '`';
|
return '`' + lodashMethod + '` should avoid overwritten native `' + nativeMethod + '`';
|
||||||
@@ -855,6 +855,14 @@
|
|||||||
var label = message('_.isEmpty', 'Object#propertyIsEnumerable');
|
var label = message('_.isEmpty', 'Object#propertyIsEnumerable');
|
||||||
assert.strictEqual(actual, true, label);
|
assert.strictEqual(actual, true, label);
|
||||||
|
|
||||||
|
try {
|
||||||
|
actual = lodashBizarro.create(Foo.prototype);
|
||||||
|
} catch (e) {
|
||||||
|
actual = null;
|
||||||
|
}
|
||||||
|
label = message('_.create', 'Object.create');
|
||||||
|
assert.ok(actual instanceof Foo, label);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
actual = [
|
actual = [
|
||||||
lodashBizarro.difference([object, otherObject], largeArray),
|
lodashBizarro.difference([object, otherObject], largeArray),
|
||||||
@@ -920,7 +928,7 @@
|
|||||||
assert.deepEqual(actual, [], label);
|
assert.deepEqual(actual, [], label);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
skipAssert(assert, 7);
|
skipAssert(assert, 8);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}());
|
}());
|
||||||
|
|||||||
Reference in New Issue
Block a user