From 744ee69630de59ca3ba660b0aab6361cd17ce1b4 Mon Sep 17 00:00:00 2001 From: Eduardo Julian Date: Wed, 30 Jun 2021 23:24:55 -0400 Subject: "signature:" -> "interface:" & "structure:" -> "implementation:" "signature" & "structure" feel like very ML-specific terminology and might not be easy on programmers unfamiliar with it.--- stdlib/source/test/aedifex/repository.lux | 36 +++++++++++++++++++++++++------ 1 file changed, 30 insertions(+), 6 deletions(-) (limited to 'stdlib/source/test/aedifex/repository.lux') diff --git a/stdlib/source/test/aedifex/repository.lux b/stdlib/source/test/aedifex/repository.lux index df8db3e88..ed32f0ac3 100644 --- a/stdlib/source/test/aedifex/repository.lux +++ b/stdlib/source/test/aedifex/repository.lux @@ -30,6 +30,7 @@ ["$." /]} {#program ["." / + ["#." remote] ["/#" // #_ ["#." artifact (#+ Version Artifact) ["#/." extension (#+ Extension)]]]]}) @@ -42,6 +43,10 @@ (exception.report ["URI" (%.text uri)])) +(exception: (cannot_upload {uri URI}) + (exception.report + ["URI" (%.text uri)])) + (type: Store (Dictionary URI Binary)) @@ -49,27 +54,46 @@ Store (dictionary.new text.hash)) -(structure: #export simulation +(def: valid_version + Version + "1.2.3-YES") + +(def: invalid_version + Version + "4.5.6-NO") + +(implementation: #export simulation (/.Simulation Store) (def: (on_download uri state) (case (dictionary.get uri state) (#.Some content) - (exception.return [state content]) + (case (binary.size content) + 0 (exception.throw ..not_found [uri]) + _ (exception.return [state content])) #.None (exception.throw ..not_found [uri]))) (def: (on_upload uri content state) - (exception.return (dictionary.put uri content state)))) + (if (dictionary.key? state uri) + (exception.throw ..cannot_upload [uri]) + (exception.return (dictionary.put uri content state))))) (def: #export test Test (<| (_.covering /._) ($_ _.and (_.for [/.mock /.Simulation] - ($/.spec (..artifact "1.2.3-YES") - (..artifact "4.5.6-NO") - (/.mock ..simulation ..empty))) + (do random.monad + [_ (wrap [])] + ($/.spec (..artifact ..valid_version) + (..artifact ..invalid_version) + (/.mock ..simulation + (|> ..empty + (dictionary.put (/remote.uri ..invalid_version + (..artifact ..invalid_version) + //artifact/extension.lux_library) + (binary.create 0))))))) /identity.test /origin.test -- cgit v1.2.3