Skip to content
Permalink
Browse files

test: assert: add failing deepEqual test for faked boxed primitives

PR-URL: #29029
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Gus Caplan <me@gus.host>
Reviewed-By: Michaël Zasso <targos@protonmail.com>
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Rich Trott <rtrott@gmail.com>
  • Loading branch information...
ljharb authored and targos committed Aug 6, 2019
1 parent 375d1ee commit f9ed5f351b254571b4edda964107e1048635df7a
Showing with 12 additions and 2 deletions.
  1. +12 −2 test/parallel/test-assert-deep.js
@@ -28,8 +28,7 @@ function re(literals, ...values) {
getters: true
});
// Need to escape special characters.
result += str;
result += literals[i + 1];
result += `${str}${literals[i + 1]}`;
}
return {
code: 'ERR_ASSERTION',
@@ -605,11 +604,21 @@ assert.deepStrictEqual([ 1, 2, NaN, 4 ], [ 1, 2, NaN, 4 ]);
{
const boxedString = new String('test');
const boxedSymbol = Object(Symbol());

const fakeBoxedSymbol = {};
Object.setPrototypeOf(fakeBoxedSymbol, Symbol.prototype);
Object.defineProperty(
fakeBoxedSymbol,
Symbol.toStringTag,
{ enumerable: false, value: 'Symbol' }
);

assertNotDeepOrStrict(new Boolean(true), Object(false));
assertNotDeepOrStrict(Object(true), new Number(1));
assertNotDeepOrStrict(new Number(2), new Number(1));
assertNotDeepOrStrict(boxedSymbol, Object(Symbol()));
assertNotDeepOrStrict(boxedSymbol, {});
assertNotDeepOrStrict(boxedSymbol, fakeBoxedSymbol);
assertDeepAndStrictEqual(boxedSymbol, boxedSymbol);
assertDeepAndStrictEqual(Object(true), Object(true));
assertDeepAndStrictEqual(Object(2), Object(2));
@@ -618,6 +627,7 @@ assert.deepStrictEqual([ 1, 2, NaN, 4 ], [ 1, 2, NaN, 4 ]);
assertNotDeepOrStrict(boxedString, Object('test'));
boxedSymbol.slow = true;
assertNotDeepOrStrict(boxedSymbol, {});
assertNotDeepOrStrict(boxedSymbol, fakeBoxedSymbol);
}

// Minus zero

0 comments on commit f9ed5f3

Please sign in to comment.
You can’t perform that action at this time.