-
Notifications
You must be signed in to change notification settings - Fork 0
/
test.gleam
57 lines (46 loc) · 1.1 KB
/
test.gleam
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
57
import showtime/tests/should
import showtime/tests/meta.{type Meta}
import gleam/io
pub type Test {
Test(meta: Meta, test_function: fn() -> Nil)
}
pub type MetaShould(t) {
MetaShould(equal: fn(t, t) -> Nil, not_equal: fn(t, t) -> Nil)
}
pub fn test(meta: Meta, test_function: fn(Meta) -> Nil) {
Test(meta, fn() { test_function(meta) })
}
pub fn with_meta(meta: Meta, test_function: fn(MetaShould(a)) -> Nil) {
Test(
meta,
fn() {
test_function(MetaShould(
fn(a, b) { equal(a, b, meta) },
fn(a, b) { not_equal(a, b, meta) },
))
},
)
}
pub fn equal(a: t, b: t, meta: Meta) {
io.debug(a)
io.debug(b)
should.equal_meta(a, b, meta)
}
pub fn not_equal(a: t, b: t, meta: Meta) {
should.equal_meta(a, b, meta)
}
pub fn be_ok(a: Result(o, e), meta: Meta) {
should.be_ok_meta(a, meta)
}
pub fn be_error(a: Result(o, e), meta: Meta) {
should.be_error_meta(a, meta)
}
pub fn fail(meta: Meta) {
should.fail_meta(meta)
}
pub fn be_true(a: Bool, meta: Meta) {
should.be_true_meta(a, meta)
}
pub fn be_false(a: Bool, meta: Meta) {
should.be_false_meta(a, meta)
}