diff options
Diffstat (limited to '')
-rw-r--r-- | stdlib/test/test/lux/time/date.lux | 45 | ||||
-rw-r--r-- | stdlib/test/test/lux/time/duration.lux | 18 |
2 files changed, 59 insertions, 4 deletions
diff --git a/stdlib/test/test/lux/time/date.lux b/stdlib/test/test/lux/time/date.lux index e5b5fefc5..2a56fb71a 100644 --- a/stdlib/test/test/lux/time/date.lux +++ b/stdlib/test/test/lux/time/date.lux @@ -1,10 +1,14 @@ (;module: lux (lux [io] - (control [monad #+ do Monad]) + (control [monad #+ do Monad] + [pipe]) + (data ["R" result]) (math ["r" random "r/" Monad<Random>]) - (time ["@" date])) - lux/test) + (time ["@;" instant] + ["@" date])) + lux/test + (test (lux (time ["_;" instant])))) (def: month (r;Random @;Month) @@ -84,3 +88,38 @@ sample)) (|> sample @/succ @/pred (@/= sample)) (|> sample @/pred @/succ (@/= sample))))) + +(def: date + (r;Random @;Date) + (|> _instant;instant (:: r;Monad<Random> map @instant;date))) + +(context: "(Date) Eq." + [sample date + #let [(^open "@/") @;Eq<Date>]] + (test "Every value equals itself." + (@/= sample sample))) + +(context: "(Date) Order." + [reference date + sample date + #let [(^open "@/") @;Order<Date>]] + (test "Valid Order." + (and (or (@/< reference sample) + (@/>= reference sample)) + (or (@/> reference sample) + (@/<= reference sample))))) + +(context: "(Date) Codec" + #seed +1501531301120 + [sample date + #let [(^open "@/") @;Eq<Date> + (^open "@/") @;Codec<Text,Date>]] + (test "Can encode/decode dates." + (|> sample + @/encode + @/decode + (pipe;case> (#R;Success decoded) + (@/= sample decoded) + + (#R;Error error) + false)))) diff --git a/stdlib/test/test/lux/time/duration.lux b/stdlib/test/test/lux/time/duration.lux index 18ec46090..565010a07 100644 --- a/stdlib/test/test/lux/time/duration.lux +++ b/stdlib/test/test/lux/time/duration.lux @@ -1,7 +1,9 @@ (;module: lux (lux [io] - (control [monad #+ do Monad]) + (control [monad #+ do Monad] + [pipe]) + (data ["R" result]) (math ["r" random]) (time ["@" duration])) lux/test) @@ -55,3 +57,17 @@ (@;scale -1 frame) frame)))))) )) + +(context: "Codec" + [sample duration + #let [(^open "@/") @;Eq<Duration> + (^open "@/") @;Codec<Text,Duration>]] + (test "Can encode/decode durations." + (|> sample + @/encode + @/decode + (pipe;case> (#R;Success decoded) + (@/= sample decoded) + + (#R;Error error) + false)))) |