From e2cf7f3d8460834044e1eb860d72adc71080fc73 Mon Sep 17 00:00:00 2001 From: teppeis Date: Sun, 21 Dec 2014 19:13:34 +0900 Subject: [PATCH 1/2] remove unnecessary call to isNaN() from https://github.com/joyent/node/commit/b87ca794e31096b61ead46911baf92ba1c020a7d#diff-1 --- assert.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/assert.js b/assert.js index be6a0db..6d15eb3 100644 --- a/assert.js +++ b/assert.js @@ -86,7 +86,7 @@ function replacer(key, value) { if (util.isUndefined(value)) { return '' + value; } - if (util.isNumber(value) && (isNaN(value) || !isFinite(value))) { + if (util.isNumber(value) && !isFinite(value)) { return value.toString(); } if (util.isFunction(value) || util.isRegExp(value)) { From ae6abd7a9e7fcce64f7b8d8f4c5ea46b8747e251 Mon Sep 17 00:00:00 2001 From: teppeis Date: Sun, 21 Dec 2014 19:08:23 +0900 Subject: [PATCH 2/2] ensure that deepEqual does not depend on arguments order from https://github.com/joyent/node/commit/aae51ecf7d407b2fb56c1f3e1edf91a16940c973 --- assert.js | 9 +++++---- test.js | 5 +++++ 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/assert.js b/assert.js index 6d15eb3..08d2ca2 100644 --- a/assert.js +++ b/assert.js @@ -227,10 +227,11 @@ function objEquiv(a, b) { if (a.prototype !== b.prototype) return false; //~~~I've managed to break Object.keys through screwy arguments passing. // Converting to array solves the problem. - if (isArguments(a)) { - if (!isArguments(b)) { - return false; - } + var aIsArgs = isArguments(a), + bIsArgs = isArguments(b); + if ((aIsArgs && !bIsArgs) || (!aIsArgs && bIsArgs)) + return false; + if (aIsArgs) { a = pSlice.call(a); b = pSlice.call(b); return _deepEqual(a, b); diff --git a/test.js b/test.js index 3151a93..a6200d3 100644 --- a/test.js +++ b/test.js @@ -264,6 +264,11 @@ test('assert - Make sure deepEqual doesn\'t loop forever on circular refs', func assert.ok(gotError); }); +test('assert - Ensure reflexivity of deepEqual with `arguments` objects', function() { + var args = (function() { return arguments; })(); + assert.throws(makeBlock(assert.deepEqual, [], args), assert.AssertionError); + assert.throws(makeBlock(assert.deepEqual, args, []), assert.AssertionError); +}); test('assert - test assertion message', function () { function testAssertionMessage(actual, expected) {