Check for custom isEqual methods in _.isEqual before other comparisons and add cross-browser support for arguments objects.

Former-commit-id: 56e40f670309aeb0dcda7868c8aa84b5909db1f1
This commit is contained in:
John-David Dalton
2012-07-24 01:45:34 -07:00
parent 7088ab89f1
commit ed89a3e0f8
2 changed files with 24 additions and 10 deletions

View File

@@ -671,6 +671,20 @@
QUnit.module('lodash.isEqual');
(function() {
test('should work with `arguments` objects (test in IE < 9)', function() {
var args1 = (function() { return arguments; }(1, 2, 3)),
args2 = (function() { return arguments; }(1, 2, 3)),
args3 = (function() { return arguments; }(1, 2));
equal(_.isEqual(args1, args2), true);
equal(_.isEqual(args1, args3), false);
});
test('should respect custom `isEqual` result despite objects strict equaling each other', function() {
var object = { 'isEqual': function() { return false; } };
equal(_.isEqual(object, object), false);
});
test('fixes the JScript [[DontEnum]] bug (test in IE < 9)', function() {
equal(_.isEqual(shadowed, {}), false);
});