summaryrefslogtreecommitdiff
path: root/std/testing/asserts.ts
diff options
context:
space:
mode:
authorChristian Petersen <fnky@users.noreply.github.com>2020-08-29 01:59:28 +0200
committerGitHub <noreply@github.com>2020-08-28 19:59:28 -0400
commit84086e7d3274fd46eace4a9131cda9eda1d76907 (patch)
tree20503bcd4f2745492fb3e7dffd92f0e59f7cd54c /std/testing/asserts.ts
parent00b67624125f0d1725130b3d74fcdc1583ad874f (diff)
fix(std/testing): invalid dates assertion equality (#7230)
Diffstat (limited to 'std/testing/asserts.ts')
-rw-r--r--std/testing/asserts.ts7
1 files changed, 7 insertions, 0 deletions
diff --git a/std/testing/asserts.ts b/std/testing/asserts.ts
index aa3017a4c..b7377c1bc 100644
--- a/std/testing/asserts.ts
+++ b/std/testing/asserts.ts
@@ -95,6 +95,13 @@ export function equal(c: unknown, d: unknown): boolean {
return String(a) === String(b);
}
if (a instanceof Date && b instanceof Date) {
+ const aTime = a.getTime();
+ const bTime = b.getTime();
+ // Check for NaN equality manually since NaN is not
+ // equal to itself.
+ if (Number.isNaN(aTime) && Number.isNaN(bTime)) {
+ return true;
+ }
return a.getTime() === b.getTime();
}
if (Object.is(a, b)) {