From 14287585025b2d8fff1991691def9e643b039ac8 Mon Sep 17 00:00:00 2001 From: Eduardo Julian Date: Thu, 10 Dec 2020 00:15:15 -0400 Subject: Re-named "with-cover" to "for". --- stdlib/source/lux/data/number/ratio.lux | 93 ++-- stdlib/source/lux/test.lux | 10 +- stdlib/source/program/aedifex.lux | 89 ++-- stdlib/source/program/aedifex/command/auto.lux | 5 +- stdlib/source/program/aedifex/command/build.lux | 5 +- stdlib/source/program/aedifex/command/test.lux | 5 +- stdlib/source/spec/lux/abstract/apply.lux | 14 +- stdlib/source/spec/lux/abstract/codec.lux | 16 +- stdlib/source/spec/lux/abstract/comonad.lux | 2 +- stdlib/source/spec/lux/abstract/enum.lux | 2 +- stdlib/source/spec/lux/abstract/equivalence.lux | 2 +- stdlib/source/spec/lux/abstract/functor.lux | 2 +- .../spec/lux/abstract/functor/contravariant.lux | 2 +- stdlib/source/spec/lux/abstract/interval.lux | 2 +- stdlib/source/spec/lux/abstract/monad.lux | 2 +- stdlib/source/spec/lux/abstract/monoid.lux | 2 +- stdlib/source/spec/lux/abstract/order.lux | 2 +- stdlib/source/spec/lux/world/console.lux | 2 +- stdlib/source/spec/lux/world/shell.lux | 2 +- stdlib/source/test/aedifex/artifact.lux | 34 +- stdlib/source/test/aedifex/artifact/extension.lux | 34 +- stdlib/source/test/aedifex/artifact/type.lux | 20 +- stdlib/source/test/aedifex/cli.lux | 18 +- stdlib/source/test/aedifex/command/auto.lux | 3 +- stdlib/source/test/aedifex/dependency.lux | 10 +- .../source/test/aedifex/dependency/resolution.lux | 6 +- stdlib/source/test/aedifex/hash.lux | 90 ++-- stdlib/source/test/aedifex/package.lux | 2 +- stdlib/source/test/aedifex/parser.lux | 12 +- stdlib/source/test/aedifex/profile.lux | 18 +- stdlib/source/test/aedifex/project.lux | 104 ++-- stdlib/source/test/aedifex/repository.lux | 8 +- stdlib/source/test/lux/abstract/comonad/cofree.lux | 14 +- stdlib/source/test/lux/abstract/equivalence.lux | 4 +- stdlib/source/test/lux/abstract/interval.lux | 24 +- stdlib/source/test/lux/abstract/monad/free.lux | 20 +- stdlib/source/test/lux/abstract/order.lux | 4 +- stdlib/source/test/lux/abstract/predicate.lux | 14 +- .../source/test/lux/control/concurrency/actor.lux | 42 +- stdlib/source/test/lux/control/concurrency/frp.lux | 12 +- .../test/lux/control/concurrency/semaphore.lux | 244 ++++----- stdlib/source/test/lux/control/concurrency/stm.lux | 12 +- stdlib/source/test/lux/control/continuation.lux | 14 +- stdlib/source/test/lux/control/exception.lux | 2 +- stdlib/source/test/lux/control/function.lux | 4 +- stdlib/source/test/lux/control/function/memo.lux | 2 +- stdlib/source/test/lux/control/function/mixin.lux | 178 +++---- stdlib/source/test/lux/control/io.lux | 14 +- stdlib/source/test/lux/control/parser.lux | 14 +- stdlib/source/test/lux/control/parser/analysis.lux | 2 +- stdlib/source/test/lux/control/parser/binary.lux | 4 +- stdlib/source/test/lux/control/parser/cli.lux | 2 +- stdlib/source/test/lux/control/parser/code.lux | 2 +- .../source/test/lux/control/parser/environment.lux | 4 +- stdlib/source/test/lux/control/parser/json.lux | 2 +- .../source/test/lux/control/parser/synthesis.lux | 12 +- stdlib/source/test/lux/control/parser/text.lux | 2 +- stdlib/source/test/lux/control/parser/tree.lux | 2 +- stdlib/source/test/lux/control/parser/type.lux | 4 +- stdlib/source/test/lux/control/parser/xml.lux | 45 +- stdlib/source/test/lux/control/reader.lux | 14 +- stdlib/source/test/lux/control/region.lux | 26 +- .../test/lux/control/security/capability.lux | 28 +- stdlib/source/test/lux/control/security/policy.lux | 22 +- stdlib/source/test/lux/control/state.lux | 12 +- stdlib/source/test/lux/control/thread.lux | 86 +-- stdlib/source/test/lux/control/try.lux | 18 +- stdlib/source/test/lux/control/writer.lux | 14 +- stdlib/source/test/lux/data/binary.lux | 138 ++--- stdlib/source/test/lux/data/bit.lux | 16 +- stdlib/source/test/lux/data/collection/array.lux | 18 +- stdlib/source/test/lux/data/collection/bits.lux | 6 +- .../source/test/lux/data/collection/dictionary.lux | 12 +- .../lux/data/collection/dictionary/ordered.lux | 6 +- .../test/lux/data/collection/dictionary/plist.lux | 8 +- stdlib/source/test/lux/data/collection/list.lux | 26 +- stdlib/source/test/lux/data/collection/queue.lux | 10 +- .../test/lux/data/collection/queue/priority.lux | 38 +- stdlib/source/test/lux/data/collection/row.lux | 26 +- .../source/test/lux/data/collection/sequence.lux | 10 +- stdlib/source/test/lux/data/collection/set.lux | 10 +- .../source/test/lux/data/collection/set/multi.lux | 6 +- .../test/lux/data/collection/set/ordered.lux | 6 +- stdlib/source/test/lux/data/collection/stack.lux | 10 +- stdlib/source/test/lux/data/collection/tree.lux | 18 +- .../test/lux/data/collection/tree/finger.lux | 2 +- .../test/lux/data/collection/tree/zipper.lux | 14 +- stdlib/source/test/lux/data/color.lux | 118 ++-- stdlib/source/test/lux/data/format/binary.lux | 6 +- stdlib/source/test/lux/data/format/json.lux | 10 +- stdlib/source/test/lux/data/format/tar.lux | 592 ++++++++++----------- stdlib/source/test/lux/data/format/xml.lux | 10 +- stdlib/source/test/lux/data/identity.lux | 18 +- stdlib/source/test/lux/data/lazy.lux | 42 +- stdlib/source/test/lux/data/maybe.lux | 92 ++-- stdlib/source/test/lux/data/name.lux | 64 +-- stdlib/source/test/lux/data/number/complex.lux | 6 +- stdlib/source/test/lux/data/number/frac.lux | 18 +- stdlib/source/test/lux/data/number/i16.lux | 6 +- stdlib/source/test/lux/data/number/i32.lux | 6 +- stdlib/source/test/lux/data/number/i64.lux | 64 +-- stdlib/source/test/lux/data/number/i8.lux | 6 +- stdlib/source/test/lux/data/number/int.lux | 26 +- stdlib/source/test/lux/data/number/nat.lux | 26 +- stdlib/source/test/lux/data/number/ratio.lux | 109 +++- stdlib/source/test/lux/data/product.lux | 8 +- stdlib/source/test/lux/data/sum.lux | 8 +- stdlib/source/test/lux/data/text.lux | 48 +- stdlib/source/test/lux/locale.lux | 6 +- stdlib/source/test/lux/locale/language.lux | 2 +- stdlib/source/test/lux/locale/territory.lux | 2 +- stdlib/source/test/lux/macro/code.lux | 98 ++-- stdlib/source/test/lux/macro/poly/json.lux | 4 +- stdlib/source/test/lux/macro/syntax/common.lux | 46 +- stdlib/source/test/lux/meta.lux | 12 +- stdlib/source/test/lux/meta/annotation.lux | 2 +- .../compiler/language/lux/phase/synthesis/case.lux | 2 +- stdlib/source/test/lux/world/console.lux | 4 +- stdlib/source/test/lux/world/file/watch.lux | 4 +- stdlib/source/test/lux/world/program.lux | 4 +- stdlib/source/test/lux/world/shell.lux | 6 +- 121 files changed, 1762 insertions(+), 1630 deletions(-) (limited to 'stdlib') diff --git a/stdlib/source/lux/data/number/ratio.lux b/stdlib/source/lux/data/number/ratio.lux index 8f22aca70..0d67bd3d6 100644 --- a/stdlib/source/lux/data/number/ratio.lux +++ b/stdlib/source/lux/data/number/ratio.lux @@ -1,6 +1,6 @@ (.module: {#.doc "Rational numbers."} - [lux #* + [lux (#- nat) [abstract [equivalence (#+ Equivalence)] [order (#+ Order)] @@ -10,8 +10,8 @@ [control ["." function] ["." try] - ["p" parser - ["s" code (#+ Parser)]]] + ["<>" parser + ["<.>" code (#+ Parser)]]] [data ["." product] ["." maybe] @@ -27,6 +27,39 @@ {#numerator Nat #denominator Nat}) +(def: #export (nat value) + (-> Ratio (Maybe Nat)) + (case (get@ #denominator value) + 1 (#.Some (get@ #numerator value)) + _ #.None)) + +(def: (normalize (^slots [#numerator #denominator])) + (-> Ratio Ratio) + (let [common (n.gcd numerator denominator)] + {#numerator (n./ common numerator) + #denominator (n./ common denominator)})) + +(syntax: #export (ratio numerator {?denominator (<>.maybe .any)}) + {#.doc (doc "Rational literals." + (ratio numerator denominator) + "The denominator can be omitted if it's 1." + (ratio numerator))} + (wrap (list (` ((~! ..normalize) {#..numerator (~ numerator) + #..denominator (~ (maybe.default (' 1) + ?denominator))}))))) + +(def: #export (= parameter subject) + (-> Ratio Ratio Bit) + (and (n.= (get@ #numerator parameter) + (get@ #numerator subject)) + (n.= (get@ #denominator parameter) + (get@ #denominator subject)))) + +(structure: #export equivalence + (Equivalence Ratio) + + (def: = ..=)) + (def: (equalize parameter subject) (-> Ratio Ratio [Nat Nat]) [(n.* (get@ #denominator subject) @@ -34,26 +67,30 @@ (n.* (get@ #denominator parameter) (get@ #numerator subject))]) -(def: (normalize (^slots [#numerator #denominator])) - (-> Ratio Ratio) - (let [common (n.gcd numerator denominator)] - {#numerator (n./ common numerator) - #denominator (n./ common denominator)})) +(def: #export (< parameter subject) + (-> Ratio Ratio Bit) + (let [[parameter' subject'] (..equalize parameter subject)] + (n.< parameter' subject'))) -(structure: #export equivalence (Equivalence Ratio) - (def: (= parameter subject) - (and (n.= (get@ #numerator parameter) - (get@ #numerator subject)) - (n.= (get@ #denominator parameter) - (get@ #denominator subject))))) +(def: #export (<= parameter subject) + (-> Ratio Ratio Bit) + (or (< parameter subject) + (= parameter subject))) -(structure: #export order (Order Ratio) - (def: &equivalence ..equivalence) +(def: #export (> parameter subject) + (-> Ratio Ratio Bit) + (..< subject parameter)) - (def: (< parameter subject) - (let [[parameter' subject'] (..equalize parameter subject)] - (n.< parameter' subject'))) - ) +(def: #export (>= parameter subject) + (-> Ratio Ratio Bit) + (or (> parameter subject) + (= parameter subject))) + +(structure: #export order + (Order Ratio) + + (def: &equivalence ..equivalence) + (def: < ..<)) (def: #export (+ parameter subject) (-> Ratio Ratio Ratio) @@ -95,7 +132,9 @@ (def: separator ":") -(structure: #export codec (Codec Text Ratio) +(structure: #export codec + (Codec Text Ratio) + (def: (encode (^slots [#numerator #denominator])) ($_ text\compose (n\encode numerator) ..separator (n\encode denominator))) @@ -111,22 +150,12 @@ #.None (#.Left (text\compose "Invalid syntax for ratio: " input))))) -(syntax: #export (ratio numerator {?denominator (p.maybe s.any)}) - {#.doc (doc "Rational literals." - (ratio numerator denominator) - "The denominator can be omitted if it's 1." - (ratio numerator))} - (wrap (list (` ((~! ..normalize) {#..numerator (~ numerator) - #..denominator (~ (maybe.default (' 1) - ?denominator))}))))) - (template [ ] [(structure: #export (Monoid Ratio) (def: identity (..ratio )) - (def: compose ) - )] + (def: compose ))] [0 ..+ addition] [1 ..* multiplication] diff --git a/stdlib/source/lux/test.lux b/stdlib/source/lux/test.lux index 80df67812..e2e4d5644 100644 --- a/stdlib/source/lux/test.lux +++ b/stdlib/source/lux/test.lux @@ -1,5 +1,5 @@ (.module: {#.doc "Tools for unit & property-based/generative testing."} - [lux (#- and) + [lux (#- and for) [abstract ["." monad (#+ do)]] [control @@ -255,7 +255,7 @@ (|> (..|cover'| coverage condition) (\ random.monad wrap))) -(def: (|with-cover| coverage test) +(def: (|for| coverage test) (-> (List Name) Test Test) (let [context (|> coverage (list\map %.name) @@ -291,12 +291,12 @@ [cover ..|cover|] ) -(syntax: #export (with-cover {coverage (.tuple (<>.many .any))} - test) +(syntax: #export (for {coverage (.tuple (<>.many .any))} + test) (let [coverage (list\map (function (_ definition) (` ((~! ..reference) (~ definition)))) coverage)] - (wrap (list (` ((~! ..|with-cover|) + (wrap (list (` ((~! ..|for|) (: (.List .Name) (.list (~+ coverage))) (~ test))))))) diff --git a/stdlib/source/program/aedifex.lux b/stdlib/source/program/aedifex.lux index d804fd552..160720fa7 100644 --- a/stdlib/source/program/aedifex.lux +++ b/stdlib/source/program/aedifex.lux @@ -8,8 +8,8 @@ ["." try (#+ Try) ("#\." functor)] ["." exception (#+ exception:)] [parser - ["." cli (#+ program:)] - ["" code]] + [environment (#+ Environment)] + [cli (#+ program:)]] [security ["!" capability]] [concurrency @@ -31,9 +31,9 @@ [lux ["." syntax]]]]] [world - ["." environment (#+ Environment)] ["." shell (#+ Shell)] ["." console (#+ Console)] + ["." program] ["." file (#+ Path) ["." watch]]]] ["." / #_ @@ -71,7 +71,7 @@ (-> (Console Promise) Environment (file.System Promise) (Shell Promise) Resolution (Command a)) (Command a))) (do promise.monad - [environment (promise.future environment.read)] + [environment (promise.future (\ program.default environment []))] (do /action.monad [resolution (/command/deps.do! console (file.async file.default) (..repositories profile) profile)] ((command console environment (file.async file.default) (shell.async shell.default) resolution) profile)))) @@ -84,6 +84,20 @@ (format (%.text name) " := " (%.text repo))) (dictionary.entries options))])) +(def: (command action) + (All [a] (-> (Promise (Try a)) (IO Any))) + (exec (do promise.monad + [outcome action + #let [code (case outcome + (#try.Failure error) + (exec (log! error) + shell.normal) + + (#try.Success _) + shell.error)]] + (promise.future (\ program.default exit code))) + (\ io.monad wrap []))) + (program: [{[profile operation] /cli.command}] (do {! io.monad} [?console console.default] @@ -94,15 +108,16 @@ (#try.Success console) (case operation #/cli.Version - (exec (/command/version.do! console (\ /.monoid identity)) - (wrap [])) + (..command + (/command/version.do! console (\ /.monoid identity))) _ (do ! [?profile (/input.read io.monad file.default profile)] (case ?profile (#try.Failure error) - (wrap (log! error)) + (exec (log! error) + (\ program.default exit shell.error)) (#try.Success profile) (case operation @@ -110,45 +125,45 @@ (wrap []) #/cli.Clean - (exec (/command/clean.do! console (file.async file.default) profile) - (wrap [])) + (..command + (/command/clean.do! console (file.async file.default) profile)) #/cli.POM - (exec (/command/pom.do! console (file.async file.default) profile) - (wrap [])) + (..command + (/command/pom.do! console (file.async file.default) profile)) #/cli.Install - (exec (/command/install.do! console (file.async file.default) profile) - (wrap [])) + (..command + (/command/install.do! console (file.async file.default) profile)) (#/cli.Deploy repository identity) - (exec (case [(get@ #/.identity profile) - (dictionary.get repository (get@ #/.deploy-repositories profile))] - [(#.Some artifact) (#.Some repository)] - (/command/deploy.do! console - (/repository.async (/repository.remote repository)) - (file.async file.default) - identity - artifact - profile) + (..command + (case [(get@ #/.identity profile) + (dictionary.get repository (get@ #/.deploy-repositories profile))] + [(#.Some artifact) (#.Some repository)] + (/command/deploy.do! console + (/repository.async (/repository.remote repository)) + (file.async file.default) + identity + artifact + profile) - [#.None _] - (promise\wrap (exception.throw /.no-identity [])) + [#.None _] + (promise\wrap (exception.throw /.no-identity [])) - [_ #.None] - (promise\wrap (exception.throw ..cannot-find-repository [repository (get@ #/.deploy-repositories profile)]))) - (wrap [])) + [_ #.None] + (promise\wrap (exception.throw ..cannot-find-repository [repository (get@ #/.deploy-repositories profile)])))) #/cli.Dependencies - (exec (/command/deps.do! console (file.async file.default) (..repositories profile) profile) - (wrap [])) + (..command + (/command/deps.do! console (file.async file.default) (..repositories profile) profile)) (#/cli.Compilation compilation) (case compilation - #/cli.Build (exec (..with-dependencies console /command/build.do! profile) - (wrap [])) - #/cli.Test (exec (..with-dependencies console /command/test.do! profile) - (wrap []))) + #/cli.Build (..command + (..with-dependencies console /command/build.do! profile)) + #/cli.Test (..command + (..with-dependencies console /command/test.do! profile))) (#/cli.Auto auto) (do ! @@ -158,8 +173,8 @@ (wrap (log! error)) (#try.Success watcher) - (exec (case auto - #/cli.Build (..with-dependencies console (/command/auto.do! watcher /command/build.do!) profile) - #/cli.Test (..with-dependencies console (/command/auto.do! watcher /command/test.do!) profile)) - (wrap []))))) + (..command + (case auto + #/cli.Build (..with-dependencies console (/command/auto.do! watcher /command/build.do!) profile) + #/cli.Test (..with-dependencies console (/command/auto.do! watcher /command/test.do!) profile)))))) )))))) diff --git a/stdlib/source/program/aedifex/command/auto.lux b/stdlib/source/program/aedifex/command/auto.lux index 33115c2e4..a2f2b1ff5 100644 --- a/stdlib/source/program/aedifex/command/auto.lux +++ b/stdlib/source/program/aedifex/command/auto.lux @@ -7,13 +7,14 @@ [concurrency ["." promise (#+ Promise)]] [security - ["!" capability]]] + ["!" capability]] + [parser + [environment (#+ Environment)]]] [data [collection ["." list] ["." set]]] [world - [environment (#+ Environment)] [shell (#+ Shell)] ["." console (#+ Console)] ["." file (#+ Path) diff --git a/stdlib/source/program/aedifex/command/build.lux b/stdlib/source/program/aedifex/command/build.lux index be20d2e29..78e38a6c5 100644 --- a/stdlib/source/program/aedifex/command/build.lux +++ b/stdlib/source/program/aedifex/command/build.lux @@ -9,7 +9,9 @@ [concurrency ["." promise (#+ Promise) ("#\." monad)]] [security - ["!" capability]]] + ["!" capability]] + [parser + [environment (#+ Environment)]]] [data ["." product] ["." maybe] @@ -22,7 +24,6 @@ [number ["i" int]]] [world - [environment (#+ Environment)] ["." file (#+ Path)] ["." shell (#+ Shell)] ["." console (#+ Console)]]] diff --git a/stdlib/source/program/aedifex/command/test.lux b/stdlib/source/program/aedifex/command/test.lux index 93c705be1..3b5afaabf 100644 --- a/stdlib/source/program/aedifex/command/test.lux +++ b/stdlib/source/program/aedifex/command/test.lux @@ -6,14 +6,15 @@ [concurrency ["." promise (#+ Promise) ("#\." monad)]] [security - ["!" capability]]] + ["!" capability]] + [parser + [environment (#+ Environment)]]] [data [text ["%" format (#+ format)]] [number ["i" int]]] [world - [environment (#+ Environment)] ["." file] ["." shell (#+ Shell)] ["." console (#+ Console)]]] diff --git a/stdlib/source/spec/lux/abstract/apply.lux b/stdlib/source/spec/lux/abstract/apply.lux index 40bd37826..8b9884b26 100644 --- a/stdlib/source/spec/lux/abstract/apply.lux +++ b/stdlib/source/spec/lux/abstract/apply.lux @@ -64,10 +64,10 @@ (def: #export (spec injection comparison apply) (All [f] (-> (Injection f) (Comparison f) (Apply f) Test)) - (_.with-cover [/.Apply] - ($_ _.and - (..identity injection comparison apply) - (..homomorphism injection comparison apply) - (..interchange injection comparison apply) - (..composition injection comparison apply) - ))) + (_.for [/.Apply] + ($_ _.and + (..identity injection comparison apply) + (..homomorphism injection comparison apply) + (..interchange injection comparison apply) + (..composition injection comparison apply) + ))) diff --git a/stdlib/source/spec/lux/abstract/codec.lux b/stdlib/source/spec/lux/abstract/codec.lux index e5740cf53..db3148c3f 100644 --- a/stdlib/source/spec/lux/abstract/codec.lux +++ b/stdlib/source/spec/lux/abstract/codec.lux @@ -16,11 +16,11 @@ (All [m a] (-> (Equivalence a) (/.Codec m a) (Random a) Test)) (do random.monad [expected generator] - (_.with-cover [/.Codec] - (_.test "Isomorphism." - (case (|> expected @//encode @//decode) - (#try.Success actual) - (@//= expected actual) - - (#try.Failure _) - false))))) + (_.for [/.Codec] + (_.test "Isomorphism." + (case (|> expected @//encode @//decode) + (#try.Success actual) + (@//= expected actual) + + (#try.Failure _) + false))))) diff --git a/stdlib/source/spec/lux/abstract/comonad.lux b/stdlib/source/spec/lux/abstract/comonad.lux index ed56d5787..5865381d2 100644 --- a/stdlib/source/spec/lux/abstract/comonad.lux +++ b/stdlib/source/spec/lux/abstract/comonad.lux @@ -53,7 +53,7 @@ (def: #export (spec injection comparison subject) (All [f] (-> (Injection f) (Comparison f) (CoMonad f) Test)) - (<| (_.with-cover [/.CoMonad]) + (<| (_.for [/.CoMonad]) ($_ _.and (..left-identity injection subject) (..right-identity injection comparison subject) diff --git a/stdlib/source/spec/lux/abstract/enum.lux b/stdlib/source/spec/lux/abstract/enum.lux index 7f541b0e9..e598179ad 100644 --- a/stdlib/source/spec/lux/abstract/enum.lux +++ b/stdlib/source/spec/lux/abstract/enum.lux @@ -12,7 +12,7 @@ (All [a] (-> (/.Enum a) (Random a) Test)) (do random.monad [sample gen-sample] - (<| (_.with-cover [/.Enum]) + (<| (_.for [/.Enum]) ($_ _.and (_.test "Successor and predecessor are inverse functions." (and (@//= (|> sample @//succ @//pred) diff --git a/stdlib/source/spec/lux/abstract/equivalence.lux b/stdlib/source/spec/lux/abstract/equivalence.lux index 1d8db459c..5c5114f4d 100644 --- a/stdlib/source/spec/lux/abstract/equivalence.lux +++ b/stdlib/source/spec/lux/abstract/equivalence.lux @@ -13,7 +13,7 @@ (do random.monad [left generator right generator] - (<| (_.with-cover [/.Equivalence]) + (<| (_.for [/.Equivalence]) ($_ _.and (_.test "Reflexivity." (_//= left left)) diff --git a/stdlib/source/spec/lux/abstract/functor.lux b/stdlib/source/spec/lux/abstract/functor.lux index 70206e9bb..f29e34554 100644 --- a/stdlib/source/spec/lux/abstract/functor.lux +++ b/stdlib/source/spec/lux/abstract/functor.lux @@ -54,7 +54,7 @@ (def: #export (spec injection comparison functor) (All [f] (-> (Injection f) (Comparison f) (Functor f) Test)) - (<| (_.with-cover [/.Functor]) + (<| (_.for [/.Functor]) ($_ _.and (..identity injection comparison functor) (..homomorphism injection comparison functor) diff --git a/stdlib/source/spec/lux/abstract/functor/contravariant.lux b/stdlib/source/spec/lux/abstract/functor/contravariant.lux index 8adf0139d..8a2e237b6 100644 --- a/stdlib/source/spec/lux/abstract/functor/contravariant.lux +++ b/stdlib/source/spec/lux/abstract/functor/contravariant.lux @@ -25,7 +25,7 @@ (All [f a] (-> (Equivalence (f a)) (f a) (Functor f) Test)) (do random.monad [sample random.nat] - (<| (_.with-cover [/.Functor]) + (<| (_.for [/.Functor]) ($_ _.and (..identity equivalence value functor) )))) diff --git a/stdlib/source/spec/lux/abstract/interval.lux b/stdlib/source/spec/lux/abstract/interval.lux index 0cd255eb2..c80c3ec5b 100644 --- a/stdlib/source/spec/lux/abstract/interval.lux +++ b/stdlib/source/spec/lux/abstract/interval.lux @@ -11,7 +11,7 @@ (def: #export (spec (^open "@//.") gen-sample) (All [a] (-> (/.Interval a) (Random a) Test)) - (<| (_.with-cover [/.Interval]) + (<| (_.for [/.Interval]) (do random.monad [sample gen-sample] ($_ _.and diff --git a/stdlib/source/spec/lux/abstract/monad.lux b/stdlib/source/spec/lux/abstract/monad.lux index 8c1cf7f76..322de7b7b 100644 --- a/stdlib/source/spec/lux/abstract/monad.lux +++ b/stdlib/source/spec/lux/abstract/monad.lux @@ -49,7 +49,7 @@ (def: #export (spec injection comparison monad) (All [f] (-> (Injection f) (Comparison f) (Monad f) Test)) - (<| (_.with-cover [/.Monad]) + (<| (_.for [/.Monad]) ($_ _.and (..left-identity injection comparison monad) (..right-identity injection comparison monad) diff --git a/stdlib/source/spec/lux/abstract/monoid.lux b/stdlib/source/spec/lux/abstract/monoid.lux index 23e35d0db..b3bcd7a67 100644 --- a/stdlib/source/spec/lux/abstract/monoid.lux +++ b/stdlib/source/spec/lux/abstract/monoid.lux @@ -17,7 +17,7 @@ left gen-sample mid gen-sample right gen-sample] - (<| (_.with-cover [/.Monoid]) + (<| (_.for [/.Monoid]) ($_ _.and (_.test "Left identity." (@//= sample diff --git a/stdlib/source/spec/lux/abstract/order.lux b/stdlib/source/spec/lux/abstract/order.lux index 7fa8c618c..6d259a465 100644 --- a/stdlib/source/spec/lux/abstract/order.lux +++ b/stdlib/source/spec/lux/abstract/order.lux @@ -10,7 +10,7 @@ (def: #export (spec (^open "@//.") generator) (All [a] (-> (/.Order a) (Random a) Test)) - (<| (_.with-cover [/.Order]) + (<| (_.for [/.Order]) ($_ _.and (do random.monad [parameter generator diff --git a/stdlib/source/spec/lux/world/console.lux b/stdlib/source/spec/lux/world/console.lux index 761376526..1da631a98 100644 --- a/stdlib/source/spec/lux/world/console.lux +++ b/stdlib/source/spec/lux/world/console.lux @@ -17,7 +17,7 @@ (def: #export (spec console) (-> (IO (/.Console Promise)) Test) - (<| (_.with-cover [/.Console]) + (<| (_.for [/.Console]) (do {! random.monad} [message (random.ascii/alpha 10)] (wrap (do promise.monad diff --git a/stdlib/source/spec/lux/world/shell.lux b/stdlib/source/spec/lux/world/shell.lux index b6aa282d4..935bd3ab3 100644 --- a/stdlib/source/spec/lux/world/shell.lux +++ b/stdlib/source/spec/lux/world/shell.lux @@ -78,7 +78,7 @@ (with-expansions [ (as-is [/.Can-Execute /.Command /.Argument])] (def: #export (spec shell) (-> (/.Shell Promise) Test) - (<| (_.with-cover [/.Shell /.Process]) + (<| (_.for [/.Shell /.Process]) (do {! random.monad} [message (random.ascii/alpha 10) seconds (\ ! map (|>> (n.% 5) (n.+ 5)) random.nat)] diff --git a/stdlib/source/test/aedifex/artifact.lux b/stdlib/source/test/aedifex/artifact.lux index 6ba31f9b7..a718d51f6 100644 --- a/stdlib/source/test/aedifex/artifact.lux +++ b/stdlib/source/test/aedifex/artifact.lux @@ -34,21 +34,21 @@ (def: #export test Test (<| (_.covering /._) - (_.with-cover [/.Group /.Name /.Version - /.Artifact] - ($_ _.and - (_.with-cover [/.equivalence] - ($equivalence.spec /.equivalence ..random)) + (_.for [/.Group /.Name /.Version + /.Artifact] + ($_ _.and + (_.for [/.equivalence] + ($equivalence.spec /.equivalence ..random)) - (do random.monad - [sample ..random - #let [fs (: (file.System Promise) - (file.mock (\ file.default separator)))]] - (_.cover [/.uri /.path] - (|> (/.path fs sample) - (text.replace-all uri.separator (\ fs separator)) - (text\= (/.uri sample))))) - - /type.test - /extension.test - )))) + (do random.monad + [sample ..random + #let [fs (: (file.System Promise) + (file.mock (\ file.default separator)))]] + (_.cover [/.uri /.path] + (|> (/.path fs sample) + (text.replace-all uri.separator (\ fs separator)) + (text\= (/.uri sample))))) + + /type.test + /extension.test + )))) diff --git a/stdlib/source/test/aedifex/artifact/extension.lux b/stdlib/source/test/aedifex/artifact/extension.lux index e098b0f9c..cd695ae93 100644 --- a/stdlib/source/test/aedifex/artifact/extension.lux +++ b/stdlib/source/test/aedifex/artifact/extension.lux @@ -20,21 +20,21 @@ (def: #export test Test (<| (_.covering /._) - (_.with-cover [/.Extension] - ($_ _.and - (_.cover [/.lux-library /.jvm-library /.pom - /.sha-1 /.md5] - (let [options (list /.lux-library /.jvm-library /.pom /.sha-1 /.md5) - uniques (set.from-list text.hash options)] - (n.= (list.size options) - (set.size uniques)))) - (_.cover [/.extension] - (`` (and (~~ (template [ ] - [(text\= - (/.extension ))] + (_.for [/.Extension] + ($_ _.and + (_.cover [/.lux-library /.jvm-library /.pom + /.sha-1 /.md5] + (let [options (list /.lux-library /.jvm-library /.pom /.sha-1 /.md5) + uniques (set.from-list text.hash options)] + (n.= (list.size options) + (set.size uniques)))) + (_.cover [/.extension] + (`` (and (~~ (template [ ] + [(text\= + (/.extension ))] - [//.lux-library /.lux-library] - [//.jvm-library /.jvm-library] - [//.pom /.pom] - ))))) - )))) + [//.lux-library /.lux-library] + [//.jvm-library /.jvm-library] + [//.pom /.pom] + ))))) + )))) diff --git a/stdlib/source/test/aedifex/artifact/type.lux b/stdlib/source/test/aedifex/artifact/type.lux index 0d8284d7c..84807a8c6 100644 --- a/stdlib/source/test/aedifex/artifact/type.lux +++ b/stdlib/source/test/aedifex/artifact/type.lux @@ -18,13 +18,13 @@ (def: #export test Test (<| (_.covering /._) - (_.with-cover [/.Type] - ($_ _.and - (_.cover [/.lux-library /.jvm-library - /.pom /.md5 /.sha-1] - (let [options (list /.lux-library /.jvm-library - /.pom /.md5 /.sha-1) - uniques (set.from-list text.hash options)] - (n.= (list.size options) - (set.size uniques)))) - )))) + (_.for [/.Type] + ($_ _.and + (_.cover [/.lux-library /.jvm-library + /.pom /.md5 /.sha-1] + (let [options (list /.lux-library /.jvm-library + /.pom /.md5 /.sha-1) + uniques (set.from-list text.hash options)] + (n.= (list.size options) + (set.size uniques)))) + )))) diff --git a/stdlib/source/test/aedifex/cli.lux b/stdlib/source/test/aedifex/cli.lux index c4c76f32f..9118132cd 100644 --- a/stdlib/source/test/aedifex/cli.lux +++ b/stdlib/source/test/aedifex/cli.lux @@ -102,13 +102,13 @@ (def: #export test Test (<| (_.covering /._) - (_.with-cover [/.Compilation /.Command] - ($_ _.and - (_.with-cover [/.equivalence] - ($equivalence.spec /.equivalence ..command)) + (_.for [/.Compilation /.Command] + ($_ _.and + (_.for [/.equivalence] + ($equivalence.spec /.equivalence ..command)) - (_.with-cover [/.command] - ($_ _.and - ..without-profile - ..with-profile - )))))) + (_.for [/.command] + ($_ _.and + ..without-profile + ..with-profile + )))))) diff --git a/stdlib/source/test/aedifex/command/auto.lux b/stdlib/source/test/aedifex/command/auto.lux index aa1b8ebe8..e8f6d17f1 100644 --- a/stdlib/source/test/aedifex/command/auto.lux +++ b/stdlib/source/test/aedifex/command/auto.lux @@ -6,7 +6,7 @@ [control ["." try] [parser - ["." environment]] + ["." environment (#+ Environment)]] [concurrency ["." atom (#+ Atom)] ["." promise (#+ Promise)]] @@ -24,7 +24,6 @@ [math ["." random]] [world - [environment (#+ Environment)] [console (#+ Console)] ["." shell (#+ Shell)] ["." file (#+ Path) diff --git a/stdlib/source/test/aedifex/dependency.lux b/stdlib/source/test/aedifex/dependency.lux index e7388189c..95fec9800 100644 --- a/stdlib/source/test/aedifex/dependency.lux +++ b/stdlib/source/test/aedifex/dependency.lux @@ -22,8 +22,8 @@ (def: #export test Test (<| (_.covering /._) - (_.with-cover [/.Dependency] - ($_ _.and - (_.with-cover [/.equivalence] - ($equivalence.spec /.equivalence ..random)) - )))) + (_.for [/.Dependency] + ($_ _.and + (_.for [/.equivalence] + ($equivalence.spec /.equivalence ..random)) + )))) diff --git a/stdlib/source/test/aedifex/dependency/resolution.lux b/stdlib/source/test/aedifex/dependency/resolution.lux index 0b3bf1634..08bbaa4a4 100644 --- a/stdlib/source/test/aedifex/dependency/resolution.lux +++ b/stdlib/source/test/aedifex/dependency/resolution.lux @@ -357,10 +357,10 @@ (def: #export test Test (<| (_.covering /._) - (_.with-cover [/.Resolution]) + (_.for [/.Resolution]) ($_ _.and - (_.with-cover [/.equivalence] - ($equivalence.spec /.equivalence ..random)) + (_.for [/.equivalence] + ($equivalence.spec /.equivalence ..random)) (_.cover [/.empty] (dictionary.empty? /.empty)) diff --git a/stdlib/source/test/aedifex/hash.lux b/stdlib/source/test/aedifex/hash.lux index 472342c70..8bc830801 100644 --- a/stdlib/source/test/aedifex/hash.lux +++ b/stdlib/source/test/aedifex/hash.lux @@ -36,60 +36,60 @@ (def: #export test Test (<| (_.covering /._) - (_.with-cover [/.Hash /.SHA-1 /.MD5]) + (_.for [/.Hash /.SHA-1 /.MD5]) (`` ($_ _.and - (_.with-cover [/.equivalence] - ($_ _.and - ($equivalence.spec /.equivalence (..random /.sha-1)) - ($equivalence.spec /.equivalence (..random /.md5)) - )) - (_.with-cover [/.data] - ($_ _.and - (~~ (template [ ] - [(do random.monad - [expected (..random )] - (_.cover [ ] - (and (case ( (/.data expected)) - (#try.Success actual) - (\ /.equivalence = expected actual) + (_.for [/.equivalence] + ($_ _.and + ($equivalence.spec /.equivalence (..random /.sha-1)) + ($equivalence.spec /.equivalence (..random /.md5)) + )) + (_.for [/.data] + ($_ _.and + (~~ (template [ ] + [(do random.monad + [expected (..random )] + (_.cover [ ] + (and (case ( (/.data expected)) + (#try.Success actual) + (\ /.equivalence = expected actual) - (#try.Failure error) - false) - (case ( (\ binary.monoid compose - (/.data expected) - (/.data expected))) - (#try.Success actual) - false + (#try.Failure error) + false) + (case ( (\ binary.monoid compose + (/.data expected) + (/.data expected))) + (#try.Success actual) + false - (#try.Failure error) - (exception.match? error)))))] + (#try.Failure error) + (exception.match? error)))))] - [/.sha-1 /.as-sha-1 /.not-a-sha-1] - [/.md5 /.as-md5 /.not-a-md5] - )))) + [/.sha-1 /.as-sha-1 /.not-a-sha-1] + [/.md5 /.as-md5 /.not-a-md5] + )))) (~~ (template [ ] - [(_.with-cover [] - ($codec.spec /.equivalence (..random )))] + [(_.for [] + ($codec.spec /.equivalence (..random )))] [/.sha-1-codec /.sha-1] [/.md5-codec /.md5] )) - (_.with-cover [/.not-a-hash] - ($_ _.and - (~~ (template [ ] - [(do random.monad - [expected (..random )] - (_.cover [] - (case (\ decode - (format (\ encode expected) - "AABBCC")) - (#try.Success actual) - false + (_.for [/.not-a-hash] + ($_ _.and + (~~ (template [ ] + [(do random.monad + [expected (..random )] + (_.cover [] + (case (\ decode + (format (\ encode expected) + "AABBCC")) + (#try.Success actual) + false - (#try.Failure error) - (exception.match? /.not-a-hash error))))] + (#try.Failure error) + (exception.match? /.not-a-hash error))))] - [/.sha-1-codec /.sha-1] - [/.md5-codec /.md5] - )))) + [/.sha-1-codec /.sha-1] + [/.md5-codec /.md5] + )))) )))) diff --git a/stdlib/source/test/aedifex/package.lux b/stdlib/source/test/aedifex/package.lux index c1add80d3..aecdcc5af 100644 --- a/stdlib/source/test/aedifex/package.lux +++ b/stdlib/source/test/aedifex/package.lux @@ -47,7 +47,7 @@ (def: #export test Test (<| (_.covering /._) - (_.with-cover [/.Package]) + (_.for [/.Package]) (do {! random.monad} [[profile package] ..random] ($_ _.and diff --git a/stdlib/source/test/aedifex/parser.lux b/stdlib/source/test/aedifex/parser.lux index 248023e80..7aeff7a18 100644 --- a/stdlib/source/test/aedifex/parser.lux +++ b/stdlib/source/test/aedifex/parser.lux @@ -110,9 +110,9 @@ Test (<| (_.covering /._) (_.covering //format._) - (_.with-cover [/.project - //format.Format //format.profile //format.project] - ($_ _.and - ..single-profile - ..multiple-profiles - )))) + (_.for [/.project + //format.Format //format.profile //format.project] + ($_ _.and + ..single-profile + ..multiple-profiles + )))) diff --git a/stdlib/source/test/aedifex/profile.lux b/stdlib/source/test/aedifex/profile.lux index 7f95c07c2..1743a243a 100644 --- a/stdlib/source/test/aedifex/profile.lux +++ b/stdlib/source/test/aedifex/profile.lux @@ -133,12 +133,12 @@ (def: #export test Test (<| (_.covering /._) - (_.with-cover [/.Distribution /.License /.SCM /.Organization - /.Email /.Developer /.Contributor /.Info - /.Source /.Target /.Name /.Profile] - ($_ _.and - (_.with-cover [/.equivalence] - ($equivalence.spec /.equivalence ..random)) - (_.with-cover [/.monoid] - ($monoid.spec /.equivalence /.monoid ..random)) - )))) + (_.for [/.Distribution /.License /.SCM /.Organization + /.Email /.Developer /.Contributor /.Info + /.Source /.Target /.Name /.Profile] + ($_ _.and + (_.for [/.equivalence] + ($equivalence.spec /.equivalence ..random)) + (_.for [/.monoid] + ($monoid.spec /.equivalence /.monoid ..random)) + )))) diff --git a/stdlib/source/test/aedifex/project.lux b/stdlib/source/test/aedifex/project.lux index ec6849e4e..4ea00a3c4 100644 --- a/stdlib/source/test/aedifex/project.lux +++ b/stdlib/source/test/aedifex/project.lux @@ -39,58 +39,58 @@ (def: #export test Test (<| (_.covering /._) - (_.with-cover [/.Project /.project] - ($_ _.and - (_.with-cover [/.equivalence] - ($equivalence.spec /.equivalence ..random)) - (_.with-cover [/.monoid] - ($monoid.spec /.equivalence /.monoid ..random)) + (_.for [/.Project /.project] + ($_ _.and + (_.for [/.equivalence] + ($equivalence.spec /.equivalence ..random)) + (_.for [/.monoid] + ($monoid.spec /.equivalence /.monoid ..random)) - (do random.monad - [[super-name super-profile] ..profile - [dummy-name dummy-profile] (random.filter (|>> product.left (text\= super-name) not) - ..profile) - [sub-name sub-profile] (random.filter (function (_ [name profile]) - (and (not (text\= super-name name)) - (not (text\= dummy-name name)))) - ..profile) - fake-name (random.filter (function (_ name) - (and (not (text\= super-name name)) - (not (text\= dummy-name name)) - (not (text\= sub-name name)))) - (random.ascii/alpha 1)) - #let [project ($_ (\ /.monoid compose) - (/.project super-name super-profile) - (/.project dummy-name dummy-profile) - (/.project sub-name (set@ #//.parents (list super-name) sub-profile))) - circular ($_ (\ /.monoid compose) - (/.project super-name (set@ #//.parents (list sub-name) super-profile)) - (/.project dummy-name dummy-profile) - (/.project sub-name (set@ #//.parents (list super-name) sub-profile)))]] - ($_ _.and - (_.cover [/.profile] - (and (|> (/.profile super-name project) - (try\map (\ //.equivalence = super-profile)) - (try.default false)) - (|> (/.profile dummy-name project) - (try\map (\ //.equivalence = dummy-profile)) - (try.default false)) - (|> (/.profile sub-name project) - (try\map (\ //.equivalence = (\ //.monoid compose sub-profile super-profile))) - (try.default false)))) - (_.cover [/.unknown-profile] - (case (/.profile fake-name project) - (#try.Success _) - false + (do random.monad + [[super-name super-profile] ..profile + [dummy-name dummy-profile] (random.filter (|>> product.left (text\= super-name) not) + ..profile) + [sub-name sub-profile] (random.filter (function (_ [name profile]) + (and (not (text\= super-name name)) + (not (text\= dummy-name name)))) + ..profile) + fake-name (random.filter (function (_ name) + (and (not (text\= super-name name)) + (not (text\= dummy-name name)) + (not (text\= sub-name name)))) + (random.ascii/alpha 1)) + #let [project ($_ (\ /.monoid compose) + (/.project super-name super-profile) + (/.project dummy-name dummy-profile) + (/.project sub-name (set@ #//.parents (list super-name) sub-profile))) + circular ($_ (\ /.monoid compose) + (/.project super-name (set@ #//.parents (list sub-name) super-profile)) + (/.project dummy-name dummy-profile) + (/.project sub-name (set@ #//.parents (list super-name) sub-profile)))]] + ($_ _.and + (_.cover [/.profile] + (and (|> (/.profile super-name project) + (try\map (\ //.equivalence = super-profile)) + (try.default false)) + (|> (/.profile dummy-name project) + (try\map (\ //.equivalence = dummy-profile)) + (try.default false)) + (|> (/.profile sub-name project) + (try\map (\ //.equivalence = (\ //.monoid compose sub-profile super-profile))) + (try.default false)))) + (_.cover [/.unknown-profile] + (case (/.profile fake-name project) + (#try.Success _) + false - (#try.Failure error) - (exception.match? /.unknown-profile error))) - (_.cover [/.circular-dependency] - (case (/.profile sub-name circular) - (#try.Success _) - false + (#try.Failure error) + (exception.match? /.unknown-profile error))) + (_.cover [/.circular-dependency] + (case (/.profile sub-name circular) + (#try.Success _) + false - (#try.Failure error) - (exception.match? /.circular-dependency error))) - )) - )))) + (#try.Failure error) + (exception.match? /.circular-dependency error))) + )) + )))) diff --git a/stdlib/source/test/aedifex/repository.lux b/stdlib/source/test/aedifex/repository.lux index 55bd3af19..4da17a059 100644 --- a/stdlib/source/test/aedifex/repository.lux +++ b/stdlib/source/test/aedifex/repository.lux @@ -86,8 +86,8 @@ invalid (random.filter (|>> (\ identity-equivalence = valid) not) ..identity)] ($_ _.and - (_.with-cover [/.mock /.Simulation] - ($/.spec valid (..artifact "1.2.3-YES") - invalid (..artifact "4.5.6-NO") - (/.mock (..simulation valid) ..empty))) + (_.for [/.mock /.Simulation] + ($/.spec valid (..artifact "1.2.3-YES") + invalid (..artifact "4.5.6-NO") + (/.mock (..simulation valid) ..empty))) )))) diff --git a/stdlib/source/test/lux/abstract/comonad/cofree.lux b/stdlib/source/test/lux/abstract/comonad/cofree.lux index 9fc2df11b..8a089c533 100644 --- a/stdlib/source/test/lux/abstract/comonad/cofree.lux +++ b/stdlib/source/test/lux/abstract/comonad/cofree.lux @@ -40,12 +40,12 @@ (def: #export test Test (<| (_.covering /._) - (_.with-cover [/.CoFree]) + (_.for [/.CoFree]) ($_ _.and - (_.with-cover [/.functor] - ($functor.spec ..injection ..comparison (: (Functor (/.CoFree Sequence)) - (/.functor sequence.functor)))) - (_.with-cover [/.comonad] - ($comonad.spec ..injection ..comparison (: (CoMonad (/.CoFree Sequence)) - (/.comonad sequence.functor)))) + (_.for [/.functor] + ($functor.spec ..injection ..comparison (: (Functor (/.CoFree Sequence)) + (/.functor sequence.functor)))) + (_.for [/.comonad] + ($comonad.spec ..injection ..comparison (: (CoMonad (/.CoFree Sequence)) + (/.comonad sequence.functor)))) ))) diff --git a/stdlib/source/test/lux/abstract/equivalence.lux b/stdlib/source/test/lux/abstract/equivalence.lux index 0193773eb..95f62218c 100644 --- a/stdlib/source/test/lux/abstract/equivalence.lux +++ b/stdlib/source/test/lux/abstract/equivalence.lux @@ -37,8 +37,8 @@ (\ right = leftN rightN))))))]] (<| (_.covering /._) ($_ _.and - (_.with-cover [/.functor] - ($contravariant.spec equivalence n.equivalence /.functor)) + (_.for [/.functor] + ($contravariant.spec equivalence n.equivalence /.functor)) (_.cover [/.sum] (let [equivalence (/.sum n.equivalence i.equivalence)] (and (bit\= (\ n.equivalence = leftN leftN) diff --git a/stdlib/source/test/lux/abstract/interval.lux b/stdlib/source/test/lux/abstract/interval.lux index 55ad4111d..a4e06fa3a 100644 --- a/stdlib/source/test/lux/abstract/interval.lux +++ b/stdlib/source/test/lux/abstract/interval.lux @@ -248,21 +248,21 @@ Test (<| (_.covering /._) ($_ _.and - (_.with-cover [/.equivalence] - ($equivalence.spec /.equivalence ..interval)) + (_.for [/.equivalence] + ($equivalence.spec /.equivalence ..interval)) ..types ..boundaries - (_.with-cover [/.union] - ..union) - (_.with-cover [/.intersection] - ..intersection) - (_.with-cover [/.complement] - ..complement) + (_.for [/.union] + ..union) + (_.for [/.intersection] + ..intersection) + (_.for [/.complement] + ..complement) ..location ..touch - (_.with-cover [/.nested?] - ..nested) - (_.with-cover [/.overlaps?] - ..overlap) + (_.for [/.nested?] + ..nested) + (_.for [/.overlaps?] + ..overlap) ))) diff --git a/stdlib/source/test/lux/abstract/monad/free.lux b/stdlib/source/test/lux/abstract/monad/free.lux index 5cae8ef16..5f71df542 100644 --- a/stdlib/source/test/lux/abstract/monad/free.lux +++ b/stdlib/source/test/lux/abstract/monad/free.lux @@ -43,15 +43,15 @@ (def: #export test Test (<| (_.covering /._) - (_.with-cover [/.Free]) + (_.for [/.Free]) ($_ _.and - (_.with-cover [/.functor] - ($functor.spec ..injection ..comparison (: (Functor (/.Free List)) - (/.functor list.functor)))) - (_.with-cover [/.apply] - ($apply.spec ..injection ..comparison (: (Apply (/.Free List)) - (/.apply list.functor)))) - (_.with-cover [/.monad] - ($monad.spec ..injection ..comparison (: (Monad (/.Free List)) - (/.monad list.functor)))) + (_.for [/.functor] + ($functor.spec ..injection ..comparison (: (Functor (/.Free List)) + (/.functor list.functor)))) + (_.for [/.apply] + ($apply.spec ..injection ..comparison (: (Apply (/.Free List)) + (/.apply list.functor)))) + (_.for [/.monad] + ($monad.spec ..injection ..comparison (: (Monad (/.Free List)) + (/.monad list.functor)))) ))) diff --git a/stdlib/source/test/lux/abstract/order.lux b/stdlib/source/test/lux/abstract/order.lux index 38479a79f..f45076a0c 100644 --- a/stdlib/source/test/lux/abstract/order.lux +++ b/stdlib/source/test/lux/abstract/order.lux @@ -34,8 +34,8 @@ (bit\= (\ leftO < left right) (\ rightO < left right))))))]]) ($_ _.and - (_.with-cover [/.functor] - ($contravariant.spec equivalence n.order /.functor)) + (_.for [/.functor] + ($contravariant.spec equivalence n.order /.functor)) (_.cover [/.Choice /.min /.max] (n.< (/.max n.order left right) (/.min n.order left right))) diff --git a/stdlib/source/test/lux/abstract/predicate.lux b/stdlib/source/test/lux/abstract/predicate.lux index 502e1c845..47875a6c4 100644 --- a/stdlib/source/test/lux/abstract/predicate.lux +++ b/stdlib/source/test/lux/abstract/predicate.lux @@ -39,19 +39,19 @@ (def: (= left right) (bit\= (left sample) (right sample)))))]]) - (_.with-cover [/.Predicate]) + (_.for [/.Predicate]) ($_ _.and - (_.with-cover [/.functor] - ($contravariant.spec equivalence (multiple? 2) /.functor)) + (_.for [/.functor] + ($contravariant.spec equivalence (multiple? 2) /.functor)) (let [generator (: (Random (/.Predicate Nat)) (|> random.nat (random.filter (|>> (n.= 0) not)) (\ ! map multiple?)))] ($_ _.and - (_.with-cover [/.union] - ($monoid.spec equivalence /.union generator)) - (_.with-cover [/.intersection] - ($monoid.spec equivalence /.intersection generator)))) + (_.for [/.union] + ($monoid.spec equivalence /.union generator)) + (_.for [/.intersection] + ($monoid.spec equivalence /.intersection generator)))) (_.cover [/.none] (bit\= false (/.none sample))) diff --git a/stdlib/source/test/lux/control/concurrency/actor.lux b/stdlib/source/test/lux/control/concurrency/actor.lux index 0f98a0b77..5c47eab5e 100644 --- a/stdlib/source/test/lux/control/concurrency/actor.lux +++ b/stdlib/source/test/lux/control/concurrency/actor.lux @@ -57,7 +57,7 @@ inc! (: (/.Mail Nat) (as-mail inc)) dec! (: (/.Mail Nat) (as-mail dec))]] (<| (_.covering /._) - (_.with-cover [/.Actor]) + (_.for [/.Actor]) ($_ _.and (_.cover [/.alive?] (io.run (do io.monad @@ -185,7 +185,7 @@ (..mailed? sent/dec?) (..mailed? poisoned?) (case obituary - (^ (#.Some [error final-state (list)])) + (^ (#.Some [error final-state (list poison-pill)])) (and (exception.match? /.poisoned error) (n.= (inc (inc initial-state)) final-state)) @@ -194,15 +194,14 @@ false)))))] (_.cover' [/.actor] verdict))) + (do ! [num-events (\ ! map (|>> (n.% 10) inc) random.nat) events (random.list num-events random.nat) num-observations (\ ! map (n.% num-events) random.nat) #let [expected (list.take num-observations events) sink (: (Atom (Row Nat)) - (atom.atom row.empty)) - [signal signal!] (: [(Promise Any) (Resolver Any)] - (promise.promise []))]] + (atom.atom row.empty))]] (wrap (do promise.monad [agent (promise.future (do {! io.monad} @@ -210,31 +209,18 @@ _ (/.observe (function (_ event stop) (function (_ events-seen self) (promise.future - (cond (n.< num-observations events-seen) - (do ! - [_ (atom.update (row.add event) sink)] - (wrap (#try.Success (inc events-seen)))) - - (n.= num-observations events-seen) - (do ! - [_ stop - _ (signal! [])] - (wrap (#try.Success (inc events-seen)))) - - (wrap (#try.Failure "YOLO")))))) + (if (n.< num-observations events-seen) + (do ! + [_ (atom.update (row.add event) sink)] + (wrap (#try.Success (inc events-seen)))) + (do ! + [_ stop] + (wrap (#try.Failure "YOLO"))))))) (frp.sequential 0 events) agent)] (wrap agent))) - _ signal - actual (promise.future (atom.read sink)) - died? (promise.time-out 1,000 (/.await agent)) - #let [died? (case died? - (#.Some _) - true - - #.None - false)]] + _ (/.await agent) + actual (promise.future (atom.read sink))] (_.cover' [/.observe] - (and (\ (list.equivalence n.equivalence) = expected (row.to-list actual)) - (not died?)))))) + (\ (list.equivalence n.equivalence) = expected (row.to-list actual)))))) )))) diff --git a/stdlib/source/test/lux/control/concurrency/frp.lux b/stdlib/source/test/lux/control/concurrency/frp.lux index 6b10df1d8..709c756a2 100644 --- a/stdlib/source/test/lux/control/concurrency/frp.lux +++ b/stdlib/source/test/lux/control/concurrency/frp.lux @@ -60,12 +60,12 @@ (n.= distint/1 value)))))) shift random.nat] ($_ _.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)) (_.cover [/.Channel /.Sink /.channel] (case (io.run diff --git a/stdlib/source/test/lux/control/concurrency/semaphore.lux b/stdlib/source/test/lux/control/concurrency/semaphore.lux index 8c31b9796..7e632b8cb 100644 --- a/stdlib/source/test/lux/control/concurrency/semaphore.lux +++ b/stdlib/source/test/lux/control/concurrency/semaphore.lux @@ -28,99 +28,99 @@ (def: semaphore Test - (_.with-cover [/.Semaphore] - ($_ _.and - (do {! random.monad} - [initial-open-positions (|> random.nat (\ ! map (|>> (n.% 10) (n.max 1)))) - #let [semaphore (/.semaphore initial-open-positions)]] - (wrap (do promise.monad - [result (promise.time-out 10 (/.wait semaphore))] - (_.cover' [/.semaphore] - (case result - (#.Some _) - true + (_.for [/.Semaphore] + ($_ _.and + (do {! random.monad} + [initial-open-positions (|> random.nat (\ ! map (|>> (n.% 10) (n.max 1)))) + #let [semaphore (/.semaphore initial-open-positions)]] + (wrap (do promise.monad + [result (promise.time-out 10 (/.wait semaphore))] + (_.cover' [/.semaphore] + (case result + (#.Some _) + true - #.None - false))))) - (do {! random.monad} - [initial-open-positions (|> random.nat (\ ! map (|>> (n.% 10) (n.max 1)))) - #let [semaphore (/.semaphore initial-open-positions)]] - (wrap (do {! promise.monad} - [_ (monad.map ! /.wait (list.repeat initial-open-positions semaphore)) - result (promise.time-out 10 (/.wait semaphore))] - (_.cover' [/.wait] - (case result - (#.Some _) - false + #.None + false))))) + (do {! random.monad} + [initial-open-positions (|> random.nat (\ ! map (|>> (n.% 10) (n.max 1)))) + #let [semaphore (/.semaphore initial-open-positions)]] + (wrap (do {! promise.monad} + [_ (monad.map ! /.wait (list.repeat initial-open-positions semaphore)) + result (promise.time-out 10 (/.wait semaphore))] + (_.cover' [/.wait] + (case result + (#.Some _) + false - #.None - true))))) - (do {! random.monad} - [initial-open-positions (|> random.nat (\ ! map (|>> (n.% 10) (n.max 1)))) - #let [semaphore (/.semaphore initial-open-positions)]] - (wrap (do {! promise.monad} - [_ (monad.map ! /.wait (list.repeat initial-open-positions semaphore)) - #let [block (/.wait semaphore)] - result/0 (promise.time-out 10 block) - open-positions (/.signal semaphore) - result/1 (promise.time-out 10 block)] - (_.cover' [/.signal] - (case [result/0 result/1 open-positions] - [#.None (#.Some _) (#try.Success +0)] - true + #.None + true))))) + (do {! random.monad} + [initial-open-positions (|> random.nat (\ ! map (|>> (n.% 10) (n.max 1)))) + #let [semaphore (/.semaphore initial-open-positions)]] + (wrap (do {! promise.monad} + [_ (monad.map ! /.wait (list.repeat initial-open-positions semaphore)) + #let [block (/.wait semaphore)] + result/0 (promise.time-out 10 block) + open-positions (/.signal semaphore) + result/1 (promise.time-out 10 block)] + (_.cover' [/.signal] + (case [result/0 result/1 open-positions] + [#.None (#.Some _) (#try.Success +0)] + true - _ - false))))) - (do {! random.monad} - [initial-open-positions (|> random.nat (\ ! map (|>> (n.% 10) (n.max 1)))) - #let [semaphore (/.semaphore initial-open-positions)]] - (wrap (do promise.monad - [outcome (/.signal semaphore)] - (_.cover' [/.semaphore-is-maxed-out] - (case outcome - (#try.Failure error) - (exception.match? /.semaphore-is-maxed-out error) + _ + false))))) + (do {! random.monad} + [initial-open-positions (|> random.nat (\ ! map (|>> (n.% 10) (n.max 1)))) + #let [semaphore (/.semaphore initial-open-positions)]] + (wrap (do promise.monad + [outcome (/.signal semaphore)] + (_.cover' [/.semaphore-is-maxed-out] + (case outcome + (#try.Failure error) + (exception.match? /.semaphore-is-maxed-out error) - _ - false))))) - ))) + _ + false))))) + ))) (def: mutex Test - (_.with-cover [/.Mutex] - ($_ _.and - (do {! random.monad} - [repetitions (|> random.nat (\ ! map (|>> (n.% 100) (n.max 10)))) - #let [resource (atom.atom "") - expected-As (text.join-with "" (list.repeat repetitions "A")) - expected-Bs (text.join-with "" (list.repeat repetitions "B")) - mutex (/.mutex []) - processA (<| (/.synchronize mutex) - io.io - promise.future - (do {! io.monad} - [_ (<| (monad.seq !) - (list.repeat repetitions) - (atom.update (|>> (format "A")) resource))] - (wrap []))) - processB (<| (/.synchronize mutex) - io.io - promise.future - (do {! io.monad} - [_ (<| (monad.seq !) - (list.repeat repetitions) - (atom.update (|>> (format "B")) resource))] - (wrap [])))]] - (wrap (do promise.monad - [_ processA - _ processB - #let [outcome (io.run (atom.read resource))]] - (_.cover' [/.mutex /.synchronize] - (or (text\= (format expected-As expected-Bs) - outcome) - (text\= (format expected-Bs expected-As) - outcome)))))) - ))) + (_.for [/.Mutex] + ($_ _.and + (do {! random.monad} + [repetitions (|> random.nat (\ ! map (|>> (n.% 100) (n.max 10)))) + #let [resource (atom.atom "") + expected-As (text.join-with "" (list.repeat repetitions "A")) + expected-Bs (text.join-with "" (list.repeat repetitions "B")) + mutex (/.mutex []) + processA (<| (/.synchronize mutex) + io.io + promise.future + (do {! io.monad} + [_ (<| (monad.seq !) + (list.repeat repetitions) + (atom.update (|>> (format "A")) resource))] + (wrap []))) + processB (<| (/.synchronize mutex) + io.io + promise.future + (do {! io.monad} + [_ (<| (monad.seq !) + (list.repeat repetitions) + (atom.update (|>> (format "B")) resource))] + (wrap [])))]] + (wrap (do promise.monad + [_ processA + _ processB + #let [outcome (io.run (atom.read resource))]] + (_.cover' [/.mutex /.synchronize] + (or (text\= (format expected-As expected-Bs) + outcome) + (text\= (format expected-Bs expected-As) + outcome)))))) + ))) (def: (waiter resource barrier id) (-> (Atom Text) /.Barrier Nat (Promise Any)) @@ -131,43 +131,43 @@ (def: barrier Test - (_.with-cover [/.Barrier] - ($_ _.and - (do random.monad - [raw random.nat] - (_.cover [/.Limit /.limit] - (case [raw (/.limit raw)] - [0 #.None] - true - - [_ (#.Some limit)] - (and (n.> 0 raw) - (n.= raw (refinement.un-refine limit))) + (_.for [/.Barrier] + ($_ _.and + (do random.monad + [raw random.nat] + (_.cover [/.Limit /.limit] + (case [raw (/.limit raw)] + [0 #.None] + true + + [_ (#.Some limit)] + (and (n.> 0 raw) + (n.= raw (refinement.un-refine limit))) - _ - false))) - (do {! random.monad} - [limit (|> random.nat (\ ! map (|>> (n.% 10) (n.max 1)))) - #let [barrier (/.barrier (maybe.assume (/.limit limit))) - resource (atom.atom "")]] - (wrap (do {! promise.monad} - [#let [ending (|> "_" - (list.repeat limit) - (text.join-with "")) - ids (enum.range n.enum 0 (dec limit)) - waiters (list\map (function (_ id) - (exec (io.run (atom.update (|>> (format "_")) resource)) - (waiter resource barrier id))) - ids)] - _ (monad.seq ! waiters) - #let [outcome (io.run (atom.read resource))]] - (_.cover' [/.barrier /.block] - (and (text.ends-with? ending outcome) - (list.every? (function (_ id) - (text.contains? (%.nat id) outcome)) - ids) - ))))) - ))) + _ + false))) + (do {! random.monad} + [limit (|> random.nat (\ ! map (|>> (n.% 10) (n.max 1)))) + #let [barrier (/.barrier (maybe.assume (/.limit limit))) + resource (atom.atom "")]] + (wrap (do {! promise.monad} + [#let [ending (|> "_" + (list.repeat limit) + (text.join-with "")) + ids (enum.range n.enum 0 (dec limit)) + waiters (list\map (function (_ id) + (exec (io.run (atom.update (|>> (format "_")) resource)) + (waiter resource barrier id))) + ids)] + _ (monad.seq ! waiters) + #let [outcome (io.run (atom.read resource))]] + (_.cover' [/.barrier /.block] + (and (text.ends-with? ending outcome) + (list.every? (function (_ id) + (text.contains? (%.nat id) outcome)) + ids) + ))))) + ))) (def: #export test Test diff --git a/stdlib/source/test/lux/control/concurrency/stm.lux b/stdlib/source/test/lux/control/concurrency/stm.lux index 1e7dee4e4..ade5dd70d 100644 --- a/stdlib/source/test/lux/control/concurrency/stm.lux +++ b/stdlib/source/test/lux/control/concurrency/stm.lux @@ -43,12 +43,12 @@ expected random.nat iterations-per-process (|> random.nat (\ ! map (n.% 100)))] ($_ _.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 promise.monad [actual (/.commit (\ /.monad wrap expected))] diff --git a/stdlib/source/test/lux/control/continuation.lux b/stdlib/source/test/lux/control/continuation.lux index 0c09dcb23..b22705489 100644 --- a/stdlib/source/test/lux/control/continuation.lux +++ b/stdlib/source/test/lux/control/continuation.lux @@ -35,14 +35,14 @@ #let [(^open "_\.") /.apply (^open "_\.") /.monad] elems (random.list 3 random.nat)]) - (_.with-cover [/.Cont]) + (_.for [/.Cont]) ($_ _.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)) (_.cover [/.run] (n.= sample (/.run (_\wrap sample)))) diff --git a/stdlib/source/test/lux/control/exception.lux b/stdlib/source/test/lux/control/exception.lux index 7f0578c5d..8f890018c 100644 --- a/stdlib/source/test/lux/control/exception.lux +++ b/stdlib/source/test/lux/control/exception.lux @@ -34,7 +34,7 @@ field1 report-element value1 report-element] (<| (_.covering /._) - (_.with-cover [/.Exception]) + (_.for [/.Exception]) ($_ _.and (_.cover [/.return] (case (/.return expected) diff --git a/stdlib/source/test/lux/control/function.lux b/stdlib/source/test/lux/control/function.lux index 5775b9085..3bd59dc41 100644 --- a/stdlib/source/test/lux/control/function.lux +++ b/stdlib/source/test/lux/control/function.lux @@ -33,8 +33,8 @@ (right extra))))) generator (: (Random (-> Nat Nat)) (\ ! map n.- random.nat))] - (_.with-cover [/.monoid] - ($monoid.spec equivalence /.monoid generator))) + (_.for [/.monoid] + ($monoid.spec equivalence /.monoid generator))) (_.cover [/.identity] (n.= expected diff --git a/stdlib/source/test/lux/control/function/memo.lux b/stdlib/source/test/lux/control/function/memo.lux index 6350320b5..0180196b2 100644 --- a/stdlib/source/test/lux/control/function/memo.lux +++ b/stdlib/source/test/lux/control/function/memo.lux @@ -51,7 +51,7 @@ (<| (_.covering /._) (do {! random.monad} [input (|> random.nat (\ ! map (|>> (n.% 5) (n.+ 23))))]) - (_.with-cover [/.Memo]) + (_.for [/.Memo]) ($_ _.and (_.cover [/.closed /.none] (io.run diff --git a/stdlib/source/test/lux/control/function/mixin.lux b/stdlib/source/test/lux/control/function/mixin.lux index e9308e5bb..0c343a685 100644 --- a/stdlib/source/test/lux/control/function/mixin.lux +++ b/stdlib/source/test/lux/control/function/mixin.lux @@ -42,94 +42,94 @@ (list\map inc) (list\fold n.* 1))]]) ($_ _.and - (_.with-cover [/.Mixin] - ($_ _.and - (_.with-cover [/.monoid] - ($monoid.spec equivalence /.monoid generator)) - - (_.cover [/.mixin] - (let [factorial (/.mixin - (function (_ delegate recur input) - (case input - (^or 0 1) 1 - _ (n.* input (recur (dec input))))))] - (n.= expected - (factorial input)))) - (_.cover [/.inherit] - (let [bottom (: (/.Mixin Nat Nat) - (function (_ delegate recur input) - (case input - (^or 0 1) 1 - _ (delegate input)))) - multiplication (: (/.Mixin Nat Nat) - (function (_ delegate recur input) - (n.* input (recur (dec input))))) - factorial (/.mixin (/.inherit bottom multiplication))] - (n.= expected - (factorial input)))) - (_.cover [/.nothing] - (let [loop (: (/.Mixin Nat Nat) - (function (_ delegate recur input) - (case input - (^or 0 1) 1 - _ (n.* input (delegate (dec input)))))) - left (/.mixin (/.inherit /.nothing loop)) - right (/.mixin (/.inherit loop /.nothing))] - (and (n.= expected - (left input)) + (_.for [/.Mixin] + ($_ _.and + (_.for [/.monoid] + ($monoid.spec equivalence /.monoid generator)) + + (_.cover [/.mixin] + (let [factorial (/.mixin + (function (_ delegate recur input) + (case input + (^or 0 1) 1 + _ (n.* input (recur (dec input))))))] (n.= expected - (right input))))) - (_.cover [/.advice] - (let [bottom (: (/.Mixin Nat Nat) - (function (_ delegate recur input) - 1)) - bottom? (: (Predicate Nat) - (function (_ input) - (case input - (^or 0 1) true - _ false))) - multiplication (: (/.Mixin Nat Nat) - (function (_ delegate recur input) - (n.* input (recur (dec input))))) - factorial (/.mixin (/.inherit (/.advice bottom? bottom) - multiplication))] - (n.= expected - (factorial input)))) - (_.cover [/.before] - (let [implant (: (-> Nat (State Nat [])) - (function (_ input) - (function (_ state) - [shift []]))) - meld (: (/.Mixin Nat (State Nat Nat)) - (function (_ delegate recur input) - (function (_ state) - [state (n.+ state input)]))) - function (/.mixin (/.inherit (/.before state.monad implant) - meld))] - (n.= (n.+ shift input) - (|> input function (state.run dummy) product.right)))) - (_.cover [/.after] - (let [implant (: (-> Nat Nat (State Nat [])) - (function (_ input output) - (function (_ state) - [shift []]))) - meld (: (/.Mixin Nat (State Nat Nat)) - (function (_ delegate recur input) - (function (_ state) - [state (n.+ state input)]))) - function (/.mixin (/.inherit (/.after state.monad implant) - meld))] - (n.= (n.+ dummy input) - (|> input function (state.run dummy) product.right)))) - )) - (_.with-cover [/.Recursive] - (_.cover [/.from-recursive] - (let [factorial (/.mixin - (/.from-recursive - (function (_ recur input) - (case input - (^or 0 1) 1 - _ (n.* input (recur (dec input)))))))] - (n.= expected - (factorial input))))) + (factorial input)))) + (_.cover [/.inherit] + (let [bottom (: (/.Mixin Nat Nat) + (function (_ delegate recur input) + (case input + (^or 0 1) 1 + _ (delegate input)))) + multiplication (: (/.Mixin Nat Nat) + (function (_ delegate recur input) + (n.* input (recur (dec input))))) + factorial (/.mixin (/.inherit bottom multiplication))] + (n.= expected + (factorial input)))) + (_.cover [/.nothing] + (let [loop (: (/.Mixin Nat Nat) + (function (_ delegate recur input) + (case input + (^or 0 1) 1 + _ (n.* input (delegate (dec input)))))) + left (/.mixin (/.inherit /.nothing loop)) + right (/.mixin (/.inherit loop /.nothing))] + (and (n.= expected + (left input)) + (n.= expected + (right input))))) + (_.cover [/.advice] + (let [bottom (: (/.Mixin Nat Nat) + (function (_ delegate recur input) + 1)) + bottom? (: (Predicate Nat) + (function (_ input) + (case input + (^or 0 1) true + _ false))) + multiplication (: (/.Mixin Nat Nat) + (function (_ delegate recur input) + (n.* input (recur (dec input))))) + factorial (/.mixin (/.inherit (/.advice bottom? bottom) + multiplication))] + (n.= expected + (factorial input)))) + (_.cover [/.before] + (let [implant (: (-> Nat (State Nat [])) + (function (_ input) + (function (_ state) + [shift []]))) + meld (: (/.Mixin Nat (State Nat Nat)) + (function (_ delegate recur input) + (function (_ state) + [state (n.+ state input)]))) + function (/.mixin (/.inherit (/.before state.monad implant) + meld))] + (n.= (n.+ shift input) + (|> input function (state.run dummy) product.right)))) + (_.cover [/.after] + (let [implant (: (-> Nat Nat (State Nat [])) + (function (_ input output) + (function (_ state) + [shift []]))) + meld (: (/.Mixin Nat (State Nat Nat)) + (function (_ delegate recur input) + (function (_ state) + [state (n.+ state input)]))) + function (/.mixin (/.inherit (/.after state.monad implant) + meld))] + (n.= (n.+ dummy input) + (|> input function (state.run dummy) product.right)))) + )) + (_.for [/.Recursive] + (_.cover [/.from-recursive] + (let [factorial (/.mixin + (/.from-recursive + (function (_ recur input) + (case input + (^or 0 1) 1 + _ (n.* input (recur (dec input)))))))] + (n.= expected + (factorial input))))) ))) diff --git a/stdlib/source/test/lux/control/io.lux b/stdlib/source/test/lux/control/io.lux index 596f29b11..937d73870 100644 --- a/stdlib/source/test/lux/control/io.lux +++ b/stdlib/source/test/lux/control/io.lux @@ -30,17 +30,17 @@ (def: #export test Test (<| (_.covering /._) - (_.with-cover [/.IO]) + (_.for [/.IO]) (do random.monad [sample random.nat exit-code random.int] ($_ _.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)) (_.cover [/.run /.io] (n.= sample diff --git a/stdlib/source/test/lux/control/parser.lux b/stdlib/source/test/lux/control/parser.lux index 6710faaab..26cf4ebd1 100644 --- a/stdlib/source/test/lux/control/parser.lux +++ b/stdlib/source/test/lux/control/parser.lux @@ -350,14 +350,14 @@ failure (random.ascii 1) assertion (random.ascii 1)] (<| (_.covering /._) - (_.with-cover [/.Parser]) + (_.for [/.Parser]) ($_ _.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)) (_.cover [/.run] (|> (/.run (\ /.monad wrap expected) (list)) diff --git a/stdlib/source/test/lux/control/parser/analysis.lux b/stdlib/source/test/lux/control/parser/analysis.lux index d4b4e533f..d3e966715 100644 --- a/stdlib/source/test/lux/control/parser/analysis.lux +++ b/stdlib/source/test/lux/control/parser/analysis.lux @@ -47,7 +47,7 @@ (def: #export test Test (<| (_.covering /._) - (_.with-cover [/.Parser]) + (_.for [/.Parser]) (do {! random.monad} [] (`` ($_ _.and diff --git a/stdlib/source/test/lux/control/parser/binary.lux b/stdlib/source/test/lux/control/parser/binary.lux index 94225be79..b967df5db 100644 --- a/stdlib/source/test/lux/control/parser/binary.lux +++ b/stdlib/source/test/lux/control/parser/binary.lux @@ -122,7 +122,7 @@ (def: size Test - (<| (_.with-cover [/.Size]) + (<| (_.for [/.Size]) (`` ($_ _.and (~~ (template [ ] [(do {! random.monad} @@ -319,7 +319,7 @@ (def: #export test Test (<| (_.covering /._) - (_.with-cover [/.Parser]) + (_.for [/.Parser]) (`` ($_ _.and (_.cover [/.run /.any format.no-op format.instance] diff --git a/stdlib/source/test/lux/control/parser/cli.lux b/stdlib/source/test/lux/control/parser/cli.lux index 6be78b640..60bd3f9fe 100644 --- a/stdlib/source/test/lux/control/parser/cli.lux +++ b/stdlib/source/test/lux/control/parser/cli.lux @@ -28,7 +28,7 @@ (def: #export test Test (<| (_.covering /._) - (_.with-cover [/.Parser]) + (_.for [/.Parser]) (do {! random.monad} [expected (\ ! map n\encode random.nat) #let [random-dummy (random.filter (|>> (text\= expected) not) diff --git a/stdlib/source/test/lux/control/parser/code.lux b/stdlib/source/test/lux/control/parser/code.lux index 3955d760f..0c2c42c8e 100644 --- a/stdlib/source/test/lux/control/parser/code.lux +++ b/stdlib/source/test/lux/control/parser/code.lux @@ -41,7 +41,7 @@ (def: #export test Test (<| (_.covering /._) - (_.with-cover [/.Parser]) + (_.for [/.Parser]) (`` ($_ _.and (do {! random.monad} [expected (\ ! map code.bit random.bit)] diff --git a/stdlib/source/test/lux/control/parser/environment.lux b/stdlib/source/test/lux/control/parser/environment.lux index 2c2263862..117693fe9 100644 --- a/stdlib/source/test/lux/control/parser/environment.lux +++ b/stdlib/source/test/lux/control/parser/environment.lux @@ -21,7 +21,7 @@ (def: #export test Test (<| (_.covering /._) - (_.with-cover [/.Parser]) + (_.for [/.Environment /.Parser]) ($_ _.and (_.cover [/.empty] (dictionary.empty? /.empty)) @@ -34,7 +34,7 @@ (do random.monad [property (random.ascii/alpha 1) expected (random.ascii/alpha 1)] - (_.cover [/.property] + (_.cover [/.Property /.property] (|> /.empty (dictionary.put property expected) (/.run (/.property property)) diff --git a/stdlib/source/test/lux/control/parser/json.lux b/stdlib/source/test/lux/control/parser/json.lux index e9bd03ef6..cb6928062 100644 --- a/stdlib/source/test/lux/control/parser/json.lux +++ b/stdlib/source/test/lux/control/parser/json.lux @@ -42,7 +42,7 @@ (def: #export test Test (<| (_.covering /._) - (_.with-cover [/.Parser]) + (_.for [/.Parser]) (`` ($_ _.and (do {! random.monad} [expected (\ ! map (|>> #json.String) (random.unicode 1))] diff --git a/stdlib/source/test/lux/control/parser/synthesis.lux b/stdlib/source/test/lux/control/parser/synthesis.lux index d7709687f..daf44e7ae 100644 --- a/stdlib/source/test/lux/control/parser/synthesis.lux +++ b/stdlib/source/test/lux/control/parser/synthesis.lux @@ -159,7 +159,7 @@ (def: #export test Test (<| (_.covering /._) - (_.with-cover [/.Parser]) + (_.for [/.Parser]) ($_ _.and (do {! random.monad} [expected (\ ! map (|>> synthesis.i64) random.nat)] @@ -192,9 +192,9 @@ (!expect (#try.Success #1))) (|> (/.run (<>.before /.any /.end?) (list dummy)) (!expect (#try.Success #0)))))) - (_.with-cover [/.cannot-parse] - ($_ _.and - ..simple - ..complex - )) + (_.for [/.cannot-parse] + ($_ _.and + ..simple + ..complex + )) ))) diff --git a/stdlib/source/test/lux/control/parser/text.lux b/stdlib/source/test/lux/control/parser/text.lux index 74fc6a8fd..5a2245401 100644 --- a/stdlib/source/test/lux/control/parser/text.lux +++ b/stdlib/source/test/lux/control/parser/text.lux @@ -291,7 +291,7 @@ (def: #export test Test (<| (_.covering /._) - (_.with-cover [/.Parser]) + (_.for [/.Parser]) ($_ _.and (do {! random.monad} [sample (random.unicode 1)] diff --git a/stdlib/source/test/lux/control/parser/tree.lux b/stdlib/source/test/lux/control/parser/tree.lux index 93fec1175..f4f3da769 100644 --- a/stdlib/source/test/lux/control/parser/tree.lux +++ b/stdlib/source/test/lux/control/parser/tree.lux @@ -51,7 +51,7 @@ (def: #export test Test (<| (_.covering /._) - (_.with-cover [/.Parser]) + (_.for [/.Parser]) ($_ _.and (!cover [/.run /.value] /.value diff --git a/stdlib/source/test/lux/control/parser/type.lux b/stdlib/source/test/lux/control/parser/type.lux index 705c9ef24..9d8d498c5 100644 --- a/stdlib/source/test/lux/control/parser/type.lux +++ b/stdlib/source/test/lux/control/parser/type.lux @@ -33,7 +33,7 @@ (def: matches Test - (<| (_.with-cover [/.types-do-not-match]) + (<| (_.for [/.types-do-not-match]) (do {! random.monad} [expected ..primitive dummy (random.filter (|>> (type\= expected) not) @@ -118,7 +118,7 @@ (def: #export test Test (<| (_.covering /._) - (_.with-cover [/.Parser]) + (_.for [/.Parser]) ($_ _.and (do {! random.monad} [expected ..primitive] diff --git a/stdlib/source/test/lux/control/parser/xml.lux b/stdlib/source/test/lux/control/parser/xml.lux index 70e881cd2..c17faa6b0 100644 --- a/stdlib/source/test/lux/control/parser/xml.lux +++ b/stdlib/source/test/lux/control/parser/xml.lux @@ -8,13 +8,14 @@ ["." exception]] [data ["." text ("#\." equivalence)] - ["." name] + ["." name ("#\." equivalence)] [format ["." xml]] [number ["n" nat]] [collection - ["." dictionary]]] + ["." dictionary] + ["." list]]] [math ["." random (#+ Random)]] [macro @@ -55,7 +56,7 @@ (def: #export test Test (<| (_.covering /._) - (_.with-cover [/.Parser]) + (_.for [/.Parser]) ($_ _.and (do {! random.monad} [expected (random.ascii/alpha 1)] @@ -71,6 +72,15 @@ (_.cover [/.ignore] (|> (/.run /.ignore (#xml.Text expected)) (!expect (#try.Success []))))) + (do {! random.monad} + [expected ..random-tag] + (_.cover [/.tag] + (|> (/.run (do //.monad + [actual /.tag + _ /.ignore] + (wrap (name\= expected actual))) + (#xml.Node expected (dictionary.new name.hash) (list))) + (!expect (#try.Success #1))))) (do {! random.monad} [expected ..random-tag] (_.cover [/.node] @@ -168,4 +178,33 @@ [_ (/.node [expected expected])] /.ignore))) (#xml.Text expected)]]) + (do {! random.monad} + [#let [node (: (-> xml.Tag (List xml.XML) xml.XML) + (function (_ tag children) + (#xml.Node tag (dictionary.new name.hash) children)))] + parent ..random-tag + right ..random-tag + wrong (random.filter (|>> (name\= right) not) + ..random-tag) + #let [parser (/.children + (do //.monad + [_ (/.somewhere (/.node right)) + _ (//.some /.ignore)] + (wrap [])))] + repetitions (\ ! map (n.% 10) random.nat)] + ($_ _.and + (_.cover [/.somewhere] + (|> (/.run parser + (node parent + (list.concat (list (list.repeat repetitions (node wrong (list))) + (list (node right (list))) + (list.repeat repetitions (node wrong (list))))))) + (!expect (#try.Success [])))) + (_.cover [/.nowhere] + (|> (/.run parser + (node parent + (list.repeat repetitions (node wrong (list))))) + (!expect (^multi (#try.Failure error) + (exception.match? /.nowhere error))))) + )) ))) diff --git a/stdlib/source/test/lux/control/reader.lux b/stdlib/source/test/lux/control/reader.lux index f211948e4..cd8204b0c 100644 --- a/stdlib/source/test/lux/control/reader.lux +++ b/stdlib/source/test/lux/control/reader.lux @@ -31,17 +31,17 @@ (def: #export test Test (<| (_.covering /._) - (_.with-cover [/.Reader]) + (_.for [/.Reader]) (do random.monad [sample random.nat factor random.nat] ($_ _.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)) (_.cover [/.run /.ask] (n.= sample diff --git a/stdlib/source/test/lux/control/region.lux b/stdlib/source/test/lux/control/region.lux index 088f3dc7c..cfdbf5148 100644 --- a/stdlib/source/test/lux/control/region.lux +++ b/stdlib/source/test/lux/control/region.lux @@ -77,22 +77,22 @@ (def: #export test Test (<| (_.covering /._) - (_.with-cover [/.Region]) + (_.for [/.Region]) (do {! random.monad} [expected-clean-ups (|> random.nat (\ ! map (|>> (n.% 100) (n.max 1))))] ($_ _.and - (_.with-cover [/.functor] - ($functor.spec ..injection ..comparison (: (All [! r] - (Functor (Region r (thread.Thread !)))) - (/.functor thread.functor)))) - (_.with-cover [/.apply] - ($apply.spec ..injection ..comparison (: (All [! r] - (Apply (Region r (thread.Thread !)))) - (/.apply thread.monad)))) - (_.with-cover [/.monad] - ($monad.spec ..injection ..comparison (: (All [! r] - (Monad (Region r (thread.Thread !)))) - (/.monad thread.monad)))) + (_.for [/.functor] + ($functor.spec ..injection ..comparison (: (All [! r] + (Functor (Region r (thread.Thread !)))) + (/.functor thread.functor)))) + (_.for [/.apply] + ($apply.spec ..injection ..comparison (: (All [! r] + (Apply (Region r (thread.Thread !)))) + (/.apply thread.monad)))) + (_.for [/.monad] + ($monad.spec ..injection ..comparison (: (All [! r] + (Monad (Region r (thread.Thread !)))) + (/.monad thread.monad)))) (_.cover [/.run] (thread.run diff --git a/stdlib/source/test/lux/control/security/capability.lux b/stdlib/source/test/lux/control/security/capability.lux index f8f757641..50a2d04d8 100644 --- a/stdlib/source/test/lux/control/security/capability.lux +++ b/stdlib/source/test/lux/control/security/capability.lux @@ -29,17 +29,17 @@ base random.nat #let [expected (n.+ shift base)] pass-through (random.ascii 1)] - (_.with-cover [/.Capability] - ($_ _.and - (_.cover [/.capability: /.use] - (let [capability (..can-shift (function (_ [no-op raw]) - [no-op (n.+ shift raw)])) - [untouched actual] (/.use capability [pass-through base])] - (and (is? pass-through untouched) - (n.= expected actual)))) - (wrap (let [capability (..can-io (function (_ _) (io.io expected)))] - (do promise.monad - [actual (/.use (/.async capability) [])] - (_.cover' [/.async] - (n.= expected actual))))) - ))))) + (_.for [/.Capability] + ($_ _.and + (_.cover [/.capability: /.use] + (let [capability (..can-shift (function (_ [no-op raw]) + [no-op (n.+ shift raw)])) + [untouched actual] (/.use capability [pass-through base])] + (and (is? pass-through untouched) + (n.= expected actual)))) + (wrap (let [capability (..can-io (function (_ _) (io.io expected)))] + (do promise.monad + [actual (/.use (/.async capability) [])] + (_.cover' [/.async] + (n.= expected actual))))) + ))))) diff --git a/stdlib/source/test/lux/control/security/policy.lux b/stdlib/source/test/lux/control/security/policy.lux index bb5144fd1..647526b6c 100644 --- a/stdlib/source/test/lux/control/security/policy.lux +++ b/stdlib/source/test/lux/control/security/policy.lux @@ -71,22 +71,22 @@ (def: #export test Test (<| (_.covering /._) - (_.with-cover [/.Policy - /.Can-Upgrade /.Can-Downgrade]) + (_.for [/.Policy + /.Can-Upgrade /.Can-Downgrade]) (do random.monad [#let [policy-0 (policy [])] raw-password (random.ascii 10) #let [password (\ policy-0 password raw-password)]] ($_ _.and - (_.with-cover [/.Privacy /.Private /.Can-Conceal /.Can-Reveal - /.Safety /.Safe /.Can-Trust /.Can-Distrust] - ($_ _.and - (_.with-cover [/.functor] - ($functor.spec (..injection (\ policy-0 can-upgrade)) (..comparison (\ policy-0 can-downgrade)) /.functor)) - (_.with-cover [/.apply] - ($apply.spec (..injection (\ policy-0 can-upgrade)) (..comparison (\ policy-0 can-downgrade)) /.apply)) - (_.with-cover [/.monad] - ($monad.spec (..injection (\ policy-0 can-upgrade)) (..comparison (\ policy-0 can-downgrade)) /.monad)))) + (_.for [/.Privacy /.Private /.Can-Conceal /.Can-Reveal + /.Safety /.Safe /.Can-Trust /.Can-Distrust] + ($_ _.and + (_.for [/.functor] + ($functor.spec (..injection (\ policy-0 can-upgrade)) (..comparison (\ policy-0 can-downgrade)) /.functor)) + (_.for [/.apply] + ($apply.spec (..injection (\ policy-0 can-upgrade)) (..comparison (\ policy-0 can-downgrade)) /.apply)) + (_.for [/.monad] + ($monad.spec (..injection (\ policy-0 can-upgrade)) (..comparison (\ policy-0 can-downgrade)) /.monad)))) (_.cover [/.Privilege /.Context /.with-policy] (and (\ policy-0 = password password) diff --git a/stdlib/source/test/lux/control/state.lux b/stdlib/source/test/lux/control/state.lux index 60f06dbef..4d6772069 100644 --- a/stdlib/source/test/lux/control/state.lux +++ b/stdlib/source/test/lux/control/state.lux @@ -73,12 +73,12 @@ [state random.nat value random.nat] ($_ _.and - (_.with-cover [/.functor] - ($functor.spec ..injection (..comparison state) /.functor)) - (_.with-cover [/.apply] - ($apply.spec ..injection (..comparison state) /.apply)) - (_.with-cover [/.monad] - ($monad.spec ..injection (..comparison state) /.monad)) + (_.for [/.functor] + ($functor.spec ..injection (..comparison state) /.functor)) + (_.for [/.apply] + ($apply.spec ..injection (..comparison state) /.apply)) + (_.for [/.monad] + ($monad.spec ..injection (..comparison state) /.monad)) ))) (def: loops diff --git a/stdlib/source/test/lux/control/thread.lux b/stdlib/source/test/lux/control/thread.lux index dfc5e7306..cedd55530 100644 --- a/stdlib/source/test/lux/control/thread.lux +++ b/stdlib/source/test/lux/control/thread.lux @@ -34,50 +34,50 @@ factor random.nat] (<| (_.covering /._) ($_ _.and - (_.with-cover [/.Thread] - ($_ _.and - (_.cover [/.run] - (n.= sample - (|> sample - (\ /.monad wrap) - /.run))) - (_.cover [/.io] - (n.= sample - (|> sample - (\ /.monad wrap) - /.io - io.run))) - - (_.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 [/.Thread] + ($_ _.and + (_.cover [/.run] + (n.= sample + (|> sample + (\ /.monad wrap) + /.run))) + (_.cover [/.io] + (n.= sample + (|> sample + (\ /.monad wrap) + /.io + io.run))) + + (_.for [/.functor] + ($functor.spec ..injection ..comparison /.functor)) + (_.for [/.apply] + ($apply.spec ..injection ..comparison /.apply)) + (_.for [/.monad] + ($monad.spec ..injection ..comparison /.monad)) + )) - (_.with-cover [/.Box /.box] - ($_ _.and - (_.cover [/.read] - (n.= sample - (/.run (: (All [!] (Thread ! Nat)) - (do /.monad - [box (/.box sample)] - (/.read box)))))) + (_.for [/.Box /.box] + ($_ _.and + (_.cover [/.read] + (n.= sample + (/.run (: (All [!] (Thread ! Nat)) + (do /.monad + [box (/.box sample)] + (/.read box)))))) - (_.cover [/.write] - (n.= factor - (/.run (: (All [!] (Thread ! Nat)) - (do /.monad - [box (/.box sample) - _ (/.write factor box)] - (/.read box)))))) + (_.cover [/.write] + (n.= factor + (/.run (: (All [!] (Thread ! Nat)) + (do /.monad + [box (/.box sample) + _ (/.write factor box)] + (/.read box)))))) - (_.cover [/.update] - (n.= (n.* factor sample) - (/.run (: (All [!] (Thread ! Nat)) - (do /.monad - [box (/.box sample) - old (/.update (n.* factor) box)] - (/.read box)))))))) + (_.cover [/.update] + (n.= (n.* factor sample) + (/.run (: (All [!] (Thread ! Nat)) + (do /.monad + [box (/.box sample) + old (/.update (n.* factor) box)] + (/.read box)))))))) )))) diff --git a/stdlib/source/test/lux/control/try.lux b/stdlib/source/test/lux/control/try.lux index cc01b7337..4238980d9 100644 --- a/stdlib/source/test/lux/control/try.lux +++ b/stdlib/source/test/lux/control/try.lux @@ -39,21 +39,21 @@ (def: #export test Test (<| (_.covering /._) - (_.with-cover [/.Try]) + (_.for [/.Try]) (do random.monad [expected random.nat alternative (|> random.nat (random.filter (|>> (n.= expected) not))) error (random.unicode 1) #let [(^open "io\.") io.monad]]) ($_ _.and - (_.with-cover [/.equivalence] - ($equivalence.spec (/.equivalence n.equivalence) (..try random.nat))) - (_.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 [/.equivalence] + ($equivalence.spec (/.equivalence n.equivalence) (..try random.nat))) + (_.for [/.functor] + ($functor.spec ..injection ..comparison /.functor)) + (_.for [/.apply] + ($apply.spec ..injection ..comparison /.apply)) + (_.for [/.monad] + ($monad.spec ..injection ..comparison /.monad)) (_.cover [/.succeed] (case (/.succeed expected) diff --git a/stdlib/source/test/lux/control/writer.lux b/stdlib/source/test/lux/control/writer.lux index 9bb471bf5..d9544def1 100644 --- a/stdlib/source/test/lux/control/writer.lux +++ b/stdlib/source/test/lux/control/writer.lux @@ -39,14 +39,14 @@ left random.nat right random.nat] (<| (_.covering /._) - (_.with-cover [/.Writer]) + (_.for [/.Writer]) ($_ _.and - (_.with-cover [/.functor] - ($functor.spec (..injection text.monoid) ..comparison /.functor)) - (_.with-cover [/.apply] - ($apply.spec (..injection text.monoid) ..comparison (/.apply text.monoid))) - (_.with-cover [/.monad] - ($monad.spec (..injection text.monoid) ..comparison (/.monad text.monoid))) + (_.for [/.functor] + ($functor.spec (..injection text.monoid) ..comparison /.functor)) + (_.for [/.apply] + ($apply.spec (..injection text.monoid) ..comparison (/.apply text.monoid))) + (_.for [/.monad] + ($monad.spec (..injection text.monoid) ..comparison (/.monad text.monoid))) (_.cover [/.write] (text\= log diff --git a/stdlib/source/test/lux/data/binary.lux b/stdlib/source/test/lux/data/binary.lux index b9fe6c207..ce286a113 100644 --- a/stdlib/source/test/lux/data/binary.lux +++ b/stdlib/source/test/lux/data/binary.lux @@ -85,75 +85,75 @@ #let [gen-idx (|> random.nat (\ ! map (n.% size)))] [from to] (random.and gen-idx gen-idx) #let [[from to] [(n.min from to) (n.max from to)]]] - (_.with-cover [/.Binary] - ($_ _.and - (_.with-cover [/.equivalence] - ($equivalence.spec /.equivalence (..random size))) - (_.with-cover [/.monoid] - ($monoid.spec /.equivalence /.monoid (..random size))) - (_.cover [/.fold] - (n.= (\ list.fold fold n.+ 0 (..as-list sample)) - (/.fold n.+ 0 sample))) - - (_.cover [/.create] - (\ /.equivalence = - (/.create size) - (/.create size))) - (_.cover [/.size] - (|> (/.create size) /.size (n.= size))) - (_.with-cover [/.index-out-of-bounds] - ($_ _.and - (_.cover [/.read/8 /.write/8] - (..binary-io 1 /.read/8 /.write/8 value)) - (_.cover [/.read/16 /.write/16] - (..binary-io 2 /.read/16 /.write/16 value)) - (_.cover [/.read/32 /.write/32] - (..binary-io 4 /.read/32 /.write/32 value)) - (_.cover [/.read/64 /.write/64] - (..binary-io 8 /.read/64 /.write/64 value)))) - (_.cover [/.slice] - (let [slice-size (|> to (n.- from) inc) - random-slice (try.assume (/.slice from to sample)) - idxs (enum.range n.enum 0 (dec slice-size)) - reader (function (_ binary idx) (/.read/8 idx binary))] - (and (n.= slice-size (/.size random-slice)) - (case [(monad.map try.monad (reader random-slice) idxs) - (monad.map try.monad (|>> (n.+ from) (reader sample)) idxs)] - [(#try.Success slice-vals) (#try.Success binary-vals)] - (\ (list.equivalence n.equivalence) = slice-vals binary-vals) + (_.for [/.Binary] + ($_ _.and + (_.for [/.equivalence] + ($equivalence.spec /.equivalence (..random size))) + (_.for [/.monoid] + ($monoid.spec /.equivalence /.monoid (..random size))) + (_.cover [/.fold] + (n.= (\ list.fold fold n.+ 0 (..as-list sample)) + (/.fold n.+ 0 sample))) + + (_.cover [/.create] + (\ /.equivalence = + (/.create size) + (/.create size))) + (_.cover [/.size] + (|> (/.create size) /.size (n.= size))) + (_.for [/.index-out-of-bounds] + ($_ _.and + (_.cover [/.read/8 /.write/8] + (..binary-io 1 /.read/8 /.write/8 value)) + (_.cover [/.read/16 /.write/16] + (..binary-io 2 /.read/16 /.write/16 value)) + (_.cover [/.read/32 /.write/32] + (..binary-io 4 /.read/32 /.write/32 value)) + (_.cover [/.read/64 /.write/64] + (..binary-io 8 /.read/64 /.write/64 value)))) + (_.cover [/.slice] + (let [slice-size (|> to (n.- from) inc) + random-slice (try.assume (/.slice from to sample)) + idxs (enum.range n.enum 0 (dec slice-size)) + reader (function (_ binary idx) (/.read/8 idx binary))] + (and (n.= slice-size (/.size random-slice)) + (case [(monad.map try.monad (reader random-slice) idxs) + (monad.map try.monad (|>> (n.+ from) (reader sample)) idxs)] + [(#try.Success slice-vals) (#try.Success binary-vals)] + (\ (list.equivalence n.equivalence) = slice-vals binary-vals) - _ - #0)))) - (_.cover [/.slice-out-of-bounds] - (and (throws? /.slice-out-of-bounds (/.slice size size sample)) - (throws? /.slice-out-of-bounds (/.slice from size sample)))) - (_.cover [/.inverted-slice] - (or (throws? /.inverted-slice (/.slice to from sample)) - (n.= to from))) - (_.cover [/.drop] - (and (\ /.equivalence = sample (/.drop 0 sample)) - (\ /.equivalence = (/.create 0) (/.drop size sample)) - (case (list.reverse (..as-list sample)) - #.Nil - false + _ + #0)))) + (_.cover [/.slice-out-of-bounds] + (and (throws? /.slice-out-of-bounds (/.slice size size sample)) + (throws? /.slice-out-of-bounds (/.slice from size sample)))) + (_.cover [/.inverted-slice] + (or (throws? /.inverted-slice (/.slice to from sample)) + (n.= to from))) + (_.cover [/.drop] + (and (\ /.equivalence = sample (/.drop 0 sample)) + (\ /.equivalence = (/.create 0) (/.drop size sample)) + (case (list.reverse (..as-list sample)) + #.Nil + false - (#.Cons head tail) - (n.= (list.fold n.+ 0 tail) - (/.fold n.+ 0 (/.drop 1 sample)))))) - (_.cover [/.copy] - (and (case (/.copy size 0 sample 0 (/.create size)) - (#try.Success output) - (and (not (is? sample output)) - (\ /.equivalence = sample output)) + (#.Cons head tail) + (n.= (list.fold n.+ 0 tail) + (/.fold n.+ 0 (/.drop 1 sample)))))) + (_.cover [/.copy] + (and (case (/.copy size 0 sample 0 (/.create size)) + (#try.Success output) + (and (not (is? sample output)) + (\ /.equivalence = sample output)) - (#try.Failure _) - false) - (succeed - (do try.monad - [sample/0 (/.read/8 0 sample) - copy (/.copy 1 0 sample 0 (/.create 2)) - copy/0 (/.read/8 0 copy) - copy/1 (/.read/8 1 copy)] - (wrap (and (n.= sample/0 copy/0) - (n.= 0 copy/1))))))) - ))))) + (#try.Failure _) + false) + (succeed + (do try.monad + [sample/0 (/.read/8 0 sample) + copy (/.copy 1 0 sample 0 (/.create 2)) + copy/0 (/.read/8 0 copy) + copy/1 (/.read/8 1 copy)] + (wrap (and (n.= sample/0 copy/0) + (n.= 0 copy/1))))))) + ))))) diff --git a/stdlib/source/test/lux/data/bit.lux b/stdlib/source/test/lux/data/bit.lux index 0b3eab351..82d459d10 100644 --- a/stdlib/source/test/lux/data/bit.lux +++ b/stdlib/source/test/lux/data/bit.lux @@ -21,14 +21,14 @@ (do random.monad [value random.bit] ($_ _.and - (_.with-cover [/.equivalence] - ($equivalence.spec /.equivalence random.bit)) - (_.with-cover [/.disjunction] - ($monoid.spec /.equivalence /.disjunction random.bit)) - (_.with-cover [/.conjunction] - ($monoid.spec /.equivalence /.conjunction random.bit)) - (_.with-cover [/.codec] - ($codec.spec /.equivalence /.codec random.bit)) + (_.for [/.equivalence] + ($equivalence.spec /.equivalence random.bit)) + (_.for [/.disjunction] + ($monoid.spec /.equivalence /.disjunction random.bit)) + (_.for [/.conjunction] + ($monoid.spec /.equivalence /.conjunction random.bit)) + (_.for [/.codec] + ($codec.spec /.equivalence /.codec random.bit)) (_.cover [/.complement] (and (not (\ /.equivalence = value ((/.complement function.identity) value))) diff --git a/stdlib/source/test/lux/data/collection/array.lux b/stdlib/source/test/lux/data/collection/array.lux index 99ae8e06d..d47defeaf 100644 --- a/stdlib/source/test/lux/data/collection/array.lux +++ b/stdlib/source/test/lux/data/collection/array.lux @@ -38,14 +38,14 @@ (do {! random.monad} [size ..bounded-size] ($_ _.and - (_.with-cover [/.equivalence] - ($equivalence.spec (/.equivalence n.equivalence) (random.array size random.nat))) - (_.with-cover [/.monoid] - ($monoid.spec (/.equivalence n.equivalence) /.monoid (random.array size random.nat))) - (_.with-cover [/.functor] - ($functor.spec ..injection /.equivalence /.functor)) - (_.with-cover [/.fold] - ($fold.spec ..injection /.equivalence /.fold)) + (_.for [/.equivalence] + ($equivalence.spec (/.equivalence n.equivalence) (random.array size random.nat))) + (_.for [/.monoid] + ($monoid.spec (/.equivalence n.equivalence) /.monoid (random.array size random.nat))) + (_.for [/.functor] + ($functor.spec ..injection /.equivalence /.functor)) + (_.for [/.fold] + ($fold.spec ..injection /.equivalence /.fold)) ))) (def: search @@ -90,7 +90,7 @@ (def: #export test Test (<| (_.covering /._) - (_.with-cover [/.Array]) + (_.for [/.Array]) (do {! random.monad} [size ..bounded-size base random.nat diff --git a/stdlib/source/test/lux/data/collection/bits.lux b/stdlib/source/test/lux/data/collection/bits.lux index cb5ecf681..6e07dc2e6 100644 --- a/stdlib/source/test/lux/data/collection/bits.lux +++ b/stdlib/source/test/lux/data/collection/bits.lux @@ -33,10 +33,10 @@ (def: #export test Test (<| (_.covering /._) - (_.with-cover [/.Bits]) + (_.for [/.Bits]) ($_ _.and - (_.with-cover [/.equivalence] - ($equivalence.spec /.equivalence ..random)) + (_.for [/.equivalence] + ($equivalence.spec /.equivalence ..random)) (do random.monad [sample ..random] diff --git a/stdlib/source/test/lux/data/collection/dictionary.lux b/stdlib/source/test/lux/data/collection/dictionary.lux index b852f8dbf..e5f37d5de 100644 --- a/stdlib/source/test/lux/data/collection/dictionary.lux +++ b/stdlib/source/test/lux/data/collection/dictionary.lux @@ -210,7 +210,7 @@ (def: #export test Test (<| (_.covering /._) - (_.with-cover [/.Dictionary]) + (_.for [/.Dictionary]) (do random.monad [#let [capped-nat (\ random.monad map (n.% 100) random.nat)] size capped-nat @@ -220,12 +220,12 @@ test-val (random.filter (|>> (list.member? n.equivalence (/.values dict)) not) random.nat)] ($_ _.and - (_.with-cover [/.equivalence] - ($equivalence.spec (/.equivalence n.equivalence) - (random.dictionary n.hash size random.nat random.nat))) + (_.for [/.equivalence] + ($equivalence.spec (/.equivalence n.equivalence) + (random.dictionary n.hash size random.nat random.nat))) - (_.with-cover [/.functor] - ($functor.spec ..injection /.equivalence /.functor)) + (_.for [/.functor] + ($functor.spec ..injection /.equivalence /.functor)) ..for-dictionaries ..for-entries diff --git a/stdlib/source/test/lux/data/collection/dictionary/ordered.lux b/stdlib/source/test/lux/data/collection/dictionary/ordered.lux index 01920fa1c..1553f2266 100644 --- a/stdlib/source/test/lux/data/collection/dictionary/ordered.lux +++ b/stdlib/source/test/lux/data/collection/dictionary/ordered.lux @@ -40,7 +40,7 @@ (def: #export test Test (<| (_.covering /._) - (_.with-cover [/.Dictionary]) + (_.for [/.Dictionary]) (do {! random.monad} [size (\ ! map (n.% 100) random.nat) keys (random.set n.hash size random.nat) @@ -62,8 +62,8 @@ (n.= vr vs))))) (^open "/\.") (/.equivalence n.equivalence)]] ($_ _.and - (_.with-cover [/.equivalence] - ($equivalence.spec (/.equivalence n.equivalence) (..dictionary n.order random.nat random.nat size))) + (_.for [/.equivalence] + ($equivalence.spec (/.equivalence n.equivalence) (..dictionary n.order random.nat random.nat size))) (_.cover [/.size] (n.= size (/.size sample))) diff --git a/stdlib/source/test/lux/data/collection/dictionary/plist.lux b/stdlib/source/test/lux/data/collection/dictionary/plist.lux index 7d8d3a662..2a92e28db 100644 --- a/stdlib/source/test/lux/data/collection/dictionary/plist.lux +++ b/stdlib/source/test/lux/data/collection/dictionary/plist.lux @@ -31,7 +31,7 @@ (def: #export test Test (<| (_.covering /._) - (_.with-cover [/.PList]) + (_.for [/.PList]) (do {! random.monad} [#let [gen-key (random.ascii/alpha 10)] size (\ ! map (n.% 100) random.nat) @@ -43,9 +43,9 @@ extra-value random.nat shift random.nat] ($_ _.and - (_.with-cover [/.equivalence] - ($equivalence.spec (/.equivalence n.equivalence) - (..random size gen-key random.nat))) + (_.for [/.equivalence] + ($equivalence.spec (/.equivalence n.equivalence) + (..random size gen-key random.nat))) (_.cover [/.size] (n.= size (/.size sample))) diff --git a/stdlib/source/test/lux/data/collection/list.lux b/stdlib/source/test/lux/data/collection/list.lux index 7f3ed62e6..792feeabc 100644 --- a/stdlib/source/test/lux/data/collection/list.lux +++ b/stdlib/source/test/lux/data/collection/list.lux @@ -48,18 +48,18 @@ (def: signatures Test ($_ _.and - (_.with-cover [/.equivalence] - ($equivalence.spec (/.equivalence n.equivalence) ..random)) - (_.with-cover [/.monoid] - ($monoid.spec (/.equivalence n.equivalence) /.monoid ..random)) - (_.with-cover [/.fold] - ($fold.spec /\wrap /.equivalence /.fold)) - (_.with-cover [/.functor] - ($functor.spec /\wrap /.equivalence /.functor)) - (_.with-cover [/.apply] - ($apply.spec /\wrap /.equivalence /.apply)) - (_.with-cover [/.monad] - ($monad.spec /\wrap /.equivalence /.monad)) + (_.for [/.equivalence] + ($equivalence.spec (/.equivalence n.equivalence) ..random)) + (_.for [/.monoid] + ($monoid.spec (/.equivalence n.equivalence) /.monoid ..random)) + (_.for [/.fold] + ($fold.spec /\wrap /.equivalence /.fold)) + (_.for [/.functor] + ($functor.spec /\wrap /.equivalence /.functor)) + (_.for [/.apply] + ($apply.spec /\wrap /.equivalence /.apply)) + (_.for [/.monad] + ($monad.spec /\wrap /.equivalence /.monad)) (do {! random.monad} [parameter random.nat @@ -388,7 +388,7 @@ (def: #export test Test (<| (_.covering /._) - (_.with-cover [.List]) + (_.for [.List]) (let [(^open "/\.") (/.equivalence n.equivalence) (^open "/\.") /.functor] (do {! random.monad} diff --git a/stdlib/source/test/lux/data/collection/queue.lux b/stdlib/source/test/lux/data/collection/queue.lux index 1eb6efe1b..aed90ebf9 100644 --- a/stdlib/source/test/lux/data/collection/queue.lux +++ b/stdlib/source/test/lux/data/collection/queue.lux @@ -27,7 +27,7 @@ (def: #export test Test (<| (_.covering /._) - (_.with-cover [/.Queue]) + (_.for [/.Queue]) (do {! random.monad} [size (\ ! map (n.% 100) random.nat) members (random.set n.hash size random.nat) @@ -36,10 +36,10 @@ #let [members (set.to-list members) sample (/.from-list members)]] ($_ _.and - (_.with-cover [/.equivalence] - ($equivalence.spec (/.equivalence n.equivalence) (random.queue size random.nat))) - (_.with-cover [/.functor] - ($functor.spec ..injection /.equivalence /.functor)) + (_.for [/.equivalence] + ($equivalence.spec (/.equivalence n.equivalence) (random.queue size random.nat))) + (_.for [/.functor] + ($functor.spec ..injection /.equivalence /.functor)) (_.cover [/.from-list /.to-list] (|> members /.from-list /.to-list diff --git a/stdlib/source/test/lux/data/collection/queue/priority.lux b/stdlib/source/test/lux/data/collection/queue/priority.lux index 545c1e2a1..19f219378 100644 --- a/stdlib/source/test/lux/data/collection/queue/priority.lux +++ b/stdlib/source/test/lux/data/collection/queue/priority.lux @@ -27,7 +27,7 @@ (def: #export test Test (<| (_.covering /._) - (_.with-cover [/.Queue]) + (_.for [/.Queue]) (do {! random.monad} [size (\ ! map (n.% 100) random.nat) sample (..random size) @@ -71,22 +71,22 @@ (/.empty? sample-)) (n.= (dec (/.size sample)) (/.size sample-))))) - (_.with-cover [/.Priority] - ($_ _.and - (_.cover [/.max] - (|> /.empty - (/.push /.min min-member) - (/.push /.max max-member) - /.peek - (maybe\map (n.= max-member)) - (maybe.default false))) - (_.cover [/.min] - (|> /.empty - (/.push /.max max-member) - (/.push /.min min-member) - /.pop - /.peek - (maybe\map (n.= min-member)) - (maybe.default false))) - )) + (_.for [/.Priority] + ($_ _.and + (_.cover [/.max] + (|> /.empty + (/.push /.min min-member) + (/.push /.max max-member) + /.peek + (maybe\map (n.= max-member)) + (maybe.default false))) + (_.cover [/.min] + (|> /.empty + (/.push /.max max-member) + (/.push /.min min-member) + /.pop + /.peek + (maybe\map (n.= min-member)) + (maybe.default false))) + )) )))) diff --git a/stdlib/source/test/lux/data/collection/row.lux b/stdlib/source/test/lux/data/collection/row.lux index 17dae6904..46e305b8d 100644 --- a/stdlib/source/test/lux/data/collection/row.lux +++ b/stdlib/source/test/lux/data/collection/row.lux @@ -31,18 +31,18 @@ (do {! random.monad} [size (\ ! map (n.% 100) random.nat)] ($_ _.and - (_.with-cover [/.equivalence] - ($equivalence.spec (/.equivalence n.equivalence) (random.row size random.nat))) - (_.with-cover [/.monoid] - ($monoid.spec (/.equivalence n.equivalence) /.monoid (random.row size random.nat))) - (_.with-cover [/.fold] - ($fold.spec /\wrap /.equivalence /.fold)) - (_.with-cover [/.functor] - ($functor.spec /\wrap /.equivalence /.functor)) - (_.with-cover [/.apply] - ($apply.spec /\wrap /.equivalence /.apply)) - (_.with-cover [/.monad] - ($monad.spec /\wrap /.equivalence /.monad)) + (_.for [/.equivalence] + ($equivalence.spec (/.equivalence n.equivalence) (random.row size random.nat))) + (_.for [/.monoid] + ($monoid.spec (/.equivalence n.equivalence) /.monoid (random.row size random.nat))) + (_.for [/.fold] + ($fold.spec /\wrap /.equivalence /.fold)) + (_.for [/.functor] + ($functor.spec /\wrap /.equivalence /.functor)) + (_.for [/.apply] + ($apply.spec /\wrap /.equivalence /.apply)) + (_.for [/.monad] + ($monad.spec /\wrap /.equivalence /.monad)) ))) (def: whole @@ -132,7 +132,7 @@ (def: #export test Test (<| (_.covering /._) - (_.with-cover [/.Row]) + (_.for [/.Row]) (do {! random.monad} [size (\ ! map (|>> (n.% 100) inc) random.nat)] ($_ _.and diff --git a/stdlib/source/test/lux/data/collection/sequence.lux b/stdlib/source/test/lux/data/collection/sequence.lux index 7ffadccad..e24e30c58 100644 --- a/stdlib/source/test/lux/data/collection/sequence.lux +++ b/stdlib/source/test/lux/data/collection/sequence.lux @@ -34,7 +34,7 @@ (def: #export test Test (<| (_.covering /._) - (_.with-cover [/.Sequence]) + (_.for [/.Sequence]) (let [(^open "list\.") (list.equivalence n.equivalence)]) (do {! random.monad} [repeated random.nat @@ -44,10 +44,10 @@ cycle-start random.nat cycle-next (random.list size random.nat)] ($_ _.and - (_.with-cover [/.functor] - ($functor.spec /.repeat ..equivalence /.functor)) - (_.with-cover [/.comonad] - ($comonad.spec /.repeat ..equivalence /.comonad)) + (_.for [/.functor] + ($functor.spec /.repeat ..equivalence /.functor)) + (_.for [/.comonad] + ($comonad.spec /.repeat ..equivalence /.comonad)) (_.cover [/.iterate /.nth] (n.= (n.+ offset index) diff --git a/stdlib/source/test/lux/data/collection/set.lux b/stdlib/source/test/lux/data/collection/set.lux index 147fe6beb..024a41e39 100644 --- a/stdlib/source/test/lux/data/collection/set.lux +++ b/stdlib/source/test/lux/data/collection/set.lux @@ -27,14 +27,14 @@ (def: #export test Test (<| (_.covering /._) - (_.with-cover [/.Set]) + (_.for [/.Set]) (do {! random.monad} [size ..gen-nat] ($_ _.and - (_.with-cover [/.equivalence] - ($equivalence.spec /.equivalence (random.set n.hash size random.nat))) - (_.with-cover [/.monoid] - ($monoid.spec /.equivalence (/.monoid n.hash) (random.set n.hash size random.nat))) + (_.for [/.equivalence] + ($equivalence.spec /.equivalence (random.set n.hash size random.nat))) + (_.for [/.monoid] + ($monoid.spec /.equivalence (/.monoid n.hash) (random.set n.hash size random.nat))) (do ! [sizeL ..gen-nat diff --git a/stdlib/source/test/lux/data/collection/set/multi.lux b/stdlib/source/test/lux/data/collection/set/multi.lux index e49c325ba..98877583f 100644 --- a/stdlib/source/test/lux/data/collection/set/multi.lux +++ b/stdlib/source/test/lux/data/collection/set/multi.lux @@ -38,7 +38,7 @@ (def: #export test Test (<| (_.covering /._) - (_.with-cover [/.Set]) + (_.for [/.Set]) (do {! random.monad} [diversity (\ ! map (n.% 10) random.nat) sample (..random diversity n.hash ..count random.nat) @@ -48,8 +48,8 @@ partial-removal-count (\ ! map (n.% addition-count) random.nat) another (..random diversity n.hash ..count random.nat)] (`` ($_ _.and - (_.with-cover [/.equivalence] - ($equivalence.spec /.equivalence (..random diversity n.hash ..count random.nat))) + (_.for [/.equivalence] + ($equivalence.spec /.equivalence (..random diversity n.hash ..count random.nat))) (_.cover [/.to-list /.from-list] (|> sample diff --git a/stdlib/source/test/lux/data/collection/set/ordered.lux b/stdlib/source/test/lux/data/collection/set/ordered.lux index eaa8bab4b..25c645651 100644 --- a/stdlib/source/test/lux/data/collection/set/ordered.lux +++ b/stdlib/source/test/lux/data/collection/set/ordered.lux @@ -39,7 +39,7 @@ (def: #export test Test (<| (_.covering /._) - (_.with-cover [/.Set]) + (_.for [/.Set]) (do {! random.monad} [sizeL ..size sizeR ..size @@ -53,8 +53,8 @@ setR (/.from-list n.order listR) empty (/.new n.order)]] (`` ($_ _.and - (_.with-cover [/.equivalence] - ($equivalence.spec /.equivalence (..random sizeL n.order random.nat))) + (_.for [/.equivalence] + ($equivalence.spec /.equivalence (..random sizeL n.order random.nat))) (_.cover [/.size] (n.= sizeL (/.size setL))) diff --git a/stdlib/source/test/lux/data/collection/stack.lux b/stdlib/source/test/lux/data/collection/stack.lux index 6cc4c5b10..8a12c4fab 100644 --- a/stdlib/source/test/lux/data/collection/stack.lux +++ b/stdlib/source/test/lux/data/collection/stack.lux @@ -24,16 +24,16 @@ (def: #export test Test (<| (_.covering /._) - (_.with-cover [/.Stack]) + (_.for [/.Stack]) (do random.monad [size (\ random.monad map (n.% 100) random.nat) sample (random.stack size random.nat) expected-top random.nat] ($_ _.and - (_.with-cover [/.equivalence] - ($equivalence.spec (/.equivalence n.equivalence) (random.stack size random.nat))) - (_.with-cover [/.functor] - ($functor.spec ..injection /.equivalence /.functor)) + (_.for [/.equivalence] + ($equivalence.spec (/.equivalence n.equivalence) (random.stack size random.nat))) + (_.for [/.functor] + ($functor.spec ..injection /.equivalence /.functor)) (_.cover [/.size] (n.= size (/.size sample))) diff --git a/stdlib/source/test/lux/data/collection/tree.lux b/stdlib/source/test/lux/data/collection/tree.lux index ad5766525..0b7dbbdf8 100644 --- a/stdlib/source/test/lux/data/collection/tree.lux +++ b/stdlib/source/test/lux/data/collection/tree.lux @@ -34,16 +34,16 @@ (def: #export test Test (<| (_.covering /._) - (_.with-cover [/.Tree]) + (_.for [/.Tree]) ($_ _.and - (_.with-cover [/.equivalence] - (|> (..tree random.nat) - (\ random.monad map product.right) - ($equivalence.spec (/.equivalence n.equivalence)))) - (_.with-cover [/.fold] - ($fold.spec /.leaf /.equivalence /.fold)) - (_.with-cover [/.functor] - ($functor.spec /.leaf /.equivalence /.functor)) + (_.for [/.equivalence] + (|> (..tree random.nat) + (\ random.monad map product.right) + ($equivalence.spec (/.equivalence n.equivalence)))) + (_.for [/.fold] + ($fold.spec /.leaf /.equivalence /.fold)) + (_.for [/.functor] + ($functor.spec /.leaf /.equivalence /.functor)) (do random.monad [[size sample] (..tree random.nat)] diff --git a/stdlib/source/test/lux/data/collection/tree/finger.lux b/stdlib/source/test/lux/data/collection/tree/finger.lux index d5f4dba52..3760298f9 100644 --- a/stdlib/source/test/lux/data/collection/tree/finger.lux +++ b/stdlib/source/test/lux/data/collection/tree/finger.lux @@ -26,7 +26,7 @@ (def: #export test Test (<| (_.covering /._) - (_.with-cover [/.Tree]) + (_.for [/.Tree]) (do {! random.monad} [tag-left (random.ascii/alpha-num 1) tag-right (random.filter (|>> (text\= tag-left) not) diff --git a/stdlib/source/test/lux/data/collection/tree/zipper.lux b/stdlib/source/test/lux/data/collection/tree/zipper.lux index b32ddecc2..419935101 100644 --- a/stdlib/source/test/lux/data/collection/tree/zipper.lux +++ b/stdlib/source/test/lux/data/collection/tree/zipper.lux @@ -154,7 +154,7 @@ (def: #export test Test (<| (_.covering /._) - (_.with-cover [/.Zipper]) + (_.for [/.Zipper]) (do {! random.monad} [[size sample] (//.tree random.nat) expected random.nat @@ -162,12 +162,12 @@ #let [(^open "tree\.") (tree.equivalence n.equivalence) (^open "list\.") (list.equivalence n.equivalence)]] ($_ _.and - (_.with-cover [/.equivalence] - ($equivalence.spec (/.equivalence n.equivalence) (\ ! map (|>> product.right /.zip) (//.tree random.nat)))) - (_.with-cover [/.functor] - ($functor.spec (|>> tree.leaf /.zip) /.equivalence /.functor)) - (_.with-cover [/.comonad] - ($comonad.spec (|>> tree.leaf /.zip) /.equivalence /.comonad)) + (_.for [/.equivalence] + ($equivalence.spec (/.equivalence n.equivalence) (\ ! map (|>> product.right /.zip) (//.tree random.nat)))) + (_.for [/.functor] + ($functor.spec (|>> tree.leaf /.zip) /.equivalence /.functor)) + (_.for [/.comonad] + ($comonad.spec (|>> tree.leaf /.zip) /.equivalence /.comonad)) (_.cover [/.zip /.unzip] (|> sample /.zip /.unzip (tree\= sample))) diff --git a/stdlib/source/test/lux/data/color.lux b/stdlib/source/test/lux/data/color.lux index 3b84f1b68..1e7896faf 100644 --- a/stdlib/source/test/lux/data/color.lux +++ b/stdlib/source/test/lux/data/color.lux @@ -123,66 +123,66 @@ (def: palette Test - (_.with-cover [/.Spread /.Palette] - (do {! random.monad} - [eH (\ ! map (|>> f.abs (f.% +0.9) (f.+ +0.05)) - random.safe-frac) - #let [eS +0.5] - variations (\ ! map (|>> (n.% 3) (n.+ 2)) random.nat) - #let [max-spread (f./ (|> variations inc .int int.frac) - +1.0) - min-spread (f./ +2.0 max-spread) - spread-space (f.- min-spread max-spread)] - spread (\ ! map (|>> f.abs (f.% spread-space) (f.+ min-spread)) - random.safe-frac)] - (`` ($_ _.and - (~~ (template [ ] - [(_.cover [] - (let [eB - expected (/.from-hsb [eH eS eB]) - palette ( spread variations expected)] - (and (n.= variations (list.size palette)) - (not (list.any? (\ /.equivalence = expected) palette)))))] - [+1.0 /.analogous] - [+0.5 /.monochromatic] - )) - (~~ (template [] - [(_.cover [] - (let [expected (/.from-hsb [eH eS +0.5]) - [c0 c1 c2] ( expected)] - (and (\ /.equivalence = expected c0) - (not (\ /.equivalence = expected c1)) - (not (\ /.equivalence = expected c2)))))] + (_.for [/.Spread /.Palette] + (do {! random.monad} + [eH (\ ! map (|>> f.abs (f.% +0.9) (f.+ +0.05)) + random.safe-frac) + #let [eS +0.5] + variations (\ ! map (|>> (n.% 3) (n.+ 2)) random.nat) + #let [max-spread (f./ (|> variations inc .int int.frac) + +1.0) + min-spread (f./ +2.0 max-spread) + spread-space (f.- min-spread max-spread)] + spread (\ ! map (|>> f.abs (f.% spread-space) (f.+ min-spread)) + random.safe-frac)] + (`` ($_ _.and + (~~ (template [ ] + [(_.cover [] + (let [eB + expected (/.from-hsb [eH eS eB]) + palette ( spread variations expected)] + (and (n.= variations (list.size palette)) + (not (list.any? (\ /.equivalence = expected) palette)))))] + [+1.0 /.analogous] + [+0.5 /.monochromatic] + )) + (~~ (template [] + [(_.cover [] + (let [expected (/.from-hsb [eH eS +0.5]) + [c0 c1 c2] ( expected)] + (and (\ /.equivalence = expected c0) + (not (\ /.equivalence = expected c1)) + (not (\ /.equivalence = expected c2)))))] - [/.triad] - [/.clash] - [/.split-complement])) - (~~ (template [] - [(_.cover [] - (let [expected (/.from-hsb [eH eS +0.5]) - [c0 c1 c2 c3] ( expected)] - (and (\ /.equivalence = expected c0) - (not (\ /.equivalence = expected c1)) - (not (\ /.equivalence = expected c2)) - (not (\ /.equivalence = expected c3)))))] + [/.triad] + [/.clash] + [/.split-complement])) + (~~ (template [] + [(_.cover [] + (let [expected (/.from-hsb [eH eS +0.5]) + [c0 c1 c2 c3] ( expected)] + (and (\ /.equivalence = expected c0) + (not (\ /.equivalence = expected c1)) + (not (\ /.equivalence = expected c2)) + (not (\ /.equivalence = expected c3)))))] - [/.square] - [/.tetradic])) - ))))) + [/.square] + [/.tetradic])) + ))))) (def: #export test Test (<| (_.covering /._) - (_.with-cover [/.Color]) + (_.for [/.Color]) (do {! random.monad} [expected ..color] ($_ _.and - (_.with-cover [/.equivalence] - ($equivalence.spec /.equivalence ..color)) - (_.with-cover [/.addition] - ($monoid.spec /.equivalence /.addition ..color)) - (_.with-cover [/.subtraction] - ($monoid.spec /.equivalence /.addition ..color)) + (_.for [/.equivalence] + ($equivalence.spec /.equivalence ..color)) + (_.for [/.addition] + ($monoid.spec /.equivalence /.addition ..color)) + (_.for [/.subtraction] + ($monoid.spec /.equivalence /.addition ..color)) (..encoding expected) (_.cover [/.complement] @@ -195,12 +195,12 @@ (\ /.equivalence = /.black (/.complement /.white)))) ..transformation ..palette - (_.with-cover [/.Alpha /.Pigment] - ($_ _.and - (_.cover [/.transparent /.opaque] - (and (r.= /.opaque (dec /.transparent)) - (r.= /.transparent (inc /.opaque)))) - (_.cover [/.translucent] - (r.= /.transparent (r.+ /.translucent /.translucent))) - )) + (_.for [/.Alpha /.Pigment] + ($_ _.and + (_.cover [/.transparent /.opaque] + (and (r.= /.opaque (dec /.transparent)) + (r.= /.transparent (inc /.opaque)))) + (_.cover [/.translucent] + (r.= /.transparent (r.+ /.translucent /.translucent))) + )) )))) diff --git a/stdlib/source/test/lux/data/format/binary.lux b/stdlib/source/test/lux/data/format/binary.lux index 5c819299f..6cc42d90d 100644 --- a/stdlib/source/test/lux/data/format/binary.lux +++ b/stdlib/source/test/lux/data/format/binary.lux @@ -28,8 +28,8 @@ (def: #export test Test (<| (_.covering /._) - (_.with-cover [/.Mutation /.Specification /.Writer]) + (_.for [/.Mutation /.Specification /.Writer]) ($_ _.and - (_.with-cover [/.monoid] - ($monoid.spec ..equivalence /.monoid ..random)) + (_.for [/.monoid] + ($monoid.spec ..equivalence /.monoid ..random)) ))) diff --git a/stdlib/source/test/lux/data/format/json.lux b/stdlib/source/test/lux/data/format/json.lux index ebfc6a4d5..61ba93d30 100644 --- a/stdlib/source/test/lux/data/format/json.lux +++ b/stdlib/source/test/lux/data/format/json.lux @@ -64,12 +64,12 @@ (def: #export test Test (<| (_.covering /._) - (_.with-cover [/.JSON]) + (_.for [/.JSON]) (`` ($_ _.and - (_.with-cover [/.equivalence] - ($equivalence.spec /.equivalence ..json)) - (_.with-cover [/.codec] - ($codec.spec /.equivalence /.codec ..json)) + (_.for [/.equivalence] + ($equivalence.spec /.equivalence ..json)) + (_.for [/.codec] + ($codec.spec /.equivalence /.codec ..json)) (do random.monad [sample ..json] diff --git a/stdlib/source/test/lux/data/format/tar.lux b/stdlib/source/test/lux/data/format/tar.lux index 374c068a8..fc92947ff 100644 --- a/stdlib/source/test/lux/data/format/tar.lux +++ b/stdlib/source/test/lux/data/format/tar.lux @@ -34,117 +34,117 @@ (def: path Test - (_.with-cover [/.Path] - (do {! random.monad} - [expected (random.ascii/lower-alpha /.path-size) - invalid (random.ascii/lower-alpha (inc /.path-size)) - not-ascii (random.text (random.char (unicode.set [unicode.katakana (list)])) - /.path-size)] - (`` ($_ _.and - (_.cover [/.path /.from-path] - (case (/.path expected) - (#try.Success actual) - (text\= expected - (/.from-path actual)) - - (#try.Failure error) - false)) - (_.cover [/.path-size /.path-is-too-long] - (case (/.path invalid) - (#try.Success _) - false - - (#try.Failure error) - (exception.match? /.path-is-too-long error))) - (_.cover [/.not-ascii] - (case (/.path not-ascii) - (#try.Success actual) - false - - (#try.Failure error) - (exception.match? /.not-ascii error))) - ))))) + (_.for [/.Path] + (do {! random.monad} + [expected (random.ascii/lower-alpha /.path-size) + invalid (random.ascii/lower-alpha (inc /.path-size)) + not-ascii (random.text (random.char (unicode.set [unicode.katakana (list)])) + /.path-size)] + (`` ($_ _.and + (_.cover [/.path /.from-path] + (case (/.path expected) + (#try.Success actual) + (text\= expected + (/.from-path actual)) + + (#try.Failure error) + false)) + (_.cover [/.path-size /.path-is-too-long] + (case (/.path invalid) + (#try.Success _) + false + + (#try.Failure error) + (exception.match? /.path-is-too-long error))) + (_.cover [/.not-ascii] + (case (/.path not-ascii) + (#try.Success actual) + false + + (#try.Failure error) + (exception.match? /.not-ascii error))) + ))))) (def: name Test - (_.with-cover [/.Name] - (do {! random.monad} - [expected (random.ascii/lower-alpha /.name-size) - invalid (random.ascii/lower-alpha (inc /.name-size)) - not-ascii (random.text (random.char (unicode.set [unicode.katakana (list)])) - /.name-size)] - (`` ($_ _.and - (_.cover [/.name /.from-name] - (case (/.name expected) - (#try.Success actual) - (text\= expected - (/.from-name actual)) - - (#try.Failure error) - false)) - (_.cover [/.name-size /.name-is-too-long] - (case (/.name invalid) - (#try.Success _) - false - - (#try.Failure error) - (exception.match? /.name-is-too-long error))) - (_.cover [/.not-ascii] - (case (/.name not-ascii) - (#try.Success actual) - false - - (#try.Failure error) - (exception.match? /.not-ascii error))) - ))))) + (_.for [/.Name] + (do {! random.monad} + [expected (random.ascii/lower-alpha /.name-size) + invalid (random.ascii/lower-alpha (inc /.name-size)) + not-ascii (random.text (random.char (unicode.set [unicode.katakana (list)])) + /.name-size)] + (`` ($_ _.and + (_.cover [/.name /.from-name] + (case (/.name expected) + (#try.Success actual) + (text\= expected + (/.from-name actual)) + + (#try.Failure error) + false)) + (_.cover [/.name-size /.name-is-too-long] + (case (/.name invalid) + (#try.Success _) + false + + (#try.Failure error) + (exception.match? /.name-is-too-long error))) + (_.cover [/.not-ascii] + (case (/.name not-ascii) + (#try.Success actual) + false + + (#try.Failure error) + (exception.match? /.not-ascii error))) + ))))) (def: small Test - (_.with-cover [/.Small] - (do {! random.monad} - [expected (|> random.nat (\ ! map (n.% /.small-limit))) - invalid (|> random.nat (\ ! map (n.max /.small-limit)))] - (`` ($_ _.and - (_.cover [/.small /.from-small] - (case (/.small expected) - (#try.Success actual) - (n.= expected - (/.from-small actual)) - - (#try.Failure error) - false)) - (_.cover [/.small-limit /.not-a-small-number] - (case (/.small invalid) - (#try.Success actual) - false - - (#try.Failure error) - (exception.match? /.not-a-small-number error))) - ))))) + (_.for [/.Small] + (do {! random.monad} + [expected (|> random.nat (\ ! map (n.% /.small-limit))) + invalid (|> random.nat (\ ! map (n.max /.small-limit)))] + (`` ($_ _.and + (_.cover [/.small /.from-small] + (case (/.small expected) + (#try.Success actual) + (n.= expected + (/.from-small actual)) + + (#try.Failure error) + false)) + (_.cover [/.small-limit /.not-a-small-number] + (case (/.small invalid) + (#try.Success actual) + false + + (#try.Failure error) + (exception.match? /.not-a-small-number error))) + ))))) (def: big Test - (_.with-cover [/.Big] - (do {! random.monad} - [expected (|> random.nat (\ ! map (n.% /.big-limit))) - invalid (|> random.nat (\ ! map (n.max /.big-limit)))] - (`` ($_ _.and - (_.cover [/.big /.from-big] - (case (/.big expected) - (#try.Success actual) - (n.= expected - (/.from-big actual)) - - (#try.Failure error) - false)) - (_.cover [/.big-limit /.not-a-big-number] - (case (/.big invalid) - (#try.Success actual) - false - - (#try.Failure error) - (exception.match? /.not-a-big-number error))) - ))))) + (_.for [/.Big] + (do {! random.monad} + [expected (|> random.nat (\ ! map (n.% /.big-limit))) + invalid (|> random.nat (\ ! map (n.max /.big-limit)))] + (`` ($_ _.and + (_.cover [/.big /.from-big] + (case (/.big expected) + (#try.Success actual) + (n.= expected + (/.from-big actual)) + + (#try.Failure error) + false)) + (_.cover [/.big-limit /.not-a-big-number] + (case (/.big invalid) + (#try.Success actual) + false + + (#try.Failure error) + (exception.match? /.not-a-big-number error))) + ))))) (def: chunk-size 32) @@ -180,41 +180,41 @@ [/.Symbolic-Link #/.Symbolic-Link] [/.Directory #/.Directory] )) - (_.with-cover [/.File /.Content /.content /.data] - ($_ _.and - (~~ (template [ ] - [(_.cover [] - (|> (do try.monad - [expected-path (/.path expected-path) - expected-content (/.content content) - tar (|> (row.row ( [expected-path - expected-moment - /.none - {#/.user {#/.name /.anonymous - #/.id /.no-id} - #/.group {#/.name /.anonymous - #/.id /.no-id}} - expected-content])) - (format.run /.writer) - (.run /.parser))] - (wrap (case (row.to-list tar) - (^ (list ( [actual-path actual-moment actual-mode actual-ownership actual-content]))) - (let [seconds (: (-> Instant Int) - (|>> instant.relative (duration.query duration.second)))] - (and (text\= (/.from-path expected-path) - (/.from-path actual-path)) - (i.= (seconds expected-moment) - (seconds actual-moment)) - (binary\= (/.data expected-content) - (/.data actual-content)))) - - _ - false))) - (try.default false)))] - - [/.Normal #/.Normal] - [/.Contiguous #/.Contiguous] - )))))))) + (_.for [/.File /.Content /.content /.data] + ($_ _.and + (~~ (template [ ] + [(_.cover [] + (|> (do try.monad + [expected-path (/.path expected-path) + expected-content (/.content content) + tar (|> (row.row ( [expected-path + expected-moment + /.none + {#/.user {#/.name /.anonymous + #/.id /.no-id} + #/.group {#/.name /.anonymous + #/.id /.no-id}} + expected-content])) + (format.run /.writer) + (.run /.parser))] + (wrap (case (row.to-list tar) + (^ (list ( [actual-path actual-moment actual-mode actual-ownership actual-content]))) + (let [seconds (: (-> Instant Int) + (|>> instant.relative (duration.query duration.second)))] + (and (text\= (/.from-path expected-path) + (/.from-path actual-path)) + (i.= (seconds expected-moment) + (seconds actual-moment)) + (binary\= (/.data expected-content) + (/.data actual-content)))) + + _ + false))) + (try.default false)))] + + [/.Normal #/.Normal] + [/.Contiguous #/.Contiguous] + )))))))) (def: random-mode (Random /.Mode) @@ -235,76 +235,76 @@ (def: mode Test - (_.with-cover [/.Mode /.mode] - (do {! random.monad} - [path (random.ascii/lower-alpha 10) - modes (random.list 4 ..random-mode) - #let [expected-mode (list\fold /.and /.none modes)]] - (`` ($_ _.and - (_.cover [/.and] - (|> (do try.monad - [path (/.path path) - content (/.content (binary.create 0)) - tar (|> (row.row (#/.Normal [path - (instant.from-millis +0) - expected-mode - {#/.user {#/.name /.anonymous - #/.id /.no-id} - #/.group {#/.name /.anonymous - #/.id /.no-id}} - content])) - (format.run /.writer) - (.run /.parser))] - (wrap (case (row.to-list tar) - (^ (list (#/.Normal [_ _ actual-mode _ _]))) - (n.= (/.mode expected-mode) - (/.mode actual-mode)) - - _ - false))) - (try.default false))) - (~~ (template [] - [(_.cover [] - (|> (do try.monad - [path (/.path path) - content (/.content (binary.create 0)) - tar (|> (row.row (#/.Normal [path - (instant.from-millis +0) - - {#/.user {#/.name /.anonymous - #/.id /.no-id} - #/.group {#/.name /.anonymous - #/.id /.no-id}} - content])) - (format.run /.writer) - (.run /.parser))] - (wrap (case (row.to-list tar) - (^ (list (#/.Normal [_ _ actual-mode _ _]))) - (n.= (/.mode ) - (/.mode actual-mode)) - - _ - false))) - (try.default false)))] - - [/.none] - - [/.execute-by-other] - [/.write-by-other] - [/.read-by-other] - - [/.execute-by-group] - [/.write-by-group] - [/.read-by-group] - - [/.execute-by-owner] - [/.write-by-owner] - [/.read-by-owner] - - [/.save-text] - [/.set-group-id-on-execution] - [/.set-user-id-on-execution] - ))))))) + (_.for [/.Mode /.mode] + (do {! random.monad} + [path (random.ascii/lower-alpha 10) + modes (random.list 4 ..random-mode) + #let [expected-mode (list\fold /.and /.none modes)]] + (`` ($_ _.and + (_.cover [/.and] + (|> (do try.monad + [path (/.path path) + content (/.content (binary.create 0)) + tar (|> (row.row (#/.Normal [path + (instant.from-millis +0) + expected-mode + {#/.user {#/.name /.anonymous + #/.id /.no-id} + #/.group {#/.name /.anonymous + #/.id /.no-id}} + content])) + (format.run /.writer) + (.run /.parser))] + (wrap (case (row.to-list tar) + (^ (list (#/.Normal [_ _ actual-mode _ _]))) + (n.= (/.mode expected-mode) + (/.mode actual-mode)) + + _ + false))) + (try.default false))) + (~~ (template [] + [(_.cover [] + (|> (do try.monad + [path (/.path path) + content (/.content (binary.create 0)) + tar (|> (row.row (#/.Normal [path + (instant.from-millis +0) + + {#/.user {#/.name /.anonymous + #/.id /.no-id} + #/.group {#/.name /.anonymous + #/.id /.no-id}} + content])) + (format.run /.writer) + (.run /.parser))] + (wrap (case (row.to-list tar) + (^ (list (#/.Normal [_ _ actual-mode _ _]))) + (n.= (/.mode ) + (/.mode actual-mode)) + + _ + false))) + (try.default false)))] + + [/.none] + + [/.execute-by-other] + [/.write-by-other] + [/.read-by-other] + + [/.execute-by-group] + [/.write-by-group] + [/.read-by-group] + + [/.execute-by-owner] + [/.write-by-owner] + [/.read-by-owner] + + [/.save-text] + [/.set-group-id-on-execution] + [/.set-user-id-on-execution] + ))))))) (def: ownership Test @@ -314,96 +314,96 @@ invalid (random.ascii/lower-alpha (inc /.name-size)) not-ascii (random.text (random.char (unicode.set [unicode.katakana (list)])) /.name-size)] - (_.with-cover [/.Ownership /.Owner /.ID] - ($_ _.and - (_.cover [/.name-size /.name-is-too-long] - (case (/.name invalid) - (#try.Success _) - false - - (#try.Failure error) - (exception.match? /.name-is-too-long error))) - (_.cover [/.not-ascii] - (case (/.name not-ascii) - (#try.Success actual) - false - - (#try.Failure error) - (exception.match? /.not-ascii error))) - (_.cover [/.Name /.name /.from-name] - (|> (do try.monad - [path (/.path path) - content (/.content (binary.create 0)) - expected (/.name expected) - tar (|> (row.row (#/.Normal [path - (instant.from-millis +0) - /.none - {#/.user {#/.name expected - #/.id /.no-id} - #/.group {#/.name /.anonymous - #/.id /.no-id}} - content])) - (format.run /.writer) - (.run /.parser))] - (wrap (case (row.to-list tar) - (^ (list (#/.Normal [_ _ _ actual-ownership _]))) - (and (text\= (/.from-name expected) - (/.from-name (get@ [#/.user #/.name] actual-ownership))) - (text\= (/.from-name /.anonymous) - (/.from-name (get@ [#/.group #/.name] actual-ownership)))) - - _ - false))) - (try.default false))) - (_.cover [/.anonymous /.no-id] - (|> (do try.monad - [path (/.path path) - content (/.content (binary.create 0)) - tar (|> (row.row (#/.Normal [path - (instant.from-millis +0) - /.none - {#/.user {#/.name /.anonymous - #/.id /.no-id} - #/.group {#/.name /.anonymous - #/.id /.no-id}} - content])) - (format.run /.writer) - (.run /.parser))] - (wrap (case (row.to-list tar) - (^ (list (#/.Normal [_ _ _ actual-ownership _]))) - (and (text\= (/.from-name /.anonymous) - (/.from-name (get@ [#/.user #/.name] actual-ownership))) - (n.= (/.from-small /.no-id) - (/.from-small (get@ [#/.user #/.id] actual-ownership))) - (text\= (/.from-name /.anonymous) - (/.from-name (get@ [#/.group #/.name] actual-ownership))) - (n.= (/.from-small /.no-id) - (/.from-small (get@ [#/.group #/.id] actual-ownership)))) - - _ - false))) - (try.default false))) - )))) + (_.for [/.Ownership /.Owner /.ID] + ($_ _.and + (_.cover [/.name-size /.name-is-too-long] + (case (/.name invalid) + (#try.Success _) + false + + (#try.Failure error) + (exception.match? /.name-is-too-long error))) + (_.cover [/.not-ascii] + (case (/.name not-ascii) + (#try.Success actual) + false + + (#try.Failure error) + (exception.match? /.not-ascii error))) + (_.cover [/.Name /.name /.from-name] + (|> (do try.monad + [path (/.path path) + content (/.content (binary.create 0)) + expected (/.name expected) + tar (|> (row.row (#/.Normal [path + (instant.from-millis +0) + /.none + {#/.user {#/.name expected + #/.id /.no-id} + #/.group {#/.name /.anonymous + #/.id /.no-id}} + content])) + (format.run /.writer) + (.run /.parser))] + (wrap (case (row.to-list tar) + (^ (list (#/.Normal [_ _ _ actual-ownership _]))) + (and (text\= (/.from-name expected) + (/.from-name (get@ [#/.user #/.name] actual-ownership))) + (text\= (/.from-name /.anonymous) + (/.from-name (get@ [#/.group #/.name] actual-ownership)))) + + _ + false))) + (try.default false))) + (_.cover [/.anonymous /.no-id] + (|> (do try.monad + [path (/.path path) + content (/.content (binary.create 0)) + tar (|> (row.row (#/.Normal [path + (instant.from-millis +0) + /.none + {#/.user {#/.name /.anonymous + #/.id /.no-id} + #/.group {#/.name /.anonymous + #/.id /.no-id}} + content])) + (format.run /.writer) + (.run /.parser))] + (wrap (case (row.to-list tar) + (^ (list (#/.Normal [_ _ _ actual-ownership _]))) + (and (text\= (/.from-name /.anonymous) + (/.from-name (get@ [#/.user #/.name] actual-ownership))) + (n.= (/.from-small /.no-id) + (/.from-small (get@ [#/.user #/.id] actual-ownership))) + (text\= (/.from-name /.anonymous) + (/.from-name (get@ [#/.group #/.name] actual-ownership))) + (n.= (/.from-small /.no-id) + (/.from-small (get@ [#/.group #/.id] actual-ownership)))) + + _ + false))) + (try.default false))) + )))) (def: #export test Test (<| (_.covering /._) - (_.with-cover [/.Tar] - ($_ _.and - (_.cover [/.writer /.parser] - (|> row.empty - (format.run /.writer) - (.run /.parser) - (\ try.monad map row.empty?) - (try.default false))) - ..path - ..name - ..small - ..big - (_.with-cover [/.Entry] - ($_ _.and - ..entry - ..mode - ..ownership - )) - )))) + (_.for [/.Tar] + ($_ _.and + (_.cover [/.writer /.parser] + (|> row.empty + (format.run /.writer) + (.run /.parser) + (\ try.monad map row.empty?) + (try.default false))) + ..path + ..name + ..small + ..big + (_.for [/.Entry] + ($_ _.and + ..entry + ..mode + ..ownership + )) + )))) diff --git a/stdlib/source/test/lux/data/format/xml.lux b/stdlib/source/test/lux/data/format/xml.lux index 7ac52ef02..e649040c1 100644 --- a/stdlib/source/test/lux/data/format/xml.lux +++ b/stdlib/source/test/lux/data/format/xml.lux @@ -69,12 +69,12 @@ (def: #export test Test (<| (_.covering /._) - (_.with-cover [/.XML]) + (_.for [/.XML]) ($_ _.and - (_.with-cover [/.equivalence] - ($equivalence.spec /.equivalence ..xml)) - (_.with-cover [/.codec] - ($codec.spec /.equivalence /.codec ..xml)) + (_.for [/.equivalence] + ($equivalence.spec /.equivalence ..xml)) + (_.for [/.codec] + ($codec.spec /.equivalence /.codec ..xml)) (do {! random.monad} [(^@ identifier [namespace name]) ..identifier] diff --git a/stdlib/source/test/lux/data/identity.lux b/stdlib/source/test/lux/data/identity.lux index 4601aaf0b..a68e11511 100644 --- a/stdlib/source/test/lux/data/identity.lux +++ b/stdlib/source/test/lux/data/identity.lux @@ -24,14 +24,14 @@ (def: #export test Test (<| (_.covering /._) - (_.with-cover [/.Identity]) + (_.for [/.Identity]) ($_ _.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)) - (_.with-cover [/.comonad] - ($comonad.spec ..injection ..comparison /.comonad)) + (_.for [/.functor] + ($functor.spec ..injection ..comparison /.functor)) + (_.for [/.apply] + ($apply.spec ..injection ..comparison /.apply)) + (_.for [/.monad] + ($monad.spec ..injection ..comparison /.monad)) + (_.for [/.comonad] + ($comonad.spec ..injection ..comparison /.comonad)) ))) diff --git a/stdlib/source/test/lux/data/lazy.lux b/stdlib/source/test/lux/data/lazy.lux index dc305ae33..ddb24aee8 100644 --- a/stdlib/source/test/lux/data/lazy.lux +++ b/stdlib/source/test/lux/data/lazy.lux @@ -37,26 +37,26 @@ [left random.nat right random.nat #let [expected (n.* left right)]] - (_.with-cover [/.Lazy] - ($_ _.and - (_.with-cover [/.equivalence] - ($equivalence.spec (/.equivalence n.equivalence) (..lazy random.nat))) - (_.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 [/.Lazy] + ($_ _.and + (_.for [/.equivalence] + ($equivalence.spec (/.equivalence n.equivalence) (..lazy random.nat))) + (_.for [/.functor] + ($functor.spec ..injection ..comparison /.functor)) + (_.for [/.apply] + ($apply.spec ..injection ..comparison /.apply)) + (_.for [/.monad] + ($monad.spec ..injection ..comparison /.monad)) - (_.cover [/.freeze] - (let [lazy (/.freeze (n.* left right))] - (n.= expected - (/.thaw lazy)))) + (_.cover [/.freeze] + (let [lazy (/.freeze (n.* left right))] + (n.= expected + (/.thaw lazy)))) - (_.cover [/.thaw] - (let [lazy (/.freeze (n.* left right))] - (and (not (is? expected - (/.thaw lazy))) - (is? (/.thaw lazy) - (/.thaw lazy))))) - ))))) + (_.cover [/.thaw] + (let [lazy (/.freeze (n.* left right))] + (and (not (is? expected + (/.thaw lazy))) + (is? (/.thaw lazy) + (/.thaw lazy))))) + ))))) diff --git a/stdlib/source/test/lux/data/maybe.lux b/stdlib/source/test/lux/data/maybe.lux index fa863cdae..f5e965614 100644 --- a/stdlib/source/test/lux/data/maybe.lux +++ b/stdlib/source/test/lux/data/maybe.lux @@ -27,51 +27,51 @@ (def: #export test Test (<| (_.covering /._) - (_.with-cover [.Maybe] - ($_ _.and - (_.with-cover [/.equivalence] - ($equivalence.spec (/.equivalence n.equivalence) (random.maybe random.nat))) - (_.with-cover [/.monoid] - ($monoid.spec (/.equivalence n.equivalence) /.monoid (random.maybe random.nat))) - (_.with-cover [/.functor] - ($functor.spec /\wrap /.equivalence /.functor)) - (_.with-cover [/.apply] - ($apply.spec /\wrap /.equivalence /.apply)) - (_.with-cover [/.monad] - ($monad.spec /\wrap /.equivalence /.monad)) - - (do random.monad - [left random.nat - right random.nat - #let [expected (n.+ left right)]] - (let [lift (/.lift io.monad)] - (_.cover [/.with /.lift] - (|> (io.run (do (/.with io.monad) - [a (lift (io\wrap left)) - b (wrap right)] - (wrap (n.+ a b)))) - (case> (#.Some actual) - (n.= expected actual) + (_.for [.Maybe] + ($_ _.and + (_.for [/.equivalence] + ($equivalence.spec (/.equivalence n.equivalence) (random.maybe random.nat))) + (_.for [/.monoid] + ($monoid.spec (/.equivalence n.equivalence) /.monoid (random.maybe random.nat))) + (_.for [/.functor] + ($functor.spec /\wrap /.equivalence /.functor)) + (_.for [/.apply] + ($apply.spec /\wrap /.equivalence /.apply)) + (_.for [/.monad] + ($monad.spec /\wrap /.equivalence /.monad)) + + (do random.monad + [left random.nat + right random.nat + #let [expected (n.+ left right)]] + (let [lift (/.lift io.monad)] + (_.cover [/.with /.lift] + (|> (io.run (do (/.with io.monad) + [a (lift (io\wrap left)) + b (wrap right)] + (wrap (n.+ a b)))) + (case> (#.Some actual) + (n.= expected actual) - _ - false))))) - (do random.monad - [default random.nat - value random.nat] - (_.cover [/.default] - (and (is? default (/.default default - #.None)) + _ + false))))) + (do random.monad + [default random.nat + value random.nat] + (_.cover [/.default] + (and (is? default (/.default default + #.None)) - (is? value (/.default default - (#.Some value)))))) - (do random.monad - [value random.nat] - (_.cover [/.assume] - (is? value (/.assume (#.Some value))))) - (do random.monad - [value random.nat] - (_.cover [/.to-list] - (\ (list.equivalence n.equivalence) = - (list value) - (/.to-list (#.Some value))))) - )))) + (is? value (/.default default + (#.Some value)))))) + (do random.monad + [value random.nat] + (_.cover [/.assume] + (is? value (/.assume (#.Some value))))) + (do random.monad + [value random.nat] + (_.cover [/.to-list] + (\ (list.equivalence n.equivalence) = + (list value) + (/.to-list (#.Some value))))) + )))) diff --git a/stdlib/source/test/lux/data/name.lux b/stdlib/source/test/lux/data/name.lux index fd6f5b546..904c14668 100644 --- a/stdlib/source/test/lux/data/name.lux +++ b/stdlib/source/test/lux/data/name.lux @@ -41,35 +41,35 @@ sizeM2 (|> random.nat (\ ! map (n.% 100))) sizeS2 (|> random.nat (\ ! map (|>> (n.% 100) (n.max 1)))) (^@ name2 [module2 short2]) (..name sizeM2 sizeS2)] - (_.with-cover [.Name] - ($_ _.and - (_.with-cover [/.equivalence] - ($equivalence.spec /.equivalence (..name sizeM1 sizeS1))) - (_.with-cover [/.order] - ($order.spec /.order (..name sizeM1 sizeS1))) - (_.with-cover [/.codec] - (_.and ($codec.spec /.equivalence /.codec (..name sizeM1 sizeS1)) - (let [(^open "/\.") /.codec] - (_.test "Encoding an name without a module component results in text equal to the short of the name." - (if (text.empty? module1) - (text\= short1 (/\encode name1)) - #1))))) - - (_.cover [/.module /.short] - (and (is? module1 (/.module name1)) - (is? short1 (/.short name1)))) - - (_.with-cover [.name-of] - (let [(^open "/\.") /.equivalence] - ($_ _.and - (_.test "Can obtain Name from identifier." - (and (/\= ["lux" "yolo"] (.name-of .yolo)) - (/\= ["test/lux/data/name" "yolo"] (.name-of ..yolo)) - (/\= ["" "yolo"] (.name-of yolo)) - (/\= ["lux/test" "yolo"] (.name-of lux/test.yolo)))) - (_.test "Can obtain Name from tag." - (and (/\= ["lux" "yolo"] (.name-of #.yolo)) - (/\= ["test/lux/data/name" "yolo"] (.name-of #..yolo)) - (/\= ["" "yolo"] (.name-of #yolo)) - (/\= ["lux/test" "yolo"] (.name-of #lux/test.yolo))))))) - ))))) + (_.for [.Name] + ($_ _.and + (_.for [/.equivalence] + ($equivalence.spec /.equivalence (..name sizeM1 sizeS1))) + (_.for [/.order] + ($order.spec /.order (..name sizeM1 sizeS1))) + (_.for [/.codec] + (_.and ($codec.spec /.equivalence /.codec (..name sizeM1 sizeS1)) + (let [(^open "/\.") /.codec] + (_.test "Encoding an name without a module component results in text equal to the short of the name." + (if (text.empty? module1) + (text\= short1 (/\encode name1)) + #1))))) + + (_.cover [/.module /.short] + (and (is? module1 (/.module name1)) + (is? short1 (/.short name1)))) + + (_.for [.name-of] + (let [(^open "/\.") /.equivalence] + ($_ _.and + (_.test "Can obtain Name from identifier." + (and (/\= ["lux" "yolo"] (.name-of .yolo)) + (/\= ["test/lux/data/name" "yolo"] (.name-of ..yolo)) + (/\= ["" "yolo"] (.name-of yolo)) + (/\= ["lux/test" "yolo"] (.name-of lux/test.yolo)))) + (_.test "Can obtain Name from tag." + (and (/\= ["lux" "yolo"] (.name-of #.yolo)) + (/\= ["test/lux/data/name" "yolo"] (.name-of #..yolo)) + (/\= ["" "yolo"] (.name-of #yolo)) + (/\= ["lux/test" "yolo"] (.name-of #lux/test.yolo))))))) + ))))) diff --git a/stdlib/source/test/lux/data/number/complex.lux b/stdlib/source/test/lux/data/number/complex.lux index 0a3866371..2d5865e3d 100644 --- a/stdlib/source/test/lux/data/number/complex.lux +++ b/stdlib/source/test/lux/data/number/complex.lux @@ -269,10 +269,10 @@ (def: #export test Test (<| (_.covering /._) - (_.with-cover [/.Complex]) + (_.for [/.Complex]) ($_ _.and - (_.with-cover [/.= /.equivalence] - ($equivalence.spec /.equivalence ..random)) + (_.for [/.= /.equivalence] + ($equivalence.spec /.equivalence ..random)) ..construction ..constant diff --git a/stdlib/source/test/lux/data/number/frac.lux b/stdlib/source/test/lux/data/number/frac.lux index 08fcef498..aa472c572 100644 --- a/stdlib/source/test/lux/data/number/frac.lux +++ b/stdlib/source/test/lux/data/number/frac.lux @@ -93,13 +93,13 @@ (def: signature Test (`` ($_ _.and - (_.with-cover [/.equivalence /.=] - ($equivalence.spec /.equivalence random.safe-frac)) - (_.with-cover [/.order /.<] - ($order.spec /.order random.safe-frac)) + (_.for [/.equivalence /.=] + ($equivalence.spec /.equivalence random.safe-frac)) + (_.for [/.order /.<] + ($order.spec /.order random.safe-frac)) (~~ (template [ ] - [(_.with-cover [ ] - ($monoid.spec /.equivalence ..random))] + [(_.for [ ] + ($monoid.spec /.equivalence ..random))] [/.+ /.addition] [/.* /.multiplication] @@ -108,8 +108,8 @@ [/.max /.maximum] )) (~~ (template [] - [(_.with-cover [] - ($codec.spec /.equivalence random.safe-frac))] + [(_.for [] + ($codec.spec /.equivalence random.safe-frac))] [/.binary] [/.octal] [/.decimal] [/.hex] )) @@ -125,7 +125,7 @@ (def: #export test Test (<| (_.covering /._) - (_.with-cover [.Frac]) + (_.for [.Frac]) ($_ _.and (do random.monad [left random.safe-frac diff --git a/stdlib/source/test/lux/data/number/i16.lux b/stdlib/source/test/lux/data/number/i16.lux index 038d6d7f2..1a5009a03 100644 --- a/stdlib/source/test/lux/data/number/i16.lux +++ b/stdlib/source/test/lux/data/number/i16.lux @@ -23,7 +23,7 @@ (def: #export test Test (<| (_.covering /._) - (_.with-cover [/.I16]) + (_.for [/.I16]) (do {! random.monad} [#let [limit (|> (dec /.width) //i64.mask @@ -31,8 +31,8 @@ inc)] expected (\ ! map (i.% limit) random.int)] ($_ _.and - (_.with-cover [/.equivalence] - ($equivalence.spec /.equivalence ..random)) + (_.for [/.equivalence] + ($equivalence.spec /.equivalence ..random)) (_.cover [/.i16 /.i64 /.width] (let [actual (|> expected .i64 /.i16 /.i64)] diff --git a/stdlib/source/test/lux/data/number/i32.lux b/stdlib/source/test/lux/data/number/i32.lux index 11dd6f3f9..fd48509ea 100644 --- a/stdlib/source/test/lux/data/number/i32.lux +++ b/stdlib/source/test/lux/data/number/i32.lux @@ -23,7 +23,7 @@ (def: #export test Test (<| (_.covering /._) - (_.with-cover [/.I32]) + (_.for [/.I32]) (do {! random.monad} [#let [limit (|> (dec /.width) //i64.mask @@ -31,8 +31,8 @@ inc)] expected (\ ! map (i.% limit) random.int)] ($_ _.and - (_.with-cover [/.equivalence] - ($equivalence.spec /.equivalence ..random)) + (_.for [/.equivalence] + ($equivalence.spec /.equivalence ..random)) (_.cover [/.i32 /.i64 /.width] (let [actual (|> expected .i64 /.i32 /.i64)] diff --git a/stdlib/source/test/lux/data/number/i64.lux b/stdlib/source/test/lux/data/number/i64.lux index a9cddc921..49f63d1a9 100644 --- a/stdlib/source/test/lux/data/number/i64.lux +++ b/stdlib/source/test/lux/data/number/i64.lux @@ -87,7 +87,7 @@ (def: mask Test - (<| (_.with-cover [/.Mask]) + (<| (_.for [/.Mask]) (do {! random.monad} [pattern random.nat idx (\ ! map (n.% /.width) random.nat) @@ -136,47 +136,47 @@ (def: sub Test - (_.with-cover [/.Sub] - (do {! random.monad} - [size (\ ! map (n.% /.width) random.nat)] - (case (/.sub size) - #.None - (_.cover [/.sub] - (n.= 0 size)) + (_.for [/.Sub] + (do {! random.monad} + [size (\ ! map (n.% /.width) random.nat)] + (case (/.sub size) + #.None + (_.cover [/.sub] + (n.= 0 size)) - (#.Some sub) - (do {! random.monad} - [#let [limit (|> (dec (\ sub width)) - /.mask - .int - inc)] - expected (\ ! map (i.% limit) random.int) - #let [random (: (All [size] - (-> (-> I64 (I64 size)) (Random (I64 size)))) - (function (_ narrow) - (\ random.functor map narrow random.i64)))]] - ($_ _.and - ($equivalence.spec (\ sub &equivalence) (random (\ sub narrow))) - (_.cover [/.sub] - (let [actual (|> expected .i64 (\ sub narrow) (\ sub widen))] - (\= expected actual))) - )))))) + (#.Some sub) + (do {! random.monad} + [#let [limit (|> (dec (\ sub width)) + /.mask + .int + inc)] + expected (\ ! map (i.% limit) random.int) + #let [random (: (All [size] + (-> (-> I64 (I64 size)) (Random (I64 size)))) + (function (_ narrow) + (\ random.functor map narrow random.i64)))]] + ($_ _.and + ($equivalence.spec (\ sub &equivalence) (random (\ sub narrow))) + (_.cover [/.sub] + (let [actual (|> expected .i64 (\ sub narrow) (\ sub widen))] + (\= expected actual))) + )))))) (def: signature Test ($_ _.and - (_.with-cover [/.equivalence] - ($equivalence.spec /.equivalence random.i64)) - (_.with-cover [/.disjunction] - ($monoid.spec n.equivalence /.disjunction random.nat)) - (_.with-cover [/.conjunction] - ($monoid.spec n.equivalence /.conjunction random.nat)) + (_.for [/.equivalence] + ($equivalence.spec /.equivalence random.i64)) + (_.for [/.disjunction] + ($monoid.spec n.equivalence /.disjunction random.nat)) + (_.for [/.conjunction] + ($monoid.spec n.equivalence /.conjunction random.nat)) )) (def: #export test Test (<| (_.covering /._) - (_.with-cover [.I64]) + (_.for [.I64]) (do {! random.monad} [pattern random.nat idx (\ ! map (n.% /.width) random.nat)] diff --git a/stdlib/source/test/lux/data/number/i8.lux b/stdlib/source/test/lux/data/number/i8.lux index b855ac1e0..49b6995e8 100644 --- a/stdlib/source/test/lux/data/number/i8.lux +++ b/stdlib/source/test/lux/data/number/i8.lux @@ -23,7 +23,7 @@ (def: #export test Test (<| (_.covering /._) - (_.with-cover [/.I8]) + (_.for [/.I8]) (do {! random.monad} [#let [limit (|> (dec /.width) //i64.mask @@ -31,8 +31,8 @@ inc)] expected (\ ! map (i.% limit) random.int)] ($_ _.and - (_.with-cover [/.equivalence] - ($equivalence.spec /.equivalence ..random)) + (_.for [/.equivalence] + ($equivalence.spec /.equivalence ..random)) (_.cover [/.i8 /.i64 /.width] (let [actual (|> expected .i64 /.i8 /.i64)] diff --git a/stdlib/source/test/lux/data/number/int.lux b/stdlib/source/test/lux/data/number/int.lux index 16c23246a..02d44e282 100644 --- a/stdlib/source/test/lux/data/number/int.lux +++ b/stdlib/source/test/lux/data/number/int.lux @@ -24,17 +24,17 @@ (def: signature Test (`` ($_ _.and - (_.with-cover [/.equivalence /.=] - ($equivalence.spec /.equivalence random.int)) - (_.with-cover [/.order /.<] - ($order.spec /.order random.int)) - (_.with-cover [/.enum] - ($enum.spec /.enum random.int)) - (_.with-cover [/.interval] - ($interval.spec /.interval random.int)) + (_.for [/.equivalence /.=] + ($equivalence.spec /.equivalence random.int)) + (_.for [/.order /.<] + ($order.spec /.order random.int)) + (_.for [/.enum] + ($enum.spec /.enum random.int)) + (_.for [/.interval] + ($interval.spec /.interval random.int)) (~~ (template [ ] - [(_.with-cover [ ] - ($monoid.spec /.equivalence random.int))] + [(_.for [ ] + ($monoid.spec /.equivalence random.int))] [/.+ /.addition] [/.* /.multiplication] @@ -43,8 +43,8 @@ [/.max /.maximum] )) (~~ (template [] - [(_.with-cover [] - ($codec.spec /.equivalence random.int))] + [(_.for [] + ($codec.spec /.equivalence random.int))] [/.binary] [/.octal] [/.decimal] [/.hex] )) @@ -72,7 +72,7 @@ (def: #export test Test (<| (_.covering /._) - (_.with-cover [.Int]) + (_.for [.Int]) ($_ _.and (do random.monad [sample random.int] diff --git a/stdlib/source/test/lux/data/number/nat.lux b/stdlib/source/test/lux/data/number/nat.lux index 6e027eab1..d53ca4631 100644 --- a/stdlib/source/test/lux/data/number/nat.lux +++ b/stdlib/source/test/lux/data/number/nat.lux @@ -24,17 +24,17 @@ (def: signature Test (`` ($_ _.and - (_.with-cover [/.equivalence /.=] - ($equivalence.spec /.equivalence random.nat)) - (_.with-cover [/.order /.<] - ($order.spec /.order random.nat)) - (_.with-cover [/.enum] - ($enum.spec /.enum random.nat)) - (_.with-cover [/.interval] - ($interval.spec /.interval random.nat)) + (_.for [/.equivalence /.=] + ($equivalence.spec /.equivalence random.nat)) + (_.for [/.order /.<] + ($order.spec /.order random.nat)) + (_.for [/.enum] + ($enum.spec /.enum random.nat)) + (_.for [/.interval] + ($interval.spec /.interval random.nat)) (~~ (template [ ] - [(_.with-cover [ ] - ($monoid.spec /.equivalence random.nat))] + [(_.for [ ] + ($monoid.spec /.equivalence random.nat))] [/.+ /.addition] [/.* /.multiplication] @@ -43,8 +43,8 @@ [/.max /.maximum] )) (~~ (template [] - [(_.with-cover [] - ($codec.spec /.equivalence random.nat))] + [(_.for [] + ($codec.spec /.equivalence random.nat))] [/.binary] [/.octal] [/.decimal] [/.hex] )) @@ -63,7 +63,7 @@ (def: #export test Test (<| (_.covering /._) - (_.with-cover [.Nat]) + (_.for [.Nat]) ($_ _.and (do random.monad [sample random.nat] diff --git a/stdlib/source/test/lux/data/number/ratio.lux b/stdlib/source/test/lux/data/number/ratio.lux index 38a3ab9f3..1e8da2e78 100644 --- a/stdlib/source/test/lux/data/number/ratio.lux +++ b/stdlib/source/test/lux/data/number/ratio.lux @@ -1,6 +1,5 @@ (.module: [lux #* - ["%" data/text/format (#+ format)] ["_" test (#+ Test)] [abstract [monad (#+ do)] @@ -11,43 +10,105 @@ ["$." monoid] ["$." codec]]}] [data + ["." bit ("#\." equivalence)] + ["." maybe ("#\." functor)] [number - ["n" nat]]] + ["n" nat ("#\." equivalence)]]] [math - ["r" random (#+ Random)]]] + ["." random (#+ Random)]]] {1 - ["." / (#+ Ratio)]}) + ["." /]}) (def: part (Random Nat) - (|> r.nat (\ r.monad map (|>> (n.% 1,000,000) (n.max 1))))) + (\ random.monad map + (|>> (n.% 1,000,000) (n.max 1)) + random.nat)) -(def: #export ratio - (Random Ratio) - (do r.monad +(def: #export random + (Random /.Ratio) + (do random.monad [numerator ..part - denominator (r.filter (|>> (n.= 0) not) ..part)] + denominator (random.filter (|>> (n.= 0) not) + ..part)] (wrap (/.ratio numerator denominator)))) (def: #export test Test - (<| (_.context (%.name (name-of /._))) + (<| (_.covering /._) + (_.for [/.Ratio]) (`` ($_ _.and - ($equivalence.spec /.equivalence ..ratio) - ($order.spec /.order ..ratio) - (~~ (template [] - [(<| (_.context (%.name (name-of ))) - ($monoid.spec /.equivalence ..ratio))] + (_.for [/.equivalence /.=] + ($equivalence.spec /.equivalence ..random)) + (_.for [/.order /.<] + ($order.spec /.order ..random)) + (~~ (template [ ] + [(_.for [ ] + ($monoid.spec /.equivalence ..random))] - [/.addition] [/.multiplication] + [/.+ /.addition] + [/.* /.multiplication] )) - ($codec.spec /.equivalence /.codec ..ratio) + (_.for [/.codec] + ($codec.spec /.equivalence /.codec ..random)) - (do r.monad - [denom0 ..part - denom1 ..part] - (_.test "All zeroes are the same." - (let [(^open "/\.") /.equivalence] - (/\= (/.ratio 0 denom0) - (/.ratio 0 denom1))))) + (do random.monad + [#let [(^open "\.") /.equivalence] + denom/0 ..part + denom/1 ..part] + (_.cover [/.ratio] + (\= (/.ratio 0 denom/0) + (/.ratio 0 denom/1)))) + (do random.monad + [numerator ..part + denominator (random.filter (|>> (n\= 1) not) + ..part)] + (_.cover [/.nat] + (and (|> (/.ratio numerator) + /.nat + (maybe\map (n\= numerator)) + (maybe.default false)) + (|> (/.ratio numerator 1) + /.nat + (maybe\map (n\= numerator)) + (maybe.default false)) + (case (/.nat (/.ratio numerator denominator)) + #.None true + (#.Some _) false)))) + (do random.monad + [sample ..random] + ($_ _.and + (_.cover [/.-] + (and (/.= (/.ratio 0) (/.- sample sample)) + (/.= sample (/.- (/.ratio 0) sample)))) + (_.cover [/./] + (and (/.= (/.ratio 1) (/./ sample sample)) + (/.= sample (/./ (/.ratio 1) sample)))) + (_.cover [/.reciprocal] + (/.= (/.ratio 1) + (/.* sample (/.reciprocal sample)))) + )) + (do random.monad + [left (random.filter (|>> (/.= (/.ratio 0)) not) + ..random) + right ..random] + (_.cover [/.%] + (let [rem (/.% left right) + div (|> right (/.- rem) (/./ left))] + (and (/.= right + (|> div (/.* left) (/.+ rem))) + (case (/.nat div) + (#.Some _) true + #.None false))))) + (do random.monad + [left ..random + right ..random] + ($_ _.and + (_.cover [/.>] + (bit\= (/.> left right) + (/.< right left))) + (_.cover [/.<= /.>=] + (bit\= (/.<= left right) + (/.>= right left))) + )) )))) diff --git a/stdlib/source/test/lux/data/product.lux b/stdlib/source/test/lux/data/product.lux index 74057ad63..6e15c90b8 100644 --- a/stdlib/source/test/lux/data/product.lux +++ b/stdlib/source/test/lux/data/product.lux @@ -18,16 +18,16 @@ (def: #export test Test (<| (_.covering /._) - (_.with-cover [.&]) + (_.for [.&]) (do random.monad [expected random.nat shift random.nat dummy (random.filter (|>> (n.= expected) not) random.nat)] ($_ _.and - (_.with-cover [/.equivalence] - ($equivalence.spec (/.equivalence n.equivalence i.equivalence) - (random.and random.nat random.int))) + (_.for [/.equivalence] + ($equivalence.spec (/.equivalence n.equivalence i.equivalence) + (random.and random.nat random.int))) (<| (_.cover [/.left]) (n.= expected (/.left [expected dummy]))) diff --git a/stdlib/source/test/lux/data/sum.lux b/stdlib/source/test/lux/data/sum.lux index 7484eac15..8dadcf272 100644 --- a/stdlib/source/test/lux/data/sum.lux +++ b/stdlib/source/test/lux/data/sum.lux @@ -22,14 +22,14 @@ (def: #export test Test (<| (_.covering /._) - (_.with-cover [.|]) + (_.for [.|]) (do {! random.monad} [expected random.nat shift random.nat]) ($_ _.and - (_.with-cover [/.equivalence] - ($equivalence.spec (/.equivalence n.equivalence n.equivalence) - (random.or random.nat random.nat))) + (_.for [/.equivalence] + ($equivalence.spec (/.equivalence n.equivalence n.equivalence) + (random.or random.nat random.nat))) (_.cover [/.left] (|> (/.left expected) diff --git a/stdlib/source/test/lux/data/text.lux b/stdlib/source/test/lux/data/text.lux index ce645f46e..778559483 100644 --- a/stdlib/source/test/lux/data/text.lux +++ b/stdlib/source/test/lux/data/text.lux @@ -136,24 +136,24 @@ (def: char Test ($_ _.and - (_.with-cover [/.Char /.from-code] - (`` ($_ _.and - (~~ (template [ ] - [(_.cover [ ] - (\ /.equivalence = ))] + (_.for [/.Char /.from-code] + (`` ($_ _.and + (~~ (template [ ] + [(_.cover [ ] + (\ /.equivalence = ))] - [/.\0 /.null] - [/.\a /.alarm] - [/.\b /.back-space] - [/.\t /.tab] - [/.\n /.new-line] - [/.\v /.vertical-tab] - [/.\f /.form-feed] - [/.\r /.carriage-return] - [/.\'' /.double-quote])) - (_.cover [/.line-feed] - (\ /.equivalence = /.new-line /.line-feed)) - ))) + [/.\0 /.null] + [/.\a /.alarm] + [/.\b /.back-space] + [/.\t /.tab] + [/.\n /.new-line] + [/.\v /.vertical-tab] + [/.\f /.form-feed] + [/.\r /.carriage-return] + [/.\'' /.double-quote])) + (_.cover [/.line-feed] + (\ /.equivalence = /.new-line /.line-feed)) + ))) (do {! random.monad} [size (\ ! map (|>> (n.% 10) inc) random.nat) characters (random.set /.hash size (random.ascii/alpha 1)) @@ -227,14 +227,14 @@ (def: #export test Test (<| (_.covering /._) - (_.with-cover [.Text]) + (_.for [.Text]) ($_ _.and - (_.with-cover [/.equivalence] - ($equivalence.spec /.equivalence (random.ascii 2))) - (_.with-cover [/.order] - ($order.spec /.order (random.ascii 2))) - (_.with-cover [/.monoid] - ($monoid.spec /.equivalence /.monoid (random.ascii 2))) + (_.for [/.equivalence] + ($equivalence.spec /.equivalence (random.ascii 2))) + (_.for [/.order] + ($order.spec /.order (random.ascii 2))) + (_.for [/.monoid] + ($monoid.spec /.equivalence /.monoid (random.ascii 2))) ..size ..affix diff --git a/stdlib/source/test/lux/locale.lux b/stdlib/source/test/lux/locale.lux index 3518dac9d..b494779d3 100644 --- a/stdlib/source/test/lux/locale.lux +++ b/stdlib/source/test/lux/locale.lux @@ -47,10 +47,10 @@ (def: #export test Test (<| (_.covering /._) - (_.with-cover [/.Locale]) + (_.for [/.Locale]) ($_ _.and - (_.with-cover [/.equivalence] - ($equivalence.spec /.equivalence ..random-locale)) + (_.for [/.equivalence] + ($equivalence.spec /.equivalence ..random-locale)) (do random.monad [language ..random-language diff --git a/stdlib/source/test/lux/locale/language.lux b/stdlib/source/test/lux/locale/language.lux index 3ba8e7567..c1b8a4b5f 100644 --- a/stdlib/source/test/lux/locale/language.lux +++ b/stdlib/source/test/lux/locale/language.lux @@ -259,7 +259,7 @@ (def: #export test Test (<| (_.covering /._) - (_.with-cover [/.Language]) + (_.for [/.Language]) ($_ _.and ..languages-test ..aliases-test diff --git a/stdlib/source/test/lux/locale/territory.lux b/stdlib/source/test/lux/locale/territory.lux index 485cd7efc..4fe08f75a 100644 --- a/stdlib/source/test/lux/locale/territory.lux +++ b/stdlib/source/test/lux/locale/territory.lux @@ -199,7 +199,7 @@ (def: #export test Test (<| (_.covering /._) - (_.with-cover [/.Territory]) + (_.for [/.Territory]) ($_ _.and ..territories-test ..aliases-test diff --git a/stdlib/source/test/lux/macro/code.lux b/stdlib/source/test/lux/macro/code.lux index 8ba65a181..8f6dc91d5 100644 --- a/stdlib/source/test/lux/macro/code.lux +++ b/stdlib/source/test/lux/macro/code.lux @@ -117,57 +117,57 @@ Test (<| (_.covering /._) ($_ _.and - (_.with-cover [/.equivalence] - ($equivalence.spec /.equivalence ..random)) - (_.with-cover [/.format] - (`` ($_ _.and - (~~ (template [ ] - [(do {! random.monad} - [expected ] - (_.cover [] - (and (case (..read (/.format ( expected))) - (#try.Success actual) - (\ /.equivalence = - actual - ( expected)) - - (#try.Failure error) - false) - (\ /.equivalence = - [location.dummy ( expected)] - ( expected)))))] + (_.for [/.equivalence] + ($equivalence.spec /.equivalence ..random)) + (_.for [/.format] + (`` ($_ _.and + (~~ (template [ ] + [(do {! random.monad} + [expected ] + (_.cover [] + (and (case (..read (/.format ( expected))) + (#try.Success actual) + (\ /.equivalence = + actual + ( expected)) + + (#try.Failure error) + false) + (\ /.equivalence = + [location.dummy ( expected)] + ( expected)))))] - [/.bit random.bit #.Bit] - [/.nat random.nat #.Nat] - [/.int random.int #.Int] - [/.rev random.rev #.Rev] - [/.frac random.safe-frac #.Frac] - [/.text ..random-text #.Text] - [/.tag ..random-name #.Tag] - [/.identifier ..random-name #.Identifier] - [/.form (..random-sequence ..random) #.Form] - [/.tuple (..random-sequence ..random) #.Tuple] - [/.record (..random-record ..random) #.Record])) - (~~ (template [ ] - [(do {! random.monad} - [expected ] - (_.cover [] - (and (case (..read (/.format ( expected))) - (#try.Success actual) - (\ /.equivalence = - actual - ( expected)) - - (#try.Failure error) - false) - (\ /.equivalence = - [location.dummy ( ["" expected])] - ( expected))) - ))] + [/.bit random.bit #.Bit] + [/.nat random.nat #.Nat] + [/.int random.int #.Int] + [/.rev random.rev #.Rev] + [/.frac random.safe-frac #.Frac] + [/.text ..random-text #.Text] + [/.tag ..random-name #.Tag] + [/.identifier ..random-name #.Identifier] + [/.form (..random-sequence ..random) #.Form] + [/.tuple (..random-sequence ..random) #.Tuple] + [/.record (..random-record ..random) #.Record])) + (~~ (template [ ] + [(do {! random.monad} + [expected ] + (_.cover [] + (and (case (..read (/.format ( expected))) + (#try.Success actual) + (\ /.equivalence = + actual + ( expected)) + + (#try.Failure error) + false) + (\ /.equivalence = + [location.dummy ( ["" expected])] + ( expected))) + ))] - [/.local-tag ..random-text #.Tag] - [/.local-identifier ..random-text #.Identifier] - ))))) + [/.local-tag ..random-text #.Tag] + [/.local-identifier ..random-text #.Identifier] + ))))) (do {! random.monad} [[original substitute] (random.and ..random ..random) [sample expected] (..replace-simulation [original substitute])] diff --git a/stdlib/source/test/lux/macro/poly/json.lux b/stdlib/source/test/lux/macro/poly/json.lux index 6988adb4a..4b6718577 100644 --- a/stdlib/source/test/lux/macro/poly/json.lux +++ b/stdlib/source/test/lux/macro/poly/json.lux @@ -116,5 +116,5 @@ (def: #export test Test (<| (_.covering /._) - (_.with-cover [/.codec] - ($codec.spec ..equivalence ..codec ..gen-record)))) + (_.for [/.codec] + ($codec.spec ..equivalence ..codec ..gen-record)))) diff --git a/stdlib/source/test/lux/macro/syntax/common.lux b/stdlib/source/test/lux/macro/syntax/common.lux index ab29448d7..d25fff149 100644 --- a/stdlib/source/test/lux/macro/syntax/common.lux +++ b/stdlib/source/test/lux/macro/syntax/common.lux @@ -66,29 +66,29 @@ (#try.Failure error) false)))) - (_.with-cover [/.Annotations] - ($_ _.and - (do random.monad - [expected ..random-annotations] - (_.cover [/reader.annotations /writer.annotations] - (|> expected - /writer.annotations list - (.run /reader.annotations) - (case> (#try.Success actual) - (\ ..annotations-equivalence = expected actual) - - (#try.Failure error) - false)))) - (_.cover [/.empty-annotations] - (|> /.empty-annotations - /writer.annotations list - (.run /reader.annotations) - (case> (#try.Success actual) - (\ ..annotations-equivalence = /.empty-annotations actual) - - (#try.Failure error) - false))) - )) + (_.for [/.Annotations] + ($_ _.and + (do random.monad + [expected ..random-annotations] + (_.cover [/reader.annotations /writer.annotations] + (|> expected + /writer.annotations list + (.run /reader.annotations) + (case> (#try.Success actual) + (\ ..annotations-equivalence = expected actual) + + (#try.Failure error) + false)))) + (_.cover [/.empty-annotations] + (|> /.empty-annotations + /writer.annotations list + (.run /reader.annotations) + (case> (#try.Success actual) + (\ ..annotations-equivalence = /.empty-annotations actual) + + (#try.Failure error) + false))) + )) (do {! random.monad} [size (\ ! map (|>> (n.% 3)) random.nat) expected (random.list size ..random-text)] diff --git a/stdlib/source/test/lux/meta.lux b/stdlib/source/test/lux/meta.lux index 25e3b3f94..ef5be32b5 100644 --- a/stdlib/source/test/lux/meta.lux +++ b/stdlib/source/test/lux/meta.lux @@ -261,12 +261,12 @@ #.extensions [] #.host []}]] ($_ _.and - (_.with-cover [/.functor] - ($functor.spec ..injection (..comparison expected-lux) /.functor)) - (_.with-cover [/.apply] - ($apply.spec ..injection (..comparison expected-lux) /.apply)) - (_.with-cover [/.monad] - ($monad.spec ..injection (..comparison expected-lux) /.monad)) + (_.for [/.functor] + ($functor.spec ..injection (..comparison expected-lux) /.functor)) + (_.for [/.apply] + ($apply.spec ..injection (..comparison expected-lux) /.apply)) + (_.for [/.monad] + ($monad.spec ..injection (..comparison expected-lux) /.monad)) ..compiler-related ..error-handling diff --git a/stdlib/source/test/lux/meta/annotation.lux b/stdlib/source/test/lux/meta/annotation.lux index 3b5b4d635..af0ee2490 100644 --- a/stdlib/source/test/lux/meta/annotation.lux +++ b/stdlib/source/test/lux/meta/annotation.lux @@ -145,7 +145,7 @@ (def: #export test Test (<| (_.covering /._) - (_.with-cover [/.Annotation]) + (_.for [/.Annotation]) (do {! random.monad} [key ..random-key] ($_ _.and diff --git a/stdlib/source/test/lux/tool/compiler/language/lux/phase/synthesis/case.lux b/stdlib/source/test/lux/tool/compiler/language/lux/phase/synthesis/case.lux index 9735eda42..84c238ad7 100644 --- a/stdlib/source/test/lux/tool/compiler/language/lux/phase/synthesis/case.lux +++ b/stdlib/source/test/lux/tool/compiler/language/lux/phase/synthesis/case.lux @@ -343,7 +343,7 @@ (def: #export test Test (<| (_.covering /._) - (_.with-cover [/.synthesize]) + (_.for [/.synthesize]) ($_ _.and ..masking-test ..let-test diff --git a/stdlib/source/test/lux/world/console.lux b/stdlib/source/test/lux/world/console.lux index 6e1ce67b3..56291563d 100644 --- a/stdlib/source/test/lux/world/console.lux +++ b/stdlib/source/test/lux/world/console.lux @@ -40,5 +40,5 @@ (def: #export test Test (<| (_.covering /._) - (_.with-cover [/.mock /.Simulation] - ($/.spec (io.io (/.mock ..simulation false)))))) + (_.for [/.mock /.Simulation] + ($/.spec (io.io (/.mock ..simulation false)))))) diff --git a/stdlib/source/test/lux/world/file/watch.lux b/stdlib/source/test/lux/world/file/watch.lux index 8b1c22697..aa3a51e59 100644 --- a/stdlib/source/test/lux/world/file/watch.lux +++ b/stdlib/source/test/lux/world/file/watch.lux @@ -35,7 +35,7 @@ (def: concern\\test Test - (<| (_.with-cover [/.Concern]) + (<| (_.for [/.Concern]) ($_ _.and (_.cover [/.creation /.creation?] (and (/.creation? /.creation) @@ -92,7 +92,7 @@ (def: #export test Test (<| (_.covering /._) - (_.with-cover [/.Watcher]) + (_.for [/.Watcher]) ($_ _.and ..concern\\test ..exception diff --git a/stdlib/source/test/lux/world/program.lux b/stdlib/source/test/lux/world/program.lux index 5dcf6270a..531ba0095 100644 --- a/stdlib/source/test/lux/world/program.lux +++ b/stdlib/source/test/lux/world/program.lux @@ -34,6 +34,6 @@ [environment ..environment directory ..directory] ($_ _.and - (_.with-cover [/.mock /.async] - ($/.spec (/.async (/.mock environment directory)))) + (_.for [/.mock /.async] + ($/.spec (/.async (/.mock environment directory)))) )))) diff --git a/stdlib/source/test/lux/world/shell.lux b/stdlib/source/test/lux/world/shell.lux index cf349e225..d3c7e24f8 100644 --- a/stdlib/source/test/lux/world/shell.lux +++ b/stdlib/source/test/lux/world/shell.lux @@ -98,9 +98,9 @@ Test (<| (_.covering /._) ($_ _.and - (_.with-cover [/.mock /.Simulation] - ($/.spec (/.mock (|>> ..simulation #try.Success) - false))) + (_.for [/.mock /.Simulation] + ($/.spec (/.mock (|>> ..simulation #try.Success) + false))) (_.cover [/.error] (not (i.= /.normal /.error))) (do random.monad -- cgit v1.2.3