summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorRich Trott <rtrott@gmail.com>2019-02-04 16:10:33 -0800
committerRich Trott <rtrott@gmail.com>2019-02-06 13:34:49 -0800
commit5d52c8e43cb6633f7a71af403030d1eee070773a (patch)
tree5840a4eea3d4bffe9c0fed46a88da71df596713c /test
parent935b1af9907cd166a1a8b40fb83fdef411110e91 (diff)
downloadandroid-node-v8-5d52c8e43cb6633f7a71af403030d1eee070773a.tar.gz
android-node-v8-5d52c8e43cb6633f7a71af403030d1eee070773a.tar.bz2
android-node-v8-5d52c8e43cb6633f7a71af403030d1eee070773a.zip
test: add util.isDeepStrictEqual edge case tests
Test for deep strict equality when prototype and toStringTag have been modified in surprising ways. PR-URL: https://github.com/nodejs/node/pull/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>
Diffstat (limited to 'test')
-rw-r--r--test/parallel/test-util-isDeepStrictEqual.js25
1 files changed, 25 insertions, 0 deletions
diff --git a/test/parallel/test-util-isDeepStrictEqual.js b/test/parallel/test-util-isDeepStrictEqual.js
index 0eb75e46eb..08a30a28db 100644
--- a/test/parallel/test-util-isDeepStrictEqual.js
+++ b/test/parallel/test-util-isDeepStrictEqual.js
@@ -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