From 0abd5bd3c0e38e352e9ba38268e04e1c858ab01e Mon Sep 17 00:00:00 2001 From: Eduardo Julian Date: Thu, 15 Jul 2021 00:45:15 -0400 Subject: Re-named "spec" hierarchy to "specification". --- stdlib/source/specification/aedifex/repository.lux | 57 ++++++++++++++++++++++ 1 file changed, 57 insertions(+) create mode 100644 stdlib/source/specification/aedifex/repository.lux (limited to 'stdlib/source/specification/aedifex/repository.lux') diff --git a/stdlib/source/specification/aedifex/repository.lux b/stdlib/source/specification/aedifex/repository.lux new file mode 100644 index 000000000..de9a05fde --- /dev/null +++ b/stdlib/source/specification/aedifex/repository.lux @@ -0,0 +1,57 @@ +(.module: + [library + [lux #* + ["_" test (#+ Test)] + [abstract + [monad (#+ do)]] + [control + ["." try (#+ Try)] + [concurrency + ["." promise (#+ Promise)]]] + [data + ["." binary + ["_#" \\test]]] + [math + ["." random]]]] + [\\program + ["." / + ["#." remote] + ["/#" // #_ + ["#." artifact (#+ Artifact) + ["#/." extension]]]]] + [\\test + ["_." // #_ + ["#." artifact]]]) + +(def: #export (spec valid_artifact invalid_artifact subject) + (-> Artifact Artifact (/.Repository Promise) Test) + (do random.monad + [expected (_binary.random 100)] + (wrap ($_ _.and' + (do promise.monad + [#let [good_uri (/remote.uri (get@ #//artifact.version valid_artifact) valid_artifact //artifact/extension.lux_library)] + good_upload! (\ subject upload good_uri expected) + good_download! (\ subject download good_uri) + + #let [bad_uri (/remote.uri (get@ #//artifact.version invalid_artifact) invalid_artifact //artifact/extension.lux_library)] + bad_upload! (\ subject upload bad_uri expected) + bad_download! (\ subject download bad_uri)] + (_.cover' [/.Repository] + (let [successfull_flow! + (case [good_upload! good_download!] + [(#try.Success _) (#try.Success actual)] + (\ binary.equivalence = expected actual) + + _ + false) + + failed_flow! + (case [bad_upload! bad_download!] + [(#try.Failure _) (#try.Failure _)] + true + + _ + false)] + (and successfull_flow! + failed_flow!)))) + )))) -- cgit v1.2.3