From 6ab04866ecc7891464e30ad1337ebb7184b3cbd4 Mon Sep 17 00:00:00 2001 From: John-David Dalton Date: Wed, 11 Jun 2014 12:23:42 -0700 Subject: [PATCH] Fix failing tests. --- lodash.js | 10 ++++++---- test/test.js | 3 ++- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/lodash.js b/lodash.js index 2471d85ba..d5039ce7b 100644 --- a/lodash.js +++ b/lodash.js @@ -1791,6 +1791,10 @@ // to `1` or `0` treating invalid dates coerced to `NaN` as not equal return +value == +other; + case errorClass: + // check properties instead of coercing to strings to support IE < 8 + return value.name === other.name && value.message === other.message; + case numberClass: // treat `NaN` vs. `NaN` as equal return (value != +value) @@ -1798,12 +1802,10 @@ // but treat `-0` vs. `+0` as not equal : (value == 0 ? (1 / value == 1 / other) : value == +other); - case errorClass: case regexpClass: case stringClass: - // coerce errors (http://es5.github.io/#x15.11.4.4) - // and regexes (http://es5.github.io/#x15.10.6.4) to strings - // treat string primitives and their corresponding object instances as equal + // coerce regexes to strings (http://es5.github.io/#x15.10.6.4) + // treat string primitives and object instances as equal return value == String(other); } if (!support.argsClass) { diff --git a/test/test.js b/test/test.js index e80b28f82..059ecfd1d 100644 --- a/test/test.js +++ b/test/test.js @@ -1272,6 +1272,7 @@ _.forOwn(objects, function(object, key) { test('`_.' + methodName + '` should clone ' + key, 2, function() { var actual = func(object); + ok(_.isEqual(actual, object)); if (_.isObject(object)) { @@ -1294,7 +1295,7 @@ error = new Ctor('text'), actual = func(error); - deepEqual(actual, error); + ok(_.isEqual(actual, error)); notStrictEqual(actual, error); }); });