Skip to content

Commit 2c27df2

Browse files
BridgeARtargos
authored andcommitted
test: run more assert tests
This makes sure the assertion does not depend on the argument order. It also removes comments that do not apply anymore and verifies the behavior for the loose and strict implementation. PR-URL: #30764 Refs: #30743 Reviewed-By: James M Snell <[email protected]> Reviewed-By: David Carlier <[email protected]> Reviewed-By: Rich Trott <[email protected]>
1 parent 1f68004 commit 2c27df2

File tree

1 file changed

+9
-16
lines changed

1 file changed

+9
-16
lines changed

test/parallel/test-assert-deep.js

+9-16
Original file line numberDiff line numberDiff line change
@@ -109,10 +109,7 @@ class MyDate extends Date {
109109

110110
const date2 = new MyDate('2016');
111111

112-
// deepEqual returns true as long as the time are the same,
113-
// but deepStrictEqual checks own properties
114-
assert.notDeepEqual(date, date2);
115-
assert.notDeepEqual(date2, date);
112+
assertNotDeepOrStrict(date, date2);
116113
assert.throws(
117114
() => assert.deepStrictEqual(date, date2),
118115
{
@@ -142,9 +139,7 @@ class MyRegExp extends RegExp {
142139
const re1 = new RegExp('test');
143140
const re2 = new MyRegExp('test');
144141

145-
// deepEqual returns true as long as the regexp-specific properties
146-
// are the same, but deepStrictEqual checks all properties
147-
assert.notDeepEqual(re1, re2);
142+
assertNotDeepOrStrict(re1, re2);
148143
assert.throws(
149144
() => assert.deepStrictEqual(re1, re2),
150145
{
@@ -684,7 +679,7 @@ assert.throws(
684679
}
685680
);
686681

687-
assert.deepEqual(new Date(2000, 3, 14), new Date(2000, 3, 14));
682+
assertDeepAndStrictEqual(new Date(2000, 3, 14), new Date(2000, 3, 14));
688683

689684
assert.throws(() => { assert.deepEqual(new Date(), new Date(2000, 3, 14)); },
690685
AssertionError,
@@ -702,7 +697,7 @@ assert.throws(
702697
'notDeepEqual("a".repeat(1024), "a".repeat(1024))'
703698
);
704699

705-
assert.notDeepEqual(new Date(), new Date(2000, 3, 14));
700+
assertNotDeepOrStrict(new Date(), new Date(2000, 3, 14));
706701

707702
assertDeepAndStrictEqual(/a/, /a/);
708703
assertDeepAndStrictEqual(/a/g, /a/g);
@@ -743,7 +738,7 @@ a2.b = true;
743738
a2.a = 'test';
744739
assert.throws(() => assert.deepEqual(Object.keys(a1), Object.keys(a2)),
745740
AssertionError);
746-
assert.deepEqual(a1, a2);
741+
assertDeepAndStrictEqual(a1, a2);
747742

748743
// Having an identical prototype property.
749744
const nbRoot = {
@@ -899,14 +894,12 @@ assert.throws(
899894

900895
/* eslint-enable */
901896

902-
assert.deepStrictEqual({ a: 4, b: '1' }, { b: '1', a: 4 });
897+
assertDeepAndStrictEqual({ a: 4, b: '1' }, { b: '1', a: 4 });
903898

904899
assert.throws(
905900
() => assert.deepStrictEqual([0, 1, 2, 'a', 'b'], [0, 1, 2, 'b', 'a']),
906901
AssertionError);
907902

908-
assert.deepStrictEqual(a1, a2);
909-
910903
// Prototype check.
911904
function Constructor1(first, last) {
912905
this.first = first;
@@ -926,7 +919,7 @@ assert.throws(() => assert.deepStrictEqual(obj1, obj2), AssertionError);
926919
Constructor2.prototype = Constructor1.prototype;
927920
obj2 = new Constructor2('Ryan', 'Dahl');
928921

929-
assert.deepStrictEqual(obj1, obj2);
922+
assertDeepAndStrictEqual(obj1, obj2);
930923

931924
// Check extra properties on errors.
932925
{
@@ -1047,7 +1040,7 @@ assert.throws(
10471040
Object.defineProperty(a, 'getTime', {
10481041
value: () => 5
10491042
});
1050-
assert.deepStrictEqual(a, b);
1043+
assertDeepAndStrictEqual(a, b);
10511044
}
10521045

10531046
// Verify that an array and the equivalent fake array object
@@ -1079,7 +1072,7 @@ assert.throws(
10791072
Object.defineProperty(a, 'length', {
10801073
value: 2
10811074
});
1082-
assert.notDeepStrictEqual(a, [1, 1]);
1075+
assertNotDeepOrStrict(a, [1, 1]);
10831076
}
10841077

10851078
// Verify that changed tags will still check for the error message.

0 commit comments

Comments
 (0)