diff options
author | teppeis <teppeis@gmail.com> | 2014-12-22 00:56:33 +0900 |
---|---|---|
committer | Ben Noordhuis <info@bnoordhuis.nl> | 2014-12-22 12:46:59 +0100 |
commit | 00a7456c1958b0bf2db7b6cd42ffb598b29d3b41 (patch) | |
tree | c830f23e657070dc4cca0e91a8499785cbf966b5 /lib/assert.js | |
parent | ef10827c9f940e0afcde21639439ca95d134ffe4 (diff) | |
download | android-node-v8-00a7456c1958b0bf2db7b6cd42ffb598b29d3b41.tar.gz android-node-v8-00a7456c1958b0bf2db7b6cd42ffb598b29d3b41.tar.bz2 android-node-v8-00a7456c1958b0bf2db7b6cd42ffb598b29d3b41.zip |
assert: fix deepEqual regression
Change of Object.keys in ES6 breaks assert.deepEqual about primitive
values.
V8: https://code.google.com/p/v8/issues/detail?id=3443
Previously deepEqual depends on Object.key that throws an error for
a primitive value, but now Object.key does not throw.
PR-URL: https://github.com/iojs/io.js/pull/193
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Diffstat (limited to 'lib/assert.js')
-rw-r--r-- | lib/assert.js | 15 |
1 files changed, 6 insertions, 9 deletions
diff --git a/lib/assert.js b/lib/assert.js index a05a487288..7e18a071e9 100644 --- a/lib/assert.js +++ b/lib/assert.js @@ -201,8 +201,9 @@ function objEquiv(a, b) { return false; // an identical 'prototype' property. 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 one is a primitive, the other must be same + if (util.isPrimitive(a) || util.isPrimitive(b)) + return a === b; var aIsArgs = isArguments(a), bIsArgs = isArguments(b); if ((aIsArgs && !bIsArgs) || (!aIsArgs && bIsArgs)) @@ -212,13 +213,9 @@ function objEquiv(a, b) { b = pSlice.call(b); return _deepEqual(a, b); } - try { - var ka = Object.keys(a), - kb = Object.keys(b), - key, i; - } catch (e) {//happens when one is a string literal and the other isn't - return false; - } + var ka = Object.keys(a), + kb = Object.keys(b), + key, i; // having the same number of owned properties (keys incorporates // hasOwnProperty) if (ka.length != kb.length) |