summaryrefslogtreecommitdiff
path: root/test/parallel/test-assert-deep.js
diff options
context:
space:
mode:
Diffstat (limited to 'test/parallel/test-assert-deep.js')
-rw-r--r--test/parallel/test-assert-deep.js66
1 files changed, 66 insertions, 0 deletions
diff --git a/test/parallel/test-assert-deep.js b/test/parallel/test-assert-deep.js
index 87f2a5f44f..1cddb47692 100644
--- a/test/parallel/test-assert-deep.js
+++ b/test/parallel/test-assert-deep.js
@@ -1123,3 +1123,69 @@ assert.throws(
// The descriptor is not compared.
assertDeepAndStrictEqual(a, { a: 5 });
}
+
+// Verify object types being identical on both sides.
+{
+ let a = Buffer.from('test');
+ let b = Object.create(
+ Object.getPrototypeOf(a),
+ Object.getOwnPropertyDescriptors(a)
+ );
+ Object.defineProperty(b, Symbol.toStringTag, {
+ value: 'Uint8Array'
+ });
+ assertNotDeepOrStrict(a, b);
+
+ a = new Uint8Array(10);
+ b = new Int8Array(10);
+ Object.defineProperty(b, Symbol.toStringTag, {
+ value: 'Uint8Array'
+ });
+ Object.setPrototypeOf(b, Uint8Array.prototype);
+ assertNotDeepOrStrict(a, b);
+
+ a = [1, 2, 3];
+ b = { 0: 1, 1: 2, 2: 3 };
+ Object.setPrototypeOf(b, Array.prototype);
+ Object.defineProperty(b, 'length', { value: 3, enumerable: false });
+ Object.defineProperty(b, Symbol.toStringTag, {
+ value: 'Array'
+ });
+ assertNotDeepOrStrict(a, b);
+
+ a = new Date(2000);
+ b = Object.create(
+ Object.getPrototypeOf(a),
+ Object.getOwnPropertyDescriptors(a)
+ );
+ Object.defineProperty(b, Symbol.toStringTag, {
+ value: 'Date'
+ });
+ assertNotDeepOrStrict(a, b);
+
+ a = /abc/g;
+ b = Object.create(
+ Object.getPrototypeOf(a),
+ Object.getOwnPropertyDescriptors(a)
+ );
+ Object.defineProperty(b, Symbol.toStringTag, {
+ value: 'RegExp'
+ });
+ assertNotDeepOrStrict(a, b);
+
+ a = [];
+ b = /abc/;
+ Object.setPrototypeOf(b, Array.prototype);
+ Object.defineProperty(b, Symbol.toStringTag, {
+ value: 'Array'
+ });
+ assertNotDeepOrStrict(a, b);
+
+ a = Object.create(null);
+ b = new RangeError('abc');
+ Object.defineProperty(a, Symbol.toStringTag, {
+ value: 'Error'
+ });
+ Object.setPrototypeOf(b, null);
+ assertNotDeepOrStrict(a, b, assert.AssertionError);
+}