fix(ext/node): improve comparison of faked objects in deepStrictEqual (#29819)

This commit improves the handling of objects with faked prototypes in
`deepStrictEqual`. This enables `parallel/test-assert-checktag.js`

- `Date` objects are checked by `core.isDate`
- In object comparison, now it checks `obj.toString()` output (The
difference of `Symbol.toStringTag` is now detected).
- Stoped using std's assertion error message for `deepStrictEqual`, but
started using Node.js version of diff string. Now the diff expression is
more compatible with Node.
This commit is contained in:
Yoshiya Hinosawa 2025-06-20 23:33:18 +09:00 committed by GitHub
parent 1e9415cda8
commit c538f44fa0
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
8 changed files with 109 additions and 19 deletions

View file

@ -383,11 +383,16 @@ function deepStrictEqual(
throw new ERR_MISSING_ARGS("actual", "expected");
}
toNode(
() => asserts.assertEquals(actual, expected),
{ message, actual, expected, operator: "deepStrictEqual" },
);
if (!asserts.equal(actual, expected)) {
throw new AssertionError({
message,
actual,
expected,
operator: "deepStrictEqual",
});
}
}
function notDeepStrictEqual(
actual: unknown,
expected: unknown,