aboutsummaryrefslogtreecommitdiff
path: root/stdlib/source/test/lux/math/number/i32.lux
diff options
context:
space:
mode:
authorEduardo Julian2020-12-29 00:38:21 -0400
committerEduardo Julian2020-12-29 00:38:21 -0400
commit832a9361b632331e82a64c07baa560487ca8abde (patch)
tree5fec882399315def4d789ecef1746d90e761df93 /stdlib/source/test/lux/math/number/i32.lux
parent92dca9f487c625d27f6c291784ef709b0cc13a72 (diff)
Moved "lux/data/number" to "lux/math/number".
Diffstat (limited to 'stdlib/source/test/lux/math/number/i32.lux')
-rw-r--r--stdlib/source/test/lux/math/number/i32.lux38
1 files changed, 38 insertions, 0 deletions
diff --git a/stdlib/source/test/lux/math/number/i32.lux b/stdlib/source/test/lux/math/number/i32.lux
new file mode 100644
index 000000000..1061cdc1b
--- /dev/null
+++ b/stdlib/source/test/lux/math/number/i32.lux
@@ -0,0 +1,38 @@
+(.module:
+ [lux #*
+ ["_" test (#+ Test)]
+ [abstract
+ [monad (#+ do)]
+ {[0 #spec]
+ [/
+ ["$." equivalence]]}]
+ [math
+ ["." random (#+ Random)]]]
+ {1
+ ["." /
+ ["/#" // #_
+ ["i" int]
+ ["#." i64]]]})
+
+(def: #export random
+ (Random /.I32)
+ (\ random.functor map /.i32 random.i64))
+
+(def: #export test
+ Test
+ (<| (_.covering /._)
+ (_.for [/.I32])
+ (do {! random.monad}
+ [#let [limit (|> (dec /.width)
+ //i64.mask
+ .int
+ inc)]
+ expected (\ ! map (i.% limit) random.int)]
+ ($_ _.and
+ (_.for [/.equivalence]
+ ($equivalence.spec /.equivalence ..random))
+
+ (_.cover [/.i32 /.i64 /.width]
+ (let [actual (|> expected .i64 /.i32 /.i64)]
+ (\ //i64.equivalence = expected actual)))
+ ))))