diff options
author | Eduardo Julian | 2020-12-10 00:15:15 -0400 |
---|---|---|
committer | Eduardo Julian | 2020-12-10 00:15:15 -0400 |
commit | 14287585025b2d8fff1991691def9e643b039ac8 (patch) | |
tree | 4fdbe2aafa907d1dd0f47150c545adf3eabeb124 /stdlib/source/test/lux/control | |
parent | 893c76ad530ca0e81cd84602543c3114407f4592 (diff) |
Re-named "with-cover" to "for".
Diffstat (limited to 'stdlib/source/test/lux/control')
30 files changed, 432 insertions, 407 deletions
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 [<size> <parser> <format>] [(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)] @@ -73,6 +74,15 @@ (!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] (|> (/.run (do //.monad [_ (/.node expected)] @@ -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 |