From 8da49c143bfd7dc4c93d9bf80a0462655b8772c9 Mon Sep 17 00:00:00 2001 From: Ruben Bridgewater Date: Sat, 19 Aug 2017 02:50:57 -0300 Subject: [PATCH] assert: use Same-value equality in deepStrictEqual PR-URL: https://github.com/nodejs/node/pull/15398 Reviewed-By: James M Snell Reviewed-By: Colin Ihrig Reviewed-By: Anna Henningsen Reviewed-By: Rich Trott --- doc/api/assert.md | 9 ++++++ lib/assert.js | 25 +++++++++-------- test/parallel/test-assert-deep.js | 3 ++ .../test-assert-typedarray-deepequal.js | 28 +++++++++++++++---- 4 files changed, 48 insertions(+), 17 deletions(-) diff --git a/doc/api/assert.md b/doc/api/assert.md index b53e221416..ca7f048f9e 100644 --- a/doc/api/assert.md +++ b/doc/api/assert.md @@ -142,6 +142,7 @@ Generally identical to `assert.deepEqual()` with a few exceptions: the [Strict Equality Comparison][] too. 3. [Type tags][Object.prototype.toString()] of objects should be the same. 4. [Object wrappers][] are compared both as objects and unwrapped values. +5. `0` and `-0` are not considered equal. ```js const assert = require('assert'); @@ -179,6 +180,11 @@ assert.deepStrictEqual(new Number(1), new Number(2)); // Fails because the wrapped number is unwrapped and compared as well. assert.deepStrictEqual(new String('foo'), Object('foo')); // OK because the object and the string are identical when unwrapped. + +assert.deepStrictEqual(-0, -0); +// OK +assert.deepStrictEqual(0, -0); +// AssertionError: 0 deepStrictEqual -0 ``` If the values are not equal, an `AssertionError` is thrown with a `message` @@ -438,6 +444,9 @@ parameter is an instance of an `Error` then it will be thrown instead of the