Skip to content

Commit 1f8991f

Browse files
Trottaddaleax
authored andcommitted
test: add util.isDeepStrictEqual edge case tests
Test for deep strict equality when prototype and toStringTag have been modified in surprising ways. PR-URL: #25932 Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de> Reviewed-By: Anto Aravinth <anto.aravinth.cse@gmail.com> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com>
1 parent baa10ae commit 1f8991f

File tree

1 file changed

+25
-0
lines changed

1 file changed

+25
-0
lines changed

test/parallel/test-util-isDeepStrictEqual.js

+25
Original file line numberDiff line numberDiff line change
@@ -449,6 +449,31 @@ assert.strictEqual(
449449
notUtilIsDeepStrict(boxedSymbol, {});
450450
utilIsDeepStrict(Object(BigInt(1)), Object(BigInt(1)));
451451
notUtilIsDeepStrict(Object(BigInt(1)), Object(BigInt(2)));
452+
453+
const booleanish = new Boolean(true);
454+
Object.defineProperty(booleanish, Symbol.toStringTag, { value: 'String' });
455+
Object.setPrototypeOf(booleanish, String.prototype);
456+
notUtilIsDeepStrict(booleanish, new String('true'));
457+
458+
const numberish = new Number(42);
459+
Object.defineProperty(numberish, Symbol.toStringTag, { value: 'String' });
460+
Object.setPrototypeOf(numberish, String.prototype);
461+
notUtilIsDeepStrict(numberish, new String('42'));
462+
463+
const stringish = new String('0');
464+
Object.defineProperty(stringish, Symbol.toStringTag, { value: 'Number' });
465+
Object.setPrototypeOf(stringish, Number.prototype);
466+
notUtilIsDeepStrict(stringish, new Number(0));
467+
468+
const bigintish = new Object(BigInt(42));
469+
Object.defineProperty(bigintish, Symbol.toStringTag, { value: 'String' });
470+
Object.setPrototypeOf(bigintish, String.prototype);
471+
notUtilIsDeepStrict(bigintish, new String('42'));
472+
473+
const symbolish = new Object(Symbol('fhqwhgads'));
474+
Object.defineProperty(symbolish, Symbol.toStringTag, { value: 'String' });
475+
Object.setPrototypeOf(symbolish, String.prototype);
476+
notUtilIsDeepStrict(symbolish, new String('fhqwhgads'));
452477
}
453478

454479
// Minus zero

0 commit comments

Comments
 (0)