-
Notifications
You must be signed in to change notification settings - Fork 0
/
mod_test.ts
43 lines (37 loc) · 946 Bytes
/
mod_test.ts
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
43
import { assertEquals } from "./test_deps.ts";
import { Stream } from "./mod.ts";
Deno.test({
name: "creation (of)",
fn(): void {
let stream = Stream.of(1, 2, 3);
assertEquals(stream.blockingGet(), [1, 2, 3]);
},
});
Deno.test({
name: "creation (fromList)",
fn(): void {
let stream = Stream.fromList([1, 2, 3]);
assertEquals(stream.blockingGet(), [1, 2, 3]);
},
});
Deno.test({
name: "rudimentary map",
fn(): void {
let stream = Stream.of(1, 2, 3).map((x: number) => x + 1);
assertEquals(stream.blockingGet(), [2, 3, 4]);
},
});
Deno.test({
name: "rudimentary filter",
fn(): void {
let stream = Stream.of(1, 2, 3).filter((x: number) => x % 2 == 0);
assertEquals(stream.blockingGet(), [2]);
},
});
Deno.test({
name: "rudimentary reduce",
fn(): void {
let stream = Stream.of(1, 2, 3).reduce((x: number, y: number) => x + y);
assertEquals(stream.blockingGet(), 6);
},
});