aboutsummaryrefslogtreecommitdiff
path: root/stdlib/test
diff options
context:
space:
mode:
authorEduardo Julian2017-09-19 19:15:12 -0400
committerEduardo Julian2017-09-19 19:15:12 -0400
commit6da0a54773e44ad0696437efacefa6f870c9868f (patch)
tree9d708d28ae179e2023f57743a97b19fee2ae3bdb /stdlib/test
parentddac5af82dc943146b8c34a736b39bc1557db4f1 (diff)
- Added unary function support for the "infix" macro.
Diffstat (limited to 'stdlib/test')
-rw-r--r--stdlib/test/test/lux/math.lux33
1 files changed, 20 insertions, 13 deletions
diff --git a/stdlib/test/test/lux/math.lux b/stdlib/test/test/lux/math.lux
index 63a449965..701790886 100644
--- a/stdlib/test/test/lux/math.lux
+++ b/stdlib/test/test/lux/math.lux
@@ -8,7 +8,7 @@
[number "f/" Number<Frac>]
(coll [list "List/" Fold<List> Functor<List>])
[product])
- ["R" math/random]
+ ["r" math/random]
["&" math])
lux/test)
@@ -23,7 +23,7 @@
## ## I won't be testing this, until I can figure out what's going on, or
## ## come up with my own implementation
## (context: "Trigonometry"
-## [angle (|> R;frac (:: @ map (f.* &;tau)))]
+## [angle (|> r;frac (:: @ map (f.* &;tau)))]
## ($_ seq
## (test "Sine and arc-sine are inverse functions."
## (|> angle &;sin &;asin (within? margin angle)))
@@ -36,11 +36,11 @@
## ))
(context: "Roots"
- [factor (|> R;nat (:: @ map (|>. (n.% +1000)
+ [factor (|> r;nat (:: @ map (|>. (n.% +1000)
(n.max +1)
nat-to-int
int-to-frac)))
- base (|> R;frac (:: @ map (f.* factor)))]
+ base (|> r;frac (:: @ map (f.* factor)))]
($_ seq
(test "Square-root is inverse of square."
(|> base (&;pow 2.0) &;root2 (f.= base)))
@@ -50,7 +50,7 @@
))
(context: "Rounding"
- [sample (|> R;frac (:: @ map (f.* 1000.0)))]
+ [sample (|> r;frac (:: @ map (f.* 1000.0)))]
($_ seq
(test "The ceiling will be an integer value, and will be >= the original."
(let [ceil'd (&;ceil sample)]
@@ -71,12 +71,12 @@
))
(context: "Exponentials and logarithms"
- [sample (|> R;frac (:: @ map (f.* 10.0)))]
+ [sample (|> r;frac (:: @ map (f.* 10.0)))]
(test "Logarithm is the inverse of exponential."
(|> sample &;exp &;log (within? 1.0e-15 sample))))
(context: "Greatest-Common-Divisor and Least-Common-Multiple"
- [#let [gen-nat (|> R;nat (:: @ map (|>. (n.% +1000) (n.max +1))))]
+ [#let [gen-nat (|> r;nat (:: @ map (|>. (n.% +1000) (n.max +1))))]
x gen-nat
y gen-nat]
($_ (test "GCD"
@@ -93,17 +93,24 @@
))
(context: "Infix syntax"
- [x R;nat
- y R;nat
- z R;nat
+ [x r;nat
+ y r;nat
+ z r;nat
+ theta r;frac
#let [top (|> x (n.max y) (n.max z))
bottom (|> x (n.min y) (n.min z))]]
($_ seq
(test "Constant values don't change."
- (n.= x (&;infix x)))
+ (n.= x
+ (&;infix x)))
- (test "Can call infix functions."
- (n.= (&;gcd y x) (&;infix [x &;gcd y])))
+ (test "Can call binary functions."
+ (n.= (&;gcd y x)
+ (&;infix [x &;gcd y])))
+
+ (test "Can call unary functions."
+ (f.= (&;sin theta)
+ (&;infix [&;sin theta])))
(test "Can use regular syntax in the middle of infix code."
(n.= (&;gcd +450 (n.* +3 +9))