@@ -160,6 +160,10 @@ An alias of [`assert.ok()`][].
160
160
<!-- YAML
161
161
added: v0.1.21
162
162
changes:
163
+ - version: REPLACEME
164
+ pr-url: https://github.com/nodejs/node/pull/30766
165
+ description: NaN is now treated as being identical in case both sides are
166
+ NaN.
163
167
- version: v12.0.0
164
168
pr-url: https://github.com/nodejs/node/pull/25008
165
169
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.
203
207
### Comparison details
204
208
205
209
* Primitive values are compared with the [ Abstract Equality Comparison] [ ]
206
- ( ` == ` ).
210
+ ( ` == ` ) with the exception of ` NaN ` . It is treated as being identical in case
211
+ both sides are ` NaN ` .
207
212
* [ Type tags] [ Object.prototype.toString() ] of objects should be the same.
208
213
* Only [ enumerable "own" properties] [ ] are considered.
209
214
* [ ` Error ` ] [ ] names and messages are always compared, even if these are not
@@ -554,6 +559,11 @@ assert.doesNotThrow(
554
559
## assert.equal(actual, expected\[ , message\] )
555
560
<!-- YAML
556
561
added: v0.1.21
562
+ changes:
563
+ - version: REPLACEME
564
+ pr-url: https://github.com/nodejs/node/pull/30766
565
+ description: NaN is now treated as being identical in case both sides are
566
+ NaN.
557
567
-->
558
568
559
569
* ` actual ` {any}
@@ -569,7 +579,8 @@ An alias of [`assert.strictEqual()`][].
569
579
> Stability: 0 - Deprecated: Use [ ` assert.strictEqual() ` ] [ ] instead.
570
580
571
581
Tests shallow, coercive equality between the ` actual ` and ` expected ` parameters
572
- using the [ Abstract Equality Comparison] [ ] ( ` == ` ).
582
+ using the [ Abstract Equality Comparison] [ ] ( ` == ` ). ` NaN ` is special handled
583
+ and treated as being identical in case both sides are ` NaN ` .
573
584
574
585
``` js
575
586
const assert = require (' assert' );
@@ -578,6 +589,8 @@ assert.equal(1, 1);
578
589
// OK, 1 == 1
579
590
assert .equal (1 , ' 1' );
580
591
// OK, 1 == '1'
592
+ assert .equal (NaN , NaN );
593
+ // OK
581
594
582
595
assert .equal (1 , 2 );
583
596
// AssertionError: 1 == 2
@@ -732,6 +745,10 @@ let err;
732
745
<!-- YAML
733
746
added: v0.1.21
734
747
changes:
748
+ - version: REPLACEME
749
+ pr-url: https://github.com/nodejs/node/pull/30766
750
+ description: NaN is now treated as being identical in case both sides are
751
+ NaN.
735
752
- version: v9.0.0
736
753
pr-url: https://github.com/nodejs/node/pull/15001
737
754
description: The `Error` names and messages are now properly compared
@@ -853,6 +870,11 @@ instead of the [`AssertionError`][].
853
870
## assert.notEqual(actual, expected\[ , message\] )
854
871
<!-- YAML
855
872
added: v0.1.21
873
+ changes:
874
+ - version: REPLACEME
875
+ pr-url: https://github.com/nodejs/node/pull/30766
876
+ description: NaN is now treated as being identical in case both sides are
877
+ NaN.
856
878
-->
857
879
858
880
* ` actual ` {any}
@@ -868,7 +890,8 @@ An alias of [`assert.notStrictEqual()`][].
868
890
> Stability: 0 - Deprecated: Use [ ` assert.notStrictEqual() ` ] [ ] instead.
869
891
870
892
Tests shallow, coercive inequality with the [ Abstract Equality Comparison] [ ]
871
- ( ` != ` ).
893
+ (` != ` ). ` NaN ` is special handled and treated as being identical in case both
894
+ sides are ` NaN ` .
872
895
873
896
``` js
874
897
const assert = require (' assert' );
0 commit comments