(.require [library [lux (.except) [abstract [monad (.only do)] [\\specification ["$[0]" equivalence] ["$[0]" monoid]]] [control ["<>" parser] ["[0]" try (.use "[1]#[0]" functor)] ["[0]" exception]] [data ["[0]" text (.only) ["<[1]>" \\parser]] [collection ["[0]" list]]] [math ["[0]" random (.only Random) (.use "[1]#[0]" monad)]] ["[0]" meta (.only) ["[0]" code (.only) ["<[1]>" \\parser]] [macro [syntax (.only syntax)] ["[0]" expansion]]] [test ["_" property (.only Test)]]]] [\\library ["[0]" /]]) (def .public (random amount) (-> Nat (Random /.Configuration)) (when amount 0 (random#in /.empty) _ (do [! random.monad] [feature (random.upper_cased amount) value (random.lower_cased amount)] (at ! each (|>> (list.partial [feature value])) (random (-- amount)))))) (def failure (syntax (_ [it .any]) (function (_ lux) (when (expansion.complete it lux) {try.#Failure error} {try.#Success [lux (list (code.text error))]} {try.#Success _} {try.#Failure ""})))) (def .public test Test (<| (_.covering /._) (_.for [/.Configuration]) (do [! random.monad] [expected (..random 5)] (all _.and (_.for [/.equivalence] ($equivalence.spec /.equivalence (..random 5))) (_.for [/.monoid] ($monoid.spec /.equivalence /.monoid (..random 5))) (_.coverage [/.empty] (list.empty? /.empty)) (_.coverage [/.format /.parser] (|> expected /.format (.result /.parser) (try#each (at /.equivalence = expected)) (try.else false))) (_.coverage [/.for] (and (and (/.for ["left" "<<<" "right" ">>>"] true ... else false) (/.for ["left" "<<<"] true ... else false) (/.for ["right" ">>>"] true ... else false)) (and (/.for ["yolo" ""] false ... else true) (/.for ["left" "yolo"] false ... else true)))) (_.coverage [/.invalid] (and (text.contains? (the exception.#label /.invalid) (..failure (/.for))) (text.contains? (the exception.#label /.invalid) (..failure (/.for ["left" "yolo"] ... else false))))) ))))