mirror of
https://github.com/denoland/deno.git
synced 2024-10-29 08:58:01 -04:00
Fix assertEqual so that it handles URL objects (#6278)
This commit is contained in:
parent
0bc70b89c0
commit
f6fa659384
2 changed files with 11 additions and 1 deletions
|
@ -82,7 +82,8 @@ export function equal(c: unknown, d: unknown): boolean {
|
|||
a &&
|
||||
b &&
|
||||
((a instanceof RegExp && b instanceof RegExp) ||
|
||||
(a instanceof Date && b instanceof Date))
|
||||
(a instanceof Date && b instanceof Date) ||
|
||||
(a instanceof URL && b instanceof URL))
|
||||
) {
|
||||
return String(a) === String(b);
|
||||
}
|
||||
|
|
|
@ -112,6 +112,15 @@ Deno.test("testingEqual", function (): void {
|
|||
assert(!equal([1, 2, 3, 4], [1, 4, 2, 3]));
|
||||
assert(equal(new Uint8Array([1, 2, 3, 4]), new Uint8Array([1, 2, 3, 4])));
|
||||
assert(!equal(new Uint8Array([1, 2, 3, 4]), new Uint8Array([2, 1, 4, 3])));
|
||||
assert(
|
||||
equal(new URL("https://example.test"), new URL("https://example.test"))
|
||||
);
|
||||
assert(
|
||||
!equal(
|
||||
new URL("https://example.test"),
|
||||
new URL("https://example.test/with-path")
|
||||
)
|
||||
);
|
||||
});
|
||||
|
||||
Deno.test("testingNotEquals", function (): void {
|
||||
|
|
Loading…
Reference in a new issue