aboutsummaryrefslogtreecommitdiff
path: root/stdlib/test
diff options
context:
space:
mode:
Diffstat (limited to 'stdlib/test')
-rw-r--r--stdlib/test/test/lux.lux16
1 files changed, 11 insertions, 5 deletions
diff --git a/stdlib/test/test/lux.lux b/stdlib/test/test/lux.lux
index a089f7cee..788085db4 100644
--- a/stdlib/test/test/lux.lux
+++ b/stdlib/test/test/lux.lux
@@ -5,6 +5,7 @@
[math]
["r" math/random]
(data [maybe]
+ [bit]
[text "text/" Eq<Text>]
text/format)
[macro]
@@ -141,6 +142,11 @@
["Deg" r.deg d/= d/+ d/- d/* d// d/% d/> .0 (:! Deg -1) (:! Deg -1) %f id id]
)
+(def: frac-deg
+ (r.Random Deg)
+ (|> r.deg
+ (:: r.Functor<Random> map (|>> (:! Nat) (bit.left-shift +11) (bit.right-shift +11) (:! Deg)))))
+
(do-template [category rand-gen -> <- = <cap> %a %z]
[(context: (format "[" category "] " "Numeric conversions")
(<| (times +100)
@@ -150,11 +156,11 @@
(test ""
(|> value -> <- (= value))))))]
- ["Int->Nat" r.int int-to-nat nat-to-int i/= (i/% 1000000) %i %n]
- ["Nat->Int" r.nat nat-to-int int-to-nat n/= (n/% +1000000) %n %i]
- ["Int->Frac" r.int int-to-frac frac-to-int i/= (i/% 1000000) %i %r]
- ["Frac->Int" r.frac frac-to-int int-to-frac f/= math.floor %r %i]
- ## [r.frac frac-to-deg deg-to-frac f/= (f/% 1.0) %r %f]
+ ["Int->Nat" r.int int-to-nat nat-to-int i/= (i/% 1000000) %i %n]
+ ["Nat->Int" r.nat nat-to-int int-to-nat n/= (n/% +1000000) %n %i]
+ ["Int->Frac" r.int int-to-frac frac-to-int i/= (i/% 1000000) %i %r]
+ ["Frac->Int" r.frac frac-to-int int-to-frac f/= math.floor %r %i]
+ ["Deg->Frac" frac-deg deg-to-frac frac-to-deg d/= id %d %r]
)
(context: "Simple macros and constructs"