diff options
Diffstat (limited to 'stdlib/source/test')
-rw-r--r-- | stdlib/source/test/lux/abstract.lux | 6 | ||||
-rw-r--r-- | stdlib/source/test/lux/abstract/apply.lux | 24 | ||||
-rw-r--r-- | stdlib/source/test/lux/abstract/comonad.lux | 27 | ||||
-rw-r--r-- | stdlib/source/test/lux/abstract/functor.lux | 1 | ||||
-rw-r--r-- | stdlib/source/test/lux/abstract/hash.lux | 35 |
5 files changed, 91 insertions, 2 deletions
diff --git a/stdlib/source/test/lux/abstract.lux b/stdlib/source/test/lux/abstract.lux index b9aa18c9c..ef7cb0774 100644 --- a/stdlib/source/test/lux/abstract.lux +++ b/stdlib/source/test/lux/abstract.lux @@ -2,11 +2,14 @@ [lux #* ["_" test (#+ Test)]] ["." / #_ + ["#." apply] ["#." codec] + ["#." comonad] ["#." enum] ["#." equivalence] ["#." fold] ["#." functor] + ["#." hash] ["#." interval] ["#." monad] ["#." monoid] @@ -16,11 +19,14 @@ (def: #export test Test ($_ _.and + /apply.test /codec.test + /comonad.test /enum.test /equivalence.test /fold.test /functor.test + /hash.test /interval.test /monad.test /monoid.test diff --git a/stdlib/source/test/lux/abstract/apply.lux b/stdlib/source/test/lux/abstract/apply.lux index 29e3e9d6f..eb8fd4e52 100644 --- a/stdlib/source/test/lux/abstract/apply.lux +++ b/stdlib/source/test/lux/abstract/apply.lux @@ -2,8 +2,11 @@ [lux #* [abstract/monad (#+ do)] [data + ["." maybe] [number - ["n" nat]]] + ["n" nat]] + [collection + ["." list]]] [control ["." function]] [math @@ -70,3 +73,22 @@ (..interchange injection comparison apply) (..composition injection comparison apply) ))) + +(def: #export test + Test + (do random.monad + [left random.nat + right random.nat] + (<| (_.covering /._) + ($_ _.and + (_.cover [/.compose] + (let [expected (n.+ left right)] + (case (:: (/.compose maybe.monad maybe.apply list.apply) apply + (#.Some (list (n.+ left))) + (#.Some (list right))) + (^ (#.Some (list actual))) + (n.= expected actual) + + _ + false))) + )))) diff --git a/stdlib/source/test/lux/abstract/comonad.lux b/stdlib/source/test/lux/abstract/comonad.lux new file mode 100644 index 000000000..2e63b4eb8 --- /dev/null +++ b/stdlib/source/test/lux/abstract/comonad.lux @@ -0,0 +1,27 @@ +(.module: + [lux #* + [abstract + [monad (#+ do)]] + [data + ["." identity (#+ Identity)] + [number + ["n" nat]]] + [math + ["." random]] + ["_" test (#+ Test)]] + {1 + ["." /]}) + +(def: #export test + Test + (do random.monad + [sample random.nat] + (<| (_.covering /._) + ($_ _.and + (_.cover [/.be] + (n.= (inc sample) + (: (Identity Nat) + (/.be identity.comonad + [value (unwrap sample)] + (unwrap (inc value)))))) + )))) diff --git a/stdlib/source/test/lux/abstract/functor.lux b/stdlib/source/test/lux/abstract/functor.lux index fcceca39b..faef439c6 100644 --- a/stdlib/source/test/lux/abstract/functor.lux +++ b/stdlib/source/test/lux/abstract/functor.lux @@ -1,7 +1,6 @@ (.module: [lux #* ["_" test (#+ Test)] - ["%" data/text/format (#+ format)] [abstract [equivalence (#+ Equivalence)] [monad (#+ do)]] 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))))) + )))) |