diff options
Diffstat (limited to 'stdlib/source/test/lux/abstract/hash.lux')
-rw-r--r-- | stdlib/source/test/lux/abstract/hash.lux | 39 |
1 files changed, 39 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..c527fb9c9 --- /dev/null +++ b/stdlib/source/test/lux/abstract/hash.lux @@ -0,0 +1,39 @@ +(.module: + [lux #* + ["_" test (#+ Test)] + [abstract + [monad (#+ do)] + {[0 #spec] + [/ + [functor + ["$." contravariant]]]}] + [data + ["." bit ("#\." equivalence)]] + [math + ["." random] + [number + ["." nat]]]] + {1 + ["." / (#+ Hash) + [// + [equivalence (#+ Equivalence)]]]}) + +(def: #export test + Test + (do random.monad + [leftN random.nat + rightN random.nat + #let [hash (: (Equivalence (/.Hash Nat)) + (structure + (def: (= (^open "left\.") (^open "right\.")) + (and (bit\= (left\= (left\hash leftN) (left\hash leftN)) + (right\= (right\hash leftN) (right\hash leftN))) + (bit\= (left\= (left\hash rightN) (left\hash rightN)) + (right\= (right\hash rightN) (right\hash rightN))) + (bit\= (left\= (left\hash leftN) (left\hash rightN)) + (right\= (right\hash leftN) (right\hash rightN)))))))]] + (<| (_.covering /._) + ($_ _.and + (_.for [/.functor] + ($contravariant.spec hash nat.hash /.functor)) + )))) |