diff options
author | Eduardo Julian | 2018-05-12 18:48:52 -0400 |
---|---|---|
committer | Eduardo Julian | 2018-05-12 18:48:52 -0400 |
commit | 6717fc5e4aaf5986cd4f0d4ea1a12793188cbe9a (patch) | |
tree | 471ee5a4a585183b2fcb570c75277969b5953406 /stdlib/test | |
parent | a268b8e66fbb5ad51e053bbb9a334a6460602aed (diff) |
- Implemented Deg(ree) reciprocal & conversions Deg<->Frac.
- Added an easy way to define aliases.
Diffstat (limited to 'stdlib/test')
-rw-r--r-- | stdlib/test/test/lux.lux | 16 |
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" |