aboutsummaryrefslogtreecommitdiff
path: root/stdlib/source/test/lux/data
diff options
context:
space:
mode:
Diffstat (limited to 'stdlib/source/test/lux/data')
-rw-r--r--stdlib/source/test/lux/data/binary.lux10
-rw-r--r--stdlib/source/test/lux/data/collection/array.lux9
-rw-r--r--stdlib/source/test/lux/data/collection/bits.lux7
-rw-r--r--stdlib/source/test/lux/data/collection/dictionary.lux6
-rw-r--r--stdlib/source/test/lux/data/collection/dictionary/ordered.lux6
-rw-r--r--stdlib/source/test/lux/data/collection/dictionary/plist.lux6
-rw-r--r--stdlib/source/test/lux/data/collection/list.lux8
-rw-r--r--stdlib/source/test/lux/data/collection/queue.lux7
-rw-r--r--stdlib/source/test/lux/data/collection/queue/priority.lux8
-rw-r--r--stdlib/source/test/lux/data/collection/row.lux6
-rw-r--r--stdlib/source/test/lux/data/collection/sequence.lux6
-rw-r--r--stdlib/source/test/lux/data/collection/set.lux6
-rw-r--r--stdlib/source/test/lux/data/collection/set/multi.lux6
-rw-r--r--stdlib/source/test/lux/data/collection/set/ordered.lux6
-rw-r--r--stdlib/source/test/lux/data/collection/stack.lux8
-rw-r--r--stdlib/source/test/lux/data/collection/tree.lux6
-rw-r--r--stdlib/source/test/lux/data/collection/tree/finger.lux6
-rw-r--r--stdlib/source/test/lux/data/collection/tree/zipper.lux6
-rw-r--r--stdlib/source/test/lux/data/color.lux12
-rw-r--r--stdlib/source/test/lux/data/color/named.lux6
-rw-r--r--stdlib/source/test/lux/data/format/json.lux8
-rw-r--r--stdlib/source/test/lux/data/format/tar.lux8
-rw-r--r--stdlib/source/test/lux/data/format/xml.lux6
-rw-r--r--stdlib/source/test/lux/data/lazy.lux7
-rw-r--r--stdlib/source/test/lux/data/maybe.lux98
-rw-r--r--stdlib/source/test/lux/data/name.lux6
-rw-r--r--stdlib/source/test/lux/data/number.lux110
-rw-r--r--stdlib/source/test/lux/data/number/complex.lux286
-rw-r--r--stdlib/source/test/lux/data/number/frac.lux244
-rw-r--r--stdlib/source/test/lux/data/number/i16.lux40
-rw-r--r--stdlib/source/test/lux/data/number/i32.lux40
-rw-r--r--stdlib/source/test/lux/data/number/i64.lux282
-rw-r--r--stdlib/source/test/lux/data/number/i8.lux40
-rw-r--r--stdlib/source/test/lux/data/number/int.lux184
-rw-r--r--stdlib/source/test/lux/data/number/nat.lux130
-rw-r--r--stdlib/source/test/lux/data/number/ratio.lux114
-rw-r--r--stdlib/source/test/lux/data/number/rev.lux164
-rw-r--r--stdlib/source/test/lux/data/product.lux7
-rw-r--r--stdlib/source/test/lux/data/sum.lux8
-rw-r--r--stdlib/source/test/lux/data/text.lux6
-rw-r--r--stdlib/source/test/lux/data/text/buffer.lux8
-rw-r--r--stdlib/source/test/lux/data/text/encoding.lux6
-rw-r--r--stdlib/source/test/lux/data/text/format.lux14
-rw-r--r--stdlib/source/test/lux/data/text/regex.lux14
-rw-r--r--stdlib/source/test/lux/data/text/unicode/block.lux6
-rw-r--r--stdlib/source/test/lux/data/text/unicode/set.lux6
46 files changed, 172 insertions, 1811 deletions
diff --git a/stdlib/source/test/lux/data/binary.lux b/stdlib/source/test/lux/data/binary.lux
index 3d828dbb2..07c02ea09 100644
--- a/stdlib/source/test/lux/data/binary.lux
+++ b/stdlib/source/test/lux/data/binary.lux
@@ -1,8 +1,6 @@
(.module:
[lux #*
["_" test (#+ Test)]
- [math
- ["." random (#+ Random)]]
[abstract
["." monad (#+ do)]
["." enum]
@@ -14,11 +12,13 @@
["." try (#+ Try)]
["." exception (#+ Exception)]]
[data
+ [collection
+ ["." list]]]
+ [math
+ ["." random (#+ Random)]
[number
["." i64]
- ["n" nat]]
- [collection
- ["." list]]]]
+ ["n" nat]]]]
{1
["." / (#+ Binary)]})
diff --git a/stdlib/source/test/lux/data/collection/array.lux b/stdlib/source/test/lux/data/collection/array.lux
index ab1b1f04c..5cfbe4a7d 100644
--- a/stdlib/source/test/lux/data/collection/array.lux
+++ b/stdlib/source/test/lux/data/collection/array.lux
@@ -12,15 +12,14 @@
[data
["." bit]
["." maybe]
- ["." text ("#\." equivalence)
- ["%" format (#+ format)]]
- [number
- ["n" nat]]
+ ["." text ("#\." equivalence)]
[collection
["." list]
["." set]]]
[math
- ["." random (#+ Random)]]]
+ ["." random (#+ Random)]
+ [number
+ ["n" nat]]]]
{1
["." / (#+ Array)]})
diff --git a/stdlib/source/test/lux/data/collection/bits.lux b/stdlib/source/test/lux/data/collection/bits.lux
index 6e07dc2e6..f4b780864 100644
--- a/stdlib/source/test/lux/data/collection/bits.lux
+++ b/stdlib/source/test/lux/data/collection/bits.lux
@@ -7,11 +7,10 @@
{[0 #spec]
[/
["$." equivalence]]}]
- [data
- [number
- ["n" nat]]]
[math
- ["." random (#+ Random)]]]
+ ["." random (#+ Random)]
+ [number
+ ["n" nat]]]]
{1
["." / (#+ Bits)]})
diff --git a/stdlib/source/test/lux/data/collection/dictionary.lux b/stdlib/source/test/lux/data/collection/dictionary.lux
index 0de661e64..92705210b 100644
--- a/stdlib/source/test/lux/data/collection/dictionary.lux
+++ b/stdlib/source/test/lux/data/collection/dictionary.lux
@@ -14,12 +14,12 @@
[data
["." product]
["." maybe]
- [number
- ["n" nat]]
[collection
["." list ("#\." functor)]]]
[math
- ["." random]]]
+ ["." random]
+ [number
+ ["n" nat]]]]
{1
["." /]})
diff --git a/stdlib/source/test/lux/data/collection/dictionary/ordered.lux b/stdlib/source/test/lux/data/collection/dictionary/ordered.lux
index a44b5c295..778726329 100644
--- a/stdlib/source/test/lux/data/collection/dictionary/ordered.lux
+++ b/stdlib/source/test/lux/data/collection/dictionary/ordered.lux
@@ -12,13 +12,13 @@
["." product]
["." bit ("#\." equivalence)]
["." maybe ("#\." monad)]
- [number
- ["n" nat]]
[collection
["." set]
["." list ("#\." functor)]]]
[math
- ["." random (#+ Random) ("#\." monad)]]]
+ ["." random (#+ Random) ("#\." monad)]
+ [number
+ ["n" nat]]]]
{1
["." /]})
diff --git a/stdlib/source/test/lux/data/collection/dictionary/plist.lux b/stdlib/source/test/lux/data/collection/dictionary/plist.lux
index 753b8db8a..7473aec04 100644
--- a/stdlib/source/test/lux/data/collection/dictionary/plist.lux
+++ b/stdlib/source/test/lux/data/collection/dictionary/plist.lux
@@ -10,13 +10,13 @@
["." bit ("#\." equivalence)]
["." maybe ("#\." monad)]
["." text]
- [number
- ["n" nat]]
[collection
["." set]
["." list]]]
[math
- ["." random (#+ Random)]]]
+ ["." random (#+ Random)]
+ [number
+ ["n" nat]]]]
{1
["." /]})
diff --git a/stdlib/source/test/lux/data/collection/list.lux b/stdlib/source/test/lux/data/collection/list.lux
index b2d35b1f4..6306f62fc 100644
--- a/stdlib/source/test/lux/data/collection/list.lux
+++ b/stdlib/source/test/lux/data/collection/list.lux
@@ -21,13 +21,13 @@
["." product]
["." maybe]
["." text ("#\." equivalence)]
- [number
- ["n" nat]
- ["." int]]
[collection
["." set]]]
[math
- ["." random (#+ Random)]]]
+ ["." random (#+ Random)]
+ [number
+ ["n" nat]
+ ["." int]]]]
{1
["." / ("#\." monad)]})
diff --git a/stdlib/source/test/lux/data/collection/queue.lux b/stdlib/source/test/lux/data/collection/queue.lux
index 3e532a66e..b246f8187 100644
--- a/stdlib/source/test/lux/data/collection/queue.lux
+++ b/stdlib/source/test/lux/data/collection/queue.lux
@@ -9,14 +9,13 @@
["$." functor (#+ Injection)]]}]
[data
["." bit ("#\." equivalence)]
- ["%" text/format (#+ format)]
- [number
- ["n" nat]]
[collection
["." set]
["." list ("#\." monoid)]]]
[math
- ["." random]]]
+ ["." random]
+ [number
+ ["n" nat]]]]
{1
["." /]})
diff --git a/stdlib/source/test/lux/data/collection/queue/priority.lux b/stdlib/source/test/lux/data/collection/queue/priority.lux
index 19f219378..4e99d2a3a 100644
--- a/stdlib/source/test/lux/data/collection/queue/priority.lux
+++ b/stdlib/source/test/lux/data/collection/queue/priority.lux
@@ -5,11 +5,11 @@
["." monad (#+ do)]]
[data
["." maybe ("#\." functor)]
- ["." bit ("#\." equivalence)]
- [number
- ["n" nat]]]
+ ["." bit ("#\." equivalence)]]
[math
- ["." random (#+ Random)]]]
+ ["." random (#+ Random)]
+ [number
+ ["n" nat]]]]
{1
["." / (#+ Queue)]})
diff --git a/stdlib/source/test/lux/data/collection/row.lux b/stdlib/source/test/lux/data/collection/row.lux
index 13ed9af28..55d9492ff 100644
--- a/stdlib/source/test/lux/data/collection/row.lux
+++ b/stdlib/source/test/lux/data/collection/row.lux
@@ -16,13 +16,13 @@
["." exception]]
[data
["." bit ("#\." equivalence)]
- [number
- ["n" nat]]
[collection
["." list ("#\." fold)]
["." set]]]
[math
- ["." random]]]
+ ["." random]
+ [number
+ ["n" nat]]]]
{1
["." / ("#\." monad)]})
diff --git a/stdlib/source/test/lux/data/collection/sequence.lux b/stdlib/source/test/lux/data/collection/sequence.lux
index b97e1f7d2..013936731 100644
--- a/stdlib/source/test/lux/data/collection/sequence.lux
+++ b/stdlib/source/test/lux/data/collection/sequence.lux
@@ -10,14 +10,14 @@
["$." functor]
["$." comonad]]}]
[data
- [number
- ["n" nat]]
["." text
["%" format (#+ format)]]
[collection
["." list ("#\." functor)]]]
[math
- ["." random]]]
+ ["." random]
+ [number
+ ["n" nat]]]]
{1
["." /]})
diff --git a/stdlib/source/test/lux/data/collection/set.lux b/stdlib/source/test/lux/data/collection/set.lux
index a58627cde..6f981af91 100644
--- a/stdlib/source/test/lux/data/collection/set.lux
+++ b/stdlib/source/test/lux/data/collection/set.lux
@@ -10,12 +10,12 @@
["$." monoid]]}]
[data
["." bit ("#\." equivalence)]
- [number
- ["n" nat]]
[collection
["." list]]]
[math
- ["." random (#+ Random)]]]
+ ["." random (#+ Random)]
+ [number
+ ["n" nat]]]]
{1
["." / ("\." equivalence)]})
diff --git a/stdlib/source/test/lux/data/collection/set/multi.lux b/stdlib/source/test/lux/data/collection/set/multi.lux
index 8d6d5aa22..9d9572795 100644
--- a/stdlib/source/test/lux/data/collection/set/multi.lux
+++ b/stdlib/source/test/lux/data/collection/set/multi.lux
@@ -10,13 +10,13 @@
["$." equivalence]]}]
[data
["." bit ("#\." equivalence)]
- [number
- ["n" nat]]
[collection
["." set]
["." list ("#\." fold)]]]
[math
- ["." random (#+ Random)]]]
+ ["." random (#+ Random)]
+ [number
+ ["n" nat]]]]
{1
["." /]})
diff --git a/stdlib/source/test/lux/data/collection/set/ordered.lux b/stdlib/source/test/lux/data/collection/set/ordered.lux
index 6c0e75b3d..daf924012 100644
--- a/stdlib/source/test/lux/data/collection/set/ordered.lux
+++ b/stdlib/source/test/lux/data/collection/set/ordered.lux
@@ -9,12 +9,12 @@
["$." equivalence]]}]
[data
["." bit ("#\." equivalence)]
- [number
- ["n" nat]]
[collection
["." list]]]
[math
- ["." random (#+ Random) ("#\." monad)]]]
+ ["." random (#+ Random) ("#\." monad)]
+ [number
+ ["n" nat]]]]
{1
["." / (#+ Set)
["." //]]})
diff --git a/stdlib/source/test/lux/data/collection/stack.lux b/stdlib/source/test/lux/data/collection/stack.lux
index 8a12c4fab..ae6fbabf6 100644
--- a/stdlib/source/test/lux/data/collection/stack.lux
+++ b/stdlib/source/test/lux/data/collection/stack.lux
@@ -9,11 +9,11 @@
["$." functor (#+ Injection)]]}]
[data
["." maybe]
- ["." bit ("#\." equivalence)]
- [number
- ["n" nat]]]
+ ["." bit ("#\." equivalence)]]
[math
- ["." random]]]
+ ["." random]
+ [number
+ ["n" nat]]]]
{1
["." /]})
diff --git a/stdlib/source/test/lux/data/collection/tree.lux b/stdlib/source/test/lux/data/collection/tree.lux
index 0b7dbbdf8..b7fea5e4f 100644
--- a/stdlib/source/test/lux/data/collection/tree.lux
+++ b/stdlib/source/test/lux/data/collection/tree.lux
@@ -10,12 +10,12 @@
["$." functor]]}]
[data
["." product]
- [number
- ["n" nat]]
[collection
["." list ("#\." functor fold)]]]
[math
- ["." random (#+ Random)]]]
+ ["." random (#+ Random)]
+ [number
+ ["n" nat]]]]
{1
["." / (#+ Tree)]})
diff --git a/stdlib/source/test/lux/data/collection/tree/finger.lux b/stdlib/source/test/lux/data/collection/tree/finger.lux
index f169d8a5d..33b333396 100644
--- a/stdlib/source/test/lux/data/collection/tree/finger.lux
+++ b/stdlib/source/test/lux/data/collection/tree/finger.lux
@@ -6,12 +6,12 @@
[data
["." maybe ("#\." functor)]
["." text ("#\." equivalence monoid)]
- [number
- ["n" nat]]
[collection
["." list ("#\." fold)]]]
[math
- ["." random]]
+ ["." random]
+ [number
+ ["n" nat]]]
[type (#+ :by_example)]]
{1
["." /]})
diff --git a/stdlib/source/test/lux/data/collection/tree/zipper.lux b/stdlib/source/test/lux/data/collection/tree/zipper.lux
index 419935101..929572a37 100644
--- a/stdlib/source/test/lux/data/collection/tree/zipper.lux
+++ b/stdlib/source/test/lux/data/collection/tree/zipper.lux
@@ -14,12 +14,12 @@
["." product]
["." maybe ("#\." functor)]
["." text]
- [number
- ["n" nat]]
[collection
["." list]]]
[math
- ["." random]]]
+ ["." random]
+ [number
+ ["n" nat]]]]
["." //]
{1
["." / (#+ Zipper)
diff --git a/stdlib/source/test/lux/data/color.lux b/stdlib/source/test/lux/data/color.lux
index c0ea5e699..a8119145b 100644
--- a/stdlib/source/test/lux/data/color.lux
+++ b/stdlib/source/test/lux/data/color.lux
@@ -9,17 +9,17 @@
["$." hash]
["$." monoid]]}]
[data
- [number
- ["n" nat]
- ["." int]
- ["f" frac]
- ["r" rev]]
[collection
["." list]]]
[macro
["." template]]
["." math
- ["." random (#+ Random)]]]
+ ["." random (#+ Random)]
+ [number
+ ["n" nat]
+ ["." int]
+ ["f" frac]
+ ["r" rev]]]]
{1
["." / (#+ Color)]})
diff --git a/stdlib/source/test/lux/data/color/named.lux b/stdlib/source/test/lux/data/color/named.lux
index 062ba560b..9a3fddcaf 100644
--- a/stdlib/source/test/lux/data/color/named.lux
+++ b/stdlib/source/test/lux/data/color/named.lux
@@ -4,15 +4,15 @@
[abstract
[monad (#+ do)]]
[data
- [number
- ["n" nat]]
[collection
["." list]
["." set]]]
[macro
["." template]]
[math
- ["." random (#+ Random)]]]
+ ["." random (#+ Random)]
+ [number
+ ["n" nat]]]]
{1
["." /
["/#" //]]})
diff --git a/stdlib/source/test/lux/data/format/json.lux b/stdlib/source/test/lux/data/format/json.lux
index 2d38b8988..4f14375d9 100644
--- a/stdlib/source/test/lux/data/format/json.lux
+++ b/stdlib/source/test/lux/data/format/json.lux
@@ -15,16 +15,16 @@
["." bit]
["." text
["%" format (#+ format)]]
- [number
- ["n" nat]
- ["." frac]]
[collection
["." row]
["." dictionary]
["." set]
["." list ("#\." functor)]]]
[math
- ["." random (#+ Random)]]
+ ["." random (#+ Random)]
+ [number
+ ["n" nat]
+ ["." frac]]]
[macro
["." syntax (#+ syntax:)]
["." code]]]
diff --git a/stdlib/source/test/lux/data/format/tar.lux b/stdlib/source/test/lux/data/format/tar.lux
index 72024ba29..9d576b93a 100644
--- a/stdlib/source/test/lux/data/format/tar.lux
+++ b/stdlib/source/test/lux/data/format/tar.lux
@@ -18,9 +18,6 @@
["." unicode #_
["#" set]
["#/." block]]]
- [number
- ["n" nat]
- ["i" int]]
[collection
["." row]
["." list ("#\." fold)]]
@@ -30,7 +27,10 @@
["." instant (#+ Instant)]
["." duration]]
[math
- ["." random (#+ Random)]]]
+ ["." random (#+ Random)]
+ [number
+ ["n" nat]
+ ["i" int]]]]
{1
["." /]})
diff --git a/stdlib/source/test/lux/data/format/xml.lux b/stdlib/source/test/lux/data/format/xml.lux
index 57958281c..bd3b45216 100644
--- a/stdlib/source/test/lux/data/format/xml.lux
+++ b/stdlib/source/test/lux/data/format/xml.lux
@@ -17,13 +17,13 @@
["." maybe]
["." text ("#\." equivalence)
["%" format (#+ format)]]
- [number
- ["n" nat]]
[collection
["." dictionary]
["." list ("#\." functor)]]]
[math
- ["." random (#+ Random) ("#\." monad)]]]
+ ["." random (#+ Random) ("#\." monad)]
+ [number
+ ["n" nat]]]]
{1
["." / (#+ XML)]})
diff --git a/stdlib/source/test/lux/data/lazy.lux b/stdlib/source/test/lux/data/lazy.lux
index ddb24aee8..5900817e4 100644
--- a/stdlib/source/test/lux/data/lazy.lux
+++ b/stdlib/source/test/lux/data/lazy.lux
@@ -9,11 +9,10 @@
["$." apply]
["$." monad]
["$." equivalence]]}]
- [data
- [number
- ["n" nat]]]
[math
- ["." random (#+ Random)]]]
+ ["." random (#+ Random)]
+ [number
+ ["n" nat]]]]
{1
["." / (#+ Lazy)]})
diff --git a/stdlib/source/test/lux/data/maybe.lux b/stdlib/source/test/lux/data/maybe.lux
index f5e965614..64f9b5ff5 100644
--- a/stdlib/source/test/lux/data/maybe.lux
+++ b/stdlib/source/test/lux/data/maybe.lux
@@ -15,63 +15,63 @@
pipe]
[data
["." text]
- [number
- ["n" nat]]
[collection
["." list]]]
[math
- ["." random (#+ Random)]]]
+ ["." random (#+ Random)]
+ [number
+ ["n" nat]]]]
{1
["." / ("#\." monoid monad)]})
(def: #export test
Test
(<| (_.covering /._)
- (_.for [.Maybe]
- ($_ _.and
- (_.for [/.equivalence]
- ($equivalence.spec (/.equivalence n.equivalence) (random.maybe random.nat)))
- (_.for [/.monoid]
- ($monoid.spec (/.equivalence n.equivalence) /.monoid (random.maybe random.nat)))
- (_.for [/.functor]
- ($functor.spec /\wrap /.equivalence /.functor))
- (_.for [/.apply]
- ($apply.spec /\wrap /.equivalence /.apply))
- (_.for [/.monad]
- ($monad.spec /\wrap /.equivalence /.monad))
-
- (do random.monad
- [left random.nat
- right random.nat
- #let [expected (n.+ left right)]]
- (let [lift (/.lift io.monad)]
- (_.cover [/.with /.lift]
- (|> (io.run (do (/.with io.monad)
- [a (lift (io\wrap left))
- b (wrap right)]
- (wrap (n.+ a b))))
- (case> (#.Some actual)
- (n.= expected actual)
+ (_.for [.Maybe])
+ ($_ _.and
+ (_.for [/.equivalence]
+ ($equivalence.spec (/.equivalence n.equivalence) (random.maybe random.nat)))
+ (_.for [/.monoid]
+ ($monoid.spec (/.equivalence n.equivalence) /.monoid (random.maybe random.nat)))
+ (_.for [/.functor]
+ ($functor.spec /\wrap /.equivalence /.functor))
+ (_.for [/.apply]
+ ($apply.spec /\wrap /.equivalence /.apply))
+ (_.for [/.monad]
+ ($monad.spec /\wrap /.equivalence /.monad))
+
+ (do random.monad
+ [left random.nat
+ right random.nat
+ #let [expected (n.+ left right)]]
+ (let [lift (/.lift io.monad)]
+ (_.cover [/.with /.lift]
+ (|> (io.run (do (/.with io.monad)
+ [a (lift (io\wrap left))
+ b (wrap right)]
+ (wrap (n.+ a b))))
+ (case> (#.Some actual)
+ (n.= expected actual)
- _
- false)))))
- (do random.monad
- [default random.nat
- value random.nat]
- (_.cover [/.default]
- (and (is? default (/.default default
- #.None))
+ _
+ false)))))
+ (do random.monad
+ [default random.nat
+ value random.nat]
+ (_.cover [/.default]
+ (and (is? default (/.default default
+ #.None))
- (is? value (/.default default
- (#.Some value))))))
- (do random.monad
- [value random.nat]
- (_.cover [/.assume]
- (is? value (/.assume (#.Some value)))))
- (do random.monad
- [value random.nat]
- (_.cover [/.to-list]
- (\ (list.equivalence n.equivalence) =
- (list value)
- (/.to-list (#.Some value)))))
- ))))
+ (is? value (/.default default
+ (#.Some value))))))
+ (do random.monad
+ [value random.nat]
+ (_.cover [/.assume]
+ (is? value (/.assume (#.Some value)))))
+ (do random.monad
+ [value random.nat]
+ (_.cover [/.to-list]
+ (\ (list.equivalence n.equivalence) =
+ (list value)
+ (/.to-list (#.Some value)))))
+ )))
diff --git a/stdlib/source/test/lux/data/name.lux b/stdlib/source/test/lux/data/name.lux
index 08fd3065e..7912994c3 100644
--- a/stdlib/source/test/lux/data/name.lux
+++ b/stdlib/source/test/lux/data/name.lux
@@ -11,11 +11,11 @@
[control
pipe]
[data
- [number
- ["n" nat]]
["." text ("#\." equivalence)]]
[math
- ["." random (#+ Random)]]]
+ ["." random (#+ Random)]
+ [number
+ ["n" nat]]]]
{1
["." /]})
diff --git a/stdlib/source/test/lux/data/number.lux b/stdlib/source/test/lux/data/number.lux
deleted file mode 100644
index d8e769369..000000000
--- a/stdlib/source/test/lux/data/number.lux
+++ /dev/null
@@ -1,110 +0,0 @@
-(.module:
- [lux #*
- ["_" test (#+ Test)]
- [control
- ["." try]]
- [data
- ["." text
- ["%" format (#+ format)]]
- [number
- ["n" nat]
- ["i" int]
- ["r" rev]
- ["f" frac]]]]
- {1
- ["." /]}
- ["." / #_
- ["#." i8]
- ["#." i16]
- ["#." i32]
- ["#." i64]
- ["#." nat]
- ["#." int]
- ["#." rev]
- ["#." frac]
- ["#." ratio]
- ["#." complex]])
-
-(def: clean_commas
- (-> Text Text)
- (text.replace_all "," ""))
-
-(def: #export test
- Test
- (<| (_.covering /._)
- ($_ _.and
- (_.cover [/.bin]
- (`` (and (~~ (template [<=> <codec> <number>]
- [(case (\ <codec> decode (..clean_commas <number>))
- (#try.Success actual)
- (<=> (/.bin <number>) actual)
-
- (#try.Failure error)
- false)]
-
- [n.= n.binary "11001001"]
- [n.= n.binary "11,00,10,01"]
-
- [i.= i.binary "+11001001"]
- [i.= i.binary "-11,00,10,01"]
-
- [r.= r.binary ".11001001"]
- [r.= r.binary ".11,00,10,01"]
-
- [f.= f.binary "+1100.1001"]
- [f.= f.binary "-11,00.10,01"]
- )))))
- (_.cover [/.oct]
- (`` (and (~~ (template [<=> <codec> <number>]
- [(case (\ <codec> decode (..clean_commas <number>))
- (#try.Success actual)
- (<=> (/.oct <number>) actual)
-
- (#try.Failure error)
- false)]
-
- [n.= n.octal "615243"]
- [n.= n.octal "615,243"]
-
- [i.= i.octal "+615243"]
- [i.= i.octal "-615,243"]
-
- [r.= r.octal ".615243"]
- [r.= r.octal ".615,243"]
-
- [f.= f.octal "+6152.43"]
- [f.= f.octal "-61,52.43"]
- )))))
- (_.cover [/.hex]
- (`` (and (~~ (template [<=> <codec> <number>]
- [(case (\ <codec> decode (..clean_commas <number>))
- (#try.Success actual)
- (<=> (/.hex <number>) actual)
-
- (#try.Failure error)
- false)]
-
- [n.= n.hex "deadBEEF"]
- [n.= n.hex "dead,BEEF"]
-
- [i.= i.hex "+deadBEEF"]
- [i.= i.hex "-dead,BEEF"]
-
- [r.= r.hex ".deadBEEF"]
- [r.= r.hex ".dead,BEEF"]
-
- [f.= f.hex "+dead.BEEF"]
- [f.= f.hex "-dead,BE.EF"]
- )))))
-
- /i8.test
- /i16.test
- /i32.test
- /i64.test
- /nat.test
- /int.test
- /rev.test
- /frac.test
- /ratio.test
- /complex.test
- )))
diff --git a/stdlib/source/test/lux/data/number/complex.lux b/stdlib/source/test/lux/data/number/complex.lux
deleted file mode 100644
index fc83ddb51..000000000
--- a/stdlib/source/test/lux/data/number/complex.lux
+++ /dev/null
@@ -1,286 +0,0 @@
-(.module:
- [lux #*
- ["%" data/text/format (#+ format)]
- ["_" test (#+ Test)]
- [abstract
- [monad (#+ do)]
- {[0 #spec]
- [/
- ["$." equivalence]
- ["$." order]
- ["$." codec]]}]
- [data
- [number
- ["n" nat]
- ["." int]
- ["f" frac]]
- [collection
- ["." list ("#\." functor)]]]
- ["." math
- ["." random (#+ Random)]]]
- {1
- ["." /]})
-
-(def: margin_of_error
- +0.000000001)
-
-(def: dimension
- (Random Frac)
- (do {! random.monad}
- [factor (|> random.nat (\ ! map (|>> (n.% 1000) (n.max 1))))
- measure (|> random.safe_frac (random.filter (f.> +0.0)))]
- (wrap (f.* (|> factor .int int.frac)
- measure))))
-
-(def: #export random
- (Random /.Complex)
- (do random.monad
- [real ..dimension
- imaginary ..dimension]
- (wrap (/.complex real imaginary))))
-
-(def: angle
- (Random /.Complex)
- (\ random.monad map
- (|>> (update@ #/.real (f.% +1.0))
- (update@ #/.imaginary (f.% +1.0)))
- ..random))
-
-(def: construction
- Test
- (do random.monad
- [real ..dimension
- imaginary ..dimension]
- ($_ _.and
- (_.cover [/.complex]
- (and (let [r+i (/.complex real imaginary)]
- (and (f.= real (get@ #/.real r+i))
- (f.= imaginary (get@ #/.imaginary r+i))))
- (let [r+i (/.complex real)]
- (and (f.= real (get@ #/.real r+i))
- (f.= +0.0 (get@ #/.imaginary r+i))))))
- (_.cover [/.within?]
- (/.within? ..margin_of_error
- (/.complex real imaginary)
- (/.complex real imaginary)))
- (_.cover [/.not_a_number?]
- (and (/.not_a_number? (/.complex f.not_a_number imaginary))
- (/.not_a_number? (/.complex real f.not_a_number))))
- )))
-
-(def: constant
- Test
- (do random.monad
- [sample ..random
- dimension ..dimension]
- ($_ _.and
- (_.cover [/.zero]
- (/.= /.zero (/.* /.zero sample)))
- (_.cover [/.+one]
- (/.= sample (/.* /.+one sample)))
- (_.cover [/.-one]
- (and (/.= /.zero
- (/.+ sample
- (/.* /.-one sample)))
- (/.= sample (/.* /.-one (/.* /.-one sample)))))
- (_.cover [/.i]
- (and (/.= (/.complex +0.0 dimension)
- (/.* /.i (/.complex dimension)))
- (/.= (/.* /.-one sample)
- (/.* /.i (/.* /.i sample)))))
- )))
-
-(def: absolute_value&argument
- Test
- (do random.monad
- [real ..dimension
- imaginary ..dimension]
- ($_ _.and
- (_.cover [/.abs]
- (let [normal!
- (let [r+i (/.complex real imaginary)]
- (and (f.>= (f.abs real) (/.abs r+i))
- (f.>= (f.abs imaginary) (/.abs r+i))))
-
- not_a_number!
- (and (f.not_a_number? (/.abs (/.complex f.not_a_number imaginary)))
- (f.not_a_number? (/.abs (/.complex real f.not_a_number))))
-
- infinity!
- (and (f.= f.positive_infinity (/.abs (/.complex f.positive_infinity imaginary)))
- (f.= f.positive_infinity (/.abs (/.complex real f.positive_infinity)))
- (f.= f.positive_infinity (/.abs (/.complex f.negative_infinity imaginary)))
- (f.= f.positive_infinity (/.abs (/.complex real f.negative_infinity))))]
- (and normal!
- not_a_number!
- infinity!)))
- ## https://en.wikipedia.org/wiki/Argument_(complex_analysis)#Identities
- (_.cover [/.argument]
- (let [sample (/.complex real imaginary)]
- (or (/.= /.zero sample)
- (/.within? ..margin_of_error
- sample
- (/.*' (/.abs sample)
- (/.exp (/.* /.i (/.complex (/.argument sample)))))))))
- )))
-
-(def: number
- Test
- (do random.monad
- [x ..random
- y ..random
- factor ..dimension]
- ($_ _.and
- (_.cover [/.+]
- (let [z (/.+ y x)]
- (and (/.= z
- (/.complex (f.+ (get@ #/.real y)
- (get@ #/.real x))
- (f.+ (get@ #/.imaginary y)
- (get@ #/.imaginary x)))))))
- (_.cover [/.-]
- (let [normal!
- (let [z (/.- y x)]
- (and (/.= z
- (/.complex (f.- (get@ #/.real y)
- (get@ #/.real x))
- (f.- (get@ #/.imaginary y)
- (get@ #/.imaginary x))))))
-
- inverse!
- (and (|> x (/.+ y) (/.- y) (/.within? ..margin_of_error x))
- (|> x (/.- y) (/.+ y) (/.within? ..margin_of_error x)))]
- (and normal!
- inverse!)))
- (_.cover [/.* /./]
- (|> x (/.* y) (/./ y) (/.within? ..margin_of_error x)))
- (_.cover [/.*' /./']
- (|> x (/.*' factor) (/./' factor) (/.within? ..margin_of_error x)))
- (_.cover [/.%]
- (let [rem (/.% y x)
- quotient (|> x (/.- rem) (/./ y))
- floored (|> quotient
- (update@ #/.real math.floor)
- (update@ #/.imaginary math.floor))]
- (/.within? +0.000000000001
- x
- (|> quotient (/.* y) (/.+ rem)))))
- )))
-
-(def: conjugate&reciprocal&signum&negation
- Test
- (do random.monad
- [x ..random]
- ($_ _.and
- (_.cover [/.conjugate]
- (let [cx (/.conjugate x)]
- (and (f.= (get@ #/.real x)
- (get@ #/.real cx))
- (f.= (f.negate (get@ #/.imaginary x))
- (get@ #/.imaginary cx)))))
- (_.cover [/.reciprocal]
- (let [reciprocal!
- (|> x (/.* (/.reciprocal x)) (/.within? ..margin_of_error /.+one))
-
- own_inverse!
- (|> x /.reciprocal /.reciprocal (/.within? ..margin_of_error x))]
- (and reciprocal!
- own_inverse!)))
- (_.cover [/.signum]
- ## Absolute value of signum is always root/2(2), 1 or 0.
- (let [signum_abs (|> x /.signum /.abs)]
- (or (f.= +0.0 signum_abs)
- (f.= +1.0 signum_abs)
- (f.= (math.pow +0.5 +2.0) signum_abs))))
- (_.cover [/.negate]
- (let [own_inverse!
- (let [there (/.negate x)
- back_again (/.negate there)]
- (and (not (/.= there x))
- (/.= back_again x)))
-
- absolute!
- (f.= (/.abs x)
- (/.abs (/.negate x)))]
- (and own_inverse!
- absolute!)))
- )))
-
-(def: (trigonometric_symmetry forward backward angle)
- (-> (-> /.Complex /.Complex) (-> /.Complex /.Complex) /.Complex Bit)
- (let [normal (|> angle forward backward)]
- (|> normal forward backward (/.within? ..margin_of_error normal))))
-
-(def: trigonometry
- Test
- (do {! random.monad}
- [angle ..angle]
- ($_ _.and
- (_.cover [/.sin /.asin]
- (trigonometric_symmetry /.sin /.asin angle))
- (_.cover [/.cos /.acos]
- (trigonometric_symmetry /.cos /.acos angle))
- (_.cover [/.tan /.atan]
- (trigonometric_symmetry /.tan /.atan angle)))))
-
-(def: hyperbolic
- Test
- (do {! random.monad}
- [angle ..angle]
- ($_ _.and
- (_.cover [/.sinh]
- (/.within? ..margin_of_error
- (|> angle (/.* /.i) /.sin (/.* /.i) (/.* /.-one))
- (/.sinh angle)))
- (_.cover [/.cosh]
- (/.within? ..margin_of_error
- (|> angle (/.* /.i) /.cos)
- (/.cosh angle)))
- (_.cover [/.tanh]
- (/.within? ..margin_of_error
- (|> angle (/.* /.i) /.tan (/.* /.i) (/.* /.-one))
- (/.tanh angle)))
- )))
-
-(def: exponentiation&logarithm
- Test
- (do random.monad
- [x ..random]
- ($_ _.and
- (_.cover [/.pow /.root/2]
- (|> x (/.pow (/.complex +2.0)) /.root/2 (/.within? ..margin_of_error x)))
- (_.cover [/.pow']
- (|> x (/.pow' +2.0) (/.pow' +0.5) (/.within? ..margin_of_error x)))
- (_.cover [/.log /.exp]
- (|> x /.log /.exp (/.within? ..margin_of_error x)))
- )))
-
-(def: root
- Test
- (do {! random.monad}
- [sample ..random
- degree (|> random.nat (\ ! map (|>> (n.max 1) (n.% 5))))]
- (_.cover [/.roots]
- (|> sample
- (/.roots degree)
- (list\map (/.pow' (|> degree .int int.frac)))
- (list.every? (/.within? ..margin_of_error sample))))))
-
-(def: #export test
- Test
- (<| (_.covering /._)
- (_.for [/.Complex])
- ($_ _.and
- (_.for [/.= /.equivalence]
- ($equivalence.spec /.equivalence ..random))
-
- ..construction
- ..constant
- ..absolute_value&argument
- ..number
- ..conjugate&reciprocal&signum&negation
- ..trigonometry
- ..hyperbolic
- ..exponentiation&logarithm
- ..root
- )))
diff --git a/stdlib/source/test/lux/data/number/frac.lux b/stdlib/source/test/lux/data/number/frac.lux
deleted file mode 100644
index dcaa417ed..000000000
--- a/stdlib/source/test/lux/data/number/frac.lux
+++ /dev/null
@@ -1,244 +0,0 @@
-(.module:
- [lux #*
- ["_" test (#+ Test)]
- ["@" target]
- ["." host]
- [abstract
- [monad (#+ do)]
- {[0 #spec]
- [/
- ["$." equivalence]
- ["$." hash]
- ["$." order]
- ["$." monoid]
- ["$." codec]]}]
- [data
- ["." bit ("#\." equivalence)]]
- [math
- ["." random (#+ Random)]]]
- {1
- ["." /
- [// #*
- ["n" nat]
- ["i" int]
- ["r" rev]
- ["." i64]]]})
-
-(def: random
- (Random Frac)
- (\ random.monad map (|>> (i.% +1,000,000) i.frac) random.int))
-
-(def: constant
- Test
- (do random.monad
- [sample random.safe_frac]
- ($_ _.and
- (_.cover [/.biggest]
- (/.<= /.biggest sample))
- (_.cover [/.positive_infinity]
- (/.< /.positive_infinity sample))
- (_.cover [/.smallest]
- (bit\= (/.positive? sample)
- (/.>= /.smallest sample)))
- (_.cover [/.negative_infinity]
- (/.> /.negative_infinity sample))
- (_.cover [/.not_a_number /.not_a_number?]
- (and (/.not_a_number? /.not_a_number)
- (not (or (/.= /.not_a_number sample)
- (/.not_a_number? sample)))))
- )))
-
-(def: predicate
- Test
- (do {! random.monad}
- [sample ..random
- shift (\ ! map /.abs ..random)]
- ($_ _.and
- (_.cover [/.negative?]
- (bit\= (/.negative? sample)
- (/.< +0.0 sample)))
- (_.cover [/.positive?]
- (bit\= (/.positive? sample)
- (/.> +0.0 sample)))
- (_.cover [/.zero?]
- (bit\= (/.zero? sample)
- (/.= +0.0 sample)))
- (_.cover [/.within?]
- (and (/.within? /.smallest sample sample)
- (/.within? (/.+ +1.0 shift) sample (/.+ shift sample))))
- (_.cover [/.number?]
- (and (not (/.number? /.not_a_number))
- (not (/.number? /.positive_infinity))
- (not (/.number? /.negative_infinity))
- (/.number? sample)))
- )))
-
-(def: conversion
- Test
- ($_ _.and
- (do {! random.monad}
- [expected (\ ! map (n.% 1,000,000) random.nat)]
- (_.cover [/.nat]
- (|> expected n.frac /.nat (n.= expected))))
- (do {! random.monad}
- [expected (\ ! map (i.% +1,000,000) random.int)]
- (_.cover [/.int]
- (|> expected i.frac /.int (i.= expected))))
- (do {! random.monad}
- [expected (\ ! map (|>> (i64.left_shift 52) .rev)
- random.nat)]
- (_.cover [/.rev]
- (|> expected r.frac /.rev (r.= expected))))
- ))
-
-(def: signature
- Test
- (`` ($_ _.and
- (_.for [/.equivalence /.=]
- ($equivalence.spec /.equivalence random.safe_frac))
- (_.for [/.hash]
- ($hash.spec /.hash random.frac))
- (_.for [/.order /.<]
- ($order.spec /.order random.safe_frac))
- (~~ (template [<compose> <monoid>]
- [(_.for [<monoid> <compose>]
- ($monoid.spec /.equivalence <monoid> ..random))]
-
- [/.+ /.addition]
- [/.* /.multiplication]
-
- [/.min /.minimum]
- [/.max /.maximum]
- ))
- (~~ (template [<codec>]
- [(_.for [<codec>]
- ($codec.spec /.equivalence <codec> random.safe_frac))]
-
- [/.binary] [/.octal] [/.decimal] [/.hex]
- ))
- )))
-
-(with_expansions [<jvm> (as_is (host.import: java/lang/Double
- ["#::."
- (#static doubleToRawLongBits #manual [double] long)
- (#static longBitsToDouble #manual [long] double)]))]
- (for {@.old (as_is <jvm>)
- @.jvm (as_is <jvm>)}))
-
-(def: #export test
- Test
- (<| (_.covering /._)
- (_.for [.Frac])
- ($_ _.and
- (do random.monad
- [left random.safe_frac
- right random.safe_frac]
- ($_ _.and
- (_.cover [/.>]
- (bit\= (/.> left right)
- (/.< right left)))
- (_.cover [/.<= /.>=]
- (bit\= (/.<= left right)
- (/.>= right left)))
- ))
- (do random.monad
- [sample random.safe_frac]
- ($_ _.and
- (_.cover [/.-]
- (and (/.= +0.0 (/.- sample sample))
- (/.= sample (/.- +0.0 sample))
- (/.= (/.negate sample)
- (/.- sample +0.0))))
- (_.cover [/./]
- (and (/.= +1.0 (/./ sample sample))
- (/.= sample (/./ +1.0 sample))))
- (_.cover [/.abs]
- (bit\= (/.> sample (/.abs sample))
- (/.negative? sample)))
- (_.cover [/.signum]
- (/.= (/.abs sample)
- (/.* (/.signum sample) sample)))
- ))
- (do random.monad
- [left (random.filter (|>> (/.= +0.0) not)
- ..random)
- right ..random]
- ($_ _.and
- (_.cover [/.%]
- (let [rem (/.% left right)
- div (|> right (/.- rem) (/./ left))]
- (/.= right
- (|> div (/.* left) (/.+ rem)))))
- (_.cover [/./%]
- (let [[div rem] (/./% left right)]
- (and (/.= div (/./ left right))
- (/.= rem (/.% left right)))))
- (_.cover [/.mod]
- (and (/.= (/.signum left)
- (/.signum (/.mod left right)))
- (/.= (/.signum right)
- (/.signum (/.% left right)))
- (if (/.= (/.signum left) (/.signum right))
- (/.= (/.% left right)
- (/.mod left right))
- (or (and (/.= +0.0 (/.% left right))
- (/.= +0.0 (/.mod left right)))
- (/.= (/.+ left (/.% left right))
- (/.mod left right))))))
- ))
- (with_expansions [<jvm> ($_ _.and
- (let [test (: (-> Frac Bit)
- (function (_ value)
- (n.= (.nat (java/lang/Double::doubleToRawLongBits value))
- (/.to_bits value))))]
- (do random.monad
- [sample random.frac]
- (_.cover [/.to_bits]
- (and (test sample)
- (test /.biggest)
- (test /.smallest)
- (test /.not_a_number)
- (test /.positive_infinity)
- (test /.negative_infinity)))))
- (do random.monad
- [sample random.i64]
- (_.cover [/.from_bits]
- (let [expected (java/lang/Double::longBitsToDouble sample)
- actual (/.from_bits sample)]
- (or (/.= expected actual)
- (and (/.not_a_number? expected)
- (/.not_a_number? actual))))))
- )]
- (for {@.old <jvm>
- @.jvm <jvm>}
- (let [test (: (-> Frac Bit)
- (function (_ expected)
- (let [actual (|> expected /.to_bits /.from_bits)]
- (or (/.= expected actual)
- (and (/.not_a_number? expected)
- (/.not_a_number? actual))))))]
- (do random.monad
- [sample random.frac]
- (_.cover [/.to_bits /.from_bits]
- (and (test sample)
- (test /.biggest)
- (test /.smallest)
- (test /.not_a_number)
- (test /.positive_infinity)
- (test /.negative_infinity)))))))
- (do random.monad
- [expected random.safe_frac]
- (_.cover [/.negate]
- (let [subtraction!
- (/.= +0.0 (/.+ (/.negate expected) expected))
-
- inverse!
- (|> expected /.negate /.negate (/.= expected))]
- (and subtraction!
- inverse!))))
-
- ..constant
- ..predicate
- ..conversion
- ..signature
- )))
diff --git a/stdlib/source/test/lux/data/number/i16.lux b/stdlib/source/test/lux/data/number/i16.lux
deleted file mode 100644
index 1a5009a03..000000000
--- a/stdlib/source/test/lux/data/number/i16.lux
+++ /dev/null
@@ -1,40 +0,0 @@
-(.module:
- [lux #*
- ["_" test (#+ Test)]
- [abstract
- [monad (#+ do)]
- {[0 #spec]
- [/
- ["$." equivalence]]}]
- [data
- [number
- ["i" int]]]
- [math
- ["." random (#+ Random)]]]
- {1
- ["." /
- ["/#" // #_
- ["#." i64]]]})
-
-(def: #export random
- (Random /.I16)
- (\ random.functor map /.i16 random.i64))
-
-(def: #export test
- Test
- (<| (_.covering /._)
- (_.for [/.I16])
- (do {! random.monad}
- [#let [limit (|> (dec /.width)
- //i64.mask
- .int
- inc)]
- expected (\ ! map (i.% limit) random.int)]
- ($_ _.and
- (_.for [/.equivalence]
- ($equivalence.spec /.equivalence ..random))
-
- (_.cover [/.i16 /.i64 /.width]
- (let [actual (|> expected .i64 /.i16 /.i64)]
- (\ //i64.equivalence = expected actual)))
- ))))
diff --git a/stdlib/source/test/lux/data/number/i32.lux b/stdlib/source/test/lux/data/number/i32.lux
deleted file mode 100644
index fd48509ea..000000000
--- a/stdlib/source/test/lux/data/number/i32.lux
+++ /dev/null
@@ -1,40 +0,0 @@
-(.module:
- [lux #*
- ["_" test (#+ Test)]
- [abstract
- [monad (#+ do)]
- {[0 #spec]
- [/
- ["$." equivalence]]}]
- [data
- [number
- ["i" int]]]
- [math
- ["." random (#+ Random)]]]
- {1
- ["." /
- ["/#" // #_
- ["#." i64]]]})
-
-(def: #export random
- (Random /.I32)
- (\ random.functor map /.i32 random.i64))
-
-(def: #export test
- Test
- (<| (_.covering /._)
- (_.for [/.I32])
- (do {! random.monad}
- [#let [limit (|> (dec /.width)
- //i64.mask
- .int
- inc)]
- expected (\ ! map (i.% limit) random.int)]
- ($_ _.and
- (_.for [/.equivalence]
- ($equivalence.spec /.equivalence ..random))
-
- (_.cover [/.i32 /.i64 /.width]
- (let [actual (|> expected .i64 /.i32 /.i64)]
- (\ //i64.equivalence = expected actual)))
- ))))
diff --git a/stdlib/source/test/lux/data/number/i64.lux b/stdlib/source/test/lux/data/number/i64.lux
deleted file mode 100644
index 45e644ab2..000000000
--- a/stdlib/source/test/lux/data/number/i64.lux
+++ /dev/null
@@ -1,282 +0,0 @@
-(.module:
- [lux #*
- ["_" test (#+ Test)]
- [data
- ["." bit ("#\." equivalence)]
- [number (#+ hex)
- ["n" nat]
- ["i" int]]]
- [abstract
- [monad (#+ do)]
- {[0 #spec]
- [/
- ["$." equivalence]
- ["$." hash]
- ["$." monoid]]}]
- [math
- ["." random (#+ Random)]]]
- {1
- ["." / ("\." equivalence)]})
-
-(def: bit
- Test
- (do {! random.monad}
- [pattern random.nat
- idx (\ ! map (n.% /.width) random.nat)]
- ($_ _.and
- (_.cover [/.set? /.set]
- (if (/.set? idx pattern)
- (\= pattern (/.set idx pattern))
- (not (\= pattern (/.set idx pattern)))))
- (_.cover [/.clear? /.clear]
- (if (/.clear? idx pattern)
- (\= pattern (/.clear idx pattern))
- (not (\= pattern (/.clear idx pattern)))))
- (_.cover [/.flip]
- (\= (/.flip idx pattern)
- (if (/.set? idx pattern)
- (/.clear idx pattern)
- (/.set idx pattern))))
- (_.cover [/.bit]
- (bit\= (/.clear? idx pattern)
- (\= /.false (/.and (/.bit idx) pattern))))
- )))
-
-(def: shift
- Test
- (do {! random.monad}
- [pattern random.nat]
- ($_ _.and
- (do !
- [idx (\ ! map (n.% /.width) random.nat)]
- (_.cover [/.arithmetic_right_shift]
- (let [value (.int pattern)
-
- nullity!
- (\= pattern (/.arithmetic_right_shift 0 pattern))
-
- idempotency!
- (\= value (/.arithmetic_right_shift /.width value))
-
- sign_preservation!
- (bit\= (i.negative? value)
- (i.negative? (/.arithmetic_right_shift idx value)))]
- (and nullity!
- idempotency!
- sign_preservation!))))
- (do !
- [idx (\ ! map (|>> (n.% (dec /.width)) inc) random.nat)]
- (_.cover [/.left_shift /.logic_right_shift]
- (let [nullity!
- (and (\= pattern (/.left_shift 0 pattern))
- (\= pattern (/.logic_right_shift 0 pattern)))
-
- idempotency!
- (and (\= pattern (/.left_shift /.width pattern))
- (\= pattern (/.logic_right_shift /.width pattern)))
-
- movement!
- (let [shift (n.- idx /.width)]
- (\= (/.and (/.mask idx) pattern)
- (|> pattern
- (/.left_shift shift)
- (/.logic_right_shift shift))))]
- (and nullity!
- idempotency!
- movement!))))
- )))
-
-(def: mask
- Test
- (<| (_.for [/.Mask])
- (do {! random.monad}
- [pattern random.nat
- idx (\ ! map (n.% /.width) random.nat)
- signed random.int]
- ($_ _.and
- (_.cover [/.sign]
- (bit\= (\= (.i64 0) (/.and /.sign signed))
- (i.positive? signed)))
- (_.cover [/.mask]
- (let [mask (/.mask idx)
- idempotency! (\= (/.and mask pattern)
- (/.and mask (/.and mask pattern)))
-
- limit (inc (.nat mask))
- limit! (if (n.< limit pattern)
- (\= pattern (/.and mask pattern))
- (n.< limit (/.and mask pattern)))
-
- empty! (\= /.false (/.mask 0))
- full! (\= /.true (/.mask /.width))]
- (and idempotency!
- limit!
-
- empty!
- full!)))
- (do !
- [size (\ ! map (n.% /.width) random.nat)
- #let [spare (n.- size /.width)]
- offset (\ ! map (n.% spare) random.nat)]
- (_.cover [/.region]
- (case size
- 0 (\= /.false (/.region size offset))
- _ (\= (|> pattern
- ## NNNNYYYYNNNN
- (/.logic_right_shift offset)
- ## ____NNNNYYYY
- (/.left_shift spare)
- ## YYYY________
- (/.logic_right_shift spare)
- ## ________YYYY
- (/.left_shift offset)
- ## ____YYYY____
- )
- (/.and (/.region size offset) pattern)))))
- ))))
-
-(def: sub
- Test
- (_.for [/.Sub]
- (do {! random.monad}
- [size (\ ! map (n.% /.width) random.nat)]
- (case (/.sub size)
- #.None
- (_.cover [/.sub]
- (n.= 0 size))
-
- (#.Some sub)
- (do {! random.monad}
- [#let [limit (|> (dec (\ sub width))
- /.mask
- .int
- inc)]
- expected (\ ! map (i.% limit) random.int)
- #let [random (: (All [size]
- (-> (-> I64 (I64 size)) (Random (I64 size))))
- (function (_ narrow)
- (\ random.functor map narrow random.i64)))]]
- ($_ _.and
- ($equivalence.spec (\ sub &equivalence) (random (\ sub narrow)))
- (_.cover [/.sub]
- (let [actual (|> expected .i64 (\ sub narrow) (\ sub widen))]
- (\= expected actual)))
- ))))))
-
-(def: signature
- Test
- ($_ _.and
- (_.for [/.equivalence]
- ($equivalence.spec /.equivalence random.i64))
- (_.for [/.hash]
- ($hash.spec /.hash random.i64))
- (_.for [/.disjunction]
- ($monoid.spec n.equivalence /.disjunction random.nat))
- (_.for [/.conjunction]
- ($monoid.spec n.equivalence /.conjunction random.nat))
- ))
-
-(def: #export test
- Test
- (<| (_.covering /._)
- (_.for [.I64])
- (do {! random.monad}
- [pattern random.nat
- idx (\ ! map (n.% /.width) random.nat)]
- ($_ _.and
- (_.cover [/.width /.bits_per_byte /.bytes_per_i64]
- (and (n.= /.bytes_per_i64
- (n./ /.bits_per_byte /.width))
- (n.= /.bits_per_byte
- (n./ /.bytes_per_i64 /.width))))
- (_.cover [/.false]
- (n.= 0 (/.count /.false)))
- (_.cover [/.or]
- (and (\= /.true (/.or /.true pattern))
- (\= pattern (/.or /.false pattern))))
- (_.cover [/.true]
- (n.= /.width (/.count /.true)))
- (_.cover [/.and]
- (and (\= pattern (/.and /.true pattern))
- (\= /.false (/.and /.false pattern))))
- (_.cover [/.not]
- (and (\= /.false
- (/.and pattern
- (/.not pattern)))
- (\= /.true
- (/.or pattern
- (/.not pattern)))))
- (_.cover [/.xor]
- (and (\= /.true
- (/.xor pattern
- (/.not pattern)))
- (\= /.false
- (/.xor pattern
- pattern))))
- (_.cover [/.count]
- (let [clear&set!
- (if (/.set? idx pattern)
- (n.= (dec (/.count pattern)) (/.count (/.clear idx pattern)))
- (n.= (inc (/.count pattern)) (/.count (/.set idx pattern))))
-
- complementarity!
- (n.= /.width
- (n.+ (/.count pattern)
- (/.count (/.not pattern))))]
- (and clear&set!
- complementarity!)))
- (_.cover [/.rotate_left /.rotate_right]
- (let [false!
- (and (\= /.false (/.rotate_left idx /.false))
- (\= /.false (/.rotate_right idx /.false)))
-
- true!
- (and (\= /.true (/.rotate_left idx /.true))
- (\= /.true (/.rotate_right idx /.true)))
-
- inverse!
- (and (|> pattern
- (/.rotate_left idx)
- (/.rotate_right idx)
- (\= pattern))
- (|> pattern
- (/.rotate_right idx)
- (/.rotate_left idx)
- (\= pattern)))
-
- nullity!
- (and (|> pattern
- (/.rotate_left 0)
- (\= pattern))
- (|> pattern
- (/.rotate_right 0)
- (\= pattern)))
-
- futility!
- (and (|> pattern
- (/.rotate_left /.width)
- (\= pattern))
- (|> pattern
- (/.rotate_right /.width)
- (\= pattern)))]
- (and false!
- true!
- inverse!
- nullity!
- futility!)))
- (_.cover [/.reverse]
- (and (|> pattern /.reverse /.reverse (\= pattern))
- (or (|> pattern /.reverse (\= pattern) not)
- (let [high (/.and (hex "FFFFFFFF00000000")
- pattern)
- low (/.and (hex "00000000FFFFFFFF")
- pattern)]
- (\= (/.reverse high)
- low)))))
-
- ..bit
- ..shift
- ..mask
- ..sub
- ..signature
- ))))
diff --git a/stdlib/source/test/lux/data/number/i8.lux b/stdlib/source/test/lux/data/number/i8.lux
deleted file mode 100644
index 49b6995e8..000000000
--- a/stdlib/source/test/lux/data/number/i8.lux
+++ /dev/null
@@ -1,40 +0,0 @@
-(.module:
- [lux #*
- ["_" test (#+ Test)]
- [abstract
- [monad (#+ do)]
- {[0 #spec]
- [/
- ["$." equivalence]]}]
- [data
- [number
- ["i" int]]]
- [math
- ["." random (#+ Random)]]]
- {1
- ["." /
- ["/#" // #_
- ["#." i64]]]})
-
-(def: #export random
- (Random /.I8)
- (\ random.functor map /.i8 random.i64))
-
-(def: #export test
- Test
- (<| (_.covering /._)
- (_.for [/.I8])
- (do {! random.monad}
- [#let [limit (|> (dec /.width)
- //i64.mask
- .int
- inc)]
- expected (\ ! map (i.% limit) random.int)]
- ($_ _.and
- (_.for [/.equivalence]
- ($equivalence.spec /.equivalence ..random))
-
- (_.cover [/.i8 /.i64 /.width]
- (let [actual (|> expected .i64 /.i8 /.i64)]
- (\ //i64.equivalence = expected actual)))
- ))))
diff --git a/stdlib/source/test/lux/data/number/int.lux b/stdlib/source/test/lux/data/number/int.lux
deleted file mode 100644
index 24155602b..000000000
--- a/stdlib/source/test/lux/data/number/int.lux
+++ /dev/null
@@ -1,184 +0,0 @@
-(.module:
- [lux #*
- ["_" test (#+ Test)]
- [abstract
- [monad (#+ do)]
- {[0 #spec]
- [/
- ["$." equivalence]
- ["$." hash]
- ["$." order]
- ["$." enum]
- ["$." interval]
- ["$." monoid]
- ["$." codec]]}]
- [data
- ["." bit ("#\." equivalence)]
- [number
- ["f" frac]]]
- [math
- ["." random (#+ Random)]]]
- {1
- ["." /]})
-
-(def: signature
- Test
- (`` ($_ _.and
- (_.for [/.equivalence /.=]
- ($equivalence.spec /.equivalence random.int))
- (_.for [/.hash]
- ($hash.spec /.hash random.int))
- (_.for [/.order /.<]
- ($order.spec /.order random.int))
- (_.for [/.enum]
- ($enum.spec /.enum random.int))
- (_.for [/.interval]
- ($interval.spec /.interval random.int))
- (~~ (template [<compose> <monoid>]
- [(_.for [<monoid> <compose>]
- ($monoid.spec /.equivalence <monoid> random.int))]
-
- [/.+ /.addition]
- [/.* /.multiplication]
-
- [/.min /.minimum]
- [/.max /.maximum]
- ))
- (~~ (template [<codec>]
- [(_.for [<codec>]
- ($codec.spec /.equivalence <codec> random.int))]
-
- [/.binary] [/.octal] [/.decimal] [/.hex]
- ))
- )))
-
-(def: predicate
- Test
- (do {! random.monad}
- [sample random.int]
- ($_ _.and
- (_.cover [/.negative?]
- (bit\= (/.negative? sample)
- (/.< +0 sample)))
- (_.cover [/.positive?]
- (bit\= (/.positive? sample)
- (/.> +0 sample)))
- (_.cover [/.zero?]
- (bit\= (/.zero? sample)
- (/.= +0 sample)))
- (_.cover [/.even? /.odd?]
- (bit\= (/.even? sample)
- (not (/.odd? sample))))
- )))
-
-(def: #export test
- Test
- (<| (_.covering /._)
- (_.for [.Int])
- ($_ _.and
- (do random.monad
- [sample random.int]
- ($_ _.and
- (_.cover [/.-]
- (and (/.= +0 (/.- sample sample))
- (/.= sample (/.- +0 sample))
- (/.= (/.negate sample)
- (/.- sample +0))))
- (_.cover [/./]
- (and (/.= +1 (/./ sample sample))
- (/.= sample (/./ +1 sample))))
- (_.cover [/.abs]
- (bit\= (/.> sample (/.abs sample))
- (/.negative? sample)))
- (_.cover [/.signum]
- (/.= (/.abs sample)
- (/.* (/.signum sample) sample)))
- ))
- (do random.monad
- [left random.int
- right random.int]
- ($_ _.and
- (_.cover [/.>]
- (bit\= (/.> left right)
- (/.< right left)))
- (_.cover [/.<= /.>=]
- (bit\= (/.<= left right)
- (/.>= right left)))
- ))
- (do random.monad
- [left (random.filter (|>> (/.= +0) not)
- random.int)
- right random.int]
- ($_ _.and
- (_.cover [/.%]
- (let [rem (/.% left right)
- div (|> right (/.- rem) (/./ left))]
- (/.= right
- (|> div (/.* left) (/.+ rem)))))
- (_.cover [/./%]
- (let [[div rem] (/./% left right)]
- (and (/.= div (/./ left right))
- (/.= rem (/.% left right)))))
- (_.cover [/.mod]
- (and (/.= (/.signum left)
- (/.signum (/.mod left right)))
- (/.= (/.signum right)
- (/.signum (/.% left right)))
- (if (/.= (/.signum left) (/.signum right))
- (/.= (/.% left right)
- (/.mod left right))
- (or (and (/.= +0 (/.% left right))
- (/.= +0 (/.mod left right)))
- (/.= (/.+ left (/.% left right))
- (/.mod left right))))))
- ))
- (do {! random.monad}
- [#let [random (|> random.int
- (\ ! map (/.% +1,000))
- (random.filter (|>> (/.= +0) not)))]
- left random
- right random]
- ($_ _.and
- (_.cover [/.gcd]
- (let [gcd (/.gcd left right)]
- (and (/.= +0 (/.% gcd left))
- (/.= +0 (/.% gcd right)))))
- (_.cover [/.extended_gcd]
- (let [[[left_k right_k] gcd] (/.extended_gcd left right)
-
- same_gcd!
- (/.= gcd
- (/.gcd left right))
-
- bezout_identity!
- (/.= gcd
- (/.+ (/.* left_k left)
- (/.* right_k right)))]
- (and same_gcd!
- bezout_identity!)))
- (_.cover [/.co-prime?]
- (bit\= (/.= +1 (/.gcd left right))
- (/.co-prime? left right)))
- (_.cover [/.lcm]
- (let [lcm (/.lcm left right)]
- (and (/.= +0 (/.% left lcm))
- (/.= +0 (/.% right lcm)))))
- ))
- (do random.monad
- [expected random.int]
- (_.cover [/.negate]
- (let [subtraction!
- (/.= +0 (/.+ (/.negate expected) expected))
-
- inverse!
- (|> expected /.negate /.negate (/.= expected))]
- (and subtraction!
- inverse!))))
- (do {! random.monad}
- [expected (\ ! map (/.% +1,000,000) random.int)]
- (_.cover [/.frac]
- (|> expected /.frac f.int (/.= expected))))
-
- ..predicate
- ..signature
- )))
diff --git a/stdlib/source/test/lux/data/number/nat.lux b/stdlib/source/test/lux/data/number/nat.lux
deleted file mode 100644
index a2d0fd655..000000000
--- a/stdlib/source/test/lux/data/number/nat.lux
+++ /dev/null
@@ -1,130 +0,0 @@
-(.module:
- [lux #*
- ["_" test (#+ Test)]
- [abstract
- [monad (#+ do)]
- {[0 #spec]
- [/
- ["$." equivalence]
- ["$." hash]
- ["$." order]
- ["$." enum]
- ["$." interval]
- ["$." monoid]
- ["$." codec]]}]
- [data
- ["." bit ("#\." equivalence)]
- [number
- ["f" frac]]]
- [math
- ["." random]]]
- {1
- ["." /]})
-
-(def: signature
- Test
- (`` ($_ _.and
- (_.for [/.equivalence /.=]
- ($equivalence.spec /.equivalence random.nat))
- (_.for [/.hash]
- ($hash.spec /.hash random.nat))
- (_.for [/.order /.<]
- ($order.spec /.order random.nat))
- (_.for [/.enum]
- ($enum.spec /.enum random.nat))
- (_.for [/.interval]
- ($interval.spec /.interval random.nat))
- (~~ (template [<compose> <monoid>]
- [(_.for [<monoid> <compose>]
- ($monoid.spec /.equivalence <monoid> random.nat))]
-
- [/.+ /.addition]
- [/.* /.multiplication]
-
- [/.min /.minimum]
- [/.max /.maximum]
- ))
- (~~ (template [<codec>]
- [(_.for [<codec>]
- ($codec.spec /.equivalence <codec> random.nat))]
-
- [/.binary] [/.octal] [/.decimal] [/.hex]
- ))
- )))
-
-(def: predicate
- Test
- (do {! random.monad}
- [sample random.nat]
- ($_ _.and
- (_.cover [/.even? /.odd?]
- (bit\= (/.even? sample)
- (not (/.odd? sample))))
- )))
-
-(def: #export test
- Test
- (<| (_.covering /._)
- (_.for [.Nat])
- ($_ _.and
- (do random.monad
- [sample random.nat]
- ($_ _.and
- (_.cover [/.-]
- (and (/.= 0 (/.- sample sample))
- (/.= sample (/.- 0 sample))))
- (_.cover [/./]
- (and (/.= 1 (/./ sample sample))
- (/.= sample (/./ 1 sample))))
- ))
- (do random.monad
- [left random.nat
- right random.nat]
- ($_ _.and
- (_.cover [/.>]
- (bit\= (/.> left right)
- (/.< right left)))
- (_.cover [/.<= /.>=]
- (bit\= (/.<= left right)
- (/.>= right left)))
- ))
- (do random.monad
- [left (random.filter (|>> (/.= 0) not)
- random.nat)
- right random.nat]
- ($_ _.and
- (_.cover [/.%]
- (let [rem (/.% left right)
- div (|> right (/.- rem) (/./ left))]
- (/.= right
- (|> div (/.* left) (/.+ rem)))))
- (_.cover [/./%]
- (let [[div rem] (/./% left right)]
- (and (/.= div (/./ left right))
- (/.= rem (/.% left right)))))
- ))
- (do {! random.monad}
- [#let [random (\ ! map (|>> (/.% 1,000) inc) random.nat)]
- left random
- right random]
- ($_ _.and
- (_.cover [/.gcd]
- (let [gcd (/.gcd left right)]
- (and (/.= 0 (/.% gcd left))
- (/.= 0 (/.% gcd right)))))
- (_.cover [/.co-prime?]
- (bit\= (/.= 1 (/.gcd left right))
- (/.co-prime? left right)))
- (_.cover [/.lcm]
- (let [lcm (/.lcm left right)]
- (and (/.= 0 (/.% left lcm))
- (/.= 0 (/.% right lcm)))))
- ))
- (do {! random.monad}
- [expected (\ ! map (/.% 1,000,000) random.nat)]
- (_.cover [/.frac]
- (|> expected /.frac f.nat (/.= expected))))
-
- ..predicate
- ..signature
- )))
diff --git a/stdlib/source/test/lux/data/number/ratio.lux b/stdlib/source/test/lux/data/number/ratio.lux
deleted file mode 100644
index 1e8da2e78..000000000
--- a/stdlib/source/test/lux/data/number/ratio.lux
+++ /dev/null
@@ -1,114 +0,0 @@
-(.module:
- [lux #*
- ["_" test (#+ Test)]
- [abstract
- [monad (#+ do)]
- {[0 #spec]
- [/
- ["$." equivalence]
- ["$." order]
- ["$." monoid]
- ["$." codec]]}]
- [data
- ["." bit ("#\." equivalence)]
- ["." maybe ("#\." functor)]
- [number
- ["n" nat ("#\." equivalence)]]]
- [math
- ["." random (#+ Random)]]]
- {1
- ["." /]})
-
-(def: part
- (Random Nat)
- (\ random.monad map
- (|>> (n.% 1,000,000) (n.max 1))
- random.nat))
-
-(def: #export random
- (Random /.Ratio)
- (do random.monad
- [numerator ..part
- denominator (random.filter (|>> (n.= 0) not)
- ..part)]
- (wrap (/.ratio numerator denominator))))
-
-(def: #export test
- Test
- (<| (_.covering /._)
- (_.for [/.Ratio])
- (`` ($_ _.and
- (_.for [/.equivalence /.=]
- ($equivalence.spec /.equivalence ..random))
- (_.for [/.order /.<]
- ($order.spec /.order ..random))
- (~~ (template [<compose> <monoid>]
- [(_.for [<monoid> <compose>]
- ($monoid.spec /.equivalence <monoid> ..random))]
-
- [/.+ /.addition]
- [/.* /.multiplication]
- ))
- (_.for [/.codec]
- ($codec.spec /.equivalence /.codec ..random))
-
- (do random.monad
- [#let [(^open "\.") /.equivalence]
- denom/0 ..part
- denom/1 ..part]
- (_.cover [/.ratio]
- (\= (/.ratio 0 denom/0)
- (/.ratio 0 denom/1))))
- (do random.monad
- [numerator ..part
- denominator (random.filter (|>> (n\= 1) not)
- ..part)]
- (_.cover [/.nat]
- (and (|> (/.ratio numerator)
- /.nat
- (maybe\map (n\= numerator))
- (maybe.default false))
- (|> (/.ratio numerator 1)
- /.nat
- (maybe\map (n\= numerator))
- (maybe.default false))
- (case (/.nat (/.ratio numerator denominator))
- #.None true
- (#.Some _) false))))
- (do random.monad
- [sample ..random]
- ($_ _.and
- (_.cover [/.-]
- (and (/.= (/.ratio 0) (/.- sample sample))
- (/.= sample (/.- (/.ratio 0) sample))))
- (_.cover [/./]
- (and (/.= (/.ratio 1) (/./ sample sample))
- (/.= sample (/./ (/.ratio 1) sample))))
- (_.cover [/.reciprocal]
- (/.= (/.ratio 1)
- (/.* sample (/.reciprocal sample))))
- ))
- (do random.monad
- [left (random.filter (|>> (/.= (/.ratio 0)) not)
- ..random)
- right ..random]
- (_.cover [/.%]
- (let [rem (/.% left right)
- div (|> right (/.- rem) (/./ left))]
- (and (/.= right
- (|> div (/.* left) (/.+ rem)))
- (case (/.nat div)
- (#.Some _) true
- #.None false)))))
- (do random.monad
- [left ..random
- right ..random]
- ($_ _.and
- (_.cover [/.>]
- (bit\= (/.> left right)
- (/.< right left)))
- (_.cover [/.<= /.>=]
- (bit\= (/.<= left right)
- (/.>= right left)))
- ))
- ))))
diff --git a/stdlib/source/test/lux/data/number/rev.lux b/stdlib/source/test/lux/data/number/rev.lux
deleted file mode 100644
index 2e75eb874..000000000
--- a/stdlib/source/test/lux/data/number/rev.lux
+++ /dev/null
@@ -1,164 +0,0 @@
-(.module:
- [lux #*
- ["_" test (#+ Test)]
- [abstract
- [monad (#+ do)]
- {[0 #spec]
- [/
- ["$." equivalence]
- ["$." hash]
- ["$." order]
- ["$." enum]
- ["$." interval]
- ["$." monoid]
- ["$." codec]]}]
- [data
- ["." bit ("#\." equivalence)]
- [number (#+ hex)
- ["n" nat]
- ["f" frac]
- ["." i64 ("#\." hash)]]]
- [math
- ["." random]]]
- {1
- ["." /]})
-
-(def: signature
- Test
- (`` ($_ _.and
- (_.for [/.equivalence /.=]
- ($equivalence.spec /.equivalence random.rev))
- (_.for [/.hash]
- ($hash.spec /.hash random.rev))
- (_.for [/.order /.<]
- ($order.spec /.order random.rev))
- (_.for [/.enum]
- ($enum.spec /.enum random.rev))
- (_.for [/.interval]
- ($interval.spec /.interval random.rev))
- (~~ (template [<compose> <monoid>]
- [(_.for [<monoid> <compose>]
- ($monoid.spec /.equivalence <monoid> random.rev))]
-
- [/.+ /.addition]
-
- [/.min /.minimum]
- [/.max /.maximum]
- ))
- (~~ (template [<codec>]
- [(_.for [<codec>]
- ($codec.spec /.equivalence <codec> random.rev))]
-
- [/.binary] [/.octal] [/.decimal] [/.hex]
- ))
- )))
-
-(def: #export test
- Test
- (<| (_.covering /._)
- (_.for [.Rev])
- (`` ($_ _.and
- (~~ (template [<half> <whole>]
- [(_.cover [<half>]
- (/.= <whole>
- (/.+ <half> <half>)))]
-
- [/./2 .0]
- [/./4 /./2]
- [/./8 /./4]
- [/./16 /./8]
- [/./32 /./16]
- [/./64 /./32]
- [/./128 /./64]
- [/./256 /./128]
- [/./512 /./256]
- [/./1024 /./512]
- [/./2048 /./1024]
- [/./4096 /./2048]
- ))
- (do random.monad
- [sample random.rev]
- (_.cover [/.-]
- (and (/.= .0 (/.- sample sample))
- (/.= sample (/.- .0 sample)))))
- (do {! random.monad}
- [left random.rev
- right random.rev]
- (_.cover [/.*]
- (and (/.< left (/.* left right))
- (/.< right (/.* left right)))))
- (do {! random.monad}
- [#let [dividend (\ ! map (i64.and (hex "FFFF"))
- random.rev)
- divisor (\ ! map (|>> (i64.and (hex "F"))
- (i64.or (hex "1"))
- (i64.rotate_right 8)
- .rev)
- random.nat)]
- dividend (random.filter (/.> .0) dividend)
- divisor/0 divisor
- divisor/1 (random.filter (|>> (/.= divisor/0) not)
- divisor)
- scale (\ ! map (|>> (n.% 10) inc)
- random.nat)]
- ($_ _.and
- (_.cover [/./]
- (bit\= (/.< divisor/0 divisor/1)
- (/.> (/./ divisor/0 dividend) (/./ divisor/1 dividend))))
- (_.cover [/.%]
- (\ i64.equivalence =
- (.i64 (n.% (.nat divisor/0) (.nat dividend)))
- (.i64 (/.% divisor/0 dividend))))
- (_.cover [/.up /.down]
- (let [symmetry!
- (|> dividend
- (/.up scale)
- (/.down scale)
- (/.= dividend))
-
- discrete_division!
- (/.= (/.% (.rev scale) dividend)
- (/.- (|> dividend
- (/.down scale)
- (/.up scale))
- dividend))]
- (and symmetry!
- discrete_division!)))
- (_.cover [/.ratio]
- (|> dividend
- (/.up scale)
- (/.ratio dividend)
- (n.= scale)))
- ))
- (do {! random.monad}
- [dividend random.rev
- divisor (random.filter (|>> (/.= .0) not)
- random.rev)]
- (_.cover [/./%]
- (let [[quotient remainder] (/./% divisor dividend)]
- (and (/.= (/./ divisor dividend) quotient)
- (/.= (/.% divisor dividend) remainder)))))
- (do random.monad
- [left random.rev
- right random.rev]
- ($_ _.and
- (_.cover [/.>]
- (bit\= (/.> left right)
- (/.< right left)))
- (_.cover [/.<= /.>=]
- (bit\= (/.<= left right)
- (/.>= right left)))
- ))
- (do random.monad
- [sample random.nat]
- (_.cover [/.reciprocal]
- (/.= (/.reciprocal sample)
- (|> sample /.reciprocal .nat /.reciprocal .nat /.reciprocal))))
- (do {! random.monad}
- [expected (\ ! map (|>> f.abs (f.% +1.0))
- random.safe_frac)]
- (_.cover [/.frac]
- (|> expected f.rev /.frac (f.= expected))))
-
- ..signature
- ))))
diff --git a/stdlib/source/test/lux/data/product.lux b/stdlib/source/test/lux/data/product.lux
index 3c61091bb..c33e60dd1 100644
--- a/stdlib/source/test/lux/data/product.lux
+++ b/stdlib/source/test/lux/data/product.lux
@@ -6,12 +6,11 @@
{[0 #spec]
[/
["$." equivalence]]}]
- [data
+ [math
+ ["." random]
[number
["n" nat]
- ["i" int]]]
- [math
- ["." random]]]
+ ["i" int]]]]
{1
["." /]})
diff --git a/stdlib/source/test/lux/data/sum.lux b/stdlib/source/test/lux/data/sum.lux
index 7fbf816a1..da108ede8 100644
--- a/stdlib/source/test/lux/data/sum.lux
+++ b/stdlib/source/test/lux/data/sum.lux
@@ -10,13 +10,13 @@
pipe]
[data
["." text]
- [number
- ["n" nat]
- ["i" int]]
[collection
["." list ("#\." functor)]]]
[math
- ["." random]]]
+ ["." random]
+ [number
+ ["n" nat]
+ ["i" int]]]]
{1
["." /]})
diff --git a/stdlib/source/test/lux/data/text.lux b/stdlib/source/test/lux/data/text.lux
index 4100d5f0d..4308f8e95 100644
--- a/stdlib/source/test/lux/data/text.lux
+++ b/stdlib/source/test/lux/data/text.lux
@@ -12,13 +12,13 @@
pipe]
[data
["." maybe]
- [number
- ["n" nat]]
[collection
["." list]
["." set]]]
[math
- ["." random]]]
+ ["." random]
+ [number
+ ["n" nat]]]]
["." / #_
["#." buffer]
["#." encoding]
diff --git a/stdlib/source/test/lux/data/text/buffer.lux b/stdlib/source/test/lux/data/text/buffer.lux
index a12d57fc5..852a3c951 100644
--- a/stdlib/source/test/lux/data/text/buffer.lux
+++ b/stdlib/source/test/lux/data/text/buffer.lux
@@ -5,11 +5,11 @@
[monad (#+ do)]]
[data
["." text ("#\." equivalence)
- ["%" format (#+ format)]]
- [number
- ["n" nat]]]
+ ["%" format (#+ format)]]]
[math
- ["." random (#+ Random)]]]
+ ["." random (#+ Random)]
+ [number
+ ["n" nat]]]]
{1
["." /]})
diff --git a/stdlib/source/test/lux/data/text/encoding.lux b/stdlib/source/test/lux/data/text/encoding.lux
index 2e61159dc..c5b985f50 100644
--- a/stdlib/source/test/lux/data/text/encoding.lux
+++ b/stdlib/source/test/lux/data/text/encoding.lux
@@ -11,15 +11,15 @@
[data
["." maybe]
["." text ("#\." equivalence)]
- [number
- ["n" nat]]
[collection
["." list ("#\." functor)]
["." set]]]
[macro
["." template]]
[math
- ["." random (#+ Random)]]]
+ ["." random (#+ Random)]
+ [number
+ ["n" nat]]]]
{1
["." /]})
diff --git a/stdlib/source/test/lux/data/text/format.lux b/stdlib/source/test/lux/data/text/format.lux
index 00df7058a..2aa33d2d4 100644
--- a/stdlib/source/test/lux/data/text/format.lux
+++ b/stdlib/source/test/lux/data/text/format.lux
@@ -14,12 +14,6 @@
["." text ("#\." equivalence)]
["." bit]
["." name]
- [number
- ["." nat]
- ["." int]
- ["." rev]
- ["." frac]
- ["." ratio]]
[format
["." xml]
["." json]]
@@ -32,7 +26,13 @@
[math
["." random (#+ Random) ("#\." monad)]
["." modulus]
- ["." modular]]
+ ["." modular]
+ [number
+ ["." nat]
+ ["." int]
+ ["." rev]
+ ["." frac]
+ ["." ratio]]]
[macro
["." code]]
[meta
diff --git a/stdlib/source/test/lux/data/text/regex.lux b/stdlib/source/test/lux/data/text/regex.lux
index 3998f78f7..2cdead181 100644
--- a/stdlib/source/test/lux/data/text/regex.lux
+++ b/stdlib/source/test/lux/data/text/regex.lux
@@ -10,10 +10,10 @@
["<.>" text (#+ Parser)]
["s" code]]]
[data
- [number (#+ hex)]
["." text ("#\." equivalence)
["%" format (#+ format)]]]
[math
+ [number (#+ hex)]
["." random]]
["." meta]
[macro
@@ -53,13 +53,13 @@
(syntax: (should_check pattern regex input)
(meta.with_gensyms [g!message g!_]
- (wrap (list (` (|> (~ input)
- (<text>.run (~ regex))
- (case> (^ (#try.Success (~ pattern)))
- true
+ (wrap (list (` (|> (~ input)
+ (<text>.run (~ regex))
+ (case> (^ (#try.Success (~ pattern)))
+ true
- (~ g!_)
- false)))))))
+ (~ g!_)
+ false)))))))
(def: basics
Test
diff --git a/stdlib/source/test/lux/data/text/unicode/block.lux b/stdlib/source/test/lux/data/text/unicode/block.lux
index a575b4fc6..316bbe516 100644
--- a/stdlib/source/test/lux/data/text/unicode/block.lux
+++ b/stdlib/source/test/lux/data/text/unicode/block.lux
@@ -10,15 +10,15 @@
["$." monoid]]}]
[data
["." text]
- [number (#+ hex)
- ["n" nat]]
[collection
["." set]
["." list]]]
[macro
["." template]]
[math
- ["." random (#+ Random)]]]
+ ["." random (#+ Random)]
+ [number (#+ hex)
+ ["n" nat]]]]
{1
["." /]})
diff --git a/stdlib/source/test/lux/data/text/unicode/set.lux b/stdlib/source/test/lux/data/text/unicode/set.lux
index e32c08bfd..a219bff51 100644
--- a/stdlib/source/test/lux/data/text/unicode/set.lux
+++ b/stdlib/source/test/lux/data/text/unicode/set.lux
@@ -9,12 +9,12 @@
[data
["." product]
["." bit ("#\." equivalence)]
- [number
- ["n" nat]]
[collection
["." set ("#\." equivalence)]]]
[math
- ["." random (#+ Random)]]]
+ ["." random (#+ Random)]
+ [number
+ ["n" nat]]]]
["." / #_
["/#" // #_
["#." block]]]