aboutsummaryrefslogtreecommitdiff
path: root/stdlib/source/test
diff options
context:
space:
mode:
Diffstat (limited to 'stdlib/source/test')
-rw-r--r--stdlib/source/test/lux/data/sum.lux14
-rw-r--r--stdlib/source/test/lux/data/text/regex.lux10
-rw-r--r--stdlib/source/test/lux/macro.lux6
-rw-r--r--stdlib/source/test/lux/type/implicit.lux37
4 files changed, 34 insertions, 33 deletions
diff --git a/stdlib/source/test/lux/data/sum.lux b/stdlib/source/test/lux/data/sum.lux
index b90206fe7..7434d7509 100644
--- a/stdlib/source/test/lux/data/sum.lux
+++ b/stdlib/source/test/lux/data/sum.lux
@@ -19,23 +19,23 @@
(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))))
+ (and (|> (/.left "Hello") (case> (0 #0 "Hello") #1 _ #0))
+ (|> (/.right "World") (case> (0 #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"))))]
+ (list (0 #0 "0") (0 #1 "1") (0 #0 "2"))))]
(and (list/= _lefts
(/.lefts (: (List (| Text Text))
- (list (0 "0") (1 "1") (0 "2")))))
+ (list (0 #0 "0") (0 #1 "1") (0 #0 "2")))))
(list/= _rights
(/.rights (: (List (| Text Text))
- (list (0 "0") (1 "1") (0 "2"))))))))
+ (list (0 #0 "0") (0 #1 "1") (0 #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 ""))))
+ (: (| Text Text) (0 #0 ""))))
(n.= 20 (/.either (function (_ _) 10)
(function (_ _) 20)
- (: (| Text Text) (1 ""))))))
+ (: (| Text Text) (0 #1 ""))))))
))))
diff --git a/stdlib/source/test/lux/data/text/regex.lux b/stdlib/source/test/lux/data/text/regex.lux
index 7789cc9bf..49f20a726 100644
--- a/stdlib/source/test/lux/data/text/regex.lux
+++ b/stdlib/source/test/lux/data/text/regex.lux
@@ -259,15 +259,15 @@
Test
($_ _.and
(_.test "Can specify alternative patterns."
- (and (should-check ["a" (0 [])] (/.regex "a|b") "a")
- (should-check ["b" (1 [])] (/.regex "a|b") "b")
+ (and (should-check ["a" (0 #0 [])] (/.regex "a|b") "a")
+ (should-check ["b" (0 #1 [])] (/.regex "a|b") "b")
(should-fail (/.regex "a|b") "c")))
(_.test "Can have groups within alternations."
- (and (should-check ["abc" (0 ["b" "c"])] (/.regex "a(.)(.)|b(.)(.)") "abc")
- (should-check ["bcd" (1 ["c" "d"])] (/.regex "a(.)(.)|b(.)(.)") "bcd")
+ (and (should-check ["abc" (0 #0 ["b" "c"])] (/.regex "a(.)(.)|b(.)(.)") "abc")
+ (should-check ["bcd" (0 #1 ["c" "d"])] (/.regex "a(.)(.)|b(.)(.)") "bcd")
(should-fail (/.regex "a(.)(.)|b(.)(.)") "cde")
- (should-check ["123-456-7890" (0 ["123" "456-7890" "456" "7890"])]
+ (should-check ["123-456-7890" (0 #0 ["123" "456-7890" "456" "7890"])]
(/.regex "(\d{3})-((\d{3})-(\d{4}))|b(.)d")
"123-456-7890")))
))
diff --git a/stdlib/source/test/lux/macro.lux b/stdlib/source/test/lux/macro.lux
index 6d65a8c3f..4875820b6 100644
--- a/stdlib/source/test/lux/macro.lux
+++ b/stdlib/source/test/lux/macro.lux
@@ -1,9 +1,7 @@
(.module:
[lux #*
- ["%" data/text/format (#+ format)]
- [abstract/monad (#+ do)]
- ["r" math/random (#+ Random)]
- ["_" test (#+ Test)]]
+ ["_" test (#+ Test)]
+ ["%" data/text/format]]
{1
["." /]}
["." / #_
diff --git a/stdlib/source/test/lux/type/implicit.lux b/stdlib/source/test/lux/type/implicit.lux
index 14b7c9524..520776996 100644
--- a/stdlib/source/test/lux/type/implicit.lux
+++ b/stdlib/source/test/lux/type/implicit.lux
@@ -1,41 +1,44 @@
(.module:
[lux #*
- ["%" data/text/format (#+ format)]
- ["r" math/random (#+ Random)]
+ ["%" data/text/format]
["_" test (#+ Test)]
- [abstract/monad (#+ do)]
[abstract
[equivalence (#+)]
- [functor (#+)]]
+ [functor (#+)]
+ [monad (#+ do)]]
[data
["." bit ("#@." equivalence)]
[number
["n" nat]]
[collection
- ["." list]]]]
+ ["." list]]]
+ [math
+ ["." random (#+ Random)]]]
{1
["." /]})
(def: #export test
Test
(<| (_.context (%.name (name-of /._)))
- (do r.monad
- [x r.nat
- y r.nat]
+ (do {@ random.monad}
+ [#let [digit (:: @ map (n.% 10) random.nat)]
+ left digit
+ right digit
+ #let [start (n.min left right)
+ end (n.max left right)]]
($_ _.and
(_.test "Can automatically select first-order structures."
(let [(^open "list@.") (list.equivalence n.equivalence)]
- (and (bit@= (:: n.equivalence = x y)
- (/.::: = x y))
- (list@= (list.n/range 1 10)
- (/.::: map inc (list.n/range 0 9)))
- )))
+ (and (bit@= (:: n.equivalence = left right)
+ (/.::: = left right))
+ (list@= (:: list.functor map inc (list.n/range start end))
+ (/.::: map inc (list.n/range start end))))))
(_.test "Can automatically select second-order structures."
(/.::: =
- (list.n/range 1 10)
- (list.n/range 1 10)))
+ (list.n/range start end)
+ (list.n/range start end)))
(_.test "Can automatically select third-order structures."
- (let [lln (/.::: map (list.n/range 1)
- (list.n/range 1 10))]
+ (let [lln (/.::: map (list.n/range start)
+ (list.n/range start end))]
(/.::: = lln lln)))
))))