diff options
Diffstat (limited to 'stdlib/source/test/lux/data')
20 files changed, 114 insertions, 114 deletions
diff --git a/stdlib/source/test/lux/data/binary.lux b/stdlib/source/test/lux/data/binary.lux index 296867c13..05c3c2c6a 100644 --- a/stdlib/source/test/lux/data/binary.lux +++ b/stdlib/source/test/lux/data/binary.lux @@ -54,7 +54,7 @@ (def !expect (template (_ <expectation> <computation>) - [(case <computation> + [(when <computation> <expectation> true @@ -68,7 +68,7 @@ (|> value (at utf8.codec encoded) (at utf8.codec decoded) - (pipe.case + (pipe.when {try.#Success converted} (text#= value converted) @@ -423,7 +423,7 @@ (def (succeed result) (-> (Try Bit) Bit) - (case result + (when result {try.#Failure _} false @@ -443,7 +443,7 @@ (def (throws? exception try) (All (_ e a) (-> (Exception e) (Try a) Bit)) - (case try + (when try {try.#Failure error} (exception.match? exception error) @@ -454,7 +454,7 @@ (-> Nat (-> Nat /.Binary (Try Nat)) (-> Nat Nat /.Binary (Try Any)) Nat Bit) (let [bytes (i64.left_shifted power 1) binary (/.empty bytes) - cap (case bytes + cap (when bytes 8 (-- 0) _ (|> 1 (i64.left_shifted (n.* 8 bytes)) --)) capped_value (i64.and cap value)] @@ -499,7 +499,7 @@ [(_.coverage [<bytes/?> <has/?>] (let [bytes (i64.left_shifted <power> 1) binary (!.empty bytes) - cap (case bytes + cap (when bytes 8 (-- 0) _ (|> 1 (i64.left_shifted (n.* 8 bytes)) --)) capped_value (i64.and cap value) @@ -517,7 +517,7 @@ (_.coverage [!.slice] (let [random_slice (!.slice offset length sample) idxs (is (List Nat) - (case length + (when length 0 (list) _ (enum.range n.enum 0 (-- length)))) reader (function (_ binary idx) @@ -578,13 +578,13 @@ (_.coverage [/.slice] (let [random_slice (try.trusted (/.slice offset length sample)) idxs (is (List Nat) - (case length + (when length 0 (list) _ (enum.range n.enum 0 (-- length)))) reader (function (_ binary idx) (/.bits_8 idx binary))] (and (n.= length (/.size random_slice)) - (case [(monad.each try.monad (|>> (n.+ offset) (reader sample)) idxs) + (when [(monad.each try.monad (|>> (n.+ offset) (reader sample)) idxs) (monad.each try.monad (reader random_slice) idxs)] [{try.#Success binary_vals} {try.#Success slice_vals}] (at (list.equivalence n.equivalence) = binary_vals slice_vals) @@ -594,14 +594,14 @@ (_.coverage [/.slice_out_of_bounds] (and (throws? /.slice_out_of_bounds (/.slice size size sample)) (let [verdict (throws? /.slice_out_of_bounds (/.slice offset size sample))] - (case offset + (when offset 0 (not verdict) _ verdict)))) (_.coverage [/.after] (and (at /.equivalence = sample (/.after 0 sample)) (at /.equivalence = (/.empty 0) (/.after size sample)) (n.= (n.- offset size) (/.size (/.after offset sample))) - (case (list.reversed (..as_list sample)) + (when (list.reversed (..as_list sample)) {.#End} false @@ -609,7 +609,7 @@ (n.= (list.mix n.+ 0 tail) (/.mix n.+ 0 (/.after 1 sample)))))) (_.coverage [/.copy!] - (and (case (/.copy! size 0 sample 0 (/.empty size)) + (and (when (/.copy! size 0 sample 0 (/.empty size)) {try.#Success output} (and (not (same? sample output)) (at /.equivalence = sample output)) diff --git a/stdlib/source/test/lux/data/collection/array.lux b/stdlib/source/test/lux/data/collection/array.lux index f12014f24..b13c77f6b 100644 --- a/stdlib/source/test/lux/data/collection/array.lux +++ b/stdlib/source/test/lux/data/collection/array.lux @@ -70,7 +70,7 @@ {.#Some (at n.decimal encoded value)} {.#None})))] (_.coverage [/.one] - (case [(|> evens + (when [(|> evens (/#each (at n.decimal encoded)) (/.item 0)) (/.one choose evens)] @@ -87,12 +87,12 @@ (/.example n.even? the_array) (list.example n.even? (/.list {.#None} the_array)))) (_.coverage [/.example'] - (case [(/.example n.even? the_array) + (when [(/.example n.even? the_array) (/.example' (function (_ idx member) (n.even? member)) the_array)] [{.#Some expected} {.#Some [idx actual]}] - (case (/.item idx the_array) + (when (/.item idx the_array) {.#Some again} (and (n.= expected actual) (n.= actual again)) @@ -156,7 +156,7 @@ (n.= size (!.size (is (Array Nat) (!.empty size))))) (_.coverage [!.primitive] - (case !.Array + (when !.Array (<| {.#Named (symbol !.Array)} {.#UnivQ (list)} {.#Primitive nominal_type (list {.#Parameter 1})}) @@ -281,7 +281,7 @@ (!.example n.even? the_array) (list.example n.even? (!.list {.#None} the_array)))) (_.coverage [!.example'] - (case [(!.example n.even? the_array) + (when [(!.example n.even? the_array) (!.example' (function (_ idx member) (n.even? member)) the_array)] @@ -324,7 +324,7 @@ (n.= size (/.size (is (Array Nat) (/.empty size))))) (_.coverage [/.primitive] - (case /.Array + (when /.Array (<| {.#Named (symbol /.Array)} {.#Named (symbol !.Array)} {.#UnivQ (list)} @@ -337,7 +337,7 @@ (let [the_array (|> (/.empty 2) (is (Array Nat)) (/.has! 0 expected))] - (case [(/.item 0 the_array) + (when [(/.item 0 the_array) (/.item 1 the_array)] [{.#Some actual} {.#None}] (n.= expected actual) @@ -348,7 +348,7 @@ (let [the_array (|> (/.empty 1) (is (Array Nat)) (/.has! 0 expected))] - (case [(/.item 0 the_array) + (when [(/.item 0 the_array) (/.item 0 (/.lacks! 0 the_array))] [{.#Some actual} {.#None}] (n.= expected actual) @@ -372,7 +372,7 @@ (is (Array Nat)) (/.has! 0 base) (/.revised! 0 (n.+ shift)))] - (case (/.item 0 the_array) + (when (/.item 0 the_array) {.#Some actual} (n.= expected actual) @@ -384,7 +384,7 @@ (/.has! 0 base) (/.upsert! 0 dummy (n.+ shift)) (/.upsert! 1 base (n.+ shift)))] - (case [(/.item 0 the_array) + (when [(/.item 0 the_array) (/.item 1 the_array)] [{.#Some actual/0} {.#Some actual/1}] (and (n.= expected actual/0) diff --git a/stdlib/source/test/lux/data/collection/bits.lux b/stdlib/source/test/lux/data/collection/bits.lux index 379cfd131..2a134ab17 100644 --- a/stdlib/source/test/lux/data/collection/bits.lux +++ b/stdlib/source/test/lux/data/collection/bits.lux @@ -26,7 +26,7 @@ (Random Bits) (do [! random.monad] [size (at ! each (n.% 1,000) random.nat)] - (case size + (when size 0 (in /.empty) _ (do [! random.monad] [idx (|> random.nat (at ! each (n.% size)))] diff --git a/stdlib/source/test/lux/data/collection/dictionary.lux b/stdlib/source/test/lux/data/collection/dictionary.lux index 369bddd2d..d02d9f3a4 100644 --- a/stdlib/source/test/lux/data/collection/dictionary.lux +++ b/stdlib/source/test/lux/data/collection/dictionary.lux @@ -44,7 +44,7 @@ (n.= size (/.size dict))) (_.coverage [/.empty?] - (case size + (when size 0 (/.empty? dict) _ (not (/.empty? dict)))) @@ -147,26 +147,26 @@ (/.keys dict))) (_.coverage [/.value] - (and (list.every? (function (_ key) (case (/.value key dict) + (and (list.every? (function (_ key) (when (/.value key dict) {.#Some _} true _ false)) (/.keys dict)) - (case (/.value non_key dict) + (when (/.value non_key dict) {.#Some _} false _ true))) (_.coverage [/.has] (and (n.= (++ (/.size dict)) (/.size (/.has non_key test_val dict))) - (case (/.value non_key (/.has non_key test_val dict)) + (when (/.value non_key (/.has non_key test_val dict)) {.#Some v} (n.= test_val v) _ true))) (_.coverage [/.has' /.key_already_exists] (let [can_put_new_keys! - (case (/.has' non_key test_val dict) + (when (/.has' non_key test_val dict) {try.#Success dict} - (case (/.value non_key dict) + (when (/.value non_key dict) {.#Some v} (n.= test_val v) _ true) @@ -176,7 +176,7 @@ cannot_put_old_keys! (or (n.= 0 size) (let [first_key (|> dict /.keys list.head maybe.trusted)] - (case (/.has' first_key test_val dict) + (when (/.has' first_key test_val dict) {try.#Success _} false @@ -189,7 +189,7 @@ (and (let [base (/.has non_key test_val dict)] (and (/.key? base non_key) (not (/.key? (/.lacks non_key base) non_key)))) - (case (list.head (/.keys dict)) + (when (list.head (/.keys dict)) {.#None} true @@ -200,7 +200,7 @@ (_.coverage [/.revised] (let [base (/.has non_key test_val dict) updt (/.revised non_key ++ base)] - (case [(/.value non_key base) (/.value non_key updt)] + (when [(/.value non_key base) (/.value non_key updt)] [{.#Some x} {.#Some y}] (n.= (++ x) y) @@ -209,7 +209,7 @@ (_.coverage [/.revised'] (let [can_upsert_new_key! - (case (/.value non_key (/.revised' non_key test_val ++ dict)) + (when (/.value non_key (/.revised' non_key test_val ++ dict)) {.#Some inserted} (n.= (++ test_val) inserted) @@ -217,12 +217,12 @@ false) can_upsert_old_key! - (case (list.head (/.entries dict)) + (when (list.head (/.entries dict)) {.#None} true {.#Some [known_key known_value]} - (case (/.value known_key (/.revised' known_key test_val ++ dict)) + (when (/.value known_key (/.revised' known_key test_val ++ dict)) {.#Some updated} (n.= (++ known_value) updated) diff --git a/stdlib/source/test/lux/data/collection/dictionary/ordered.lux b/stdlib/source/test/lux/data/collection/dictionary/ordered.lux index 7736202d0..951d6c891 100644 --- a/stdlib/source/test/lux/data/collection/dictionary/ordered.lux +++ b/stdlib/source/test/lux/data/collection/dictionary/ordered.lux @@ -27,7 +27,7 @@ (def .public (dictionary order gen_key gen_value size) (All (_ k v) (-> (Order k) (Random k) (Random v) Nat (Random (/.Dictionary k v)))) - (case size + (when size 0 (random#in (/.empty order)) @@ -75,7 +75,7 @@ (_.coverage [/.empty] (/.empty? (/.empty n.order))) (_.coverage [/.min] - (case [(/.min sample) (list.head sorted_values)] + (when [(/.min sample) (list.head sorted_values)] [{.#None} {.#None}] true @@ -85,7 +85,7 @@ _ false)) (_.coverage [/.max] - (case [(/.max sample) (list.last sorted_values)] + (when [(/.max sample) (list.last sorted_values)] [{.#None} {.#None}] true @@ -116,7 +116,7 @@ (/.size sample+)))))) (_.coverage [/.value] (let [sample+ (/.has extra_key extra_value sample)] - (case [(/.value extra_key sample) + (when [(/.value extra_key sample) (/.value extra_key sample+)] [{.#None} {.#Some actual}] (n.= extra_value actual) diff --git a/stdlib/source/test/lux/data/collection/list.lux b/stdlib/source/test/lux/data/collection/list.lux index 6bb1808f7..bd1e684d7 100644 --- a/stdlib/source/test/lux/data/collection/list.lux +++ b/stdlib/source/test/lux/data/collection/list.lux @@ -77,7 +77,7 @@ [a (lifted (io#in parameter)) b (in subject)] (in (n.+ a b)))) - (pipe.case + (pipe.when (list actual) (n.= expected actual) @@ -169,7 +169,7 @@ has_correct_values!))) (_.coverage [/.item] (/.every? (function (_ [index expected]) - (case (/.item index sample) + (when (/.item index sample) {.#Some actual} (n.= expected actual) @@ -177,13 +177,13 @@ false)) (/.enumeration sample))) (do ! - [index (case size + [index (when size 0 random.nat _ (at ! each (n.% size) random.nat)) .let [changed? (/#= sample (/.revised index ++ sample)) same? (/#= sample (/.revised size ++ sample))]] (_.coverage [/.revised] - (case size + (when size 0 (and changed? same?) _ (not changed?)))) @@ -250,7 +250,7 @@ (,, (with_template [<head> <tail> <pre>] [(all _.and (_.coverage [<head>] - (case [(<pre> sample) (<head> sample)] + (when [(<pre> sample) (<head> sample)] [{.#Item expected _} {.#Some actual}] (n.= expected actual) @@ -260,7 +260,7 @@ _ false)) (_.coverage [<tail>] - (case [(<pre> sample) (<tail> sample)] + (when [(<pre> sample) (<tail> sample)] [{.#Item _ expected} {.#Some actual}] (/#= (<pre> expected) actual) @@ -298,7 +298,7 @@ /.size (n.% 2) (n.= 0))] - (case (/.pairs sample/0) + (when (/.pairs sample/0) {.#Some pairs/0} (and even_sized? (n.= (n./ 2 (/.size sample/0)) @@ -384,7 +384,7 @@ [sample ..random] (all _.and (_.coverage [/.one] - (case [(|> sample + (when [(|> sample (/.only n.even?) (/#each (at n.decimal encoded)) /.head) @@ -404,7 +404,7 @@ (/#each (at n.decimal encoded))) (/.all choice sample))) (_.coverage [/.example] - (case (/.example n.even? sample) + (when (/.example n.even? sample) {.#Some found} (n.even? found) diff --git a/stdlib/source/test/lux/data/collection/queue.lux b/stdlib/source/test/lux/data/collection/queue.lux index b1889edc9..99511bab5 100644 --- a/stdlib/source/test/lux/data/collection/queue.lux +++ b/stdlib/source/test/lux/data/collection/queue.lux @@ -60,7 +60,7 @@ (and empty_is_empty! all_empty_queues_look_the_same!))) (_.coverage [/.front] - (case [members (/.front sample)] + (when [members (/.front sample)] [{.#Item head tail} {.#Some first}] (n.= head first) @@ -95,7 +95,7 @@ new_member_is_identified! has_expected_order!))) (_.coverage [/.next] - (case members + (when members {.#Item target expected} (let [popped (/.next sample) diff --git a/stdlib/source/test/lux/data/collection/queue/priority.lux b/stdlib/source/test/lux/data/collection/queue/priority.lux index b0ca6a4f9..b7a1028fe 100644 --- a/stdlib/source/test/lux/data/collection/queue/priority.lux +++ b/stdlib/source/test/lux/data/collection/queue/priority.lux @@ -49,14 +49,14 @@ (_.coverage [/.empty] (/.empty? /.empty)) (_.coverage [/.front] - (case (/.front sample) + (when (/.front sample) {.#Some first} (n.> 0 (/.size sample)) {.#None} (/.empty? sample))) (_.coverage [/.member?] - (case (/.front sample) + (when (/.front sample) {.#Some first} (/.member? n.equivalence sample first) diff --git a/stdlib/source/test/lux/data/collection/sequence.lux b/stdlib/source/test/lux/data/collection/sequence.lux index dac8c85a5..a24d05ed6 100644 --- a/stdlib/source/test/lux/data/collection/sequence.lux +++ b/stdlib/source/test/lux/data/collection/sequence.lux @@ -94,7 +94,7 @@ .let [sample (|> sample set.list /.of_list)]] (all _.and (_.coverage [/.item] - (case (/.item good_index sample) + (when (/.item good_index sample) {try.#Success member} (/.member? n.equivalence sample member) @@ -119,7 +119,7 @@ (_.coverage [/.index_out_of_bounds] (let [fails! (is (All (_ a) (-> (Try a) Bit)) (function (_ situation) - (case situation + (when situation {try.#Success member} false @@ -201,7 +201,7 @@ (if (n.even? value) {.#Some (at n.decimal encoded value)} {.#None})))] - (case [(|> sample + (when [(|> sample (/.only n.even?) (/#each (at n.decimal encoded)) (/.item 0)) diff --git a/stdlib/source/test/lux/data/collection/set/ordered.lux b/stdlib/source/test/lux/data/collection/set/ordered.lux index cc68dbb85..cedc2db15 100644 --- a/stdlib/source/test/lux/data/collection/set/ordered.lux +++ b/stdlib/source/test/lux/data/collection/set/ordered.lux @@ -26,7 +26,7 @@ (def .public (random size order gen_value) (All (_ a) (-> Nat (Order a) (Random a) (Random (Set a)))) - (case size + (when size 0 (random#in (/.empty order)) @@ -74,7 +74,7 @@ (/#= setL))) (,, (with_template [<coverage> <comparison>] [(_.coverage [<coverage>] - (case (<coverage> setL) + (when (<coverage> setL) {.#Some value} (|> setL /.list (list.every? (<comparison> value))) diff --git a/stdlib/source/test/lux/data/collection/stack.lux b/stdlib/source/test/lux/data/collection/stack.lux index 51357230f..22935a5f9 100644 --- a/stdlib/source/test/lux/data/collection/stack.lux +++ b/stdlib/source/test/lux/data/collection/stack.lux @@ -45,14 +45,14 @@ (_.coverage [/.empty] (/.empty? /.empty)) (_.coverage [/.value] - (case (/.value sample) + (when (/.value sample) {.#None} (/.empty? sample) {.#Some _} (not (/.empty? sample)))) (_.coverage [/.next] - (case (/.next sample) + (when (/.next sample) {.#None} (/.empty? sample) @@ -61,7 +61,7 @@ sample (/.top top remaining)))) (_.coverage [/.top] - (case (/.next (/.top expected_top sample)) + (when (/.next (/.top expected_top sample)) {.#Some [actual_top actual_sample]} (and (same? expected_top actual_top) (same? sample actual_sample)) diff --git a/stdlib/source/test/lux/data/collection/tree.lux b/stdlib/source/test/lux/data/collection/tree.lux index 1193c4e9e..8f7ef89da 100644 --- a/stdlib/source/test/lux/data/collection/tree.lux +++ b/stdlib/source/test/lux/data/collection/tree.lux @@ -31,7 +31,7 @@ (def !expect (template (_ <pattern> <value>) - [(case <value> + [(when <value> <pattern> true diff --git a/stdlib/source/test/lux/data/collection/tree/finger.lux b/stdlib/source/test/lux/data/collection/tree/finger.lux index f291a6e51..ff6e1b62f 100644 --- a/stdlib/source/test/lux/data/collection/tree/finger.lux +++ b/stdlib/source/test/lux/data/collection/tree/finger.lux @@ -51,20 +51,20 @@ (at ..builder leaf tag_left expected_left) (at ..builder leaf tag_right expected_right)))))) (_.coverage [/.root] - (and (case (/.root (at ..builder leaf tag_left expected_left)) + (and (when (/.root (at ..builder leaf tag_left expected_left)) {.#Left actual} (n.= expected_left actual) {.#Right _} false) - (case (/.root (at ..builder branch + (when (/.root (at ..builder branch (at ..builder leaf tag_left expected_left) (at ..builder leaf tag_right expected_right))) {.#Left _} false {.#Right [left right]} - (case [(/.root left) + (when [(/.root left) (/.root right)] [{.#Left actual_left} {.#Left actual_right}] (and (n.= expected_left actual_left) diff --git a/stdlib/source/test/lux/data/format/json.lux b/stdlib/source/test/lux/data/format/json.lux index d39552093..0b5dca612 100644 --- a/stdlib/source/test/lux/data/format/json.lux +++ b/stdlib/source/test/lux/data/format/json.lux @@ -54,7 +54,7 @@ (def !expect (template (_ <pattern> <value>) - [(case <value> + [(when <value> <pattern> true @@ -152,7 +152,7 @@ expected_string (random.unicode 1) [boolean_field number_field string_field] (|> (random.set text.hash 3 (random.unicode 3)) (at ! each (|>> set.list - (pipe.case + (pipe.when (list boolean_field number_field string_field) [boolean_field number_field string_field] @@ -312,7 +312,7 @@ (_.coverage [/.Null /.null?] (at bit.equivalence = (/.null? sample) - (case sample + (when sample {/.#Null} true _ false)))) (do random.monad @@ -331,7 +331,7 @@ object (/.object expected)]] (all _.and (_.coverage [/.object /.fields] - (case (/.fields object) + (when (/.fields object) {try.#Success actual} (at (list.equivalence text.equivalence) = (list#each product.left expected) @@ -362,7 +362,7 @@ (try.else false)) cannot_find_unknown_key! - (case (/.field unknown object) + (when (/.field unknown object) {try.#Success _} false diff --git a/stdlib/source/test/lux/data/format/tar.lux b/stdlib/source/test/lux/data/format/tar.lux index 1101f9ca1..a858db473 100644 --- a/stdlib/source/test/lux/data/format/tar.lux +++ b/stdlib/source/test/lux/data/format/tar.lux @@ -47,7 +47,7 @@ /.path_size)] (`` (all _.and (_.coverage [/.path /.from_path] - (case (/.path expected) + (when (/.path expected) {try.#Success actual} (text#= expected (/.from_path actual)) @@ -57,14 +57,14 @@ (_.coverage [/.no_path] (text#= "" (/.from_path /.no_path))) (_.coverage [/.path_size /.path_is_too_long] - (case (/.path invalid) + (when (/.path invalid) {try.#Success _} false {try.#Failure error} (exception.match? /.path_is_too_long error))) (_.coverage [/.not_ascii] - (case (/.path not_ascii) + (when (/.path not_ascii) {try.#Success actual} false @@ -82,7 +82,7 @@ /.name_size)] (`` (all _.and (_.coverage [/.name /.from_name] - (case (/.name expected) + (when (/.name expected) {try.#Success actual} (text#= expected (/.from_name actual)) @@ -90,14 +90,14 @@ {try.#Failure error} false)) (_.coverage [/.name_size /.name_is_too_long] - (case (/.name invalid) + (when (/.name invalid) {try.#Success _} false {try.#Failure error} (exception.match? /.name_is_too_long error))) (_.coverage [/.not_ascii] - (case (/.name not_ascii) + (when (/.name not_ascii) {try.#Success actual} false @@ -113,7 +113,7 @@ invalid (|> random.nat (at ! each (n.max /.small_limit)))] (`` (all _.and (_.coverage [/.small /.from_small] - (case (/.small expected) + (when (/.small expected) {try.#Success actual} (n.= expected (/.from_small actual)) @@ -121,7 +121,7 @@ {try.#Failure error} false)) (_.coverage [/.small_limit /.not_a_small_number] - (case (/.small invalid) + (when (/.small invalid) {try.#Success actual} false @@ -137,7 +137,7 @@ invalid (|> random.nat (at ! each (n.max /.big_limit)))] (`` (all _.and (_.coverage [/.big /.from_big] - (case (/.big expected) + (when (/.big expected) {try.#Success actual} (n.= expected (/.from_big actual)) @@ -145,7 +145,7 @@ {try.#Failure error} false)) (_.coverage [/.big_limit /.not_a_big_number] - (case (/.big invalid) + (when (/.big invalid) {try.#Success actual} false @@ -175,7 +175,7 @@ tar (|> (sequence.sequence {<tag> expected_path}) (\\format.result /.format) (<b>.result /.parser))] - (in (case (sequence.list tar) + (in (when (sequence.list tar) (list {<tag> actual_path}) (text#= (/.from_path expected_path) (/.from_path actual_path)) @@ -204,7 +204,7 @@ expected_content]}) (\\format.result /.format) (<b>.result /.parser))] - (in (case (sequence.list tar) + (in (when (sequence.list tar) (list {<tag> [actual_path actual_moment actual_mode actual_ownership actual_content]}) (let [seconds (is (-> Instant Int) (|>> instant.relative (duration.ticks duration.second)))] @@ -262,7 +262,7 @@ content]}) (\\format.result /.format) (<b>.result /.parser))] - (in (case (sequence.list tar) + (in (when (sequence.list tar) (list {/.#Normal [_ _ actual_mode _ _]}) (n.= (/.mode expected_mode) (/.mode actual_mode)) @@ -285,7 +285,7 @@ content]}) (\\format.result /.format) (<b>.result /.parser))] - (in (case (sequence.list tar) + (in (when (sequence.list tar) (list {/.#Normal [_ _ actual_mode _ _]}) (n.= (/.mode <expected_mode>) (/.mode actual_mode)) @@ -324,14 +324,14 @@ (_.for [/.Ownership /.Owner /.ID] (all _.and (_.coverage [/.name_size /.name_is_too_long] - (case (/.name invalid) + (when (/.name invalid) {try.#Success _} false {try.#Failure error} (exception.match? /.name_is_too_long error))) (_.coverage [/.not_ascii] - (case (/.name not_ascii) + (when (/.name not_ascii) {try.#Success actual} false @@ -352,7 +352,7 @@ content]}) (\\format.result /.format) (<b>.result /.parser))] - (in (case (sequence.list tar) + (in (when (sequence.list tar) (list {/.#Normal [_ _ _ actual_ownership _]}) (and (text#= (/.from_name expected) (/.from_name (the [/.#user /.#name] actual_ownership))) @@ -376,7 +376,7 @@ content]}) (\\format.result /.format) (<b>.result /.parser))] - (in (case (sequence.list tar) + (in (when (sequence.list tar) (list {/.#Normal [_ _ _ actual_ownership _]}) (and (text#= (/.from_name /.anonymous) (/.from_name (the [/.#user /.#name] actual_ownership))) @@ -407,7 +407,7 @@ (try.else false))) (_.coverage [/.invalid_end_of_archive] (let [dump (\\format.result /.format sequence.empty)] - (case (<b>.result /.parser (binary#composite dump dump)) + (when (<b>.result /.parser (binary#composite dump dump)) {try.#Success _} false diff --git a/stdlib/source/test/lux/data/format/xml.lux b/stdlib/source/test/lux/data/format/xml.lux index c4cccc987..44e3c2553 100644 --- a/stdlib/source/test/lux/data/format/xml.lux +++ b/stdlib/source/test/lux/data/format/xml.lux @@ -35,7 +35,7 @@ (def !expect (template (_ <pattern> <value>) - [(case <value> + [(when <value> <pattern> true diff --git a/stdlib/source/test/lux/data/sum.lux b/stdlib/source/test/lux/data/sum.lux index 11430bb32..b0956f5ba 100644 --- a/stdlib/source/test/lux/data/sum.lux +++ b/stdlib/source/test/lux/data/sum.lux @@ -40,13 +40,13 @@ (_.coverage [/.left] (|> (/.left expected) (is (Or Nat Nat)) - (pipe.case + (pipe.when {0 #0 actual} (n.= expected actual) _ false))) (_.coverage [/.right] (|> (/.right expected) (is (Or Nat Nat)) - (pipe.case + (pipe.when {0 #1 actual} (n.= expected actual) _ false))) (_.coverage [/.either] @@ -62,11 +62,11 @@ (and (|> (/.left expected) (is (Or Nat Nat)) (/.then (n.+ shift) (n.- shift)) - (pipe.case {0 #0 actual} (n.= (n.+ shift expected) actual) _ false)) + (pipe.when {0 #0 actual} (n.= (n.+ shift expected) actual) _ false)) (|> (/.right expected) (is (Or Nat Nat)) (/.then (n.+ shift) (n.- shift)) - (pipe.case {0 #1 actual} (n.= (n.- shift expected) actual) _ false)))) + (pipe.when {0 #1 actual} (n.= (n.- shift expected) actual) _ false)))) (do ! [size (at ! each (n.% 5) random.nat) expected (random.list size random.nat)] diff --git a/stdlib/source/test/lux/data/text.lux b/stdlib/source/test/lux/data/text.lux index dca84b015..97fe18d59 100644 --- a/stdlib/source/test/lux/data/text.lux +++ b/stdlib/source/test/lux/data/text.lux @@ -195,7 +195,7 @@ (do random.monad [sample (random.maybe random.nat)] (_.coverage [\\format.maybe] - (case sample + (when sample {.#None} true @@ -215,7 +215,7 @@ (def !expect (template (_ <pattern> <value>) - [(case <value> + [(when <value> <pattern> true @@ -224,7 +224,7 @@ (def (should_fail' sample parser exception) (All (_ a e) (-> Text (\\parser.Parser a) (Exception e) Bit)) - (case (\\parser.result parser sample) + (when (\\parser.result parser sample) {try.#Failure error} (exception.match? exception error) @@ -233,7 +233,7 @@ (def (should_fail sample parser) (All (_ a) (-> Text (\\parser.Parser a) Bit)) - (case (\\parser.result parser sample) + (when (\\parser.result parser sample) {try.#Failure _} true @@ -259,7 +259,7 @@ range (at ! each (|>> (nat.% 50) (nat.+ 10)) random.nat) .let [limit (nat.+ offset range)] expected (at ! each (|>> (nat.% range) (nat.+ offset) /.of_char) random.nat) - out_of_range (case offset + out_of_range (when offset 0 (at ! each (|>> (nat.% 10) ++ (nat.+ limit) /.of_char) random.nat) _ (at ! each (|>> (nat.% offset) /.of_char) random.nat))] (_.coverage [\\parser.range] @@ -745,9 +745,9 @@ .let [sample (|> characters set.list /.together)] expected (at ! each (nat.% size) random.nat)] (_.coverage [/.char] - (case (/.char expected sample) + (when (/.char expected sample) {.#Some char} - (case (/.index (/.of_char char) sample) + (when (/.index (/.of_char char) sample) {.#Some actual} (nat.= expected actual) @@ -803,7 +803,7 @@ (at /.monoid composite post static) (/.replaced_once pre post (at /.monoid composite pre static)))) (_.coverage [/.split_by] - (case (/.split_by static (all (at /.monoid composite) pre static post)) + (when (/.split_by static (all (at /.monoid composite) pre static post)) {.#Some [left right]} (and (at /.equivalence = pre left) (at /.equivalence = post right)) @@ -883,7 +883,7 @@ (all _.and (_.coverage [/.split_at] (|> (/.split_at sizeL sample) - (pipe.case + (pipe.when {.#Right [_l _r]} (and (/#= sampleL _l) (/#= sampleR _r) @@ -896,7 +896,7 @@ (/.clip sizeL (nat.- sizeL (/.size sample)) sample) (/.clip_since sizeL sample) (/.clip_since 0 sample)] - (pipe.case + (pipe.when [{.#Right _l} {.#Right _r} {.#Right _r'} {.#Right _f}] (and (/#= sampleL _l) (/#= sampleR _r) diff --git a/stdlib/source/test/lux/data/text/escape.lux b/stdlib/source/test/lux/data/text/escape.lux index 1ac4b1904..554aaa16f 100644 --- a/stdlib/source/test/lux/data/text/escape.lux +++ b/stdlib/source/test/lux/data/text/escape.lux @@ -107,7 +107,7 @@ (if (or (/.escapable? left) (/.escapable? right)) (let [escaped (/.escaped expected)] - (case (/.un_escaped escaped) + (when (/.un_escaped escaped) {try.#Success un_escaped} (and (not (text#= escaped expected)) (text#= un_escaped expected)) @@ -119,7 +119,7 @@ [dummy (|> (random.char unicode.character) (at ! each text.of_char))] (_.coverage [/.dangling_escape] - (case (/.un_escaped (format (/.escaped dummy) "\")) + (when (/.un_escaped (format (/.escaped dummy) "\")) {try.#Success _} false @@ -130,7 +130,7 @@ (random.only (|>> (set.member? ..valid_sigils) not)) (at ! each text.of_char))] (_.coverage [/.invalid_escape] - (case (/.un_escaped (format "\" dummy)) + (when (/.un_escaped (format "\" dummy)) {try.#Success _} false @@ -141,12 +141,12 @@ (at ! each (n.% (hex "1000")))) code (|> (random.unicode 4) (random.only (function (_ code) - (case (at n.hex decoded code) + (when (at n.hex decoded code) {try.#Failure error} true {try.#Success _} false))))] (_.coverage [/.invalid_unicode_escape] (template.let [(!invalid <code>) - [(case (/.un_escaped (format "\u" <code>)) + [(when (/.un_escaped (format "\u" <code>)) {try.#Success _} false diff --git a/stdlib/source/test/lux/data/text/regex.lux b/stdlib/source/test/lux/data/text/regex.lux index d5be70ce1..1b1b8ec95 100644 --- a/stdlib/source/test/lux/data/text/regex.lux +++ b/stdlib/source/test/lux/data/text/regex.lux @@ -28,7 +28,7 @@ (-> (Parser Text) Text Bit) (|> input (<text>.result regex) - (pipe.case + (pipe.when {try.#Success parsed} (text#= parsed input) @@ -39,7 +39,7 @@ (-> Text (Parser Text) Text Bit) (|> input (<text>.result regex) - (pipe.case + (pipe.when {try.#Success parsed} (text#= test parsed) @@ -50,7 +50,7 @@ (All (_ a) (-> (Parser a) Text Bit)) (|> input (<text>.result regex) - (pipe.case + (pipe.when {try.#Failure _} true @@ -64,7 +64,7 @@ (macro.with_symbols [g!message g!_] (in (list (` (|> (, input) (<text>.result (, regex)) - (pipe.case + (pipe.when {try.#Success (, pattern)} true @@ -282,7 +282,7 @@ (def expands? (syntax (_ [form <code>.any]) (function (_ lux) - {try.#Success [lux (list (code.bit (case (expansion.single form lux) + {try.#Success [lux (list (code.bit (when (expansion.single form lux) {try.#Success _} true @@ -310,7 +310,7 @@ sample2 (random.unicode 3) sample3 (random.unicode 4)] (_.coverage [/.pattern] - (case (format sample1 "-" sample2 "-" sample3) + (when (format sample1 "-" sample2 "-" sample3) (/.pattern "(.{3})-(.{3})-(.{4})" [_ match1 match2 match3]) (and (text#= sample1 match1) |