aboutsummaryrefslogtreecommitdiff
path: root/stdlib/source/test
diff options
context:
space:
mode:
authorEduardo Julian2020-03-05 21:32:13 -0400
committerEduardo Julian2020-03-05 21:32:13 -0400
commit71c99d63a313d497c3881ab06752f05e3af33350 (patch)
tree1170c040d4dcfb2077a62fa26acbad7702cc2785 /stdlib/source/test
parente5153db14981fa7da2c34058bed494a8662496c8 (diff)
Test for equivalence + adjustments to Lua-generation code.
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