... This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0. ... If a copy of the MPL was not distributed with this file, You can obtain one at https://mozilla.org/MPL/2.0/. (.require [library [lux (.except) [abstract ["[0]" monad (.only do)]] [control ["[0]" io] ["[0]" try (.use "[1]#[0]" functor)] ["[0]" exception]] [data ["[0]" text (.only) ["%" \\format]] [collection ["[0]" list]]] [math ["[0]" random] [number ["n" nat]]] [test ["_" property (.only Test)]]]] [\\library ["[0]" /]]) (def .public test Test (<| (_.covering /._) (do [! random.monad] [loop_name (of ! each %.nat random.nat) error (of ! each %.nat random.nat) expected_events (of ! each (n.% 10) random.nat)] (all _.and (_.coverage [/.loop] (and (let [[schedule! run!] (/.loop loop_name)] (io.run! (do [! io.monad] [_ (|> (in []) (list.repeated expected_events) (monad.each ! (schedule! 0))) events_processed run!] (in (|> events_processed (try#each (n.= expected_events)) (try.else false)))))) (let [[schedule! run!] (/.loop loop_name)] (io.run! (do [! io.monad] [_ (|> (do ! [_ (in [])] (schedule! 0 (in []))) (list.repeated expected_events) (monad.each ! (schedule! 0))) events_processed run!] (in (|> events_processed (try#each (n.= (n.* 2 expected_events))) (try.else false)))))))) (_.coverage [/.already_started] (let [[schedule! run!] (/.loop loop_name)] (io.run! (do io.monad [events_processed run! failure run!] (in (and (|> events_processed (try#each (n.= 0)) (try.else false)) (when failure {try.#Failure error} (and (exception.match? /.already_started error) (text.contains? loop_name error)) _ false))))))) (_.coverage [/.error_during_execution] (let [[schedule! run!] (/.loop loop_name)] (io.run! (do io.monad [_ (schedule! 0 (io.io (panic! error))) failure run!] (in (when failure {try.#Failure error} (and (exception.match? /.error_during_execution error) (text.contains? loop_name error) (text.contains? error error)) _ false)))))) ))))