diff options
author | Eduardo Julian | 2018-05-02 19:49:03 -0400 |
---|---|---|
committer | Eduardo Julian | 2018-05-02 19:49:03 -0400 |
commit | f1768c649501e736452ca50dca76644e01af0518 (patch) | |
tree | 6c109df6835f6626841f4ecd08d3c08f75d104ce /stdlib/test | |
parent | 0c38ade25c2b7f4456ed29b22b2585b407097311 (diff) |
- List ranges can now be generated backwards.
Diffstat (limited to '')
-rw-r--r-- | stdlib/test/test/lux/control/region.lux | 2 | ||||
-rw-r--r-- | stdlib/test/test/lux/data/coll/list.lux | 33 |
2 files changed, 23 insertions, 12 deletions
diff --git a/stdlib/test/test/lux/control/region.lux b/stdlib/test/test/lux/control/region.lux index a7a577ab5..fc1eb7edf 100644 --- a/stdlib/test/test/lux/control/region.lux +++ b/stdlib/test/test/lux/control/region.lux @@ -26,7 +26,7 @@ (context: "Regions." (<| (times +100) (do @ - [expected-clean-ups (|> r.nat (:: @ map (n/% +100)))] + [expected-clean-ups (|> r.nat (:: @ map (|>> (n/% +100) (n/max +1))))] ($_ seq (test "Clean-up functions are always run when region execution is done." (thread.run diff --git a/stdlib/test/test/lux/data/coll/list.lux b/stdlib/test/test/lux/data/coll/list.lux index 729519823..578b652da 100644 --- a/stdlib/test/test/lux/data/coll/list.lux +++ b/stdlib/test/test/lux/data/coll/list.lux @@ -132,6 +132,8 @@ other-size bounded-size other-sample (r.list other-size r.nat) separator r.nat + from (|> r.nat (:: @ map (n/% +10))) + to (|> r.nat (:: @ map (n/% +10))) #let [(^open) (&.Eq<List> number.Eq<Nat>) (^open "&/") &.Functor<List>]] ($_ seq @@ -208,17 +210,26 @@ (&/map product.left enum-sample)) (= sample (&/map product.right enum-sample))))) + + (test "Ranges can be constructed forward and backwards." + (and (let [(^open "list/") (&.Eq<List> number.Eq<Nat>)] + (list/= (&.n/range from to) + (&.reverse (&.n/range to from)))) + (let [(^open "list/") (&.Eq<List> number.Eq<Int>) + from (nat-to-int from) + to (nat-to-int to)] + (list/= (&.i/range from to) + (&.reverse (&.i/range to from)))))) )))) ## TODO: Add again once new-luxc becomes the standard compiler. -## (context: "Monad transformer" -## (let [lift (&.lift io.Monad<IO>) -## (^open "io/") io.Monad<IO>] -## (test "Can add list functionality to any monad." -## (|> (io.run (do (&.ListT io.Monad<IO>) -## [a (lift (io/wrap 123)) -## b (wrap 456)] -## (wrap (i/+ a b)))) -## (case> (^ (list 579)) true -## _ false))) -## )) +(context: "Monad transformer" + (let [lift (&.lift io.Monad<IO>) + (^open "io/") io.Monad<IO>] + (test "Can add list functionality to any monad." + (|> (io.run (do (&.ListT io.Monad<IO>) + [a (lift (io/wrap 123)) + b (wrap 456)] + (wrap (i/+ a b)))) + (case> (^ (list 579)) true + _ false))))) |