aboutsummaryrefslogtreecommitdiff
path: root/stdlib/source/test/lux/data/sum.lux
diff options
context:
space:
mode:
Diffstat (limited to 'stdlib/source/test/lux/data/sum.lux')
-rw-r--r--stdlib/source/test/lux/data/sum.lux56
1 files changed, 29 insertions, 27 deletions
diff --git a/stdlib/source/test/lux/data/sum.lux b/stdlib/source/test/lux/data/sum.lux
index d47922304..2a7fa889e 100644
--- a/stdlib/source/test/lux/data/sum.lux
+++ b/stdlib/source/test/lux/data/sum.lux
@@ -1,37 +1,39 @@
(.module:
[lux #*
+ ["_" test (#+ Test)]
+ data/text/format
[control
pipe]
[data
- sum
["." text]
[collection
["." list]]]]
- lux/test)
+ {1
+ ["." /]})
-(context: "Sum operations"
- (let [(^open "List/.") (list.equivalence text.equivalence)]
- ($_ seq
- (test "Can inject values into Either."
- (and (|> (left "Hello") (case> (0 "Hello") #1 _ #0))
- (|> (right "World") (case> (1 "World") #1 _ #0))))
+(def: #export test
+ Test
+ (<| (_.context (%name (name-of .|)))
+ (let [(^open "list/.") (list.equivalence text.equivalence)]
+ ($_ _.and
+ (_.test "Can inject values into Either."
+ (and (|> (/.left "Hello") (case> (0 "Hello") #1 _ #0))
+ (|> (/.right "World") (case> (1 "World") #1 _ #0))))
+ (_.test "Can discriminate eithers based on their cases."
+ (let [[_lefts _rights] (/.partition (: (List (| Text Text))
+ (list (0 "0") (1 "1") (0 "2"))))]
+ (and (list/= _lefts
+ (/.lefts (: (List (| Text Text))
+ (list (0 "0") (1 "1") (0 "2")))))
- (test "Can discriminate eithers based on their cases."
- (let [[_lefts _rights] (partition (: (List (| Text Text))
- (list (0 "+0") (1 "+1") (0 "+2"))))]
- (and (List/= _lefts
- (lefts (: (List (| Text Text))
- (list (0 "+0") (1 "+1") (0 "+2")))))
-
- (List/= _rights
- (rights (: (List (| Text Text))
- (list (0 "+0") (1 "+1") (0 "+2"))))))))
-
- (test "Can apply a function to an Either value depending on the case."
- (and (i/= +10 (either (function (_ _) +10)
- (function (_ _) +20)
- (: (| Text Text) (0 ""))))
- (i/= +20 (either (function (_ _) +10)
- (function (_ _) +20)
- (: (| Text Text) (1 ""))))))
- )))
+ (list/= _rights
+ (/.rights (: (List (| Text Text))
+ (list (0 "0") (1 "1") (0 "2"))))))))
+ (_.test "Can apply a function to an Either value depending on the case."
+ (and (n/= 10 (/.either (function (_ _) 10)
+ (function (_ _) 20)
+ (: (| Text Text) (0 ""))))
+ (n/= 20 (/.either (function (_ _) 10)
+ (function (_ _) 20)
+ (: (| Text Text) (1 ""))))))
+ ))))