diff options
Diffstat (limited to '')
-rw-r--r-- | stdlib/test/test/lux/data/number.lux | 29 |
1 files changed, 17 insertions, 12 deletions
diff --git a/stdlib/test/test/lux/data/number.lux b/stdlib/test/test/lux/data/number.lux index dcd27745e..d5d60a9ce 100644 --- a/stdlib/test/test/lux/data/number.lux +++ b/stdlib/test/test/lux/data/number.lux @@ -8,7 +8,7 @@ (lux (codata [io]) (control monad) (data number - [text "Text/" Monoid<Text>] + [text "Text/" Monoid<Text> Eq<Text>] text/format) (math ["R" random]) pipe) @@ -31,17 +31,22 @@ (do-template [category rand-gen <Number>] [(test: (format "[" category "] " "Number") - [x rand-gen] - (assert "" (let [(^open) <Number>] - (and (>= x (abs x)) - (<= x (negate (abs x))) - (= x (* (signum x) - (abs x)))))))] - - ["Nat" R;nat Number<Nat>] + [x rand-gen + #let [(^open) <Number>]] + (assert "" (and (>= x (abs x)) + ## abs(0.0) == 0.0 && negate(abs(0.0)) == -0.0 + (or (Text/= "Real" category) + (not (= x (negate x)))) + (= x (negate (negate x))) + ## There is loss of precision when multiplying + (or (Text/= "Frac" category) + (= x (* (signum x) + (abs x)))))))] + + ## ["Nat" R;nat Number<Nat>] ["Int" R;int Number<Int>] ["Real" R;real Number<Real>] - ## ["Frac" R;frac Number<Frac>] + ["Frac" R;frac Number<Frac>] ) (do-template [category rand-gen <Enum> <Number>] @@ -74,7 +79,7 @@ ["Int" R;int Number<Int> Bounded<Int> (lambda [_] true)] ## Both min and max values will be positive (thus, greater than zero) ["Real" R;real Number<Real> Bounded<Real> (r.> 0.0)] - ## ["Frac" R;frac Number<Frac> Bounded<Frac> (lambda [_] true)] + ["Frac" R;frac Number<Frac> Bounded<Frac> (lambda [_] true)] ) (do-template [category rand-gen <Number> <Monoid> <cap> <test>] @@ -121,7 +126,7 @@ ["Nat" R;nat Number<Nat> Codec<Text,Nat>] ["Int" R;int Number<Int> Codec<Text,Int>] ["Real" R;real Number<Real> Codec<Text,Real>] - ## ["Frac" R;frac Number<Frac> Codec<Text,Frac>] + ["Frac" R;frac Number<Frac> Codec<Text,Frac>] ) (do-template [<category> <rand-gen> <Number> <Codec>] |