-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest.slang
More file actions
43 lines (34 loc) · 1.5 KB
/
test.slang
File metadata and controls
43 lines (34 loc) · 1.5 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
import "prelude.slang";
let it = function(desc, actual, expected) namespace {
description = desc;
actual = actual;
expected = expected;
};
let describe = function(desc, tests) namespace {
description = desc;
tests = tests;
};
[
describe("prelude", [
it("max returns maximum value.", 7, math::max(1, 7)),
it("max returns maximal value.", 7, math::max(7, 7)),
it("max handles negative numbers.", -1, math::max(-1, -7)),
it("ceil handles negative numbers.", 0, math::ceil(-0.9)),
it("floor handles negative numbers.", -1, math::floor(-0.9)),
it("zip handles equal length arrays.",
[[1, 4], [2, 5], [3, 6]],
zip([1, 2, 3], [4, 5, 6]))
it("zip handles arrays with longer lhs.",
[[1, 4], [2, 5], [3, 6]],
zip([1, 2, 3, 0], [4, 5, 6]))
it("zip handles arrays with longer rhs.",
[[1, 4], [2, 5], [3, 6]],
zip([1, 2, 3], [4, 5, 6, 0]))
it("zip handles empty arrays.", [], zip([], [])),
it("map array maps function.", [1, 2, 3].map(function(x) x + 1), [2, 3, 4]),
it("map array handles empty array.", [].map(function(x) x + 1), []),
it("map2 array maps function.", [[1, 2], [2, 3], [3, 4]].map(function(x) [x[0] + 1, x[1] + 2]), [[2, 4], [3, 5], [4, 6]]),
it("enumerate enumerates non empty lists.", [100, 200, 300].enumerate(), [[0, 100], [1, 200], [2, 300]])
it("enumerate enumerates empty lists.", [].enumerate(), [])
])
]