diff options
Diffstat (limited to 'stdlib/source/test')
-rw-r--r-- | stdlib/source/test/lux.lux | 3 | ||||
-rw-r--r-- | stdlib/source/test/lux/data/color.lux | 16 | ||||
-rw-r--r-- | stdlib/source/test/lux/data/number/complex.lux | 23 | ||||
-rw-r--r-- | stdlib/source/test/lux/math.lux | 8 |
4 files changed, 24 insertions, 26 deletions
diff --git a/stdlib/source/test/lux.lux b/stdlib/source/test/lux.lux index a52c70fd4..f830f8215 100644 --- a/stdlib/source/test/lux.lux +++ b/stdlib/source/test/lux.lux @@ -375,6 +375,5 @@ (program: args (<| io _.run! - ## (_.times 100) - (_.seed 4035274984803317370) + (_.times 100) ..test)) diff --git a/stdlib/source/test/lux/data/color.lux b/stdlib/source/test/lux/data/color.lux index f5ac95d90..ed69ddf7c 100644 --- a/stdlib/source/test/lux/data/color.lux +++ b/stdlib/source/test/lux/data/color.lux @@ -11,12 +11,12 @@ [number ["." frac ("#@." number)]]] ["." math - ["r" random]]] + ["r" random (#+ Random)]]] {1 - ["." /]}) + ["." / (#+ Color)]}) -(def: color - (r.Random /.Color) +(def: #export color + (Random Color) (|> ($_ r.and r.nat r.nat r.nat) (:: r.monad map /.from-rgb))) @@ -27,7 +27,7 @@ (def: square (-> Frac Frac) (math.pow +2.0)) (def: (distance from to) - (-> /.Color /.Color Frac) + (-> Color Color Frac) (let [[fr fg fb] (/.to-rgb from) [tr tg tb] (/.to-rgb to)] (math.pow +0.5 ($_ f/+ @@ -42,7 +42,7 @@ (do-template [<field>] [(def: (<field> color) - (-> /.Color Frac) + (-> Color Frac) (let [[hue saturation luminance] (/.to-hsl color)] <field>))] @@ -52,7 +52,7 @@ (def: #export test Test - (<| (_.context (%name (name-of /.Color))) + (<| (_.context (%name (name-of /._))) (do r.monad [any ..color colorful (|> color @@ -63,7 +63,7 @@ ((function (_ saturation) (and (f/>= +0.25 saturation) (f/<= +0.75 saturation))))))) - ratio (|> r.frac (r.filter (f/>= +0.5)))] + ratio (|> r.safe-frac (r.filter (f/>= +0.5)))] ($_ _.and ($equivalence.spec /.equivalence ..color) (_.test "Can convert to/from HSL." diff --git a/stdlib/source/test/lux/data/number/complex.lux b/stdlib/source/test/lux/data/number/complex.lux index 19db6081d..a1fc7beca 100644 --- a/stdlib/source/test/lux/data/number/complex.lux +++ b/stdlib/source/test/lux/data/number/complex.lux @@ -35,7 +35,7 @@ (Random Frac) (do r.monad [factor (|> r.nat (:: @ map (|>> (n/% 1000) (n/max 1)))) - measure (|> r.frac (r.filter (f/> +0.0)))] + measure (|> r.safe-frac (r.filter (f/> +0.0)))] (wrap (f/* (|> factor .int int-to-frac) measure)))) @@ -158,17 +158,16 @@ (def: trigonometry Test - (<| (_.seed 17274883666004960943) - (do r.monad - [angle (|> ..complex (:: @ map (|>> (update@ #/.real (f/% +1.0)) - (update@ #/.imaginary (f/% +1.0)))))] - ($_ _.and - (_.test "Arc-sine is the inverse of sine." - (trigonometric-symmetry /.sin /.asin angle)) - (_.test "Arc-cosine is the inverse of cosine." - (trigonometric-symmetry /.cos /.acos angle)) - (_.test "Arc-tangent is the inverse of tangent." - (trigonometric-symmetry /.tan /.atan angle)))))) + (do r.monad + [angle (|> ..complex (:: @ map (|>> (update@ #/.real (f/% +1.0)) + (update@ #/.imaginary (f/% +1.0)))))] + ($_ _.and + (_.test "Arc-sine is the inverse of sine." + (trigonometric-symmetry /.sin /.asin angle)) + (_.test "Arc-cosine is the inverse of cosine." + (trigonometric-symmetry /.cos /.acos angle)) + (_.test "Arc-tangent is the inverse of tangent." + (trigonometric-symmetry /.tan /.atan angle))))) (def: exponentiation&logarithm Test diff --git a/stdlib/source/test/lux/math.lux b/stdlib/source/test/lux/math.lux index 79143b815..a659e8095 100644 --- a/stdlib/source/test/lux/math.lux +++ b/stdlib/source/test/lux/math.lux @@ -2,7 +2,7 @@ [lux #* data/text/format ["_" test (#+ Test)] - ["r" math/random] + ["r" math/random (#+ Random)] [control [monad (#+ Monad do)]] [data @@ -35,7 +35,7 @@ ($_ _.and (<| (_.context "Trigonometry") (do r.monad - [angle (|> r.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)) @@ -46,7 +46,7 @@ ))) (<| (_.context "Rounding") (do r.monad - [sample (|> r.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)] @@ -65,7 +65,7 @@ ))) (<| (_.context "Exponentials and logarithms") (do r.monad - [sample (|> r.frac (:: @ map (f/* +10.0)))] + [sample (|> r.safe-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") |