diff options
author | Ruben Bridgewater <ruben@bridgewater.de> | 2019-12-02 13:15:11 +0100 |
---|---|---|
committer | Beth Griggs <Bethany.Griggs@uk.ibm.com> | 2020-02-06 02:49:27 +0000 |
commit | 6086a1dd6167343d6fd01294c20b2e84f77025ff (patch) | |
tree | df0a8a5b72e742e34b3aea9f80087d21937826f9 /test | |
parent | a0f338ecc1df843dc221d4cd0ceae0af569af41a (diff) | |
download | node-new-6086a1dd6167343d6fd01294c20b2e84f77025ff.tar.gz |
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: https://github.com/nodejs/node/pull/30764
Refs: https://github.com/nodejs/node/pull/30743
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: David Carlier <devnexen@gmail.com>
Reviewed-By: Rich Trott <rtrott@gmail.com>
Diffstat (limited to 'test')
-rw-r--r-- | test/parallel/test-assert-deep.js | 25 |
1 files changed, 9 insertions, 16 deletions
diff --git a/test/parallel/test-assert-deep.js b/test/parallel/test-assert-deep.js index 92e04634dc..fcc3765105 100644 --- a/test/parallel/test-assert-deep.js +++ b/test/parallel/test-assert-deep.js @@ -109,10 +109,7 @@ class MyDate extends Date { const date2 = new MyDate('2016'); -// deepEqual returns true as long as the time are the same, -// but deepStrictEqual checks own properties -assert.notDeepEqual(date, date2); -assert.notDeepEqual(date2, date); +assertNotDeepOrStrict(date, date2); assert.throws( () => assert.deepStrictEqual(date, date2), { @@ -142,9 +139,7 @@ class MyRegExp extends RegExp { const re1 = new RegExp('test'); const re2 = new MyRegExp('test'); -// deepEqual returns true as long as the regexp-specific properties -// are the same, but deepStrictEqual checks all properties -assert.notDeepEqual(re1, re2); +assertNotDeepOrStrict(re1, re2); assert.throws( () => assert.deepStrictEqual(re1, re2), { @@ -684,7 +679,7 @@ assert.throws( } ); -assert.deepEqual(new Date(2000, 3, 14), new Date(2000, 3, 14)); +assertDeepAndStrictEqual(new Date(2000, 3, 14), new Date(2000, 3, 14)); assert.throws(() => { assert.deepEqual(new Date(), new Date(2000, 3, 14)); }, AssertionError, @@ -702,7 +697,7 @@ assert.throws( 'notDeepEqual("a".repeat(1024), "a".repeat(1024))' ); -assert.notDeepEqual(new Date(), new Date(2000, 3, 14)); +assertNotDeepOrStrict(new Date(), new Date(2000, 3, 14)); assertDeepAndStrictEqual(/a/, /a/); assertDeepAndStrictEqual(/a/g, /a/g); @@ -743,7 +738,7 @@ a2.b = true; a2.a = 'test'; assert.throws(() => assert.deepEqual(Object.keys(a1), Object.keys(a2)), AssertionError); -assert.deepEqual(a1, a2); +assertDeepAndStrictEqual(a1, a2); // Having an identical prototype property. const nbRoot = { @@ -899,14 +894,12 @@ assert.throws( /* eslint-enable */ -assert.deepStrictEqual({ a: 4, b: '1' }, { b: '1', a: 4 }); +assertDeepAndStrictEqual({ a: 4, b: '1' }, { b: '1', a: 4 }); assert.throws( () => assert.deepStrictEqual([0, 1, 2, 'a', 'b'], [0, 1, 2, 'b', 'a']), AssertionError); -assert.deepStrictEqual(a1, a2); - // Prototype check. function Constructor1(first, last) { this.first = first; @@ -926,7 +919,7 @@ assert.throws(() => assert.deepStrictEqual(obj1, obj2), AssertionError); Constructor2.prototype = Constructor1.prototype; obj2 = new Constructor2('Ryan', 'Dahl'); -assert.deepStrictEqual(obj1, obj2); +assertDeepAndStrictEqual(obj1, obj2); // Check extra properties on errors. { @@ -1047,7 +1040,7 @@ assert.throws( Object.defineProperty(a, 'getTime', { value: () => 5 }); - assert.deepStrictEqual(a, b); + assertDeepAndStrictEqual(a, b); } // Verify that an array and the equivalent fake array object @@ -1079,7 +1072,7 @@ assert.throws( Object.defineProperty(a, 'length', { value: 2 }); - assert.notDeepStrictEqual(a, [1, 1]); + assertNotDeepOrStrict(a, [1, 1]); } // Verify that changed tags will still check for the error message. |