mirror of
https://github.com/whoisclebs/lodash.git
synced 2026-02-02 08:07:50 +00:00
Ensure isType methods return false for subclassed values.
Former-commit-id: e300d12eb506c6ae4949bd37cf8eb33c3a4be2e1
This commit is contained in:
@@ -961,11 +961,6 @@
|
||||
|
||||
strictEqual(actual, false, '_.isEqual should ignore `callback` and `thisArg`: ' + basename);
|
||||
|
||||
_.each(['isArray', 'isBoolean', 'isDate', 'isFunction', 'isNumber', 'isRegExp', 'isString'], function(methodName) {
|
||||
var proto = global[methodName.slice(2)].prototype;
|
||||
strictEqual(lodash[methodName](Object.create(proto)), false, '_.' + methodName + ' returns `false` for subclassed values: ' + basename);
|
||||
});
|
||||
|
||||
equal(lodash.max('abc'), -Infinity, '_.max should return `-Infinity` for strings: ' + basename);
|
||||
equal(lodash.min('abc'), Infinity, '_.min should return `Infinity` for strings: ' + basename);
|
||||
|
||||
|
||||
@@ -1611,6 +1611,15 @@
|
||||
equal(typeof func({ 'a': 1 }), expected);
|
||||
equal(typeof func('a'), expected);
|
||||
});
|
||||
|
||||
test('should return `false` for subclassed values', function() {
|
||||
_.each(['isArray', 'isBoolean', 'isDate', 'isFunction', 'isNumber', 'isRegExp', 'isString'], function(methodName) {
|
||||
function Foo() {}
|
||||
Foo.prototype = window[methodName.slice(2)].prototype;
|
||||
|
||||
strictEqual(_[methodName](new Foo), false, '_.' + methodName + ' returns `false`');
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
/*--------------------------------------------------------------------------*/
|
||||
|
||||
Reference in New Issue
Block a user