aboutsummaryrefslogtreecommitdiff
path: root/stdlib/source/test/lux/world/time/month.lux
diff options
context:
space:
mode:
authorEduardo Julian2022-09-03 14:31:47 -0400
committerEduardo Julian2022-09-03 14:31:47 -0400
commit1f4557bf0d904231b3b8d2b2bf73c35e9caead48 (patch)
tree30e49d4ed6cc75b3185ed9a771d2dbb004fca00f /stdlib/source/test/lux/world/time/month.lux
parent950836e72a1b775ccab19a722566c431f56208f6 (diff)
Added support for context-oriented programming.
Diffstat (limited to '')
-rw-r--r--stdlib/source/test/lux/world/time/month.lux136
1 files changed, 77 insertions, 59 deletions
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)))
+ ))))))