-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathassert_iterable_test.ts
More file actions
42 lines (38 loc) · 869 Bytes
/
assert_iterable_test.ts
File metadata and controls
42 lines (38 loc) · 869 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
import { assertIterable } from "./assert_iterable.ts";
import { assertFalse, assertThrows, describe, it } from "./_dev_deps.ts";
describe("assertIterable", () => {
it("should return void", () => {
const table: unknown[] = [
{ [Symbol.iterator]: () => {} },
"",
[],
new Map(),
new Set(),
new Map(),
new Int8Array(),
new Int16Array(),
];
table.forEach((input) => {
assertFalse(assertIterable(input));
});
});
it("should throw error", () => {
const table: unknown[] = [
false,
null,
undefined,
1,
1n,
Symbol.for("test"),
{},
new Date(),
{ [Symbol.iterator]: [] },
new WeakRef([]),
new WeakSet(),
new WeakMap(),
];
table.forEach((input) => {
assertThrows(() => assertIterable(input));
});
});
});