Skip to content

Commit f9ed5f3

Browse files
ljharbtargos
authored andcommitted
test: assert: add failing deepEqual test for faked boxed primitives
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]>
1 parent 375d1ee commit f9ed5f3

File tree

1 file changed

+12
-2
lines changed

1 file changed

+12
-2
lines changed

test/parallel/test-assert-deep.js

+12-2
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,7 @@ function re(literals, ...values) {
2828
getters: true
2929
});
3030
// Need to escape special characters.
31-
result += str;
32-
result += literals[i + 1];
31+
result += `${str}${literals[i + 1]}`;
3332
}
3433
return {
3534
code: 'ERR_ASSERTION',
@@ -605,11 +604,21 @@ assert.deepStrictEqual([ 1, 2, NaN, 4 ], [ 1, 2, NaN, 4 ]);
605604
{
606605
const boxedString = new String('test');
607606
const boxedSymbol = Object(Symbol());
607+
608+
const fakeBoxedSymbol = {};
609+
Object.setPrototypeOf(fakeBoxedSymbol, Symbol.prototype);
610+
Object.defineProperty(
611+
fakeBoxedSymbol,
612+
Symbol.toStringTag,
613+
{ enumerable: false, value: 'Symbol' }
614+
);
615+
608616
assertNotDeepOrStrict(new Boolean(true), Object(false));
609617
assertNotDeepOrStrict(Object(true), new Number(1));
610618
assertNotDeepOrStrict(new Number(2), new Number(1));
611619
assertNotDeepOrStrict(boxedSymbol, Object(Symbol()));
612620
assertNotDeepOrStrict(boxedSymbol, {});
621+
assertNotDeepOrStrict(boxedSymbol, fakeBoxedSymbol);
613622
assertDeepAndStrictEqual(boxedSymbol, boxedSymbol);
614623
assertDeepAndStrictEqual(Object(true), Object(true));
615624
assertDeepAndStrictEqual(Object(2), Object(2));
@@ -618,6 +627,7 @@ assert.deepStrictEqual([ 1, 2, NaN, 4 ], [ 1, 2, NaN, 4 ]);
618627
assertNotDeepOrStrict(boxedString, Object('test'));
619628
boxedSymbol.slow = true;
620629
assertNotDeepOrStrict(boxedSymbol, {});
630+
assertNotDeepOrStrict(boxedSymbol, fakeBoxedSymbol);
621631
}
622632

623633
// Minus zero

0 commit comments

Comments
 (0)