Ensure isType methods return false for subclassed values.

Former-commit-id: e300d12eb506c6ae4949bd37cf8eb33c3a4be2e1
This commit is contained in:
John-David Dalton
2013-04-19 00:12:22 -07:00
parent 3bb119f578
commit a707c2fe8e
4 changed files with 58 additions and 50 deletions

View File

@@ -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);

View File

@@ -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`');
});
});
});
/*--------------------------------------------------------------------------*/