Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Consolidates asserts#equal branches for keyed collections (Map/Set) and supports deep equality of Map keys #3258

Merged
merged 13 commits into from
Nov 4, 2019
Merged
Prev Previous commit
Next Next commit
Formats asserts changes
  • Loading branch information
jamesseanwright committed Nov 3, 2019
commit 6951b6afc366d699afb29d83fa604d70d425d81c
6 changes: 4 additions & 2 deletions std/testing/asserts.ts
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,9 @@ function buildMessage(diffResult: ReadonlyArray<DiffResult<string>>): string[] {
return messages;
}

function isKeyedCollection(x: unknown): x is Map<unknown, unknown> | Set<unknown> {
function isKeyedCollection(
x: unknown
): x is Map<unknown, unknown> | Set<unknown> {
return x instanceof Map || x instanceof Set;
}

Expand Down Expand Up @@ -100,7 +102,7 @@ export function equal(c: unknown, d: unknown): boolean {
}

for (const [key, value] of a.entries()) {
if (!b.has(key) || !compare(value, 'get' in b ? b.get(key) : key)) {
if (!b.has(key) || !compare(value, "get" in b ? b.get(key) : key)) {
return false;
}
}
Expand Down