(.module: [library [lux #* ["_" test (#+ Test)] [abstract [monad (#+ do)]] [control ["." io (#+ IO)] [concurrency ["." promise]]] [math ["." random] [number ["n" nat]]]]] [\\library ["." /]]) (/.capability: (Can-Shift a) (can-shift [a Nat] [a Nat])) (/.capability: Can-IO (can-io [] (IO Nat))) (def: #export test Test (<| (_.covering /._) (do random.monad [shift random.nat base random.nat #let [expected (n.+ shift base)] pass-through (random.ascii 1)] (_.for [/.Capability] ($_ _.and (_.cover [/.capability: /.use] (let [capability (..can-shift (function (_ [no-op raw]) [no-op (n.+ shift raw)])) [untouched actual] (/.use capability [pass-through base])] (and (is? pass-through untouched) (n.= expected actual)))) (wrap (let [capability (..can-io (function (_ _) (io.io expected)))] (do promise.monad [actual (/.use (/.async capability) [])] (_.cover' [/.async] (n.= expected actual))))) )))))