aboutsummaryrefslogtreecommitdiff
path: root/stdlib/source/test
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--stdlib/source/test/lux/abstract.lux5
-rw-r--r--stdlib/source/test/lux/abstract/equivalence.lux34
2 files changed, 36 insertions, 3 deletions
diff --git a/stdlib/source/test/lux/abstract.lux b/stdlib/source/test/lux/abstract.lux
index b35b38137..b18d1c61b 100644
--- a/stdlib/source/test/lux/abstract.lux
+++ b/stdlib/source/test/lux/abstract.lux
@@ -4,6 +4,7 @@
["." / #_
["#." codec]
["#." enum]
+ ["#." equivalence]
["#." interval]])
(def: #export test
@@ -11,5 +12,5 @@
($_ _.and
/codec.test
/enum.test
- /interval.test
- ))
+ /equivalence.test
+ /interval.test))
diff --git a/stdlib/source/test/lux/abstract/equivalence.lux b/stdlib/source/test/lux/abstract/equivalence.lux
index ac0084e82..7ae9b37af 100644
--- a/stdlib/source/test/lux/abstract/equivalence.lux
+++ b/stdlib/source/test/lux/abstract/equivalence.lux
@@ -3,13 +3,45 @@
["_" test (#+ Test)]
[abstract/monad (#+ do)]
[data
+ ["." bit ("#@." equivalence)]
[text
- ["%" format (#+ format)]]]
+ ["%" format (#+ format)]]
+ [number
+ ["n" nat]
+ ["i" int]]]
[math
["r" random (#+ Random)]]]
{1
["." / (#+ Equivalence)]})
+(def: #export test
+ Test
+ (do r.monad
+ [leftN r.nat
+ rightN r.nat
+ leftI r.int
+ rightI r.int]
+ (<| (_.context (%.name (name-of /._)))
+ ($_ _.and
+ (_.test (%.name (name-of /.sum))
+ (let [equivalence (/.sum n.equivalence i.equivalence)]
+ (and (bit@= (:: n.equivalence = leftN leftN)
+ (:: equivalence = (#.Left leftN) (#.Left leftN)))
+ (bit@= (:: n.equivalence = leftN rightN)
+ (:: equivalence = (#.Left leftN) (#.Left rightN)))
+ (bit@= (:: i.equivalence = leftI leftI)
+ (:: equivalence = (#.Right leftI) (#.Right leftI)))
+ (bit@= (:: i.equivalence = leftI rightI)
+ (:: equivalence = (#.Right leftI) (#.Right rightI))))))
+ (_.test (%.name (name-of /.product))
+ (let [equivalence (/.product n.equivalence i.equivalence)]
+ (and (bit@= (and (:: n.equivalence = leftN leftN)
+ (:: i.equivalence = leftI leftI))
+ (:: equivalence = [leftN leftI] [leftN leftI]))
+ (bit@= (and (:: n.equivalence = leftN rightN)
+ (:: i.equivalence = leftI rightI))
+ (:: equivalence = [leftN leftI] [rightN rightI])))))))))
+
(def: #export (spec (^open "_@.") generator)
(All [a] (-> (Equivalence a) (Random a) Test))
(do r.monad