summaryrefslogtreecommitdiff
path: root/testing/asserts.ts
diff options
context:
space:
mode:
authorDmitry Sharshakov <sh7dm@outlook.com>2019-04-22 16:39:33 +0300
committerRyan Dahl <ry@tinyclouds.org>2019-04-22 09:39:33 -0400
commiteff23abc3280026cb44e3cf41e91bc804afbf969 (patch)
tree688146df6557055f79963b9d4a50fe5bb69d2985 /testing/asserts.ts
parent6df5291818287d8ce00cbd59eeeb94ea0e8e8416 (diff)
Support Sets in asserts.equals (denoland/deno_std#350)
Original: https://github.com/denoland/deno_std/commit/9432d703291f74b230f39b30614d57a5623faa59
Diffstat (limited to 'testing/asserts.ts')
-rw-r--r--testing/asserts.ts11
1 files changed, 11 insertions, 0 deletions
diff --git a/testing/asserts.ts b/testing/asserts.ts
index eb5e11969..83fa7c8e5 100644
--- a/testing/asserts.ts
+++ b/testing/asserts.ts
@@ -16,6 +16,17 @@ export class AssertionError extends Error {
export function equal(c: unknown, d: unknown): boolean {
const seen = new Map();
return (function compare(a: unknown, b: unknown) {
+ if (a && a instanceof Set && b && b instanceof Set) {
+ if (a.size !== b.size) {
+ return false;
+ }
+ for (const item of b) {
+ if (!a.has(item)) {
+ return false;
+ }
+ }
+ return true;
+ }
// Have to render RegExp & Date for string comparison
// unless it's mistreated as object
if (