From a4b64bf1cdf47160b6b615d2c6493039abfd7a94 Mon Sep 17 00:00:00 2001 From: Eduardo Julian Date: Thu, 28 Jul 2022 17:39:01 -0400 Subject: Extracted unit-testing machinery into its own module. --- stdlib/source/test/aedifex/cache.lux | 9 ++++--- stdlib/source/test/aedifex/cli.lux | 4 +-- stdlib/source/test/aedifex/command/auto.lux | 7 ++--- stdlib/source/test/aedifex/command/build.lux | 31 +++++++++++----------- stdlib/source/test/aedifex/command/clean.lux | 7 ++--- stdlib/source/test/aedifex/command/deploy.lux | 7 ++--- stdlib/source/test/aedifex/command/deps.lux | 7 ++--- stdlib/source/test/aedifex/command/install.lux | 9 ++++--- stdlib/source/test/aedifex/command/pom.lux | 9 ++++--- stdlib/source/test/aedifex/command/test.lux | 11 ++++---- stdlib/source/test/aedifex/command/version.lux | 7 ++--- .../source/test/aedifex/dependency/deployment.lux | 9 ++++--- .../source/test/aedifex/dependency/resolution.lux | 15 ++++++----- stdlib/source/test/aedifex/input.lux | 7 ++--- stdlib/source/test/aedifex/metadata/artifact.lux | 7 ++--- stdlib/source/test/aedifex/metadata/snapshot.lux | 7 ++--- stdlib/source/test/aedifex/repository/local.lux | 7 ++--- 17 files changed, 88 insertions(+), 72 deletions(-) (limited to 'stdlib/source/test/aedifex') diff --git a/stdlib/source/test/aedifex/cache.lux b/stdlib/source/test/aedifex/cache.lux index 515ca42b7..9dbb8405b 100644 --- a/stdlib/source/test/aedifex/cache.lux +++ b/stdlib/source/test/aedifex/cache.lux @@ -1,7 +1,6 @@ (.require [library [lux (.except Type) - ["_" test (.only Test)] [abstract ["[0]" monad (.only do)]] [control @@ -25,7 +24,9 @@ ["n" nat]]] [world ["[0]" file] - ["[0]" program]]]] + ["[0]" program]] + ["_" test (.only Test) + ["[0]" unit]]]] [// ["@[0]" profile] ["@[0]" artifact] @@ -111,7 +112,7 @@ (in (do async.monad [wrote! (/.write_one program fs dependency expected_package) read! (/.read_one program fs dependency)] - (_.coverage' [/.write_one /.read_one] + (unit.coverage [/.write_one /.read_one] (<| (try.else false) (do try.monad [_ wrote! @@ -132,7 +133,7 @@ (in (do async.monad [wrote! (/.write_all program fs expected) read! (/.read_all program fs (dictionary.keys expected) //dependency/resolution.empty)] - (_.coverage' [/.write_all /.read_all] + (unit.coverage [/.write_all /.read_all] (<| (try.else false) (do try.monad [_ wrote! diff --git a/stdlib/source/test/aedifex/cli.lux b/stdlib/source/test/aedifex/cli.lux index d0aef0468..b83d643b8 100644 --- a/stdlib/source/test/aedifex/cli.lux +++ b/stdlib/source/test/aedifex/cli.lux @@ -72,7 +72,7 @@ Test (do random.monad [expected ..command] - (_.property "Without profile." + (_.test "Without profile." (|> expected ..format (cli.result /.command) @@ -89,7 +89,7 @@ (do random.monad [expected_profile (random.alphabetic 1) expected_command ..command] - (_.property "With profile." + (_.test "With profile." (|> expected_command ..format (list.partial "with" expected_profile) diff --git a/stdlib/source/test/aedifex/command/auto.lux b/stdlib/source/test/aedifex/command/auto.lux index 8cc8177a1..10c249e3e 100644 --- a/stdlib/source/test/aedifex/command/auto.lux +++ b/stdlib/source/test/aedifex/command/auto.lux @@ -1,7 +1,6 @@ (.require [library [lux (.except) - ["_" test (.only Test)] [abstract [monad (.only do)]] [control @@ -31,7 +30,9 @@ ["[0]" file ["[0]" watch]] [time - ["[0]" instant]]]]] + ["[0]" instant]]] + ["_" test (.only Test) + ["[0]" unit]]]] ["[0]" // ["$[0]" version] ["$[0]" build]] @@ -120,6 +121,6 @@ (at ! each (n.= expected_runs)))] (in {try.#Success (and correct_number_of_runs! no_dangling_process!)})))] - (_.coverage' [/.do!] + (unit.coverage [/.do!] (try.else false verdict)))) )))) diff --git a/stdlib/source/test/aedifex/command/build.lux b/stdlib/source/test/aedifex/command/build.lux index 7ae2a8c72..81907a9ad 100644 --- a/stdlib/source/test/aedifex/command/build.lux +++ b/stdlib/source/test/aedifex/command/build.lux @@ -1,7 +1,6 @@ (.require [library [lux (.except) - ["_" test (.only Test)] [abstract [monad (.only do)]] [control @@ -22,7 +21,9 @@ [world ["[0]" file] ["[0]" shell (.only Shell)] - ["[0]" program]]]] + ["[0]" program]] + ["_" test (.only Test) + ["[0]" unit]]]] ["[0]" // ["@[0]" version] ["$/[1]" // @@ -162,7 +163,7 @@ (in (do async.monad [outcome (/.do! (@version.echo "") (program.async (program.mock environment.empty home working_directory)) fs shell ///dependency/resolution.empty (with_target empty_profile))] - (_.coverage' [/.no_specified_program] + (unit.coverage [/.no_specified_program] (case outcome {try.#Success _} false @@ -171,7 +172,7 @@ (exception.match? /.no_specified_program error))))) (in (do async.monad [outcome (/.do! (@version.echo "") (program.async (program.mock environment.empty home working_directory)) fs shell ///dependency/resolution.empty profile)] - (_.coverage' [/.Lux /.no_available_lux] + (unit.coverage [/.Lux /.no_available_lux] (case outcome {try.#Success _} false @@ -190,15 +191,15 @@ end (at console read_line [])] (in (and (text#= /.start start) (text#= /.success end))))] - (_.coverage' [/.do! - /.lux_group - /.jvm_lux_name - /.js_lux_name - /.python_lux_name - /.lua_lux_name - /.ruby_lux_name - /.start - /.success] + (unit.coverage [/.do! + /.lux_group + /.jvm_lux_name + /.js_lux_name + /.python_lux_name + /.lua_lux_name + /.ruby_lux_name + /.start + /.success] (try.else false verdict))))) (do ! [.let [console (@version.echo "")] @@ -212,7 +213,7 @@ end (at console read_line [])] (in (and (text#= /.start start) (text#= /.failure end))))] - (_.coverage' [/.failure] + (unit.coverage [/.failure] (try.else false verdict))))) (do ! [expected/0 (random.alphabetic 5) @@ -243,7 +244,7 @@ (text#= expected/1 actual/1) (text#= expected/2 actual/2) end!)))] - (_.coverage' [] + (unit.coverage [] (try.else false verdict)))))] [#0 /.log_output!] diff --git a/stdlib/source/test/aedifex/command/clean.lux b/stdlib/source/test/aedifex/command/clean.lux index f4e220aa1..bbc47ccfe 100644 --- a/stdlib/source/test/aedifex/command/clean.lux +++ b/stdlib/source/test/aedifex/command/clean.lux @@ -1,7 +1,6 @@ (.require [library [lux (.except) - ["_" test (.only Test)] [abstract ["[0]" monad (.only do)]] [control @@ -21,7 +20,9 @@ [number ["n" nat]]] [world - ["[0]" file (.only Path)]]]] + ["[0]" file (.only Path)]] + ["_" test (.only Test) + ["[0]" unit]]]] [// ["@[0]" version] [// @@ -115,5 +116,5 @@ (and sub_exists!/pre (not sub_exists!/post)) (text#= (/.success target_path) logging))))] - (_.coverage' [/.do! /.success] + (unit.coverage [/.do! /.success] (try.else false verdict))))))) diff --git a/stdlib/source/test/aedifex/command/deploy.lux b/stdlib/source/test/aedifex/command/deploy.lux index 6a146cc44..dfa352553 100644 --- a/stdlib/source/test/aedifex/command/deploy.lux +++ b/stdlib/source/test/aedifex/command/deploy.lux @@ -1,7 +1,6 @@ (.require [library [lux (.except) - ["_" test (.only Test)] [abstract [monad (.only do)]] [control @@ -32,7 +31,9 @@ [world ["[0]" file] ["[0]" program (.only Program)] - ["[0]" shell]]]] + ["[0]" shell]] + ["_" test (.only Test) + ["[0]" unit]]]] [// ["$[0]" build] ["$[0]" install] @@ -130,5 +131,5 @@ deployed_pom! deployed_sha-1! deployed_md5!)))] - (_.coverage' [/.do! /.success] + (unit.coverage [/.do! /.success] (try.else false verdict))))))) diff --git a/stdlib/source/test/aedifex/command/deps.lux b/stdlib/source/test/aedifex/command/deps.lux index 4d08505b0..905afb575 100644 --- a/stdlib/source/test/aedifex/command/deps.lux +++ b/stdlib/source/test/aedifex/command/deps.lux @@ -1,7 +1,6 @@ (.require [library [lux (.except) - ["_" test (.only Test)] [abstract [monad (.only do)] ["[0]" predicate]] @@ -25,7 +24,9 @@ ["[0]" random (.only Random)]] [world ["[0]" program] - ["[0]" file]]]] + ["[0]" file]] + ["_" test (.only Test) + ["[0]" unit]]]] ["[0]" // ["@[0]" version] ["$/[1]" // @@ -126,5 +127,5 @@ had_dependee_after! had_depender_after!)))] - (_.coverage' [/.do!] + (unit.coverage [/.do!] (try.else false verdict))))))) diff --git a/stdlib/source/test/aedifex/command/install.lux b/stdlib/source/test/aedifex/command/install.lux index 3221f640a..930cc17f4 100644 --- a/stdlib/source/test/aedifex/command/install.lux +++ b/stdlib/source/test/aedifex/command/install.lux @@ -1,7 +1,6 @@ (.require [library [lux (.except) - ["_" test (.only Test)] [abstract ["[0]" monad (.only do)]] [control @@ -21,7 +20,9 @@ ["[0]" random]] [world ["[0]" file] - ["[0]" program (.only Program)]]]] + ["[0]" program (.only Program)]] + ["_" test (.only Test) + ["[0]" unit]]]] [// ["$[0]" version] [// @@ -91,13 +92,13 @@ (in (and succeeded! library_exists! pom_exists!)))] - (_.coverage' [/.do! /.success] + (unit.coverage [/.do! /.success] (try.else false verdict)))) (in (do [! async.monad] [.let [fs (file.mock /) program (program.async (program.mock environment.empty home working_directory))] logging (..execute! program fs (has ///.#identity {.#None} sample))] - (_.coverage' [/.failure] + (unit.coverage [/.failure] (|> logging (try#each (text#= /.failure)) (try.else false))))) diff --git a/stdlib/source/test/aedifex/command/pom.lux b/stdlib/source/test/aedifex/command/pom.lux index 9390cb51b..21deefa0f 100644 --- a/stdlib/source/test/aedifex/command/pom.lux +++ b/stdlib/source/test/aedifex/command/pom.lux @@ -1,7 +1,6 @@ (.require [library [lux (.except) - ["_" test (.only Test)] [abstract [monad (.only do)]] [control @@ -18,7 +17,9 @@ [math ["[0]" random]] [world - ["[0]" file]]]] + ["[0]" file]] + ["_" test (.only Test) + ["[0]" unit]]]] [// ["@[0]" version] [// @@ -57,11 +58,11 @@ (binary#= expected actual)]] (in (and logging! expected_content!)))] - (_.coverage' [/.do! /.success] + (unit.coverage [/.do! /.success] (try.else false verdict))) {try.#Failure error} - (_.coverage' [/.do!] + (unit.coverage [/.do!] (case (the ///.#identity sample) {.#Some _} false diff --git a/stdlib/source/test/aedifex/command/test.lux b/stdlib/source/test/aedifex/command/test.lux index d65fbd491..440123f65 100644 --- a/stdlib/source/test/aedifex/command/test.lux +++ b/stdlib/source/test/aedifex/command/test.lux @@ -1,7 +1,6 @@ (.require [library [lux (.except) - ["_" test (.only Test)] [abstract [monad (.only do)]] [control @@ -21,7 +20,9 @@ [world ["[0]" file] ["[0]" shell] - ["[0]" program]]]] + ["[0]" program]] + ["_" test (.only Test) + ["[0]" unit]]]] ["[0]" // ["@[0]" version] ["@[0]" build] @@ -74,8 +75,8 @@ (text#= //build.success build_end)) (and (text#= /.start test_start) (text#= /.success test_end)))))] - (_.coverage' [/.do! - /.start /.success] + (unit.coverage [/.do! + /.start /.success] (try.else false verdict))))) (let [fs (file.mock (at file.default separator)) console (@version.echo "")] @@ -110,6 +111,6 @@ (text#= //build.success build_end)) (and (text#= /.start test_start) (text#= /.failure test_end)))))] - (_.coverage' [/.failure] + (unit.coverage [/.failure] (try.else false verdict))))) )))) diff --git a/stdlib/source/test/aedifex/command/version.lux b/stdlib/source/test/aedifex/command/version.lux index fa22f379b..1becba8d2 100644 --- a/stdlib/source/test/aedifex/command/version.lux +++ b/stdlib/source/test/aedifex/command/version.lux @@ -1,7 +1,6 @@ (.require [library [lux (.except) - ["_" test (.only Test)] [abstract [monad (.only do)]] [control @@ -20,7 +19,9 @@ [compiler ["[0]" version]]] [world - ["[0]" console (.only Console Mock)]]]] + ["[0]" console (.only Console Mock)]] + ["_" test (.only Test) + ["[0]" unit]]]] [/// ["@[0]" profile]] [\\program @@ -73,5 +74,5 @@ logging (at console read_line [])] (in (text#= (version.format lux_version.latest) logging)))] - (_.coverage' [/.do!] + (unit.coverage [/.do!] (try.else false verdict))))))) diff --git a/stdlib/source/test/aedifex/dependency/deployment.lux b/stdlib/source/test/aedifex/dependency/deployment.lux index fee8caf9d..2eeb0abb8 100644 --- a/stdlib/source/test/aedifex/dependency/deployment.lux +++ b/stdlib/source/test/aedifex/dependency/deployment.lux @@ -1,7 +1,6 @@ (.require [library [lux (.except) - ["_" test (.only Test)] [abstract [monad (.only do)] ["[0]" hash (.only Hash)]] @@ -31,7 +30,9 @@ ["[0]" http ["[1]" client] ["[1]/[0]" status] - ["@[1]" /]]]]]] + ["@[1]" /]]]] + ["_" test (.only Test) + ["[0]" unit]]]] ["$[0]" // (.only) ["[1]/" // ["[1][0]" package]]] @@ -159,7 +160,7 @@ (in (do async.monad [?outcome (/.one repository dependency package) cache (async.future (atom.read! cache))] - (_.coverage' [/.one] + (unit.coverage [/.one] (|> ?outcome (try#each (verify_one 1 address package cache expected_artifact)) (try.else false)))))) @@ -182,7 +183,7 @@ (in (do async.monad [?outcome (/.all repository resolution) cache (async.future (atom.read! cache))] - (_.coverage' [/.all] + (unit.coverage [/.all] (|> ?outcome (try#each (function (_ actual_artifacts) (let [expected_deployments! diff --git a/stdlib/source/test/aedifex/dependency/resolution.lux b/stdlib/source/test/aedifex/dependency/resolution.lux index e724392a5..153d4b4ac 100644 --- a/stdlib/source/test/aedifex/dependency/resolution.lux +++ b/stdlib/source/test/aedifex/dependency/resolution.lux @@ -1,7 +1,6 @@ (.require [library [lux (.except all) - ["_" test (.only Test)] [abstract [monad (.only do)] ["[0]" predicate] @@ -26,7 +25,9 @@ ["[0]" set] ["[0]" list]]] [math - ["[0]" random (.only Random)]]]] + ["[0]" random (.only Random)]] + ["_" test (.only Test) + ["[0]" unit]]]] ["$[0]" /// ["[1][0]" package] ["[1][0]" repository] @@ -262,7 +263,7 @@ [actual_package (/.one (///repository.mock good []) [///dependency.#artifact expected_artifact ///dependency.#type ///artifact/type.lux_library])] - (_.coverage' [/.one] + (unit.coverage [/.one] (case actual_package {try.#Success actual_package} (at ///package.equivalence = @@ -276,7 +277,7 @@ [actual_package (/.one (///repository.mock []) [///dependency.#artifact expected_artifact ///dependency.#type ///artifact/type.lux_library])] - (_.coverage' [] + (unit.coverage [] (case actual_package {try.#Failure error} (exception.match? error) @@ -311,7 +312,7 @@ (///repository.mock good [])) [///dependency.#artifact expected_artifact ///dependency.#type ///artifact/type.lux_library])] - (_.coverage' [/.any] + (unit.coverage [/.any] (case actual_package {try.#Success actual_package} (at ///package.equivalence = @@ -327,7 +328,7 @@ (///repository.mock bad_md5 [])) [///dependency.#artifact expected_artifact ///dependency.#type ///artifact/type.lux_library])] - (_.coverage' [/.cannot_resolve] + (unit.coverage [/.cannot_resolve] (case actual_package {try.#Failure error} (exception.match? /.cannot_resolve error) @@ -416,7 +417,7 @@ (///repository.mock ..nope [])) (list depender) /.empty)] - (_.coverage' [/.all] + (unit.coverage [/.all] (and (dictionary.key? resolution depender) (list.any? (///dependency#= depender) successes) diff --git a/stdlib/source/test/aedifex/input.lux b/stdlib/source/test/aedifex/input.lux index 23192f590..b9f8195f6 100644 --- a/stdlib/source/test/aedifex/input.lux +++ b/stdlib/source/test/aedifex/input.lux @@ -1,7 +1,6 @@ (.require [library [lux (.except) - ["_" test (.only Test)] [abstract [monad (.only do)]] [control @@ -18,7 +17,9 @@ [math ["[0]" random]] [world - ["[0]" file]]]] + ["[0]" file]] + ["_" test (.only Test) + ["[0]" unit]]]] [// ["$[0]" profile]] [\\program @@ -63,5 +64,5 @@ (revised //.#sources ..with_default_source) (revised //.#repositories ..with_default_repository)) actual)))] - (_.coverage' [/.read] + (unit.coverage [/.read] (try.else false verdict))))))) diff --git a/stdlib/source/test/aedifex/metadata/artifact.lux b/stdlib/source/test/aedifex/metadata/artifact.lux index ed5b95b3b..1e05fbc3a 100644 --- a/stdlib/source/test/aedifex/metadata/artifact.lux +++ b/stdlib/source/test/aedifex/metadata/artifact.lux @@ -1,7 +1,6 @@ (.require [library [lux (.except) - ["_" test (.only Test)] [abstract [monad (.only do)] [\\specification @@ -34,7 +33,9 @@ ["[0]" year] ["[0]" month] ["[0]" instant] - ["[0]" duration]]]]] + ["[0]" duration]]] + ["_" test (.only Test) + ["[0]" unit]]]] [\\program ["[0]" / (.only) ["/[1]" // (.only) @@ -105,7 +106,7 @@ (in (do async.monad [wrote? (/.write repository artifact expected) actual (/.read repository artifact)] - (_.coverage' [/.write /.read] + (unit.coverage [/.write /.read] (and (case wrote? {try.#Success _} true {try.#Failure _} false) diff --git a/stdlib/source/test/aedifex/metadata/snapshot.lux b/stdlib/source/test/aedifex/metadata/snapshot.lux index 773dd262b..983b78d6d 100644 --- a/stdlib/source/test/aedifex/metadata/snapshot.lux +++ b/stdlib/source/test/aedifex/metadata/snapshot.lux @@ -1,7 +1,6 @@ (.require [library [lux (.except) - ["_" test (.only Test)] [abstract [monad (.only do)] [\\specification @@ -34,7 +33,9 @@ ["[0]" year] ["[0]" month] ["[0]" instant (.only Instant)] - ["[0]" duration]]]]] + ["[0]" duration]]] + ["_" test (.only Test) + ["[0]" unit]]]] ["$[0]" /// ["[1][0]" artifact ["[1]/[0]" type] @@ -117,7 +118,7 @@ (in (do async.monad [wrote? (/.write repository artifact expected) actual (/.read repository artifact)] - (_.coverage' [/.write /.read] + (unit.coverage [/.write /.read] (and (case wrote? {try.#Success _} true {try.#Failure _} false) diff --git a/stdlib/source/test/aedifex/repository/local.lux b/stdlib/source/test/aedifex/repository/local.lux index 8eadfd24c..811a8e4e9 100644 --- a/stdlib/source/test/aedifex/repository/local.lux +++ b/stdlib/source/test/aedifex/repository/local.lux @@ -1,7 +1,6 @@ (.require [library [lux (.except) - ["_" test (.only Test)] [abstract [monad (.only do)]] [control @@ -19,7 +18,9 @@ ["[0]" random]] [world ["[0]" file] - ["[0]" program]]]] + ["[0]" program]] + ["_" test (.only Test) + ["[0]" unit]]]] [\\program ["[0]" /]]) @@ -42,7 +43,7 @@ [before_upload (at repo download uri) _ (at repo upload uri expected) actual (at repo download uri)] - (_.coverage' [/.repository] + (unit.coverage [/.repository] (and (case before_upload {try.#Success _} false {try.#Failure _} true) -- cgit v1.2.3