aboutsummaryrefslogtreecommitdiff
path: root/stdlib/source/test
diff options
context:
space:
mode:
authorEduardo Julian2019-07-24 21:18:30 -0400
committerEduardo Julian2019-07-24 21:18:30 -0400
commit68b37de7281d31470263d0e06bc72b1c5b6c2e32 (patch)
tree0b4d89fbc5fa8ab8a41190bba78425a26e5f21eb /stdlib/source/test
parente87fba1b7204ee611dcb5528b8a8a3716588c976 (diff)
Got rid of the "Number" abstraction.
Diffstat (limited to 'stdlib/source/test')
-rw-r--r--stdlib/source/test/lux/abstract/number.lux46
-rw-r--r--stdlib/source/test/lux/data/color.lux4
-rw-r--r--stdlib/source/test/lux/data/number/complex.lux13
-rw-r--r--stdlib/source/test/lux/data/number/frac.lux2
-rw-r--r--stdlib/source/test/lux/data/number/int.lux2
-rw-r--r--stdlib/source/test/lux/data/number/nat.lux2
-rw-r--r--stdlib/source/test/lux/data/number/ratio.lux2
-rw-r--r--stdlib/source/test/lux/data/number/rev.lux1
-rw-r--r--stdlib/source/test/lux/macro/poly/equivalence.lux41
-rw-r--r--stdlib/source/test/lux/math.lux6
-rw-r--r--stdlib/source/test/lux/world/file.lux2
11 files changed, 33 insertions, 88 deletions
diff --git a/stdlib/source/test/lux/abstract/number.lux b/stdlib/source/test/lux/abstract/number.lux
deleted file mode 100644
index e04ad3124..000000000
--- a/stdlib/source/test/lux/abstract/number.lux
+++ /dev/null
@@ -1,46 +0,0 @@
-(.module:
- [lux #*
- ["_" test (#+ Test)]
- [abstract/monad (#+ do)]
- [data
- [text
- ["%" format (#+ format)]]]
- [math
- ["r" random (#+ Random)]]]
- {1
- ["." / (#+ Number)
- [//
- ["." order (#+ Order)]]]})
-
-(def: #export (spec (^@ order (^open "/@.")) (^open "/@.") gen-sample)
- (All [a] (-> (Order a) (Number a) (Random a) Test))
- (do r.monad
- [#let [non-zero (r.filter (function (_ sample)
- (|> sample (/@+ sample) (/@= sample) not))
- gen-sample)]
- parameter non-zero
- subject non-zero]
- (<| (_.context (%.name (name-of /.Number)))
- ($_ _.and
- (_.test "Addition and subtraction are inverse functions."
- (|> subject (/@+ parameter) (/@- parameter) (/@= subject)))
- (_.test "Multiplication and division are inverse functions."
- (|> subject (/@* parameter) (/@/ parameter) (/@= subject)))
- (_.test "Modulus fills all the information division misses."
- (let [modulus (/@% parameter subject)
- multiple (/@- modulus subject)
- factor (/@/ parameter multiple)]
- (|> parameter (/@* factor) (/@+ modulus) (/@= subject))))
- (_.test "Negation flips the sign of a number and mimics subtraction."
- (let [unsigned? (/@= (/@signum parameter)
- (/@signum (/@negate parameter)))]
- (or unsigned?
- (/@= (/@+ (/@negate parameter) subject)
- (/@- parameter subject)))))
- (_.test "The absolute value is always positive."
- (let [unsigned? (/@= parameter
- (/@negate parameter))]
- (if unsigned?
- (/@= subject (/@abs subject))
- (order.>= order subject (/@abs subject)))))
- ))))
diff --git a/stdlib/source/test/lux/data/color.lux b/stdlib/source/test/lux/data/color.lux
index 86abba0a3..ee3bdffb1 100644
--- a/stdlib/source/test/lux/data/color.lux
+++ b/stdlib/source/test/lux/data/color.lux
@@ -9,7 +9,7 @@
[data
["%" text/format (#+ format)]
[number
- ["." frac ("#@." number)]]]
+ ["." frac]]]
["." math
["r" random (#+ Random)]]]
{1
@@ -100,6 +100,6 @@
(saturation gray'ed))
(|> (luminance gray'ed)
(f/- (luminance mediocre))
- frac@abs
+ frac.abs
(f/<= error-margin)))))
))))
diff --git a/stdlib/source/test/lux/data/number/complex.lux b/stdlib/source/test/lux/data/number/complex.lux
index 6d7689582..52e43a77e 100644
--- a/stdlib/source/test/lux/data/number/complex.lux
+++ b/stdlib/source/test/lux/data/number/complex.lux
@@ -8,11 +8,10 @@
[/
["$." equivalence]
["$." order]
- ["$." number]
["$." codec]]}]
[data
[number
- ["." frac ("#@." number)]]
+ ["." frac]]
[collection
["." list ("#@." functor)]]]
["." math
@@ -24,9 +23,9 @@
(def: (within? margin standard value)
(-> Frac Complex Complex Bit)
- (let [real-dist (frac@abs (f/- (get@ #/.real standard)
+ (let [real-dist (frac.abs (f/- (get@ #/.real standard)
(get@ #/.real value)))
- imgn-dist (frac@abs (f/- (get@ #/.imaginary standard)
+ imgn-dist (frac.abs (f/- (get@ #/.imaginary standard)
(get@ #/.imaginary value)))]
(and (f/< margin real-dist)
(f/< margin imgn-dist))))
@@ -70,8 +69,8 @@
(_.test "Absolute value of complex >= absolute value of any of the parts."
(let [r+i (/.complex real imaginary)
abs (get@ #/.real (/.abs r+i))]
- (and (f/>= (frac@abs real) abs)
- (f/>= (frac@abs imaginary) abs))))
+ (and (f/>= (frac.abs real) abs)
+ (f/>= (frac.abs imaginary) abs))))
(_.test "The absolute value of a complex number involving a NaN on either dimension, results in a NaN value."
(and (frac.not-a-number? (get@ #/.real (/.abs (/.complex frac.not-a-number imaginary))))
(frac.not-a-number? (get@ #/.real (/.abs (/.complex real frac.not-a-number))))))
@@ -130,7 +129,7 @@
(let [cx (/.conjugate x)]
(and (f/= (get@ #/.real x)
(get@ #/.real cx))
- (f/= (frac@negate (get@ #/.imaginary x))
+ (f/= (frac.negate (get@ #/.imaginary x))
(get@ #/.imaginary cx)))))
(_.test "The reciprocal functions is its own inverse."
(|> x /.reciprocal /.reciprocal (within? margin-of-error x)))
diff --git a/stdlib/source/test/lux/data/number/frac.lux b/stdlib/source/test/lux/data/number/frac.lux
index 9edc0f921..736f82457 100644
--- a/stdlib/source/test/lux/data/number/frac.lux
+++ b/stdlib/source/test/lux/data/number/frac.lux
@@ -8,7 +8,6 @@
[/
["$." equivalence]
["$." order]
- ["$." number]
["$." monoid]
["$." codec]]}]
[math
@@ -24,7 +23,6 @@
(`` ($_ _.and
($equivalence.spec /.equivalence gen-frac)
($order.spec /.order gen-frac)
- ($number.spec /.order /.number gen-frac)
(~~ (template [<monoid>]
[(<| (_.context (%.name (name-of <monoid>)))
($monoid.spec /.equivalence <monoid> gen-frac))]
diff --git a/stdlib/source/test/lux/data/number/int.lux b/stdlib/source/test/lux/data/number/int.lux
index 4fa93051b..7d11f0a03 100644
--- a/stdlib/source/test/lux/data/number/int.lux
+++ b/stdlib/source/test/lux/data/number/int.lux
@@ -8,7 +8,6 @@
[/
["$." equivalence]
["$." order]
- ["$." number]
["$." enum]
["$." interval]
["$." monoid]
@@ -25,7 +24,6 @@
(`` ($_ _.and
($equivalence.spec /.equivalence r.int)
($order.spec /.order r.int)
- ($number.spec /.order /.number (:: r.monad map (i/% +1,000,000) r.int))
($enum.spec /.enum r.int)
($interval.spec /.interval r.int)
(~~ (template [<monoid>]
diff --git a/stdlib/source/test/lux/data/number/nat.lux b/stdlib/source/test/lux/data/number/nat.lux
index dda227223..9a7f5907c 100644
--- a/stdlib/source/test/lux/data/number/nat.lux
+++ b/stdlib/source/test/lux/data/number/nat.lux
@@ -8,7 +8,6 @@
[/
["$." equivalence]
["$." order]
- ["$." number]
["$." enum]
["$." interval]
["$." monoid]
@@ -25,7 +24,6 @@
(`` ($_ _.and
($equivalence.spec /.equivalence r.nat)
($order.spec /.order r.nat)
- ($number.spec /.order /.number (:: r.monad map (n/% 1,000,000) r.nat))
($enum.spec /.enum r.nat)
($interval.spec /.interval r.nat)
(~~ (template [<monoid>]
diff --git a/stdlib/source/test/lux/data/number/ratio.lux b/stdlib/source/test/lux/data/number/ratio.lux
index 160a4fa53..f2162681d 100644
--- a/stdlib/source/test/lux/data/number/ratio.lux
+++ b/stdlib/source/test/lux/data/number/ratio.lux
@@ -8,7 +8,6 @@
[/
["$." equivalence]
["$." order]
- ["$." number]
["$." monoid]
["$." codec]]}]
[math
@@ -33,7 +32,6 @@
(`` ($_ _.and
($equivalence.spec /.equivalence ..ratio)
($order.spec /.order ..ratio)
- ($number.spec /.order /.number ..ratio)
(~~ (template [<monoid>]
[(<| (_.context (%.name (name-of <monoid>)))
($monoid.spec /.equivalence <monoid> ..ratio))]
diff --git a/stdlib/source/test/lux/data/number/rev.lux b/stdlib/source/test/lux/data/number/rev.lux
index 37df07567..1a0bc4571 100644
--- a/stdlib/source/test/lux/data/number/rev.lux
+++ b/stdlib/source/test/lux/data/number/rev.lux
@@ -8,7 +8,6 @@
[/
["$." equivalence]
["$." order]
- ["$." number]
["$." enum]
["$." interval]
["$." monoid]
diff --git a/stdlib/source/test/lux/macro/poly/equivalence.lux b/stdlib/source/test/lux/macro/poly/equivalence.lux
index ef46b9063..c6dcd4687 100644
--- a/stdlib/source/test/lux/macro/poly/equivalence.lux
+++ b/stdlib/source/test/lux/macro/poly/equivalence.lux
@@ -1,16 +1,17 @@
(.module:
[lux #*
["%" data/text/format (#+ format)]
- ["r" math/random (#+ Random)]
["_" test (#+ Test)]
- [abstract/monad (#+ do)]
+ [math
+ ["." random (#+ Random)]]
[abstract
+ [monad (#+ do)]
[equivalence (#+ Equivalence)]]
[data
["." bit]
["." maybe]
[number
- ["." int ("#@." number)]]
+ ["." int]]
["." text]
[collection
["." list]]]
@@ -40,25 +41,25 @@
#recursive Recursive})
(def: gen-recursive
- (r.Random Recursive)
- (r.rec (function (_ gen-recursive)
- (r.or r.frac
- (r.and r.frac gen-recursive)))))
+ (Random Recursive)
+ (random.rec (function (_ gen-recursive)
+ (random.or random.frac
+ (random.and random.frac gen-recursive)))))
(def: gen-record
- (r.Random Record)
- (do r.monad
- [size (:: @ map (n/% 2) r.nat)
- #let [gen-int (|> r.int (:: @ map (|>> int@abs (i/% +1,000,000))))]]
- ($_ r.and
- r.bit
+ (Random Record)
+ (do random.monad
+ [size (:: @ map (n/% 2) random.nat)
+ #let [gen-int (|> random.int (:: @ map (|>> int.abs (i/% +1,000,000))))]]
+ ($_ random.and
+ random.bit
gen-int
- r.frac
- (r.unicode size)
- (r.maybe gen-int)
- (r.list size gen-int)
- ($_ r.or r.bit gen-int r.frac)
- ($_ r.and gen-int r.frac (r.unicode size))
+ random.frac
+ (random.unicode size)
+ (random.maybe gen-int)
+ (random.list size gen-int)
+ ($_ random.or random.bit gen-int random.frac)
+ ($_ random.and gen-int random.frac (random.unicode size))
gen-recursive)))
(derived: equivalence (/.equivalence Record))
@@ -66,7 +67,7 @@
(def: #export test
Test
(<| (_.context (%.name (name-of /._)))
- (do r.monad
+ (do random.monad
[sample gen-record
#let [(^open "/@.") ..equivalence]]
(_.test "Every instance equals itself."
diff --git a/stdlib/source/test/lux/math.lux b/stdlib/source/test/lux/math.lux
index 88dc6d420..46b5171ee 100644
--- a/stdlib/source/test/lux/math.lux
+++ b/stdlib/source/test/lux/math.lux
@@ -7,7 +7,7 @@
[data
["." bit ("#@." equivalence)]
[number
- ["." frac ("#@." number)]]]]
+ ["." frac]]]]
{1
["." /]}
["." / #_
@@ -20,7 +20,7 @@
(def: (within? margin-of-error standard value)
(-> Frac Frac Frac Bit)
(f/< margin-of-error
- (frac@abs (f/- standard value))))
+ (frac.abs (f/- standard value))))
(def: margin Frac +0.0000001)
@@ -61,7 +61,7 @@
(_.test "The round will be an integer value, and will be < or > or = the original."
(let [round'd (/.round sample)]
(and (|> round'd frac-to-int int-to-frac (f/= round'd))
- (f/<= +1.0 (frac@abs (f/- sample round'd))))))
+ (f/<= +1.0 (frac.abs (f/- sample round'd))))))
)))
(<| (_.context "Exponentials and logarithms")
(do r.monad
diff --git a/stdlib/source/test/lux/world/file.lux b/stdlib/source/test/lux/world/file.lux
index 808a09e0e..2659183af 100644
--- a/stdlib/source/test/lux/world/file.lux
+++ b/stdlib/source/test/lux/world/file.lux
@@ -71,7 +71,7 @@
[file-size (|> r.nat (:: @ map (|>> (n/% 100) (n/max 10))))
dataL (_binary.binary file-size)
dataR (_binary.binary file-size)
- new-modified (|> r.int (:: @ map (|>> (:: int.number abs)
+ new-modified (|> r.int (:: @ map (|>> int.abs
truncate-millis
duration.from-millis
instant.absolute)))]