(.module: [library [lux "*" ["_" test {"+" [Test]}] [abstract [monad {"+" [do]}]] [control [pipe {"+" [case>]}] ["[0]" io] ["[0]" maybe ("[1]\[0]" functor)] ["[0]" try] ["[0]" exception] [parser [environment {"+" [Environment]}]]] [data ["[0]" text ("[1]\[0]" equivalence)] [collection ["[0]" dictionary] ["[0]" list]]] [math ["[0]" random {"+" [Random]}] [number ["n" nat]]]]] [\\library ["[0]" / [// [file {"+" [Path]}]]]] [\\specification ["$[0]" /]]) (def: (environment env_size) (-> Nat (Random Environment)) (random.dictionary text.hash env_size (random.ascii/alpha 5) (random.ascii/alpha 5))) (def: path (Random Path) (random.ascii/alpha 5)) (def: .public test Test (<| (_.covering /._) (do [! random.monad] [env_size (\ ! each (|>> (n.% 10) ++) random.nat) environment (..environment env_size) home ..path directory ..path unknown (random.ascii/alpha 1)] ($_ _.and (_.for [/.mock /.async] ($/.spec (/.async (/.mock environment home directory)))) (_.cover [/.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))))))))))) (_.cover [/.unknown_environment_variable] (let [program (/.mock environment home directory)] (|> unknown (\ program variable) io.run! (case> (#try.Success _) false (#try.Failure error) (exception.match? /.unknown_environment_variable error))))) ))))