Skip to content

Commit 916cc82

Browse files
ljharbbfarias-godaddy
authored andcommitted
test: assert: fix deepStrictEqual comparing a real array and fake array
PR-URL: #30743 Reviewed-By: Rich Trott <[email protected]> Reviewed-By: Michaël Zasso <[email protected]>
1 parent 76cbb66 commit 916cc82

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

test/parallel/test-assert-deep.js

+15
Original file line numberDiff line numberDiff line change
@@ -1042,6 +1042,21 @@ assert.throws(
10421042
assertDeepAndStrictEqual(a, b);
10431043
}
10441044

1045+
// Verify that an array and the equivalent fake array object
1046+
// are correctly compared
1047+
{
1048+
const a = [1, 2, 3];
1049+
const o = {
1050+
__proto__: Array.prototype,
1051+
0: 1,
1052+
1: 2,
1053+
2: 3,
1054+
length: 3,
1055+
};
1056+
Object.defineProperty(o, 'length', { enumerable: false });
1057+
assertNotDeepOrStrict(o, a);
1058+
}
1059+
10451060
// Verify that extra keys will be tested for when using fake arrays.
10461061
{
10471062
const a = {

0 commit comments

Comments
 (0)