From 6717fc5e4aaf5986cd4f0d4ea1a12793188cbe9a Mon Sep 17 00:00:00 2001 From: Eduardo Julian Date: Sat, 12 May 2018 18:48:52 -0400 Subject: - Implemented Deg(ree) reciprocal & conversions Deg<->Frac. - Added an easy way to define aliases. --- stdlib/test/test/lux.lux | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) (limited to 'stdlib/test') 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/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 map (|>> (:! Nat) (bit.left-shift +11) (bit.right-shift +11) (:! Deg))))) + (do-template [category rand-gen -> <- = %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" -- cgit v1.2.3