summaryrefslogtreecommitdiff
path: root/doc/api/assert.md
diff options
context:
space:
mode:
authorRuben Bridgewater <ruben@bridgewater.de>2019-12-02 13:12:52 +0100
committerRuben Bridgewater <ruben@bridgewater.de>2019-12-07 00:43:51 +0100
commit5360dd151da9d8b1c97785a0e394cc731af31f69 (patch)
treef8bee2cd4810c7ee9e168fdfcb84397dca37c5ad /doc/api/assert.md
parentb5f2942fb55055b5a8b5de290953f81d2e291005 (diff)
downloadandroid-node-v8-5360dd151da9d8b1c97785a0e394cc731af31f69.tar.gz
android-node-v8-5360dd151da9d8b1c97785a0e394cc731af31f69.tar.bz2
android-node-v8-5360dd151da9d8b1c97785a0e394cc731af31f69.zip
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 <jasnell@gmail.com> Reviewed-By: Denys Otrishko <shishugi@gmail.com> Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: David Carlier <devnexen@gmail.com> Reviewed-By: Rich Trott <rtrott@gmail.com>
Diffstat (limited to 'doc/api/assert.md')
-rw-r--r--doc/api/assert.md29
1 files changed, 26 insertions, 3 deletions
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()`][].
<!-- YAML
added: v0.1.21
changes:
+ - version: REPLACEME
+ pr-url: https://github.com/nodejs/node/pull/30766
+ description: NaN is now treated as being identical in case both sides are
+ NaN.
- version: v12.0.0
pr-url: https://github.com/nodejs/node/pull/25008
description: The type tags are now properly compared and there are a couple
@@ -203,7 +207,8 @@ are also recursively evaluated by the following rules.
### Comparison details
* Primitive values are compared with the [Abstract Equality Comparison][]
- ( `==` ).
+ ( `==` ) with the exception of `NaN`. It is treated as being identical in case
+ both sides are `NaN`.
* [Type tags][Object.prototype.toString()] of objects should be the same.
* Only [enumerable "own" properties][] are considered.
* [`Error`][] names and messages are always compared, even if these are not
@@ -554,6 +559,11 @@ assert.doesNotThrow(
## assert.equal(actual, expected\[, message\])
<!-- YAML
added: v0.1.21
+changes:
+ - version: REPLACEME
+ pr-url: https://github.com/nodejs/node/pull/30766
+ description: NaN is now treated as being identical in case both sides are
+ NaN.
-->
* `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;
<!-- YAML
added: v0.1.21
changes:
+ - version: REPLACEME
+ pr-url: https://github.com/nodejs/node/pull/30766
+ description: NaN is now treated as being identical in case both sides are
+ NaN.
- version: v9.0.0
pr-url: https://github.com/nodejs/node/pull/15001
description: The `Error` names and messages are now properly compared
@@ -853,6 +870,11 @@ instead of the [`AssertionError`][].
## assert.notEqual(actual, expected\[, message\])
<!-- YAML
added: v0.1.21
+changes:
+ - version: REPLACEME
+ pr-url: https://github.com/nodejs/node/pull/30766
+ description: NaN is now treated as being identical in case both sides are
+ NaN.
-->
* `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');