(.using [library [lux (.except) ["_" test (.only Test)] [abstract [monad (.only do)]] [control ["[0]" pipe] ["[0]" io] ["[0]" maybe (.open: "[1]#[0]" functor)] ["[0]" try] ["[0]" exception] [parser [environment (.only Environment)]]] [data ["[0]" text (.open: "[1]#[0]" equivalence)] [collection ["[0]" dictionary] ["[0]" list]]] [math ["[0]" random (.only Random)] [number ["n" nat]]]]] [\\library ["[0]" / (.only) [// [file (.only Path)]]]] [\\specification ["$[0]" /]]) (def: (environment env_size) (-> Nat (Random Environment)) (random.dictionary text.hash env_size (random.alphabetic 5) (random.alphabetic 5))) (def: path (Random Path) (random.alphabetic 5)) (def: .public test Test (<| (_.covering /._) (do [! random.monad] [env_size (at ! each (|>> (n.% 10) ++) random.nat) environment (..environment env_size) home ..path directory ..path unknown (random.alphabetic 1)] (all _.and (_.for [/.mock /.async] ($/.spec (/.async (/.mock environment home directory)))) (_.coverage [/.environment] (let [program (/.mock environment home directory)] (io.run! (do io.monad [actual (/.environment io.monad program)] (in (and (n.= (dictionary.size environment) (dictionary.size actual)) (|> actual dictionary.entries (list.every? (function (_ [key value]) (|> environment (dictionary.value key) (maybe#each (text#= value)) (maybe.else false))))))))))) (_.coverage [/.unknown_environment_variable] (let [program (/.mock environment home directory)] (|> unknown (at program variable) io.run! (pipe.case {try.#Success _} false {try.#Failure error} (exception.match? /.unknown_environment_variable error))))) ))))