aboutsummaryrefslogtreecommitdiff
path: root/stdlib/test
diff options
context:
space:
mode:
authorEduardo Julian2017-07-29 18:38:09 -0400
committerEduardo Julian2017-07-29 18:38:09 -0400
commitf502efa593f22c82d2ae4cee70be90b5e3c96fe8 (patch)
tree2efa9ef699b64dfe5ee2de3595e555ba8af2042d /stdlib/test
parent2d94e3f1e25a98d0b3a4cf0ebbadd17cc8cc5d32 (diff)
- Added more structures for instants and dates.
Diffstat (limited to '')
-rw-r--r--stdlib/test/test/lux/time/date.lux86
-rw-r--r--stdlib/test/test/lux/time/instant.lux11
-rw-r--r--stdlib/test/tests.lux3
3 files changed, 99 insertions, 1 deletions
diff --git a/stdlib/test/test/lux/time/date.lux b/stdlib/test/test/lux/time/date.lux
new file mode 100644
index 000000000..e5b5fefc5
--- /dev/null
+++ b/stdlib/test/test/lux/time/date.lux
@@ -0,0 +1,86 @@
+(;module:
+ lux
+ (lux [io]
+ (control [monad #+ do Monad])
+ (math ["r" random "r/" Monad<Random>])
+ (time ["@" date]))
+ lux/test)
+
+(def: month
+ (r;Random @;Month)
+ (r;either (r;either (r;either (r/wrap #@;January)
+ (r;either (r/wrap #@;February)
+ (r/wrap #@;March)))
+ (r;either (r/wrap #@;April)
+ (r;either (r/wrap #@;May)
+ (r/wrap #@;June))))
+ (r;either (r;either (r/wrap #@;July)
+ (r;either (r/wrap #@;August)
+ (r/wrap #@;September)))
+ (r;either (r/wrap #@;October)
+ (r;either (r/wrap #@;November)
+ (r/wrap #@;December))))))
+
+(context: "(Month) Eq."
+ [sample month
+ #let [(^open "@/") @;Eq<Month>]]
+ (test "Every value equals itself."
+ (@/= sample sample)))
+
+(context: "(Month) Order."
+ [reference month
+ sample month
+ #let [(^open "@/") @;Order<Month>]]
+ (test "Valid Order."
+ (and (or (@/< reference sample)
+ (@/>= reference sample))
+ (or (@/> reference sample)
+ (@/<= reference sample)))))
+
+(context: "(Month) Enum."
+ [sample month
+ #let [(^open "@/") @;Enum<Month>]]
+ (test "Valid Enum."
+ (and (not (@/= (@/succ sample)
+ sample))
+ (not (@/= (@/pred sample)
+ sample))
+ (|> sample @/succ @/pred (@/= sample))
+ (|> sample @/pred @/succ (@/= sample)))))
+
+(def: day
+ (r;Random @;Day)
+ (r;either (r;either (r;either (r/wrap #@;Sunday)
+ (r/wrap #@;Monday))
+ (r;either (r/wrap #@;Tuesday)
+ (r/wrap #@;Wednesday)))
+ (r;either (r;either (r/wrap #@;Thursday)
+ (r/wrap #@;Friday))
+ (r/wrap #@;Saturday))))
+
+(context: "(Day) Eq."
+ [sample day
+ #let [(^open "@/") @;Eq<Day>]]
+ (test "Every value equals itself."
+ (@/= sample sample)))
+
+(context: "(Day) Order."
+ [reference day
+ sample day
+ #let [(^open "@/") @;Order<Day>]]
+ (test "Valid Order."
+ (and (or (@/< reference sample)
+ (@/>= reference sample))
+ (or (@/> reference sample)
+ (@/<= reference sample)))))
+
+(context: "(Day) Enum."
+ [sample day
+ #let [(^open "@/") @;Enum<Day>]]
+ (test "Valid Enum."
+ (and (not (@/= (@/succ sample)
+ sample))
+ (not (@/= (@/pred sample)
+ sample))
+ (|> sample @/succ @/pred (@/= sample))
+ (|> sample @/pred @/succ (@/= sample)))))
diff --git a/stdlib/test/test/lux/time/instant.lux b/stdlib/test/test/lux/time/instant.lux
index 2baeff7a7..40ab587d7 100644
--- a/stdlib/test/test/lux/time/instant.lux
+++ b/stdlib/test/test/lux/time/instant.lux
@@ -44,6 +44,17 @@
(or (@/> reference sample)
(@/<= reference sample)))))
+(context: "Enum"
+ [sample instant
+ #let [(^open "@/") @;Enum<Instant>]]
+ (test "Valid Enum."
+ (and (not (@/= (@/succ sample)
+ sample))
+ (not (@/= (@/pred sample)
+ sample))
+ (|> sample @/succ @/pred (@/= sample))
+ (|> sample @/pred @/succ (@/= sample)))))
+
(context: "Arithmetic"
[sample instant
span duration
diff --git a/stdlib/test/tests.lux b/stdlib/test/tests.lux
index 6f593abff..b6dbdfcd2 100644
--- a/stdlib/test/tests.lux
+++ b/stdlib/test/tests.lux
@@ -10,7 +10,8 @@
["_;" host]
["_;" io]
(time ["_;" instant]
- ["_;" duration])
+ ["_;" duration]
+ ["_;" date])
(concurrency ["_;" actor]
["_;" atom]
["_;" frp]