diff options
Diffstat (limited to '')
40 files changed, 862 insertions, 801 deletions
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 [<brightness> <palette>] - [(_.cover [<palette>] - (let [eB <brightness> - expected (/.from-hsb [eH eS eB]) - palette (<palette> spread variations expected)] - (and (n.= variations (list.size palette)) - (not (list.any? (\ /.equivalence = expected) palette)))))] - [+1.0 /.analogous] - [+0.5 /.monochromatic] - )) - (~~ (template [<palette>] - [(_.cover [<palette>] - (let [expected (/.from-hsb [eH eS +0.5]) - [c0 c1 c2] (<palette> 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 [<brightness> <palette>] + [(_.cover [<palette>] + (let [eB <brightness> + expected (/.from-hsb [eH eS eB]) + palette (<palette> spread variations expected)] + (and (n.= variations (list.size palette)) + (not (list.any? (\ /.equivalence = expected) palette)))))] + [+1.0 /.analogous] + [+0.5 /.monochromatic] + )) + (~~ (template [<palette>] + [(_.cover [<palette>] + (let [expected (/.from-hsb [eH eS +0.5]) + [c0 c1 c2] (<palette> expected)] + (and (\ /.equivalence = expected c0) + (not (\ /.equivalence = expected c1)) + (not (\ /.equivalence = expected c2)))))] - [/.triad] - [/.clash] - [/.split-complement])) - (~~ (template [<palette>] - [(_.cover [<palette>] - (let [expected (/.from-hsb [eH eS +0.5]) - [c0 c1 c2 c3] (<palette> expected)] - (and (\ /.equivalence = expected c0) - (not (\ /.equivalence = expected c1)) - (not (\ /.equivalence = expected c2)) - (not (\ /.equivalence = expected c3)))))] + [/.triad] + [/.clash] + [/.split-complement])) + (~~ (template [<palette>] + [(_.cover [<palette>] + (let [expected (/.from-hsb [eH eS +0.5]) + [c0 c1 c2 c3] (<palette> 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 [<type> <tag>] - [(_.cover [<type>] - (|> (do try.monad - [expected-path (/.path expected-path) - expected-content (/.content content) - tar (|> (row.row (<tag> [expected-path - expected-moment - /.none - {#/.user {#/.name /.anonymous - #/.id /.no-id} - #/.group {#/.name /.anonymous - #/.id /.no-id}} - expected-content])) - (format.run /.writer) - (<b>.run /.parser))] - (wrap (case (row.to-list tar) - (^ (list (<tag> [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 [<type> <tag>] + [(_.cover [<type>] + (|> (do try.monad + [expected-path (/.path expected-path) + expected-content (/.content content) + tar (|> (row.row (<tag> [expected-path + expected-moment + /.none + {#/.user {#/.name /.anonymous + #/.id /.no-id} + #/.group {#/.name /.anonymous + #/.id /.no-id}} + expected-content])) + (format.run /.writer) + (<b>.run /.parser))] + (wrap (case (row.to-list tar) + (^ (list (<tag> [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) - (<b>.run /.parser))] - (wrap (case (row.to-list tar) - (^ (list (#/.Normal [_ _ actual-mode _ _]))) - (n.= (/.mode expected-mode) - (/.mode actual-mode)) - - _ - false))) - (try.default false))) - (~~ (template [<expected-mode>] - [(_.cover [<expected-mode>] - (|> (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) - (<b>.run /.parser))] - (wrap (case (row.to-list tar) - (^ (list (#/.Normal [_ _ actual-mode _ _]))) - (n.= (/.mode <expected-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) + (<b>.run /.parser))] + (wrap (case (row.to-list tar) + (^ (list (#/.Normal [_ _ actual-mode _ _]))) + (n.= (/.mode expected-mode) + (/.mode actual-mode)) + + _ + false))) + (try.default false))) + (~~ (template [<expected-mode>] + [(_.cover [<expected-mode>] + (|> (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) + (<b>.run /.parser))] + (wrap (case (row.to-list tar) + (^ (list (#/.Normal [_ _ actual-mode _ _]))) + (n.= (/.mode <expected-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) - (<b>.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) - (<b>.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) + (<b>.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) + (<b>.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) - (<b>.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) + (<b>.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 [<compose> <monoid>] - [(_.with-cover [<monoid> <compose>] - ($monoid.spec /.equivalence <monoid> ..random))] + [(_.for [<monoid> <compose>] + ($monoid.spec /.equivalence <monoid> ..random))] [/.+ /.addition] [/.* /.multiplication] @@ -108,8 +108,8 @@ [/.max /.maximum] )) (~~ (template [<codec>] - [(_.with-cover [<codec>] - ($codec.spec /.equivalence <codec> random.safe-frac))] + [(_.for [<codec>] + ($codec.spec /.equivalence <codec> 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 [<compose> <monoid>] - [(_.with-cover [<monoid> <compose>] - ($monoid.spec /.equivalence <monoid> random.int))] + [(_.for [<monoid> <compose>] + ($monoid.spec /.equivalence <monoid> random.int))] [/.+ /.addition] [/.* /.multiplication] @@ -43,8 +43,8 @@ [/.max /.maximum] )) (~~ (template [<codec>] - [(_.with-cover [<codec>] - ($codec.spec /.equivalence <codec> random.int))] + [(_.for [<codec>] + ($codec.spec /.equivalence <codec> 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 [<compose> <monoid>] - [(_.with-cover [<monoid> <compose>] - ($monoid.spec /.equivalence <monoid> random.nat))] + [(_.for [<monoid> <compose>] + ($monoid.spec /.equivalence <monoid> random.nat))] [/.+ /.addition] [/.* /.multiplication] @@ -43,8 +43,8 @@ [/.max /.maximum] )) (~~ (template [<codec>] - [(_.with-cover [<codec>] - ($codec.spec /.equivalence <codec> random.nat))] + [(_.for [<codec>] + ($codec.spec /.equivalence <codec> 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 [<monoid>] - [(<| (_.context (%.name (name-of <monoid>))) - ($monoid.spec /.equivalence <monoid> ..ratio))] + (_.for [/.equivalence /.=] + ($equivalence.spec /.equivalence ..random)) + (_.for [/.order /.<] + ($order.spec /.order ..random)) + (~~ (template [<compose> <monoid>] + [(_.for [<monoid> <compose>] + ($monoid.spec /.equivalence <monoid> ..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 [<short> <long>] - [(_.cover [<short> <long>] - (\ /.equivalence = <short> <long>))] + (_.for [/.Char /.from-code] + (`` ($_ _.and + (~~ (template [<short> <long>] + [(_.cover [<short> <long>] + (\ /.equivalence = <short> <long>))] - [/.\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 |