test: assert: add failing deepEqual test for faked boxed primitives
PR-URL: https://github.com/nodejs/node/pull/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>
This commit is contained in:
parent
885c644158
commit
e079f6c93e
@ -28,8 +28,7 @@ function re(literals, ...values) {
|
|||||||
getters: true
|
getters: true
|
||||||
});
|
});
|
||||||
// Need to escape special characters.
|
// Need to escape special characters.
|
||||||
result += str;
|
result += `${str}${literals[i + 1]}`;
|
||||||
result += literals[i + 1];
|
|
||||||
}
|
}
|
||||||
return {
|
return {
|
||||||
code: 'ERR_ASSERTION',
|
code: 'ERR_ASSERTION',
|
||||||
@ -605,11 +604,21 @@ assert.deepStrictEqual([ 1, 2, NaN, 4 ], [ 1, 2, NaN, 4 ]);
|
|||||||
{
|
{
|
||||||
const boxedString = new String('test');
|
const boxedString = new String('test');
|
||||||
const boxedSymbol = Object(Symbol());
|
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(new Boolean(true), Object(false));
|
||||||
assertNotDeepOrStrict(Object(true), new Number(1));
|
assertNotDeepOrStrict(Object(true), new Number(1));
|
||||||
assertNotDeepOrStrict(new Number(2), new Number(1));
|
assertNotDeepOrStrict(new Number(2), new Number(1));
|
||||||
assertNotDeepOrStrict(boxedSymbol, Object(Symbol()));
|
assertNotDeepOrStrict(boxedSymbol, Object(Symbol()));
|
||||||
assertNotDeepOrStrict(boxedSymbol, {});
|
assertNotDeepOrStrict(boxedSymbol, {});
|
||||||
|
assertNotDeepOrStrict(boxedSymbol, fakeBoxedSymbol);
|
||||||
assertDeepAndStrictEqual(boxedSymbol, boxedSymbol);
|
assertDeepAndStrictEqual(boxedSymbol, boxedSymbol);
|
||||||
assertDeepAndStrictEqual(Object(true), Object(true));
|
assertDeepAndStrictEqual(Object(true), Object(true));
|
||||||
assertDeepAndStrictEqual(Object(2), Object(2));
|
assertDeepAndStrictEqual(Object(2), Object(2));
|
||||||
@ -618,6 +627,7 @@ assert.deepStrictEqual([ 1, 2, NaN, 4 ], [ 1, 2, NaN, 4 ]);
|
|||||||
assertNotDeepOrStrict(boxedString, Object('test'));
|
assertNotDeepOrStrict(boxedString, Object('test'));
|
||||||
boxedSymbol.slow = true;
|
boxedSymbol.slow = true;
|
||||||
assertNotDeepOrStrict(boxedSymbol, {});
|
assertNotDeepOrStrict(boxedSymbol, {});
|
||||||
|
assertNotDeepOrStrict(boxedSymbol, fakeBoxedSymbol);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Minus zero
|
// Minus zero
|
||||||
|
Loading…
x
Reference in New Issue
Block a user