From 5360dd151da9d8b1c97785a0e394cc731af31f69 Mon Sep 17 00:00:00 2001 From: Ruben Bridgewater Date: Mon, 2 Dec 2019 13:12:52 +0100 Subject: assert: handle (deep) equal(NaN, NaN) as being identical This aligns the `equal` and `deepEqual()` implementations with the strict versions by accepting `NaN` as being identical in case both sides are NaN. Refs: https://github.com/nodejs/node/issues/30350#issuecomment-552191641 PR-URL: https://github.com/nodejs/node/pull/30766 Reviewed-By: James M Snell Reviewed-By: Denys Otrishko Reviewed-By: Anna Henningsen Reviewed-By: David Carlier Reviewed-By: Rich Trott --- doc/api/assert.md | 29 ++++++++++++++++++++++++++--- 1 file changed, 26 insertions(+), 3 deletions(-) (limited to 'doc/api') diff --git a/doc/api/assert.md b/doc/api/assert.md index 9d1a7fb7e1..05df0d4483 100644 --- a/doc/api/assert.md +++ b/doc/api/assert.md @@ -160,6 +160,10 @@ An alias of [`assert.ok()`][]. * `actual` {any} @@ -569,7 +579,8 @@ An alias of [`assert.strictEqual()`][]. > Stability: 0 - Deprecated: Use [`assert.strictEqual()`][] instead. Tests shallow, coercive equality between the `actual` and `expected` parameters -using the [Abstract Equality Comparison][] ( `==` ). +using the [Abstract Equality Comparison][] ( `==` ). `NaN` is special handled +and treated as being identical in case both sides are `NaN`. ```js const assert = require('assert'); @@ -578,6 +589,8 @@ assert.equal(1, 1); // OK, 1 == 1 assert.equal(1, '1'); // OK, 1 == '1' +assert.equal(NaN, NaN); +// OK assert.equal(1, 2); // AssertionError: 1 == 2 @@ -732,6 +745,10 @@ let err; * `actual` {any} @@ -868,7 +890,8 @@ An alias of [`assert.notStrictEqual()`][]. > Stability: 0 - Deprecated: Use [`assert.notStrictEqual()`][] instead. Tests shallow, coercive inequality with the [Abstract Equality Comparison][] -( `!=` ). +(`!=` ). `NaN` is special handled and treated as being identical in case both +sides are `NaN`. ```js const assert = require('assert'); -- cgit v1.2.3