-
Notifications
You must be signed in to change notification settings - Fork 31
Expand file tree
/
Copy pathOptionTests.res
More file actions
43 lines (37 loc) · 875 Bytes
/
OptionTests.res
File metadata and controls
43 lines (37 loc) · 875 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
40
41
42
43
open RescriptCore
let eq = (a, b) => a == b
// ======================
// isSomeAnd and isNoneOr
// ======================
let isPositive = i => i > 0
Test.run(
__POS_OF__("isSomeAnd: if None, return false"),
None->Option.isSomeAnd(isPositive),
eq,
false,
)
Test.run(
__POS_OF__("isSomeAnd: if Some and true, return true"),
Some(1)->Option.isSomeAnd(isPositive),
eq,
true,
)
Test.run(
__POS_OF__("isSomeAnd: if Some and false, return false"),
Some(-1)->Option.isSomeAnd(isPositive),
eq,
false,
)
Test.run(__POS_OF__("isNoneOr: if None, return true"), None->Option.isNoneOr(isPositive), eq, true)
Test.run(
__POS_OF__("isNoneOr: if Some and true, return true"),
Some(1)->Option.isNoneOr(isPositive),
eq,
true,
)
Test.run(
__POS_OF__("isNoneOr: if Some and false, return false"),
Some(-1)->Option.isNoneOr(isPositive),
eq,
false,
)