diff options
Diffstat (limited to 'stdlib/source/test/lux/math.lux')
-rw-r--r-- | stdlib/source/test/lux/math.lux | 26 |
1 files changed, 13 insertions, 13 deletions
diff --git a/stdlib/source/test/lux/math.lux b/stdlib/source/test/lux/math.lux index bede0dd2c..d9741e6ad 100644 --- a/stdlib/source/test/lux/math.lux +++ b/stdlib/source/test/lux/math.lux @@ -19,36 +19,36 @@ ["#/." continuous] ["#/." fuzzy]]]) -(def: (within? margin-of-error standard value) +(def: (within? margin_of_error standard value) (-> Frac Frac Frac Bit) - (f.< margin-of-error + (f.< margin_of_error (f.abs (f.- standard value)))) (def: margin Frac +0.0000001) -(def: (trigonometric-symmetry forward backward angle) +(def: (trigonometric_symmetry forward backward angle) (-> (-> Frac Frac) (-> Frac Frac) Frac Bit) (let [normal (|> angle forward backward)] (|> normal forward backward (within? margin normal)))) (def: #export test Test - (<| (_.context (%.name (name-of /._))) + (<| (_.context (%.name (name_of /._))) ($_ _.and (<| (_.context "Trigonometry") (do {! r.monad} - [angle (|> r.safe-frac (\ ! map (f.* /.tau)))] + [angle (|> r.safe_frac (\ ! map (f.* /.tau)))] ($_ _.and (_.test "Sine and arc-sine are inverse functions." - (trigonometric-symmetry /.sin /.asin angle)) + (trigonometric_symmetry /.sin /.asin angle)) (_.test "Cosine and arc-cosine are inverse functions." - (trigonometric-symmetry /.cos /.acos angle)) + (trigonometric_symmetry /.cos /.acos angle)) (_.test "Tangent and arc-tangent are inverse functions." - (trigonometric-symmetry /.tan /.atan angle)) + (trigonometric_symmetry /.tan /.atan angle)) ))) (<| (_.context "Rounding") (do {! r.monad} - [sample (|> r.safe-frac (\ ! map (f.* +1000.0)))] + [sample (|> r.safe_frac (\ ! map (f.* +1000.0)))] ($_ _.and (_.test "The ceiling will be an integer value, and will be >= the original." (let [ceil'd (/.ceil sample)] @@ -67,14 +67,14 @@ ))) (<| (_.context "Exponentials and logarithms") (do {! r.monad} - [sample (|> r.safe-frac (\ ! map (f.* +10.0)))] + [sample (|> r.safe_frac (\ ! map (f.* +10.0)))] (_.test "Logarithm is the inverse of exponential." (|> sample /.exp /.log (within? +0.000000000000001 sample))))) (<| (_.context "Greatest-Common-Divisor and Least-Common-Multiple") (do {! r.monad} - [#let [gen-nat (|> r.nat (\ ! map (|>> (n.% 1000) (n.max 1))))] - x gen-nat - y gen-nat] + [#let [gen_nat (|> r.nat (\ ! map (|>> (n.% 1000) (n.max 1))))] + x gen_nat + y gen_nat] ($_ _.and (_.test "GCD" (let [gcd (n.gcd x y)] |