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/command/build.lux | 4 +-- stdlib/source/test/aedifex/command/test.lux | 2 +- stdlib/source/test/aedifex/command/version.lux | 2 +- .../source/test/aedifex/dependency/resolution.lux | 6 ++-- stdlib/source/test/aedifex/repository.lux | 36 ++++++++++++++++++---- stdlib/source/test/aedifex/runtime.lux | 5 +-- 6 files changed, 40 insertions(+), 15 deletions(-) (limited to 'stdlib/source/test/aedifex') diff --git a/stdlib/source/test/aedifex/command/build.lux b/stdlib/source/test/aedifex/command/build.lux index 7fd8c3eb3..0e86ef946 100644 --- a/stdlib/source/test/aedifex/command/build.lux +++ b/stdlib/source/test/aedifex/command/build.lux @@ -43,7 +43,7 @@ (function (_ [actual_environment actual_working_directory actual_command actual_arguments]) (#try.Success (: (shell.Simulation []) - (structure + (implementation (def: (on_read state) (exception.throw shell.no_more_output [])) (def: (on_error state) @@ -61,7 +61,7 @@ (function (_ [actual_environment actual_working_directory actual_command actual_arguments]) (#try.Success (: (shell.Simulation []) - (structure + (implementation (def: (on_read state) (exception.throw shell.no_more_output [])) (def: (on_error state) diff --git a/stdlib/source/test/aedifex/command/test.lux b/stdlib/source/test/aedifex/command/test.lux index 291b31863..cad06aa69 100644 --- a/stdlib/source/test/aedifex/command/test.lux +++ b/stdlib/source/test/aedifex/command/test.lux @@ -84,7 +84,7 @@ (function (_ [actual_environment actual_working_directory actual_command actual_arguments]) (#try.Success (: (shell.Simulation []) - (structure + (implementation (def: (on_read state) (exception.throw shell.no_more_output [])) (def: (on_error state) diff --git a/stdlib/source/test/aedifex/command/version.lux b/stdlib/source/test/aedifex/command/version.lux index c7a9aa4ef..079b0fde4 100644 --- a/stdlib/source/test/aedifex/command/version.lux +++ b/stdlib/source/test/aedifex/command/version.lux @@ -31,7 +31,7 @@ (exception: #export console_is_closed!) -(structure: simulation +(implementation: simulation (Simulation [Bit Text]) (def: (on_read [open? state]) diff --git a/stdlib/source/test/aedifex/dependency/resolution.lux b/stdlib/source/test/aedifex/dependency/resolution.lux index ae8c7699b..ebb32b790 100644 --- a/stdlib/source/test/aedifex/dependency/resolution.lux +++ b/stdlib/source/test/aedifex/dependency/resolution.lux @@ -59,7 +59,7 @@ (def: #export (single artifact package) (-> Artifact Package (Simulation Any)) (let [expected (///artifact.uri (get@ #///artifact.version artifact) artifact)] - (structure + (implementation (def: (on_download uri state) (if (text.contains? expected uri) (cond (text.ends_with? ///artifact/extension.lux_library uri) @@ -122,7 +122,7 @@ (def: (bad_sha-1 expected_artifact expected_package dummy_package) (-> Artifact Package Package (Simulation Any)) - (structure + (implementation (def: (on_download uri state) (if (text.contains? (///artifact.uri (get@ #///artifact.version expected_artifact) expected_artifact) uri) (cond (text.ends_with? ///artifact/extension.lux_library uri) @@ -173,7 +173,7 @@ (def: (bad_md5 expected_artifact expected_package dummy_package) (-> Artifact Package Package (Simulation Any)) - (structure + (implementation (def: (on_download uri state) (if (text.contains? (///artifact.uri (get@ #///artifact.version expected_artifact) expected_artifact) uri) (cond (text.ends_with? ///artifact/extension.lux_library uri) 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 diff --git a/stdlib/source/test/aedifex/runtime.lux b/stdlib/source/test/aedifex/runtime.lux index 17b3428d2..0143eaac8 100644 --- a/stdlib/source/test/aedifex/runtime.lux +++ b/stdlib/source/test/aedifex/runtime.lux @@ -18,8 +18,9 @@ (`` ($_ _.and (~~ (template [] [(_.cover [] - (let [command ( path)] - (and (text.starts_with? ( "") command) + (let [command (text.join_with " " (#.Cons ( path))) + pure_command (text.join_with " " (#.Cons ( "")))] + (and (text.starts_with? pure_command command) (text.ends_with? path command))))] [/.java] -- cgit v1.2.3