diff options
Diffstat (limited to 'stdlib/source/test/lux/control/function/trampoline.lux')
-rw-r--r-- | stdlib/source/test/lux/control/function/trampoline.lux | 50 |
1 files changed, 50 insertions, 0 deletions
diff --git a/stdlib/source/test/lux/control/function/trampoline.lux b/stdlib/source/test/lux/control/function/trampoline.lux new file mode 100644 index 000000000..18d29110c --- /dev/null +++ b/stdlib/source/test/lux/control/function/trampoline.lux @@ -0,0 +1,50 @@ +(.require + [library + [lux (.except) + [abstract + [monad (.only do)] + [\\specification + ["$[0]" functor (.only Injection Comparison)] + ["$[0]" monad]]] + [math + ["[0]" random] + [number + ["n" nat]]] + [test + ["_" property (.only Test)]]]] + [\\library + ["[0]" /]]) + +(def injection + (Injection /.Trampoline) + (|>> /.return)) + +(def comparison + (Comparison /.Trampoline) + (function (_ == left right) + (== (/.result left) (/.result right)))) + +(def .public test + Test + (<| (_.covering /._) + (_.for [/.Trampoline]) + (do [! random.monad] + [expected random.nat + left random.nat + right random.nat]) + (all _.and + (_.for [/.functor] + ($functor.spec ..injection ..comparison /.functor)) + (_.for [/.monad] + ($monad.spec ..injection ..comparison /.monad)) + + (_.coverage [/.return /.result] + (|> (/.return expected) + /.result + (same? expected))) + (_.coverage [/.jump] + (with_expansions [<expected> (n.+ left right)] + (|> (/.jump (/.return <expected>)) + /.result + (n.= <expected>)))) + ))) |