diff options
Diffstat (limited to 'stdlib/source/test/lux/data')
22 files changed, 141 insertions, 147 deletions
diff --git a/stdlib/source/test/lux/data/binary.lux b/stdlib/source/test/lux/data/binary.lux index 2d1a25092..7b5f5fab0 100644 --- a/stdlib/source/test/lux/data/binary.lux +++ b/stdlib/source/test/lux/data/binary.lux @@ -79,11 +79,11 @@ Test (<| (_.covering /._) (do {! random.monad} - [#let [gen_size (|> random.nat (\ ! map (|>> (n.% 100) (n.max 8))))] + [.let [gen_size (|> random.nat (\ ! map (|>> (n.% 100) (n.max 8))))] size gen_size sample (..random size) value random.nat - #let [gen_idx (|> random.nat (\ ! map (n.% size)))] + .let [gen_idx (|> random.nat (\ ! map (n.% size)))] offset gen_idx length (\ ! map (n.% (n.- offset size)) random.nat)] (_.for [/.Binary] diff --git a/stdlib/source/test/lux/data/collection/array.lux b/stdlib/source/test/lux/data/collection/array.lux index d5ea9badf..dc8527fdc 100644 --- a/stdlib/source/test/lux/data/collection/array.lux +++ b/stdlib/source/test/lux/data/collection/array.lux @@ -52,13 +52,13 @@ [size ..bounded_size base random.nat shift random.nat - #let [expected (n.+ base shift)] + .let [expected (n.+ base shift)] the_array (random.array size random.nat)] ($_ _.and (_.cover [/.find] (\ (maybe.equivalence n.equivalence) = (/.find n.even? the_array) - (list.find n.even? (/.to_list the_array)))) + (list.find n.even? (/.list the_array)))) (_.cover [/.find+] (case [(/.find n.even? the_array) (/.find+ (function (_ idx member) @@ -80,11 +80,11 @@ false)) (_.cover [/.every?] (\ bit.equivalence = - (list.every? n.even? (/.to_list the_array)) + (list.every? n.even? (/.list the_array)) (/.every? n.even? the_array))) (_.cover [/.any?] (\ bit.equivalence = - (list.any? n.even? (/.to_list the_array)) + (list.any? n.even? (/.list the_array)) (/.any? n.even? the_array))) ))) @@ -97,7 +97,7 @@ base random.nat shift random.nat dummy (random.only (|>> (n.= base) not) random.nat) - #let [expected (n.+ base shift)] + .let [expected (n.+ base shift)] the_array (random.array size random.nat)] ($_ _.and ..structures @@ -182,10 +182,10 @@ (/.vacancy the_array))))))) (do ! [the_list (random.list size random.nat)] - (_.cover [/.of_list /.to_list] - (and (|> the_list /.of_list /.to_list + (_.cover [/.of_list /.list] + (and (|> the_list /.of_list /.list (\ (list.equivalence n.equivalence) = the_list)) - (|> the_array /.to_list /.of_list + (|> the_array /.list /.of_list (\ (/.equivalence n.equivalence) = the_array))))) (do ! [amount (\ ! map (n.% (inc size)) random.nat)] @@ -194,31 +194,31 @@ (/.empty size))] (exec (/.copy! amount 0 the_array 0 copy) (\ (list.equivalence n.equivalence) = - (list.take amount (/.to_list the_array)) - (/.to_list copy)))))) + (list.take amount (/.list the_array)) + (/.list copy)))))) (_.cover [/.clone] (let [clone (/.clone the_array)] (and (not (is? the_array clone)) (\ (/.equivalence n.equivalence) = the_array clone)))) (let [the_array (/.clone the_array) - evens (|> the_array /.to_list (list.only n.even?)) - odds (|> the_array /.to_list (list.only n.odd?))] + evens (|> the_array /.list (list.only n.even?)) + odds (|> the_array /.list (list.only n.odd?))] (_.cover [/.filter!] (exec (/.filter! n.even? the_array) (and (n.= (list.size evens) (/.occupancy the_array)) (n.= (list.size odds) (/.vacancy the_array)) - (|> the_array /.to_list (\ (list.equivalence n.equivalence) = evens)))))) + (|> the_array /.list (\ (list.equivalence n.equivalence) = evens)))))) (do ! - [#let [the_array (/.clone the_array) - members (|> the_array /.to_list (set.of_list n.hash))] + [.let [the_array (/.clone the_array) + members (|> the_array /.list (set.of_list n.hash))] default (random.only (function (_ value) (not (or (n.even? value) (set.member? members value)))) random.nat)] - (_.cover [/.to_list'] + (_.cover [/.list'] (exec (/.filter! n.even? the_array) (list.every? (function (_ value) (or (n.even? value) (is? default value))) - (/.to_list' default the_array))))) + (/.list' default the_array))))) )))) diff --git a/stdlib/source/test/lux/data/collection/dictionary.lux b/stdlib/source/test/lux/data/collection/dictionary.lux index 11c4b59cd..fe04241a1 100644 --- a/stdlib/source/test/lux/data/collection/dictionary.lux +++ b/stdlib/source/test/lux/data/collection/dictionary.lux @@ -31,7 +31,7 @@ (def: for_dictionaries Test (do {! random.monad} - [#let [capped_nat (\ random.monad map (n.% 100) random.nat)] + [.let [capped_nat (\ random.monad map (n.% 100) random.nat)] size capped_nat dict (random.dictionary n.hash size random.nat capped_nat) non_key (random.only (|>> (/.key? dict) not) @@ -54,7 +54,7 @@ (do ! [constant random.nat - #let [hash (: (Hash Nat) + .let [hash (: (Hash Nat) (implementation (def: &equivalence n.equivalence) (def: (hash _) @@ -133,7 +133,7 @@ (def: for_entries Test (do random.monad - [#let [capped_nat (\ random.monad map (n.% 100) random.nat)] + [.let [capped_nat (\ random.monad map (n.% 100) random.nat)] size capped_nat dict (random.dictionary n.hash size random.nat capped_nat) non_key (random.only (|>> (/.key? dict) not) @@ -253,7 +253,7 @@ (<| (_.covering /._) (_.for [/.Dictionary]) (do random.monad - [#let [capped_nat (\ random.monad map (n.% 100) random.nat)] + [.let [capped_nat (\ random.monad map (n.% 100) random.nat)] size capped_nat dict (random.dictionary n.hash size random.nat capped_nat) non_key (random.only (|>> (/.key? dict) not) diff --git a/stdlib/source/test/lux/data/collection/dictionary/ordered.lux b/stdlib/source/test/lux/data/collection/dictionary/ordered.lux index 4637d3058..fb57cd70e 100644 --- a/stdlib/source/test/lux/data/collection/dictionary/ordered.lux +++ b/stdlib/source/test/lux/data/collection/dictionary/ordered.lux @@ -49,8 +49,8 @@ random.nat) extra_value random.nat shift random.nat - #let [pairs (list.zipped/2 (set.to_list keys) - (set.to_list values)) + .let [pairs (list.zipped/2 (set.list keys) + (set.list values)) sample (/.of_list n.order pairs) sorted_pairs (list.sort (function (_ [left _] [right _]) (n.< left right)) diff --git a/stdlib/source/test/lux/data/collection/dictionary/plist.lux b/stdlib/source/test/lux/data/collection/dictionary/plist.lux index 5ba785919..316d7c7ce 100644 --- a/stdlib/source/test/lux/data/collection/dictionary/plist.lux +++ b/stdlib/source/test/lux/data/collection/dictionary/plist.lux @@ -26,18 +26,18 @@ (do random.monad [keys (random.set text.hash size gen_key) values (random.list size gen_value)] - (in (list.zipped/2 (set.to_list keys) values)))) + (in (list.zipped/2 (set.list keys) values)))) (def: #export test Test (<| (_.covering /._) (_.for [/.PList]) (do {! random.monad} - [#let [gen_key (random.ascii/alpha 10)] + [.let [gen_key (random.ascii/alpha 10)] size (\ ! map (n.% 100) random.nat) sample (..random size gen_key random.nat) - #let [keys (|> sample /.keys (set.of_list text.hash))] + .let [keys (|> sample /.keys (set.of_list text.hash))] extra_key (random.only (|>> (set.member? keys) not) gen_key) extra_value random.nat diff --git a/stdlib/source/test/lux/data/collection/list.lux b/stdlib/source/test/lux/data/collection/list.lux index 209dfe143..a0c6fc685 100644 --- a/stdlib/source/test/lux/data/collection/list.lux +++ b/stdlib/source/test/lux/data/collection/list.lux @@ -43,7 +43,7 @@ [size ..bounded_size] (|> random.nat (random.set n.hash size) - (\ ! map set.to_list)))) + (\ ! map set.list)))) (def: signatures Test @@ -87,8 +87,8 @@ Test (do {! random.monad} [size ..bounded_size - #let [(^open "/\.") (/.equivalence n.equivalence)] - sample (\ ! map set.to_list (random.set n.hash size random.nat))] + .let [(^open "/\.") (/.equivalence n.equivalence)] + sample (\ ! map set.list (random.set n.hash size random.nat))] ($_ _.and (_.cover [/.size] (n.= size (/.size sample))) @@ -133,7 +133,7 @@ (^open "/\.") /.functor] (do {! random.monad} [sample ..random - #let [size (/.size sample)]] + .let [size (/.size sample)]] ($_ _.and (_.cover [/.indices] (let [indices (/.indices size) @@ -183,7 +183,7 @@ (do {! random.monad} [sample (random.only (|>> /.size (n.> 0)) ..random) - #let [size (/.size sample)] + .let [size (/.size sample)] idx (\ ! map (n.% size) random.nat) chunk_size (\ ! map (|>> (n.% size) inc) random.nat)] ($_ _.and @@ -427,4 +427,10 @@ (\ /.fold fold n.+ 0 (/.take index sample))) (/.indices (inc (/.size sample)))) (/.folds n.+ 0 sample))) + (do random.monad + [expected random.nat + .let [(^open "/\.") (/.equivalence n.equivalence)]] + (_.cover [/.when] + (and (/\= (list expected) (/.when true (list expected))) + (/\= (list) (/.when false (list expected)))))) ))))) diff --git a/stdlib/source/test/lux/data/collection/queue.lux b/stdlib/source/test/lux/data/collection/queue.lux index b394220ef..36f6ef9a4 100644 --- a/stdlib/source/test/lux/data/collection/queue.lux +++ b/stdlib/source/test/lux/data/collection/queue.lux @@ -32,7 +32,7 @@ members (random.set n.hash size random.nat) non_member (random.only (|>> (set.member? members) not) random.nat) - #let [members (set.to_list members) + .let [members (set.list members) sample (/.of_list members)]] ($_ _.and (_.for [/.equivalence] @@ -40,8 +40,8 @@ (_.for [/.functor] ($functor.spec ..injection /.equivalence /.functor)) - (_.cover [/.of_list /.to_list] - (|> members /.of_list /.to_list + (_.cover [/.of_list /.list] + (|> members /.of_list /.list (\ (list.equivalence n.equivalence) = members))) (_.cover [/.size] (n.= size (/.size sample))) @@ -71,7 +71,7 @@ (_.cover [/.member?] (let [every_member_is_identified! (list.every? (/.member? n.equivalence sample) - (/.to_list sample)) + (/.list sample)) non_member_is_not_identified! (not (/.member? n.equivalence sample non_member))] @@ -88,8 +88,8 @@ has_expected_order! (\ (list.equivalence n.equivalence) = - (list\compose (/.to_list sample) (list non_member)) - (/.to_list pushed))] + (list\compose (/.list sample) (list non_member)) + (/.list pushed))] (and size_increases! new_member_is_identified! has_expected_order!))) @@ -108,7 +108,7 @@ has_expected_order! (\ (list.equivalence n.equivalence) = expected - (/.to_list popped))] + (/.list popped))] (and size_decreases! popped_member_is_not_identified! has_expected_order!)) diff --git a/stdlib/source/test/lux/data/collection/row.lux b/stdlib/source/test/lux/data/collection/row.lux index 4eda82b14..343442e91 100644 --- a/stdlib/source/test/lux/data/collection/row.lux +++ b/stdlib/source/test/lux/data/collection/row.lux @@ -50,8 +50,8 @@ (do {! random.monad} [size (\ ! map (n.% 100) random.nat) sample (random.set n.hash size random.nat) - #let [sample (|> sample set.to_list /.of_list)] - #let [(^open "/\.") (/.equivalence n.equivalence)]] + .let [sample (|> sample set.list /.of_list)] + .let [(^open "/\.") (/.equivalence n.equivalence)]] ($_ _.and (_.cover [/.size] (n.= size (/.size sample))) @@ -59,8 +59,8 @@ (bit\= (/.empty? sample) (n.= 0 (/.size sample)))) (_.cover [/.empty] (/.empty? /.empty)) - (_.cover [/.to_list /.of_list] - (|> sample /.to_list /.of_list (/\= sample))) + (_.cover [/.list /.of_list] + (|> sample /.list /.of_list (/\= sample))) (_.cover [/.reversed] (or (n.< 2 (/.size sample)) (let [not_same! @@ -85,11 +85,11 @@ ($_ _.and (do ! [good_index (|> random.nat (\ ! map (n.% size))) - #let [bad_index (n.+ size good_index)] + .let [bad_index (n.+ size good_index)] sample (random.set n.hash size random.nat) non_member (random.only (|>> (set.member? sample) not) random.nat) - #let [sample (|> sample set.to_list /.of_list)]] + .let [sample (|> sample set.list /.of_list)]] ($_ _.and (_.cover [/.item] (case (/.item good_index sample) @@ -144,8 +144,8 @@ [sample (random.set n.hash size random.nat) non_member (random.only (|>> (set.member? sample) not) random.nat) - #let [sample (|> sample set.to_list /.of_list)] - #let [(^open "/\.") (/.equivalence n.equivalence)]] + .let [sample (|> sample set.list /.of_list)] + .let [(^open "/\.") (/.equivalence n.equivalence)]] ($_ _.and (do ! [value/0 random.nat @@ -156,7 +156,7 @@ (/.row value/0 value/1 value/2)))) (_.cover [/.member?] (and (list.every? (/.member? n.equivalence sample) - (/.to_list sample)) + (/.list sample)) (not (/.member? n.equivalence sample non_member)))) (_.cover [/.add] (let [added (/.add non_member sample) diff --git a/stdlib/source/test/lux/data/collection/set.lux b/stdlib/source/test/lux/data/collection/set.lux index d092dcf6f..df0c653b9 100644 --- a/stdlib/source/test/lux/data/collection/set.lux +++ b/stdlib/source/test/lux/data/collection/set.lux @@ -67,10 +67,10 @@ (_.cover [/.empty?] (bit\= (/.empty? setL) (n.= 0 (/.size setL)))) - (_.cover [/.to_list /.of_list] - (|> setL /.to_list (/.of_list n.hash) (\= setL))) + (_.cover [/.list /.of_list] + (|> setL /.list (/.of_list n.hash) (\= setL))) (_.cover [/.member?] - (and (list.every? (/.member? setL) (/.to_list setL)) + (and (list.every? (/.member? setL) (/.list setL)) (not (/.member? setL non_memberL)))) (_.cover [/.add] (let [before_addition! @@ -126,8 +126,8 @@ (_.cover [/.difference] (let [setL+R (/.union setR setL) setL_R (/.difference setR setL+R)] - (and (list.every? (/.member? setL+R) (/.to_list setR)) - (not (list.any? (/.member? setL_R) (/.to_list setR)))))) + (and (list.every? (/.member? setL+R) (/.list setR)) + (not (list.any? (/.member? setL_R) (/.list setR)))))) (_.cover [/.predicate] - (list.every? (/.predicate setL) (/.to_list setL))) + (list.every? (/.predicate setL) (/.list setL))) )))))) diff --git a/stdlib/source/test/lux/data/collection/set/multi.lux b/stdlib/source/test/lux/data/collection/set/multi.lux index 7f23bfe3d..37645cbed 100644 --- a/stdlib/source/test/lux/data/collection/set/multi.lux +++ b/stdlib/source/test/lux/data/collection/set/multi.lux @@ -34,7 +34,7 @@ (/.add count element set)) (/.empty hash) (list.zipped/2 element_counts - (set.to_list elements)))))) + (set.list elements)))))) (def: signature Test @@ -69,16 +69,16 @@ no_left_changes! (list.every? (function (_ member) (n.= (/.multiplicity sample member) (/.multiplicity composed member))) - (set.to_list sample_only)) + (set.list sample_only)) no_right_changes! (list.every? (function (_ member) (n.= (/.multiplicity another member) (/.multiplicity composed member))) - (set.to_list another_only)) + (set.list another_only)) common_changes! (list.every? (function (_ member) (n.= (<composition> (/.multiplicity sample member) (/.multiplicity another member)) (/.multiplicity composed member))) - (set.to_list common))] + (set.list common))] (and no_left_changes! no_right_changes! common_changes!)))] @@ -95,14 +95,14 @@ composed (/.intersection sample another) left_removals! (list.every? (|>> (/.member? composed) not) - (set.to_list sample_only)) + (set.list sample_only)) right_removals! (list.every? (|>> (/.member? composed) not) - (set.to_list another_only)) + (set.list another_only)) common_changes! (list.every? (function (_ member) (n.= (n.min (/.multiplicity sample member) (/.multiplicity another member)) (/.multiplicity composed member))) - (set.to_list common))] + (set.list common))] (and left_removals! right_removals! common_changes!))) @@ -121,13 +121,13 @@ partial_removal_count (\ ! map (n.% addition_count) random.nat) another (..random diversity n.hash ..count random.nat)] ($_ _.and - (_.cover [/.to_list /.of_list] + (_.cover [/.list /.of_list] (|> sample - /.to_list + /.list (/.of_list n.hash) (\ /.equivalence = sample))) (_.cover [/.size] - (n.= (list.size (/.to_list sample)) + (n.= (list.size (/.list sample)) (/.size sample))) (_.cover [/.empty?] (bit\= (/.empty? sample) @@ -136,14 +136,14 @@ (/.empty? (/.empty n.hash))) (_.cover [/.support] (list.every? (set.member? (/.support sample)) - (/.to_list sample))) + (/.list sample))) (_.cover [/.member?] (let [non_member_is_not_identified! (not (/.member? sample non_member)) all_members_are_identified! (list.every? (/.member? sample) - (/.to_list sample))] + (/.list sample))] (and non_member_is_not_identified! all_members_are_identified!))) (_.cover [/.multiplicity] @@ -152,7 +152,7 @@ every_member_has_positive_multiplicity! (list.every? (|>> (/.multiplicity sample) (n.> 0)) - (/.to_list sample))] + (/.list sample))] (and non_members_have_0_multiplicity! every_member_has_positive_multiplicity!))) (_.cover [/.add] @@ -197,7 +197,7 @@ (_.cover [/.of_set] (let [unary (|> sample /.support /.of_set)] (list.every? (|>> (/.multiplicity unary) (n.= 1)) - (/.to_list unary)))) + (/.list unary)))) (_.cover [/.sub?] (let [unary (|> sample /.support /.of_set)] (and (/.sub? sample unary) @@ -217,11 +217,11 @@ composed (/.difference sample another) ommissions! (list.every? (|>> (/.member? composed) not) - (set.to_list sample_only)) + (set.list sample_only)) intact! (list.every? (function (_ member) (n.= (/.multiplicity another member) (/.multiplicity composed member))) - (set.to_list another_only)) + (set.list another_only)) subtractions! (list.every? (function (_ member) (let [sample_multiplicity (/.multiplicity sample member) another_multiplicity (/.multiplicity another member)] @@ -230,7 +230,7 @@ (n.- sample_multiplicity another_multiplicity)) (/.multiplicity composed member)))) - (set.to_list common))] + (set.list common))] (and ommissions! intact! subtractions!))) diff --git a/stdlib/source/test/lux/data/collection/set/ordered.lux b/stdlib/source/test/lux/data/collection/set/ordered.lux index 89ce681b0..620a63289 100644 --- a/stdlib/source/test/lux/data/collection/set/ordered.lux +++ b/stdlib/source/test/lux/data/collection/set/ordered.lux @@ -46,9 +46,9 @@ usetL (random.set n.hash sizeL random.nat) non_memberL (random.only (|>> (//.member? usetL) not) random.nat) - #let [listL (//.to_list usetL)] - listR (|> (random.set n.hash sizeR random.nat) (\ ! map //.to_list)) - #let [(^open "/\.") /.equivalence + .let [listL (//.list usetL)] + listR (|> (random.set n.hash sizeR random.nat) (\ ! map //.list)) + .let [(^open "/\.") /.equivalence setL (/.of_list n.order listL) setR (/.of_list n.order listR) empty (/.empty n.order)]] @@ -63,19 +63,19 @@ (/.empty? setL))) (_.cover [/.empty] (/.empty? (/.empty n.order))) - (_.cover [/.to_list] + (_.cover [/.list] (\ (list.equivalence n.equivalence) = - (/.to_list (/.of_list n.order listL)) + (/.list (/.of_list n.order listL)) (list.sort (\ n.order <) listL))) (_.cover [/.of_list] (|> setL - /.to_list (/.of_list n.order) + /.list (/.of_list n.order) (/\= setL))) (~~ (template [<coverage> <comparison>] [(_.cover [<coverage>] (case (<coverage> setL) (#.Some value) - (|> setL /.to_list (list.every? (<comparison> value))) + (|> setL /.list (list.every? (<comparison> value))) #.None (/.empty? setL)))] @@ -85,7 +85,7 @@ )) (_.cover [/.member?] (let [members_are_identified! - (list.every? (/.member? setL) (/.to_list setL)) + (list.every? (/.member? setL) (/.list setL)) non_members_are_not_identified! (not (/.member? setL non_memberL))] @@ -164,7 +164,7 @@ difference! (not (list.any? (/.member? (/.difference setL setR)) - (/.to_list setL))) + (/.list setL))) idempotence! (\ /.equivalence = diff --git a/stdlib/source/test/lux/data/collection/tree/finger.lux b/stdlib/source/test/lux/data/collection/tree/finger.lux index 496c25865..be46b8249 100644 --- a/stdlib/source/test/lux/data/collection/tree/finger.lux +++ b/stdlib/source/test/lux/data/collection/tree/finger.lux @@ -78,7 +78,7 @@ (\ ..builder leaf tag_left expected_left) (\ ..builder leaf tag_right expected_right)))))) (do random.monad - [#let [tags_equivalence (list.equivalence text.equivalence) + [.let [tags_equivalence (list.equivalence text.equivalence) values_equivalence (list.equivalence n.equivalence)] tags/H (random.ascii/alpha_num 1) tags/T (random.list 5 (random.ascii/alpha_num 1)) diff --git a/stdlib/source/test/lux/data/collection/tree/zipper.lux b/stdlib/source/test/lux/data/collection/tree/zipper.lux index 749a8c59b..756318c0b 100644 --- a/stdlib/source/test/lux/data/collection/tree/zipper.lux +++ b/stdlib/source/test/lux/data/collection/tree/zipper.lux @@ -159,7 +159,7 @@ [[size sample] (//.tree random.nat) expected random.nat dummy (random.only (|>> (n.= expected) not) random.nat) - #let [(^open "tree\.") (tree.equivalence n.equivalence) + .let [(^open "tree\.") (tree.equivalence n.equivalence) (^open "list\.") (list.equivalence n.equivalence)]] ($_ _.and (_.for [/.equivalence] diff --git a/stdlib/source/test/lux/data/color.lux b/stdlib/source/test/lux/data/color.lux index 81c45a8e2..990eb6aea 100644 --- a/stdlib/source/test/lux/data/color.lux +++ b/stdlib/source/test/lux/data/color.lux @@ -48,8 +48,8 @@ (def: (distance/3 from to) (-> /.Color /.Color Frac) - (let [[fr fg fb] (/.to_rgb from) - [tr tg tb] (/.to_rgb to)] + (let [[fr fg fb] (/.rgb from) + [tr tg tb] (/.rgb to)] (square_root ($_ f.+ (|> (scale tr) (f.- (scale fr)) square) @@ -61,7 +61,7 @@ (template [<field>] [(def: (<field> color) (-> /.Color Frac) - (let [[hue saturation luminance] (/.to_hsl color)] + (let [[hue saturation luminance] (/.hsl color)] <field>))] [saturation] @@ -71,19 +71,19 @@ (def: (encoding expected) (-> /.Color Test) ($_ _.and - (_.cover [/.RGB /.to_rgb /.of_rgb] - (|> expected /.to_rgb /.of_rgb + (_.cover [/.RGB /.rgb /.of_rgb] + (|> expected /.rgb /.of_rgb (\ /.equivalence = expected))) - (_.cover [/.HSL /.to_hsl /.of_hsl] - (|> expected /.to_hsl /.of_hsl + (_.cover [/.HSL /.hsl /.of_hsl] + (|> expected /.hsl /.of_hsl (distance/3 expected) (f.<= ..rgb_error_margin))) - (_.cover [/.HSB /.to_hsb /.of_hsb] - (|> expected /.to_hsb /.of_hsb + (_.cover [/.HSB /.hsb /.of_hsb] + (|> expected /.hsb /.of_hsb (distance/3 expected) (f.<= ..rgb_error_margin))) - (_.cover [/.CMYK /.to_cmyk /.of_cmyk] - (|> expected /.to_cmyk /.of_cmyk + (_.cover [/.CMYK /.cmyk /.of_cmyk] + (|> expected /.cmyk /.of_cmyk (distance/3 expected) (f.<= ..rgb_error_margin))) )) @@ -133,9 +133,9 @@ (do {! random.monad} [eH (\ ! map (|>> f.abs (f.% +0.9) (f.+ +0.05)) random.safe_frac) - #let [eS +0.5] + .let [eS +0.5] variations (\ ! map (|>> (n.% 3) (n.+ 2)) random.nat) - #let [max_spread (f./ (|> variations inc .int int.frac) + .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)] diff --git a/stdlib/source/test/lux/data/format/json.lux b/stdlib/source/test/lux/data/format/json.lux index 940f22cd8..1c4469df2 100644 --- a/stdlib/source/test/lux/data/format/json.lux +++ b/stdlib/source/test/lux/data/format/json.lux @@ -90,8 +90,8 @@ (do random.monad [keys (random.set text.hash 3 (random.ascii/alpha 1)) values (random.set frac.hash 3 random.safe_frac) - #let [expected (list.zipped/2 (set.to_list keys) - (list\map (|>> #/.Number) (set.to_list values))) + .let [expected (list.zipped/2 (set.list keys) + (list\map (|>> #/.Number) (set.list values))) object (/.object expected)]] ($_ _.and (_.cover [/.object /.fields] @@ -119,7 +119,7 @@ (<| (try.else false) (do try.monad [object (/.set key (#/.Number expected) (/.object (list))) - #let [can_find_known_key! + .let [can_find_known_key! (|> object (/.get key) (try\map (\= (#/.Number expected))) diff --git a/stdlib/source/test/lux/data/format/tar.lux b/stdlib/source/test/lux/data/format/tar.lux index 13c713f7f..34618433b 100644 --- a/stdlib/source/test/lux/data/format/tar.lux +++ b/stdlib/source/test/lux/data/format/tar.lux @@ -162,7 +162,7 @@ random.nat) chunk (random.ascii/lower chunk_size) chunks (\ ! map (n.% 100) random.nat) - #let [content (|> chunk + .let [content (|> chunk (list.repeat chunks) (text.join_with "") (\ utf8.codec encode))]] @@ -174,7 +174,7 @@ tar (|> (row.row (<tag> expected_path)) (format.run /.writer) (<b>.run /.parser))] - (in (case (row.to_list tar) + (in (case (row.list tar) (^ (list (<tag> actual_path))) (text\= (/.from_path expected_path) (/.from_path actual_path)) @@ -203,7 +203,7 @@ expected_content])) (format.run /.writer) (<b>.run /.parser))] - (in (case (row.to_list tar) + (in (case (row.list tar) (^ (list (<tag> [actual_path actual_moment actual_mode actual_ownership actual_content]))) (let [seconds (: (-> Instant Int) (|>> instant.relative (duration.query duration.second)))] @@ -245,7 +245,7 @@ (do {! random.monad} [path (random.ascii/lower 10) modes (random.list 4 ..random_mode) - #let [expected_mode (list\fold /.and /.none modes)]] + .let [expected_mode (list\fold /.and /.none modes)]] (`` ($_ _.and (_.cover [/.and] (|> (do try.monad @@ -261,7 +261,7 @@ content])) (format.run /.writer) (<b>.run /.parser))] - (in (case (row.to_list tar) + (in (case (row.list tar) (^ (list (#/.Normal [_ _ actual_mode _ _]))) (n.= (/.mode expected_mode) (/.mode actual_mode)) @@ -284,7 +284,7 @@ content])) (format.run /.writer) (<b>.run /.parser))] - (in (case (row.to_list tar) + (in (case (row.list tar) (^ (list (#/.Normal [_ _ actual_mode _ _]))) (n.= (/.mode <expected_mode>) (/.mode actual_mode)) @@ -351,7 +351,7 @@ content])) (format.run /.writer) (<b>.run /.parser))] - (in (case (row.to_list tar) + (in (case (row.list tar) (^ (list (#/.Normal [_ _ _ actual_ownership _]))) (and (text\= (/.from_name expected) (/.from_name (get@ [#/.user #/.name] actual_ownership))) @@ -375,7 +375,7 @@ content])) (format.run /.writer) (<b>.run /.parser))] - (in (case (row.to_list tar) + (in (case (row.list tar) (^ (list (#/.Normal [_ _ _ actual_ownership _]))) (and (text\= (/.from_name /.anonymous) (/.from_name (get@ [#/.user #/.name] actual_ownership))) diff --git a/stdlib/source/test/lux/data/lazy.lux b/stdlib/source/test/lux/data/lazy.lux index 4fb2f6642..c30fd3692 100644 --- a/stdlib/source/test/lux/data/lazy.lux +++ b/stdlib/source/test/lux/data/lazy.lux @@ -40,7 +40,7 @@ (do random.monad [left random.nat right random.nat - #let [expected <eager>]] + .let [expected <eager>]] (_.for [/.Lazy] ($_ _.and (_.for [/.equivalence] diff --git a/stdlib/source/test/lux/data/maybe.lux b/stdlib/source/test/lux/data/maybe.lux index 9aa890d9f..65d405473 100644 --- a/stdlib/source/test/lux/data/maybe.lux +++ b/stdlib/source/test/lux/data/maybe.lux @@ -48,7 +48,7 @@ (do random.monad [left random.nat right random.nat - #let [expected (n.+ left right)]] + .let [expected (n.+ left right)]] (let [lift (/.lift io.monad)] (_.cover [/.with /.lift] (|> (io.run (do (/.with io.monad) @@ -75,8 +75,14 @@ (is? value (/.assume (#.Some value))))) (do random.monad [value random.nat] - (_.cover [/.to_list] + (_.cover [/.list] (\ (list.equivalence n.equivalence) = (list value) - (/.to_list (#.Some value))))) + (/.list (#.Some value))))) + (do random.monad + [expected random.nat + .let [(^open "/\.") (/.equivalence n.equivalence)]] + (_.cover [/.when] + (and (/\= (#.Some expected) (/.when true (#.Some expected))) + (/\= #.None (/.when false (#.Some expected)))))) ))) diff --git a/stdlib/source/test/lux/data/text.lux b/stdlib/source/test/lux/data/text.lux index 3e063f73a..5d02dbfcf 100644 --- a/stdlib/source/test/lux/data/text.lux +++ b/stdlib/source/test/lux/data/text.lux @@ -56,7 +56,7 @@ (random.unicode 1)) left (random.unicode 1) right (random.unicode 1) - #let [full (\ /.monoid compose inner outer) + .let [full (\ /.monoid compose inner outer) fake_index (dec 0)]] (`` ($_ _.and (~~ (template [<affix> <predicate>] @@ -83,7 +83,7 @@ [inner (random.unicode 1) outer (random.only (|>> (\ /.equivalence = inner) not) (random.unicode 1)) - #let [fake_index (dec 0)]] + .let [fake_index (dec 0)]] ($_ _.and (_.cover [/.contains?] (let [full (\ /.monoid compose inner outer)] @@ -122,24 +122,6 @@ (|> (/.last_index_of outer full) (maybe.else fake_index) (n.= 2))))) - (_.cover [/.last_index_of'] - (let [full ($_ (\ /.monoid compose) outer inner outer)] - (and (|> (/.last_index_of' 0 inner full) - (maybe.else fake_index) - (n.= 1)) - (|> (/.last_index_of' 2 inner full) - (maybe.else fake_index) - (n.= fake_index)) - - (|> (/.last_index_of' 0 outer full) - (maybe.else fake_index) - (n.= 2)) - (|> (/.last_index_of' 2 outer full) - (maybe.else fake_index) - (n.= 2)) - (|> (/.last_index_of' 3 outer full) - (maybe.else fake_index) - (n.= fake_index))))) ))) (def: char @@ -166,7 +148,7 @@ (do {! random.monad} [size (\ ! map (|>> (n.% 10) inc) random.nat) characters (random.set /.hash size (random.ascii/alpha 1)) - #let [sample (|> characters set.to_list /.concat)] + .let [sample (|> characters set.list /.concat)] expected (\ ! map (n.% size) random.nat)] (_.cover [/.char] (case (/.char expected sample) @@ -200,9 +182,9 @@ characters (random.set /.hash size (random.ascii/alpha 1)) separator (random.only (|>> (set.member? characters) not) (random.ascii/alpha 1)) - #let [with_no_separator (|> characters set.to_list /.concat)] + .let [with_no_separator (|> characters set.list /.concat)] static (random.ascii/alpha 1) - #let [dynamic (random.only (|>> (\ /.equivalence = static) not) + .let [dynamic (random.only (|>> (\ /.equivalence = static) not) (random.ascii/alpha 1))] pre dynamic post dynamic @@ -212,16 +194,16 @@ ($_ _.and (_.cover [/.concat] (n.= (set.size characters) - (/.size (/.concat (set.to_list characters))))) + (/.size (/.concat (set.list characters))))) (_.cover [/.join_with /.split_all_with] - (and (|> (set.to_list characters) + (and (|> (set.list characters) (/.join_with separator) (/.split_all_with separator) (set.of_list /.hash) (\ set.equivalence = characters)) (\ /.equivalence = - (/.concat (set.to_list characters)) - (/.join_with "" (set.to_list characters))))) + (/.concat (set.list characters)) + (/.join_with "" (set.list characters))))) (_.cover [/.replace_once] (\ /.equivalence = (\ /.monoid compose post static) @@ -303,7 +285,7 @@ sampleL (random.unicode sizeL) sampleR (random.unicode sizeR) middle (random.unicode 1) - #let [sample (/.concat (list sampleL sampleR)) + .let [sample (/.concat (list sampleL sampleR)) (^open "/\.") /.equivalence]] ($_ _.and (_.cover [/.split] @@ -332,16 +314,16 @@ (do {! random.monad} [sizeP bounded_size sizeL bounded_size - #let [## The wider unicode charset includes control characters that + .let [## The wider unicode charset includes control characters that ## can make text replacement work improperly. ## Because of that, I restrict the charset. normal_char_gen (|> random.nat (\ ! map (|>> (n.% 128) (n.max 1))))] sep1 (random.text normal_char_gen 1) sep2 (random.text normal_char_gen 1) - #let [part_gen (|> (random.text normal_char_gen sizeP) + .let [part_gen (|> (random.text normal_char_gen sizeP) (random.only (|>> (/.contains? sep1) not)))] parts (random.list sizeL part_gen) - #let [sample1 (/.concat (list.interpose sep1 parts)) + .let [sample1 (/.concat (list.interpose sep1 parts)) sample2 (/.concat (list.interpose sep2 parts)) (^open "/\.") /.equivalence]] (_.cover [/.replace_all] diff --git a/stdlib/source/test/lux/data/text/escape.lux b/stdlib/source/test/lux/data/text/escape.lux index 34f37de58..21266b277 100644 --- a/stdlib/source/test/lux/data/text/escape.lux +++ b/stdlib/source/test/lux/data/text/escape.lux @@ -72,7 +72,7 @@ (syntax: (static_sample) (do meta.monad [seed meta.seed - #let [[_ expected] (random.run (random.pcg32 [seed seed]) + .let [[_ expected] (random.run (random.pcg_32 [seed seed]) (random.ascii 10))]] (in (list (code.text expected))))) diff --git a/stdlib/source/test/lux/data/text/unicode/block.lux b/stdlib/source/test/lux/data/text/unicode/block.lux index 9588ce6ce..e2a415abd 100644 --- a/stdlib/source/test/lux/data/text/unicode/block.lux +++ b/stdlib/source/test/lux/data/text/unicode/block.lux @@ -170,12 +170,12 @@ (<| (_.covering /._) (_.for [/.Block]) (do {! random.monad} - [#let [top_start (hex "AC00") + [.let [top_start (hex "AC00") top_end (hex "D7AF") end_range (n.- top_start top_end)] start (\ ! map (|>> (n.% top_start) inc) random.nat) end (\ ! map (|>> (n.% end_range) (n.+ top_start)) random.nat) - #let [additional (n.- start end) + .let [additional (n.- start end) sample (/.block start additional) size (/.size sample)] inside (\ ! map diff --git a/stdlib/source/test/lux/data/text/unicode/set.lux b/stdlib/source/test/lux/data/text/unicode/set.lux index cd74a038c..0f50a1dd7 100644 --- a/stdlib/source/test/lux/data/text/unicode/set.lux +++ b/stdlib/source/test/lux/data/text/unicode/set.lux @@ -42,7 +42,7 @@ random.nat) left //block.random right //block.random - #let [equivalence (product.equivalence n.equivalence + .let [equivalence (product.equivalence n.equivalence n.equivalence)]] (`` ($_ _.and (_.for [/.equivalence] @@ -76,7 +76,7 @@ (~~ (template [<set>] [(do random.monad [char (random.char <set>) - #let [start (/.start <set>) + .let [start (/.start <set>) end (/.end <set>)]] (_.cover [<set>] (and (/.member? <set> char) |