diff options
author | Eduardo Julian | 2020-12-10 22:29:32 -0400 |
---|---|---|
committer | Eduardo Julian | 2020-12-10 22:29:32 -0400 |
commit | 9af671a34728b35c48bff2ba163c371dc5084946 (patch) | |
tree | ec35f32b8f0cabec702708e0e3cc4462b587c752 /stdlib/source/test | |
parent | d747aada2d6df6538d0a88d70169f3757aef50af (diff) |
Render XML to text in an indented form for human readability.
Diffstat (limited to '')
19 files changed, 209 insertions, 96 deletions
diff --git a/stdlib/source/test/aedifex/cache.lux b/stdlib/source/test/aedifex/cache.lux index 7923eb8c5..0bb0aea68 100644 --- a/stdlib/source/test/aedifex/cache.lux +++ b/stdlib/source/test/aedifex/cache.lux @@ -6,7 +6,9 @@ [control ["." try] [concurrency - ["." promise (#+ Promise)]]] + ["." promise (#+ Promise)]] + [parser + ["." environment]]] [data [binary (#+ Binary)] ["." text] @@ -20,7 +22,8 @@ [math ["." random (#+ Random) ("#\." monad)]] [world - ["." file]]] + ["." file] + ["." program]]] [// ["@." profile] ["@." artifact] @@ -96,11 +99,14 @@ Test (do {! random.monad} [[dependency expected-package] ..package + home (random.ascii/alpha 5) + working-directory (random.ascii/alpha 5) #let [fs (: (file.System Promise) - (file.mock (\ file.default separator)))]] + (file.mock (\ file.default separator))) + program (program.async (program.mock environment.empty home working-directory))]] (wrap (do promise.monad - [wrote! (/.write-one fs dependency expected-package) - read! (/.read-one fs dependency)] + [wrote! (/.write-one program fs dependency expected-package) + read! (/.read-one program fs dependency)] (_.cover' [/.write-one /.read-one] (<| (try.default false) (do try.monad @@ -114,11 +120,14 @@ Test (do {! random.monad} [expected ..resolution + home (random.ascii/alpha 5) + working-directory (random.ascii/alpha 5) #let [fs (: (file.System Promise) - (file.mock (\ file.default separator)))]] + (file.mock (\ file.default separator))) + program (program.async (program.mock environment.empty home working-directory))]] (wrap (do promise.monad - [wrote! (/.write-all fs expected) - read! (/.read-all fs (dictionary.keys expected) //dependency/resolution.empty)] + [wrote! (/.write-all program fs expected) + read! (/.read-all program fs (dictionary.keys expected) //dependency/resolution.empty)] (_.cover' [/.write-all /.read-all] (<| (try.default false) (do try.monad diff --git a/stdlib/source/test/aedifex/command/auto.lux b/stdlib/source/test/aedifex/command/auto.lux index 48b2a7eb3..c43d8642f 100644 --- a/stdlib/source/test/aedifex/command/auto.lux +++ b/stdlib/source/test/aedifex/command/auto.lux @@ -80,6 +80,7 @@ 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) @@ -107,7 +108,7 @@ (do promise.monad [outcome ((/.do! watcher command) (@version.echo "") - (program.async (program.mock environment.empty working-directory)) + (program.async (program.mock environment.empty home working-directory)) fs (@build.good-shell []) resolution diff --git a/stdlib/source/test/aedifex/command/build.lux b/stdlib/source/test/aedifex/command/build.lux index 74508ef3d..025d01c0b 100644 --- a/stdlib/source/test/aedifex/command/build.lux +++ b/stdlib/source/test/aedifex/command/build.lux @@ -101,6 +101,7 @@ shell (..good-shell [])] program (random.ascii/alpha 5) target (random.ascii/alpha 5) + home (random.ascii/alpha 5) working-directory (random.ascii/alpha 5) #let [empty-profile (: Profile (\ ///.monoid identity)) @@ -114,7 +115,7 @@ with-target)]] ($_ _.and (wrap (do promise.monad - [outcome (/.do! (@version.echo "") (program.async (program.mock environment.empty working-directory)) fs shell ///dependency/resolution.empty + [outcome (/.do! (@version.echo "") (program.async (program.mock environment.empty home working-directory)) fs shell ///dependency/resolution.empty (with-target empty-profile))] (_.cover' [/.no-specified-program] (case outcome @@ -124,7 +125,7 @@ (#try.Failure error) (exception.match? /.no-specified-program error))))) (wrap (do promise.monad - [outcome (/.do! (@version.echo "") (program.async (program.mock environment.empty working-directory)) fs shell ///dependency/resolution.empty + [outcome (/.do! (@version.echo "") (program.async (program.mock environment.empty home working-directory)) fs shell ///dependency/resolution.empty (with-program empty-profile))] (_.cover' [/.no-specified-target] (case outcome @@ -134,7 +135,7 @@ (#try.Failure error) (exception.match? /.no-specified-target error))))) (wrap (do promise.monad - [outcome (/.do! (@version.echo "") (program.async (program.mock environment.empty working-directory)) fs shell ///dependency/resolution.empty profile)] + [outcome (/.do! (@version.echo "") (program.async (program.mock environment.empty home working-directory)) fs shell ///dependency/resolution.empty profile)] (_.cover' [/.Compiler /.no-available-compiler] (case outcome (#try.Success _) @@ -147,7 +148,7 @@ resolution ..resolution] (wrap (do promise.monad [verdict (do ///action.monad - [_ (/.do! console (program.async (program.mock environment.empty working-directory)) fs shell resolution profile) + [_ (/.do! console (program.async (program.mock environment.empty home working-directory)) fs shell resolution profile) start (!.use (\ console read-line) []) end (!.use (\ console read-line) [])] (wrap (and (text\= /.start start) @@ -161,7 +162,7 @@ resolution ..resolution] (wrap (do promise.monad [verdict (do ///action.monad - [_ (/.do! console (program.async (program.mock environment.empty working-directory)) fs (..bad-shell []) resolution profile) + [_ (/.do! console (program.async (program.mock environment.empty home working-directory)) fs (..bad-shell []) resolution profile) start (!.use (\ console read-line) []) end (!.use (\ console read-line) [])] (wrap (and (text\= /.start start) diff --git a/stdlib/source/test/aedifex/command/deploy.lux b/stdlib/source/test/aedifex/command/deploy.lux index 773069322..eafd1f968 100644 --- a/stdlib/source/test/aedifex/command/deploy.lux +++ b/stdlib/source/test/aedifex/command/deploy.lux @@ -9,7 +9,9 @@ [concurrency ["." promise (#+ Promise)]] [security - ["!" capability]]] + ["!" capability]] + [parser + ["." environment (#+ Environment)]]] [data ["." maybe] ["." binary] @@ -26,7 +28,8 @@ [math ["." random (#+ Random)]] [world - ["." file (#+ Path File)]]] + ["." file (#+ Path File)] + ["." program (#+ Program)]]] [program [compositor ["." export]]] @@ -66,17 +69,19 @@ (file.get-file promise.monad fs (format head (\ fs separator) head ".lux")))] (recur tail))))) -(def: (execute! repository fs identity artifact profile) - (-> (Repository Promise) (file.System Promise) +(def: (execute! program repository fs identity artifact profile) + (-> (Program Promise) (Repository Promise) (file.System Promise) Identity Artifact ///.Profile (Promise (Try Text))) - (do ///action.monad - [#let [console (@version.echo "")] - _ (..make-sources! fs (get@ #///.sources profile)) - _ (: (Promise (Try Path)) - (file.make-directories promise.monad fs (///local.repository fs))) - _ (/.do! console repository fs identity artifact profile)] - (!.use (\ console read-line) []))) + (do promise.monad + [home (\ program home [])] + (do ///action.monad + [#let [console (@version.echo "")] + _ (..make-sources! fs (get@ #///.sources profile)) + _ (: (Promise (Try Path)) + (file.make-directories promise.monad fs (///local.repository fs home))) + _ (/.do! console repository fs identity artifact profile)] + (!.use (\ console read-line) [])))) (def: #export test Test @@ -91,12 +96,15 @@ @profile.random) identity @repository.identity + home (random.ascii/alpha 5) + working-directory (random.ascii/alpha 5) #let [repository (///repository.mock (@repository.simulation identity) @repository.empty) - fs (file.mock (\ file.default separator))]] + fs (file.mock (\ file.default separator)) + program (program.async (program.mock environment.empty home working-directory))]] (wrap (do {! promise.monad} [verdict (do {! ///action.monad} - [logging (..execute! repository fs identity artifact profile) + [logging (..execute! program repository fs identity artifact profile) expected-library (|> profile (get@ #///.sources) set.to-list diff --git a/stdlib/source/test/aedifex/command/deps.lux b/stdlib/source/test/aedifex/command/deps.lux index 5b9dd87da..292185a28 100644 --- a/stdlib/source/test/aedifex/command/deps.lux +++ b/stdlib/source/test/aedifex/command/deps.lux @@ -9,7 +9,9 @@ [concurrency ["." promise]] [security - ["!" capability]]] + ["!" capability]] + [parser + ["." environment]]] [data ["." text ("#\." equivalence) ["%" format (#+ format)]] @@ -19,6 +21,7 @@ [math ["." random (#+ Random)]] [world + ["." program] ["." file]]] ["." // #_ ["@." version] @@ -47,7 +50,10 @@ Test (<| (_.covering /._) (do random.monad - [dependee-artifact $///artifact.random + [home (random.ascii/alpha 5) + working-directory (random.ascii/alpha 5) + + dependee-artifact $///artifact.random depender-artifact (random.filter (predicate.complement (\ ///artifact.equivalence = dependee-artifact)) $///artifact.random) @@ -77,16 +83,17 @@ (set@ #///package.origin #///package.Remote) (set@ #///package.pom depender-pom)) - fs (file.mock (\ file.default separator))]] + fs (file.mock (\ file.default separator)) + program (program.async (program.mock environment.empty home working-directory))]] (wrap (do promise.monad [verdict (do ///action.monad [#let [console (@version.echo "")] pre (|> ///dependency/resolution.empty (dictionary.put dependee dependee-package) - (///cache.write-all fs)) + (///cache.write-all program fs)) post (|> (\ ///.monoid identity) (set@ #///.dependencies (set.from-list ///dependency.hash (list dependee depender))) - (/.do! console fs (list (///repository.mock ($///dependency/resolution.single depender-artifact depender-package) [])))) + (/.do! program console fs (list (///repository.mock ($///dependency/resolution.single depender-artifact depender-package) [])))) logging! (\ ///action.monad map (text\= //clean.success) (!.use (\ console read-line) []))] diff --git a/stdlib/source/test/aedifex/command/install.lux b/stdlib/source/test/aedifex/command/install.lux index 2dbddeaa3..9ffa65bab 100644 --- a/stdlib/source/test/aedifex/command/install.lux +++ b/stdlib/source/test/aedifex/command/install.lux @@ -9,7 +9,9 @@ [concurrency ["." promise (#+ Promise)]] [security - ["!" capability]]] + ["!" capability]] + [parser + ["." environment (#+ Environment)]]] [data ["." maybe] ["." binary] @@ -23,7 +25,8 @@ [math ["." random (#+ Random)]] [world - ["." file (#+ Path File)]]] + ["." file (#+ Path File)] + ["." program (#+ Program)]]] [// ["@." version] [// @@ -58,15 +61,17 @@ (file.get-file promise.monad fs (format head (\ fs separator) head ".lux")))] (recur tail))))) -(def: (execute! fs sample) - (-> (file.System Promise) ///.Profile (Promise (Try Text))) - (do ///action.monad - [#let [console (@version.echo "")] - _ (..make-sources! fs (get@ #///.sources sample)) - _ (: (Promise (Try Path)) - (file.make-directories promise.monad fs (///local.repository fs))) - _ (/.do! console fs sample)] - (!.use (\ console read-line) []))) +(def: (execute! program fs sample) + (-> (Program Promise) (file.System Promise) ///.Profile (Promise (Try Text))) + (do promise.monad + [home (\ program home [])] + (do ///action.monad + [#let [console (@version.echo "")] + _ (..make-sources! fs (get@ #///.sources sample)) + _ (: (Promise (Try Path)) + (file.make-directories promise.monad fs (///local.repository fs home))) + _ (/.do! program console fs sample)] + (!.use (\ console read-line) [])))) (def: #export test Test @@ -74,13 +79,16 @@ (do {! random.monad} [identity @artifact.random sample (\ ! map (set@ #///.identity (#.Some identity)) - @profile.random)] + @profile.random) + home (random.ascii/alpha 5) + working-directory (random.ascii/alpha 5)] ($_ _.and (wrap (do {! promise.monad} - [#let [fs (file.mock (\ file.default separator))] + [#let [fs (file.mock (\ file.default separator)) + program (program.async (program.mock environment.empty home working-directory))] verdict (do ///action.monad - [logging (..execute! fs sample) - #let [artifact-path (format (///local.path fs identity) + [logging (..execute! program fs sample) + #let [artifact-path (format (///local.path fs home identity) (\ fs separator) (///artifact.identity identity)) library-path (format artifact-path ///artifact/extension.lux-library) @@ -98,8 +106,9 @@ (_.cover' [/.do!] (try.default false verdict)))) (wrap (do {! promise.monad} - [#let [fs (file.mock (\ file.default separator))] - logging (..execute! fs (set@ #///.identity #.None sample))] + [#let [fs (file.mock (\ file.default separator)) + program (program.async (program.mock environment.empty home working-directory))] + logging (..execute! program fs (set@ #///.identity #.None sample))] (_.cover' [/.failure] (|> logging (try\map (text\= /.failure)) diff --git a/stdlib/source/test/aedifex/command/test.lux b/stdlib/source/test/aedifex/command/test.lux index f87e70e85..b63662bc0 100644 --- a/stdlib/source/test/aedifex/command/test.lux +++ b/stdlib/source/test/aedifex/command/test.lux @@ -44,6 +44,7 @@ (do {! random.monad} [program (random.ascii/alpha 5) target (random.ascii/alpha 5) + home (random.ascii/alpha 5) working-directory (random.ascii/alpha 5) #let [empty-profile (: Profile (\ ///.monoid identity)) @@ -61,7 +62,7 @@ console (@version.echo "")] (wrap (do promise.monad [verdict (do ///action.monad - [_ (/.do! console (program.async (program.mock environment.empty working-directory)) fs (@build.good-shell []) resolution profile) + [_ (/.do! console (program.async (program.mock environment.empty home working-directory)) fs (@build.good-shell []) resolution profile) build-start (!.use (\ console read-line) []) build-end (!.use (\ console read-line) []) test-start (!.use (\ console read-line) []) @@ -95,7 +96,7 @@ shell.normal shell.error)])))))) [])] - _ (/.do! console (program.async (program.mock environment.empty working-directory)) fs bad-shell resolution profile) + _ (/.do! console (program.async (program.mock environment.empty home working-directory)) fs bad-shell resolution profile) build-start (!.use (\ console read-line) []) build-end (!.use (\ console read-line) []) test-start (!.use (\ console read-line) []) diff --git a/stdlib/source/test/aedifex/local.lux b/stdlib/source/test/aedifex/local.lux index 1d90ff905..b95bf2e19 100644 --- a/stdlib/source/test/aedifex/local.lux +++ b/stdlib/source/test/aedifex/local.lux @@ -24,12 +24,13 @@ (<| (_.covering /._) (do {! random.monad} [sample @artifact.random + home (random.ascii/alpha 5) #let [fs (: (file.System Promise) (file.mock (\ file.default separator)))]] ($_ _.and (_.cover [/.repository /.path] - (let [path (/.path fs sample)] - (and (text.starts-with? (/.repository fs) + (let [path (/.path fs home sample)] + (and (text.starts-with? (/.repository fs home) path) (text.ends-with? (//artifact.path fs sample) path)))) diff --git a/stdlib/source/test/lux/abstract.lux b/stdlib/source/test/lux/abstract.lux index 9fd3986b8..b31c10617 100644 --- a/stdlib/source/test/lux/abstract.lux +++ b/stdlib/source/test/lux/abstract.lux @@ -8,6 +8,7 @@ ["#/." cofree]] ["#." enum] ["#." equivalence] + ["#." hash] ["#." fold] ["#." functor ["#/." contravariant]] @@ -46,6 +47,7 @@ /codec.test /enum.test /equivalence.test + /hash.test /fold.test /interval.test /monoid.test diff --git a/stdlib/source/test/lux/abstract/hash.lux b/stdlib/source/test/lux/abstract/hash.lux new file mode 100644 index 000000000..d829d489e --- /dev/null +++ b/stdlib/source/test/lux/abstract/hash.lux @@ -0,0 +1,37 @@ +(.module: + [lux #* + ["_" test (#+ Test)] + [abstract + [monad (#+ do)] + {[0 #spec] + [/ + [functor + ["$." contravariant]]]}] + [data + [number + ["n" nat] + ["i" int]]] + [math + ["." random (#+ Random)]]] + {1 + ["." /]}) + +(def: #export test + Test + (do random.monad + [left random.int + right random.nat] + (<| (_.covering /._) + ($_ _.and + (_.cover [/.sum] + (let [hash (/.sum i.hash n.hash)] + (and (n.= (\ i.hash hash left) + (\ hash hash (#.Left left))) + (n.= (\ n.hash hash right) + (\ hash hash (#.Right right)))))) + (_.cover [/.product] + (let [hash (/.product i.hash n.hash)] + (n.= (n.+ (\ i.hash hash left) + (\ n.hash hash right)) + (\ hash hash [left right])))) + )))) diff --git a/stdlib/source/test/lux/control/concurrency/actor.lux b/stdlib/source/test/lux/control/concurrency/actor.lux index 5c47eab5e..0b750b9cc 100644 --- a/stdlib/source/test/lux/control/concurrency/actor.lux +++ b/stdlib/source/test/lux/control/concurrency/actor.lux @@ -158,7 +158,7 @@ (wrap (and (n.= 1 output-1) (n.= 2 output-2) (n.= 3 output-3))))] - (_.cover' [/.actor: /.message: /.tell!] + (_.cover' [/.Message /.actor: /.message: /.tell!] (case result (#try.Success outcome) outcome @@ -221,6 +221,6 @@ (wrap agent))) _ (/.await agent) actual (promise.future (atom.read sink))] - (_.cover' [/.observe] + (_.cover' [/.Stop /.observe /.await] (\ (list.equivalence n.equivalence) = expected (row.to-list actual)))))) )))) diff --git a/stdlib/source/test/lux/control/concurrency/promise.lux b/stdlib/source/test/lux/control/concurrency/promise.lux index bd980cd55..04dd1c220 100644 --- a/stdlib/source/test/lux/control/concurrency/promise.lux +++ b/stdlib/source/test/lux/control/concurrency/promise.lux @@ -49,19 +49,18 @@ (<| (_.covering /._) (do {! random.monad} [to-wait (|> random.nat (\ ! map (|>> (n.% 100) (n.max 10)))) - #let [extra-time (n.* 2 to-wait)] expected random.nat dummy random.nat #let [not-dummy (|> random.nat (random.filter (|>> (n.= dummy) not)))] leftE not-dummy rightE not-dummy] ($_ _.and - (_.with-cover [/.functor] - ($functor.spec ..injection ..comparison /.functor)) - (_.with-cover [/.apply] - ($apply.spec ..injection ..comparison /.apply)) - (_.with-cover [/.monad] - ($monad.spec ..injection ..comparison /.monad)) + (_.for [/.functor] + ($functor.spec ..injection ..comparison /.functor)) + (_.for [/.apply] + ($apply.spec ..injection ..comparison /.apply)) + (_.for [/.monad] + ($monad.spec ..injection ..comparison /.monad)) (wrap (do /.monad [#let [[promise resolver] (: [(/.Promise Nat) (/.Resolver Nat)] @@ -150,8 +149,8 @@ (and yep (not nope))))) (wrap (do /.monad - [?none (/.time-out to-wait (/.delay extra-time dummy)) - ?actual (/.time-out extra-time (/.delay to-wait expected))] + [?none (/.time-out 0 (/.delay to-wait dummy)) + ?actual (/.time-out to-wait (wrap expected))] (_.cover' [/.time-out] (case [?none ?actual] [#.None (#.Some actual)] diff --git a/stdlib/source/test/lux/data.lux b/stdlib/source/test/lux/data.lux index 5a80af5a7..78cae485a 100644 --- a/stdlib/source/test/lux/data.lux +++ b/stdlib/source/test/lux/data.lux @@ -22,19 +22,7 @@ ["#/." json] ["#/." tar] ["#/." xml]] - [number - ["#." i8] - ["#." i16] - ["#." i32] - ["#." i64] - ["#." nat] - ["#." int] - ["#." rev] - ["#." frac] - ["#." ratio] - ["#." complex]] - ["#." text - ["#/." regex]] + ["#." text] ["#." collection]]) ## TODO: Get rid of this ASAP @@ -44,12 +32,6 @@ [_ (wrap [])] body))) -(def: text - ($_ _.and - /text.test - /text/regex.test - )) - (def: format ($_ _.and /format/binary.test @@ -75,7 +57,7 @@ /product.test) test2 ($_ _.and /sum.test - ..text + /text.test ..format /collection.test )] diff --git a/stdlib/source/test/lux/data/bit.lux b/stdlib/source/test/lux/data/bit.lux index 82d459d10..8fa84d273 100644 --- a/stdlib/source/test/lux/data/bit.lux +++ b/stdlib/source/test/lux/data/bit.lux @@ -8,6 +8,7 @@ {[0 #spec] [/ ["$." equivalence] + ["$." hash] ["$." monoid] ["$." codec]]}] [control @@ -23,6 +24,8 @@ ($_ _.and (_.for [/.equivalence] ($equivalence.spec /.equivalence random.bit)) + (_.for [/.hash] + ($hash.spec /.hash random.bit)) (_.for [/.disjunction] ($monoid.spec /.equivalence /.disjunction random.bit)) (_.for [/.conjunction] diff --git a/stdlib/source/test/lux/data/color.lux b/stdlib/source/test/lux/data/color.lux index 1e7896faf..76075ba0b 100644 --- a/stdlib/source/test/lux/data/color.lux +++ b/stdlib/source/test/lux/data/color.lux @@ -6,6 +6,7 @@ {[0 #spec] [/ ["$." equivalence] + ["$." hash] ["$." monoid]]}] [data [number @@ -22,7 +23,7 @@ {1 ["." / (#+ Color)]}) -(def: #export color +(def: #export random (Random Color) (|> ($_ random.and random.nat random.nat random.nat) (\ random.monad map /.from-rgb))) @@ -85,10 +86,10 @@ (def: transformation Test (do random.monad - [colorful (|> ..color + [colorful (|> ..random (random.filter (function (_ color) (|> (distance/3 color /.black) (f.>= +100.0)))) (random.filter (function (_ color) (|> (distance/3 color /.white) (f.>= +100.0))))) - mediocre (|> ..color + mediocre (|> ..random (random.filter (|>> saturation ((function (_ saturation) (and (f.>= +0.25 saturation) @@ -175,14 +176,16 @@ (<| (_.covering /._) (_.for [/.Color]) (do {! random.monad} - [expected ..color] + [expected ..random] ($_ _.and (_.for [/.equivalence] - ($equivalence.spec /.equivalence ..color)) + ($equivalence.spec /.equivalence ..random)) + (_.for [/.hash] + ($hash.spec /.hash ..random)) (_.for [/.addition] - ($monoid.spec /.equivalence /.addition ..color)) + ($monoid.spec /.equivalence /.addition ..random)) (_.for [/.subtraction] - ($monoid.spec /.equivalence /.addition ..color)) + ($monoid.spec /.equivalence /.addition ..random)) (..encoding expected) (_.cover [/.complement] diff --git a/stdlib/source/test/lux/data/number/rev.lux b/stdlib/source/test/lux/data/number/rev.lux index c28f89451..2807dac8d 100644 --- a/stdlib/source/test/lux/data/number/rev.lux +++ b/stdlib/source/test/lux/data/number/rev.lux @@ -85,14 +85,14 @@ (and (/.< left (/.* left right)) (/.< right (/.* left right))))) (do {! random.monad} - [#let [dividend (\ ! map (i64.and (hex "FF")) + [#let [dividend (\ ! map (i64.and (hex "FFFF")) random.rev) divisor (\ ! map (|>> (i64.and (hex "F")) (i64.or (hex "1")) (i64.rotate-right 8) .rev) random.nat)] - dividend dividend + dividend (random.filter (/.> .0) dividend) divisor/0 divisor divisor/1 (random.filter (|>> (/.= divisor/0) not) divisor) diff --git a/stdlib/source/test/lux/data/text.lux b/stdlib/source/test/lux/data/text.lux index 778559483..cd03b89fc 100644 --- a/stdlib/source/test/lux/data/text.lux +++ b/stdlib/source/test/lux/data/text.lux @@ -19,6 +19,9 @@ ["." set]]] [math ["." random]]] + ["." / #_ + ["#." buffer] + ["#." regex]] {1 ["." /]}) @@ -292,4 +295,7 @@ (_.cover [/.replace-all] (/\= sample2 (/.replace-all sep1 sep2 sample1)))) + + /buffer.test + /regex.test ))) diff --git a/stdlib/source/test/lux/data/text/buffer.lux b/stdlib/source/test/lux/data/text/buffer.lux new file mode 100644 index 000000000..a12d57fc5 --- /dev/null +++ b/stdlib/source/test/lux/data/text/buffer.lux @@ -0,0 +1,43 @@ +(.module: + [lux #* + ["_" test (#+ Test)] + [abstract + [monad (#+ do)]] + [data + ["." text ("#\." equivalence) + ["%" format (#+ format)]] + [number + ["n" nat]]] + [math + ["." random (#+ Random)]]] + {1 + ["." /]}) + +(def: part + (Random Text) + (do {! random.monad} + [size (\ ! map (|>> (n.% 10) inc) random.nat)] + (random.ascii/alpha size))) + +(def: #export test + Test + (<| (_.covering /._) + (_.for [/.Buffer]) + (do random.monad + [left ..part + mid ..part + right ..part] + ($_ _.and + (_.cover [/.empty] + (n.= 0(/.size /.empty))) + (_.cover [/.size /.append] + (n.= (text.size left) + (/.size (/.append left /.empty)))) + (_.cover [/.text] + (text\= (format left mid right) + (|> /.empty + (/.append left) + (/.append mid) + (/.append right) + /.text))) + )))) diff --git a/stdlib/source/test/lux/world/program.lux b/stdlib/source/test/lux/world/program.lux index 531ba0095..91484bf50 100644 --- a/stdlib/source/test/lux/world/program.lux +++ b/stdlib/source/test/lux/world/program.lux @@ -23,7 +23,7 @@ (random.ascii/alpha 5) (random.ascii/alpha 5))) -(def: directory +(def: path (Random Path) (random.ascii/alpha 5)) @@ -32,8 +32,9 @@ (<| (_.covering /._) (do random.monad [environment ..environment - directory ..directory] + home ..path + directory ..path] ($_ _.and (_.for [/.mock /.async] - ($/.spec (/.async (/.mock environment directory)))) + ($/.spec (/.async (/.mock environment home directory)))) )))) |