aboutsummaryrefslogtreecommitdiff
path: root/stdlib/test/test/lux/data/number/ratio.lux
diff options
context:
space:
mode:
Diffstat (limited to 'stdlib/test/test/lux/data/number/ratio.lux')
-rw-r--r--stdlib/test/test/lux/data/number/ratio.lux50
1 files changed, 25 insertions, 25 deletions
diff --git a/stdlib/test/test/lux/data/number/ratio.lux b/stdlib/test/test/lux/data/number/ratio.lux
index 0cd1f58ea..cd6657f8a 100644
--- a/stdlib/test/test/lux/data/number/ratio.lux
+++ b/stdlib/test/test/lux/data/number/ratio.lux
@@ -14,14 +14,14 @@
(def: gen-part
(r;Random Nat)
- (|> r;nat (:: r;Monad<Random> map (|>. (n/% +1000) (n/max +1)))))
+ (|> r;nat (:: r;Monad<Random> map (|>> (n/% +1000) (n/max +1)))))
(def: gen-ratio
(r;Random &;Ratio)
(do r;Monad<Random>
[numerator gen-part
denominator (|> gen-part
- (r;filter (|>. (n/= +0) not))
+ (r;filter (|>> (n/= +0) not))
(r;filter (. not (n/= numerator))))]
(wrap (&;ratio numerator denominator))))
@@ -33,11 +33,11 @@
sample gen-ratio]
($_ seq
(test "All zeroes are the same."
- (&;q.= (&;ratio +0 denom1)
+ (&;r/= (&;ratio +0 denom1)
(&;ratio +0 denom2)))
(test "All ratios are built normalized."
- (|> sample &;normalize (&;q.= sample)))
+ (|> sample &;normalize (&;r/= sample)))
))))
(context: "Arithmetic"
@@ -45,29 +45,29 @@
(do @
[x gen-ratio
y gen-ratio
- #let [min (&;q.min x y)
- max (&;q.max x y)]]
+ #let [min (&;r/min x y)
+ max (&;r/max x y)]]
($_ seq
(test "Addition and subtraction are opposites."
- (and (|> max (&;q.- min) (&;q.+ min) (&;q.= max))
- (|> max (&;q.+ min) (&;q.- min) (&;q.= max))))
+ (and (|> max (&;r/- min) (&;r/+ min) (&;r/= max))
+ (|> max (&;r/+ min) (&;r/- min) (&;r/= max))))
(test "Multiplication and division are opposites."
- (and (|> max (&;q./ min) (&;q.* min) (&;q.= max))
- (|> max (&;q.* min) (&;q./ min) (&;q.= max))))
+ (and (|> max (&;r// min) (&;r/* min) (&;r/= max))
+ (|> max (&;r/* min) (&;r// min) (&;r/= max))))
(test "Modulus by a larger ratio doesn't change the value."
- (|> min (&;q.% max) (&;q.= min)))
+ (|> min (&;r/% max) (&;r/= min)))
(test "Modulus by a smaller ratio results in a value smaller than the limit."
- (|> max (&;q.% min) (&;q.< min)))
+ (|> max (&;r/% min) (&;r/< min)))
(test "Can get the remainder of a division."
- (let [remainder (&;q.% min max)
- multiple (&;q.- remainder max)
- factor (&;q./ min multiple)]
+ (let [remainder (&;r/% min max)
+ multiple (&;r/- remainder max)
+ factor (&;r// min multiple)]
(and (|> factor (get@ #&;denominator) (n/= +1))
- (|> factor (&;q.* min) (&;q.+ remainder) (&;q.= max)))))
+ (|> factor (&;r/* min) (&;r/+ remainder) (&;r/= max)))))
))))
(context: "Negation, absolute value and signum"
@@ -78,14 +78,14 @@
(test "Negation is it's own inverse."
(let [there (&/negate sample)
back-again (&/negate there)]
- (and (not (&;q.= there sample))
- (&;q.= back-again sample))))
+ (and (not (&;r/= there sample))
+ (&;r/= back-again sample))))
(test "All ratios are already at their absolute value."
- (|> sample &/abs (&;q.= sample)))
+ (|> sample &/abs (&;r/= sample)))
(test "Signum is the identity."
- (|> sample (&;q.* (&/signum sample)) (&;q.= sample)))
+ (|> sample (&;r/* (&/signum sample)) (&;r/= sample)))
))))
(context: "Order"
@@ -95,10 +95,10 @@
y gen-ratio]
($_ seq
(test "Can compare ratios."
- (and (or (&;q.<= y x)
- (&;q.> y x))
- (or (&;q.>= y x)
- (&;q.< y x))))
+ (and (or (&;r/<= y x)
+ (&;r/> y x))
+ (or (&;r/>= y x)
+ (&;r/< y x))))
))))
(context: "Codec"
@@ -109,7 +109,7 @@
(test "Can encode/decode ratios."
(|> sample &/encode &/decode
(case> (#;Right output)
- (&;q.= sample output)
+ (&;r/= sample output)
_
false))))))