mirror of
https://github.com/zebrajr/node.git
synced 2026-01-15 12:15:26 +00:00
assert,util: fix deep comparing invalid dates skipping properties
The property comparison of invalid dates regressed when starting to handle invalid dates as being equal. PR-URL: https://github.com/nodejs/node/pull/61076 Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Yagiz Nizipli <yagiz@nizipli.com> Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com>
This commit is contained in:
committed by
Node.js GitHub Bot
parent
a968e4e672
commit
fc1d6d6b4c
@@ -304,9 +304,9 @@ function objectComparisonStart(val1, val2, mode, memos) {
|
||||
}
|
||||
const time1 = DatePrototypeGetTime(val1);
|
||||
const time2 = DatePrototypeGetTime(val2);
|
||||
if (time1 !== time2) {
|
||||
// eslint-disable-next-line no-self-compare
|
||||
return time1 !== time1 && time2 !== time2;
|
||||
// eslint-disable-next-line no-self-compare
|
||||
if (time1 !== time2 && (time1 === time1 || time2 === time2)) {
|
||||
return false;
|
||||
}
|
||||
} else if (isRegExp(val1)) {
|
||||
if (!isRegExp(val2) || !areSimilarRegExps(val1, val2)) {
|
||||
|
||||
@@ -752,7 +752,18 @@ test('Additional tests', () => {
|
||||
|
||||
assertNotDeepOrStrict(new Date(), new Date(2000, 3, 14));
|
||||
|
||||
assertDeepAndStrictEqual(new Date('foo'), new Date('bar'));
|
||||
{
|
||||
// Invalid dates deep comparison.
|
||||
const date1 = new Date('foo');
|
||||
const date2 = new Date('bar');
|
||||
date1.foo = true;
|
||||
date2.foo = true;
|
||||
assertDeepAndStrictEqual(date1, date2);
|
||||
|
||||
date1.bar = false;
|
||||
date2.bar = true;
|
||||
assertNotDeepOrStrict(date1, date2);
|
||||
}
|
||||
|
||||
assertDeepAndStrictEqual(/a/, /a/);
|
||||
assertDeepAndStrictEqual(/a/g, /a/g);
|
||||
|
||||
Reference in New Issue
Block a user