diff options
Diffstat (limited to 'doc/api/assert.md')
-rw-r--r-- | doc/api/assert.md | 29 |
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'); |