From 832a9361b632331e82a64c07baa560487ca8abde Mon Sep 17 00:00:00 2001 From: Eduardo Julian Date: Tue, 29 Dec 2020 00:38:21 -0400 Subject: Moved "lux/data/number" to "lux/math/number". --- stdlib/source/test/aedifex/artifact/extension.lux | 6 +- stdlib/source/test/aedifex/artifact/type.lux | 6 +- stdlib/source/test/aedifex/cache.lux | 6 +- stdlib/source/test/aedifex/command/auto.lux | 6 +- stdlib/source/test/aedifex/command/clean.lux | 6 +- stdlib/source/test/aedifex/command/deploy.lux | 11 +- stdlib/source/test/aedifex/hash.lux | 6 +- stdlib/source/test/aedifex/metadata/artifact.lux | 2 +- stdlib/source/test/aedifex/metadata/snapshot.lux | 2 +- stdlib/source/test/aedifex/package.lux | 6 +- stdlib/source/test/aedifex/parser.lux | 6 +- stdlib/source/test/aedifex/profile.lux | 11 +- stdlib/source/test/aedifex/project.lux | 8 +- stdlib/source/test/lux/abstract/apply.lux | 6 +- stdlib/source/test/lux/abstract/comonad.lux | 6 +- stdlib/source/test/lux/abstract/enum.lux | 6 +- stdlib/source/test/lux/abstract/equivalence.lux | 8 +- stdlib/source/test/lux/abstract/fold.lux | 6 +- stdlib/source/test/lux/abstract/functor.lux | 6 +- stdlib/source/test/lux/abstract/interval.lux | 6 +- stdlib/source/test/lux/abstract/monad.lux | 8 +- stdlib/source/test/lux/abstract/monoid.lux | 7 +- stdlib/source/test/lux/abstract/order.lux | 8 +- stdlib/source/test/lux/abstract/predicate.lux | 6 +- stdlib/source/test/lux/control/concatenative.lux | 14 +- .../source/test/lux/control/concurrency/actor.lux | 6 +- .../source/test/lux/control/concurrency/atom.lux | 7 +- stdlib/source/test/lux/control/concurrency/frp.lux | 8 +- .../test/lux/control/concurrency/promise.lux | 9 +- .../test/lux/control/concurrency/semaphore.lux | 10 +- stdlib/source/test/lux/control/concurrency/stm.lux | 6 +- .../source/test/lux/control/concurrency/thread.lux | 9 +- stdlib/source/test/lux/control/continuation.lux | 6 +- stdlib/source/test/lux/control/exception.lux | 8 +- stdlib/source/test/lux/control/function.lux | 8 +- .../source/test/lux/control/function/contract.lux | 3 +- stdlib/source/test/lux/control/function/memo.lux | 12 +- stdlib/source/test/lux/control/function/mixin.lux | 6 +- stdlib/source/test/lux/control/io.lux | 5 +- stdlib/source/test/lux/control/parser.lux | 10 +- stdlib/source/test/lux/control/parser/analysis.lux | 10 +- stdlib/source/test/lux/control/parser/binary.lux | 16 +- stdlib/source/test/lux/control/parser/cli.lux | 6 +- stdlib/source/test/lux/control/parser/code.lux | 12 +- .../source/test/lux/control/parser/environment.lux | 6 +- stdlib/source/test/lux/control/parser/json.lux | 8 +- .../source/test/lux/control/parser/synthesis.lux | 16 +- stdlib/source/test/lux/control/parser/text.lux | 6 +- stdlib/source/test/lux/control/parser/tree.lux | 6 +- stdlib/source/test/lux/control/parser/type.lux | 6 +- stdlib/source/test/lux/control/parser/xml.lux | 10 +- stdlib/source/test/lux/control/pipe.lux | 6 +- stdlib/source/test/lux/control/reader.lux | 7 +- stdlib/source/test/lux/control/region.lux | 8 +- stdlib/source/test/lux/control/remember.lux | 2 +- .../test/lux/control/security/capability.lux | 7 +- stdlib/source/test/lux/control/security/policy.lux | 8 +- stdlib/source/test/lux/control/state.lux | 10 +- stdlib/source/test/lux/control/thread.lux | 7 +- stdlib/source/test/lux/control/try.lux | 10 +- stdlib/source/test/lux/control/writer.lux | 9 +- stdlib/source/test/lux/data.lux | 2 - stdlib/source/test/lux/data/binary.lux | 10 +- stdlib/source/test/lux/data/collection/array.lux | 9 +- stdlib/source/test/lux/data/collection/bits.lux | 7 +- .../source/test/lux/data/collection/dictionary.lux | 6 +- .../lux/data/collection/dictionary/ordered.lux | 6 +- .../test/lux/data/collection/dictionary/plist.lux | 6 +- stdlib/source/test/lux/data/collection/list.lux | 8 +- stdlib/source/test/lux/data/collection/queue.lux | 7 +- .../test/lux/data/collection/queue/priority.lux | 8 +- stdlib/source/test/lux/data/collection/row.lux | 6 +- .../source/test/lux/data/collection/sequence.lux | 6 +- stdlib/source/test/lux/data/collection/set.lux | 6 +- .../source/test/lux/data/collection/set/multi.lux | 6 +- .../test/lux/data/collection/set/ordered.lux | 6 +- stdlib/source/test/lux/data/collection/stack.lux | 8 +- stdlib/source/test/lux/data/collection/tree.lux | 6 +- .../test/lux/data/collection/tree/finger.lux | 6 +- .../test/lux/data/collection/tree/zipper.lux | 6 +- stdlib/source/test/lux/data/color.lux | 12 +- stdlib/source/test/lux/data/color/named.lux | 6 +- stdlib/source/test/lux/data/format/json.lux | 8 +- stdlib/source/test/lux/data/format/tar.lux | 8 +- stdlib/source/test/lux/data/format/xml.lux | 6 +- stdlib/source/test/lux/data/lazy.lux | 7 +- stdlib/source/test/lux/data/maybe.lux | 98 +++---- stdlib/source/test/lux/data/name.lux | 6 +- stdlib/source/test/lux/data/number.lux | 110 -------- stdlib/source/test/lux/data/number/complex.lux | 286 -------------------- stdlib/source/test/lux/data/number/frac.lux | 244 ------------------ stdlib/source/test/lux/data/number/i16.lux | 40 --- stdlib/source/test/lux/data/number/i32.lux | 40 --- stdlib/source/test/lux/data/number/i64.lux | 282 -------------------- stdlib/source/test/lux/data/number/i8.lux | 40 --- stdlib/source/test/lux/data/number/int.lux | 184 ------------- stdlib/source/test/lux/data/number/nat.lux | 130 ---------- stdlib/source/test/lux/data/number/ratio.lux | 114 -------- stdlib/source/test/lux/data/number/rev.lux | 164 ------------ stdlib/source/test/lux/data/product.lux | 7 +- stdlib/source/test/lux/data/sum.lux | 8 +- stdlib/source/test/lux/data/text.lux | 6 +- stdlib/source/test/lux/data/text/buffer.lux | 8 +- stdlib/source/test/lux/data/text/encoding.lux | 6 +- stdlib/source/test/lux/data/text/format.lux | 14 +- stdlib/source/test/lux/data/text/regex.lux | 14 +- stdlib/source/test/lux/data/text/unicode/block.lux | 6 +- stdlib/source/test/lux/data/text/unicode/set.lux | 6 +- stdlib/source/test/lux/host.js.lux | 6 +- stdlib/source/test/lux/host.jvm.lux | 6 +- stdlib/source/test/lux/host.old.lux | 6 +- stdlib/source/test/lux/locale/language.lux | 6 +- stdlib/source/test/lux/locale/territory.lux | 6 +- stdlib/source/test/lux/macro/code.lux | 8 +- stdlib/source/test/lux/macro/poly/equivalence.lux | 12 +- stdlib/source/test/lux/macro/poly/json.lux | 12 +- stdlib/source/test/lux/macro/syntax.lux | 11 +- stdlib/source/test/lux/macro/syntax/common.lux | 30 +-- .../test/lux/macro/syntax/common/declaration.lux | 47 ++++ stdlib/source/test/lux/macro/template.lux | 6 +- stdlib/source/test/lux/math.lux | 30 ++- stdlib/source/test/lux/math/infix.lux | 8 +- stdlib/source/test/lux/math/logic/continuous.lux | 123 +++++++-- stdlib/source/test/lux/math/logic/fuzzy.lux | 14 +- stdlib/source/test/lux/math/modular.lux | 8 +- stdlib/source/test/lux/math/modulus.lux | 7 +- stdlib/source/test/lux/math/number.lux | 108 ++++++++ stdlib/source/test/lux/math/number/complex.lux | 287 +++++++++++++++++++++ stdlib/source/test/lux/math/number/frac.lux | 244 ++++++++++++++++++ stdlib/source/test/lux/math/number/i16.lux | 38 +++ stdlib/source/test/lux/math/number/i32.lux | 38 +++ stdlib/source/test/lux/math/number/i64.lux | 282 ++++++++++++++++++++ stdlib/source/test/lux/math/number/i8.lux | 38 +++ stdlib/source/test/lux/math/number/int.lux | 184 +++++++++++++ stdlib/source/test/lux/math/number/nat.lux | 130 ++++++++++ stdlib/source/test/lux/math/number/ratio.lux | 114 ++++++++ stdlib/source/test/lux/math/number/rev.lux | 164 ++++++++++++ stdlib/source/test/lux/meta.lux | 8 +- stdlib/source/test/lux/meta/annotation.lux | 17 +- stdlib/source/test/lux/target/jvm.lux | 14 +- stdlib/source/test/lux/time/duration.lux | 7 +- stdlib/source/test/lux/time/instant.lux | 8 +- stdlib/source/test/lux/type.lux | 116 +++++---- stdlib/source/test/lux/type/check.lux | 75 +++--- stdlib/source/test/lux/type/dynamic.lux | 8 +- stdlib/source/test/lux/type/implicit.lux | 6 +- stdlib/source/test/lux/type/resource.lux | 3 +- stdlib/source/test/lux/world/file.lux | 83 +++--- stdlib/source/test/lux/world/shell.lux | 8 +- 149 files changed, 2429 insertions(+), 2340 deletions(-) delete mode 100644 stdlib/source/test/lux/data/number.lux delete mode 100644 stdlib/source/test/lux/data/number/complex.lux delete mode 100644 stdlib/source/test/lux/data/number/frac.lux delete mode 100644 stdlib/source/test/lux/data/number/i16.lux delete mode 100644 stdlib/source/test/lux/data/number/i32.lux delete mode 100644 stdlib/source/test/lux/data/number/i64.lux delete mode 100644 stdlib/source/test/lux/data/number/i8.lux delete mode 100644 stdlib/source/test/lux/data/number/int.lux delete mode 100644 stdlib/source/test/lux/data/number/nat.lux delete mode 100644 stdlib/source/test/lux/data/number/ratio.lux delete mode 100644 stdlib/source/test/lux/data/number/rev.lux create mode 100644 stdlib/source/test/lux/macro/syntax/common/declaration.lux create mode 100644 stdlib/source/test/lux/math/number.lux create mode 100644 stdlib/source/test/lux/math/number/complex.lux create mode 100644 stdlib/source/test/lux/math/number/frac.lux create mode 100644 stdlib/source/test/lux/math/number/i16.lux create mode 100644 stdlib/source/test/lux/math/number/i32.lux create mode 100644 stdlib/source/test/lux/math/number/i64.lux create mode 100644 stdlib/source/test/lux/math/number/i8.lux create mode 100644 stdlib/source/test/lux/math/number/int.lux create mode 100644 stdlib/source/test/lux/math/number/nat.lux create mode 100644 stdlib/source/test/lux/math/number/ratio.lux create mode 100644 stdlib/source/test/lux/math/number/rev.lux (limited to 'stdlib/source/test') diff --git a/stdlib/source/test/aedifex/artifact/extension.lux b/stdlib/source/test/aedifex/artifact/extension.lux index 2a3f3f564..5d2491d28 100644 --- a/stdlib/source/test/aedifex/artifact/extension.lux +++ b/stdlib/source/test/aedifex/artifact/extension.lux @@ -5,13 +5,13 @@ [monad (#+ do)]] [data ["." text ("#\." equivalence)] - [number - ["n" nat]] [collection ["." set] ["." list]]] [math - ["." random (#+ Random)]]] + ["." random (#+ Random)] + [number + ["n" nat]]]] {#program ["." / ["/#" // #_ diff --git a/stdlib/source/test/aedifex/artifact/type.lux b/stdlib/source/test/aedifex/artifact/type.lux index 7f153b2a9..01b581eb3 100644 --- a/stdlib/source/test/aedifex/artifact/type.lux +++ b/stdlib/source/test/aedifex/artifact/type.lux @@ -5,13 +5,13 @@ [monad (#+ do)]] [data ["." text] - [number - ["n" nat]] [collection ["." set] ["." list]]] [math - ["." random (#+ Random) ("#\." monad)]]] + ["." random (#+ Random) ("#\." monad)] + [number + ["n" nat]]]] {#program ["." /]}) diff --git a/stdlib/source/test/aedifex/cache.lux b/stdlib/source/test/aedifex/cache.lux index bc436733b..22a32e43f 100644 --- a/stdlib/source/test/aedifex/cache.lux +++ b/stdlib/source/test/aedifex/cache.lux @@ -12,15 +12,15 @@ [data [binary (#+ Binary)] ["." text] - [number - ["n" nat]] [format [xml (#+ XML)]] [collection ["." set] ["." dictionary]]] [math - ["." random (#+ Random) ("#\." monad)]] + ["." random (#+ Random) ("#\." monad)] + [number + ["n" nat]]] [world ["." file] ["." program]]] diff --git a/stdlib/source/test/aedifex/command/auto.lux b/stdlib/source/test/aedifex/command/auto.lux index 817b4db5f..7bac6eb5d 100644 --- a/stdlib/source/test/aedifex/command/auto.lux +++ b/stdlib/source/test/aedifex/command/auto.lux @@ -15,14 +15,14 @@ [data ["." text ["%" format (#+ format)]] - [number - ["n" nat]] [collection ["." dictionary] ["." set] ["." list ("#\." functor)]]] [math - ["." random]] + ["." random] + [number + ["n" nat]]] [world [console (#+ Console)] ["." shell (#+ Shell)] diff --git a/stdlib/source/test/aedifex/command/clean.lux b/stdlib/source/test/aedifex/command/clean.lux index c429f34fb..d98473259 100644 --- a/stdlib/source/test/aedifex/command/clean.lux +++ b/stdlib/source/test/aedifex/command/clean.lux @@ -14,13 +14,13 @@ ["." product] ["." text ("#\." equivalence) ["%" format (#+ format)]] - [number - ["n" nat]] [collection ["." list ("#\." functor)] ["." set]]] [math - ["." random (#+ Random)]] + ["." random (#+ Random)] + [number + ["n" nat]]] [world ["." file (#+ Path File)]]] [// diff --git a/stdlib/source/test/aedifex/command/deploy.lux b/stdlib/source/test/aedifex/command/deploy.lux index b6cd89469..45d39cffc 100644 --- a/stdlib/source/test/aedifex/command/deploy.lux +++ b/stdlib/source/test/aedifex/command/deploy.lux @@ -49,7 +49,8 @@ ["#." local] ["#." hash] ["#." repository (#+ Repository) - [identity (#+ Identity)]] + [identity (#+ Identity)] + ["#/." remote]] ["#." artifact (#+ Artifact) ["#/." extension]]]]]}) @@ -111,10 +112,10 @@ (export.library fs) (\ ! map (format.run tar.writer))) - actual_pom (\ repository download (///repository.uri artifact ///artifact/extension.pom)) - actual_library (\ repository download (///repository.uri artifact ///artifact/extension.lux_library)) - actual_sha-1 (\ repository download (///repository.uri artifact (format ///artifact/extension.lux_library ///artifact/extension.sha-1))) - actual_md5 (\ repository download (///repository.uri artifact (format ///artifact/extension.lux_library ///artifact/extension.md5))) + actual_pom (\ repository download (///repository/remote.uri artifact ///artifact/extension.pom)) + actual_library (\ repository download (///repository/remote.uri artifact ///artifact/extension.lux_library)) + actual_sha-1 (\ repository download (///repository/remote.uri artifact (format ///artifact/extension.lux_library ///artifact/extension.sha-1))) + actual_md5 (\ repository download (///repository/remote.uri artifact (format ///artifact/extension.lux_library ///artifact/extension.md5))) #let [deployed_library! (\ binary.equivalence = diff --git a/stdlib/source/test/aedifex/hash.lux b/stdlib/source/test/aedifex/hash.lux index 502130970..4c057be60 100644 --- a/stdlib/source/test/aedifex/hash.lux +++ b/stdlib/source/test/aedifex/hash.lux @@ -12,12 +12,12 @@ ["." exception]] [data ["." binary (#+ Binary)] - [number - ["n" nat]] [text ["%" format (#+ format)]]] [math - ["." random (#+ Random)]]] + ["." random (#+ Random)] + [number + ["n" nat]]]] {#program ["." /]} [test diff --git a/stdlib/source/test/aedifex/metadata/artifact.lux b/stdlib/source/test/aedifex/metadata/artifact.lux index 3177c6ff2..6c39546b4 100644 --- a/stdlib/source/test/aedifex/metadata/artifact.lux +++ b/stdlib/source/test/aedifex/metadata/artifact.lux @@ -10,7 +10,7 @@ ["." try ("#\." functor)] [parser ["<.>" xml]]] - [data + [math [number ["n" nat]]] ["." time diff --git a/stdlib/source/test/aedifex/metadata/snapshot.lux b/stdlib/source/test/aedifex/metadata/snapshot.lux index e9e42be9a..c1725f55a 100644 --- a/stdlib/source/test/aedifex/metadata/snapshot.lux +++ b/stdlib/source/test/aedifex/metadata/snapshot.lux @@ -10,7 +10,7 @@ ["." try ("#\." functor)] [parser ["<.>" xml]]] - [data + [math [number ["n" nat]]] ["." time diff --git a/stdlib/source/test/aedifex/package.lux b/stdlib/source/test/aedifex/package.lux index 7562547df..960a75f21 100644 --- a/stdlib/source/test/aedifex/package.lux +++ b/stdlib/source/test/aedifex/package.lux @@ -10,11 +10,11 @@ [data ["." text] [collection - ["." set (#+ Set)]] + ["." set (#+ Set)]]] + [math + ["." random (#+ Random)] [number ["n" nat]]] - [math - ["." random (#+ Random)]] [world ["." file]]] [// diff --git a/stdlib/source/test/aedifex/parser.lux b/stdlib/source/test/aedifex/parser.lux index 1eb62b75d..0a13acb32 100644 --- a/stdlib/source/test/aedifex/parser.lux +++ b/stdlib/source/test/aedifex/parser.lux @@ -11,14 +11,14 @@ ["" code]]] [data ["." text] - [number - ["n" nat]] [collection ["." set (#+ Set)] ["." dictionary (#+ Dictionary)] ["." list ("#\." functor)]]] [math - ["." random (#+ Random)]] + ["." random (#+ Random)] + [number + ["n" nat]]] [macro ["." code]]] [// diff --git a/stdlib/source/test/aedifex/profile.lux b/stdlib/source/test/aedifex/profile.lux index 9316fae66..ea03a1e92 100644 --- a/stdlib/source/test/aedifex/profile.lux +++ b/stdlib/source/test/aedifex/profile.lux @@ -15,22 +15,23 @@ ["." cli]]] [data ["." text] - [number - ["n" nat]] [collection ["." set (#+ Set)] ["." dictionary (#+ Dictionary)]]] [math - ["." random (#+ Random) ("#\." monad)]]] + ["." random (#+ Random) ("#\." monad)] + [number + ["n" nat]]]] [// ["@." artifact] ["@." dependency]] {#program ["." / ["/#" // #_ - [repository (#+ Address)] ["#." dependency (#+ Dependency)] - ["#." format]]]}) + ["#." format] + [repository + [remote (#+ Address)]]]]}) (def: distribution (Random /.Distribution) diff --git a/stdlib/source/test/aedifex/project.lux b/stdlib/source/test/aedifex/project.lux index cec9c0cae..5e26b63de 100644 --- a/stdlib/source/test/aedifex/project.lux +++ b/stdlib/source/test/aedifex/project.lux @@ -12,11 +12,11 @@ ["." exception]] [data ["." product] - ["." text ("#\." equivalence)] - [number - ["n" nat]]] + ["." text ("#\." equivalence)]] [math - ["." random (#+ Random) ("#\." monad)]]] + ["." random (#+ Random) ("#\." monad)] + [number + ["n" nat]]]] [// ["@." profile]] {#program diff --git a/stdlib/source/test/lux/abstract/apply.lux b/stdlib/source/test/lux/abstract/apply.lux index d56860291..fc67f9830 100644 --- a/stdlib/source/test/lux/abstract/apply.lux +++ b/stdlib/source/test/lux/abstract/apply.lux @@ -4,12 +4,12 @@ [monad (#+ do)]] [data ["." maybe] - [number - ["n" nat]] [collection ["." list]]] [math - ["." random]] + ["." random] + [number + ["n" nat]]] ["_" test (#+ Test)]] {1 ["." / (#+ Apply)]}) diff --git a/stdlib/source/test/lux/abstract/comonad.lux b/stdlib/source/test/lux/abstract/comonad.lux index 2e63b4eb8..7e59dfc42 100644 --- a/stdlib/source/test/lux/abstract/comonad.lux +++ b/stdlib/source/test/lux/abstract/comonad.lux @@ -3,11 +3,11 @@ [abstract [monad (#+ do)]] [data - ["." identity (#+ Identity)] + ["." identity (#+ Identity)]] + [math + ["." random] [number ["n" nat]]] - [math - ["." random]] ["_" test (#+ Test)]] {1 ["." /]}) diff --git a/stdlib/source/test/lux/abstract/enum.lux b/stdlib/source/test/lux/abstract/enum.lux index 4446d958c..1cee8a211 100644 --- a/stdlib/source/test/lux/abstract/enum.lux +++ b/stdlib/source/test/lux/abstract/enum.lux @@ -6,12 +6,12 @@ [data ["." product] ["." maybe ("#\." functor)] - [number - ["n" nat]] [collection ["." list ("#\." fold)]]] [math - ["." random (#+ Random)]]] + ["." random (#+ Random)] + [number + ["n" nat]]]] {1 ["." /]}) diff --git a/stdlib/source/test/lux/abstract/equivalence.lux b/stdlib/source/test/lux/abstract/equivalence.lux index 3009c289f..cceb75c42 100644 --- a/stdlib/source/test/lux/abstract/equivalence.lux +++ b/stdlib/source/test/lux/abstract/equivalence.lux @@ -8,12 +8,12 @@ [functor ["$." contravariant]]]}] [data - ["." bit ("#\." equivalence)] + ["." bit ("#\." equivalence)]] + [math + ["." random (#+ Random)] [number ["n" nat] - ["i" int]]] - [math - ["." random (#+ Random)]]] + ["i" int]]]] {1 ["." / (#+ Equivalence)]}) diff --git a/stdlib/source/test/lux/abstract/fold.lux b/stdlib/source/test/lux/abstract/fold.lux index 66f7a6e48..f4a61fa95 100644 --- a/stdlib/source/test/lux/abstract/fold.lux +++ b/stdlib/source/test/lux/abstract/fold.lux @@ -4,12 +4,12 @@ [abstract [monad (#+ do)]] [data - [number - ["n" nat]] [collection ["." list]]] [math - ["." random]]] + ["." random] + [number + ["n" nat]]]] {1 ["." / (#+ Fold)]}) diff --git a/stdlib/source/test/lux/abstract/functor.lux b/stdlib/source/test/lux/abstract/functor.lux index 593400eb5..cd56a2aba 100644 --- a/stdlib/source/test/lux/abstract/functor.lux +++ b/stdlib/source/test/lux/abstract/functor.lux @@ -5,12 +5,12 @@ [monad (#+ do)]] [data ["." maybe] - [number - ["n" nat]] [collection ["." list]]] [math - ["." random]]] + ["." random] + [number + ["n" nat]]]] {1 ["." / (#+ Functor)]}) diff --git a/stdlib/source/test/lux/abstract/interval.lux b/stdlib/source/test/lux/abstract/interval.lux index 66d607ab8..ccd5562c8 100644 --- a/stdlib/source/test/lux/abstract/interval.lux +++ b/stdlib/source/test/lux/abstract/interval.lux @@ -10,13 +10,13 @@ [control [pipe (#+ case>)]] [data - [number - ["n" nat]] [collection ["." set] ["." list]]] [math - ["." random (#+ Random)]]] + ["." random (#+ Random)] + [number + ["n" nat]]]] {1 ["." / (#+ Interval) ("\." equivalence)]}) diff --git a/stdlib/source/test/lux/abstract/monad.lux b/stdlib/source/test/lux/abstract/monad.lux index 19e5bb342..805e6478f 100644 --- a/stdlib/source/test/lux/abstract/monad.lux +++ b/stdlib/source/test/lux/abstract/monad.lux @@ -1,14 +1,14 @@ (.module: [lux #* + ["_" test (#+ Test)] [data ["." identity (#+ Identity)] - [number - ["n" nat]] [collection ["." list ("#\." functor fold)]]] [math - ["." random]] - ["_" test (#+ Test)]] + ["." random] + [number + ["n" nat]]]] {1 ["." / (#+ Monad do)]}) diff --git a/stdlib/source/test/lux/abstract/monoid.lux b/stdlib/source/test/lux/abstract/monoid.lux index 2037adeea..81835537b 100644 --- a/stdlib/source/test/lux/abstract/monoid.lux +++ b/stdlib/source/test/lux/abstract/monoid.lux @@ -3,12 +3,11 @@ ["_" test (#+ Test)] [abstract [monad (#+ do)]] - [data + [math + ["." random (#+ Random)] [number ["." nat] - ["." int]]] - [math - ["." random (#+ Random)]]] + ["." int]]]] {1 ["." / [// diff --git a/stdlib/source/test/lux/abstract/order.lux b/stdlib/source/test/lux/abstract/order.lux index f45076a0c..e9121353a 100644 --- a/stdlib/source/test/lux/abstract/order.lux +++ b/stdlib/source/test/lux/abstract/order.lux @@ -8,11 +8,11 @@ [functor ["$." contravariant]]]}] [data - ["." bit ("#\." equivalence)] - [number - ["n" nat]]] + ["." bit ("#\." equivalence)]] [math - ["." random (#+ Random)]]] + ["." random (#+ Random)] + [number + ["n" nat]]]] {1 ["." / [// diff --git a/stdlib/source/test/lux/abstract/predicate.lux b/stdlib/source/test/lux/abstract/predicate.lux index 47875a6c4..be2953aba 100644 --- a/stdlib/source/test/lux/abstract/predicate.lux +++ b/stdlib/source/test/lux/abstract/predicate.lux @@ -13,12 +13,12 @@ ["." function]] [data ["." bit ("#\." equivalence)] - [number - ["n" nat]] [collection ["." list]]] [math - ["." random (#+ Random)]]] + ["." random (#+ Random)] + [number + ["n" nat]]]] {1 ["." /]}) diff --git a/stdlib/source/test/lux/control/concatenative.lux b/stdlib/source/test/lux/control/concatenative.lux index b01981730..090fd799f 100644 --- a/stdlib/source/test/lux/control/concatenative.lux +++ b/stdlib/source/test/lux/control/concatenative.lux @@ -6,18 +6,16 @@ [data ["." sum] ["." name] - ["." bit ("#\." equivalence)] + ["." bit ("#\." equivalence)]] + [macro + ["." template]] + [math + ["." random] [number ["n" nat] ["i" int] ["r" rev] - ["f" frac]] - [text - ["%" format (#+ format)]]] - [math - ["." random]] - [macro - ["." template]]] + ["f" frac]]]] {1 ["." / (#+ word: => ||>)]}) diff --git a/stdlib/source/test/lux/control/concurrency/actor.lux b/stdlib/source/test/lux/control/concurrency/actor.lux index 7a94c72aa..d983ab382 100644 --- a/stdlib/source/test/lux/control/concurrency/actor.lux +++ b/stdlib/source/test/lux/control/concurrency/actor.lux @@ -8,15 +8,15 @@ ["." exception (#+ exception:)] ["." io (#+ IO io)]] [data - [number - ["n" nat]] [text ["%" format (#+ format)]] [collection ["." list] ["." row (#+ Row)]]] [math - ["." random]]] + ["." random] + [number + ["n" nat]]]] {1 ["." / (#+ actor: message:) [// diff --git a/stdlib/source/test/lux/control/concurrency/atom.lux b/stdlib/source/test/lux/control/concurrency/atom.lux index bdc56521a..c8496c210 100644 --- a/stdlib/source/test/lux/control/concurrency/atom.lux +++ b/stdlib/source/test/lux/control/concurrency/atom.lux @@ -5,11 +5,10 @@ [monad (#+ do)]] [control ["." io]] - [data - [number - ["n" nat]]] [math - ["." random]]] + ["." random] + [number + ["n" nat]]]] {1 ["." /]}) diff --git a/stdlib/source/test/lux/control/concurrency/frp.lux b/stdlib/source/test/lux/control/concurrency/frp.lux index d48e1b1ae..2c724fa2a 100644 --- a/stdlib/source/test/lux/control/concurrency/frp.lux +++ b/stdlib/source/test/lux/control/concurrency/frp.lux @@ -13,15 +13,13 @@ ["." exception] ["." io (#+ IO io)]] [data - [text - ["%" format (#+ format)]] - [number - ["n" nat]] [collection ["." list ("#\." fold monoid)] ["." row (#+ Row)]]] [math - ["." random]]] + ["." random] + [number + ["n" nat]]]] {1 ["." / [// diff --git a/stdlib/source/test/lux/control/concurrency/promise.lux b/stdlib/source/test/lux/control/concurrency/promise.lux index 18b040acf..7fc3196cd 100644 --- a/stdlib/source/test/lux/control/concurrency/promise.lux +++ b/stdlib/source/test/lux/control/concurrency/promise.lux @@ -11,15 +11,14 @@ [control [pipe (#+ case>)] ["." io]] - [data - [number - ["n" nat] - ["i" int]]] [time ["." instant] ["." duration]] [math - ["." random]]] + ["." random] + [number + ["n" nat] + ["i" int]]]] {1 ["." / [// diff --git a/stdlib/source/test/lux/control/concurrency/semaphore.lux b/stdlib/source/test/lux/control/concurrency/semaphore.lux index e30a930ac..472e21c7d 100644 --- a/stdlib/source/test/lux/control/concurrency/semaphore.lux +++ b/stdlib/source/test/lux/control/concurrency/semaphore.lux @@ -13,16 +13,16 @@ ["." atom (#+ Atom)]]] [data ["." maybe] - [number - ["n" nat]] ["." text ("#\." equivalence) ["%" format (#+ format)]] [collection ["." list ("#\." functor)]]] - [type - ["." refinement]] [math - ["." random]]] + ["." random] + [number + ["n" nat]]] + [type + ["." refinement]]] {1 ["." /]}) diff --git a/stdlib/source/test/lux/control/concurrency/stm.lux b/stdlib/source/test/lux/control/concurrency/stm.lux index ade5dd70d..2eec0d207 100644 --- a/stdlib/source/test/lux/control/concurrency/stm.lux +++ b/stdlib/source/test/lux/control/concurrency/stm.lux @@ -12,12 +12,12 @@ ["." io (#+ IO)]] [data ["." product] - [number - ["n" nat]] [collection ["." list ("#\." functor)]]] [math - ["." random]]] + ["." random] + [number + ["n" nat]]]] {1 ["." / [// diff --git a/stdlib/source/test/lux/control/concurrency/thread.lux b/stdlib/source/test/lux/control/concurrency/thread.lux index 04da97f17..f1ea184f0 100644 --- a/stdlib/source/test/lux/control/concurrency/thread.lux +++ b/stdlib/source/test/lux/control/concurrency/thread.lux @@ -5,15 +5,14 @@ [monad (#+ do)]] [control ["." io]] - [data - [number - ["n" nat] - ["i" int]]] [time ["." instant (#+ Instant)] ["." duration]] [math - ["." random]]] + ["." random] + [number + ["n" nat] + ["i" int]]]] {1 ["." / [// diff --git a/stdlib/source/test/lux/control/continuation.lux b/stdlib/source/test/lux/control/continuation.lux index b22705489..24aadf440 100644 --- a/stdlib/source/test/lux/control/continuation.lux +++ b/stdlib/source/test/lux/control/continuation.lux @@ -9,12 +9,12 @@ ["$." apply] ["$." monad]]}] [data - [number - ["n" nat]] [collection ["." list]]] [math - ["." random]]] + ["." random] + [number + ["n" nat]]]] {1 ["." /]}) diff --git a/stdlib/source/test/lux/control/exception.lux b/stdlib/source/test/lux/control/exception.lux index 8f890018c..c65a88fbf 100644 --- a/stdlib/source/test/lux/control/exception.lux +++ b/stdlib/source/test/lux/control/exception.lux @@ -1,15 +1,15 @@ (.module: [lux #* + ["_" test (#+ Test)] [abstract [monad (#+ do)]] [data - [number - ["n" nat]] ["." text ("#\." equivalence) ["%" format (#+ format)]]] [math - ["." random]] - ["_" test (#+ Test)]] + ["." random] + [number + ["n" nat]]]] {1 ["." / (#+ exception:) [// diff --git a/stdlib/source/test/lux/control/function.lux b/stdlib/source/test/lux/control/function.lux index c78d4f2e5..f816075f5 100644 --- a/stdlib/source/test/lux/control/function.lux +++ b/stdlib/source/test/lux/control/function.lux @@ -1,5 +1,6 @@ (.module: [lux #* + ["_" test (#+ Test)] [abstract [equivalence (#+ Equivalence)] [monad (#+ do)] @@ -7,12 +8,11 @@ [/ ["$." monoid]]}] [data - [number - ["n" nat]] ["." text ("#!." equivalence)]] [math - ["." random (#+ Random)]] - ["_" test (#+ Test)]] + ["." random (#+ Random)] + [number + ["n" nat]]]] {1 ["." /]} ["." / #_ diff --git a/stdlib/source/test/lux/control/function/contract.lux b/stdlib/source/test/lux/control/function/contract.lux index 422c98618..47962d04a 100644 --- a/stdlib/source/test/lux/control/function/contract.lux +++ b/stdlib/source/test/lux/control/function/contract.lux @@ -7,8 +7,7 @@ [control ["." try]] [math - ["." random]] - [data + ["." random] [number ["n" nat]]]] {1 diff --git a/stdlib/source/test/lux/control/function/memo.lux b/stdlib/source/test/lux/control/function/memo.lux index 8fad40d86..fdf9119f6 100644 --- a/stdlib/source/test/lux/control/function/memo.lux +++ b/stdlib/source/test/lux/control/function/memo.lux @@ -6,18 +6,16 @@ [control ["." io (#+ IO)] ["." state (#+ State) ("#\." monad)]] - [math - ["." random]] [data ["." product] - [text - ["%" format (#+ format)]] - [number - ["n" nat] - ["." i64]] [collection ["." dictionary (#+ Dictionary)] ["." list ("#\." functor fold)]]] + [math + ["." random] + [number + ["n" nat] + ["." i64]]] [time ["." instant] ["." duration (#+ Duration)]]] diff --git a/stdlib/source/test/lux/control/function/mixin.lux b/stdlib/source/test/lux/control/function/mixin.lux index 0c343a685..8ca196ba5 100644 --- a/stdlib/source/test/lux/control/function/mixin.lux +++ b/stdlib/source/test/lux/control/function/mixin.lux @@ -12,12 +12,12 @@ ["." state (#+ State)]] [data ["." product] - [number - ["n" nat]] [collection ["." list ("#\." functor fold)]]] [math - ["." random (#+ Random)]]] + ["." random (#+ Random)] + [number + ["n" nat]]]] {1 ["." /]}) diff --git a/stdlib/source/test/lux/control/io.lux b/stdlib/source/test/lux/control/io.lux index 937d73870..30e4656c8 100644 --- a/stdlib/source/test/lux/control/io.lux +++ b/stdlib/source/test/lux/control/io.lux @@ -1,8 +1,6 @@ (.module: [lux #* ["_" test (#+ Test)] - [math - ["." random]] [abstract [monad (#+ do)] {[0 #spec] @@ -10,7 +8,8 @@ ["$." functor (#+ Injection Comparison)] ["$." apply] ["$." monad]]}] - [data + [math + ["." random] [number ["n" nat]]]] {1 diff --git a/stdlib/source/test/lux/control/parser.lux b/stdlib/source/test/lux/control/parser.lux index 6c2f739bb..bf69c8330 100644 --- a/stdlib/source/test/lux/control/parser.lux +++ b/stdlib/source/test/lux/control/parser.lux @@ -14,17 +14,17 @@ [parser ["s" code]]] [data - [number - ["n" nat]] ["." text ("#\." equivalence) ["%" format (#+ format)]] [collection ["." list ("#\." functor)]]] [math - ["." random]] + ["." random] + [number + ["n" nat]]] [macro - ["." code] - [syntax (#+ syntax:)]]] + [syntax (#+ syntax:)] + ["." code]]] {1 ["." / (#+ Parser)]} ["." / #_ diff --git a/stdlib/source/test/lux/control/parser/analysis.lux b/stdlib/source/test/lux/control/parser/analysis.lux index daf3632d6..8ffc75025 100644 --- a/stdlib/source/test/lux/control/parser/analysis.lux +++ b/stdlib/source/test/lux/control/parser/analysis.lux @@ -12,15 +12,15 @@ ["." name ("#\." equivalence)] ["." bit ("#\." equivalence)] ["." text ("#\." equivalence)] + [collection + ["." list]]] + [math + ["." random (#+ Random)] [number ["n" nat] ["i" int] ["f" frac] - ["r" rev]] - [collection - ["." list]]] - [math - ["." random (#+ Random)]] + ["r" rev]]] [tool [compiler [reference (#+ Constant)] diff --git a/stdlib/source/test/lux/control/parser/binary.lux b/stdlib/source/test/lux/control/parser/binary.lux index 2a29ba367..bc54ceada 100644 --- a/stdlib/source/test/lux/control/parser/binary.lux +++ b/stdlib/source/test/lux/control/parser/binary.lux @@ -1,6 +1,7 @@ (.module: [lux (#- primitive) ["_" test (#+ Test)] + ["." type] [abstract [equivalence (#+ Equivalence)] [predicate (#+ Predicate)] @@ -21,21 +22,20 @@ ["%" format (#+ format)]] ["." format #_ ["#" binary]] - [number - ["." i64] - ["n" nat] - ["." int] - ["." rev] - ["." frac]] [collection ["." list] ["." row] ["." set]]] [macro ["." code]] - ["." type] [math - ["." random (#+ Random)]]] + ["." random (#+ Random)] + [number + ["n" nat] + ["." i64] + ["." int] + ["." rev] + ["." frac]]]] {1 ["." /]}) diff --git a/stdlib/source/test/lux/control/parser/cli.lux b/stdlib/source/test/lux/control/parser/cli.lux index 60bd3f9fe..41ffb4e23 100644 --- a/stdlib/source/test/lux/control/parser/cli.lux +++ b/stdlib/source/test/lux/control/parser/cli.lux @@ -7,13 +7,13 @@ ["." try] ["<>" parser]] [data - [number - ["n" nat ("#\." decimal)]] ["." text ("#\." equivalence)] [collection ["." list]]] [math - ["." random]]] + ["." random] + [number + ["n" nat ("#\." decimal)]]]] {1 ["." /]}) diff --git a/stdlib/source/test/lux/control/parser/code.lux b/stdlib/source/test/lux/control/parser/code.lux index 71aa8f39d..0a8311fb3 100644 --- a/stdlib/source/test/lux/control/parser/code.lux +++ b/stdlib/source/test/lux/control/parser/code.lux @@ -11,17 +11,17 @@ ["." bit] ["." name] ["." text] - [number - ["." nat] - ["." int] - ["." rev] - ["." frac]] [collection ["." list]]] [macro ["." code]] [math - ["." random (#+ Random)]]] + ["." random (#+ Random)] + [number + ["." nat] + ["." int] + ["." rev] + ["." frac]]]] {1 ["." /]}) diff --git a/stdlib/source/test/lux/control/parser/environment.lux b/stdlib/source/test/lux/control/parser/environment.lux index 117693fe9..6a210f2a0 100644 --- a/stdlib/source/test/lux/control/parser/environment.lux +++ b/stdlib/source/test/lux/control/parser/environment.lux @@ -8,12 +8,12 @@ ["." exception]] [data ["." text ("#\." equivalence)] - [number - ["n" nat]] [collection ["." dictionary]]] [math - ["." random]]] + ["." random] + [number + ["n" nat]]]] {1 ["." / ["/#" // ("#\." monad)]]}) diff --git a/stdlib/source/test/lux/control/parser/json.lux b/stdlib/source/test/lux/control/parser/json.lux index b9d111eff..4d8dc0b8e 100644 --- a/stdlib/source/test/lux/control/parser/json.lux +++ b/stdlib/source/test/lux/control/parser/json.lux @@ -12,9 +12,6 @@ ["." maybe] ["." bit] ["." text] - [number - ["n" nat] - ["." frac]] [collection ["." list ("#\." functor)] ["." set] @@ -23,7 +20,10 @@ [format ["." json]]] [math - ["." random (#+ Random)]]] + ["." random (#+ Random)] + [number + ["n" nat] + ["." frac]]]] {1 ["." /]}) diff --git a/stdlib/source/test/lux/control/parser/synthesis.lux b/stdlib/source/test/lux/control/parser/synthesis.lux index b47f8338c..7916f7217 100644 --- a/stdlib/source/test/lux/control/parser/synthesis.lux +++ b/stdlib/source/test/lux/control/parser/synthesis.lux @@ -3,23 +3,23 @@ ["_" test (#+ Test)] [abstract ["." monad (#+ do)]] - [math - ["." random (#+ Random)]] [control [pipe (#+ case>)] + ["<>" parser] ["." try] - ["." exception] - ["<>" parser]] + ["." exception]] [data ["." bit] ["." name] ["." text] - [number - ["." i64] - ["n" nat] - ["." frac]] [collection ["." list ("#\." functor)]]] + [math + ["." random (#+ Random)] + [number + ["n" nat] + ["." i64] + ["." frac]]] [tool [compiler [reference (#+) diff --git a/stdlib/source/test/lux/control/parser/text.lux b/stdlib/source/test/lux/control/parser/text.lux index 8465393de..dd8ce8ceb 100644 --- a/stdlib/source/test/lux/control/parser/text.lux +++ b/stdlib/source/test/lux/control/parser/text.lux @@ -14,15 +14,15 @@ ["." unicode #_ ["#" set] ["#/." block]]] - [number (#+ hex) - ["n" nat]] [collection ["." set] ["." list ("#\." functor)] [tree ["." finger]]]] [math - ["." random]] + ["." random] + [number (#+ hex) + ["n" nat]]] [macro ["." code]]] {1 diff --git a/stdlib/source/test/lux/control/parser/tree.lux b/stdlib/source/test/lux/control/parser/tree.lux index f4f3da769..5dbe726ea 100644 --- a/stdlib/source/test/lux/control/parser/tree.lux +++ b/stdlib/source/test/lux/control/parser/tree.lux @@ -7,13 +7,13 @@ ["." try] ["." exception]] [data - [number - ["n" nat]] [collection ["." tree ["." zipper]]]] [math - ["." random]]] + ["." random] + [number + ["n" nat]]]] {1 ["." / ["/#" //]]}) diff --git a/stdlib/source/test/lux/control/parser/type.lux b/stdlib/source/test/lux/control/parser/type.lux index 47cdac08f..5390498c7 100644 --- a/stdlib/source/test/lux/control/parser/type.lux +++ b/stdlib/source/test/lux/control/parser/type.lux @@ -8,12 +8,12 @@ ["." exception]] [data ["." name ("#\." equivalence)] - [number - ["n" nat]] [collection ["." list]]] [math - ["." random (#+ Random)]] + ["." random (#+ Random)] + [number + ["n" nat]]] ["." type ("#\." equivalence)]] {1 ["." / diff --git a/stdlib/source/test/lux/control/parser/xml.lux b/stdlib/source/test/lux/control/parser/xml.lux index 6d6126e8f..a9f71af71 100644 --- a/stdlib/source/test/lux/control/parser/xml.lux +++ b/stdlib/source/test/lux/control/parser/xml.lux @@ -1,6 +1,7 @@ (.module: [lux #* ["_" test (#+ Test)] + ["." type ("#\." equivalence)] [abstract [monad (#+ do)]] [control @@ -11,16 +12,15 @@ ["." name ("#\." equivalence)] [format ["." xml]] - [number - ["n" nat]] [collection ["." dictionary] ["." list]]] - [math - ["." random (#+ Random)]] [macro ["." template]] - ["." type ("#\." equivalence)]] + [math + ["." random (#+ Random)] + [number + ["n" nat]]]] {1 ["." / ["/#" // ("#\." monad)]]}) diff --git a/stdlib/source/test/lux/control/pipe.lux b/stdlib/source/test/lux/control/pipe.lux index 6a9809c8b..cd57863b7 100644 --- a/stdlib/source/test/lux/control/pipe.lux +++ b/stdlib/source/test/lux/control/pipe.lux @@ -5,12 +5,12 @@ [monad (#+ do)]] [data ["." identity] - [number - ["n" nat]] ["." text ("#\." equivalence) ["%" format (#+ format)]]] [math - ["." random]]] + ["." random] + [number + ["n" nat]]]] {1 ["." /]}) diff --git a/stdlib/source/test/lux/control/reader.lux b/stdlib/source/test/lux/control/reader.lux index cd8204b0c..11c8b8855 100644 --- a/stdlib/source/test/lux/control/reader.lux +++ b/stdlib/source/test/lux/control/reader.lux @@ -8,11 +8,10 @@ ["$." functor (#+ Injection Comparison)] ["$." apply] ["$." monad]]}] - [data - [number - ["n" nat]]] [math - ["." random]]] + ["." random] + [number + ["n" nat]]]] {1 ["." / (#+ Reader) [// diff --git a/stdlib/source/test/lux/control/region.lux b/stdlib/source/test/lux/control/region.lux index b9389dbdf..1023822ea 100644 --- a/stdlib/source/test/lux/control/region.lux +++ b/stdlib/source/test/lux/control/region.lux @@ -1,5 +1,6 @@ (.module: [lux #* + [type (#+ :share)] ["_" test (#+ Test)] [abstract [equivalence (#+ Equivalence)] @@ -15,13 +16,12 @@ [control ["." try (#+ Try)]] [data - [number - ["n" nat]] [collection ["." list]]] [math - ["." random]] - [type (#+ :share)]] + ["." random] + [number + ["n" nat]]]] {1 ["." / (#+ Region) [// diff --git a/stdlib/source/test/lux/control/remember.lux b/stdlib/source/test/lux/control/remember.lux index 6f1e53122..fb7517237 100644 --- a/stdlib/source/test/lux/control/remember.lux +++ b/stdlib/source/test/lux/control/remember.lux @@ -10,11 +10,11 @@ [parser ["" code]]] [data - [number (#+ hex)] ["." product] ["." text ["%" format (#+ format)]]] [math + [number (#+ hex)] ["." random (#+ Random) ("#\." monad)]] [time ["." date (#+ Date)] diff --git a/stdlib/source/test/lux/control/security/capability.lux b/stdlib/source/test/lux/control/security/capability.lux index 50a2d04d8..7804cda68 100644 --- a/stdlib/source/test/lux/control/security/capability.lux +++ b/stdlib/source/test/lux/control/security/capability.lux @@ -7,11 +7,10 @@ ["." io (#+ IO)] [concurrency ["." promise]]] - [data - [number - ["n" nat]]] [math - ["." random]]] + ["." random] + [number + ["n" nat]]]] {1 ["." /]}) diff --git a/stdlib/source/test/lux/control/security/policy.lux b/stdlib/source/test/lux/control/security/policy.lux index 55e928d52..9c72304d9 100644 --- a/stdlib/source/test/lux/control/security/policy.lux +++ b/stdlib/source/test/lux/control/security/policy.lux @@ -13,11 +13,11 @@ [security ["!" capability]]] [data - ["." text ("#\." equivalence)] - [number - ["n" nat]]] + ["." text ("#\." equivalence)]] [math - ["." random]]] + ["." random] + [number + ["n" nat]]]] {1 ["." / (#+ Context Privacy Can_Conceal Can_Reveal Privilege Private)]}) diff --git a/stdlib/source/test/lux/control/state.lux b/stdlib/source/test/lux/control/state.lux index 4d6772069..a79bfc84c 100644 --- a/stdlib/source/test/lux/control/state.lux +++ b/stdlib/source/test/lux/control/state.lux @@ -12,13 +12,11 @@ [pipe (#+ let>)] ["." io]] [data - ["." product] - [number - ["n" nat]] - [text - ["%" format (#+ format)]]] + ["." product]] [math - ["." random]]] + ["." random] + [number + ["n" nat]]]] {1 ["." / (#+ State)]}) diff --git a/stdlib/source/test/lux/control/thread.lux b/stdlib/source/test/lux/control/thread.lux index cedd55530..5fac55739 100644 --- a/stdlib/source/test/lux/control/thread.lux +++ b/stdlib/source/test/lux/control/thread.lux @@ -8,11 +8,10 @@ ["$." functor (#+ Injection Comparison)] ["$." apply] ["$." monad]]}] - [data - [number - ["n" nat]]] [math - ["." random]]] + ["." random] + [number + ["n" nat]]]] {1 ["." / (#+ Thread) [// diff --git a/stdlib/source/test/lux/control/try.lux b/stdlib/source/test/lux/control/try.lux index 9993a3f70..b89246b26 100644 --- a/stdlib/source/test/lux/control/try.lux +++ b/stdlib/source/test/lux/control/try.lux @@ -2,7 +2,7 @@ [lux #* ["_" test (#+ Test)] [abstract - [monad (#+ do Monad)] + [monad (#+ do)] {[0 #spec] [/ ["$." functor (#+ Injection Comparison)] @@ -13,11 +13,11 @@ pipe ["." io]] [data - ["." text ("#\." equivalence)] - [number - ["n" nat]]] + ["." text ("#\." equivalence)]] [math - ["." random (#+ Random)]]] + ["." random (#+ Random)] + [number + ["n" nat]]]] {1 ["." / (#+ Try)]}) diff --git a/stdlib/source/test/lux/control/writer.lux b/stdlib/source/test/lux/control/writer.lux index d9544def1..843bab32b 100644 --- a/stdlib/source/test/lux/control/writer.lux +++ b/stdlib/source/test/lux/control/writer.lux @@ -14,12 +14,11 @@ ["." io]] [data ["." product] - [number - ["n" nat]] - ["." text ("#\." equivalence) - ["%" format (#+ format)]]] + ["." text ("#\." equivalence)]] [math - ["." random]]] + ["." random] + [number + ["n" nat]]]] {1 ["." / (#+ Writer)]}) diff --git a/stdlib/source/test/lux/data.lux b/stdlib/source/test/lux/data.lux index 78cae485a..376a7cd3e 100644 --- a/stdlib/source/test/lux/data.lux +++ b/stdlib/source/test/lux/data.lux @@ -12,7 +12,6 @@ ["#." lazy] ["#." maybe] ["#." name] - ["#." number] ["#." product] ["#." sum] ["#." color @@ -53,7 +52,6 @@ /lazy.test /maybe.test /name.test - /number.test /product.test) test2 ($_ _.and /sum.test 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 [<=> ] - [(case (\ decode (..clean_commas )) - (#try.Success actual) - (<=> (/.bin ) 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 [<=> ] - [(case (\ decode (..clean_commas )) - (#try.Success actual) - (<=> (/.oct ) 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 [<=> ] - [(case (\ decode (..clean_commas )) - (#try.Success actual) - (<=> (/.hex ) 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 [ ] - [(_.for [ ] - ($monoid.spec /.equivalence ..random))] - - [/.+ /.addition] - [/.* /.multiplication] - - [/.min /.minimum] - [/.max /.maximum] - )) - (~~ (template [] - [(_.for [] - ($codec.spec /.equivalence random.safe_frac))] - - [/.binary] [/.octal] [/.decimal] [/.hex] - )) - ))) - -(with_expansions [ (as_is (host.import: java/lang/Double - ["#::." - (#static doubleToRawLongBits #manual [double] long) - (#static longBitsToDouble #manual [long] double)]))] - (for {@.old (as_is ) - @.jvm (as_is )})) - -(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 [ ($_ _.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 } - (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 [ ] - [(_.for [ ] - ($monoid.spec /.equivalence random.int))] - - [/.+ /.addition] - [/.* /.multiplication] - - [/.min /.minimum] - [/.max /.maximum] - )) - (~~ (template [] - [(_.for [] - ($codec.spec /.equivalence 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 [ ] - [(_.for [ ] - ($monoid.spec /.equivalence random.nat))] - - [/.+ /.addition] - [/.* /.multiplication] - - [/.min /.minimum] - [/.max /.maximum] - )) - (~~ (template [] - [(_.for [] - ($codec.spec /.equivalence 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 [ ] - [(_.for [ ] - ($monoid.spec /.equivalence ..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 [ ] - [(_.for [ ] - ($monoid.spec /.equivalence random.rev))] - - [/.+ /.addition] - - [/.min /.minimum] - [/.max /.maximum] - )) - (~~ (template [] - [(_.for [] - ($codec.spec /.equivalence random.rev))] - - [/.binary] [/.octal] [/.decimal] [/.hex] - )) - ))) - -(def: #export test - Test - (<| (_.covering /._) - (_.for [.Rev]) - (`` ($_ _.and - (~~ (template [ ] - [(_.cover [] - (/.= - (/.+ )))] - - [/./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) - (.run (~ regex)) - (case> (^ (#try.Success (~ pattern))) - true + (wrap (list (` (|> (~ input) + (.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]]] diff --git a/stdlib/source/test/lux/host.js.lux b/stdlib/source/test/lux/host.js.lux index f27b9554c..6147ef9b9 100644 --- a/stdlib/source/test/lux/host.js.lux +++ b/stdlib/source/test/lux/host.js.lux @@ -1,14 +1,14 @@ (.module: [lux #* ["_" test (#+ Test)] - [math - ["." random (#+ Random)]] [abstract [monad (#+ do)]] [control ["." try]] [data - ["." text ("#\." equivalence)] + ["." text ("#\." equivalence)]] + [math + ["." random (#+ Random)] [number ["." nat] ["." frac]]]] diff --git a/stdlib/source/test/lux/host.jvm.lux b/stdlib/source/test/lux/host.jvm.lux index 3a55a232d..2532b3075 100644 --- a/stdlib/source/test/lux/host.jvm.lux +++ b/stdlib/source/test/lux/host.jvm.lux @@ -4,12 +4,12 @@ [control pipe] [data - ["." text ("#\." equivalence)] + ["." text ("#\." equivalence)]] + [math + ["r" random] [number ["n" nat] ["i" int]]] - [math - ["r" random]] ["_" test (#+ Test)]] {1 ["." / (#+ import: class: interface: object)]}) diff --git a/stdlib/source/test/lux/host.old.lux b/stdlib/source/test/lux/host.old.lux index c18ef1f1e..b14dac30d 100644 --- a/stdlib/source/test/lux/host.old.lux +++ b/stdlib/source/test/lux/host.old.lux @@ -4,12 +4,12 @@ [control pipe] [data - ["." text ("#\." equivalence)] + ["." text ("#\." equivalence)]] + [math + ["r" random] [number ["n" nat] ["i" int]]] - [math - ["r" random]] ["_" test (#+ Test)]] {1 ["." / (#+ import: class: interface: object)]}) diff --git a/stdlib/source/test/lux/locale/language.lux b/stdlib/source/test/lux/locale/language.lux index 6423b7627..b3bfffc4e 100644 --- a/stdlib/source/test/lux/locale/language.lux +++ b/stdlib/source/test/lux/locale/language.lux @@ -10,15 +10,15 @@ [data ["." maybe] ["." text] - [number - ["n" nat]] [collection ["." set (#+ Set)] ["." list ("#\." functor fold)]]] [macro ["." template]] [math - ["." random (#+ Random)]]] + ["." random (#+ Random)] + [number + ["n" nat]]]] {1 ["." /]}) diff --git a/stdlib/source/test/lux/locale/territory.lux b/stdlib/source/test/lux/locale/territory.lux index 86a44cf3a..909b5b68f 100644 --- a/stdlib/source/test/lux/locale/territory.lux +++ b/stdlib/source/test/lux/locale/territory.lux @@ -10,15 +10,15 @@ [data ["." maybe] ["." text] - [number - ["n" nat]] [collection ["." set (#+ Set)] ["." list ("#\." functor fold)]]] [macro ["." template]] [math - ["." random (#+ Random)]]] + ["." random (#+ Random)] + [number + ["n" nat]]]] {1 ["." /]}) diff --git a/stdlib/source/test/lux/macro/code.lux b/stdlib/source/test/lux/macro/code.lux index cbaa5aee7..1244b84e4 100644 --- a/stdlib/source/test/lux/macro/code.lux +++ b/stdlib/source/test/lux/macro/code.lux @@ -1,8 +1,6 @@ (.module: [lux #* ["_" test (#+ Test)] - [math - ["." random (#+ Random) ("#\." monad)]] [abstract [monad (#+ do)] {[0 #spec] @@ -13,10 +11,12 @@ [data ["." product] ["." text] - [number - ["n" nat]] [collection ["." list ("#\." functor)]]] + [math + ["." random (#+ Random) ("#\." monad)] + [number + ["n" nat]]] [meta ["." location]] [tool diff --git a/stdlib/source/test/lux/macro/poly/equivalence.lux b/stdlib/source/test/lux/macro/poly/equivalence.lux index 51315ec1e..c1edf6022 100644 --- a/stdlib/source/test/lux/macro/poly/equivalence.lux +++ b/stdlib/source/test/lux/macro/poly/equivalence.lux @@ -2,8 +2,6 @@ [lux #* ["%" data/text/format (#+ format)] ["_" test (#+ Test)] - [math - ["." random (#+ Random)]] [abstract [monad (#+ do)] [equivalence (#+ Equivalence) @@ -12,14 +10,16 @@ [data ["." bit] ["." maybe] - [number - ["n" nat] - ["i" int]] ["." text] [collection ["." list]]] [macro - [poly (#+ derived:)]]]) + [poly (#+ derived:)]] + [math + ["." random (#+ Random)] + [number + ["n" nat] + ["i" int]]]]) (type: Variant (#Case0 Bit) diff --git a/stdlib/source/test/lux/macro/poly/json.lux b/stdlib/source/test/lux/macro/poly/json.lux index b6b3a29e2..98b955af8 100644 --- a/stdlib/source/test/lux/macro/poly/json.lux +++ b/stdlib/source/test/lux/macro/poly/json.lux @@ -4,9 +4,9 @@ [abstract codec [monad (#+ do)] - [equivalence (#+ Equivalence) + ["." equivalence (#+ Equivalence) {[0 #poly] - ["poly/equivalence" /]}] + ["poly/#" /]}] {[0 #spec] [/ ["$." equivalence] @@ -22,9 +22,6 @@ ["." maybe] ["." text ["%" format (#+ format)]] - [number - ["n" nat] - ["." frac]] [format [json (#+) {[0 #poly] @@ -38,7 +35,10 @@ [type ["." unit]] [math - ["." random (#+ Random)]] + ["." random (#+ Random)] + [number + ["n" nat] + ["." frac]]] [time ["ti" instant] ["tda" date] diff --git a/stdlib/source/test/lux/macro/syntax.lux b/stdlib/source/test/lux/macro/syntax.lux index 316734d36..c2a1e63a5 100644 --- a/stdlib/source/test/lux/macro/syntax.lux +++ b/stdlib/source/test/lux/macro/syntax.lux @@ -2,7 +2,6 @@ [lux #* ["%" data/text/format (#+ format)] [abstract/monad (#+ do)] - ["r" math/random (#+ Random)] ["_" test (#+ Test)] [abstract [equivalence (#+ Equivalence)]] @@ -13,14 +12,16 @@ [data ["." bit] ["." name] - ["." text] + ["." text]] + [macro + ["." code]] + [math + [random (#+ Random)] [number ["." nat] ["." int] ["." rev] - ["." frac]]] - [macro - ["." code]]] + ["." frac]]]] {1 ["." / (#+ syntax:)]}) diff --git a/stdlib/source/test/lux/macro/syntax/common.lux b/stdlib/source/test/lux/macro/syntax/common.lux index 769a28439..90a72ca26 100644 --- a/stdlib/source/test/lux/macro/syntax/common.lux +++ b/stdlib/source/test/lux/macro/syntax/common.lux @@ -1,8 +1,6 @@ (.module: [lux #* ["_" test (#+ Test)] - [math - ["." random (#+ Random)]] [abstract [monad (#+ do)] [equivalence (#+ Equivalence)]] @@ -16,12 +14,14 @@ ["." bit ("#\." equivalence)] ["." name] ["." text] - [number - ["n" nat]] [collection ["." list]]] [macro - ["." code]]] + ["." code]] + [math + ["." random (#+ Random)] + [number + ["n" nat]]]] {1 ["." / ["#." reader] @@ -31,7 +31,8 @@ ["." / #_ ["#." check] ["#." definition] - ["#." export]]) + ["#." export] + ["#." declaration]]) (def: annotations_equivalence (Equivalence /.Annotations) @@ -96,22 +97,6 @@ (#try.Failure error) false)))) (do {! random.monad} - [size (\ ! map (|>> (n.% 3)) random.nat) - expected (: (Random /.Declaration) - (random.and ..random_text - (random.list size ..random_text)))] - (_.cover [/.Declaration /reader.declaration /writer.declaration] - (|> expected - /writer.declaration list - (.run /reader.declaration) - (case> (#try.Success actual) - (let [equivalence (product.equivalence text.equivalence - (list.equivalence text.equivalence))] - (\ equivalence = expected actual)) - - (#try.Failure error) - false)))) - (do {! random.monad} [expected (: (Random /.Typed_Input) (random.and ///code.random ///code.random))] @@ -129,4 +114,5 @@ /check.test /definition.test /export.test + /declaration.test ))) diff --git a/stdlib/source/test/lux/macro/syntax/common/declaration.lux b/stdlib/source/test/lux/macro/syntax/common/declaration.lux new file mode 100644 index 000000000..a9bc23296 --- /dev/null +++ b/stdlib/source/test/lux/macro/syntax/common/declaration.lux @@ -0,0 +1,47 @@ +(.module: + [lux #* + ["_" test (#+ Test)] + [abstract + [monad (#+ do)] + {[0 #spec] + [/ + ["$." equivalence]]}] + [control + ["." try] + [parser + ["<.>" code]]] + [math + ["." random (#+ Random)] + [number + ["n" nat]]]] + {1 + ["." /]}) + +(def: #export random + (Random /.Declaration) + (let [word (random.ascii/alpha 10)] + ($_ random.and + word + (do {! random.monad} + [size (\ ! map (n.% 10) random.nat)] + (random.list size word)) + ))) + +(def: #export test + Test + (<| (_.covering /._) + (_.for [/.Declaration]) + ($_ _.and + (_.for [/.equivalence] + ($equivalence.spec /.equivalence ..random)) + + (do random.monad + [expected ..random] + (_.cover [/.write /.parser] + (case (.run /.parser + (list (/.write expected))) + (#try.Failure _) + false + + (#try.Success actual) + (\ /.equivalence = expected actual))))))) diff --git a/stdlib/source/test/lux/macro/template.lux b/stdlib/source/test/lux/macro/template.lux index 902e84255..5733f40ad 100644 --- a/stdlib/source/test/lux/macro/template.lux +++ b/stdlib/source/test/lux/macro/template.lux @@ -1,13 +1,13 @@ (.module: [lux #* ["_" test (#+ Test)] - [math - ["." random (#+ Random)]] [abstract [monad (#+ do)]] [data [collection - ["." list]] + ["." list]]] + [math + ["." random (#+ Random)] [number ["." nat]]]] {1 diff --git a/stdlib/source/test/lux/math.lux b/stdlib/source/test/lux/math.lux index d9741e6ad..a8c7c121e 100644 --- a/stdlib/source/test/lux/math.lux +++ b/stdlib/source/test/lux/math.lux @@ -2,19 +2,21 @@ [lux #* ["%" data/text/format (#+ format)] ["_" test (#+ Test)] - ["r" math/random (#+ Random)] - [abstract/monad (#+ Monad do)] - [data + [abstract + [monad (#+ do)]] + [math + ["." random (#+ Random)] [number ["n" nat] - ["." int] - ["f" frac]]]] + ["f" frac] + ["." int]]]] {1 ["." /]} ["." / #_ ["#." infix] ["#." modulus] ["#." modular] + ["#." number] ["#." logic #_ ["#/." continuous] ["#/." fuzzy]]]) @@ -36,8 +38,8 @@ (<| (_.context (%.name (name_of /._))) ($_ _.and (<| (_.context "Trigonometry") - (do {! r.monad} - [angle (|> r.safe_frac (\ ! map (f.* /.tau)))] + (do {! random.monad} + [angle (|> random.safe_frac (\ ! map (f.* /.tau)))] ($_ _.and (_.test "Sine and arc-sine are inverse functions." (trigonometric_symmetry /.sin /.asin angle)) @@ -47,8 +49,8 @@ (trigonometric_symmetry /.tan /.atan angle)) ))) (<| (_.context "Rounding") - (do {! r.monad} - [sample (|> r.safe_frac (\ ! map (f.* +1000.0)))] + (do {! random.monad} + [sample (|> random.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)] @@ -66,13 +68,13 @@ (f.<= +1.0 (f.abs (f.- sample round'd)))))) ))) (<| (_.context "Exponentials and logarithms") - (do {! r.monad} - [sample (|> r.safe_frac (\ ! map (f.* +10.0)))] + (do {! random.monad} + [sample (|> random.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))))] + (do {! random.monad} + [#let [gen_nat (|> random.nat (\ ! map (|>> (n.% 1000) (n.max 1))))] x gen_nat y gen_nat] ($_ _.and @@ -90,7 +92,9 @@ ))) /infix.test + /modulus.test /modular.test + /number.test /logic/continuous.test /logic/fuzzy.test ))) diff --git a/stdlib/source/test/lux/math/infix.lux b/stdlib/source/test/lux/math/infix.lux index f4a3552e9..785285f2d 100644 --- a/stdlib/source/test/lux/math/infix.lux +++ b/stdlib/source/test/lux/math/infix.lux @@ -4,12 +4,12 @@ [abstract [monad (#+ do)]] [data - ["." bit ("#\." equivalence)] + ["." bit ("#\." equivalence)]] + [math + ["." random] [number ["n" nat] - ["f" frac]]] - [math - ["." random]]] + ["f" frac]]]] {1 ["." / ["." //]]}) diff --git a/stdlib/source/test/lux/math/logic/continuous.lux b/stdlib/source/test/lux/math/logic/continuous.lux index dd18ad2d1..e54eccc2e 100644 --- a/stdlib/source/test/lux/math/logic/continuous.lux +++ b/stdlib/source/test/lux/math/logic/continuous.lux @@ -1,11 +1,13 @@ (.module: [lux #* - ["%" data/text/format (#+ format)] - [abstract/monad (#+ do)] ["_" test (#+ Test)] + [abstract + [monad (#+ do)] + {[0 #spec] + [/ + ["$." monoid]]}] [math - ["." random]] - [data + ["." random] [number ["r" rev]]]] {1 @@ -13,24 +15,101 @@ (def: #export test Test - (<| (_.context (%.name (name_of /._))) + (<| (_.covering /._) (do random.monad [left random.rev + mid random.rev right random.rev] - ($_ _.and - (_.test "AND is the minimum." - (let [result (/.and left right)] - (and (r.<= left result) - (r.<= right result)))) - (_.test "OR is the maximum." - (let [result (/.or left right)] - (and (r.>= left result) - (r.>= right result)))) - (_.test "Double negation results in the original value." - (r.= left (/.not (/.not left)))) - (_.test "Every value is equivalent to itself." - (and (r.>= left - (/.= left left)) - (r.>= right - (/.= right right)))) - )))) + (`` ($_ _.and + (~~ (template [] + [(_.for [] + ($monoid.spec r.= random.rev))] + + [/.disjunction] + [/.conjunction] + )) + + (_.cover [/.true /.false] + (let [true=max! + (r.= /.false (inc /.true)) + + false=min! + (r.= /.true (dec /.false))] + (and true=max! + false=min!))) + (_.cover [/.or] + (let [identity! + (r.= left (/.or /.false left)) + + annihilation! + (r.= /.true (/.or /.true left)) + + idempotence! + (r.= left (/.or left left)) + + associativity! + (r.= ($_ /.or left mid right) + (_$ /.or left mid right))] + (and identity! + annihilation! + idempotence! + associativity! + (let [l|r (/.or left right)] + (and (r.>= left l|r) + (r.>= right l|r)))))) + (_.cover [/.and] + (let [identity! + (r.= left (/.and /.true left)) + + annihilation! + (r.= /.false (/.and /.false left)) + + idempotence! + (r.= left (/.and left left)) + + associativity! + (r.= ($_ /.and left mid right) + (_$ /.and left mid right))] + (and identity! + annihilation! + idempotence! + associativity! + (let [l&r (/.and left right)] + (and (r.<= left l&r) + (r.<= right l&r)))))) + (_.cover [/.not] + (let [inverses! + (and (r.= /.false (/.not /.true)) + (r.= /.true (/.not /.false))) + + double_negation! + (r.= left (/.not (/.not left))) + + de_morgan! + (and (r.= (/.not (/.or left right)) + (/.and (/.not left) (/.not right))) + (r.= (/.not (/.and left right)) + (/.or (/.not left) (/.not right))))] + (and inverses! + double_negation! + de_morgan!))) + (_.cover [/.implies] + (let [modus_tollens! + (r.= (/.implies right left) + (/.implies (/.not left) (/.not right)))] + (and modus_tollens!))) + (_.cover [/.=] + (let [trivial! + (and (r.= /.true (/.= /.true /.true)) + (r.= /.true (/.= /.false /.false)) + + (r.= /.false (/.= /.true /.false))) + + common! + (and (r.>= left + (/.= left left)) + (r.>= right + (/.= right right)))] + (and trivial! + common!))) + ))))) diff --git a/stdlib/source/test/lux/math/logic/fuzzy.lux b/stdlib/source/test/lux/math/logic/fuzzy.lux index 476a40964..6289dd64d 100644 --- a/stdlib/source/test/lux/math/logic/fuzzy.lux +++ b/stdlib/source/test/lux/math/logic/fuzzy.lux @@ -1,20 +1,20 @@ (.module: [lux #* ["%" data/text/format (#+ format)] + ["_" test (#+ Test)] [abstract [monad (#+ do)] ["." enum]] - [math - ["." random (#+ Random)]] - ["_" test (#+ Test)] [data ["." bit ("#\." equivalence)] - [number - ["n" nat] - ["r" rev]] [collection ["." list] - ["." set]]]] + ["." set]]] + [math + ["." random (#+ Random)] + [number + ["n" nat] + ["r" rev]]]] {1 ["." / (#+ Fuzzy) [// diff --git a/stdlib/source/test/lux/math/modular.lux b/stdlib/source/test/lux/math/modular.lux index 849159da2..b0c69b814 100644 --- a/stdlib/source/test/lux/math/modular.lux +++ b/stdlib/source/test/lux/math/modular.lux @@ -15,11 +15,11 @@ ["." exception]] [data ["." product] - ["." bit ("#\." equivalence)] - [number - ["i" int]]] + ["." bit ("#\." equivalence)]] [math - ["." random (#+ Random)]]] + ["." random (#+ Random)] + [number + ["i" int]]]] ["$." // #_ ["#" modulus]] {1 diff --git a/stdlib/source/test/lux/math/modulus.lux b/stdlib/source/test/lux/math/modulus.lux index 7fec2db0d..4f3b4a2fb 100644 --- a/stdlib/source/test/lux/math/modulus.lux +++ b/stdlib/source/test/lux/math/modulus.lux @@ -1,17 +1,16 @@ (.module: [lux #* ["_" test (#+ Test)] + ["." meta] [abstract [monad (#+ do)]] [control ["." try] ["." exception]] - [data + [math + ["." random (#+ Random)] [number ["i" int]]] - [math - ["." random (#+ Random)]] - ["." meta] [macro [syntax (#+ syntax:)] ["." code]]] diff --git a/stdlib/source/test/lux/math/number.lux b/stdlib/source/test/lux/math/number.lux new file mode 100644 index 000000000..5a897db71 --- /dev/null +++ b/stdlib/source/test/lux/math/number.lux @@ -0,0 +1,108 @@ +(.module: + [lux #* + ["_" test (#+ Test)] + [control + ["." try]] + [data + ["." text]]] + {1 + ["." / + ["n" nat] + ["i" int] + ["r" rev] + ["f" frac]]} + ["." / #_ + ["#." 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 [<=> ] + [(case (\ decode (..clean_commas )) + (#try.Success actual) + (<=> (/.bin ) 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 [<=> ] + [(case (\ decode (..clean_commas )) + (#try.Success actual) + (<=> (/.oct ) 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 [<=> ] + [(case (\ decode (..clean_commas )) + (#try.Success actual) + (<=> (/.hex ) 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/math/number/complex.lux b/stdlib/source/test/lux/math/number/complex.lux new file mode 100644 index 000000000..751ec9022 --- /dev/null +++ b/stdlib/source/test/lux/math/number/complex.lux @@ -0,0 +1,287 @@ +(.module: + [lux #* + ["%" data/text/format (#+ format)] + ["_" test (#+ Test)] + [abstract + [monad (#+ do)] + {[0 #spec] + [/ + ["$." equivalence] + ["$." order] + ["$." codec]]}] + [data + [collection + ["." list ("#\." functor)]]] + ["." math + ["." random (#+ Random)]]] + {1 + ["." / + [// + ["n" nat] + ["f" frac] + ["." int]]]}) + +## This margin of error is necessary because floating-point arithmetic is not exact. +(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/math/number/frac.lux b/stdlib/source/test/lux/math/number/frac.lux new file mode 100644 index 000000000..dcaa417ed --- /dev/null +++ b/stdlib/source/test/lux/math/number/frac.lux @@ -0,0 +1,244 @@ +(.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 [ ] + [(_.for [ ] + ($monoid.spec /.equivalence ..random))] + + [/.+ /.addition] + [/.* /.multiplication] + + [/.min /.minimum] + [/.max /.maximum] + )) + (~~ (template [] + [(_.for [] + ($codec.spec /.equivalence random.safe_frac))] + + [/.binary] [/.octal] [/.decimal] [/.hex] + )) + ))) + +(with_expansions [ (as_is (host.import: java/lang/Double + ["#::." + (#static doubleToRawLongBits #manual [double] long) + (#static longBitsToDouble #manual [long] double)]))] + (for {@.old (as_is ) + @.jvm (as_is )})) + +(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 [ ($_ _.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 } + (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/math/number/i16.lux b/stdlib/source/test/lux/math/number/i16.lux new file mode 100644 index 000000000..6cf457989 --- /dev/null +++ b/stdlib/source/test/lux/math/number/i16.lux @@ -0,0 +1,38 @@ +(.module: + [lux #* + ["_" test (#+ Test)] + [abstract + [monad (#+ do)] + {[0 #spec] + [/ + ["$." equivalence]]}] + [math + ["." random (#+ Random)]]] + {1 + ["." / + ["/#" // #_ + ["i" int] + ["#." 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/math/number/i32.lux b/stdlib/source/test/lux/math/number/i32.lux new file mode 100644 index 000000000..1061cdc1b --- /dev/null +++ b/stdlib/source/test/lux/math/number/i32.lux @@ -0,0 +1,38 @@ +(.module: + [lux #* + ["_" test (#+ Test)] + [abstract + [monad (#+ do)] + {[0 #spec] + [/ + ["$." equivalence]]}] + [math + ["." random (#+ Random)]]] + {1 + ["." / + ["/#" // #_ + ["i" int] + ["#." 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/math/number/i64.lux b/stdlib/source/test/lux/math/number/i64.lux new file mode 100644 index 000000000..43e240675 --- /dev/null +++ b/stdlib/source/test/lux/math/number/i64.lux @@ -0,0 +1,282 @@ +(.module: + [lux #* + ["_" test (#+ Test)] + [data + ["." bit ("#\." equivalence)]] + [abstract + [monad (#+ do)] + {[0 #spec] + [/ + ["$." equivalence] + ["$." hash] + ["$." monoid]]}] + [math + ["." random (#+ Random)]]] + {1 + ["." / ("\." equivalence) + [// (#+ hex) + ["n" nat] + ["i" int]]]}) + +(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/math/number/i8.lux b/stdlib/source/test/lux/math/number/i8.lux new file mode 100644 index 000000000..b0903a903 --- /dev/null +++ b/stdlib/source/test/lux/math/number/i8.lux @@ -0,0 +1,38 @@ +(.module: + [lux #* + ["_" test (#+ Test)] + [abstract + [monad (#+ do)] + {[0 #spec] + [/ + ["$." equivalence]]}] + [math + ["." random (#+ Random)]]] + {1 + ["." / + ["/#" // #_ + ["i" int] + ["#." 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/math/number/int.lux b/stdlib/source/test/lux/math/number/int.lux new file mode 100644 index 000000000..3d9931ad1 --- /dev/null +++ b/stdlib/source/test/lux/math/number/int.lux @@ -0,0 +1,184 @@ +(.module: + [lux #* + ["_" test (#+ Test)] + [abstract + [monad (#+ do)] + {[0 #spec] + [/ + ["$." equivalence] + ["$." hash] + ["$." order] + ["$." enum] + ["$." interval] + ["$." monoid] + ["$." codec]]}] + [data + ["." bit ("#\." equivalence)]] + [math + ["." random (#+ Random)]]] + {1 + ["." / + [// + ["f" frac]]]}) + +(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 [ ] + [(_.for [ ] + ($monoid.spec /.equivalence random.int))] + + [/.+ /.addition] + [/.* /.multiplication] + + [/.min /.minimum] + [/.max /.maximum] + )) + (~~ (template [] + [(_.for [] + ($codec.spec /.equivalence 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/math/number/nat.lux b/stdlib/source/test/lux/math/number/nat.lux new file mode 100644 index 000000000..3de2970cc --- /dev/null +++ b/stdlib/source/test/lux/math/number/nat.lux @@ -0,0 +1,130 @@ +(.module: + [lux #* + ["_" test (#+ Test)] + [abstract + [monad (#+ do)] + {[0 #spec] + [/ + ["$." equivalence] + ["$." hash] + ["$." order] + ["$." enum] + ["$." interval] + ["$." monoid] + ["$." codec]]}] + [data + ["." bit ("#\." equivalence)]] + [math + ["." random]]] + {1 + ["." / + [// + ["f" frac]]]}) + +(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 [ ] + [(_.for [ ] + ($monoid.spec /.equivalence random.nat))] + + [/.+ /.addition] + [/.* /.multiplication] + + [/.min /.minimum] + [/.max /.maximum] + )) + (~~ (template [] + [(_.for [] + ($codec.spec /.equivalence 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/math/number/ratio.lux b/stdlib/source/test/lux/math/number/ratio.lux new file mode 100644 index 000000000..199096dab --- /dev/null +++ b/stdlib/source/test/lux/math/number/ratio.lux @@ -0,0 +1,114 @@ +(.module: + [lux #* + ["_" test (#+ Test)] + [abstract + [monad (#+ do)] + {[0 #spec] + [/ + ["$." equivalence] + ["$." order] + ["$." monoid] + ["$." codec]]}] + [data + ["." bit ("#\." equivalence)] + ["." maybe ("#\." functor)]] + [math + ["." random (#+ Random)]]] + {1 + ["." / + [// + ["n" nat ("#\." equivalence)]]]}) + +(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 [ ] + [(_.for [ ] + ($monoid.spec /.equivalence ..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/math/number/rev.lux b/stdlib/source/test/lux/math/number/rev.lux new file mode 100644 index 000000000..5b30741df --- /dev/null +++ b/stdlib/source/test/lux/math/number/rev.lux @@ -0,0 +1,164 @@ +(.module: + [lux #* + ["_" test (#+ Test)] + [abstract + [monad (#+ do)] + {[0 #spec] + [/ + ["$." equivalence] + ["$." hash] + ["$." order] + ["$." enum] + ["$." interval] + ["$." monoid] + ["$." codec]]}] + [data + ["." bit ("#\." equivalence)]] + [math + ["." random]]] + {1 + ["." / + [// (#+ hex) + ["n" nat] + ["f" frac] + ["." i64 ("#\." hash)]]]}) + +(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 [ ] + [(_.for [ ] + ($monoid.spec /.equivalence random.rev))] + + [/.+ /.addition] + + [/.min /.minimum] + [/.max /.maximum] + )) + (~~ (template [] + [(_.for [] + ($codec.spec /.equivalence random.rev))] + + [/.binary] [/.octal] [/.decimal] [/.hex] + )) + ))) + +(def: #export test + Test + (<| (_.covering /._) + (_.for [.Rev]) + (`` ($_ _.and + (~~ (template [ ] + [(_.cover [] + (/.= + (/.+ )))] + + [/./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/meta.lux b/stdlib/source/test/lux/meta.lux index 7428cae69..6997d55e3 100644 --- a/stdlib/source/test/lux/meta.lux +++ b/stdlib/source/test/lux/meta.lux @@ -12,13 +12,13 @@ ["." try]] [data ["." text ("#\." equivalence) - ["%" format (#+ format)]] - [number - ["n" nat]]] + ["%" format (#+ format)]]] [meta ["." location]] [math - ["." random (#+ Random)]]] + ["." random (#+ Random)] + [number + ["n" nat]]]] {1 ["." /]} ["." / #_ diff --git a/stdlib/source/test/lux/meta/annotation.lux b/stdlib/source/test/lux/meta/annotation.lux index 3718b8797..51b33a70b 100644 --- a/stdlib/source/test/lux/meta/annotation.lux +++ b/stdlib/source/test/lux/meta/annotation.lux @@ -1,8 +1,6 @@ (.module: [lux #* ["_" test (#+ Test)] - [math - ["." random (#+ Random)]] [abstract [monad (#+ do)]] [control @@ -11,17 +9,18 @@ ["." product] ["." bit] ["." name ("#\." equivalence)] - ["." text - ["%" format (#+ format)]] + ["." text] + [collection + ["." list ("#\." functor)]]] + [macro + ["." code ("#\." equivalence)]] + [math + ["." random (#+ Random)] [number ["." nat] ["." int] ["." rev] - ["." frac]] - [collection - ["." list ("#\." functor)]]] - [macro - ["." code ("#\." equivalence)]]] + ["." frac]]]] {1 ["." /]} [/// diff --git a/stdlib/source/test/lux/target/jvm.lux b/stdlib/source/test/lux/target/jvm.lux index 42d4eba11..3a5a79711 100644 --- a/stdlib/source/test/lux/target/jvm.lux +++ b/stdlib/source/test/lux/target/jvm.lux @@ -13,12 +13,6 @@ [data ["." maybe] ["." bit ("#\." equivalence)] - [number - ["." i32 (#+ I32)] - ["." i64] - ["n" nat] - ["i" int] - ["f" frac]] ["." text ("#\." equivalence) ["%" format (#+ format)]] ["." format #_ @@ -30,7 +24,13 @@ ["." set] ["." list ("#\." functor)]]] [math - ["." random (#+ Random) ("#\." monad)]] + ["." random (#+ Random) ("#\." monad)] + [number + ["n" nat] + ["i" int] + ["f" frac] + ["." i32 (#+ I32)] + ["." i64]]] ["_" test (#+ Test)]] {1 ["." / #_ diff --git a/stdlib/source/test/lux/time/duration.lux b/stdlib/source/test/lux/time/duration.lux index 272532324..af9d46014 100644 --- a/stdlib/source/test/lux/time/duration.lux +++ b/stdlib/source/test/lux/time/duration.lux @@ -10,12 +10,11 @@ ["$." order] ["$." monoid] ["$." codec]]}] - [data + [math + ["." random (#+ Random)] [number ["n" nat] - ["i" int]]] - [math - ["." random (#+ Random)]]] + ["i" int]]]] {1 ["." / (#+ Duration)]}) diff --git a/stdlib/source/test/lux/time/instant.lux b/stdlib/source/test/lux/time/instant.lux index cc2c0a742..65fed1248 100644 --- a/stdlib/source/test/lux/time/instant.lux +++ b/stdlib/source/test/lux/time/instant.lux @@ -13,14 +13,14 @@ [control ["." try]] [data - ["." text] + ["." text]] + [math + ["." random (#+ Random)] [number ["i" int]]] - [math - ["." random (#+ Random)]] [time ["@d" duration] - ["@date" date]]] + ["@." date]]] [// ["_." duration]] {1 diff --git a/stdlib/source/test/lux/type.lux b/stdlib/source/test/lux/type.lux index c06b89478..168ed29d1 100644 --- a/stdlib/source/test/lux/type.lux +++ b/stdlib/source/test/lux/type.lux @@ -1,17 +1,19 @@ (.module: [lux (#- type) ["%" data/text/format (#+ format)] - ["M" abstract/monad (#+ do)] - ["r" math/random (#+ Random)] ["_" test (#+ Test)] + [abstract + ["." monad (#+ do)]] [control pipe] [data ["." maybe] - [number - ["n" nat]] [collection - ["." list]]]] + ["." list]]] + [math + ["." random (#+ Random)] + [number + ["n" nat]]]] {1 ["." / ("#\." equivalence)]} ["." / #_ @@ -21,41 +23,41 @@ ["#." resource]]) (def: short - (r.Random Text) - (do {! r.monad} - [size (|> r.nat (\ ! map (n.% 10)))] - (r.unicode size))) + (Random Text) + (do {! random.monad} + [size (|> random.nat (\ ! map (n.% 10)))] + (random.unicode size))) (def: name - (r.Random Name) - (r.and ..short ..short)) + (Random Name) + (random.and ..short ..short)) (def: #export random - (r.Random Type) - (let [(^open "R\.") r.monad] - (r.rec (function (_ recur) - (let [pairG (r.and recur recur) - idG r.nat - quantifiedG (r.and (R\wrap (list)) recur)] - ($_ r.or - (r.and ..short (R\wrap (list))) - pairG - pairG - pairG - idG - idG - idG - quantifiedG - quantifiedG - pairG - (r.and ..name recur) - )))))) + (Random Type) + (let [(^open "R\.") random.monad] + (random.rec (function (_ recur) + (let [pairG (random.and recur recur) + idG random.nat + quantifiedG (random.and (R\wrap (list)) recur)] + ($_ random.or + (random.and ..short (R\wrap (list))) + pairG + pairG + pairG + idG + idG + idG + quantifiedG + quantifiedG + pairG + (random.and ..name recur) + )))))) (def: #export test Test (<| (_.context (%.name (name_of /._))) ($_ _.and - (do r.monad + (do random.monad [sample ..random] (_.test "Every type is equal to itself." (\ /.equivalence = sample sample))) @@ -83,18 +85,18 @@ (\ /.equivalence = (/.un_name base) (/.un_name aliased)))))) - (do {! r.monad} - [size (|> r.nat (\ ! map (n.% 3))) + (do {! random.monad} + [size (|> random.nat (\ ! map (n.% 3))) members (|> ..random - (r.filter (function (_ type) - (case type - (^or (#.Sum _) (#.Product _)) - #0 + (random.filter (function (_ type) + (case type + (^or (#.Sum _) (#.Product _)) + #0 - _ - #1))) + _ + #1))) (list.repeat size) - (M.seq !)) + (monad.seq !)) #let [(^open "/\.") /.equivalence (^open "list\.") (list.equivalence /.equivalence)]] (`` ($_ _.and @@ -109,17 +111,17 @@ ["tuple" /.tuple /.flatten_tuple Any] )) ))) - (do {! r.monad} - [size (|> r.nat (\ ! map (n.% 3))) - members (M.seq ! (list.repeat size ..random)) + (do {! random.monad} + [size (|> random.nat (\ ! map (n.% 3))) + members (monad.seq ! (list.repeat size ..random)) extra (|> ..random - (r.filter (function (_ type) - (case type - (^or (#.Function _) (#.Apply _)) - #0 + (random.filter (function (_ type) + (case type + (^or (#.Function _) (#.Apply _)) + #0 - _ - #1)))) + _ + #1)))) #let [(^open "/\.") /.equivalence (^open "list\.") (list.equivalence /.equivalence)]] ($_ _.and @@ -132,16 +134,16 @@ (let [[tfunc tparams] (|> extra (/.application members) /.flatten_application)] (n.= (list.size members) (list.size tparams)))) )) - (do {! r.monad} - [size (|> r.nat (\ ! map (n.% 3))) + (do {! random.monad} + [size (|> random.nat (\ ! map (n.% 3))) extra (|> ..random - (r.filter (function (_ type) - (case type - (^or (#.UnivQ _) (#.ExQ _)) - #0 + (random.filter (function (_ type) + (case type + (^or (#.UnivQ _) (#.ExQ _)) + #0 - _ - #1)))) + _ + #1)))) #let [(^open "/\.") /.equivalence]] (`` ($_ _.and (~~ (template [ ] diff --git a/stdlib/source/test/lux/type/check.lux b/stdlib/source/test/lux/type/check.lux index c41f610dc..45e648b9c 100644 --- a/stdlib/source/test/lux/type/check.lux +++ b/stdlib/source/test/lux/type/check.lux @@ -1,7 +1,6 @@ (.module: [lux (#- type) ["%" data/text/format (#+ format)] - ["r" math/random (#+ Random)] ["_" test (#+ Test)] [abstract ["." monad (#+ do)]] @@ -11,53 +10,55 @@ ["." product] ["." maybe] ["." text ("#\." equivalence)] - [number - ["n" nat]] [collection ["." list ("#\." functor)] ["." set]]] + [math + ["." random (#+ Random)] + [number + ["n" nat]]] ["." type ("#\." equivalence)]] {1 ["." /]}) ## TODO: Remove the following 3 definitions ASAP. //.type already exists... (def: short - (r.Random Text) - (r.unicode 10)) + (Random Text) + (random.unicode 10)) (def: name - (r.Random Name) - (r.and ..short ..short)) + (Random Name) + (random.and ..short ..short)) (def: (type' num_vars) - (-> Nat (r.Random Type)) - (r.rec + (-> Nat (Random Type)) + (random.rec (function (_ recur) - (let [(^open "R\.") r.monad - pairG (r.and recur recur) - quantifiedG (r.and (R\wrap (list)) (type' (inc num_vars))) - random_pair (r.either (r.either (R\map (|>> #.Sum) pairG) - (R\map (|>> #.Product) pairG)) - (r.either (R\map (|>> #.Function) pairG) - (R\map (|>> #.Apply) pairG))) - random_id (let [random_id (r.either (R\map (|>> #.Var) r.nat) - (R\map (|>> #.Ex) r.nat))] + (let [(^open "R\.") random.monad + pairG (random.and recur recur) + quantifiedG (random.and (R\wrap (list)) (type' (inc num_vars))) + random_pair (random.either (random.either (R\map (|>> #.Sum) pairG) + (R\map (|>> #.Product) pairG)) + (random.either (R\map (|>> #.Function) pairG) + (R\map (|>> #.Apply) pairG))) + random_id (let [random_id (random.either (R\map (|>> #.Var) random.nat) + (R\map (|>> #.Ex) random.nat))] (case num_vars 0 random_id - _ (r.either (R\map (|>> (n.% num_vars) (n.* 2) inc #.Parameter) r.nat) - random_id))) - random_quantified (r.either (R\map (|>> #.UnivQ) quantifiedG) - (R\map (|>> #.ExQ) quantifiedG))] - ($_ r.either - (R\map (|>> #.Primitive) (r.and ..short (R\wrap (list)))) + _ (random.either (R\map (|>> (n.% num_vars) (n.* 2) inc #.Parameter) random.nat) + random_id))) + random_quantified (random.either (R\map (|>> #.UnivQ) quantifiedG) + (R\map (|>> #.ExQ) quantifiedG))] + ($_ random.either + (R\map (|>> #.Primitive) (random.and ..short (R\wrap (list)))) random_pair random_id random_quantified - (R\map (|>> #.Named) (r.and ..name (type' 0))) + (R\map (|>> #.Named) (random.and ..name (type' 0))) ))))) (def: type - (r.Random Type) + (Random Type) (..type' 0)) (def: (valid_type? type) @@ -106,8 +107,8 @@ Test (<| (_.context (%.name (name_of /._))) ($_ _.and - (do r.monad - [sample (r.filter ..valid_type? ..type)] + (do random.monad + [sample (random.filter ..valid_type? ..type)] ($_ _.and (_.test "Any is the super-type of everything." (/.checks? Any sample)) @@ -145,7 +146,7 @@ (not (/.checks? (#.Function Any Nothing) (#.Function Nothing Any))))) ) - (do r.monad + (do random.monad [meta ..type data ..type] (_.test "Can type-check type application." @@ -153,12 +154,12 @@ (type.tuple (list meta data))) (/.checks? (type.tuple (list meta data)) (|> Ann (#.Apply meta) (#.Apply data)))))) - (do r.monad - [#let [gen_short (r.ascii 10)] + (do random.monad + [#let [gen_short (random.ascii 10)] nameL gen_short - nameR (|> gen_short (r.filter (|>> (text\= nameL) not))) + nameR (|> gen_short (random.filter (|>> (text\= nameL) not))) paramL ..type - paramR (r.filter (|>> (/.checks? paramL) not) ..type)] + paramR (random.filter (|>> (/.checks? paramL) not) ..type)] ($_ _.and (_.test "Primitive types match when they have the same name and the same parameters." (/.checks? (#.Primitive nameL (list paramL)) @@ -198,10 +199,10 @@ _ (/.check var Nothing)] (/.check .Bit var)))) ) - (do {! r.monad} - [num_connections (|> r.nat (\ ! map (n.% 100))) - boundT (|> ..type (r.filter (|>> (case> (#.Var _) #0 _ #1)))) - pick_pcg (r.and r.nat r.nat)] + (do {! random.monad} + [num_connections (|> random.nat (\ ! map (n.% 100))) + boundT (|> ..type (random.filter (|>> (case> (#.Var _) #0 _ #1)))) + pick_pcg (random.and random.nat random.nat)] ($_ _.and (_.test "Can create rings of variables." (type_checks? (do /.monad diff --git a/stdlib/source/test/lux/type/dynamic.lux b/stdlib/source/test/lux/type/dynamic.lux index 4cb4e5093..fadc98ca7 100644 --- a/stdlib/source/test/lux/type/dynamic.lux +++ b/stdlib/source/test/lux/type/dynamic.lux @@ -2,11 +2,11 @@ [lux #* ["%" data/text/format (#+ format)] [abstract/monad (#+ do)] - ["r" math/random (#+ Random)] ["_" test (#+ Test)] [control ["." try]] - [data + [math + ["." random (#+ Random)] [number ["n" nat]]]] {1 @@ -15,8 +15,8 @@ (def: #export test Test (<| (_.context (%.name (name_of /._))) - (do r.monad - [expected r.nat + (do random.monad + [expected random.nat #let [value (:dynamic expected)]] ($_ _.and (_.test "Can check dynamic values." diff --git a/stdlib/source/test/lux/type/implicit.lux b/stdlib/source/test/lux/type/implicit.lux index f78637b1b..4978a9b3a 100644 --- a/stdlib/source/test/lux/type/implicit.lux +++ b/stdlib/source/test/lux/type/implicit.lux @@ -9,12 +9,12 @@ ["." enum]] [data ["." bit ("#\." equivalence)] - [number - ["n" nat]] [collection ["." list]]] [math - ["." random (#+ Random)]]] + ["." random (#+ Random)] + [number + ["n" nat]]]] {1 ["." /]}) diff --git a/stdlib/source/test/lux/type/resource.lux b/stdlib/source/test/lux/type/resource.lux index 7f84dcd2b..54150772e 100644 --- a/stdlib/source/test/lux/type/resource.lux +++ b/stdlib/source/test/lux/type/resource.lux @@ -1,14 +1,13 @@ (.module: [lux #* ["%" data/text/format (#+ format)] - ["r" math/random (#+ Random)] ["_" test (#+ Test)] [abstract [monad [indexed (#+ do)]]] [control ["." io]] - [data + [math [number ["n" nat]]]] {1 diff --git a/stdlib/source/test/lux/world/file.lux b/stdlib/source/test/lux/world/file.lux index 173bd7586..b59202972 100644 --- a/stdlib/source/test/lux/world/file.lux +++ b/stdlib/source/test/lux/world/file.lux @@ -1,7 +1,6 @@ (.module: [lux #* ["%" data/text/format (#+ format)] - ["r" math/random (#+ Random) ("#\." monad)] ["_" test (#+ Test)] [abstract/monad (#+ do)] [control @@ -14,11 +13,13 @@ [data ["." binary (#+ Binary)] ["." text] - [number - ["n" nat] - ["i" int]] [collection ["." list]]] + [math + ["." random (#+ Random) ("#\." monad)] + [number + ["n" nat] + ["i" int]]] [time ["." instant] ["." duration]]] @@ -36,49 +37,51 @@ (def: (creation_and_deletion number) (-> Nat Test) - (r\wrap (do promise.monad - [#let [path (format "temp_file_" (%.nat number))] - result (promise.future - (do (try.with io.monad) - [#let [check_existence! (: (IO (Try Bit)) - (try.lift io.monad (/.exists? io.monad /.default path)))] - pre! check_existence! - file (!.use (\ /.default create_file) path) - post! check_existence! - _ (!.use (\ file delete) []) - remains? check_existence!] - (wrap (and (not pre!) - post! - (not remains?)))))] - (_.assert "Can create/delete files." - (try.default #0 result))))) + (random\wrap + (do promise.monad + [#let [path (format "temp_file_" (%.nat number))] + result (promise.future + (do (try.with io.monad) + [#let [check_existence! (: (IO (Try Bit)) + (try.lift io.monad (/.exists? io.monad /.default path)))] + pre! check_existence! + file (!.use (\ /.default create_file) path) + post! check_existence! + _ (!.use (\ file delete) []) + remains? check_existence!] + (wrap (and (not pre!) + post! + (not remains?)))))] + (_.assert "Can create/delete files." + (try.default #0 result))))) (def: (read_and_write number data) (-> Nat Binary Test) - (r\wrap (do promise.monad - [#let [path (format "temp_file_" (%.nat number))] - result (promise.future - (do (try.with io.monad) - [file (!.use (\ /.default create_file) path) - _ (!.use (\ file over_write) data) - content (!.use (\ file content) []) - _ (!.use (\ file delete) [])] - (wrap (\ binary.equivalence = data content))))] - (_.assert "Can write/read files." - (try.default #0 result))))) + (random\wrap + (do promise.monad + [#let [path (format "temp_file_" (%.nat number))] + result (promise.future + (do (try.with io.monad) + [file (!.use (\ /.default create_file) path) + _ (!.use (\ file over_write) data) + content (!.use (\ file content) []) + _ (!.use (\ file delete) [])] + (wrap (\ binary.equivalence = data content))))] + (_.assert "Can write/read files." + (try.default #0 result))))) (def: #export test Test (<| (_.context (%.name (name_of /._))) - (do {! r.monad} - [file_size (|> r.nat (\ ! map (|>> (n.% 100) (n.max 10)))) + (do {! random.monad} + [file_size (|> random.nat (\ ! map (|>> (n.% 100) (n.max 10)))) dataL (_binary.random file_size) dataR (_binary.random file_size) - new_modified (|> r.int (\ ! map (|>> i.abs - (i.% +10,000,000,000,000) - truncate_millis - duration.from_millis - instant.absolute)))] + new_modified (|> random.int (\ ! map (|>> i.abs + (i.% +10,000,000,000,000) + truncate_millis + duration.from_millis + instant.absolute)))] ($_ _.and ## (..creation_and_deletion 0) ## (..read_and_write 1 dataL) @@ -152,12 +155,12 @@ ## [dir (!.use (\ /.default create_directory) dir_path) ## pre_files (!.use (\ dir files) []) ## pre_directories (!.use (\ dir directories) []) - + ## file (!.use (\ /.default create_file) (format dir_path "/" file_path)) ## inner_dir (!.use (\ /.default create_directory) (format dir_path "/" inner_dir_path)) ## post_files (!.use (\ dir files) []) ## post_directories (!.use (\ dir directories) []) - + ## _ (!.use (\ file delete) []) ## _ (!.use (\ inner_dir discard) []) ## _ (!.use (\ dir discard) [])] diff --git a/stdlib/source/test/lux/world/shell.lux b/stdlib/source/test/lux/world/shell.lux index 1dbe5dcd5..a336de350 100644 --- a/stdlib/source/test/lux/world/shell.lux +++ b/stdlib/source/test/lux/world/shell.lux @@ -16,13 +16,13 @@ ["." environment (#+ Environment)]]] [data ["." text ("#\." equivalence)] - [number - ["n" nat] - ["i" int]] [collection ["." list]]] [math - ["." random]]] + ["." random] + [number + ["n" nat] + ["i" int]]]] {1 ["." / [// -- cgit v1.2.3