-
-
Notifications
You must be signed in to change notification settings - Fork 110
Expand file tree
/
Copy path1-seq.test
More file actions
56 lines (56 loc) · 1.37 KB
/
1-seq.test
File metadata and controls
56 lines (56 loc) · 1.37 KB
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
44
45
46
47
48
49
50
51
52
53
54
55
56
({
name: 'seq',
length: [10, 100],
test: seq => {
{
const f1 = x => x + 7;
const f2 = x => x * 2;
const f = seq(f1)(f2);
const x = 0;
const y = f(x);
const expected = 7;
if (y !== expected) {
const msg = `seq(${f1})(${f2})(${x})`;
throw new Error(`${msg} === ${y} expected: ${expected}`);
}
}
{
const f1 = x => x + 7;
const f2 = x => x * 2;
const f = seq(f1)(f2);
const x = 5;
const y = f(x);
const expected = 17;
if (y !== expected) {
const msg = `seq(${f1})(${f2})(${x})`;
throw new Error(`${msg} === ${y} expected: ${expected}`);
}
}
{
const f1 = x => x * 2;
const f2 = x => x + 7;
const f = seq(f1)(f2);
const x = 5;
const y = f(x);
const expected = 24;
if (y !== expected) {
const msg = `seq(${f1})(${f2})(${x})`;
throw new Error(`${msg} === ${y} expected: ${expected}`);
}
}
{
const f1 = x => x + 1;
const f2 = x => x * 2;
const f3 = x => x / 3;
const f4 = x => x - 4;
const f = seq(f1)(f2)(f3)(f4);
const x = 7;
const y = f(x);
const expected = 3;
if (y !== expected) {
const msg = `seq(${f1})(${f2})(${f3})(${f4})(${x})`;
throw new Error(`${msg} === ${y} expected: ${expected}`);
}
}
}
})