Skip to content

Commit

Permalink
test: add util.isDeepStrictEqual edge case tests
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Trott authored and addaleax committed Feb 7, 2019
1 parent baa10ae commit 1f8991f
Showing 1 changed file with 25 additions and 0 deletions.
25 changes: 25 additions & 0 deletions test/parallel/test-util-isDeepStrictEqual.js
Original file line number Diff line number Diff line change
Expand Up @@ -449,6 +449,31 @@ assert.strictEqual(
notUtilIsDeepStrict(boxedSymbol, {});
utilIsDeepStrict(Object(BigInt(1)), Object(BigInt(1)));
notUtilIsDeepStrict(Object(BigInt(1)), Object(BigInt(2)));

const booleanish = new Boolean(true);
Object.defineProperty(booleanish, Symbol.toStringTag, { value: 'String' });
Object.setPrototypeOf(booleanish, String.prototype);
notUtilIsDeepStrict(booleanish, new String('true'));

const numberish = new Number(42);
Object.defineProperty(numberish, Symbol.toStringTag, { value: 'String' });
Object.setPrototypeOf(numberish, String.prototype);
notUtilIsDeepStrict(numberish, new String('42'));

const stringish = new String('0');
Object.defineProperty(stringish, Symbol.toStringTag, { value: 'Number' });
Object.setPrototypeOf(stringish, Number.prototype);
notUtilIsDeepStrict(stringish, new Number(0));

const bigintish = new Object(BigInt(42));
Object.defineProperty(bigintish, Symbol.toStringTag, { value: 'String' });
Object.setPrototypeOf(bigintish, String.prototype);
notUtilIsDeepStrict(bigintish, new String('42'));

const symbolish = new Object(Symbol('fhqwhgads'));
Object.defineProperty(symbolish, Symbol.toStringTag, { value: 'String' });
Object.setPrototypeOf(symbolish, String.prototype);
notUtilIsDeepStrict(symbolish, new String('fhqwhgads'));
}

// Minus zero
Expand Down

0 comments on commit 1f8991f

Please sign in to comment.