mirror of
https://github.com/denoland/std.git
synced 2024-11-22 04:59:05 +00:00
fix(std/testing): equals does not differentiate undefined/absent keys (#849)
This commit is contained in:
parent
da2de64d01
commit
7e4d6efe24
@ -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;
|
||||
|
@ -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 {
|
||||
|
Loading…
Reference in New Issue
Block a user