aboutsummaryrefslogtreecommitdiff
path: root/stdlib/source/test/lux/abstract/hash.lux
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--stdlib/source/test/lux/abstract/hash.lux35
1 files changed, 35 insertions, 0 deletions
diff --git a/stdlib/source/test/lux/abstract/hash.lux b/stdlib/source/test/lux/abstract/hash.lux
new file mode 100644
index 000000000..f7f82ffe2
--- /dev/null
+++ b/stdlib/source/test/lux/abstract/hash.lux
@@ -0,0 +1,35 @@
+(.module:
+ [lux #*
+ ["_" test (#+ Test)]
+ [abstract
+ [monad (#+ do)]]
+ [data
+ ["." bit ("#@." equivalence)]
+ [number
+ ["n" nat]
+ ["i" int]]]
+ [math
+ ["." random]]]
+ {1
+ ["." /]})
+
+(def: #export test
+ Test
+ (do random.monad
+ [left random.nat
+ right random.int
+ other-left random.nat
+ other-right random.int]
+ (<| (_.covering /._)
+ ($_ _.and
+ (_.cover [/.product]
+ (and (n.= (:: (/.product n.hash i.hash) hash [left right])
+ (n.* (:: n.hash hash left)
+ (:: i.hash hash right)))
+ (bit@= (:: (/.product n.hash i.hash) = [left right] [left right])
+ (and (:: n.hash = left left)
+ (:: i.hash = right right)))
+ (bit@= (:: (/.product n.hash i.hash) = [left right] [other-left other-right])
+ (and (:: n.hash = left other-left)
+ (:: i.hash = right other-right)))))
+ ))))