Skip to content

Commit

Permalink
fix(std/testing): equals does not differentiate undefined/absent keys (
Browse files Browse the repository at this point in the history
  • Loading branch information
lowlighter authored Apr 14, 2021
1 parent da2de64 commit 7e4d6ef
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 0 deletions.
3 changes: 3 additions & 0 deletions testing/asserts.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
6 changes: 6 additions & 0 deletions testing/asserts_test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down

0 comments on commit 7e4d6ef

Please sign in to comment.