(.module: [library [lux "*" ["_" test {"+" [Test]}] [abstract [equivalence {"+" [Equivalence]}] [hash {"+" [Hash]}] ["[0]" monad {"+" [do]}]] [control ["[0]" io] ["[0]" try] ["[0]" exception {"+" [exception:]}]] [data ["[0]" product] ["[0]" binary {"+" [Binary]}] ["[0]" text ["%" format {"+" [format]}]] [collection ["[0]" dictionary {"+" [Dictionary]}]]] [math ["[0]" random {"+" [Random]}]] [world [net ["[0]" uri {"+" [URI]}]]]]] ["[0]" / "_" ["[1][0]" identity] ["[1][0]" origin] ["[1][0]" local] ["[1][0]" remote] [// ["@[0]" artifact]]] [\\specification ["$[0]" /]] [\\program ["[0]" / ["[0]" remote] ["/[1]" // "_" ["[1][0]" artifact {"+" [Version Artifact]} ["[1]/[0]" extension {"+" [Extension]}]]]]]) (def: artifact (-> Version Artifact) (|>> ["com.github.luxlang" "test-artifact"])) (exception: (not_found [uri URI]) (exception.report ["URI" (%.text uri)])) (exception: (cannot_upload [uri URI]) (exception.report ["URI" (%.text uri)])) (type: Store (Dictionary URI Binary)) (def: .public empty Store (dictionary.empty text.hash)) (def: valid_version Version "1.2.3-YES") (def: invalid_version Version "4.5.6-NO") (implementation: .public mock (/.Mock Store) (def: the_description "@") (def: (on_download uri state) (case (dictionary.value uri state) {#.Some content} (case (binary.size content) 0 (exception.except ..not_found [uri]) _ {#try.Success [state content]}) #.None (exception.except ..not_found [uri]))) (def: (on_upload uri content state) (if (dictionary.key? state uri) (exception.except ..cannot_upload [uri]) {#try.Success (dictionary.has uri content state)}))) (def: .public test Test (<| (_.covering /._) ($_ _.and (_.for [/.mock /.Mock] (do random.monad [_ (in [])] ($/.spec (..artifact ..valid_version) (..artifact ..invalid_version) (/.mock ..mock (|> ..empty (dictionary.has (remote.uri ..invalid_version (..artifact ..invalid_version) //artifact/extension.lux_library) (binary.empty 0))))))) /identity.test /origin.test /local.test /remote.test )))