aboutsummaryrefslogtreecommitdiff
path: root/stdlib/test
diff options
context:
space:
mode:
authorEduardo Julian2017-07-23 03:04:37 -0400
committerEduardo Julian2017-07-23 03:04:37 -0400
commitb3e2657c901e42dc14544821a68ded03a4c925ab (patch)
tree1c77e671ac080ee586327a9633677a3bc5eb08f0 /stdlib/test
parentd8022c5aba1216e5d2abae54875d6be48eac8dcf (diff)
- Codec now works on negative times (with respect to the epoch).
- There are still some corner cases where decoding fails. MUST FIX.
Diffstat (limited to 'stdlib/test')
-rw-r--r--stdlib/test/test/lux/time.lux28
1 files changed, 5 insertions, 23 deletions
diff --git a/stdlib/test/test/lux/time.lux b/stdlib/test/test/lux/time.lux
index becdfc068..3d477f4ea 100644
--- a/stdlib/test/test/lux/time.lux
+++ b/stdlib/test/test/lux/time.lux
@@ -20,23 +20,10 @@
(i.% (nat-to-int size))
(i.* (Int/signum sample))))))
-(def: (pow exp base)
- (-> Nat Int Int)
- (case exp
- +0 1
- _ (loop [exp exp
- result base]
- (case exp
- +1 result
- _ (recur (n.dec exp)
- (i.* base result))))))
-(def: boundary Int (|> 2 (pow +31) (i.* @;second)))
+(def: boundary Int 99_999_999_999_999)
(def: time (r;Random @;Time)
- (|> r;int
- (r;filter (i.>= 0))
- ## (:: r;Monad<Random> map (i.% boundary))
- ))
+ (|> r;int (:: r;Monad<Random> map (i.% boundary))))
(context: "Equality"
[sample time
@@ -64,15 +51,11 @@
(and (or (< reference sample)
(>= reference sample))
(or (> reference sample)
- (<= reference sample))))
- )
+ (<= reference sample)))))
(context: "Codec"
- ## #seed +1484609979608
- ## #seed +1484654273059
+ #seed +16366082068080165840
[sample time
- ## #let [sample 1095292800_000]
- ## #let [_ (log! (format "sample = " (%i sample)))]
#let [(^open "&/") @;Codec<Text,Time>]]
(test "Can encode/decode times."
(|> sample
@@ -82,5 +65,4 @@
(@;t.= sample decoded)
(#R;Error error)
- false)))
- )
+ false))))