From a82bd1eabe94763162c2b0707d9c198fbe9835e3 Mon Sep 17 00:00:00 2001 From: Eduardo Julian Date: Fri, 18 Jun 2021 14:21:41 -0400 Subject: Refactored the machinery to make local macros into its own module. --- .../source/test/aedifex/dependency/resolution.lux | 232 +++++++++++---------- 1 file changed, 117 insertions(+), 115 deletions(-) (limited to 'stdlib/source/test/aedifex/dependency') diff --git a/stdlib/source/test/aedifex/dependency/resolution.lux b/stdlib/source/test/aedifex/dependency/resolution.lux index 4404cb32f..e9cd26a82 100644 --- a/stdlib/source/test/aedifex/dependency/resolution.lux +++ b/stdlib/source/test/aedifex/dependency/resolution.lux @@ -16,7 +16,8 @@ ["." product] ["." binary] ["." text - ["." encoding]] + [encoding + ["." utf8]]] [format ["." xml]] [collection @@ -59,38 +60,39 @@ (def: #export (single artifact package) (-> Artifact Package (Simulation Any)) - (structure - (def: (on_download uri state) - (if (text.contains? (///artifact.uri artifact) uri) - (cond (text.ends_with? ///artifact/extension.lux_library uri) - (#try.Success [state (|> package - (get@ #///package.library) - product.left)]) - - (text.ends_with? ///artifact/extension.pom uri) - (#try.Success [state (|> package - (get@ #///package.pom) - product.left - (\ xml.codec encode) - (\ encoding.utf8 encode))]) + (let [expected (///artifact.uri (get@ #///artifact.version artifact) artifact)] + (structure + (def: (on_download uri state) + (if (text.contains? expected uri) + (cond (text.ends_with? ///artifact/extension.lux_library uri) + (#try.Success [state (|> package + (get@ #///package.library) + product.left)]) + + (text.ends_with? ///artifact/extension.pom uri) + (#try.Success [state (|> package + (get@ #///package.pom) + product.left + (\ xml.codec encode) + (\ utf8.codec encode))]) - ## (text.ends_with? ///artifact/extension.sha-1 uri) - ## (#try.Success [state (|> package - ## (get@ #///package.sha-1) - ## (\ ///hash.sha-1_codec encode) - ## (\ encoding.utf8 encode))]) - - ## (text.ends_with? ///artifact/extension.md5 uri) - ## (#try.Success [state (|> package - ## (get@ #///package.md5) - ## (\ ///hash.md5_codec encode) - ## (\ encoding.utf8 encode))]) + ## (text.ends_with? ///artifact/extension.sha-1 uri) + ## (#try.Success [state (|> package + ## (get@ #///package.sha-1) + ## (\ ///hash.sha-1_codec encode) + ## (\ utf8.codec encode))]) + + ## (text.ends_with? ///artifact/extension.md5 uri) + ## (#try.Success [state (|> package + ## (get@ #///package.md5) + ## (\ ///hash.md5_codec encode) + ## (\ utf8.codec encode))]) - ## else - (#try.Failure "NOPE")) - (#try.Failure "NOPE"))) - (def: (on_upload uri binary state) - (#try.Failure "NOPE")))) + ## else + (#try.Failure "NOPE")) + (#try.Failure "NOPE"))) + (def: (on_upload uri binary state) + (#try.Failure "NOPE"))))) (def: one Test @@ -106,7 +108,7 @@ bad_sha-1 (: (Simulation Any) (structure (def: (on_download uri state) - (if (text.contains? (///artifact.uri expected_artifact) uri) + (if (text.contains? (///artifact.uri (get@ #///artifact.version expected_artifact) expected_artifact) uri) (cond (text.ends_with? ///artifact/extension.lux_library uri) (#try.Success [state (|> expected_package (get@ #///package.library) @@ -117,19 +119,19 @@ (get@ #///package.pom) product.left (\ xml.codec encode) - (\ encoding.utf8 encode))]) + (\ utf8.codec encode))]) ## (text\= extension ///artifact/extension.sha-1) ## (#try.Success [state (|> dummy_package ## (get@ #///package.sha-1) ## (\ ///hash.sha-1_codec encode) - ## (\ encoding.utf8 encode))]) + ## (\ utf8.codec encode))]) ## (text\= extension ///artifact/extension.md5) ## (#try.Success [state (|> expected_package ## (get@ #///package.md5) ## (\ ///hash.md5_codec encode) - ## (\ encoding.utf8 encode))]) + ## (\ utf8.codec encode))]) ## else (#try.Failure "NOPE")) @@ -139,7 +141,7 @@ bad_md5 (: (Simulation Any) (structure (def: (on_download uri state) - (if (text.contains? (///artifact.uri expected_artifact) uri) + (if (text.contains? (///artifact.uri (get@ #///artifact.version expected_artifact) expected_artifact) uri) (cond (text.ends_with? ///artifact/extension.lux_library uri) (#try.Success [state (|> expected_package (get@ #///package.library) @@ -150,19 +152,19 @@ (get@ #///package.pom) product.left (\ xml.codec encode) - (\ encoding.utf8 encode))]) + (\ utf8.codec encode))]) ## (text\= extension ///artifact/extension.sha-1) ## (#try.Success [state (|> expected_package ## (get@ #///package.sha-1) ## (\ ///hash.sha-1_codec encode) - ## (\ encoding.utf8 encode))]) + ## (\ utf8.codec encode))]) ## (text\= extension ///artifact/extension.md5) ## (#try.Success [state (|> dummy_package ## (get@ #///package.md5) ## (\ ///hash.md5_codec encode) - ## (\ encoding.utf8 encode))]) + ## (\ utf8.codec encode))]) ## else (#try.Failure "NOPE")) @@ -217,7 +219,7 @@ bad_sha-1 (: (Simulation Any) (structure (def: (on_download uri state) - (if (text.contains? (///artifact.uri expected_artifact) uri) + (if (text.contains? (///artifact.uri (get@ #///artifact.version expected_artifact) expected_artifact) uri) (cond (text.ends_with? ///artifact/extension.lux_library uri) (#try.Success [state (|> expected_package (get@ #///package.library) @@ -228,19 +230,19 @@ (get@ #///package.pom) product.left (\ xml.codec encode) - (\ encoding.utf8 encode))]) + (\ utf8.codec encode))]) ## (text\= extension ///artifact/extension.sha-1) ## (#try.Success [state (|> dummy_package ## (get@ #///package.sha-1) ## (\ ///hash.sha-1_codec encode) - ## (\ encoding.utf8 encode))]) + ## (\ utf8.codec encode))]) ## (text\= extension ///artifact/extension.md5) ## (#try.Success [state (|> expected_package ## (get@ #///package.md5) ## (\ ///hash.md5_codec encode) - ## (\ encoding.utf8 encode))]) + ## (\ utf8.codec encode))]) ## else (#try.Failure "NOPE")) @@ -250,7 +252,7 @@ bad_md5 (: (Simulation Any) (structure (def: (on_download uri state) - (if (text.contains? (///artifact.uri expected_artifact) uri) + (if (text.contains? (///artifact.uri (get@ #///artifact.version expected_artifact) expected_artifact) uri) (cond (text.ends_with? ///artifact/extension.lux_library uri) (#try.Success [state (|> expected_package (get@ #///package.library) @@ -261,19 +263,19 @@ (get@ #///package.pom) product.left (\ xml.codec encode) - (\ encoding.utf8 encode))]) + (\ utf8.codec encode))]) ## (text\= extension ///artifact/extension.sha-1) ## (#try.Success [state (|> expected_package ## (get@ #///package.sha-1) ## (\ ///hash.sha-1_codec encode) - ## (\ encoding.utf8 encode))]) + ## (\ utf8.codec encode))]) ## (text\= extension ///artifact/extension.md5) ## (#try.Success [state (|> dummy_package ## (get@ #///package.md5) ## (\ ///hash.md5_codec encode) - ## (\ encoding.utf8 encode))]) + ## (\ utf8.codec encode))]) ## else (#try.Failure "NOPE")) @@ -312,77 +314,77 @@ false)))) ))) -(def: all - Test - (do {! random.monad} - [dependee_artifact $///artifact.random - depender_artifact (random.filter (predicate.complement - (\ ///artifact.equivalence = dependee_artifact)) - $///artifact.random) - ignored_artifact (random.filter (predicate.complement - (predicate.unite (\ ///artifact.equivalence = dependee_artifact) - (\ ///artifact.equivalence = depender_artifact))) - $///artifact.random) +## (def: all +## Test +## (do {! random.monad} +## [dependee_artifact $///artifact.random +## depender_artifact (random.filter (predicate.complement +## (\ ///artifact.equivalence = dependee_artifact)) +## $///artifact.random) +## ignored_artifact (random.filter (predicate.complement +## (predicate.unite (\ ///artifact.equivalence = dependee_artifact) +## (\ ///artifact.equivalence = depender_artifact))) +## $///artifact.random) - [_ dependee_package] $///package.random - [_ depender_package] $///package.random - [_ ignored_package] $///package.random +## [_ dependee_package] $///package.random +## [_ depender_package] $///package.random +## [_ ignored_package] $///package.random - #let [dependee {#///dependency.artifact dependee_artifact - #///dependency.type ///artifact/type.lux_library} - depender {#///dependency.artifact depender_artifact - #///dependency.type ///artifact/type.lux_library} - ignored {#///dependency.artifact ignored_artifact - #///dependency.type ///artifact/type.lux_library} +## #let [dependee {#///dependency.artifact dependee_artifact +## #///dependency.type ///artifact/type.lux_library} +## depender {#///dependency.artifact depender_artifact +## #///dependency.type ///artifact/type.lux_library} +## ignored {#///dependency.artifact ignored_artifact +## #///dependency.type ///artifact/type.lux_library} - dependee_pom (|> (\ ///.monoid identity) - (set@ #///.identity (#.Some dependee_artifact)) - ///pom.write - try.assume) - depender_pom (|> (\ ///.monoid identity) - (set@ #///.identity (#.Some depender_artifact)) - (set@ #///.dependencies (set.from_list ///dependency.hash (list dependee))) - ///pom.write - try.assume) - ignored_pom (|> (\ ///.monoid identity) - (set@ #///.identity (#.Some ignored_artifact)) - ///pom.write - try.assume) - - dependee_package (set@ #///package.pom [dependee_pom #///dependency/status.Unverified] dependee_package) - depender_package (set@ #///package.pom [depender_pom #///dependency/status.Unverified] depender_package) - ignored_package (set@ #///package.pom [ignored_pom #///dependency/status.Unverified] ignored_package)]] - ($_ _.and - (wrap - (do promise.monad - [resolution (/.all (list (///repository.mock (..single dependee_artifact dependee_package) []) - (///repository.mock (..single depender_artifact depender_package) []) - (///repository.mock (..single ignored_artifact ignored_package) [])) - (list depender) - /.empty)] - (_.cover' [/.all] - (case resolution - (#try.Success resolution) - (and (dictionary.key? resolution depender) - (dictionary.key? resolution dependee) - (not (dictionary.key? resolution ignored))) +## dependee_pom (|> (\ ///.monoid identity) +## (set@ #///.identity (#.Some dependee_artifact)) +## ///pom.write +## try.assume) +## depender_pom (|> (\ ///.monoid identity) +## (set@ #///.identity (#.Some depender_artifact)) +## (set@ #///.dependencies (set.from_list ///dependency.hash (list dependee))) +## ///pom.write +## try.assume) +## ignored_pom (|> (\ ///.monoid identity) +## (set@ #///.identity (#.Some ignored_artifact)) +## ///pom.write +## try.assume) - (#try.Failure error) - false)))) - ))) +## dependee_package (set@ #///package.pom [dependee_pom #///dependency/status.Unverified] dependee_package) +## depender_package (set@ #///package.pom [depender_pom #///dependency/status.Unverified] depender_package) +## ignored_package (set@ #///package.pom [ignored_pom #///dependency/status.Unverified] ignored_package)]] +## ($_ _.and +## (wrap +## (do promise.monad +## [resolution (/.all (list (///repository.mock (..single dependee_artifact dependee_package) []) +## (///repository.mock (..single depender_artifact depender_package) []) +## (///repository.mock (..single ignored_artifact ignored_package) [])) +## (list depender) +## /.empty)] +## (_.cover' [/.all] +## (case resolution +## (#try.Success resolution) +## (and (dictionary.key? resolution depender) +## (dictionary.key? resolution dependee) +## (not (dictionary.key? resolution ignored))) -(def: #export test - Test - (<| (_.covering /._) - (_.for [/.Resolution]) - ($_ _.and - (_.for [/.equivalence] - ($equivalence.spec /.equivalence ..random)) +## (#try.Failure error) +## false)))) +## ))) + +## (def: #export test +## Test +## (<| (_.covering /._) +## (_.for [/.Resolution]) +## ($_ _.and +## (_.for [/.equivalence] +## ($equivalence.spec /.equivalence ..random)) + +## (_.cover [/.empty] +## (dictionary.empty? /.empty)) - (_.cover [/.empty] - (dictionary.empty? /.empty)) - - ..one - ..any - ..all - ))) +## ..one +## ..any +## ..all +## ))) -- cgit v1.2.3