fix(std/testing): equals does not differentiate undefined/absent keys (#849)

This commit is contained in:
Simon Lecoq 2021-04-14 07:50:48 +02:00 committed by GitHub
parent da2de64d01
commit 7e4d6efe24
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 9 additions and 0 deletions

View File

@ -161,6 +161,9 @@ export function equal(c: unknown, d: unknown): boolean {
if (!compare(a && a[key as Key], b && b[key as Key])) {
return false;
}
if (((key in a) && (!(key in b))) || ((key in b) && (!(key in a)))) {
return false;
}
}
seen.set(a, b);
return true;

View File

@ -147,6 +147,12 @@ Deno.test("testingEqual", function (): void {
new URL("https://example.test/with-path"),
),
);
assert(
!equal({ a: undefined, b: undefined }, { a: undefined, c: undefined }),
);
assert(
!equal({ a: undefined, b: undefined }, { a: undefined }),
);
});
Deno.test("testingNotEquals", function (): void {