diff options
author | Eduardo Julian | 2021-06-24 03:42:57 -0400 |
---|---|---|
committer | Eduardo Julian | 2021-06-24 03:42:57 -0400 |
commit | ce1a7a131f7c4df8eae5c019eba2893b56f04d46 (patch) | |
tree | 645c4b42c4b9bff141b7390d9f33f3f1fe4aeea1 /stdlib/source/test/aedifex | |
parent | a82bd1eabe94763162c2b0707d9c198fbe9835e3 (diff) |
Added a macro for type-casting JVM objects.
Diffstat (limited to 'stdlib/source/test/aedifex')
-rw-r--r-- | stdlib/source/test/aedifex/command.lux | 9 | ||||
-rw-r--r-- | stdlib/source/test/aedifex/command/auto.lux | 29 | ||||
-rw-r--r-- | stdlib/source/test/aedifex/command/build.lux | 12 | ||||
-rw-r--r-- | stdlib/source/test/aedifex/command/test.lux | 10 | ||||
-rw-r--r-- | stdlib/source/test/aedifex/dependency/resolution.lux | 457 | ||||
-rw-r--r-- | stdlib/source/test/aedifex/input.lux | 17 |
6 files changed, 289 insertions, 245 deletions
diff --git a/stdlib/source/test/aedifex/command.lux b/stdlib/source/test/aedifex/command.lux index e0cb2da79..42d1c1278 100644 --- a/stdlib/source/test/aedifex/command.lux +++ b/stdlib/source/test/aedifex/command.lux @@ -12,11 +12,10 @@ ["#." deploy] ["#." build] - ["#." test]] + ["#." test] + ["#." auto]] {#program - ["." / - ## ["#." auto] - ]}) + ["." /]}) (def: #export test Test @@ -34,5 +33,5 @@ /build.test /test.test - ## /auto.test + /auto.test ))) diff --git a/stdlib/source/test/aedifex/command/auto.lux b/stdlib/source/test/aedifex/command/auto.lux index 7bac6eb5d..c23519bcc 100644 --- a/stdlib/source/test/aedifex/command/auto.lux +++ b/stdlib/source/test/aedifex/command/auto.lux @@ -20,7 +20,7 @@ ["." set] ["." list ("#\." functor)]]] [math - ["." random] + ["." random (#+ Random)] [number ["n" nat]]] [world @@ -56,10 +56,10 @@ [@runs (function (_ console program fs shell resolution profile) (do {! promise.monad} - [[runs remaining_files] (promise.future - (atom.update (function (_ [runs remaining_files]) - [(inc runs) remaining_files]) - @runs))] + [[_ [runs remaining_files]] (promise.future + (atom.update (function (_ [runs remaining_files]) + [(inc runs) remaining_files]) + @runs))] (case remaining_files #.Nil (wrap (#try.Failure end_signal)) @@ -78,15 +78,10 @@ [#let [/ (\ file.default separator) [fs watcher] (watch.mock /)] end_signal (random.ascii/alpha 5) + program (random.ascii/alpha 5) target (random.ascii/alpha 5) - home (random.ascii/alpha 5) - working_directory (random.ascii/alpha 5) - expected_runs (\ ! map (|>> (n.% 10) (n.max 2)) random.nat) source (random.ascii/alpha 5) - dummy_files (|> (random.ascii/alpha 5) - (random.set text.hash (dec expected_runs)) - (\ ! map (|>> set.to_list (list\map (|>> (format source /)))))) #let [empty_profile (: Profile (\ ///.monoid identity)) with_target (: (-> Profile Profile) @@ -98,6 +93,14 @@ with_program with_target (set@ #///.sources (set.from_list text.hash (list source))))] + + home (random.ascii/alpha 5) + working_directory (random.ascii/alpha 5) + + expected_runs (\ ! map (|>> (n.% 10) (n.max 2)) random.nat) + dummy_files (|> (random.ascii/alpha 5) + (random.set text.hash (dec expected_runs)) + (\ ! map (|>> set.to_list (list\map (|>> (format source /)))))) resolution @build.resolution] ($_ _.and (wrap (do promise.monad @@ -106,11 +109,11 @@ _ (!.use (\ fs create_directory) [source]) _ (\ watcher poll [])] (do promise.monad - [outcome ((/.do! watcher command) + [outcome ((/.do! 1 watcher command) (@version.echo "") (program.async (program.mock environment.empty home working_directory)) fs - (@build.good_shell []) + (shell.async (@build.good_shell [])) resolution profile) [actual_runs _] (promise.future (atom.read @runs))] diff --git a/stdlib/source/test/aedifex/command/build.lux b/stdlib/source/test/aedifex/command/build.lux index 85231ae33..234343fea 100644 --- a/stdlib/source/test/aedifex/command/build.lux +++ b/stdlib/source/test/aedifex/command/build.lux @@ -45,9 +45,9 @@ (: (shell.Simulation []) (structure (def: (on_read state) - (#try.Failure "on_read")) + (exception.throw shell.no_more_output [])) (def: (on_error state) - (#try.Failure "on_error")) + (exception.throw shell.no_more_output [])) (def: (on_write input state) (#try.Failure "on_write")) (def: (on_destroy state) @@ -63,9 +63,9 @@ (: (shell.Simulation []) (structure (def: (on_read state) - (#try.Failure "on_read")) + (exception.throw shell.no_more_output [])) (def: (on_error state) - (#try.Failure "on_error")) + (exception.throw shell.no_more_output [])) (def: (on_write input state) (#try.Failure "on_write")) (def: (on_destroy state) @@ -98,7 +98,9 @@ Test (<| (_.covering /._) (do {! random.monad} - [#let [fs (file.mock (\ file.default separator)) + [last_read (random.ascii/alpha 5) + last_error (random.ascii/alpha 5) + #let [fs (file.mock (\ file.default separator)) shell (shell.async (..good_shell []))] program (random.ascii/alpha 5) target (random.ascii/alpha 5) diff --git a/stdlib/source/test/aedifex/command/test.lux b/stdlib/source/test/aedifex/command/test.lux index 9dd76ca08..36c21b520 100644 --- a/stdlib/source/test/aedifex/command/test.lux +++ b/stdlib/source/test/aedifex/command/test.lux @@ -5,6 +5,7 @@ [monad (#+ do)]] [control ["." try] + ["." exception] [concurrency ["." promise]] [parser @@ -14,7 +15,8 @@ [data ["." text ("#\." equivalence)] [collection - ["." dictionary]]] + ["." dictionary] + ["." list]]] [math ["." random]] [world @@ -84,15 +86,15 @@ (: (shell.Simulation []) (structure (def: (on_read state) - (#try.Failure "on_read")) + (exception.throw shell.no_more_output [])) (def: (on_error state) - (#try.Failure "on_error")) + (exception.throw shell.no_more_output [])) (def: (on_write input state) (#try.Failure "on_write")) (def: (on_destroy state) (#try.Failure "on_destroy")) (def: (on_await state) - (#try.Success [state (if (text.ends_with? " build" actual_command) + (#try.Success [state (if (list.any? (text\= "build") actual_arguments) shell.normal shell.error)])))))) [])] diff --git a/stdlib/source/test/aedifex/dependency/resolution.lux b/stdlib/source/test/aedifex/dependency/resolution.lux index e9cd26a82..ae8c7699b 100644 --- a/stdlib/source/test/aedifex/dependency/resolution.lux +++ b/stdlib/source/test/aedifex/dependency/resolution.lux @@ -13,33 +13,31 @@ [concurrency ["." promise]]] [data + [binary (#+ Binary)] ["." product] - ["." binary] ["." text + ["%" format (#+ format)] [encoding ["." utf8]]] [format ["." xml]] [collection ["." dictionary] - ["." set]]] + ["." set] + ["." list]]] [math ["." random (#+ Random)]]] ["$." /// #_ ["#." package] ["#." repository] - ["#." artifact] - [// - [lux - [data - ["$." binary]]]]] + ["#." artifact]] {#program ["." / ["//#" /// #_ ["#" profile] ["#." package (#+ Package)] ["#." hash] - ["#." dependency + ["#." dependency (#+ Dependency) ("#\." equivalence) ["#/." status]] ["#." pom] ["#." artifact (#+ Artifact) @@ -94,6 +92,136 @@ (def: (on_upload uri binary state) (#try.Failure "NOPE"))))) +(def: lux_sha1 + Text + (format ///artifact/extension.lux_library ///artifact/extension.sha-1)) + +(def: lux_md5 + Text + (format ///artifact/extension.lux_library ///artifact/extension.md5)) + +(def: pom_sha1 + Text + (format ///artifact/extension.pom ///artifact/extension.sha-1)) + +(def: pom_md5 + Text + (format ///artifact/extension.pom ///artifact/extension.md5)) + +(def: sha1 + (-> Binary Binary) + (|>> ///hash.sha-1 + (\ ///hash.sha-1_codec encode) + (\ utf8.codec encode))) + +(def: md5 + (-> Binary Binary) + (|>> ///hash.md5 + (\ ///hash.md5_codec encode) + (\ utf8.codec encode))) + +(def: (bad_sha-1 expected_artifact expected_package dummy_package) + (-> Artifact Package Package (Simulation Any)) + (structure + (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) + (#try.Success [state (|> expected_package + (get@ #///package.library) + product.left)]) + + (text.ends_with? lux_sha1 uri) + (#try.Success [state (|> expected_package + (get@ #///package.library) + product.left + sha1)]) + + (text.ends_with? lux_md5 uri) + (#try.Success [state (|> expected_package + (get@ #///package.library) + product.left + md5)]) + + (text.ends_with? ///artifact/extension.pom uri) + (#try.Success [state (|> expected_package + (get@ #///package.pom) + product.left + (\ xml.codec encode) + (\ utf8.codec encode))]) + + (text.ends_with? pom_sha1 uri) + (#try.Success [state (|> dummy_package + (get@ #///package.pom) + product.left + (\ xml.codec encode) + (\ utf8.codec encode) + sha1)]) + + (text.ends_with? pom_md5 uri) + (#try.Success [state (|> expected_package + (get@ #///package.pom) + product.left + (\ xml.codec encode) + (\ utf8.codec encode) + md5)]) + + ## else + (#try.Failure "NOPE")) + (#try.Failure "NOPE"))) + (def: (on_upload uri binary state) + (#try.Failure "NOPE")))) + +(def: (bad_md5 expected_artifact expected_package dummy_package) + (-> Artifact Package Package (Simulation Any)) + (structure + (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) + (#try.Success [state (|> expected_package + (get@ #///package.library) + product.left)]) + + (text.ends_with? lux_sha1 uri) + (#try.Success [state (|> expected_package + (get@ #///package.library) + product.left + sha1)]) + + (text.ends_with? lux_md5 uri) + (#try.Success [state (|> dummy_package + (get@ #///package.library) + product.left + md5)]) + + (text.ends_with? ///artifact/extension.pom uri) + (#try.Success [state (|> expected_package + (get@ #///package.pom) + product.left + (\ xml.codec encode) + (\ utf8.codec encode))]) + + (text.ends_with? pom_sha1 uri) + (#try.Success [state (|> expected_package + (get@ #///package.pom) + product.left + (\ xml.codec encode) + (\ utf8.codec encode) + sha1)]) + + (text.ends_with? pom_md5 uri) + (#try.Success [state (|> dummy_package + (get@ #///package.pom) + product.left + (\ xml.codec encode) + (\ utf8.codec encode) + md5)]) + + ## else + (#try.Failure "NOPE")) + (#try.Failure "NOPE"))) + (def: (on_upload uri binary state) + (#try.Failure "NOPE")))) + (def: one Test (do {! random.monad} @@ -105,72 +233,8 @@ not) $///package.random) #let [good (..single expected_artifact expected_package) - bad_sha-1 (: (Simulation Any) - (structure - (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) - (#try.Success [state (|> expected_package - (get@ #///package.library) - product.left)]) - - (text.ends_with? ///artifact/extension.pom uri) - (#try.Success [state (|> expected_package - (get@ #///package.pom) - product.left - (\ xml.codec encode) - (\ utf8.codec encode))]) - - ## (text\= extension ///artifact/extension.sha-1) - ## (#try.Success [state (|> dummy_package - ## (get@ #///package.sha-1) - ## (\ ///hash.sha-1_codec encode) - ## (\ utf8.codec encode))]) - - ## (text\= extension ///artifact/extension.md5) - ## (#try.Success [state (|> expected_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")))) - bad_md5 (: (Simulation Any) - (structure - (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) - (#try.Success [state (|> expected_package - (get@ #///package.library) - product.left)]) - - (text.ends_with? ///artifact/extension.pom uri) - (#try.Success [state (|> expected_package - (get@ #///package.pom) - product.left - (\ xml.codec encode) - (\ utf8.codec encode))]) - - ## (text\= extension ///artifact/extension.sha-1) - ## (#try.Success [state (|> expected_package - ## (get@ #///package.sha-1) - ## (\ ///hash.sha-1_codec encode) - ## (\ utf8.codec encode))]) - - ## (text\= extension ///artifact/extension.md5) - ## (#try.Success [state (|> dummy_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"))))]] + bad_sha-1 (..bad_sha-1 expected_artifact expected_package dummy_package) + bad_md5 (..bad_md5 expected_artifact expected_package dummy_package)]] (`` ($_ _.and (wrap (do promise.monad @@ -216,72 +280,8 @@ not) $///package.random) #let [good (..single expected_artifact expected_package) - bad_sha-1 (: (Simulation Any) - (structure - (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) - (#try.Success [state (|> expected_package - (get@ #///package.library) - product.left)]) - - (text.ends_with? ///artifact/extension.pom uri) - (#try.Success [state (|> expected_package - (get@ #///package.pom) - product.left - (\ xml.codec encode) - (\ utf8.codec encode))]) - - ## (text\= extension ///artifact/extension.sha-1) - ## (#try.Success [state (|> dummy_package - ## (get@ #///package.sha-1) - ## (\ ///hash.sha-1_codec encode) - ## (\ utf8.codec encode))]) - - ## (text\= extension ///artifact/extension.md5) - ## (#try.Success [state (|> expected_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")))) - bad_md5 (: (Simulation Any) - (structure - (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) - (#try.Success [state (|> expected_package - (get@ #///package.library) - product.left)]) - - (text.ends_with? ///artifact/extension.pom uri) - (#try.Success [state (|> expected_package - (get@ #///package.pom) - product.left - (\ xml.codec encode) - (\ utf8.codec encode))]) - - ## (text\= extension ///artifact/extension.sha-1) - ## (#try.Success [state (|> expected_package - ## (get@ #///package.sha-1) - ## (\ ///hash.sha-1_codec encode) - ## (\ utf8.codec encode))]) - - ## (text\= extension ///artifact/extension.md5) - ## (#try.Success [state (|> dummy_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"))))]] + bad_sha-1 (..bad_sha-1 expected_artifact expected_package dummy_package) + bad_md5 (..bad_md5 expected_artifact expected_package dummy_package)]] ($_ _.and (wrap (do promise.monad @@ -314,77 +314,106 @@ 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) - -## [_ 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} - -## 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))) - -## (#try.Failure error) -## false)))) -## ))) - -## (def: #export test -## Test -## (<| (_.covering /._) -## (_.for [/.Resolution]) -## ($_ _.and -## (_.for [/.equivalence] -## ($equivalence.spec /.equivalence ..random)) - -## (_.cover [/.empty] -## (dictionary.empty? /.empty)) - -## ..one -## ..any -## ..all -## ))) +(def: artifacts + (Random [Artifact Artifact Artifact]) + (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)] + (wrap [dependee_artifact depender_artifact ignored_artifact]))) + +(def: (packages [dependee_artifact depender_artifact ignored_artifact]) + (-> [Artifact Artifact Artifact] + (Random [[Dependency Dependency Dependency] + [Package Package Package]])) + (do random.monad + [[_ 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} + + 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 + (|> dependee_pom (\ xml.codec encode) (\ utf8.codec encode)) + #///dependency/status.Unverified] + dependee_package) + depender_package (set@ #///package.pom + [depender_pom + (|> depender_pom (\ xml.codec encode) (\ utf8.codec encode)) + #///dependency/status.Unverified] + depender_package) + ignored_package (set@ #///package.pom + [ignored_pom + (|> ignored_pom (\ xml.codec encode) (\ utf8.codec encode)) + #///dependency/status.Unverified] + ignored_package)]] + (wrap [[dependee depender ignored] + [dependee_package depender_package ignored_package]]))) + +(def: all + Test + (do {! random.monad} + [[dependee_artifact depender_artifact ignored_artifact] ..artifacts + + [[dependee depender ignored] + [dependee_package depender_package ignored_package]] + (..packages [dependee_artifact depender_artifact ignored_artifact])] + ($_ _.and + (wrap + (do promise.monad + [[successes failures 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] + (and (dictionary.key? resolution depender) + (list.any? (///dependency\= depender) successes) + + (dictionary.key? resolution dependee) + (list.any? (///dependency\= dependee) successes) + + (list.empty? failures) + (not (dictionary.key? resolution ignored)))))) + ))) + +(def: #export test + Test + (<| (_.covering /._) + (_.for [/.Resolution]) + ($_ _.and + (_.for [/.equivalence] + ($equivalence.spec /.equivalence ..random)) + + (_.cover [/.empty] + (dictionary.empty? /.empty)) + + ..one + ..any + ..all + ))) diff --git a/stdlib/source/test/aedifex/input.lux b/stdlib/source/test/aedifex/input.lux index e2751381a..86771cf1f 100644 --- a/stdlib/source/test/aedifex/input.lux +++ b/stdlib/source/test/aedifex/input.lux @@ -13,7 +13,8 @@ ["." binary] ["." text ["%" format (#+ format)] - ["." encoding]] + [encoding + ["." utf8]]] [collection ["." set (#+ Set)]]] [math @@ -28,7 +29,9 @@ ["#" profile (#+ Profile)] ["#." project] ["#." action] - ["#." format]]]}) + ["#." format] + [repository + [remote (#+ Address)]]]]}) (def: (with_default_source sources) (-> (Set //.Source) (Set //.Source)) @@ -36,6 +39,10 @@ (set.add //.default_source sources) sources)) +(def: with_default_repository + (-> (Set Address) (Set Address)) + (set.add //.default_repository)) + (def: #export test Test (<| (_.covering /._) @@ -50,12 +57,14 @@ _ (|> expected //format.profile %.code - (\ encoding.utf8 encode) + (\ utf8.codec encode) (!.use (\ file over_write))) actual (: (Promise (Try Profile)) (/.read promise.monad fs //.default))] (wrap (\ //.equivalence = - (update@ #//.sources ..with_default_source expected) + (|> expected + (update@ #//.sources ..with_default_source) + (update@ #//.repositories ..with_default_repository)) actual)))] (_.cover' [/.read] (try.default false verdict))))))) |