summaryrefslogtreecommitdiff
path: root/std/testing/asserts.ts
diff options
context:
space:
mode:
authorJames Wright <james@jamesswright.co.uk>2019-10-30 00:23:54 +0000
committerRy Dahl <ry@tinyclouds.org>2019-10-29 20:23:54 -0400
commit64957d92efdfbb8008e51c9d501b0d6754a777b7 (patch)
treeadac23650b74a4f07e0def6be36b5ad4f98b9fe5 /std/testing/asserts.ts
parent8f571ef166d31f44378c1b6de5f4092fcccef732 (diff)
Support for deep `Map` equality with `asserts#equal` (#3236)
Diffstat (limited to 'std/testing/asserts.ts')
-rw-r--r--std/testing/asserts.ts13
1 files changed, 13 insertions, 0 deletions
diff --git a/std/testing/asserts.ts b/std/testing/asserts.ts
index 0f33bb3d2..b242184b3 100644
--- a/std/testing/asserts.ts
+++ b/std/testing/asserts.ts
@@ -81,6 +81,19 @@ export function equal(c: unknown, d: unknown): boolean {
}
return true;
}
+ if (a && b && a instanceof Map && b instanceof Map) {
+ if (a.size !== b.size) {
+ return false;
+ }
+
+ for (const [key, value] of a) {
+ if (!compare(value, b.get(key))) {
+ return false;
+ }
+ }
+
+ return true;
+ }
// Have to render RegExp & Date for string comparison
// unless it's mistreated as object
if (