Skip to content

Commit

Permalink
test: assert: add failing deepEqual test for faked boxed primitives
Browse files Browse the repository at this point in the history
PR-URL: #29029
Reviewed-By: James M Snell <[email protected]>
Reviewed-By: Gus Caplan <[email protected]>
Reviewed-By: Michaël Zasso <[email protected]>
Reviewed-By: Anna Henningsen <[email protected]>
Reviewed-By: Rich Trott <[email protected]>
  • Loading branch information
ljharb authored and targos committed Aug 19, 2019
1 parent 375d1ee commit f9ed5f3
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions test/parallel/test-assert-deep.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,7 @@ function re(literals, ...values) {
getters: true
});
// Need to escape special characters.
result += str;
result += literals[i + 1];
result += `${str}${literals[i + 1]}`;
}
return {
code: 'ERR_ASSERTION',
Expand Down Expand Up @@ -605,11 +604,21 @@ assert.deepStrictEqual([ 1, 2, NaN, 4 ], [ 1, 2, NaN, 4 ]);
{
const boxedString = new String('test');
const boxedSymbol = Object(Symbol());

const fakeBoxedSymbol = {};
Object.setPrototypeOf(fakeBoxedSymbol, Symbol.prototype);
Object.defineProperty(
fakeBoxedSymbol,
Symbol.toStringTag,
{ enumerable: false, value: 'Symbol' }
);

assertNotDeepOrStrict(new Boolean(true), Object(false));
assertNotDeepOrStrict(Object(true), new Number(1));
assertNotDeepOrStrict(new Number(2), new Number(1));
assertNotDeepOrStrict(boxedSymbol, Object(Symbol()));
assertNotDeepOrStrict(boxedSymbol, {});
assertNotDeepOrStrict(boxedSymbol, fakeBoxedSymbol);
assertDeepAndStrictEqual(boxedSymbol, boxedSymbol);
assertDeepAndStrictEqual(Object(true), Object(true));
assertDeepAndStrictEqual(Object(2), Object(2));
Expand All @@ -618,6 +627,7 @@ assert.deepStrictEqual([ 1, 2, NaN, 4 ], [ 1, 2, NaN, 4 ]);
assertNotDeepOrStrict(boxedString, Object('test'));
boxedSymbol.slow = true;
assertNotDeepOrStrict(boxedSymbol, {});
assertNotDeepOrStrict(boxedSymbol, fakeBoxedSymbol);
}

// Minus zero
Expand Down

0 comments on commit f9ed5f3

Please sign in to comment.