diff options
author | Eduardo Julian | 2022-09-03 14:31:47 -0400 |
---|---|---|
committer | Eduardo Julian | 2022-09-03 14:31:47 -0400 |
commit | 1f4557bf0d904231b3b8d2b2bf73c35e9caead48 (patch) | |
tree | 30e49d4ed6cc75b3185ed9a771d2dbb004fca00f /stdlib/source/test/lux/world | |
parent | 950836e72a1b775ccab19a722566c431f56208f6 (diff) |
Added support for context-oriented programming.
Diffstat (limited to 'stdlib/source/test/lux/world')
-rw-r--r-- | stdlib/source/test/lux/world/time/day.lux | 91 | ||||
-rw-r--r-- | stdlib/source/test/lux/world/time/month.lux | 136 |
2 files changed, 129 insertions, 98 deletions
diff --git a/stdlib/source/test/lux/world/time/day.lux b/stdlib/source/test/lux/world/time/day.lux index c6471ffae..a893a1405 100644 --- a/stdlib/source/test/lux/world/time/day.lux +++ b/stdlib/source/test/lux/world/time/day.lux @@ -45,46 +45,59 @@ [expected ..random invalid (random.only (predicate.or (n.< (/.number {/.#Sunday})) (n.> (/.number {/.#Saturday}))) - random.nat)] - (all _.and - (_.for [/.equivalence] - ($equivalence.spec /.equivalence ..random)) - (_.for [/.hash] - ($hash.spec /.hash ..random)) - (_.for [/.order] - ($order.spec /.order ..random)) - (_.for [/.enum] - ($enum.spec /.enum ..random)) - (_.for [/.codec] - ($codec.spec /.equivalence /.codec ..random)) + random.nat)]) + (`` (all _.and + (_.for [/.equivalence] + ($equivalence.spec /.equivalence ..random)) + (_.for [/.hash] + ($hash.spec /.hash ..random)) + (_.for [/.order] + ($order.spec /.order ..random)) + (_.for [/.enum] + ($enum.spec /.enum ..random)) + (_.for [/.codec] + ($codec.spec /.equivalence /.codec ..random)) - (do random.monad - [not_a_day (random.upper_case 1)] - (_.coverage [/.not_a_day_of_the_week] - (when (at /.codec decoded not_a_day) + (,, (with_template [<before> <current> <after>] + [(_.coverage [<current>] + (and (at /.equivalence = {<before>} (at /.enum pred {<current>})) + (at /.equivalence = {<after>} (at /.enum succ {<current>}))))] + + [/.#Saturday /.#Sunday /.#Monday] + [/.#Sunday /.#Monday /.#Tuesday] + [/.#Monday /.#Tuesday /.#Wednesday] + [/.#Tuesday /.#Wednesday /.#Thursday] + [/.#Wednesday /.#Thursday /.#Friday] + [/.#Thursday /.#Friday /.#Saturday] + [/.#Friday /.#Saturday /.#Sunday] + )) + (do random.monad + [not_a_day (random.upper_case 1)] + (_.coverage [/.not_a_day_of_the_week] + (when (at /.codec decoded not_a_day) + {try.#Failure error} + (exception.match? /.not_a_day_of_the_week error) + + {try.#Success _} + false))) + (_.coverage [/.number /.by_number] + (|> expected + /.number + /.by_number + (try#each (at /.equivalence = expected)) + (try.else false))) + (_.coverage [/.invalid_day] + (when (/.by_number invalid) {try.#Failure error} - (exception.match? /.not_a_day_of_the_week error) + (exception.match? /.invalid_day error) {try.#Success _} - false))) - (_.coverage [/.number /.by_number] - (|> expected - /.number - /.by_number - (try#each (at /.equivalence = expected)) - (try.else false))) - (_.coverage [/.invalid_day] - (when (/.by_number invalid) - {try.#Failure error} - (exception.match? /.invalid_day error) - - {try.#Success _} - false)) - (_.coverage [/.week] - (let [all (list.size /.week) - uniques (set.size (set.of_list /.hash /.week))] - (and (n.= (/.number {/.#Saturday}) - all) - (n.= all - uniques)))) - )))) + false)) + (_.coverage [/.week] + (let [all (list.size /.week) + uniques (set.size (set.of_list /.hash /.week))] + (and (n.= (/.number {/.#Saturday}) + all) + (n.= all + uniques)))) + )))) diff --git a/stdlib/source/test/lux/world/time/month.lux b/stdlib/source/test/lux/world/time/month.lux index 29117b8d3..d259985c6 100644 --- a/stdlib/source/test/lux/world/time/month.lux +++ b/stdlib/source/test/lux/world/time/month.lux @@ -40,63 +40,81 @@ Test (<| (_.covering /._) (_.for [/.Month]) - (all _.and - (_.for [/.equivalence] - ($equivalence.spec /.equivalence ..random)) - (_.for [/.hash] - ($hash.spec /.hash ..random)) - (_.for [/.order] - ($order.spec /.order ..random)) - (_.for [/.enum] - ($enum.spec /.enum ..random)) - (_.for [/.codec] - ($codec.spec /.equivalence /.codec ..random)) + (`` (all _.and + (_.for [/.equivalence] + ($equivalence.spec /.equivalence ..random)) + (_.for [/.hash] + ($hash.spec /.hash ..random)) + (_.for [/.order] + ($order.spec /.order ..random)) + (_.for [/.enum] + ($enum.spec /.enum ..random)) + (_.for [/.codec] + ($codec.spec /.equivalence /.codec ..random)) - (do random.monad - [expected ..random - invalid (random.only (predicate.or (n.< (/.number {/.#January})) - (n.> (/.number {/.#December}))) - random.nat)] - (all _.and - (_.coverage [/.number /.by_number] - (|> expected - /.number - /.by_number - (try#each (at /.equivalence = expected)) - (try.else false))) - (_.coverage [/.invalid_month] - (when (/.by_number invalid) - {try.#Failure error} - (exception.match? /.invalid_month error) - - {try.#Success _} - false)) - (_.coverage [/.year] - (let [all (list.size /.year) - uniques (set.size (set.of_list /.hash /.year))] - (and (n.= (/.number {/.#December}) - all) - (n.= all - uniques)))) - (_.coverage [/.days] - (let [expected (.nat (duration.ticks duration.day duration.normal_year))] - (|> /.year - (list#each /.days) - (list#mix n.+ 0) - (n.= expected)))) - (_.coverage [/.leap_year_days] - (let [expected (.nat (duration.ticks duration.day duration.leap_year))] - (|> /.year - (list#each /.leap_year_days) - (list#mix n.+ 0) - (n.= expected)))) - (do random.monad - [not_a_month (random.upper_case 1)] - (_.coverage [/.not_a_month_of_the_year] - (when (at /.codec decoded not_a_month) - {try.#Failure error} - (exception.match? /.not_a_month_of_the_year error) - - {try.#Success _} - false))) - ))))) + (,, (with_template [<before> <current> <after>] + [(_.coverage [<current>] + (and (at /.equivalence = {<before>} (at /.enum pred {<current>})) + (at /.equivalence = {<after>} (at /.enum succ {<current>}))))] + + [/.#December /.#January /.#February] + [/.#January /.#February /.#March] + [/.#February /.#March /.#April] + [/.#March /.#April /.#May] + [/.#April /.#May /.#June] + [/.#May /.#June /.#July] + [/.#June /.#July /.#August] + [/.#July /.#August /.#September] + [/.#August /.#September /.#October] + [/.#September /.#October /.#November] + [/.#October /.#November /.#December] + [/.#November /.#December /.#January] + )) + (do random.monad + [expected ..random + invalid (random.only (predicate.or (n.< (/.number {/.#January})) + (n.> (/.number {/.#December}))) + random.nat)] + (all _.and + (_.coverage [/.number /.by_number] + (|> expected + /.number + /.by_number + (try#each (at /.equivalence = expected)) + (try.else false))) + (_.coverage [/.invalid_month] + (when (/.by_number invalid) + {try.#Failure error} + (exception.match? /.invalid_month error) + + {try.#Success _} + false)) + (_.coverage [/.year] + (let [all (list.size /.year) + uniques (set.size (set.of_list /.hash /.year))] + (and (n.= (/.number {/.#December}) + all) + (n.= all + uniques)))) + (_.coverage [/.days] + (let [expected (.nat (duration.ticks duration.day duration.normal_year))] + (|> /.year + (list#each /.days) + (list#mix n.+ 0) + (n.= expected)))) + (_.coverage [/.leap_year_days] + (let [expected (.nat (duration.ticks duration.day duration.leap_year))] + (|> /.year + (list#each /.leap_year_days) + (list#mix n.+ 0) + (n.= expected)))) + (do random.monad + [not_a_month (random.upper_case 1)] + (_.coverage [/.not_a_month_of_the_year] + (when (at /.codec decoded not_a_month) + {try.#Failure error} + (exception.match? /.not_a_month_of_the_year error) + + {try.#Success _} + false))) + )))))) |