From 853642c340730b3bb23c1ac87660c5c7ecbffa93 Mon Sep 17 00:00:00 2001 From: Eduardo Julian Date: Tue, 19 May 2020 23:46:38 -0400 Subject: Can now write TAR files. --- stdlib/source/test/lux/abstract.lux | 6 +++++ stdlib/source/test/lux/abstract/apply.lux | 24 +++++++++++++++++++- stdlib/source/test/lux/abstract/comonad.lux | 27 ++++++++++++++++++++++ stdlib/source/test/lux/abstract/functor.lux | 1 - stdlib/source/test/lux/abstract/hash.lux | 35 +++++++++++++++++++++++++++++ 5 files changed, 91 insertions(+), 2 deletions(-) create mode 100644 stdlib/source/test/lux/abstract/comonad.lux create mode 100644 stdlib/source/test/lux/abstract/hash.lux (limited to 'stdlib/source/test') 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))))) + )))) -- cgit v1.2.3