1
0
Fork 0
mirror of https://github.com/denoland/deno.git synced 2024-11-26 16:09:27 -05:00

Fix assertEqual so that it handles URL objects (#6278)

This commit is contained in:
Joel Chippindale 2020-06-13 15:01:05 +01:00 committed by GitHub
parent 0bc70b89c0
commit f6fa659384
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 11 additions and 1 deletions

View file

@ -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);
}

View file

@ -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 {