(.require [library [lux (.except) [abstract [monad (.only do)] [\\specification ["$[0]" equivalence]]] [control ["[0]" maybe] ["[0]" try (.use "[1]#[0]" functor)] [parser ["[0]" environment]] [concurrency ["[0]" async]]] [data ["[0]" text (.use "[1]#[0]" equivalence)] [format ["[0]" xml ["<[1]>" \\parser]]] [collection ["[0]" list]]] [math ["[0]" random (.only Random)] [number ["n" nat]]] [meta ["[0]" code]] [world ["[0]" file] ["[0]" program] ["[0]" time (.only) ["[0]" date] ["[0]" year] ["[0]" month] ["[0]" instant] ["[0]" duration]]] ["_" test (.only Test) ["[0]" unit]]]] [\\program ["[0]" / (.only) ["/[1]" // (.only) ["/[1]" // ["[1][0]" artifact] ["[1][0]" repository ["[1]/[0]" local]]]]]]) (def .public random (Random /.Metadata) (all random.and (random.alphabetic 5) (random.alphabetic 5) (random.list 5 (random.alphabetic 5)) (do [! random.monad] [year (at ! each (|>> (n.% 9,000) (n.+ 1,000) .int) random.nat) month (at ! each (|>> (n.% 12) (n.+ 1)) random.nat) day_of_month (at ! each (|>> (n.% 28) (n.+ 1)) random.nat) hour (at ! each (n.% 24) random.nat) minute (at ! each (n.% 60) random.nat) second (at ! each (n.% 60) random.nat)] (in (try.trusted (do try.monad [year (year.year year) month (month.by_number month) date (date.date year month day_of_month) time (time.time [time.#hour hour time.#minute minute time.#second second time.#milli_second 0])] (in (instant.of_date_time date time)))))))) (def .public test Test (<| (_.covering /._) (_.for [/.Metadata]) (do random.monad [expected ..random .let [artifact [///artifact.#group (the /.#group expected) ///artifact.#name (the /.#name expected) ///artifact.#version (|> expected (the /.#versions) list.head (maybe.else ""))]]] (all _.and (_.for [/.equivalence] ($equivalence.spec /.equivalence ..random)) (do random.monad [expected ..random] (_.coverage [/.format /.parser] (|> expected /.format list (.result /.parser) (try#each (at /.equivalence = expected)) (try.else false)))) (_.coverage [/.uri] (text#= (//.remote_project_uri artifact) (/.uri artifact))) (do random.monad [home (random.lower_case 5) working_directory (random.lower_case 5) .let [program (program.async (program.mock environment.empty home working_directory)) fs (file.mock (at file.default separator)) repository (///repository/local.repository program fs)]] (in (do async.monad [wrote? (/.write repository artifact expected) actual (/.read repository artifact)] (unit.coverage [/.write /.read] (and (case wrote? {try.#Success _} true {try.#Failure _} false) (case actual {try.#Success actual} (at /.equivalence = expected actual) {try.#Failure _} false)))))) ))))