forked from MathisBullinger/froebel
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathunzip.test.ts
More file actions
39 lines (34 loc) · 819 Bytes
/
Copy pathunzip.test.ts
File metadata and controls
39 lines (34 loc) · 819 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
import unzip, { unzipWith } from "./unzip.ts";
import { assertEquals } from "testing/asserts.ts";
Deno.test("unzip", () => {
{
const unzipped: [number[], string[]] = unzip([1, "a"], [2, "b"], [3, "c"]);
assertEquals(unzipped, [
[1, 2, 3],
["a", "b", "c"],
]);
}
{
const unzipped = unzip([1, true, "a"], [2, false, "b"], [3, true, "c"]);
assertEquals(unzipped, [
[1, 2, 3],
[true, false, true],
["a", "b", "c"],
]);
}
// @ts-expect-error
unzip([1, "a"], [2]);
});
Deno.test("unzipWith", () => {
const [nums, str]: [number[], string] = unzipWith(
[
[1, "a"],
[2, "b"],
[3, "c"],
],
(n, a: number[] = []) => [...a, n],
(c, str = "") => str + c,
);
assertEquals(nums, [1, 2, 3]);
assertEquals(str, "abc");
});