From 0abd5bd3c0e38e352e9ba38268e04e1c858ab01e Mon Sep 17 00:00:00 2001 From: Eduardo Julian Date: Thu, 15 Jul 2021 00:45:15 -0400 Subject: Re-named "spec" hierarchy to "specification". --- documentation/bookmark/compiler.md | 6 + documentation/bookmark/floating_point.md | 5 + documentation/bookmark/inspiration.md | 2 +- documentation/bookmark/logging.md | 1 + documentation/bookmark/money.md | 4 + documentation/bookmark/platform/js.md | 4 + documentation/bookmark/platform/jvm.md | 1 + documentation/bookmark/platform/ruby.md | 4 + .../bookmark/probabilistic_data_structure.md | 1 + documentation/bookmark/process.md | 8 + documentation/bookmark/program_transformation.md | 4 + documentation/bookmark/regular_expression.md | 4 + documentation/bookmark/time.md | 3 + documentation/bookmark/type_theory.md | 7 + .../bookmark/type_theory/cost_analysis.md | 1 + .../bookmark/type_theory/dependent_types.md | 1 + documentation/bookmark/type_theory/linear.md | 4 + documentation/bookmark/type_theory/unit.md | 4 + documentation/bookmark/user_interface/graphic.md | 1 + stdlib/source/library/lux/ffi.lua.lux | 2 +- stdlib/source/library/lux/math.lux | 3 + stdlib/source/library/lux/world/console.lux | 16 +- stdlib/source/spec/aedifex/repository.lux | 57 ---- stdlib/source/spec/compositor.lux | 67 ---- stdlib/source/spec/compositor/analysis/type.lux | 63 ---- stdlib/source/spec/compositor/common.lux | 81 ----- stdlib/source/spec/compositor/generation/case.lux | 288 ----------------- .../source/spec/compositor/generation/common.lux | 343 -------------------- .../source/spec/compositor/generation/function.lux | 93 ------ .../spec/compositor/generation/primitive.lux | 48 --- .../spec/compositor/generation/reference.lux | 60 ---- .../spec/compositor/generation/structure.lux | 89 ------ stdlib/source/spec/lux/abstract/apply.lux | 73 ----- stdlib/source/spec/lux/abstract/codec.lux | 27 -- stdlib/source/spec/lux/abstract/comonad.lux | 61 ---- stdlib/source/spec/lux/abstract/enum.lux | 27 -- stdlib/source/spec/lux/abstract/equivalence.lux | 24 -- stdlib/source/spec/lux/abstract/fold.lux | 23 -- stdlib/source/spec/lux/abstract/functor.lux | 62 ---- .../spec/lux/abstract/functor/contravariant.lux | 31 -- stdlib/source/spec/lux/abstract/hash.lux | 23 -- stdlib/source/spec/lux/abstract/interval.lux | 23 -- stdlib/source/spec/lux/abstract/monad.lux | 57 ---- stdlib/source/spec/lux/abstract/monoid.lux | 32 -- stdlib/source/spec/lux/abstract/order.lux | 58 ---- stdlib/source/spec/lux/world/console.lux | 58 ---- stdlib/source/spec/lux/world/file.lux | 351 --------------------- stdlib/source/spec/lux/world/program.lux | 32 -- stdlib/source/spec/lux/world/shell.lux | 92 ------ stdlib/source/specification/aedifex/repository.lux | 57 ++++ stdlib/source/specification/compositor.lux | 67 ++++ .../specification/compositor/analysis/type.lux | 63 ++++ stdlib/source/specification/compositor/common.lux | 81 +++++ .../specification/compositor/generation/case.lux | 288 +++++++++++++++++ .../specification/compositor/generation/common.lux | 343 ++++++++++++++++++++ .../compositor/generation/function.lux | 93 ++++++ .../compositor/generation/primitive.lux | 48 +++ .../compositor/generation/reference.lux | 60 ++++ .../compositor/generation/structure.lux | 89 ++++++ stdlib/source/specification/lux/abstract/apply.lux | 73 +++++ stdlib/source/specification/lux/abstract/codec.lux | 27 ++ .../source/specification/lux/abstract/comonad.lux | 61 ++++ stdlib/source/specification/lux/abstract/enum.lux | 27 ++ .../specification/lux/abstract/equivalence.lux | 24 ++ stdlib/source/specification/lux/abstract/fold.lux | 23 ++ .../source/specification/lux/abstract/functor.lux | 62 ++++ .../lux/abstract/functor/contravariant.lux | 31 ++ stdlib/source/specification/lux/abstract/hash.lux | 23 ++ .../source/specification/lux/abstract/interval.lux | 23 ++ stdlib/source/specification/lux/abstract/monad.lux | 57 ++++ .../source/specification/lux/abstract/monoid.lux | 32 ++ stdlib/source/specification/lux/abstract/order.lux | 58 ++++ stdlib/source/specification/lux/world/console.lux | 58 ++++ stdlib/source/specification/lux/world/file.lux | 351 +++++++++++++++++++++ stdlib/source/specification/lux/world/program.lux | 32 ++ stdlib/source/specification/lux/world/shell.lux | 92 ++++++ stdlib/source/test/aedifex/artifact.lux | 2 +- stdlib/source/test/aedifex/artifact/snapshot.lux | 2 +- .../test/aedifex/artifact/snapshot/build.lux | 2 +- .../test/aedifex/artifact/snapshot/stamp.lux | 2 +- .../source/test/aedifex/artifact/snapshot/time.lux | 2 +- .../test/aedifex/artifact/snapshot/version.lux | 2 +- .../aedifex/artifact/snapshot/version/value.lux | 2 +- stdlib/source/test/aedifex/artifact/time.lux | 2 +- stdlib/source/test/aedifex/artifact/versioning.lux | 2 +- stdlib/source/test/aedifex/cli.lux | 2 +- stdlib/source/test/aedifex/dependency.lux | 2 +- .../source/test/aedifex/dependency/resolution.lux | 2 +- stdlib/source/test/aedifex/dependency/status.lux | 2 +- stdlib/source/test/aedifex/hash.lux | 2 +- stdlib/source/test/aedifex/metadata/artifact.lux | 2 +- stdlib/source/test/aedifex/metadata/snapshot.lux | 2 +- stdlib/source/test/aedifex/package.lux | 2 +- stdlib/source/test/aedifex/profile.lux | 2 +- stdlib/source/test/aedifex/project.lux | 2 +- stdlib/source/test/aedifex/repository.lux | 2 +- stdlib/source/test/aedifex/repository/identity.lux | 2 +- stdlib/source/test/aedifex/repository/origin.lux | 2 +- stdlib/source/test/lux/abstract/comonad/cofree.lux | 2 +- stdlib/source/test/lux/abstract/equivalence.lux | 2 +- stdlib/source/test/lux/abstract/hash.lux | 2 +- stdlib/source/test/lux/abstract/interval.lux | 2 +- stdlib/source/test/lux/abstract/monad/free.lux | 2 +- stdlib/source/test/lux/abstract/order.lux | 2 +- stdlib/source/test/lux/abstract/predicate.lux | 2 +- stdlib/source/test/lux/control/concurrency/frp.lux | 2 +- .../test/lux/control/concurrency/promise.lux | 2 +- stdlib/source/test/lux/control/concurrency/stm.lux | 2 +- stdlib/source/test/lux/control/continuation.lux | 2 +- stdlib/source/test/lux/control/function.lux | 2 +- stdlib/source/test/lux/control/function/mixin.lux | 2 +- stdlib/source/test/lux/control/io.lux | 2 +- stdlib/source/test/lux/control/parser.lux | 2 +- stdlib/source/test/lux/control/reader.lux | 2 +- stdlib/source/test/lux/control/region.lux | 2 +- stdlib/source/test/lux/control/security/policy.lux | 2 +- stdlib/source/test/lux/control/state.lux | 2 +- stdlib/source/test/lux/control/thread.lux | 2 +- stdlib/source/test/lux/control/try.lux | 2 +- stdlib/source/test/lux/control/writer.lux | 2 +- stdlib/source/test/lux/data/binary.lux | 2 +- stdlib/source/test/lux/data/bit.lux | 2 +- stdlib/source/test/lux/data/collection/array.lux | 2 +- stdlib/source/test/lux/data/collection/bits.lux | 2 +- .../source/test/lux/data/collection/dictionary.lux | 2 +- .../lux/data/collection/dictionary/ordered.lux | 2 +- .../test/lux/data/collection/dictionary/plist.lux | 2 +- stdlib/source/test/lux/data/collection/list.lux | 2 +- stdlib/source/test/lux/data/collection/queue.lux | 2 +- stdlib/source/test/lux/data/collection/row.lux | 2 +- .../source/test/lux/data/collection/sequence.lux | 2 +- stdlib/source/test/lux/data/collection/set.lux | 2 +- .../source/test/lux/data/collection/set/multi.lux | 2 +- .../test/lux/data/collection/set/ordered.lux | 2 +- stdlib/source/test/lux/data/collection/stack.lux | 2 +- stdlib/source/test/lux/data/collection/tree.lux | 2 +- .../test/lux/data/collection/tree/zipper.lux | 2 +- stdlib/source/test/lux/data/color.lux | 2 +- stdlib/source/test/lux/data/format/binary.lux | 2 +- stdlib/source/test/lux/data/format/json.lux | 2 +- stdlib/source/test/lux/data/format/xml.lux | 2 +- stdlib/source/test/lux/data/identity.lux | 2 +- stdlib/source/test/lux/data/lazy.lux | 2 +- stdlib/source/test/lux/data/maybe.lux | 2 +- stdlib/source/test/lux/data/name.lux | 2 +- stdlib/source/test/lux/data/product.lux | 2 +- stdlib/source/test/lux/data/sum.lux | 2 +- stdlib/source/test/lux/data/text.lux | 2 +- stdlib/source/test/lux/data/text/encoding.lux | 2 +- stdlib/source/test/lux/data/text/encoding/utf8.lux | 2 +- stdlib/source/test/lux/data/text/format.lux | 2 +- stdlib/source/test/lux/data/text/unicode/block.lux | 2 +- stdlib/source/test/lux/data/text/unicode/set.lux | 2 +- stdlib/source/test/lux/ffi.lua.lux | 54 +++- stdlib/source/test/lux/locale.lux | 2 +- stdlib/source/test/lux/locale/language.lux | 2 +- stdlib/source/test/lux/locale/territory.lux | 2 +- stdlib/source/test/lux/macro/code.lux | 2 +- stdlib/source/test/lux/macro/poly/equivalence.lux | 2 +- stdlib/source/test/lux/macro/poly/json.lux | 2 +- .../source/test/lux/macro/syntax/annotations.lux | 2 +- stdlib/source/test/lux/macro/syntax/check.lux | 2 +- .../source/test/lux/macro/syntax/declaration.lux | 2 +- stdlib/source/test/lux/macro/syntax/definition.lux | 2 +- stdlib/source/test/lux/macro/syntax/input.lux | 2 +- .../source/test/lux/macro/syntax/type/variable.lux | 2 +- stdlib/source/test/lux/math.lux | 11 + stdlib/source/test/lux/math/logic/continuous.lux | 2 +- stdlib/source/test/lux/math/logic/fuzzy.lux | 2 +- stdlib/source/test/lux/math/modular.lux | 2 +- stdlib/source/test/lux/math/number/complex.lux | 2 +- stdlib/source/test/lux/math/number/frac.lux | 2 +- stdlib/source/test/lux/math/number/i16.lux | 2 +- stdlib/source/test/lux/math/number/i32.lux | 2 +- stdlib/source/test/lux/math/number/i64.lux | 2 +- stdlib/source/test/lux/math/number/i8.lux | 2 +- stdlib/source/test/lux/math/number/int.lux | 2 +- stdlib/source/test/lux/math/number/nat.lux | 2 +- stdlib/source/test/lux/math/number/ratio.lux | 2 +- stdlib/source/test/lux/math/number/rev.lux | 2 +- stdlib/source/test/lux/meta.lux | 2 +- stdlib/source/test/lux/meta/location.lux | 2 +- stdlib/source/test/lux/test.lux | 56 +++- stdlib/source/test/lux/time.lux | 2 +- stdlib/source/test/lux/time/date.lux | 2 +- stdlib/source/test/lux/time/day.lux | 2 +- stdlib/source/test/lux/time/duration.lux | 2 +- stdlib/source/test/lux/time/instant.lux | 2 +- stdlib/source/test/lux/time/month.lux | 2 +- stdlib/source/test/lux/time/year.lux | 2 +- stdlib/source/test/lux/type.lux | 2 +- stdlib/source/test/lux/type/check.lux | 2 +- stdlib/source/test/lux/type/quotient.lux | 2 +- stdlib/source/test/lux/type/unit.lux | 2 +- stdlib/source/test/lux/world/console.lux | 2 +- stdlib/source/test/lux/world/file.lux | 2 +- stdlib/source/test/lux/world/file/watch.lux | 13 + .../test/lux/world/output/video/resolution.lux | 2 +- stdlib/source/test/lux/world/program.lux | 2 +- stdlib/source/test/lux/world/shell.lux | 2 +- 200 files changed, 2563 insertions(+), 2383 deletions(-) create mode 100644 documentation/bookmark/money.md create mode 100644 documentation/bookmark/platform/js.md create mode 100644 documentation/bookmark/platform/ruby.md create mode 100644 documentation/bookmark/program_transformation.md create mode 100644 documentation/bookmark/regular_expression.md create mode 100644 documentation/bookmark/type_theory.md create mode 100644 documentation/bookmark/type_theory/linear.md create mode 100644 documentation/bookmark/type_theory/unit.md delete mode 100644 stdlib/source/spec/aedifex/repository.lux delete mode 100644 stdlib/source/spec/compositor.lux delete mode 100644 stdlib/source/spec/compositor/analysis/type.lux delete mode 100644 stdlib/source/spec/compositor/common.lux delete mode 100644 stdlib/source/spec/compositor/generation/case.lux delete mode 100644 stdlib/source/spec/compositor/generation/common.lux delete mode 100644 stdlib/source/spec/compositor/generation/function.lux delete mode 100644 stdlib/source/spec/compositor/generation/primitive.lux delete mode 100644 stdlib/source/spec/compositor/generation/reference.lux delete mode 100644 stdlib/source/spec/compositor/generation/structure.lux delete mode 100644 stdlib/source/spec/lux/abstract/apply.lux delete mode 100644 stdlib/source/spec/lux/abstract/codec.lux delete mode 100644 stdlib/source/spec/lux/abstract/comonad.lux delete mode 100644 stdlib/source/spec/lux/abstract/enum.lux delete mode 100644 stdlib/source/spec/lux/abstract/equivalence.lux delete mode 100644 stdlib/source/spec/lux/abstract/fold.lux delete mode 100644 stdlib/source/spec/lux/abstract/functor.lux delete mode 100644 stdlib/source/spec/lux/abstract/functor/contravariant.lux delete mode 100644 stdlib/source/spec/lux/abstract/hash.lux delete mode 100644 stdlib/source/spec/lux/abstract/interval.lux delete mode 100644 stdlib/source/spec/lux/abstract/monad.lux delete mode 100644 stdlib/source/spec/lux/abstract/monoid.lux delete mode 100644 stdlib/source/spec/lux/abstract/order.lux delete mode 100644 stdlib/source/spec/lux/world/console.lux delete mode 100644 stdlib/source/spec/lux/world/file.lux delete mode 100644 stdlib/source/spec/lux/world/program.lux delete mode 100644 stdlib/source/spec/lux/world/shell.lux create mode 100644 stdlib/source/specification/aedifex/repository.lux create mode 100644 stdlib/source/specification/compositor.lux create mode 100644 stdlib/source/specification/compositor/analysis/type.lux create mode 100644 stdlib/source/specification/compositor/common.lux create mode 100644 stdlib/source/specification/compositor/generation/case.lux create mode 100644 stdlib/source/specification/compositor/generation/common.lux create mode 100644 stdlib/source/specification/compositor/generation/function.lux create mode 100644 stdlib/source/specification/compositor/generation/primitive.lux create mode 100644 stdlib/source/specification/compositor/generation/reference.lux create mode 100644 stdlib/source/specification/compositor/generation/structure.lux create mode 100644 stdlib/source/specification/lux/abstract/apply.lux create mode 100644 stdlib/source/specification/lux/abstract/codec.lux create mode 100644 stdlib/source/specification/lux/abstract/comonad.lux create mode 100644 stdlib/source/specification/lux/abstract/enum.lux create mode 100644 stdlib/source/specification/lux/abstract/equivalence.lux create mode 100644 stdlib/source/specification/lux/abstract/fold.lux create mode 100644 stdlib/source/specification/lux/abstract/functor.lux create mode 100644 stdlib/source/specification/lux/abstract/functor/contravariant.lux create mode 100644 stdlib/source/specification/lux/abstract/hash.lux create mode 100644 stdlib/source/specification/lux/abstract/interval.lux create mode 100644 stdlib/source/specification/lux/abstract/monad.lux create mode 100644 stdlib/source/specification/lux/abstract/monoid.lux create mode 100644 stdlib/source/specification/lux/abstract/order.lux create mode 100644 stdlib/source/specification/lux/world/console.lux create mode 100644 stdlib/source/specification/lux/world/file.lux create mode 100644 stdlib/source/specification/lux/world/program.lux create mode 100644 stdlib/source/specification/lux/world/shell.lux diff --git a/documentation/bookmark/compiler.md b/documentation/bookmark/compiler.md index 326bfff9b..5d582a174 100644 --- a/documentation/bookmark/compiler.md +++ b/documentation/bookmark/compiler.md @@ -1,8 +1,14 @@ +# Methodology + +1. [Collapsing Towers of Interpreters](https://www.cs.purdue.edu/homes/rompf/papers/amin-popl18.pdf) +1. [Miniphases: Compilation using Modular and Efficient Tree Transformations](https://infoscience.epfl.ch/record/228518/files/paper.pdf) + # Security 1. [A Brief Tour of Formally Secure Compilation](http://ceur-ws.org/Vol-2315/paper03.pdf) # Framework +1. [The GENTLE Compiler Construction System](http://gentle.compilertools.net/index.html) 1. [Nanopass Framework: Clean Compiler Creation Language](http://nanopass.org/) diff --git a/documentation/bookmark/floating_point.md b/documentation/bookmark/floating_point.md index 55c84d2f2..56cbc3eb9 100644 --- a/documentation/bookmark/floating_point.md +++ b/documentation/bookmark/floating_point.md @@ -1,3 +1,7 @@ +# Comparison + +1. [Approximate Equality for Floating Point](https://github.com/apple/swift-evolution/blob/master/proposals/0259-approximately-equal.md) + # Random generation 1. [Uniform random floats: How to generate a double-precision floating-point number in [0, 1] uniformly at random given a uniform random source of bits](https://mumble.net/~campbell/2014/04/28/uniform-random-float) @@ -12,6 +16,7 @@ # Reference +1. [How Java’s Floating-Point Hurts Everyone Everywhere](https://people.eecs.berkeley.edu/~wkahan/JAVAhurt.pdf) 1. [What aspect of portable floating point did Java back down on?](https://retrocomputing.stackexchange.com/questions/18143/what-aspect-of-portable-floating-point-did-java-back-down-on) # Algorithm diff --git a/documentation/bookmark/inspiration.md b/documentation/bookmark/inspiration.md index be02d1bd7..87b095b6f 100644 --- a/documentation/bookmark/inspiration.md +++ b/documentation/bookmark/inspiration.md @@ -39,7 +39,7 @@ 1. [Local State is Poison](https://awelonblue.wordpress.com/2012/10/21/local-state-is-poison/) 1. [The dark side of ergonomics](https://vorner.github.io/2018/04/08/Dark-side-of-ergonomics.html) -1. []() +1. [A Plea for Lean Software](https://cr.yp.to/bib/1995/wirth.pdf) # Robustness diff --git a/documentation/bookmark/logging.md b/documentation/bookmark/logging.md index cb4cc64ed..8f89b529e 100644 --- a/documentation/bookmark/logging.md +++ b/documentation/bookmark/logging.md @@ -1,5 +1,6 @@ # Reference +1. [The Value of Correlation IDs](https://www.rapid7.com/blog/post/2016/12/23/the-value-of-correlation-ids/) 1. [IceCream — Never use print() to debug again](https://github.com/gruns/icecream) 1. [Capabilities of Elixir's Logger](https://blog.appsignal.com/2020/10/13/capabilities-of-elixir-logger.html) diff --git a/documentation/bookmark/money.md b/documentation/bookmark/money.md new file mode 100644 index 000000000..ecae99905 --- /dev/null +++ b/documentation/bookmark/money.md @@ -0,0 +1,4 @@ +# Reference + +1. [Dinero.js: Dinero.js is a library for working with monetary values in JavaScript.](https://dinerojs.com/) + diff --git a/documentation/bookmark/platform/js.md b/documentation/bookmark/platform/js.md new file mode 100644 index 000000000..4a5a5b4c0 --- /dev/null +++ b/documentation/bookmark/platform/js.md @@ -0,0 +1,4 @@ +# Reference + +1. [Maybe you don't need Rust and WASM to speed up your JS ](https://mrale.ph/blog/2018/02/03/maybe-you-dont-need-rust-to-speed-up-your-js.html) + diff --git a/documentation/bookmark/platform/jvm.md b/documentation/bookmark/platform/jvm.md index db2b13a6c..7e8969b91 100644 --- a/documentation/bookmark/platform/jvm.md +++ b/documentation/bookmark/platform/jvm.md @@ -1,5 +1,6 @@ # Reference +1. [Beware of computation in static initializer](https://pangin.pro/posts/computation-in-static-initializer) 1. [JVM Internals](https://blog.jamesdbloom.com/JVMInternals.html) 1. [JVM Anatomy Quarks](https://shipilev.net/jvm/anatomy-quarks/) diff --git a/documentation/bookmark/platform/ruby.md b/documentation/bookmark/platform/ruby.md new file mode 100644 index 000000000..8b124a598 --- /dev/null +++ b/documentation/bookmark/platform/ruby.md @@ -0,0 +1,4 @@ +# Reference + +1. [Weird Ruby: Positive and Negative Strings](https://metaredux.com/posts/2019/05/10/weird-ruby-positive-and-negative-strings.html) + diff --git a/documentation/bookmark/probabilistic_data_structure.md b/documentation/bookmark/probabilistic_data_structure.md index 0e1fe5986..10529136d 100644 --- a/documentation/bookmark/probabilistic_data_structure.md +++ b/documentation/bookmark/probabilistic_data_structure.md @@ -5,6 +5,7 @@ # Reference +1. [Ribbon filter: practically smaller than Bloom and Xor](https://arxiv.org/abs/2103.02515) 1. [Teaching Bloom Filters new tricks](https://toao.com/blog/teaching-bloom-filters-new-tricks) 1. [Xor Filters: Faster and Smaller Than Bloom Filters](https://lemire.me/blog/2019/12/19/xor-filters-faster-and-smaller-than-bloom-filters/) 1. [Morton Filters: Faster, Space-Efficient Cuckoo Filters via Biasing, Compression, and Decoupled Logical Sparsity](http://www.vldb.org/pvldb/vol11/p1041-breslow.pdf) diff --git a/documentation/bookmark/process.md b/documentation/bookmark/process.md index be1326cbb..e13ea3a19 100644 --- a/documentation/bookmark/process.md +++ b/documentation/bookmark/process.md @@ -1,3 +1,11 @@ +# Architecture + +1. [Why Write ADRs](https://github.blog/2020-08-13-why-write-adrs/) + +# Release + +1. [semantic-release: Fully automated version management and package publishing](https://github.com/semantic-release/semantic-release) + # Reference 1. [Conventional Commits: A specification for adding human and machine readable meaning to commit messages](https://www.conventionalcommits.org/en/v1.0.0/) diff --git a/documentation/bookmark/program_transformation.md b/documentation/bookmark/program_transformation.md new file mode 100644 index 000000000..a29095910 --- /dev/null +++ b/documentation/bookmark/program_transformation.md @@ -0,0 +1,4 @@ +# Reference + +1. [The Program Transformation Wiki](http://program-transformation.org/) + diff --git a/documentation/bookmark/regular_expression.md b/documentation/bookmark/regular_expression.md new file mode 100644 index 000000000..584f5649d --- /dev/null +++ b/documentation/bookmark/regular_expression.md @@ -0,0 +1,4 @@ +# Reference + +1. [Paper: Hyperscan: A Fast Multi-pattern Regex Matcher for Modern CPUs](https://branchfree.org/2019/02/28/paper-hyperscan-a-fast-multi-pattern-regex-matcher-for-modern-cpus/) + diff --git a/documentation/bookmark/time.md b/documentation/bookmark/time.md index caa6f16a6..6053c5d87 100644 --- a/documentation/bookmark/time.md +++ b/documentation/bookmark/time.md @@ -1,4 +1,7 @@ # Reference +1. [Calendarific: Worldwide Holidays and Observances RESTful API](https://calendarific.com/) +1. [UTC with Smoothed Leap Seconds (UTC-SLS)](https://www.cl.cam.ac.uk/~mgk25/time/utc-sls/) +1. [Hashed and Hierarchical Timing Wheels](https://paulcavallaro.com/blog/hashed-and-hierarchical-timing-wheels/) 1. [Storing UTC is not a silver bullet](https://codeblog.jonskeet.uk/2019/03/27/storing-utc-is-not-a-silver-bullet/) diff --git a/documentation/bookmark/type_theory.md b/documentation/bookmark/type_theory.md new file mode 100644 index 000000000..b27a26a37 --- /dev/null +++ b/documentation/bookmark/type_theory.md @@ -0,0 +1,7 @@ +# Reference + +1. [Statically typed PostgreSQL queries in TypeScript](https://www.cs.mcgill.ca/~mxia3/2016/11/18/Statically-typed-PostgreSQL-queries-and-typescript-schemats/) +1. [Lambdas are Codatatypes](http://blog.ielliott.io/lambdas-are-codatatypes/) +1. [SPL LIFT— Statically Analyzing Software Product Linesin Minutes Instead of Years](https://www.bodden.de/pubs/bmb+13spllift.pdf) +1. [jQuery, but for types](https://willcrichton.net/notes/jquery-for-types/) + diff --git a/documentation/bookmark/type_theory/cost_analysis.md b/documentation/bookmark/type_theory/cost_analysis.md index 6e92c792e..61f16fe8d 100644 --- a/documentation/bookmark/type_theory/cost_analysis.md +++ b/documentation/bookmark/type_theory/cost_analysis.md @@ -1,4 +1,5 @@ # Reference +1. [TiML: a functional language for practical complexity analysis with invariants](https://dl.acm.org/doi/10.1145/3133903) 1. [Liquidate Your Assets: Reasoning about Resource Usage in Liquid Haskell](http://www.cs.nott.ac.uk/~pszgmh/liquidate.pdf) diff --git a/documentation/bookmark/type_theory/dependent_types.md b/documentation/bookmark/type_theory/dependent_types.md index 68fef10f3..c46522210 100644 --- a/documentation/bookmark/type_theory/dependent_types.md +++ b/documentation/bookmark/type_theory/dependent_types.md @@ -5,6 +5,7 @@ # Reference +1. [Programming up to Congruence](http://www.cs.yale.edu/homes/vilhelm/papers/popl15congruence.pdf) 1. [From Scheme to Dependent Types in 100 lines by Gershom Bazerman (Part 1)](https://vimeo.com/134561872) 1. [From Scheme to Dependent Types in 100 Lines by Gershom Bazerman (Part 2)](https://vimeo.com/135746080) 1. [Program = Proof](http://www.lix.polytechnique.fr/Labo/Samuel.Mimram/teaching/INF551/course.pdf) diff --git a/documentation/bookmark/type_theory/linear.md b/documentation/bookmark/type_theory/linear.md new file mode 100644 index 000000000..00f70e422 --- /dev/null +++ b/documentation/bookmark/type_theory/linear.md @@ -0,0 +1,4 @@ +# Reference + +1. [Chu construction on linear logic](http://boxbase.org/entries/2019/jul/15/chu-construction/) + diff --git a/documentation/bookmark/type_theory/unit.md b/documentation/bookmark/type_theory/unit.md new file mode 100644 index 000000000..5f5306117 --- /dev/null +++ b/documentation/bookmark/type_theory/unit.md @@ -0,0 +1,4 @@ +# Reference + +1. [unittyped: An extendable library for type-safe computations including units.](https://hackage.haskell.org/package/unittyped) + diff --git a/documentation/bookmark/user_interface/graphic.md b/documentation/bookmark/user_interface/graphic.md index 35d3115ec..43304c329 100644 --- a/documentation/bookmark/user_interface/graphic.md +++ b/documentation/bookmark/user_interface/graphic.md @@ -4,6 +4,7 @@ # Widget +1. [imask.js: vanilla javascript input mask](https://imask.js.org/) 1. [Progress bar.js](https://kimmobrunfeldt.github.io/progressbar.js/) # Design diff --git a/stdlib/source/library/lux/ffi.lua.lux b/stdlib/source/library/lux/ffi.lua.lux index 0099865f5..bb224c575 100644 --- a/stdlib/source/library/lux/ffi.lua.lux +++ b/stdlib/source/library/lux/ffi.lua.lux @@ -27,7 +27,7 @@ (template [] [(with_expansions [ (template.identifier [ "'"])] - (abstract: #export Any) + (abstract: Any) (type: #export (..Object )))] diff --git a/stdlib/source/library/lux/math.lux b/stdlib/source/library/lux/math.lux index 0070bcfa3..65c3c01d0 100644 --- a/stdlib/source/library/lux/math.lux +++ b/stdlib/source/library/lux/math.lux @@ -36,6 +36,9 @@ [ceil "jvm invokestatic:java.lang.Math:ceil:double"] [floor "jvm invokestatic:java.lang.Math:floor:double"] + + [root/2 "jvm invokestatic:java.lang.Math:sqrt:double"] + [root/3 "jvm invokestatic:java.lang.Math:cbrt:double"] ) (def: #export (pow param subject) (-> Frac Frac Frac) diff --git a/stdlib/source/library/lux/world/console.lux b/stdlib/source/library/lux/world/console.lux index 41652fdd7..5020554a1 100644 --- a/stdlib/source/library/lux/world/console.lux +++ b/stdlib/source/library/lux/world/console.lux @@ -16,14 +16,6 @@ ["." text (#+ Char) ["%" format (#+ format)]]]]]) -(template [] - [(exception: #export () - "")] - - [cannot_open] - [cannot_close] - ) - (interface: #export (Console !) (: (-> [] (! (Try Char))) read) @@ -66,6 +58,14 @@ (#static in java/io/InputStream) (#static out java/io/PrintStream)]) + (template [] + [(exception: #export () + "")] + + [cannot_open] + [cannot_close] + ) + (def: #export default (IO (Try (Console IO))) (do io.monad diff --git a/stdlib/source/spec/aedifex/repository.lux b/stdlib/source/spec/aedifex/repository.lux deleted file mode 100644 index de9a05fde..000000000 --- a/stdlib/source/spec/aedifex/repository.lux +++ /dev/null @@ -1,57 +0,0 @@ -(.module: - [library - [lux #* - ["_" test (#+ Test)] - [abstract - [monad (#+ do)]] - [control - ["." try (#+ Try)] - [concurrency - ["." promise (#+ Promise)]]] - [data - ["." binary - ["_#" \\test]]] - [math - ["." random]]]] - [\\program - ["." / - ["#." remote] - ["/#" // #_ - ["#." artifact (#+ Artifact) - ["#/." extension]]]]] - [\\test - ["_." // #_ - ["#." artifact]]]) - -(def: #export (spec valid_artifact invalid_artifact subject) - (-> Artifact Artifact (/.Repository Promise) Test) - (do random.monad - [expected (_binary.random 100)] - (wrap ($_ _.and' - (do promise.monad - [#let [good_uri (/remote.uri (get@ #//artifact.version valid_artifact) valid_artifact //artifact/extension.lux_library)] - good_upload! (\ subject upload good_uri expected) - good_download! (\ subject download good_uri) - - #let [bad_uri (/remote.uri (get@ #//artifact.version invalid_artifact) invalid_artifact //artifact/extension.lux_library)] - bad_upload! (\ subject upload bad_uri expected) - bad_download! (\ subject download bad_uri)] - (_.cover' [/.Repository] - (let [successfull_flow! - (case [good_upload! good_download!] - [(#try.Success _) (#try.Success actual)] - (\ binary.equivalence = expected actual) - - _ - false) - - failed_flow! - (case [bad_upload! bad_download!] - [(#try.Failure _) (#try.Failure _)] - true - - _ - false)] - (and successfull_flow! - failed_flow!)))) - )))) diff --git a/stdlib/source/spec/compositor.lux b/stdlib/source/spec/compositor.lux deleted file mode 100644 index 08a294282..000000000 --- a/stdlib/source/spec/compositor.lux +++ /dev/null @@ -1,67 +0,0 @@ -(.module: - [lux #* - ["_" test (#+ Test)] - [abstract - [monad (#+ do)]] - [control - ["." io (#+ IO)] - ["." try]] - [math - ["r" random]] - [tool - [compiler - ["." analysis] - ["." directive] - [phase - [macro (#+ Expander)] - [generation (#+ Bundle)]] - [default - [platform (#+ Platform)]]]]] - ["." / #_ - ["#." common (#+ Runner Definer)] - ["#./" analysis #_ - ["#." type]] - ["#./" generation #_ - ["#." primitive] - ["#." structure] - ["#." reference] - ["#." case] - ["#." function] - ["#." common]]]) - -(def: (test runner definer state expander) - (-> Runner Definer analysis.State+ Expander Test) - ($_ _.and - (/analysis/type.spec expander state) - (/generation/primitive.spec runner) - (/generation/structure.spec runner) - (/generation/reference.spec runner definer) - (/generation/case.spec runner) - (/generation/function.spec runner) - (/generation/common.spec runner) - )) - -(def: #export (spec platform bundle expander program) - (All [anchor expression directive] - (-> (IO (Platform IO anchor expression directive)) - (Bundle anchor expression directive) - Expander - (-> expression directive) - Test)) - (do r.monad - [_ (wrap []) - #let [?state,runner,definer (<| io.run - (do io.monad - [platform platform]) - (/common.executors platform - bundle - expander - program))]] - (case ?state,runner,definer - (#try.Success [[directive-bundle directive-state] runner definer]) - (..test runner definer - (get@ [#directive.analysis #directive.state] directive-state) - expander) - - (#try.Failure error) - (_.fail error)))) diff --git a/stdlib/source/spec/compositor/analysis/type.lux b/stdlib/source/spec/compositor/analysis/type.lux deleted file mode 100644 index 7cbd5884b..000000000 --- a/stdlib/source/spec/compositor/analysis/type.lux +++ /dev/null @@ -1,63 +0,0 @@ -(.module: - [lux #* - ["_" test (#+ Test)] - [abstract - [monad (#+ do)]] - [control - [pipe (#+ case>)] - ["." io] - ["." try]] - [math - ["r" random (#+ Random)]] - [macro - ["." code]] - [tool - [compiler - [analysis (#+ State+)] - ["." phase - [macro (#+ Expander)] - ["." analysis - ["#/." scope] - ["#/." type]]]]]]) - -(def: (check-success+ expander state extension params output-type) - (-> Expander State+ Text (List Code) Type Bit) - (|> (analysis/scope.with-scope "" - (analysis/type.with-type output-type - (analysis.phase expander (` ((~ (code.text extension)) (~+ params)))))) - (phase.run state) - (case> (#try.Success _) - true - - (#try.Failure _) - false))) - -(def: check - (Random [Code Type Code]) - (`` ($_ r.either - (~~ (template [ ] - [(do r.monad - [value ] - (wrap [(` ) - - ( value)]))] - - [r.bit (0 #0 "#Bit" (0 #0)) code.bit] - [r.nat (0 #0 "#I64" (0 #1 (0 #0 "#Nat" (0 #0)) (0 #0))) code.nat] - [r.int (0 #0 "#I64" (0 #1 (0 #0 "#Int" (0 #0)) (0 #0))) code.int] - [r.rev (0 #0 "#I64" (0 #1 (0 #0 "#Rev" (0 #0)) (0 #0))) code.rev] - [r.safe-frac (0 #0 "#Frac" (0 #0)) code.frac] - [(r.ascii/upper-alpha 5) (0 #0 "#Text" (0 #0)) code.text] - ))))) - -(def: #export (spec expander state) - (-> Expander State+ Test) - (do r.monad - [[typeC exprT exprC] ..check - [other-typeC other-exprT other-exprC] ..check] - ($_ _.and - (_.test "lux check" - (check-success+ expander state "lux check" (list typeC exprC) exprT)) - (_.test "lux coerce" - (check-success+ expander state "lux coerce" (list typeC other-exprC) exprT)) - ))) diff --git a/stdlib/source/spec/compositor/common.lux b/stdlib/source/spec/compositor/common.lux deleted file mode 100644 index ed3b53f30..000000000 --- a/stdlib/source/spec/compositor/common.lux +++ /dev/null @@ -1,81 +0,0 @@ -(.module: - [lux #* - [abstract - [monad (#+ do)]] - [control - ["." io (#+ IO)] - ["." try (#+ Try)]] - [tool - [compiler - ["." reference] - ["." analysis] - ["." synthesis (#+ Synthesis)] - ["." directive] - ["." phase - ["." macro (#+ Expander)] - ["." generation (#+ Operation)] - [extension (#+ Extender) - ["." bundle]]] - [default - ["." platform (#+ Platform)]]]]]) - -(type: #export Runner - (-> Text Synthesis (Try Any))) - -(type: #export Definer - (-> Name Synthesis (Try Any))) - -(type: #export (Instancer what) - (All [anchor expression directive] - (-> (Platform IO anchor expression directive) - (generation.State+ anchor expression directive) - what))) - -(def: (runner (^slots [#platform.runtime #platform.phase #platform.host]) state) - (Instancer Runner) - (function (_ evaluation-name expressionS) - (do try.monad - [expressionG (<| (phase.run state) - generation.with-buffer - (do phase.monad - [_ runtime] - (phase expressionS)))] - (\ host evaluate! evaluation-name expressionG)))) - -(def: (definer (^slots [#platform.runtime #platform.phase #platform.host]) - state) - (Instancer Definer) - (function (_ lux-name expressionS) - (do try.monad - [definitionG (<| (phase.run state) - generation.with-buffer - (do phase.monad - [_ runtime - expressionG (phase expressionS) - [host-name host-value host-directive] (generation.define! lux-name expressionG) - _ (generation.learn lux-name host-name)] - (phase (synthesis.constant lux-name))))] - (\ host evaluate! "definer" definitionG)))) - -(def: #export (executors target expander platform - analysis-bundle generation-bundle directive-bundle - program extender) - (All [anchor expression directive] - (-> Text Expander (Platform IO anchor expression directive) - analysis.Bundle - (generation.Bundle anchor expression directive) - (directive.Bundle anchor expression directive) - (-> expression directive) Extender - (IO (Try [(directive.State+ anchor expression directive) - Runner - Definer])))) - (do io.monad - [?state (platform.initialize target expander analysis-bundle platform generation-bundle directive-bundle program extender)] - (wrap (do try.monad - [[directive-bundle directive-state] ?state - #let [generation-state (get@ [#directive.generation - #directive.state] - directive-state)]] - (wrap [[directive-bundle directive-state] - (..runner platform generation-state) - (..definer platform generation-state)]))))) diff --git a/stdlib/source/spec/compositor/generation/case.lux b/stdlib/source/spec/compositor/generation/case.lux deleted file mode 100644 index 2424aa330..000000000 --- a/stdlib/source/spec/compositor/generation/case.lux +++ /dev/null @@ -1,288 +0,0 @@ -(.module: - [lux (#- case) - ["_" test (#+ Test)] - [abstract - [monad (#+ do)]] - [control - [pipe (#+ case>)] - ["." try (#+ Try)]] - [data - ["." text ("#\." equivalence) - ["%" format (#+ format)]] - [number - ["n" nat] - ["f" frac]] - [collection - ["." list ("#\." fold)]]] - [math - ["r" random (#+ Random)]] - [tool - [compiler - ["." reference] - ["." analysis] - ["." synthesis (#+ Path Synthesis)] - ["." phase - ["#/." synthesis - ["." case]] - ["." extension/synthesis]]]]] - [/// - [common (#+ Runner)]]) - -(def: limit Nat 10) - -(def: size - (Random Nat) - (|> r.nat (\ r.monad map (|>> (n.% ..limit) (n.max 2))))) - -(def: (tail? size idx) - (-> Nat Nat Bit) - (n.= (dec size) idx)) - -(def: #export (verify expected) - (-> Frac (Try Any) Bit) - (|>> (case> (#try.Success actual) - (f.= expected (:as Frac actual)) - - (#try.Failure _) - false))) - -(def: case - (Random [Synthesis Path]) - (<| r.rec (function (_ case)) - (`` ($_ r.either - (do r.monad - [value r.i64] - (wrap [(synthesis.i64 value) - synthesis.path/pop])) - (~~ (template [ ] - [(do r.monad - [value ] - (wrap [( value) - ( value)]))] - - [r.bit synthesis.bit synthesis.path/bit] - [r.i64 synthesis.i64 synthesis.path/i64] - [r.frac synthesis.f64 synthesis.path/f64] - [(r.unicode 5) synthesis.text synthesis.path/text])) - (do {! r.monad} - [size ..size - idx (|> r.nat (\ ! map (n.% size))) - [subS subP] case - #let [unitS (synthesis.text synthesis.unit) - caseS (synthesis.tuple - (list.concat (list (list.repeat idx unitS) - (list subS) - (list.repeat (|> size dec (n.- idx)) unitS)))) - caseP ($_ synthesis.path/seq - (if (tail? size idx) - (synthesis.member/right idx) - (synthesis.member/left idx)) - subP)]] - (wrap [caseS caseP])) - (do {! r.monad} - [size ..size - idx (|> r.nat (\ ! map (n.% size))) - [subS subP] case - #let [right? (tail? size idx) - caseS (synthesis.variant - {#analysis.lefts idx - #analysis.right? right? - #analysis.value subS}) - caseP ($_ synthesis.path/seq - (if right? - (synthesis.side/right idx) - (synthesis.side/left idx)) - subP)]] - (wrap [caseS caseP])) - )))) - -(def: (let-spec run) - (-> Runner Test) - (do r.monad - [value r.safe-frac] - (_.test (%.name (name-of synthesis.branch/let)) - (|> (synthesis.branch/let [(synthesis.f64 value) - 0 - (synthesis.variable/local 0)]) - (run "let-spec") - (verify value))))) - -(def: (if-spec run) - (-> Runner Test) - (do r.monad - [on-true r.safe-frac - on-false (|> r.safe-frac (r.filter (|>> (f.= on-true) not))) - verdict r.bit] - (_.test (%.name (name-of synthesis.branch/if)) - (|> (synthesis.branch/if [(synthesis.bit verdict) - (synthesis.f64 on-true) - (synthesis.f64 on-false)]) - (run "if-spec") - (verify (if verdict on-true on-false)))))) - -(def: (case-spec run) - (-> Runner Test) - (do r.monad - [[inputS pathS] ..case - on-success r.safe-frac - on-failure (|> r.safe-frac (r.filter (|>> (f.= on-success) not)))] - (_.test (%.name (name-of synthesis.branch/case)) - (|> (synthesis.branch/case - [inputS - ($_ synthesis.path/alt - ($_ synthesis.path/seq - pathS - (synthesis.path/then (synthesis.f64 on-success))) - (synthesis.path/then (synthesis.f64 on-failure)))]) - (run "case-spec") - (verify on-success))))) - -(def: special-input - Synthesis - (let [_cursor_ (: Synthesis - (synthesis.tuple (list (synthesis.text .prelude_module) - (synthesis.i64 +901) - (synthesis.i64 +13)))) - _code_ (: (-> Synthesis Synthesis) - (function (_ content) - (synthesis.tuple (list _cursor_ content)))) - _nil_ (: Synthesis - (synthesis.variant [0 #0 (synthesis.text "")])) - _cons_ (: (-> Synthesis Synthesis Synthesis) - (function (_ head tail) - (synthesis.variant [0 #1 (synthesis.tuple (list head tail))]))) - _list_ (: (-> (List Synthesis) Synthesis) - (list\fold _cons_ _nil_))] - (let [__tuple__ (: (-> (List Synthesis) Synthesis) - (|>> list.reverse _list_ [9 #0] synthesis.variant _code_)) - __form__ (: (-> (List Synthesis) Synthesis) - (|>> list.reverse _list_ [8 #0] synthesis.variant _code_)) - __text__ (: (-> Text Synthesis) - (function (_ value) - (_code_ (synthesis.variant [5 #0 (synthesis.text value)])))) - __identifier__ (: (-> Name Synthesis) - (function (_ [module short]) - (_code_ (synthesis.variant [6 #0 (synthesis.tuple (list (synthesis.text module) - (synthesis.text short)))])))) - __tag__ (: (-> Name Synthesis) - (function (_ [module short]) - (_code_ (synthesis.variant [7 #0 (synthesis.tuple (list (synthesis.text module) - (synthesis.text short)))])))) - __list__ (: (-> (List Synthesis) Synthesis) - (list\fold (function (_ head tail) - (__form__ (list (__tag__ ["" "Cons"]) head tail))) - (__tag__ ["" "Nil"]))) - __apply__ (: (-> Synthesis Synthesis Synthesis) - (function (_ func arg) - (__form__ (list func arg))))] - (|> _nil_ - (_cons_ (__apply__ (__identifier__ ["" "form$"]) - (__list__ (list (__apply__ (__identifier__ ["" "tag$"]) - (__tuple__ (list (__text__ .prelude_module) - (__text__ "Cons")))) - (__identifier__ ["" "export?-meta"]) - (__identifier__ ["" "tail"]))))) - (_cons_ (__tuple__ (list (__identifier__ ["" "tail"])))) - )))) - -(def: special-path - Path - (let [_nil_ (synthesis.path/side (#.Left 0)) - _cons_ (synthesis.path/side (#.Right 0)) - _head_ (synthesis.path/member (#.Left 0)) - _tail_ (synthesis.path/member (#.Right 0)) - _tuple_ (synthesis.path/side (#.Left 9))] - ($_ synthesis.path/alt - ($_ synthesis.path/seq - _cons_ - _head_ - _head_ (synthesis.path/bind 2) synthesis.path/pop - _tail_ _tuple_ _cons_ - _head_ (synthesis.path/bind 3) synthesis.path/pop - _tail_ (synthesis.path/bind 4) synthesis.path/pop - synthesis.path/pop synthesis.path/pop synthesis.path/pop synthesis.path/pop - _tail_ _cons_ - _head_ (synthesis.path/bind 5) synthesis.path/pop - _tail_ _nil_ - ## THEN - (synthesis.path/then (synthesis.bit #1))) - ($_ synthesis.path/seq - (synthesis.path/bind 2) - ## THEN - (synthesis.path/then (synthesis.bit #0)))))) - -(def: special-pattern - analysis.Pattern - (let [## [_ (#Tuple (#Cons arg args'))] - head (<| analysis.pattern/tuple (list (analysis.pattern/bind 2)) - analysis.pattern/variant [9 #0] - analysis.pattern/variant [0 #1] - analysis.pattern/tuple (list (analysis.pattern/bind 3) - (analysis.pattern/bind 4))) - ## (#Cons body #Nil) - tail (<| analysis.pattern/variant [0 #1] - analysis.pattern/tuple (list (analysis.pattern/bind 5)) - analysis.pattern/variant [0 #0] - (analysis.pattern/unit))] - ## (#Cons ) - (<| analysis.pattern/variant [0 #1] - (analysis.pattern/tuple (list head tail))))) - -(def: special-pattern-path - Path - ($_ synthesis.path/alt - (<| try.assume - (phase.run [extension/synthesis.bundle - synthesis.init]) - (case.path phase/synthesis.phase - special-pattern) - (analysis.bit #1)) - ($_ synthesis.path/seq - (synthesis.path/bind 2) - ## THEN - (synthesis.path/then (synthesis.bit #0))))) - -## TODO: Get rid of this ASAP -(def: (special-spec run) - (-> Runner Test) - ($_ _.and - (_.test "===" - (and (text\= (synthesis.%path special-path) - (synthesis.%path special-pattern-path)) - (\ synthesis.path-equivalence = special-path special-pattern-path))) - (_.test "CODE" - (|> special-input - (run "special-input") - (case> (#try.Success output) - true - - (#try.Failure _) - false))) - (_.test "PATTERN-MATCHING 0" - (|> (synthesis.branch/case [special-input - special-path]) - (run "special-path") - (case> (#try.Success output) - true - - (#try.Failure _) - false))) - (_.test "PATTERN-MATCHING 1" - (|> (synthesis.branch/case [special-input - special-pattern-path]) - (run "special-pattern-path") - (case> (#try.Success output) - true - - (#try.Failure _) - false))) - )) - -(def: #export (spec run) - (-> Runner Test) - ($_ _.and - (..special-spec run) - (..let-spec run) - (..if-spec run) - (..case-spec run) - )) diff --git a/stdlib/source/spec/compositor/generation/common.lux b/stdlib/source/spec/compositor/generation/common.lux deleted file mode 100644 index 3d377b7ca..000000000 --- a/stdlib/source/spec/compositor/generation/common.lux +++ /dev/null @@ -1,343 +0,0 @@ -(.module: - [lux (#- i64) - ["_" test (#+ Test)] - [abstract - [monad (#+ do)]] - [control - [pipe (#+ case>)] - ["." try (#+ Try)]] - [data - ["." bit ("#\." equivalence)] - [number - ["." i64] - ["n" nat] - ["i" int] - ["f" frac]] - ["." text ("#\." equivalence) - ["%" format (#+ format)]] - [collection - ["." list]]] - [math - ["r" random (#+ Random)]] - [tool - [compiler - ["." reference] - ["." synthesis]]]] - ["." // #_ - ["#." case] - [// - [common (#+ Runner)]]]) - -(def: sanitize - (-> Text Text) - (text.replace-all " " "_")) - -(def: (bit run) - (-> Runner Test) - (do r.monad - [param r.i64 - subject r.i64] - (with-expansions [ (template [ ] - [(_.test - (|> (#synthesis.Extension (list (synthesis.i64 param) - (synthesis.i64 subject))) - (run (..sanitize )) - (case> (#try.Success valueT) - (n.= ( param subject) (:as Nat valueT)) - - (#try.Failure _) - false) - (let [param ])))] - - ["lux i64 and" i64.and param] - ["lux i64 or" i64.or param] - ["lux i64 xor" i64.xor param] - ["lux i64 left-shift" i64.left-shift (n.% 64 param)] - ["lux i64 logical-right-shift" i64.logic-right-shift (n.% 64 param)] - )] - ($_ _.and - - (_.test "lux i64 arithmetic-right-shift" - (|> (#synthesis.Extension "lux i64 arithmetic-right-shift" - (list (synthesis.i64 subject) - (synthesis.i64 param))) - (run (..sanitize "lux i64 arithmetic-right-shift")) - (case> (#try.Success valueT) - ("lux i64 =" - (i64.arithmetic-right-shift param subject) - (:as I64 valueT)) - - (#try.Failure _) - false) - (let [param (n.% 64 param)]))) - )))) - -(def: (i64 run) - (-> Runner Test) - (do r.monad - [param (|> r.i64 (r.filter (|>> ("lux i64 =" 0) not))) - subject r.i64] - (`` ($_ _.and - (~~ (template [ ] - [(_.test - (|> (#synthesis.Extension (list (synthesis.i64 subject))) - (run (..sanitize )) - (case> (#try.Success valueT) - ( ( subject) (:as valueT)) - - (#try.Failure _) - false) - (let [subject ])))] - - ["lux i64 f64" Frac i.frac f.= subject] - ["lux i64 char" Text (|>> (:as Nat) text.from-code) text\= (|> subject - (:as Nat) - (n.% (i64.left-shift 8 1)) - (:as Int))] - )) - (~~ (template [ ] - [(_.test - (|> (#synthesis.Extension (list (synthesis.i64 param) - (synthesis.i64 subject))) - (run (..sanitize )) - (case> (#try.Success valueT) - ( ( param subject) (:as valueT)) - - (#try.Failure _) - false)))] - - ["lux i64 +" i.+ Int i.=] - ["lux i64 -" i.- Int i.=] - ["lux i64 *" i.* Int i.=] - ["lux i64 /" i./ Int i.=] - ["lux i64 %" i.% Int i.=] - ["lux i64 =" i.= Bit bit\=] - ["lux i64 <" i.< Bit bit\=] - )) - )))) - -(def: simple-frac - (Random Frac) - (|> r.nat (\ r.monad map (|>> (n.% 1000) .int i.frac)))) - -(def: (f64 run) - (-> Runner Test) - (do r.monad - [param (|> ..simple-frac (r.filter (|>> (f.= +0.0) not))) - subject ..simple-frac] - (`` ($_ _.and - (~~ (template [ ] - [(_.test - (|> (#synthesis.Extension (list (synthesis.f64 param) - (synthesis.f64 subject))) - (run (..sanitize )) - (//case.verify ( param subject))))] - - ["lux f64 +" f.+ f.=] - ["lux f64 -" f.- f.=] - ["lux f64 *" f.* f.=] - ["lux f64 /" f./ f.=] - ["lux f64 %" f.% f.=] - )) - (~~ (template [ ] - [(_.test - (|> (#synthesis.Extension (list (synthesis.f64 param) - (synthesis.f64 subject))) - (run (..sanitize )) - (case> (#try.Success valueV) - (bit\= ( param subject) - (:as Bit valueV)) - - _ - false)))] - - ["lux f64 =" f.=] - ["lux f64 <" f.<] - )) - (~~ (template [ ] - [(_.test - (|> (#synthesis.Extension (list)) - (run (..sanitize )) - (//case.verify )))] - - ["lux f64 min" ("lux f64 min")] - ["lux f64 max" ("lux f64 max")] - ["lux f64 smallest" ("lux f64 smallest")] - )) - (_.test "'lux f64 i64 && 'lux i64 f64'" - (|> (run (..sanitize "lux f64 i64") - (|> subject synthesis.f64 - (list) (#synthesis.Extension "lux f64 i64") - (list) (#synthesis.Extension "lux i64 f64"))) - (//case.verify subject))) - )))) - -(def: (text run) - (-> Runner Test) - (do {! r.monad} - [sample-size (|> r.nat (\ ! map (|>> (n.% 10) (n.max 1)))) - sample-lower (r.ascii/lower-alpha sample-size) - sample-upper (r.ascii/upper-alpha sample-size) - sample-alpha (|> (r.ascii/alpha sample-size) - (r.filter (|>> (text\= sample-upper) not))) - char-idx (|> r.nat (\ ! map (n.% sample-size))) - #let [sample-lowerS (synthesis.text sample-lower) - sample-upperS (synthesis.text sample-upper) - sample-alphaS (synthesis.text sample-alpha) - concatenatedS (#synthesis.Extension "lux text concat" (list sample-lowerS sample-upperS)) - pre-rep-once (format sample-lower sample-upper) - post-rep-once (format sample-lower sample-alpha) - pre-rep-all (|> (list.repeat sample-size sample-lower) (text.join-with sample-upper)) - post-rep-all (|> (list.repeat sample-size sample-lower) (text.join-with sample-alpha))]] - ($_ _.and - (_.test "Can compare texts for equality." - (and (|> (#synthesis.Extension "lux text =" (list sample-lowerS sample-lowerS)) - (run (..sanitize "lux text =")) - (case> (#try.Success valueV) - (:as Bit valueV) - - _ - false)) - (|> (#synthesis.Extension "lux text =" (list sample-upperS sample-lowerS)) - (run (..sanitize "lux text =")) - (case> (#try.Success valueV) - (not (:as Bit valueV)) - - _ - false)))) - (_.test "Can compare texts for order." - (|> (#synthesis.Extension "lux text <" (list sample-lowerS sample-upperS)) - (run (..sanitize "lux text <")) - (case> (#try.Success valueV) - (:as Bit valueV) - - (#try.Failure _) - false))) - (_.test "Can get length of text." - (|> (#synthesis.Extension "lux text size" (list sample-lowerS)) - (run (..sanitize "lux text size")) - (case> (#try.Success valueV) - (n.= sample-size (:as Nat valueV)) - - _ - false))) - (_.test "Can concatenate text." - (|> (#synthesis.Extension "lux text size" (list concatenatedS)) - (run (..sanitize "lux text size")) - (case> (#try.Success valueV) - (n.= (n.* 2 sample-size) (:as Nat valueV)) - - _ - false))) - (_.test "Can find index of sub-text." - (and (|> (#synthesis.Extension "lux text index" - (list concatenatedS sample-lowerS - (synthesis.i64 +0))) - (run (..sanitize "lux text index")) - (case> (^multi (#try.Success valueV) - [(:as (Maybe Nat) valueV) (#.Some valueV)]) - (n.= 0 valueV) - - _ - false)) - (|> (#synthesis.Extension "lux text index" - (list concatenatedS sample-upperS - (synthesis.i64 +0))) - (run (..sanitize "lux text index")) - (case> (^multi (#try.Success valueV) - [(:as (Maybe Nat) valueV) (#.Some valueV)]) - (n.= sample-size valueV) - - _ - false)))) - (let [test-clip (: (-> (I64 Any) (I64 Any) Text Bit) - (function (_ offset length expected) - (|> (#synthesis.Extension "lux text clip" - (list concatenatedS - (synthesis.i64 offset) - (synthesis.i64 length))) - (run (..sanitize "lux text clip")) - (case> (^multi (#try.Success valueV) - [(:as (Maybe Text) valueV) (#.Some valueV)]) - (text\= expected valueV) - - _ - false))))] - (_.test "Can clip text to extract sub-text." - (and (test-clip 0 sample-size sample-lower) - (test-clip sample-size sample-size sample-upper)))) - (_.test "Can extract individual characters from text." - (|> (#synthesis.Extension "lux text char" - (list sample-lowerS - (synthesis.i64 char-idx))) - (run (..sanitize "lux text char")) - (case> (^multi (#try.Success valueV) - [(:as (Maybe Int) valueV) (#.Some valueV)]) - (text.contains? ("lux i64 char" valueV) - sample-lower) - - _ - false))) - ))) - -(def: (io run) - (-> Runner Test) - (do r.monad - [message (r.ascii/alpha 5)] - ($_ _.and - (_.test "Can log messages." - (|> (#synthesis.Extension "lux io log" - (list (synthesis.text (format "LOG: " message)))) - (run (..sanitize "lux io log")) - (case> (#try.Success valueV) - true - - (#try.Failure _) - false))) - (_.test "Can throw runtime errors." - (and (|> (#synthesis.Extension "lux try" - (list (synthesis.function/abstraction - {#synthesis.environment (list) - #synthesis.arity 1 - #synthesis.body (#synthesis.Extension "lux io error" - (list (synthesis.text message)))}))) - (run (..sanitize "lux try")) - (case> (^multi (#try.Success valueV) - [(:as (Try Text) valueV) (#try.Failure error)]) - (text.contains? message error) - - _ - false)) - (|> (#synthesis.Extension "lux try" - (list (synthesis.function/abstraction - {#synthesis.environment (list) - #synthesis.arity 1 - #synthesis.body (synthesis.text message)}))) - (run (..sanitize "lux try")) - (case> (^multi (#try.Success valueV) - [(:as (Try Text) valueV) (#try.Success valueV)]) - (text\= message valueV) - - _ - false)))) - (_.test "Can obtain current time in milli-seconds." - (|> (synthesis.tuple (list (#synthesis.Extension "lux io current-time" (list)) - (#synthesis.Extension "lux io current-time" (list)))) - (run (..sanitize "lux io current-time")) - (case> (#try.Success valueV) - (let [[pre post] (:as [Nat Nat] valueV)] - (n.>= pre post)) - - (#try.Failure _) - false))) - ))) - -(def: #export (spec runner) - (-> Runner Test) - ($_ _.and - (..bit runner) - (..i64 runner) - (..f64 runner) - (..text runner) - (..io runner) - )) diff --git a/stdlib/source/spec/compositor/generation/function.lux b/stdlib/source/spec/compositor/generation/function.lux deleted file mode 100644 index 6d0f8d541..000000000 --- a/stdlib/source/spec/compositor/generation/function.lux +++ /dev/null @@ -1,93 +0,0 @@ -(.module: - [lux (#- function) - ["_" test (#+ Test)] - [abstract - [monad (#+ do)] - ["." enum]] - [control - [pipe (#+ case>)]] - [data - ["." maybe] - [number - ["n" nat]] - [collection - ["." list ("#\." functor)]]] - [math - ["r" random (#+ Random) ("#\." monad)]] - [tool - [compiler - [analysis (#+ Arity)] - ["." reference (#+ Register)] - ["." synthesis (#+ Synthesis)]]]] - ["." // #_ - ["#." case] - [// - [common (#+ Runner)]]]) - -(def: max-arity Arity 10) - -(def: arity - (Random Arity) - (|> r.nat (r\map (|>> (n.% max-arity) (n.max 1))))) - -(def: (local arity) - (-> Arity (Random Register)) - (|> r.nat (r\map (|>> (n.% arity) inc)))) - -(def: function - (Random [Arity Register Synthesis]) - (do r.monad - [arity ..arity - local (..local arity)] - (wrap [arity local - (synthesis.function/abstraction - {#synthesis.environment (list) - #synthesis.arity arity - #synthesis.body (synthesis.variable/local local)})]))) - -(def: #export (spec run) - (-> Runner Test) - (do {! r.monad} - [[arity local functionS] ..function - partial-arity (|> r.nat (\ ! map (|>> (n.% arity) (n.max 1)))) - inputs (r.list arity r.safe-frac) - #let [expectation (maybe.assume (list.nth (dec local) inputs)) - inputsS (list\map (|>> synthesis.f64) inputs)]] - ($_ _.and - (_.test "Can read arguments." - (|> (synthesis.function/apply {#synthesis.function functionS - #synthesis.arguments inputsS}) - (run "with-local") - (//case.verify expectation))) - (_.test "Can partially apply functions." - (or (n.= 1 arity) - (let [preS (list.take partial-arity inputsS) - postS (list.drop partial-arity inputsS) - partialS (synthesis.function/apply {#synthesis.function functionS - #synthesis.arguments preS})] - (|> (synthesis.function/apply {#synthesis.function partialS - #synthesis.arguments postS}) - (run "partial-application") - (//case.verify expectation))))) - (_.test "Can read environment." - (or (n.= 1 arity) - (let [environment (|> partial-arity - (enum.range n.enum 1) - (list\map (|>> #reference.Local))) - variableS (if (n.<= partial-arity local) - (synthesis.variable/foreign (dec local)) - (synthesis.variable/local (|> local (n.- partial-arity)))) - inner-arity (n.- partial-arity arity) - innerS (synthesis.function/abstraction - {#synthesis.environment environment - #synthesis.arity inner-arity - #synthesis.body variableS}) - outerS (synthesis.function/abstraction - {#synthesis.environment (list) - #synthesis.arity partial-arity - #synthesis.body innerS})] - (|> (synthesis.function/apply {#synthesis.function outerS - #synthesis.arguments inputsS}) - (run "with-foreign") - (//case.verify expectation))))) - ))) diff --git a/stdlib/source/spec/compositor/generation/primitive.lux b/stdlib/source/spec/compositor/generation/primitive.lux deleted file mode 100644 index 3b6dd657b..000000000 --- a/stdlib/source/spec/compositor/generation/primitive.lux +++ /dev/null @@ -1,48 +0,0 @@ -(.module: - [lux #* - ["_" test (#+ Test)] - [abstract - [monad (#+ do)]] - [control - [pipe (#+ case>)] - ["." try]] - [data - ["." bit ("#\." equivalence)] - [number - ["f" frac]] - ["." text ("#\." equivalence) - ["%" format (#+ format)]]] - [math - ["r" random]] - [tool - [compiler - ["." synthesis]]]] - [/// - [common (#+ Runner)]]) - -(def: (f/=' reference subject) - (-> Frac Frac Bit) - (or (f.= reference subject) - (and (f.not-a-number? reference) - (f.not-a-number? subject)))) - -(def: #export (spec run) - (-> Runner Test) - (`` ($_ _.and - (~~ (template [ ] - [(do r.monad - [expected ] - (_.test (%.name (name-of )) - (|> (run ( expected)) - (case> (#try.Success actual) - ( expected (:assume actual)) - - (#try.Failure _) - false))))] - - ["bit" synthesis.bit r.bit bit\=] - ["i64" synthesis.i64 r.i64 "lux i64 ="] - ["f64" synthesis.f64 r.frac f.='] - ["text" synthesis.text (r.ascii 5) text\=] - )) - ))) diff --git a/stdlib/source/spec/compositor/generation/reference.lux b/stdlib/source/spec/compositor/generation/reference.lux deleted file mode 100644 index 665175ab4..000000000 --- a/stdlib/source/spec/compositor/generation/reference.lux +++ /dev/null @@ -1,60 +0,0 @@ -(.module: - [lux #* - ["_" test (#+ Test)] - [abstract - [monad (#+ do)]] - [control - [pipe (#+ case>)] - ["." try]] - [data - [number - ["n" nat] - ["f" frac]]] - [tool - [compiler - ["." reference] - ["." synthesis]]] - [math - ["r" random (#+ Random)]]] - [/// - [common (#+ Runner Definer)]]) - -(def: name - (Random Name) - (let [name-part (r.ascii/upper-alpha 5)] - [(r.and name-part name-part)])) - -(def: (definition define) - (-> Definer Test) - (do r.monad - [name ..name - expected r.safe-frac] - (_.test "Definitions." - (|> (define name (synthesis.f64 expected)) - (case> (#try.Success actual) - (f.= expected (:as Frac actual)) - - (#try.Failure _) - false))))) - -(def: (variable run) - (-> Runner Test) - (do {! r.monad} - [register (|> r.nat (\ ! map (n.% 100))) - expected r.safe-frac] - (_.test "Local variables." - (|> (synthesis.branch/let [(synthesis.f64 expected) - register - (synthesis.variable/local register)]) - (run "variable") - (case> (#try.Success actual) - (f.= expected (:as Frac actual)) - - (#try.Failure _) - false))))) - -(def: #export (spec runner definer) - (-> Runner Definer Test) - ($_ _.and - (..definition definer) - (..variable runner))) diff --git a/stdlib/source/spec/compositor/generation/structure.lux b/stdlib/source/spec/compositor/generation/structure.lux deleted file mode 100644 index 7c45d2a9b..000000000 --- a/stdlib/source/spec/compositor/generation/structure.lux +++ /dev/null @@ -1,89 +0,0 @@ -(.module: - [lux #* - ["_" test (#+ Test)] - [abstract - [monad (#+ do)]] - [control - [pipe (#+ case>)] - ["." try]] - [data - ["." maybe] - [number - ["n" nat] - ["i" int]] - ["." text ("#\." equivalence) - ["%" format (#+ format)]] - [collection - ["." array (#+ Array)] - ["." list ("#\." functor)]]] - [math - ["r" random]] - ["." ffi (#+ import:)] - [tool - [compiler - ["." analysis] - ["." synthesis]]]] - [/// - [common (#+ Runner)]]) - -(import: java/lang/Integer) - -(def: (variant run) - (-> Runner Test) - (do {! r.monad} - [num-tags (|> r.nat (\ ! map (|>> (n.% 10) (n.max 2)))) - tag-in (|> r.nat (\ ! map (n.% num-tags))) - #let [last?-in (|> num-tags dec (n.= tag-in))] - value-in r.i64] - (_.test (%.name (name-of synthesis.variant)) - (|> (synthesis.variant {#analysis.lefts (if last?-in - (dec tag-in) - tag-in) - #analysis.right? last?-in - #analysis.value (synthesis.i64 value-in)}) - (run "variant") - (case> (#try.Success valueT) - (let [valueT (:as (Array Any) valueT)] - (and (n.= 3 (array.size valueT)) - (let [tag-out (:as java/lang/Integer (maybe.assume (array.read 0 valueT))) - last?-out (array.read 1 valueT) - value-out (:as Any (maybe.assume (array.read 2 valueT))) - same-tag? (|> tag-out ffi.int-to-long (:as Nat) (n.= tag-in)) - same-flag? (case last?-out - (#.Some last?-out') - (and last?-in (text\= "" (:as Text last?-out'))) - - #.None - (not last?-in)) - same-value? (|> value-out (:as Int) (i.= value-in))] - (and same-tag? - same-flag? - same-value?)))) - - (#try.Failure _) - false))))) - -(def: (tuple run) - (-> Runner Test) - (do {! r.monad} - [size (|> r.nat (\ ! map (|>> (n.% 10) (n.max 2)))) - tuple-in (r.list size r.i64)] - (_.test (%.name (name-of synthesis.tuple)) - (|> (synthesis.tuple (list\map (|>> synthesis.i64) tuple-in)) - (run "tuple") - (case> (#try.Success tuple-out) - (let [tuple-out (:as (Array Any) tuple-out)] - (and (n.= size (array.size tuple-out)) - (list.every? (function (_ [left right]) - (i.= left (:as Int right))) - (list.zip/2 tuple-in (array.to-list tuple-out))))) - - (#try.Failure _) - false))))) - -(def: #export (spec runner) - (-> Runner Test) - ($_ _.and - (..variant runner) - (..tuple runner) - )) diff --git a/stdlib/source/spec/lux/abstract/apply.lux b/stdlib/source/spec/lux/abstract/apply.lux deleted file mode 100644 index 691e8c01c..000000000 --- a/stdlib/source/spec/lux/abstract/apply.lux +++ /dev/null @@ -1,73 +0,0 @@ -(.module: - [library - [lux #* - ["_" test (#+ Test)] - [abstract - [monad (#+ do)]] - [control - ["." function]] - [math - ["." random] - [number - ["n" nat]]]]] - [\\library - ["." / (#+ Apply)]] - [// - [functor (#+ Injection Comparison)]]) - -(def: (identity injection comparison (^open "\.")) - (All [f] (-> (Injection f) (Comparison f) (Apply f) Test)) - (do {! random.monad} - [sample (\ ! map injection random.nat)] - (_.test "Identity." - ((comparison n.=) - (\apply (injection function.identity) sample) - sample)))) - -(def: (homomorphism injection comparison (^open "\.")) - (All [f] (-> (Injection f) (Comparison f) (Apply f) Test)) - (do {! random.monad} - [sample random.nat - increase (\ ! map n.+ random.nat)] - (_.test "Homomorphism." - ((comparison n.=) - (\apply (injection increase) (injection sample)) - (injection (increase sample)))))) - -(def: (interchange injection comparison (^open "\.")) - (All [f] (-> (Injection f) (Comparison f) (Apply f) Test)) - (do {! random.monad} - [sample random.nat - increase (\ ! map n.+ random.nat)] - (_.test "Interchange." - ((comparison n.=) - (\apply (injection increase) (injection sample)) - (\apply (injection (function (_ f) (f sample))) (injection increase)))))) - -(def: (composition injection comparison (^open "\.")) - (All [f] (-> (Injection f) (Comparison f) (Apply f) Test)) - (do {! random.monad} - [sample random.nat - increase (\ ! map n.+ random.nat) - decrease (\ ! map n.- random.nat)] - (_.test "Composition." - ((comparison n.=) - (_$ \apply - (injection function.compose) - (injection increase) - (injection decrease) - (injection sample)) - ($_ \apply - (injection increase) - (injection decrease) - (injection sample)))))) - -(def: #export (spec injection comparison apply) - (All [f] (-> (Injection f) (Comparison f) (Apply f) Test)) - (_.for [/.Apply] - ($_ _.and - (..identity injection comparison apply) - (..homomorphism injection comparison apply) - (..interchange injection comparison apply) - (..composition injection comparison apply) - ))) diff --git a/stdlib/source/spec/lux/abstract/codec.lux b/stdlib/source/spec/lux/abstract/codec.lux deleted file mode 100644 index f58f6ce91..000000000 --- a/stdlib/source/spec/lux/abstract/codec.lux +++ /dev/null @@ -1,27 +0,0 @@ -(.module: - [library - [lux #* - ["_" test (#+ Test)] - [abstract - [monad (#+ do)]] - [control - ["." try]] - [math - ["." random (#+ Random)]]]] - [\\library - ["." / - [// - [equivalence (#+ Equivalence)]]]]) - -(def: #export (spec (^open "@//.") (^open "@//.") generator) - (All [m a] (-> (Equivalence a) (/.Codec m a) (Random a) Test)) - (do random.monad - [expected generator] - (_.for [/.Codec] - (_.test "Isomorphism." - (case (|> expected @//encode @//decode) - (#try.Success actual) - (@//= expected actual) - - (#try.Failure _) - false))))) diff --git a/stdlib/source/spec/lux/abstract/comonad.lux b/stdlib/source/spec/lux/abstract/comonad.lux deleted file mode 100644 index 85d00b8f2..000000000 --- a/stdlib/source/spec/lux/abstract/comonad.lux +++ /dev/null @@ -1,61 +0,0 @@ -(.module: - [library - [lux #* - ["_" test (#+ Test)] - [abstract - [monad (#+ do)]] - [math - ["." random] - [number - ["n" nat]]]]] - [\\library - ["." / (#+ CoMonad)]] - [// - [functor (#+ Injection Comparison)]]) - -(def: (left-identity injection (^open "_//.")) - (All [f] (-> (Injection f) (CoMonad f) Test)) - (do {! random.monad} - [sample random.nat - morphism (\ ! map (function (_ diff) - (|>> _//unwrap (n.+ diff))) - random.nat) - #let [start (injection sample)]] - (_.test "Left identity." - (n.= (morphism start) - (|> start _//split (_//map morphism) _//unwrap))))) - -(def: (right-identity injection comparison (^open "_//.")) - (All [f] (-> (Injection f) (Comparison f) (CoMonad f) Test)) - (do random.monad - [sample random.nat - #let [start (injection sample) - == (comparison n.=)]] - (_.test "Right identity." - (== start - (|> start _//split (_//map _//unwrap)))))) - -(def: (associativity injection comparison (^open "_//.")) - (All [f] (-> (Injection f) (Comparison f) (CoMonad f) Test)) - (do {! random.monad} - [sample random.nat - increase (\ ! map (function (_ diff) - (|>> _//unwrap (n.+ diff))) - random.nat) - decrease (\ ! map (function (_ diff) - (|>> _//unwrap(n.- diff))) - random.nat) - #let [start (injection sample) - == (comparison n.=)]] - (_.test "Associativity." - (== (|> start _//split (_//map (|>> _//split (_//map increase) decrease))) - (|> start _//split (_//map increase) _//split (_//map decrease)))))) - -(def: #export (spec injection comparison subject) - (All [f] (-> (Injection f) (Comparison f) (CoMonad f) Test)) - (<| (_.for [/.CoMonad]) - ($_ _.and - (..left-identity injection subject) - (..right-identity injection comparison subject) - (..associativity injection comparison subject) - ))) diff --git a/stdlib/source/spec/lux/abstract/enum.lux b/stdlib/source/spec/lux/abstract/enum.lux deleted file mode 100644 index ddb2a80f1..000000000 --- a/stdlib/source/spec/lux/abstract/enum.lux +++ /dev/null @@ -1,27 +0,0 @@ -(.module: - [library - [lux #* - ["_" test (#+ Test)] - [abstract - [monad (#+ do)]] - [math - ["." random (#+ Random)]]]] - [\\library - ["." /]]) - -(def: #export (spec (^open "\.") gen-sample) - (All [a] (-> (/.Enum a) (Random a) Test)) - (do random.monad - [sample gen-sample] - (<| (_.for [/.Enum]) - ($_ _.and - (_.test "Successor and predecessor are inverse functions." - (and (\= (|> sample \succ \pred) - sample) - (\= (|> sample \pred \succ) - sample) - (not (\= (\succ sample) - sample)) - (not (\= (\pred sample) - sample)))) - )))) diff --git a/stdlib/source/spec/lux/abstract/equivalence.lux b/stdlib/source/spec/lux/abstract/equivalence.lux deleted file mode 100644 index 4d6d0900a..000000000 --- a/stdlib/source/spec/lux/abstract/equivalence.lux +++ /dev/null @@ -1,24 +0,0 @@ -(.module: - [library - [lux #* - ["_" test (#+ Test)] - [abstract - [monad (#+ do)]] - [math - ["." random (#+ Random)]]]] - [\\library - ["." / (#+ Equivalence)]]) - -(def: #export (spec (^open "_//.") random) - (All [a] (-> (Equivalence a) (Random a) Test)) - (do random.monad - [left random - right random] - (<| (_.for [/.Equivalence]) - ($_ _.and - (_.test "Reflexivity." - (_//= left left)) - (_.test "Symmetry." - (if (_//= left right) - (_//= right left) - (not (_//= right left)))))))) diff --git a/stdlib/source/spec/lux/abstract/fold.lux b/stdlib/source/spec/lux/abstract/fold.lux deleted file mode 100644 index 2b4a7617f..000000000 --- a/stdlib/source/spec/lux/abstract/fold.lux +++ /dev/null @@ -1,23 +0,0 @@ -(.module: - [library - [lux #* - ["_" test (#+ Test)] - [abstract - [monad (#+ do)]] - [math - ["." random] - [number - ["n" nat]]]]] - [// - [functor (#+ Injection Comparison)]] - [\\library - ["." /]]) - -(def: #export (spec injection comparison (^open "@//.")) - (All [f] (-> (Injection f) (Comparison f) (/.Fold f) Test)) - (do random.monad - [subject random.nat - parameter random.nat] - (_.cover [/.Fold] - (n.= (@//fold n.+ parameter (injection subject)) - (n.+ parameter subject))))) diff --git a/stdlib/source/spec/lux/abstract/functor.lux b/stdlib/source/spec/lux/abstract/functor.lux deleted file mode 100644 index cfa6cc2ff..000000000 --- a/stdlib/source/spec/lux/abstract/functor.lux +++ /dev/null @@ -1,62 +0,0 @@ -(.module: - [library - [lux #* - ["_" test (#+ Test)] - [abstract - [equivalence (#+ Equivalence)] - [monad (#+ do)]] - [control - ["." function]] - [math - ["." random] - [number - ["n" nat]]]]] - [\\library - ["." / (#+ Functor)]]) - -(type: #export (Injection f) - (All [a] (-> a (f a)))) - -(type: #export (Comparison f) - (All [a] - (-> (Equivalence a) - (Equivalence (f a))))) - -(def: (identity injection comparison (^open "@//.")) - (All [f] (-> (Injection f) (Comparison f) (Functor f) Test)) - (do {! random.monad} - [sample (\ ! map injection random.nat)] - (_.test "Identity." - ((comparison n.=) - (@//map function.identity sample) - sample)))) - -(def: (homomorphism injection comparison (^open "@//.")) - (All [f] (-> (Injection f) (Comparison f) (Functor f) Test)) - (do {! random.monad} - [sample random.nat - increase (\ ! map n.+ random.nat)] - (_.test "Homomorphism." - ((comparison n.=) - (@//map increase (injection sample)) - (injection (increase sample)))))) - -(def: (composition injection comparison (^open "@//.")) - (All [f] (-> (Injection f) (Comparison f) (Functor f) Test)) - (do {! random.monad} - [sample (\ ! map injection random.nat) - increase (\ ! map n.+ random.nat) - decrease (\ ! map n.- random.nat)] - (_.test "Composition." - ((comparison n.=) - (|> sample (@//map increase) (@//map decrease)) - (|> sample (@//map (|>> increase decrease))))))) - -(def: #export (spec injection comparison functor) - (All [f] (-> (Injection f) (Comparison f) (Functor f) Test)) - (<| (_.for [/.Functor]) - ($_ _.and - (..identity injection comparison functor) - (..homomorphism injection comparison functor) - (..composition injection comparison functor) - ))) diff --git a/stdlib/source/spec/lux/abstract/functor/contravariant.lux b/stdlib/source/spec/lux/abstract/functor/contravariant.lux deleted file mode 100644 index cba839e94..000000000 --- a/stdlib/source/spec/lux/abstract/functor/contravariant.lux +++ /dev/null @@ -1,31 +0,0 @@ -(.module: - [library - [lux #* - ["_" test (#+ Test)] - [abstract - [equivalence (#+ Equivalence)] - [monad (#+ do)]] - [control - ["." function]] - [math - ["." random] - [number - ["n" nat]]]]] - [\\library - ["." / (#+ Functor)]]) - -(def: (identity equivalence value (^open "@//.")) - (All [f a] (-> (Equivalence (f a)) (f a) (Functor f) Test)) - (_.test "Law of identity." - (equivalence - (@//map function.identity value) - value))) - -(def: #export (spec equivalence value functor) - (All [f a] (-> (Equivalence (f a)) (f a) (Functor f) Test)) - (do random.monad - [sample random.nat] - (<| (_.for [/.Functor]) - ($_ _.and - (..identity equivalence value functor) - )))) diff --git a/stdlib/source/spec/lux/abstract/hash.lux b/stdlib/source/spec/lux/abstract/hash.lux deleted file mode 100644 index 4722a48a0..000000000 --- a/stdlib/source/spec/lux/abstract/hash.lux +++ /dev/null @@ -1,23 +0,0 @@ -(.module: - [library - [lux #* - ["_" test (#+ Test)] - [abstract - [monad (#+ do)]] - [data - ["." bit ("#\." equivalence)]] - [math - ["." random (#+ Random)] - [number - ["n" nat]]]]] - [\\library - ["." /]]) - -(def: #export (spec (^open "\.") random) - (All [a] (-> (/.Hash a) (Random a) Test)) - (do random.monad - [parameter random - subject random] - (_.cover [/.Hash] - (bit\= (\= parameter subject) - (n.= (\hash parameter) (\hash subject)))))) diff --git a/stdlib/source/spec/lux/abstract/interval.lux b/stdlib/source/spec/lux/abstract/interval.lux deleted file mode 100644 index 5b74bc34d..000000000 --- a/stdlib/source/spec/lux/abstract/interval.lux +++ /dev/null @@ -1,23 +0,0 @@ -(.module: - [library - [lux #* - ["_" test (#+ Test)] - [abstract - [monad (#+ do)] - ["." order]] - [math - ["." random (#+ Random)]]]] - [\\library - ["." /]]) - -(def: #export (spec (^open "@//.") gen-sample) - (All [a] (-> (/.Interval a) (Random a) Test)) - (<| (_.for [/.Interval]) - (do random.monad - [sample gen-sample] - ($_ _.and - (_.test "No value is bigger than the top." - (@//< @//top sample)) - (_.test "No value is smaller than the bottom." - (order.> @//&order @//bottom sample)) - )))) diff --git a/stdlib/source/spec/lux/abstract/monad.lux b/stdlib/source/spec/lux/abstract/monad.lux deleted file mode 100644 index 869eb24c7..000000000 --- a/stdlib/source/spec/lux/abstract/monad.lux +++ /dev/null @@ -1,57 +0,0 @@ -(.module: - [library - [lux #* - ["_" test (#+ Test)] - [math - ["." random] - [number - ["n" nat]]]]] - [\\library - ["." / (#+ do)]] - [// - [functor (#+ Injection Comparison)]]) - -(def: (left-identity injection comparison (^open "_//.")) - (All [f] (-> (Injection f) (Comparison f) (/.Monad f) Test)) - (do {! random.monad} - [sample random.nat - morphism (\ ! map (function (_ diff) - (|>> (n.+ diff) _//wrap)) - random.nat)] - (_.test "Left identity." - ((comparison n.=) - (|> (injection sample) (_//map morphism) _//join) - (morphism sample))))) - -(def: (right-identity injection comparison (^open "_//.")) - (All [f] (-> (Injection f) (Comparison f) (/.Monad f) Test)) - (do random.monad - [sample random.nat] - (_.test "Right identity." - ((comparison n.=) - (|> (injection sample) (_//map _//wrap) _//join) - (injection sample))))) - -(def: (associativity injection comparison (^open "_//.")) - (All [f] (-> (Injection f) (Comparison f) (/.Monad f) Test)) - (do {! random.monad} - [sample random.nat - increase (\ ! map (function (_ diff) - (|>> (n.+ diff) _//wrap)) - random.nat) - decrease (\ ! map (function (_ diff) - (|>> (n.- diff) _//wrap)) - random.nat)] - (_.test "Associativity." - ((comparison n.=) - (|> (injection sample) (_//map increase) _//join (_//map decrease) _//join) - (|> (injection sample) (_//map (|>> increase (_//map decrease) _//join)) _//join))))) - -(def: #export (spec injection comparison monad) - (All [f] (-> (Injection f) (Comparison f) (/.Monad f) Test)) - (<| (_.for [/.Monad]) - ($_ _.and - (..left-identity injection comparison monad) - (..right-identity injection comparison monad) - (..associativity injection comparison monad) - ))) diff --git a/stdlib/source/spec/lux/abstract/monoid.lux b/stdlib/source/spec/lux/abstract/monoid.lux deleted file mode 100644 index f8626fe74..000000000 --- a/stdlib/source/spec/lux/abstract/monoid.lux +++ /dev/null @@ -1,32 +0,0 @@ -(.module: - [library - [lux #* - ["_" test (#+ Test)] - [abstract - [monad (#+ do)]] - [math - ["." random (#+ Random)]]]] - [\\library - ["." / - [// - [equivalence (#+ Equivalence)]]]]) - -(def: #export (spec (^open "\.") (^open "\.") gen-sample) - (All [a] (-> (Equivalence a) (/.Monoid a) (Random a) Test)) - (do random.monad - [sample gen-sample - left gen-sample - mid gen-sample - right gen-sample] - (<| (_.for [/.Monoid]) - ($_ _.and - (_.test "Left identity." - (\= sample - (\compose \identity sample))) - (_.test "Right identity." - (\= sample - (\compose sample \identity))) - (_.test "Associativity." - (\= (\compose left (\compose mid right)) - (\compose (\compose left mid) right))) - )))) diff --git a/stdlib/source/spec/lux/abstract/order.lux b/stdlib/source/spec/lux/abstract/order.lux deleted file mode 100644 index 61fc22611..000000000 --- a/stdlib/source/spec/lux/abstract/order.lux +++ /dev/null @@ -1,58 +0,0 @@ -(.module: - [library - [lux #* - ["_" test (#+ Test)] - [abstract - [monad (#+ do)]] - [math - ["." random (#+ Random)]]]] - [\\library - ["." /]]) - -(def: #export (spec (^open "@//.") generator) - (All [a] (-> (/.Order a) (Random a) Test)) - (<| (_.for [/.Order]) - ($_ _.and - (do random.monad - [parameter generator - subject generator] - (_.test "Values are either ordered, or they are equal. All options are mutually exclusive." - (cond (@//< parameter subject) - (not (or (@//< subject parameter) - (@//= parameter subject))) - - (@//< subject parameter) - (not (@//= parameter subject)) - - ## else - (@//= parameter subject)))) - (do random.monad - [parameter generator - subject (random.filter (|>> (@//= parameter) not) - generator) - extra (random.filter (function (_ value) - (not (or (@//= parameter value) - (@//= subject value)))) - generator)] - (_.test "Transitive property." - (if (@//< parameter subject) - (let [greater? (and (@//< subject extra) - (@//< parameter extra)) - lesser? (and (@//< extra parameter) - (@//< extra subject)) - in-between? (and (@//< parameter extra) - (@//< extra subject))] - (or greater? - lesser? - in-between?)) - ## (@//< subject parameter) - (let [greater? (and (@//< extra subject) - (@//< extra parameter)) - lesser? (and (@//< parameter extra) - (@//< subject extra)) - in-between? (and (@//< subject extra) - (@//< extra parameter))] - (or greater? - lesser? - in-between?))))) - ))) diff --git a/stdlib/source/spec/lux/world/console.lux b/stdlib/source/spec/lux/world/console.lux deleted file mode 100644 index f454b61c9..000000000 --- a/stdlib/source/spec/lux/world/console.lux +++ /dev/null @@ -1,58 +0,0 @@ -(.module: - [library - [lux #* - ["_" test (#+ Test)] - [abstract - [monad (#+ do)]] - [control - [io (#+ IO)] - ["." try] - [concurrency - ["." promise (#+ Promise)]]] - [data - ["." text - ["%" format (#+ format)]]] - [math - ["." random]]]] - [\\library - ["." /]]) - -(def: #export (spec console) - (-> (IO (/.Console Promise)) Test) - (do random.monad - [message (random.ascii/alpha 10)] - (wrap (do promise.monad - [console (promise.future console) - ?write (\ console write (format message text.new_line)) - ?read (\ console read []) - ?read_line (\ console read_line []) - ?close/good (\ console close []) - ?close/bad (\ console close []) - - #let [can_write! - (case ?write - (#try.Success _) - true - - _ - false) - - can_read! - (case [?read ?read_line] - [(#try.Success _) (#try.Success _)] - true - - _ - false) - - can_close! - (case [?close/good ?close/bad] - [(#try.Success _) (#try.Failure _)] - true - - _ - false)]] - (_.cover' [/.Console] - (and can_write! - can_read! - can_close!)))))) diff --git a/stdlib/source/spec/lux/world/file.lux b/stdlib/source/spec/lux/world/file.lux deleted file mode 100644 index 7bdefb173..000000000 --- a/stdlib/source/spec/lux/world/file.lux +++ /dev/null @@ -1,351 +0,0 @@ -(.module: - [library - [lux #* - ["_" test (#+ Test)] - [abstract - [monad (#+ do)] - ["." predicate]] - [control - [pipe (#+ case>)] - [io (#+ IO)] - ["." try ("#\." functor)] - ["." exception] - [concurrency - ["." promise (#+ Promise)]]] - [data - ["." maybe ("#\." functor)] - ["." text ("#\." equivalence) - ["%" format (#+ format)] - [encoding - ["." utf8 ("#\." codec)]]] - ["." binary (#+ Binary) ("#\." equivalence monoid) - ["$#" \\test]] - [collection - ["." list]]] - [math - ["." random] - [number - ["n" nat]]] - [time - ["." instant (#+ Instant) ("#\." equivalence)]]]] - [\\library - ["." /]]) - -(def: (for_path fs) - (-> (IO (/.System Promise)) Test) - (<| (_.for [/.Path]) - (do {! random.monad} - [parent (random.ascii/numeric 2) - child (random.ascii/numeric 2)]) - wrap - (do promise.monad - [fs (promise.future fs)] - ($_ _.and' - (_.cover' [/.un_nest] - (and (|> (/.un_nest fs parent) - (case> (#.Some _) - false - - #.None - true)) - (|> (/.un_nest fs child) - (case> (#.Some _) - false - - #.None - true)))) - (_.cover' [/.nest] - (|> (/.nest fs parent child) - (/.un_nest fs) - (case> (#.Some [parent' child']) - (and (text\= parent parent') - (text\= child child')) - - #.None - false))) - (_.cover' [/.parent] - (|> (/.nest fs parent child) - (/.parent fs) - (maybe\map (text\= parent)) - (maybe.default false))) - (_.cover' [/.name] - (|> (/.nest fs parent child) - (/.name fs) - (text\= child))) - )))) - -(def: (directory?&make_directory fs parent) - (-> (/.System Promise) /.Path (Promise Bit)) - (do promise.monad - [directory_pre! (\ fs directory? parent) - made? (\ fs make_directory parent) - directory_post! (\ fs directory? parent)] - (wrap (and (not directory_pre!) - (case made? - (#try.Success _) true - (#try.Failure _) false) - directory_post!)))) - -(def: (file?&write fs content path) - (-> (/.System Promise) Binary /.Path (Promise Bit)) - (do promise.monad - [file_pre! (\ fs file? path) - made? (\ fs write content path) - file_post! (\ fs file? path)] - (wrap (and (not file_pre!) - (case made? - (#try.Success _) true - (#try.Failure _) false) - file_post!)))) - -(def: (file_size&read&append fs expected_file_size content appendix path) - (-> (/.System Promise) Nat Binary Binary /.Path (Promise Bit)) - (do promise.monad - [pre_file_size (\ fs file_size path) - pre_content (\ fs read path) - appended? (\ fs append appendix path) - post_file_size (\ fs file_size path) - post_content (\ fs read path)] - (wrap (<| (try.default false) - (do {! try.monad} - [pre_file_size! - (\ ! map (n.= expected_file_size) pre_file_size) - - pre_content! - (\ ! map (binary\= content) pre_content) - - _ appended? - - post_file_size! - (\ ! map (n.= (n.* 2 expected_file_size)) post_file_size) - - post_content! - (\ ! map (binary\= (binary\compose content appendix)) post_content)] - (wrap (and pre_file_size! - pre_content! - post_file_size! - post_content!))))))) - -(def: (modified?&last_modified fs expected_time path) - (-> (/.System Promise) Instant /.Path (Promise Bit)) - (do promise.monad - [modified? (\ fs modify expected_time path) - last_modified (\ fs last_modified path)] - (wrap (<| (try.default false) - (do {! try.monad} - [_ modified?] - (\ ! map (instant\= expected_time) last_modified)))))) - -(def: (directory_files&sub_directories fs parent sub_dir child) - (-> (/.System Promise) /.Path /.Path /.Path (Promise Bit)) - (let [sub_dir (/.nest fs parent sub_dir) - child (/.nest fs parent child)] - (do promise.monad - [made_sub? (\ fs make_directory sub_dir) - directory_files (\ fs directory_files parent) - sub_directories (\ fs sub_directories parent) - #let [(^open "list\.") (list.equivalence text.equivalence)]] - (wrap (<| (try.default false) - (do try.monad - [_ made_sub?] - (wrap (and (|> directory_files - (try\map (list\= (list child))) - (try.default false)) - (|> sub_directories - (try\map (list\= (list sub_dir))) - (try.default false)))))))))) - -(def: (move&delete fs parent child alternate_child) - (-> (/.System Promise) /.Path Text Text (Promise Bit)) - (let [origin (/.nest fs parent child) - destination (/.nest fs parent alternate_child)] - (do {! promise.monad} - [moved? (\ fs move destination origin) - lost? (|> origin - (\ fs file?) - (\ ! map not)) - found? (\ fs file? destination) - deleted? (\ fs delete destination)] - (wrap (<| (try.default false) - (do try.monad - [_ moved? - _ deleted?] - (wrap (and lost? - found?)))))))) - -(def: (for_system fs) - (-> (IO (/.System Promise)) Test) - (<| (do {! random.monad} - [parent (random.ascii/numeric 2) - child (random.ascii/numeric 2) - sub_dir (random.filter (|>> (text\= child) not) - (random.ascii/numeric 2)) - alternate_child (random.filter (predicate.intersect - (|>> (text\= child) not) - (|>> (text\= sub_dir) not)) - (random.ascii/numeric 2)) - expected_file_size (\ ! map (|>> (n.% 10) inc) random.nat) - content ($binary.random expected_file_size) - appendix ($binary.random expected_file_size) - expected_time random.instant]) - wrap - (do {! promise.monad} - [fs (promise.future fs) - #let [path (/.nest fs parent child)] - - directory?&make_directory - (..directory?&make_directory fs parent) - - file?&write - (..file?&write fs content path) - - file_size&read&append - (..file_size&read&append fs expected_file_size content appendix path) - - modified?&last_modified - (..modified?&last_modified fs expected_time path) - - can_execute? - (|> path - (\ fs can_execute?) - (\ ! map (|>> (try.default true) not))) - - directory_files&sub_directories - (..directory_files&sub_directories fs parent sub_dir child) - - move&delete - (..move&delete fs parent child alternate_child)]) - (_.cover' [/.System] - (and directory?&make_directory - file?&write - file_size&read&append - modified?&last_modified - can_execute? - directory_files&sub_directories - move&delete)))) - -(def: (make_directories&cannot_make_directory fs) - (-> (IO (/.System Promise)) Test) - (<| (do {! random.monad} - [dir/0 (random.ascii/numeric 2) - dir/1 (random.ascii/numeric 2) - dir/2 (random.ascii/numeric 2)]) - wrap - (do {! promise.monad} - [fs (promise.future fs) - #let [dir/1 (/.nest fs dir/0 dir/1) - dir/2 (/.nest fs dir/1 dir/2)] - pre_dir/0 (\ fs directory? dir/0) - pre_dir/1 (\ fs directory? dir/1) - pre_dir/2 (\ fs directory? dir/2) - made? (/.make_directories ! fs dir/2) - post_dir/0 (\ fs directory? dir/0) - post_dir/1 (\ fs directory? dir/1) - post_dir/2 (\ fs directory? dir/2) - - cannot_make_directory!/0 (/.make_directories ! fs "") - cannot_make_directory!/1 (/.make_directories ! fs (\ fs separator))]) - ($_ _.and' - (_.cover' [/.make_directories] - (and (not pre_dir/0) - (not pre_dir/1) - (not pre_dir/2) - (case made? - (#try.Success _) true - (#try.Failure _) false) - post_dir/0 - post_dir/1 - post_dir/2)) - (_.cover' [/.cannot_make_directory] - (and (case cannot_make_directory!/0 - (#try.Success _) - false - - (#try.Failure error) - (exception.match? /.cannot_make_directory error)) - (case cannot_make_directory!/1 - (#try.Success _) - false - - (#try.Failure error) - (exception.match? /.cannot_make_directory error)))) - ))) - -(def: (make_file&cannot_make_file fs) - (-> (IO (/.System Promise)) Test) - (<| (do {! random.monad} - [file/0 (random.ascii/numeric 3)]) - wrap - (do {! promise.monad} - [fs (promise.future fs) - make_file!/0 (/.make_file ! fs (utf8\encode file/0) file/0) - make_file!/1 (/.make_file ! fs (utf8\encode file/0) file/0)]) - ($_ _.and' - (_.cover' [/.make_file] - (case make_file!/0 - (#try.Success _) true - (#try.Failure error) false)) - (_.cover' [/.cannot_make_file] - (case make_file!/1 - (#try.Success _) - false - - (#try.Failure error) - (exception.match? /.cannot_make_file error))) - ))) - -(def: (for_utilities fs) - (-> (IO (/.System Promise)) Test) - ($_ _.and - (..make_directories&cannot_make_directory fs) - (..make_file&cannot_make_file fs) - )) - -(def: (exists? fs) - (-> (IO (/.System Promise)) Test) - (<| (do {! random.monad} - [file (random.ascii/numeric 2) - dir (random.filter (|>> (text\= file) not) - (random.ascii/numeric 2))]) - wrap - (do {! promise.monad} - [fs (promise.future fs) - - pre_file/0 (\ fs file? file) - pre_file/1 (/.exists? ! fs file) - pre_dir/0 (\ fs directory? dir) - pre_dir/1 (/.exists? ! fs dir) - - made_file? (/.make_file ! fs (utf8\encode file) file) - made_dir? (\ fs make_directory dir) - - post_file/0 (\ fs file? file) - post_file/1 (/.exists? ! fs file) - post_dir/0 (\ fs directory? dir) - post_dir/1 (/.exists? ! fs dir)]) - (_.cover' [/.exists?] - (and (not pre_file/0) - (not pre_file/1) - (not pre_dir/0) - (not pre_dir/1) - - (case made_file? - (#try.Success _) true - (#try.Failure _) false) - (case made_dir? - (#try.Success _) true - (#try.Failure _) false) - - post_file/0 - post_file/1 - post_dir/0 - post_dir/1)))) - -(def: #export (spec fs) - (-> (IO (/.System Promise)) Test) - ($_ _.and - (..for_path fs) - (..for_utilities fs) - (..for_system fs) - (..exists? fs) - )) diff --git a/stdlib/source/spec/lux/world/program.lux b/stdlib/source/spec/lux/world/program.lux deleted file mode 100644 index e79429627..000000000 --- a/stdlib/source/spec/lux/world/program.lux +++ /dev/null @@ -1,32 +0,0 @@ -(.module: - [library - [lux #* - ["_" test (#+ Test)] - [abstract - [monad (#+ do)]] - [control - ["." try] - [concurrency - ["." promise (#+ Promise)]]] - [data - ["." text] - [collection - ["." dictionary] - ["." list]]] - [math - ["." random]]]] - [\\library - ["." /]]) - -(def: #export (spec subject) - (-> (/.Program Promise) Test) - (do random.monad - [exit random.int] - (wrap (do {! promise.monad} - [environment (/.environment ! subject)] - (_.cover' [/.Program] - (and (not (dictionary.empty? environment)) - (list.every? (|>> text.empty? not) - (dictionary.keys environment)) - (not (text.empty? (\ subject home))) - (not (text.empty? (\ subject directory))))))))) diff --git a/stdlib/source/spec/lux/world/shell.lux b/stdlib/source/spec/lux/world/shell.lux deleted file mode 100644 index c4fc51b99..000000000 --- a/stdlib/source/spec/lux/world/shell.lux +++ /dev/null @@ -1,92 +0,0 @@ -(.module: - [library - [lux #* - ["_" test (#+ Test)] - [abstract - [monad (#+ do)]] - [control - ["." try ("#\." functor)] - [concurrency - ["." promise (#+ Promise) ("#\." monad)]] - [parser - ["." environment (#+ Environment)]]] - [data - ["." product] - ["." text ("#\." equivalence) - ["%" format (#+ format)]]] - [math - ["." random] - [number - ["n" nat] - ["i" int]]]]] - [\\library - ["." / - [// - [file (#+ Path)]]]]) - -(template [ ] - [(def: - (-> [Environment Path /.Command (List /.Argument)]) - (|>> list [environment.empty "~" ]))] - - [echo! "echo" Text (|>)] - [sleep! "sleep" Nat %.nat] - ) - -(def: (can_wait! process) - (-> (/.Process Promise) _.Assertion) - (|> (\ process await []) - (promise\map (|>> (try\map (i.= /.normal)) - (try.default false) - (_.cover' [/.Exit /.normal]))) - promise\join)) - -(def: (can_read! expected process) - (-> Text (/.Process Promise) (Promise Bit)) - (|> (\ process read []) - (promise\map (|>> (try\map (text\= expected)) - (try.default false))))) - -(def: (can_destroy! process) - (-> (/.Process Promise) (Promise Bit)) - (do promise.monad - [?destroy (\ process destroy []) - ?await (\ process await [])] - (wrap (and (case ?destroy - (#try.Success _) - true - - (#try.Failure error) - false) - (case ?await - (#try.Success _) - false - - (#try.Failure error) - true))))) - -(with_expansions [ (as_is [/.Command /.Argument])] - (def: #export (spec shell) - (-> (/.Shell Promise) Test) - (<| (_.for [/.Shell /.Process]) - (do {! random.monad} - [message (random.ascii/alpha 10) - seconds (\ ! map (|>> (n.% 5) (n.+ 5)) random.nat)] - (wrap (do {! promise.monad} - [?echo (\ shell execute (..echo! message)) - ?sleep (\ shell execute (..sleep! seconds))] - (case [?echo ?sleep] - [(#try.Success echo) (#try.Success sleep)] - (do ! - [can_read! (..can_read! message echo) - can_destroy! (..can_destroy! sleep)] - ($_ _.and' - (_.cover' - (and can_read! - can_destroy!)) - (..can_wait! echo) - )) - - _ - (_.cover' - false)))))))) diff --git a/stdlib/source/specification/aedifex/repository.lux b/stdlib/source/specification/aedifex/repository.lux new file mode 100644 index 000000000..de9a05fde --- /dev/null +++ b/stdlib/source/specification/aedifex/repository.lux @@ -0,0 +1,57 @@ +(.module: + [library + [lux #* + ["_" test (#+ Test)] + [abstract + [monad (#+ do)]] + [control + ["." try (#+ Try)] + [concurrency + ["." promise (#+ Promise)]]] + [data + ["." binary + ["_#" \\test]]] + [math + ["." random]]]] + [\\program + ["." / + ["#." remote] + ["/#" // #_ + ["#." artifact (#+ Artifact) + ["#/." extension]]]]] + [\\test + ["_." // #_ + ["#." artifact]]]) + +(def: #export (spec valid_artifact invalid_artifact subject) + (-> Artifact Artifact (/.Repository Promise) Test) + (do random.monad + [expected (_binary.random 100)] + (wrap ($_ _.and' + (do promise.monad + [#let [good_uri (/remote.uri (get@ #//artifact.version valid_artifact) valid_artifact //artifact/extension.lux_library)] + good_upload! (\ subject upload good_uri expected) + good_download! (\ subject download good_uri) + + #let [bad_uri (/remote.uri (get@ #//artifact.version invalid_artifact) invalid_artifact //artifact/extension.lux_library)] + bad_upload! (\ subject upload bad_uri expected) + bad_download! (\ subject download bad_uri)] + (_.cover' [/.Repository] + (let [successfull_flow! + (case [good_upload! good_download!] + [(#try.Success _) (#try.Success actual)] + (\ binary.equivalence = expected actual) + + _ + false) + + failed_flow! + (case [bad_upload! bad_download!] + [(#try.Failure _) (#try.Failure _)] + true + + _ + false)] + (and successfull_flow! + failed_flow!)))) + )))) diff --git a/stdlib/source/specification/compositor.lux b/stdlib/source/specification/compositor.lux new file mode 100644 index 000000000..08a294282 --- /dev/null +++ b/stdlib/source/specification/compositor.lux @@ -0,0 +1,67 @@ +(.module: + [lux #* + ["_" test (#+ Test)] + [abstract + [monad (#+ do)]] + [control + ["." io (#+ IO)] + ["." try]] + [math + ["r" random]] + [tool + [compiler + ["." analysis] + ["." directive] + [phase + [macro (#+ Expander)] + [generation (#+ Bundle)]] + [default + [platform (#+ Platform)]]]]] + ["." / #_ + ["#." common (#+ Runner Definer)] + ["#./" analysis #_ + ["#." type]] + ["#./" generation #_ + ["#." primitive] + ["#." structure] + ["#." reference] + ["#." case] + ["#." function] + ["#." common]]]) + +(def: (test runner definer state expander) + (-> Runner Definer analysis.State+ Expander Test) + ($_ _.and + (/analysis/type.spec expander state) + (/generation/primitive.spec runner) + (/generation/structure.spec runner) + (/generation/reference.spec runner definer) + (/generation/case.spec runner) + (/generation/function.spec runner) + (/generation/common.spec runner) + )) + +(def: #export (spec platform bundle expander program) + (All [anchor expression directive] + (-> (IO (Platform IO anchor expression directive)) + (Bundle anchor expression directive) + Expander + (-> expression directive) + Test)) + (do r.monad + [_ (wrap []) + #let [?state,runner,definer (<| io.run + (do io.monad + [platform platform]) + (/common.executors platform + bundle + expander + program))]] + (case ?state,runner,definer + (#try.Success [[directive-bundle directive-state] runner definer]) + (..test runner definer + (get@ [#directive.analysis #directive.state] directive-state) + expander) + + (#try.Failure error) + (_.fail error)))) diff --git a/stdlib/source/specification/compositor/analysis/type.lux b/stdlib/source/specification/compositor/analysis/type.lux new file mode 100644 index 000000000..7cbd5884b --- /dev/null +++ b/stdlib/source/specification/compositor/analysis/type.lux @@ -0,0 +1,63 @@ +(.module: + [lux #* + ["_" test (#+ Test)] + [abstract + [monad (#+ do)]] + [control + [pipe (#+ case>)] + ["." io] + ["." try]] + [math + ["r" random (#+ Random)]] + [macro + ["." code]] + [tool + [compiler + [analysis (#+ State+)] + ["." phase + [macro (#+ Expander)] + ["." analysis + ["#/." scope] + ["#/." type]]]]]]) + +(def: (check-success+ expander state extension params output-type) + (-> Expander State+ Text (List Code) Type Bit) + (|> (analysis/scope.with-scope "" + (analysis/type.with-type output-type + (analysis.phase expander (` ((~ (code.text extension)) (~+ params)))))) + (phase.run state) + (case> (#try.Success _) + true + + (#try.Failure _) + false))) + +(def: check + (Random [Code Type Code]) + (`` ($_ r.either + (~~ (template [ ] + [(do r.monad + [value ] + (wrap [(` ) + + ( value)]))] + + [r.bit (0 #0 "#Bit" (0 #0)) code.bit] + [r.nat (0 #0 "#I64" (0 #1 (0 #0 "#Nat" (0 #0)) (0 #0))) code.nat] + [r.int (0 #0 "#I64" (0 #1 (0 #0 "#Int" (0 #0)) (0 #0))) code.int] + [r.rev (0 #0 "#I64" (0 #1 (0 #0 "#Rev" (0 #0)) (0 #0))) code.rev] + [r.safe-frac (0 #0 "#Frac" (0 #0)) code.frac] + [(r.ascii/upper-alpha 5) (0 #0 "#Text" (0 #0)) code.text] + ))))) + +(def: #export (spec expander state) + (-> Expander State+ Test) + (do r.monad + [[typeC exprT exprC] ..check + [other-typeC other-exprT other-exprC] ..check] + ($_ _.and + (_.test "lux check" + (check-success+ expander state "lux check" (list typeC exprC) exprT)) + (_.test "lux coerce" + (check-success+ expander state "lux coerce" (list typeC other-exprC) exprT)) + ))) diff --git a/stdlib/source/specification/compositor/common.lux b/stdlib/source/specification/compositor/common.lux new file mode 100644 index 000000000..ed3b53f30 --- /dev/null +++ b/stdlib/source/specification/compositor/common.lux @@ -0,0 +1,81 @@ +(.module: + [lux #* + [abstract + [monad (#+ do)]] + [control + ["." io (#+ IO)] + ["." try (#+ Try)]] + [tool + [compiler + ["." reference] + ["." analysis] + ["." synthesis (#+ Synthesis)] + ["." directive] + ["." phase + ["." macro (#+ Expander)] + ["." generation (#+ Operation)] + [extension (#+ Extender) + ["." bundle]]] + [default + ["." platform (#+ Platform)]]]]]) + +(type: #export Runner + (-> Text Synthesis (Try Any))) + +(type: #export Definer + (-> Name Synthesis (Try Any))) + +(type: #export (Instancer what) + (All [anchor expression directive] + (-> (Platform IO anchor expression directive) + (generation.State+ anchor expression directive) + what))) + +(def: (runner (^slots [#platform.runtime #platform.phase #platform.host]) state) + (Instancer Runner) + (function (_ evaluation-name expressionS) + (do try.monad + [expressionG (<| (phase.run state) + generation.with-buffer + (do phase.monad + [_ runtime] + (phase expressionS)))] + (\ host evaluate! evaluation-name expressionG)))) + +(def: (definer (^slots [#platform.runtime #platform.phase #platform.host]) + state) + (Instancer Definer) + (function (_ lux-name expressionS) + (do try.monad + [definitionG (<| (phase.run state) + generation.with-buffer + (do phase.monad + [_ runtime + expressionG (phase expressionS) + [host-name host-value host-directive] (generation.define! lux-name expressionG) + _ (generation.learn lux-name host-name)] + (phase (synthesis.constant lux-name))))] + (\ host evaluate! "definer" definitionG)))) + +(def: #export (executors target expander platform + analysis-bundle generation-bundle directive-bundle + program extender) + (All [anchor expression directive] + (-> Text Expander (Platform IO anchor expression directive) + analysis.Bundle + (generation.Bundle anchor expression directive) + (directive.Bundle anchor expression directive) + (-> expression directive) Extender + (IO (Try [(directive.State+ anchor expression directive) + Runner + Definer])))) + (do io.monad + [?state (platform.initialize target expander analysis-bundle platform generation-bundle directive-bundle program extender)] + (wrap (do try.monad + [[directive-bundle directive-state] ?state + #let [generation-state (get@ [#directive.generation + #directive.state] + directive-state)]] + (wrap [[directive-bundle directive-state] + (..runner platform generation-state) + (..definer platform generation-state)]))))) diff --git a/stdlib/source/specification/compositor/generation/case.lux b/stdlib/source/specification/compositor/generation/case.lux new file mode 100644 index 000000000..2424aa330 --- /dev/null +++ b/stdlib/source/specification/compositor/generation/case.lux @@ -0,0 +1,288 @@ +(.module: + [lux (#- case) + ["_" test (#+ Test)] + [abstract + [monad (#+ do)]] + [control + [pipe (#+ case>)] + ["." try (#+ Try)]] + [data + ["." text ("#\." equivalence) + ["%" format (#+ format)]] + [number + ["n" nat] + ["f" frac]] + [collection + ["." list ("#\." fold)]]] + [math + ["r" random (#+ Random)]] + [tool + [compiler + ["." reference] + ["." analysis] + ["." synthesis (#+ Path Synthesis)] + ["." phase + ["#/." synthesis + ["." case]] + ["." extension/synthesis]]]]] + [/// + [common (#+ Runner)]]) + +(def: limit Nat 10) + +(def: size + (Random Nat) + (|> r.nat (\ r.monad map (|>> (n.% ..limit) (n.max 2))))) + +(def: (tail? size idx) + (-> Nat Nat Bit) + (n.= (dec size) idx)) + +(def: #export (verify expected) + (-> Frac (Try Any) Bit) + (|>> (case> (#try.Success actual) + (f.= expected (:as Frac actual)) + + (#try.Failure _) + false))) + +(def: case + (Random [Synthesis Path]) + (<| r.rec (function (_ case)) + (`` ($_ r.either + (do r.monad + [value r.i64] + (wrap [(synthesis.i64 value) + synthesis.path/pop])) + (~~ (template [ ] + [(do r.monad + [value ] + (wrap [( value) + ( value)]))] + + [r.bit synthesis.bit synthesis.path/bit] + [r.i64 synthesis.i64 synthesis.path/i64] + [r.frac synthesis.f64 synthesis.path/f64] + [(r.unicode 5) synthesis.text synthesis.path/text])) + (do {! r.monad} + [size ..size + idx (|> r.nat (\ ! map (n.% size))) + [subS subP] case + #let [unitS (synthesis.text synthesis.unit) + caseS (synthesis.tuple + (list.concat (list (list.repeat idx unitS) + (list subS) + (list.repeat (|> size dec (n.- idx)) unitS)))) + caseP ($_ synthesis.path/seq + (if (tail? size idx) + (synthesis.member/right idx) + (synthesis.member/left idx)) + subP)]] + (wrap [caseS caseP])) + (do {! r.monad} + [size ..size + idx (|> r.nat (\ ! map (n.% size))) + [subS subP] case + #let [right? (tail? size idx) + caseS (synthesis.variant + {#analysis.lefts idx + #analysis.right? right? + #analysis.value subS}) + caseP ($_ synthesis.path/seq + (if right? + (synthesis.side/right idx) + (synthesis.side/left idx)) + subP)]] + (wrap [caseS caseP])) + )))) + +(def: (let-spec run) + (-> Runner Test) + (do r.monad + [value r.safe-frac] + (_.test (%.name (name-of synthesis.branch/let)) + (|> (synthesis.branch/let [(synthesis.f64 value) + 0 + (synthesis.variable/local 0)]) + (run "let-spec") + (verify value))))) + +(def: (if-spec run) + (-> Runner Test) + (do r.monad + [on-true r.safe-frac + on-false (|> r.safe-frac (r.filter (|>> (f.= on-true) not))) + verdict r.bit] + (_.test (%.name (name-of synthesis.branch/if)) + (|> (synthesis.branch/if [(synthesis.bit verdict) + (synthesis.f64 on-true) + (synthesis.f64 on-false)]) + (run "if-spec") + (verify (if verdict on-true on-false)))))) + +(def: (case-spec run) + (-> Runner Test) + (do r.monad + [[inputS pathS] ..case + on-success r.safe-frac + on-failure (|> r.safe-frac (r.filter (|>> (f.= on-success) not)))] + (_.test (%.name (name-of synthesis.branch/case)) + (|> (synthesis.branch/case + [inputS + ($_ synthesis.path/alt + ($_ synthesis.path/seq + pathS + (synthesis.path/then (synthesis.f64 on-success))) + (synthesis.path/then (synthesis.f64 on-failure)))]) + (run "case-spec") + (verify on-success))))) + +(def: special-input + Synthesis + (let [_cursor_ (: Synthesis + (synthesis.tuple (list (synthesis.text .prelude_module) + (synthesis.i64 +901) + (synthesis.i64 +13)))) + _code_ (: (-> Synthesis Synthesis) + (function (_ content) + (synthesis.tuple (list _cursor_ content)))) + _nil_ (: Synthesis + (synthesis.variant [0 #0 (synthesis.text "")])) + _cons_ (: (-> Synthesis Synthesis Synthesis) + (function (_ head tail) + (synthesis.variant [0 #1 (synthesis.tuple (list head tail))]))) + _list_ (: (-> (List Synthesis) Synthesis) + (list\fold _cons_ _nil_))] + (let [__tuple__ (: (-> (List Synthesis) Synthesis) + (|>> list.reverse _list_ [9 #0] synthesis.variant _code_)) + __form__ (: (-> (List Synthesis) Synthesis) + (|>> list.reverse _list_ [8 #0] synthesis.variant _code_)) + __text__ (: (-> Text Synthesis) + (function (_ value) + (_code_ (synthesis.variant [5 #0 (synthesis.text value)])))) + __identifier__ (: (-> Name Synthesis) + (function (_ [module short]) + (_code_ (synthesis.variant [6 #0 (synthesis.tuple (list (synthesis.text module) + (synthesis.text short)))])))) + __tag__ (: (-> Name Synthesis) + (function (_ [module short]) + (_code_ (synthesis.variant [7 #0 (synthesis.tuple (list (synthesis.text module) + (synthesis.text short)))])))) + __list__ (: (-> (List Synthesis) Synthesis) + (list\fold (function (_ head tail) + (__form__ (list (__tag__ ["" "Cons"]) head tail))) + (__tag__ ["" "Nil"]))) + __apply__ (: (-> Synthesis Synthesis Synthesis) + (function (_ func arg) + (__form__ (list func arg))))] + (|> _nil_ + (_cons_ (__apply__ (__identifier__ ["" "form$"]) + (__list__ (list (__apply__ (__identifier__ ["" "tag$"]) + (__tuple__ (list (__text__ .prelude_module) + (__text__ "Cons")))) + (__identifier__ ["" "export?-meta"]) + (__identifier__ ["" "tail"]))))) + (_cons_ (__tuple__ (list (__identifier__ ["" "tail"])))) + )))) + +(def: special-path + Path + (let [_nil_ (synthesis.path/side (#.Left 0)) + _cons_ (synthesis.path/side (#.Right 0)) + _head_ (synthesis.path/member (#.Left 0)) + _tail_ (synthesis.path/member (#.Right 0)) + _tuple_ (synthesis.path/side (#.Left 9))] + ($_ synthesis.path/alt + ($_ synthesis.path/seq + _cons_ + _head_ + _head_ (synthesis.path/bind 2) synthesis.path/pop + _tail_ _tuple_ _cons_ + _head_ (synthesis.path/bind 3) synthesis.path/pop + _tail_ (synthesis.path/bind 4) synthesis.path/pop + synthesis.path/pop synthesis.path/pop synthesis.path/pop synthesis.path/pop + _tail_ _cons_ + _head_ (synthesis.path/bind 5) synthesis.path/pop + _tail_ _nil_ + ## THEN + (synthesis.path/then (synthesis.bit #1))) + ($_ synthesis.path/seq + (synthesis.path/bind 2) + ## THEN + (synthesis.path/then (synthesis.bit #0)))))) + +(def: special-pattern + analysis.Pattern + (let [## [_ (#Tuple (#Cons arg args'))] + head (<| analysis.pattern/tuple (list (analysis.pattern/bind 2)) + analysis.pattern/variant [9 #0] + analysis.pattern/variant [0 #1] + analysis.pattern/tuple (list (analysis.pattern/bind 3) + (analysis.pattern/bind 4))) + ## (#Cons body #Nil) + tail (<| analysis.pattern/variant [0 #1] + analysis.pattern/tuple (list (analysis.pattern/bind 5)) + analysis.pattern/variant [0 #0] + (analysis.pattern/unit))] + ## (#Cons ) + (<| analysis.pattern/variant [0 #1] + (analysis.pattern/tuple (list head tail))))) + +(def: special-pattern-path + Path + ($_ synthesis.path/alt + (<| try.assume + (phase.run [extension/synthesis.bundle + synthesis.init]) + (case.path phase/synthesis.phase + special-pattern) + (analysis.bit #1)) + ($_ synthesis.path/seq + (synthesis.path/bind 2) + ## THEN + (synthesis.path/then (synthesis.bit #0))))) + +## TODO: Get rid of this ASAP +(def: (special-spec run) + (-> Runner Test) + ($_ _.and + (_.test "===" + (and (text\= (synthesis.%path special-path) + (synthesis.%path special-pattern-path)) + (\ synthesis.path-equivalence = special-path special-pattern-path))) + (_.test "CODE" + (|> special-input + (run "special-input") + (case> (#try.Success output) + true + + (#try.Failure _) + false))) + (_.test "PATTERN-MATCHING 0" + (|> (synthesis.branch/case [special-input + special-path]) + (run "special-path") + (case> (#try.Success output) + true + + (#try.Failure _) + false))) + (_.test "PATTERN-MATCHING 1" + (|> (synthesis.branch/case [special-input + special-pattern-path]) + (run "special-pattern-path") + (case> (#try.Success output) + true + + (#try.Failure _) + false))) + )) + +(def: #export (spec run) + (-> Runner Test) + ($_ _.and + (..special-spec run) + (..let-spec run) + (..if-spec run) + (..case-spec run) + )) diff --git a/stdlib/source/specification/compositor/generation/common.lux b/stdlib/source/specification/compositor/generation/common.lux new file mode 100644 index 000000000..3d377b7ca --- /dev/null +++ b/stdlib/source/specification/compositor/generation/common.lux @@ -0,0 +1,343 @@ +(.module: + [lux (#- i64) + ["_" test (#+ Test)] + [abstract + [monad (#+ do)]] + [control + [pipe (#+ case>)] + ["." try (#+ Try)]] + [data + ["." bit ("#\." equivalence)] + [number + ["." i64] + ["n" nat] + ["i" int] + ["f" frac]] + ["." text ("#\." equivalence) + ["%" format (#+ format)]] + [collection + ["." list]]] + [math + ["r" random (#+ Random)]] + [tool + [compiler + ["." reference] + ["." synthesis]]]] + ["." // #_ + ["#." case] + [// + [common (#+ Runner)]]]) + +(def: sanitize + (-> Text Text) + (text.replace-all " " "_")) + +(def: (bit run) + (-> Runner Test) + (do r.monad + [param r.i64 + subject r.i64] + (with-expansions [ (template [ ] + [(_.test + (|> (#synthesis.Extension (list (synthesis.i64 param) + (synthesis.i64 subject))) + (run (..sanitize )) + (case> (#try.Success valueT) + (n.= ( param subject) (:as Nat valueT)) + + (#try.Failure _) + false) + (let [param ])))] + + ["lux i64 and" i64.and param] + ["lux i64 or" i64.or param] + ["lux i64 xor" i64.xor param] + ["lux i64 left-shift" i64.left-shift (n.% 64 param)] + ["lux i64 logical-right-shift" i64.logic-right-shift (n.% 64 param)] + )] + ($_ _.and + + (_.test "lux i64 arithmetic-right-shift" + (|> (#synthesis.Extension "lux i64 arithmetic-right-shift" + (list (synthesis.i64 subject) + (synthesis.i64 param))) + (run (..sanitize "lux i64 arithmetic-right-shift")) + (case> (#try.Success valueT) + ("lux i64 =" + (i64.arithmetic-right-shift param subject) + (:as I64 valueT)) + + (#try.Failure _) + false) + (let [param (n.% 64 param)]))) + )))) + +(def: (i64 run) + (-> Runner Test) + (do r.monad + [param (|> r.i64 (r.filter (|>> ("lux i64 =" 0) not))) + subject r.i64] + (`` ($_ _.and + (~~ (template [ ] + [(_.test + (|> (#synthesis.Extension (list (synthesis.i64 subject))) + (run (..sanitize )) + (case> (#try.Success valueT) + ( ( subject) (:as valueT)) + + (#try.Failure _) + false) + (let [subject ])))] + + ["lux i64 f64" Frac i.frac f.= subject] + ["lux i64 char" Text (|>> (:as Nat) text.from-code) text\= (|> subject + (:as Nat) + (n.% (i64.left-shift 8 1)) + (:as Int))] + )) + (~~ (template [ ] + [(_.test + (|> (#synthesis.Extension (list (synthesis.i64 param) + (synthesis.i64 subject))) + (run (..sanitize )) + (case> (#try.Success valueT) + ( ( param subject) (:as valueT)) + + (#try.Failure _) + false)))] + + ["lux i64 +" i.+ Int i.=] + ["lux i64 -" i.- Int i.=] + ["lux i64 *" i.* Int i.=] + ["lux i64 /" i./ Int i.=] + ["lux i64 %" i.% Int i.=] + ["lux i64 =" i.= Bit bit\=] + ["lux i64 <" i.< Bit bit\=] + )) + )))) + +(def: simple-frac + (Random Frac) + (|> r.nat (\ r.monad map (|>> (n.% 1000) .int i.frac)))) + +(def: (f64 run) + (-> Runner Test) + (do r.monad + [param (|> ..simple-frac (r.filter (|>> (f.= +0.0) not))) + subject ..simple-frac] + (`` ($_ _.and + (~~ (template [ ] + [(_.test + (|> (#synthesis.Extension (list (synthesis.f64 param) + (synthesis.f64 subject))) + (run (..sanitize )) + (//case.verify ( param subject))))] + + ["lux f64 +" f.+ f.=] + ["lux f64 -" f.- f.=] + ["lux f64 *" f.* f.=] + ["lux f64 /" f./ f.=] + ["lux f64 %" f.% f.=] + )) + (~~ (template [ ] + [(_.test + (|> (#synthesis.Extension (list (synthesis.f64 param) + (synthesis.f64 subject))) + (run (..sanitize )) + (case> (#try.Success valueV) + (bit\= ( param subject) + (:as Bit valueV)) + + _ + false)))] + + ["lux f64 =" f.=] + ["lux f64 <" f.<] + )) + (~~ (template [ ] + [(_.test + (|> (#synthesis.Extension (list)) + (run (..sanitize )) + (//case.verify )))] + + ["lux f64 min" ("lux f64 min")] + ["lux f64 max" ("lux f64 max")] + ["lux f64 smallest" ("lux f64 smallest")] + )) + (_.test "'lux f64 i64 && 'lux i64 f64'" + (|> (run (..sanitize "lux f64 i64") + (|> subject synthesis.f64 + (list) (#synthesis.Extension "lux f64 i64") + (list) (#synthesis.Extension "lux i64 f64"))) + (//case.verify subject))) + )))) + +(def: (text run) + (-> Runner Test) + (do {! r.monad} + [sample-size (|> r.nat (\ ! map (|>> (n.% 10) (n.max 1)))) + sample-lower (r.ascii/lower-alpha sample-size) + sample-upper (r.ascii/upper-alpha sample-size) + sample-alpha (|> (r.ascii/alpha sample-size) + (r.filter (|>> (text\= sample-upper) not))) + char-idx (|> r.nat (\ ! map (n.% sample-size))) + #let [sample-lowerS (synthesis.text sample-lower) + sample-upperS (synthesis.text sample-upper) + sample-alphaS (synthesis.text sample-alpha) + concatenatedS (#synthesis.Extension "lux text concat" (list sample-lowerS sample-upperS)) + pre-rep-once (format sample-lower sample-upper) + post-rep-once (format sample-lower sample-alpha) + pre-rep-all (|> (list.repeat sample-size sample-lower) (text.join-with sample-upper)) + post-rep-all (|> (list.repeat sample-size sample-lower) (text.join-with sample-alpha))]] + ($_ _.and + (_.test "Can compare texts for equality." + (and (|> (#synthesis.Extension "lux text =" (list sample-lowerS sample-lowerS)) + (run (..sanitize "lux text =")) + (case> (#try.Success valueV) + (:as Bit valueV) + + _ + false)) + (|> (#synthesis.Extension "lux text =" (list sample-upperS sample-lowerS)) + (run (..sanitize "lux text =")) + (case> (#try.Success valueV) + (not (:as Bit valueV)) + + _ + false)))) + (_.test "Can compare texts for order." + (|> (#synthesis.Extension "lux text <" (list sample-lowerS sample-upperS)) + (run (..sanitize "lux text <")) + (case> (#try.Success valueV) + (:as Bit valueV) + + (#try.Failure _) + false))) + (_.test "Can get length of text." + (|> (#synthesis.Extension "lux text size" (list sample-lowerS)) + (run (..sanitize "lux text size")) + (case> (#try.Success valueV) + (n.= sample-size (:as Nat valueV)) + + _ + false))) + (_.test "Can concatenate text." + (|> (#synthesis.Extension "lux text size" (list concatenatedS)) + (run (..sanitize "lux text size")) + (case> (#try.Success valueV) + (n.= (n.* 2 sample-size) (:as Nat valueV)) + + _ + false))) + (_.test "Can find index of sub-text." + (and (|> (#synthesis.Extension "lux text index" + (list concatenatedS sample-lowerS + (synthesis.i64 +0))) + (run (..sanitize "lux text index")) + (case> (^multi (#try.Success valueV) + [(:as (Maybe Nat) valueV) (#.Some valueV)]) + (n.= 0 valueV) + + _ + false)) + (|> (#synthesis.Extension "lux text index" + (list concatenatedS sample-upperS + (synthesis.i64 +0))) + (run (..sanitize "lux text index")) + (case> (^multi (#try.Success valueV) + [(:as (Maybe Nat) valueV) (#.Some valueV)]) + (n.= sample-size valueV) + + _ + false)))) + (let [test-clip (: (-> (I64 Any) (I64 Any) Text Bit) + (function (_ offset length expected) + (|> (#synthesis.Extension "lux text clip" + (list concatenatedS + (synthesis.i64 offset) + (synthesis.i64 length))) + (run (..sanitize "lux text clip")) + (case> (^multi (#try.Success valueV) + [(:as (Maybe Text) valueV) (#.Some valueV)]) + (text\= expected valueV) + + _ + false))))] + (_.test "Can clip text to extract sub-text." + (and (test-clip 0 sample-size sample-lower) + (test-clip sample-size sample-size sample-upper)))) + (_.test "Can extract individual characters from text." + (|> (#synthesis.Extension "lux text char" + (list sample-lowerS + (synthesis.i64 char-idx))) + (run (..sanitize "lux text char")) + (case> (^multi (#try.Success valueV) + [(:as (Maybe Int) valueV) (#.Some valueV)]) + (text.contains? ("lux i64 char" valueV) + sample-lower) + + _ + false))) + ))) + +(def: (io run) + (-> Runner Test) + (do r.monad + [message (r.ascii/alpha 5)] + ($_ _.and + (_.test "Can log messages." + (|> (#synthesis.Extension "lux io log" + (list (synthesis.text (format "LOG: " message)))) + (run (..sanitize "lux io log")) + (case> (#try.Success valueV) + true + + (#try.Failure _) + false))) + (_.test "Can throw runtime errors." + (and (|> (#synthesis.Extension "lux try" + (list (synthesis.function/abstraction + {#synthesis.environment (list) + #synthesis.arity 1 + #synthesis.body (#synthesis.Extension "lux io error" + (list (synthesis.text message)))}))) + (run (..sanitize "lux try")) + (case> (^multi (#try.Success valueV) + [(:as (Try Text) valueV) (#try.Failure error)]) + (text.contains? message error) + + _ + false)) + (|> (#synthesis.Extension "lux try" + (list (synthesis.function/abstraction + {#synthesis.environment (list) + #synthesis.arity 1 + #synthesis.body (synthesis.text message)}))) + (run (..sanitize "lux try")) + (case> (^multi (#try.Success valueV) + [(:as (Try Text) valueV) (#try.Success valueV)]) + (text\= message valueV) + + _ + false)))) + (_.test "Can obtain current time in milli-seconds." + (|> (synthesis.tuple (list (#synthesis.Extension "lux io current-time" (list)) + (#synthesis.Extension "lux io current-time" (list)))) + (run (..sanitize "lux io current-time")) + (case> (#try.Success valueV) + (let [[pre post] (:as [Nat Nat] valueV)] + (n.>= pre post)) + + (#try.Failure _) + false))) + ))) + +(def: #export (spec runner) + (-> Runner Test) + ($_ _.and + (..bit runner) + (..i64 runner) + (..f64 runner) + (..text runner) + (..io runner) + )) diff --git a/stdlib/source/specification/compositor/generation/function.lux b/stdlib/source/specification/compositor/generation/function.lux new file mode 100644 index 000000000..6d0f8d541 --- /dev/null +++ b/stdlib/source/specification/compositor/generation/function.lux @@ -0,0 +1,93 @@ +(.module: + [lux (#- function) + ["_" test (#+ Test)] + [abstract + [monad (#+ do)] + ["." enum]] + [control + [pipe (#+ case>)]] + [data + ["." maybe] + [number + ["n" nat]] + [collection + ["." list ("#\." functor)]]] + [math + ["r" random (#+ Random) ("#\." monad)]] + [tool + [compiler + [analysis (#+ Arity)] + ["." reference (#+ Register)] + ["." synthesis (#+ Synthesis)]]]] + ["." // #_ + ["#." case] + [// + [common (#+ Runner)]]]) + +(def: max-arity Arity 10) + +(def: arity + (Random Arity) + (|> r.nat (r\map (|>> (n.% max-arity) (n.max 1))))) + +(def: (local arity) + (-> Arity (Random Register)) + (|> r.nat (r\map (|>> (n.% arity) inc)))) + +(def: function + (Random [Arity Register Synthesis]) + (do r.monad + [arity ..arity + local (..local arity)] + (wrap [arity local + (synthesis.function/abstraction + {#synthesis.environment (list) + #synthesis.arity arity + #synthesis.body (synthesis.variable/local local)})]))) + +(def: #export (spec run) + (-> Runner Test) + (do {! r.monad} + [[arity local functionS] ..function + partial-arity (|> r.nat (\ ! map (|>> (n.% arity) (n.max 1)))) + inputs (r.list arity r.safe-frac) + #let [expectation (maybe.assume (list.nth (dec local) inputs)) + inputsS (list\map (|>> synthesis.f64) inputs)]] + ($_ _.and + (_.test "Can read arguments." + (|> (synthesis.function/apply {#synthesis.function functionS + #synthesis.arguments inputsS}) + (run "with-local") + (//case.verify expectation))) + (_.test "Can partially apply functions." + (or (n.= 1 arity) + (let [preS (list.take partial-arity inputsS) + postS (list.drop partial-arity inputsS) + partialS (synthesis.function/apply {#synthesis.function functionS + #synthesis.arguments preS})] + (|> (synthesis.function/apply {#synthesis.function partialS + #synthesis.arguments postS}) + (run "partial-application") + (//case.verify expectation))))) + (_.test "Can read environment." + (or (n.= 1 arity) + (let [environment (|> partial-arity + (enum.range n.enum 1) + (list\map (|>> #reference.Local))) + variableS (if (n.<= partial-arity local) + (synthesis.variable/foreign (dec local)) + (synthesis.variable/local (|> local (n.- partial-arity)))) + inner-arity (n.- partial-arity arity) + innerS (synthesis.function/abstraction + {#synthesis.environment environment + #synthesis.arity inner-arity + #synthesis.body variableS}) + outerS (synthesis.function/abstraction + {#synthesis.environment (list) + #synthesis.arity partial-arity + #synthesis.body innerS})] + (|> (synthesis.function/apply {#synthesis.function outerS + #synthesis.arguments inputsS}) + (run "with-foreign") + (//case.verify expectation))))) + ))) diff --git a/stdlib/source/specification/compositor/generation/primitive.lux b/stdlib/source/specification/compositor/generation/primitive.lux new file mode 100644 index 000000000..3b6dd657b --- /dev/null +++ b/stdlib/source/specification/compositor/generation/primitive.lux @@ -0,0 +1,48 @@ +(.module: + [lux #* + ["_" test (#+ Test)] + [abstract + [monad (#+ do)]] + [control + [pipe (#+ case>)] + ["." try]] + [data + ["." bit ("#\." equivalence)] + [number + ["f" frac]] + ["." text ("#\." equivalence) + ["%" format (#+ format)]]] + [math + ["r" random]] + [tool + [compiler + ["." synthesis]]]] + [/// + [common (#+ Runner)]]) + +(def: (f/=' reference subject) + (-> Frac Frac Bit) + (or (f.= reference subject) + (and (f.not-a-number? reference) + (f.not-a-number? subject)))) + +(def: #export (spec run) + (-> Runner Test) + (`` ($_ _.and + (~~ (template [ ] + [(do r.monad + [expected ] + (_.test (%.name (name-of )) + (|> (run ( expected)) + (case> (#try.Success actual) + ( expected (:assume actual)) + + (#try.Failure _) + false))))] + + ["bit" synthesis.bit r.bit bit\=] + ["i64" synthesis.i64 r.i64 "lux i64 ="] + ["f64" synthesis.f64 r.frac f.='] + ["text" synthesis.text (r.ascii 5) text\=] + )) + ))) diff --git a/stdlib/source/specification/compositor/generation/reference.lux b/stdlib/source/specification/compositor/generation/reference.lux new file mode 100644 index 000000000..665175ab4 --- /dev/null +++ b/stdlib/source/specification/compositor/generation/reference.lux @@ -0,0 +1,60 @@ +(.module: + [lux #* + ["_" test (#+ Test)] + [abstract + [monad (#+ do)]] + [control + [pipe (#+ case>)] + ["." try]] + [data + [number + ["n" nat] + ["f" frac]]] + [tool + [compiler + ["." reference] + ["." synthesis]]] + [math + ["r" random (#+ Random)]]] + [/// + [common (#+ Runner Definer)]]) + +(def: name + (Random Name) + (let [name-part (r.ascii/upper-alpha 5)] + [(r.and name-part name-part)])) + +(def: (definition define) + (-> Definer Test) + (do r.monad + [name ..name + expected r.safe-frac] + (_.test "Definitions." + (|> (define name (synthesis.f64 expected)) + (case> (#try.Success actual) + (f.= expected (:as Frac actual)) + + (#try.Failure _) + false))))) + +(def: (variable run) + (-> Runner Test) + (do {! r.monad} + [register (|> r.nat (\ ! map (n.% 100))) + expected r.safe-frac] + (_.test "Local variables." + (|> (synthesis.branch/let [(synthesis.f64 expected) + register + (synthesis.variable/local register)]) + (run "variable") + (case> (#try.Success actual) + (f.= expected (:as Frac actual)) + + (#try.Failure _) + false))))) + +(def: #export (spec runner definer) + (-> Runner Definer Test) + ($_ _.and + (..definition definer) + (..variable runner))) diff --git a/stdlib/source/specification/compositor/generation/structure.lux b/stdlib/source/specification/compositor/generation/structure.lux new file mode 100644 index 000000000..7c45d2a9b --- /dev/null +++ b/stdlib/source/specification/compositor/generation/structure.lux @@ -0,0 +1,89 @@ +(.module: + [lux #* + ["_" test (#+ Test)] + [abstract + [monad (#+ do)]] + [control + [pipe (#+ case>)] + ["." try]] + [data + ["." maybe] + [number + ["n" nat] + ["i" int]] + ["." text ("#\." equivalence) + ["%" format (#+ format)]] + [collection + ["." array (#+ Array)] + ["." list ("#\." functor)]]] + [math + ["r" random]] + ["." ffi (#+ import:)] + [tool + [compiler + ["." analysis] + ["." synthesis]]]] + [/// + [common (#+ Runner)]]) + +(import: java/lang/Integer) + +(def: (variant run) + (-> Runner Test) + (do {! r.monad} + [num-tags (|> r.nat (\ ! map (|>> (n.% 10) (n.max 2)))) + tag-in (|> r.nat (\ ! map (n.% num-tags))) + #let [last?-in (|> num-tags dec (n.= tag-in))] + value-in r.i64] + (_.test (%.name (name-of synthesis.variant)) + (|> (synthesis.variant {#analysis.lefts (if last?-in + (dec tag-in) + tag-in) + #analysis.right? last?-in + #analysis.value (synthesis.i64 value-in)}) + (run "variant") + (case> (#try.Success valueT) + (let [valueT (:as (Array Any) valueT)] + (and (n.= 3 (array.size valueT)) + (let [tag-out (:as java/lang/Integer (maybe.assume (array.read 0 valueT))) + last?-out (array.read 1 valueT) + value-out (:as Any (maybe.assume (array.read 2 valueT))) + same-tag? (|> tag-out ffi.int-to-long (:as Nat) (n.= tag-in)) + same-flag? (case last?-out + (#.Some last?-out') + (and last?-in (text\= "" (:as Text last?-out'))) + + #.None + (not last?-in)) + same-value? (|> value-out (:as Int) (i.= value-in))] + (and same-tag? + same-flag? + same-value?)))) + + (#try.Failure _) + false))))) + +(def: (tuple run) + (-> Runner Test) + (do {! r.monad} + [size (|> r.nat (\ ! map (|>> (n.% 10) (n.max 2)))) + tuple-in (r.list size r.i64)] + (_.test (%.name (name-of synthesis.tuple)) + (|> (synthesis.tuple (list\map (|>> synthesis.i64) tuple-in)) + (run "tuple") + (case> (#try.Success tuple-out) + (let [tuple-out (:as (Array Any) tuple-out)] + (and (n.= size (array.size tuple-out)) + (list.every? (function (_ [left right]) + (i.= left (:as Int right))) + (list.zip/2 tuple-in (array.to-list tuple-out))))) + + (#try.Failure _) + false))))) + +(def: #export (spec runner) + (-> Runner Test) + ($_ _.and + (..variant runner) + (..tuple runner) + )) diff --git a/stdlib/source/specification/lux/abstract/apply.lux b/stdlib/source/specification/lux/abstract/apply.lux new file mode 100644 index 000000000..691e8c01c --- /dev/null +++ b/stdlib/source/specification/lux/abstract/apply.lux @@ -0,0 +1,73 @@ +(.module: + [library + [lux #* + ["_" test (#+ Test)] + [abstract + [monad (#+ do)]] + [control + ["." function]] + [math + ["." random] + [number + ["n" nat]]]]] + [\\library + ["." / (#+ Apply)]] + [// + [functor (#+ Injection Comparison)]]) + +(def: (identity injection comparison (^open "\.")) + (All [f] (-> (Injection f) (Comparison f) (Apply f) Test)) + (do {! random.monad} + [sample (\ ! map injection random.nat)] + (_.test "Identity." + ((comparison n.=) + (\apply (injection function.identity) sample) + sample)))) + +(def: (homomorphism injection comparison (^open "\.")) + (All [f] (-> (Injection f) (Comparison f) (Apply f) Test)) + (do {! random.monad} + [sample random.nat + increase (\ ! map n.+ random.nat)] + (_.test "Homomorphism." + ((comparison n.=) + (\apply (injection increase) (injection sample)) + (injection (increase sample)))))) + +(def: (interchange injection comparison (^open "\.")) + (All [f] (-> (Injection f) (Comparison f) (Apply f) Test)) + (do {! random.monad} + [sample random.nat + increase (\ ! map n.+ random.nat)] + (_.test "Interchange." + ((comparison n.=) + (\apply (injection increase) (injection sample)) + (\apply (injection (function (_ f) (f sample))) (injection increase)))))) + +(def: (composition injection comparison (^open "\.")) + (All [f] (-> (Injection f) (Comparison f) (Apply f) Test)) + (do {! random.monad} + [sample random.nat + increase (\ ! map n.+ random.nat) + decrease (\ ! map n.- random.nat)] + (_.test "Composition." + ((comparison n.=) + (_$ \apply + (injection function.compose) + (injection increase) + (injection decrease) + (injection sample)) + ($_ \apply + (injection increase) + (injection decrease) + (injection sample)))))) + +(def: #export (spec injection comparison apply) + (All [f] (-> (Injection f) (Comparison f) (Apply f) Test)) + (_.for [/.Apply] + ($_ _.and + (..identity injection comparison apply) + (..homomorphism injection comparison apply) + (..interchange injection comparison apply) + (..composition injection comparison apply) + ))) diff --git a/stdlib/source/specification/lux/abstract/codec.lux b/stdlib/source/specification/lux/abstract/codec.lux new file mode 100644 index 000000000..f58f6ce91 --- /dev/null +++ b/stdlib/source/specification/lux/abstract/codec.lux @@ -0,0 +1,27 @@ +(.module: + [library + [lux #* + ["_" test (#+ Test)] + [abstract + [monad (#+ do)]] + [control + ["." try]] + [math + ["." random (#+ Random)]]]] + [\\library + ["." / + [// + [equivalence (#+ Equivalence)]]]]) + +(def: #export (spec (^open "@//.") (^open "@//.") generator) + (All [m a] (-> (Equivalence a) (/.Codec m a) (Random a) Test)) + (do random.monad + [expected generator] + (_.for [/.Codec] + (_.test "Isomorphism." + (case (|> expected @//encode @//decode) + (#try.Success actual) + (@//= expected actual) + + (#try.Failure _) + false))))) diff --git a/stdlib/source/specification/lux/abstract/comonad.lux b/stdlib/source/specification/lux/abstract/comonad.lux new file mode 100644 index 000000000..85d00b8f2 --- /dev/null +++ b/stdlib/source/specification/lux/abstract/comonad.lux @@ -0,0 +1,61 @@ +(.module: + [library + [lux #* + ["_" test (#+ Test)] + [abstract + [monad (#+ do)]] + [math + ["." random] + [number + ["n" nat]]]]] + [\\library + ["." / (#+ CoMonad)]] + [// + [functor (#+ Injection Comparison)]]) + +(def: (left-identity injection (^open "_//.")) + (All [f] (-> (Injection f) (CoMonad f) Test)) + (do {! random.monad} + [sample random.nat + morphism (\ ! map (function (_ diff) + (|>> _//unwrap (n.+ diff))) + random.nat) + #let [start (injection sample)]] + (_.test "Left identity." + (n.= (morphism start) + (|> start _//split (_//map morphism) _//unwrap))))) + +(def: (right-identity injection comparison (^open "_//.")) + (All [f] (-> (Injection f) (Comparison f) (CoMonad f) Test)) + (do random.monad + [sample random.nat + #let [start (injection sample) + == (comparison n.=)]] + (_.test "Right identity." + (== start + (|> start _//split (_//map _//unwrap)))))) + +(def: (associativity injection comparison (^open "_//.")) + (All [f] (-> (Injection f) (Comparison f) (CoMonad f) Test)) + (do {! random.monad} + [sample random.nat + increase (\ ! map (function (_ diff) + (|>> _//unwrap (n.+ diff))) + random.nat) + decrease (\ ! map (function (_ diff) + (|>> _//unwrap(n.- diff))) + random.nat) + #let [start (injection sample) + == (comparison n.=)]] + (_.test "Associativity." + (== (|> start _//split (_//map (|>> _//split (_//map increase) decrease))) + (|> start _//split (_//map increase) _//split (_//map decrease)))))) + +(def: #export (spec injection comparison subject) + (All [f] (-> (Injection f) (Comparison f) (CoMonad f) Test)) + (<| (_.for [/.CoMonad]) + ($_ _.and + (..left-identity injection subject) + (..right-identity injection comparison subject) + (..associativity injection comparison subject) + ))) diff --git a/stdlib/source/specification/lux/abstract/enum.lux b/stdlib/source/specification/lux/abstract/enum.lux new file mode 100644 index 000000000..ddb2a80f1 --- /dev/null +++ b/stdlib/source/specification/lux/abstract/enum.lux @@ -0,0 +1,27 @@ +(.module: + [library + [lux #* + ["_" test (#+ Test)] + [abstract + [monad (#+ do)]] + [math + ["." random (#+ Random)]]]] + [\\library + ["." /]]) + +(def: #export (spec (^open "\.") gen-sample) + (All [a] (-> (/.Enum a) (Random a) Test)) + (do random.monad + [sample gen-sample] + (<| (_.for [/.Enum]) + ($_ _.and + (_.test "Successor and predecessor are inverse functions." + (and (\= (|> sample \succ \pred) + sample) + (\= (|> sample \pred \succ) + sample) + (not (\= (\succ sample) + sample)) + (not (\= (\pred sample) + sample)))) + )))) diff --git a/stdlib/source/specification/lux/abstract/equivalence.lux b/stdlib/source/specification/lux/abstract/equivalence.lux new file mode 100644 index 000000000..4d6d0900a --- /dev/null +++ b/stdlib/source/specification/lux/abstract/equivalence.lux @@ -0,0 +1,24 @@ +(.module: + [library + [lux #* + ["_" test (#+ Test)] + [abstract + [monad (#+ do)]] + [math + ["." random (#+ Random)]]]] + [\\library + ["." / (#+ Equivalence)]]) + +(def: #export (spec (^open "_//.") random) + (All [a] (-> (Equivalence a) (Random a) Test)) + (do random.monad + [left random + right random] + (<| (_.for [/.Equivalence]) + ($_ _.and + (_.test "Reflexivity." + (_//= left left)) + (_.test "Symmetry." + (if (_//= left right) + (_//= right left) + (not (_//= right left)))))))) diff --git a/stdlib/source/specification/lux/abstract/fold.lux b/stdlib/source/specification/lux/abstract/fold.lux new file mode 100644 index 000000000..2b4a7617f --- /dev/null +++ b/stdlib/source/specification/lux/abstract/fold.lux @@ -0,0 +1,23 @@ +(.module: + [library + [lux #* + ["_" test (#+ Test)] + [abstract + [monad (#+ do)]] + [math + ["." random] + [number + ["n" nat]]]]] + [// + [functor (#+ Injection Comparison)]] + [\\library + ["." /]]) + +(def: #export (spec injection comparison (^open "@//.")) + (All [f] (-> (Injection f) (Comparison f) (/.Fold f) Test)) + (do random.monad + [subject random.nat + parameter random.nat] + (_.cover [/.Fold] + (n.= (@//fold n.+ parameter (injection subject)) + (n.+ parameter subject))))) diff --git a/stdlib/source/specification/lux/abstract/functor.lux b/stdlib/source/specification/lux/abstract/functor.lux new file mode 100644 index 000000000..cfa6cc2ff --- /dev/null +++ b/stdlib/source/specification/lux/abstract/functor.lux @@ -0,0 +1,62 @@ +(.module: + [library + [lux #* + ["_" test (#+ Test)] + [abstract + [equivalence (#+ Equivalence)] + [monad (#+ do)]] + [control + ["." function]] + [math + ["." random] + [number + ["n" nat]]]]] + [\\library + ["." / (#+ Functor)]]) + +(type: #export (Injection f) + (All [a] (-> a (f a)))) + +(type: #export (Comparison f) + (All [a] + (-> (Equivalence a) + (Equivalence (f a))))) + +(def: (identity injection comparison (^open "@//.")) + (All [f] (-> (Injection f) (Comparison f) (Functor f) Test)) + (do {! random.monad} + [sample (\ ! map injection random.nat)] + (_.test "Identity." + ((comparison n.=) + (@//map function.identity sample) + sample)))) + +(def: (homomorphism injection comparison (^open "@//.")) + (All [f] (-> (Injection f) (Comparison f) (Functor f) Test)) + (do {! random.monad} + [sample random.nat + increase (\ ! map n.+ random.nat)] + (_.test "Homomorphism." + ((comparison n.=) + (@//map increase (injection sample)) + (injection (increase sample)))))) + +(def: (composition injection comparison (^open "@//.")) + (All [f] (-> (Injection f) (Comparison f) (Functor f) Test)) + (do {! random.monad} + [sample (\ ! map injection random.nat) + increase (\ ! map n.+ random.nat) + decrease (\ ! map n.- random.nat)] + (_.test "Composition." + ((comparison n.=) + (|> sample (@//map increase) (@//map decrease)) + (|> sample (@//map (|>> increase decrease))))))) + +(def: #export (spec injection comparison functor) + (All [f] (-> (Injection f) (Comparison f) (Functor f) Test)) + (<| (_.for [/.Functor]) + ($_ _.and + (..identity injection comparison functor) + (..homomorphism injection comparison functor) + (..composition injection comparison functor) + ))) diff --git a/stdlib/source/specification/lux/abstract/functor/contravariant.lux b/stdlib/source/specification/lux/abstract/functor/contravariant.lux new file mode 100644 index 000000000..cba839e94 --- /dev/null +++ b/stdlib/source/specification/lux/abstract/functor/contravariant.lux @@ -0,0 +1,31 @@ +(.module: + [library + [lux #* + ["_" test (#+ Test)] + [abstract + [equivalence (#+ Equivalence)] + [monad (#+ do)]] + [control + ["." function]] + [math + ["." random] + [number + ["n" nat]]]]] + [\\library + ["." / (#+ Functor)]]) + +(def: (identity equivalence value (^open "@//.")) + (All [f a] (-> (Equivalence (f a)) (f a) (Functor f) Test)) + (_.test "Law of identity." + (equivalence + (@//map function.identity value) + value))) + +(def: #export (spec equivalence value functor) + (All [f a] (-> (Equivalence (f a)) (f a) (Functor f) Test)) + (do random.monad + [sample random.nat] + (<| (_.for [/.Functor]) + ($_ _.and + (..identity equivalence value functor) + )))) diff --git a/stdlib/source/specification/lux/abstract/hash.lux b/stdlib/source/specification/lux/abstract/hash.lux new file mode 100644 index 000000000..4722a48a0 --- /dev/null +++ b/stdlib/source/specification/lux/abstract/hash.lux @@ -0,0 +1,23 @@ +(.module: + [library + [lux #* + ["_" test (#+ Test)] + [abstract + [monad (#+ do)]] + [data + ["." bit ("#\." equivalence)]] + [math + ["." random (#+ Random)] + [number + ["n" nat]]]]] + [\\library + ["." /]]) + +(def: #export (spec (^open "\.") random) + (All [a] (-> (/.Hash a) (Random a) Test)) + (do random.monad + [parameter random + subject random] + (_.cover [/.Hash] + (bit\= (\= parameter subject) + (n.= (\hash parameter) (\hash subject)))))) diff --git a/stdlib/source/specification/lux/abstract/interval.lux b/stdlib/source/specification/lux/abstract/interval.lux new file mode 100644 index 000000000..5b74bc34d --- /dev/null +++ b/stdlib/source/specification/lux/abstract/interval.lux @@ -0,0 +1,23 @@ +(.module: + [library + [lux #* + ["_" test (#+ Test)] + [abstract + [monad (#+ do)] + ["." order]] + [math + ["." random (#+ Random)]]]] + [\\library + ["." /]]) + +(def: #export (spec (^open "@//.") gen-sample) + (All [a] (-> (/.Interval a) (Random a) Test)) + (<| (_.for [/.Interval]) + (do random.monad + [sample gen-sample] + ($_ _.and + (_.test "No value is bigger than the top." + (@//< @//top sample)) + (_.test "No value is smaller than the bottom." + (order.> @//&order @//bottom sample)) + )))) diff --git a/stdlib/source/specification/lux/abstract/monad.lux b/stdlib/source/specification/lux/abstract/monad.lux new file mode 100644 index 000000000..869eb24c7 --- /dev/null +++ b/stdlib/source/specification/lux/abstract/monad.lux @@ -0,0 +1,57 @@ +(.module: + [library + [lux #* + ["_" test (#+ Test)] + [math + ["." random] + [number + ["n" nat]]]]] + [\\library + ["." / (#+ do)]] + [// + [functor (#+ Injection Comparison)]]) + +(def: (left-identity injection comparison (^open "_//.")) + (All [f] (-> (Injection f) (Comparison f) (/.Monad f) Test)) + (do {! random.monad} + [sample random.nat + morphism (\ ! map (function (_ diff) + (|>> (n.+ diff) _//wrap)) + random.nat)] + (_.test "Left identity." + ((comparison n.=) + (|> (injection sample) (_//map morphism) _//join) + (morphism sample))))) + +(def: (right-identity injection comparison (^open "_//.")) + (All [f] (-> (Injection f) (Comparison f) (/.Monad f) Test)) + (do random.monad + [sample random.nat] + (_.test "Right identity." + ((comparison n.=) + (|> (injection sample) (_//map _//wrap) _//join) + (injection sample))))) + +(def: (associativity injection comparison (^open "_//.")) + (All [f] (-> (Injection f) (Comparison f) (/.Monad f) Test)) + (do {! random.monad} + [sample random.nat + increase (\ ! map (function (_ diff) + (|>> (n.+ diff) _//wrap)) + random.nat) + decrease (\ ! map (function (_ diff) + (|>> (n.- diff) _//wrap)) + random.nat)] + (_.test "Associativity." + ((comparison n.=) + (|> (injection sample) (_//map increase) _//join (_//map decrease) _//join) + (|> (injection sample) (_//map (|>> increase (_//map decrease) _//join)) _//join))))) + +(def: #export (spec injection comparison monad) + (All [f] (-> (Injection f) (Comparison f) (/.Monad f) Test)) + (<| (_.for [/.Monad]) + ($_ _.and + (..left-identity injection comparison monad) + (..right-identity injection comparison monad) + (..associativity injection comparison monad) + ))) diff --git a/stdlib/source/specification/lux/abstract/monoid.lux b/stdlib/source/specification/lux/abstract/monoid.lux new file mode 100644 index 000000000..f8626fe74 --- /dev/null +++ b/stdlib/source/specification/lux/abstract/monoid.lux @@ -0,0 +1,32 @@ +(.module: + [library + [lux #* + ["_" test (#+ Test)] + [abstract + [monad (#+ do)]] + [math + ["." random (#+ Random)]]]] + [\\library + ["." / + [// + [equivalence (#+ Equivalence)]]]]) + +(def: #export (spec (^open "\.") (^open "\.") gen-sample) + (All [a] (-> (Equivalence a) (/.Monoid a) (Random a) Test)) + (do random.monad + [sample gen-sample + left gen-sample + mid gen-sample + right gen-sample] + (<| (_.for [/.Monoid]) + ($_ _.and + (_.test "Left identity." + (\= sample + (\compose \identity sample))) + (_.test "Right identity." + (\= sample + (\compose sample \identity))) + (_.test "Associativity." + (\= (\compose left (\compose mid right)) + (\compose (\compose left mid) right))) + )))) diff --git a/stdlib/source/specification/lux/abstract/order.lux b/stdlib/source/specification/lux/abstract/order.lux new file mode 100644 index 000000000..61fc22611 --- /dev/null +++ b/stdlib/source/specification/lux/abstract/order.lux @@ -0,0 +1,58 @@ +(.module: + [library + [lux #* + ["_" test (#+ Test)] + [abstract + [monad (#+ do)]] + [math + ["." random (#+ Random)]]]] + [\\library + ["." /]]) + +(def: #export (spec (^open "@//.") generator) + (All [a] (-> (/.Order a) (Random a) Test)) + (<| (_.for [/.Order]) + ($_ _.and + (do random.monad + [parameter generator + subject generator] + (_.test "Values are either ordered, or they are equal. All options are mutually exclusive." + (cond (@//< parameter subject) + (not (or (@//< subject parameter) + (@//= parameter subject))) + + (@//< subject parameter) + (not (@//= parameter subject)) + + ## else + (@//= parameter subject)))) + (do random.monad + [parameter generator + subject (random.filter (|>> (@//= parameter) not) + generator) + extra (random.filter (function (_ value) + (not (or (@//= parameter value) + (@//= subject value)))) + generator)] + (_.test "Transitive property." + (if (@//< parameter subject) + (let [greater? (and (@//< subject extra) + (@//< parameter extra)) + lesser? (and (@//< extra parameter) + (@//< extra subject)) + in-between? (and (@//< parameter extra) + (@//< extra subject))] + (or greater? + lesser? + in-between?)) + ## (@//< subject parameter) + (let [greater? (and (@//< extra subject) + (@//< extra parameter)) + lesser? (and (@//< parameter extra) + (@//< subject extra)) + in-between? (and (@//< subject extra) + (@//< extra parameter))] + (or greater? + lesser? + in-between?))))) + ))) diff --git a/stdlib/source/specification/lux/world/console.lux b/stdlib/source/specification/lux/world/console.lux new file mode 100644 index 000000000..f454b61c9 --- /dev/null +++ b/stdlib/source/specification/lux/world/console.lux @@ -0,0 +1,58 @@ +(.module: + [library + [lux #* + ["_" test (#+ Test)] + [abstract + [monad (#+ do)]] + [control + [io (#+ IO)] + ["." try] + [concurrency + ["." promise (#+ Promise)]]] + [data + ["." text + ["%" format (#+ format)]]] + [math + ["." random]]]] + [\\library + ["." /]]) + +(def: #export (spec console) + (-> (IO (/.Console Promise)) Test) + (do random.monad + [message (random.ascii/alpha 10)] + (wrap (do promise.monad + [console (promise.future console) + ?write (\ console write (format message text.new_line)) + ?read (\ console read []) + ?read_line (\ console read_line []) + ?close/good (\ console close []) + ?close/bad (\ console close []) + + #let [can_write! + (case ?write + (#try.Success _) + true + + _ + false) + + can_read! + (case [?read ?read_line] + [(#try.Success _) (#try.Success _)] + true + + _ + false) + + can_close! + (case [?close/good ?close/bad] + [(#try.Success _) (#try.Failure _)] + true + + _ + false)]] + (_.cover' [/.Console] + (and can_write! + can_read! + can_close!)))))) diff --git a/stdlib/source/specification/lux/world/file.lux b/stdlib/source/specification/lux/world/file.lux new file mode 100644 index 000000000..7bdefb173 --- /dev/null +++ b/stdlib/source/specification/lux/world/file.lux @@ -0,0 +1,351 @@ +(.module: + [library + [lux #* + ["_" test (#+ Test)] + [abstract + [monad (#+ do)] + ["." predicate]] + [control + [pipe (#+ case>)] + [io (#+ IO)] + ["." try ("#\." functor)] + ["." exception] + [concurrency + ["." promise (#+ Promise)]]] + [data + ["." maybe ("#\." functor)] + ["." text ("#\." equivalence) + ["%" format (#+ format)] + [encoding + ["." utf8 ("#\." codec)]]] + ["." binary (#+ Binary) ("#\." equivalence monoid) + ["$#" \\test]] + [collection + ["." list]]] + [math + ["." random] + [number + ["n" nat]]] + [time + ["." instant (#+ Instant) ("#\." equivalence)]]]] + [\\library + ["." /]]) + +(def: (for_path fs) + (-> (IO (/.System Promise)) Test) + (<| (_.for [/.Path]) + (do {! random.monad} + [parent (random.ascii/numeric 2) + child (random.ascii/numeric 2)]) + wrap + (do promise.monad + [fs (promise.future fs)] + ($_ _.and' + (_.cover' [/.un_nest] + (and (|> (/.un_nest fs parent) + (case> (#.Some _) + false + + #.None + true)) + (|> (/.un_nest fs child) + (case> (#.Some _) + false + + #.None + true)))) + (_.cover' [/.nest] + (|> (/.nest fs parent child) + (/.un_nest fs) + (case> (#.Some [parent' child']) + (and (text\= parent parent') + (text\= child child')) + + #.None + false))) + (_.cover' [/.parent] + (|> (/.nest fs parent child) + (/.parent fs) + (maybe\map (text\= parent)) + (maybe.default false))) + (_.cover' [/.name] + (|> (/.nest fs parent child) + (/.name fs) + (text\= child))) + )))) + +(def: (directory?&make_directory fs parent) + (-> (/.System Promise) /.Path (Promise Bit)) + (do promise.monad + [directory_pre! (\ fs directory? parent) + made? (\ fs make_directory parent) + directory_post! (\ fs directory? parent)] + (wrap (and (not directory_pre!) + (case made? + (#try.Success _) true + (#try.Failure _) false) + directory_post!)))) + +(def: (file?&write fs content path) + (-> (/.System Promise) Binary /.Path (Promise Bit)) + (do promise.monad + [file_pre! (\ fs file? path) + made? (\ fs write content path) + file_post! (\ fs file? path)] + (wrap (and (not file_pre!) + (case made? + (#try.Success _) true + (#try.Failure _) false) + file_post!)))) + +(def: (file_size&read&append fs expected_file_size content appendix path) + (-> (/.System Promise) Nat Binary Binary /.Path (Promise Bit)) + (do promise.monad + [pre_file_size (\ fs file_size path) + pre_content (\ fs read path) + appended? (\ fs append appendix path) + post_file_size (\ fs file_size path) + post_content (\ fs read path)] + (wrap (<| (try.default false) + (do {! try.monad} + [pre_file_size! + (\ ! map (n.= expected_file_size) pre_file_size) + + pre_content! + (\ ! map (binary\= content) pre_content) + + _ appended? + + post_file_size! + (\ ! map (n.= (n.* 2 expected_file_size)) post_file_size) + + post_content! + (\ ! map (binary\= (binary\compose content appendix)) post_content)] + (wrap (and pre_file_size! + pre_content! + post_file_size! + post_content!))))))) + +(def: (modified?&last_modified fs expected_time path) + (-> (/.System Promise) Instant /.Path (Promise Bit)) + (do promise.monad + [modified? (\ fs modify expected_time path) + last_modified (\ fs last_modified path)] + (wrap (<| (try.default false) + (do {! try.monad} + [_ modified?] + (\ ! map (instant\= expected_time) last_modified)))))) + +(def: (directory_files&sub_directories fs parent sub_dir child) + (-> (/.System Promise) /.Path /.Path /.Path (Promise Bit)) + (let [sub_dir (/.nest fs parent sub_dir) + child (/.nest fs parent child)] + (do promise.monad + [made_sub? (\ fs make_directory sub_dir) + directory_files (\ fs directory_files parent) + sub_directories (\ fs sub_directories parent) + #let [(^open "list\.") (list.equivalence text.equivalence)]] + (wrap (<| (try.default false) + (do try.monad + [_ made_sub?] + (wrap (and (|> directory_files + (try\map (list\= (list child))) + (try.default false)) + (|> sub_directories + (try\map (list\= (list sub_dir))) + (try.default false)))))))))) + +(def: (move&delete fs parent child alternate_child) + (-> (/.System Promise) /.Path Text Text (Promise Bit)) + (let [origin (/.nest fs parent child) + destination (/.nest fs parent alternate_child)] + (do {! promise.monad} + [moved? (\ fs move destination origin) + lost? (|> origin + (\ fs file?) + (\ ! map not)) + found? (\ fs file? destination) + deleted? (\ fs delete destination)] + (wrap (<| (try.default false) + (do try.monad + [_ moved? + _ deleted?] + (wrap (and lost? + found?)))))))) + +(def: (for_system fs) + (-> (IO (/.System Promise)) Test) + (<| (do {! random.monad} + [parent (random.ascii/numeric 2) + child (random.ascii/numeric 2) + sub_dir (random.filter (|>> (text\= child) not) + (random.ascii/numeric 2)) + alternate_child (random.filter (predicate.intersect + (|>> (text\= child) not) + (|>> (text\= sub_dir) not)) + (random.ascii/numeric 2)) + expected_file_size (\ ! map (|>> (n.% 10) inc) random.nat) + content ($binary.random expected_file_size) + appendix ($binary.random expected_file_size) + expected_time random.instant]) + wrap + (do {! promise.monad} + [fs (promise.future fs) + #let [path (/.nest fs parent child)] + + directory?&make_directory + (..directory?&make_directory fs parent) + + file?&write + (..file?&write fs content path) + + file_size&read&append + (..file_size&read&append fs expected_file_size content appendix path) + + modified?&last_modified + (..modified?&last_modified fs expected_time path) + + can_execute? + (|> path + (\ fs can_execute?) + (\ ! map (|>> (try.default true) not))) + + directory_files&sub_directories + (..directory_files&sub_directories fs parent sub_dir child) + + move&delete + (..move&delete fs parent child alternate_child)]) + (_.cover' [/.System] + (and directory?&make_directory + file?&write + file_size&read&append + modified?&last_modified + can_execute? + directory_files&sub_directories + move&delete)))) + +(def: (make_directories&cannot_make_directory fs) + (-> (IO (/.System Promise)) Test) + (<| (do {! random.monad} + [dir/0 (random.ascii/numeric 2) + dir/1 (random.ascii/numeric 2) + dir/2 (random.ascii/numeric 2)]) + wrap + (do {! promise.monad} + [fs (promise.future fs) + #let [dir/1 (/.nest fs dir/0 dir/1) + dir/2 (/.nest fs dir/1 dir/2)] + pre_dir/0 (\ fs directory? dir/0) + pre_dir/1 (\ fs directory? dir/1) + pre_dir/2 (\ fs directory? dir/2) + made? (/.make_directories ! fs dir/2) + post_dir/0 (\ fs directory? dir/0) + post_dir/1 (\ fs directory? dir/1) + post_dir/2 (\ fs directory? dir/2) + + cannot_make_directory!/0 (/.make_directories ! fs "") + cannot_make_directory!/1 (/.make_directories ! fs (\ fs separator))]) + ($_ _.and' + (_.cover' [/.make_directories] + (and (not pre_dir/0) + (not pre_dir/1) + (not pre_dir/2) + (case made? + (#try.Success _) true + (#try.Failure _) false) + post_dir/0 + post_dir/1 + post_dir/2)) + (_.cover' [/.cannot_make_directory] + (and (case cannot_make_directory!/0 + (#try.Success _) + false + + (#try.Failure error) + (exception.match? /.cannot_make_directory error)) + (case cannot_make_directory!/1 + (#try.Success _) + false + + (#try.Failure error) + (exception.match? /.cannot_make_directory error)))) + ))) + +(def: (make_file&cannot_make_file fs) + (-> (IO (/.System Promise)) Test) + (<| (do {! random.monad} + [file/0 (random.ascii/numeric 3)]) + wrap + (do {! promise.monad} + [fs (promise.future fs) + make_file!/0 (/.make_file ! fs (utf8\encode file/0) file/0) + make_file!/1 (/.make_file ! fs (utf8\encode file/0) file/0)]) + ($_ _.and' + (_.cover' [/.make_file] + (case make_file!/0 + (#try.Success _) true + (#try.Failure error) false)) + (_.cover' [/.cannot_make_file] + (case make_file!/1 + (#try.Success _) + false + + (#try.Failure error) + (exception.match? /.cannot_make_file error))) + ))) + +(def: (for_utilities fs) + (-> (IO (/.System Promise)) Test) + ($_ _.and + (..make_directories&cannot_make_directory fs) + (..make_file&cannot_make_file fs) + )) + +(def: (exists? fs) + (-> (IO (/.System Promise)) Test) + (<| (do {! random.monad} + [file (random.ascii/numeric 2) + dir (random.filter (|>> (text\= file) not) + (random.ascii/numeric 2))]) + wrap + (do {! promise.monad} + [fs (promise.future fs) + + pre_file/0 (\ fs file? file) + pre_file/1 (/.exists? ! fs file) + pre_dir/0 (\ fs directory? dir) + pre_dir/1 (/.exists? ! fs dir) + + made_file? (/.make_file ! fs (utf8\encode file) file) + made_dir? (\ fs make_directory dir) + + post_file/0 (\ fs file? file) + post_file/1 (/.exists? ! fs file) + post_dir/0 (\ fs directory? dir) + post_dir/1 (/.exists? ! fs dir)]) + (_.cover' [/.exists?] + (and (not pre_file/0) + (not pre_file/1) + (not pre_dir/0) + (not pre_dir/1) + + (case made_file? + (#try.Success _) true + (#try.Failure _) false) + (case made_dir? + (#try.Success _) true + (#try.Failure _) false) + + post_file/0 + post_file/1 + post_dir/0 + post_dir/1)))) + +(def: #export (spec fs) + (-> (IO (/.System Promise)) Test) + ($_ _.and + (..for_path fs) + (..for_utilities fs) + (..for_system fs) + (..exists? fs) + )) diff --git a/stdlib/source/specification/lux/world/program.lux b/stdlib/source/specification/lux/world/program.lux new file mode 100644 index 000000000..e79429627 --- /dev/null +++ b/stdlib/source/specification/lux/world/program.lux @@ -0,0 +1,32 @@ +(.module: + [library + [lux #* + ["_" test (#+ Test)] + [abstract + [monad (#+ do)]] + [control + ["." try] + [concurrency + ["." promise (#+ Promise)]]] + [data + ["." text] + [collection + ["." dictionary] + ["." list]]] + [math + ["." random]]]] + [\\library + ["." /]]) + +(def: #export (spec subject) + (-> (/.Program Promise) Test) + (do random.monad + [exit random.int] + (wrap (do {! promise.monad} + [environment (/.environment ! subject)] + (_.cover' [/.Program] + (and (not (dictionary.empty? environment)) + (list.every? (|>> text.empty? not) + (dictionary.keys environment)) + (not (text.empty? (\ subject home))) + (not (text.empty? (\ subject directory))))))))) diff --git a/stdlib/source/specification/lux/world/shell.lux b/stdlib/source/specification/lux/world/shell.lux new file mode 100644 index 000000000..c4fc51b99 --- /dev/null +++ b/stdlib/source/specification/lux/world/shell.lux @@ -0,0 +1,92 @@ +(.module: + [library + [lux #* + ["_" test (#+ Test)] + [abstract + [monad (#+ do)]] + [control + ["." try ("#\." functor)] + [concurrency + ["." promise (#+ Promise) ("#\." monad)]] + [parser + ["." environment (#+ Environment)]]] + [data + ["." product] + ["." text ("#\." equivalence) + ["%" format (#+ format)]]] + [math + ["." random] + [number + ["n" nat] + ["i" int]]]]] + [\\library + ["." / + [// + [file (#+ Path)]]]]) + +(template [ ] + [(def: + (-> [Environment Path /.Command (List /.Argument)]) + (|>> list [environment.empty "~" ]))] + + [echo! "echo" Text (|>)] + [sleep! "sleep" Nat %.nat] + ) + +(def: (can_wait! process) + (-> (/.Process Promise) _.Assertion) + (|> (\ process await []) + (promise\map (|>> (try\map (i.= /.normal)) + (try.default false) + (_.cover' [/.Exit /.normal]))) + promise\join)) + +(def: (can_read! expected process) + (-> Text (/.Process Promise) (Promise Bit)) + (|> (\ process read []) + (promise\map (|>> (try\map (text\= expected)) + (try.default false))))) + +(def: (can_destroy! process) + (-> (/.Process Promise) (Promise Bit)) + (do promise.monad + [?destroy (\ process destroy []) + ?await (\ process await [])] + (wrap (and (case ?destroy + (#try.Success _) + true + + (#try.Failure error) + false) + (case ?await + (#try.Success _) + false + + (#try.Failure error) + true))))) + +(with_expansions [ (as_is [/.Command /.Argument])] + (def: #export (spec shell) + (-> (/.Shell Promise) Test) + (<| (_.for [/.Shell /.Process]) + (do {! random.monad} + [message (random.ascii/alpha 10) + seconds (\ ! map (|>> (n.% 5) (n.+ 5)) random.nat)] + (wrap (do {! promise.monad} + [?echo (\ shell execute (..echo! message)) + ?sleep (\ shell execute (..sleep! seconds))] + (case [?echo ?sleep] + [(#try.Success echo) (#try.Success sleep)] + (do ! + [can_read! (..can_read! message echo) + can_destroy! (..can_destroy! sleep)] + ($_ _.and' + (_.cover' + (and can_read! + can_destroy!)) + (..can_wait! echo) + )) + + _ + (_.cover' + false)))))))) diff --git a/stdlib/source/test/aedifex/artifact.lux b/stdlib/source/test/aedifex/artifact.lux index 6a1021b4c..6afbbf27c 100644 --- a/stdlib/source/test/aedifex/artifact.lux +++ b/stdlib/source/test/aedifex/artifact.lux @@ -5,7 +5,7 @@ [abstract [monad (#+ do)] [hash (#+ Hash)] - [\\spec + [\\specification ["$." equivalence]]] [control [concurrency diff --git a/stdlib/source/test/aedifex/artifact/snapshot.lux b/stdlib/source/test/aedifex/artifact/snapshot.lux index 94d98cf22..5f29620c9 100644 --- a/stdlib/source/test/aedifex/artifact/snapshot.lux +++ b/stdlib/source/test/aedifex/artifact/snapshot.lux @@ -4,7 +4,7 @@ ["_" test (#+ Test)] [abstract [monad (#+ do)] - [\\spec + [\\specification ["$." equivalence]]] [control ["." try ("#\." functor)] diff --git a/stdlib/source/test/aedifex/artifact/snapshot/build.lux b/stdlib/source/test/aedifex/artifact/snapshot/build.lux index 731219b91..8b0be9f1d 100644 --- a/stdlib/source/test/aedifex/artifact/snapshot/build.lux +++ b/stdlib/source/test/aedifex/artifact/snapshot/build.lux @@ -4,7 +4,7 @@ ["_" test (#+ Test)] [abstract [monad (#+ do)] - [\\spec + [\\specification ["$." equivalence]]] [control ["." try ("#\." functor)] diff --git a/stdlib/source/test/aedifex/artifact/snapshot/stamp.lux b/stdlib/source/test/aedifex/artifact/snapshot/stamp.lux index ba0c9f368..00be1c227 100644 --- a/stdlib/source/test/aedifex/artifact/snapshot/stamp.lux +++ b/stdlib/source/test/aedifex/artifact/snapshot/stamp.lux @@ -4,7 +4,7 @@ ["_" test (#+ Test)] [abstract [monad (#+ do)] - [\\spec + [\\specification ["$." equivalence]]] [control ["." try ("#\." functor)] diff --git a/stdlib/source/test/aedifex/artifact/snapshot/time.lux b/stdlib/source/test/aedifex/artifact/snapshot/time.lux index 9cfe28fb0..820214cba 100644 --- a/stdlib/source/test/aedifex/artifact/snapshot/time.lux +++ b/stdlib/source/test/aedifex/artifact/snapshot/time.lux @@ -4,7 +4,7 @@ ["_" test (#+ Test)] [abstract [monad (#+ do)] - [\\spec + [\\specification ["$." equivalence]]] [control ["." try ("#\." functor)] diff --git a/stdlib/source/test/aedifex/artifact/snapshot/version.lux b/stdlib/source/test/aedifex/artifact/snapshot/version.lux index f0fc26321..a4a090246 100644 --- a/stdlib/source/test/aedifex/artifact/snapshot/version.lux +++ b/stdlib/source/test/aedifex/artifact/snapshot/version.lux @@ -4,7 +4,7 @@ ["_" test (#+ Test)] [abstract [monad (#+ do)] - [\\spec + [\\specification ["$." equivalence]]] [control ["." try ("#\." functor)] diff --git a/stdlib/source/test/aedifex/artifact/snapshot/version/value.lux b/stdlib/source/test/aedifex/artifact/snapshot/version/value.lux index dcb23646d..c55b71cd1 100644 --- a/stdlib/source/test/aedifex/artifact/snapshot/version/value.lux +++ b/stdlib/source/test/aedifex/artifact/snapshot/version/value.lux @@ -4,7 +4,7 @@ ["_" test (#+ Test)] [abstract [monad (#+ do)] - [\\spec + [\\specification ["$." equivalence]]] [control ["." try ("#\." functor)] diff --git a/stdlib/source/test/aedifex/artifact/time.lux b/stdlib/source/test/aedifex/artifact/time.lux index f4fc185be..f69566096 100644 --- a/stdlib/source/test/aedifex/artifact/time.lux +++ b/stdlib/source/test/aedifex/artifact/time.lux @@ -4,7 +4,7 @@ ["_" test (#+ Test)] [abstract [monad (#+ do)] - [\\spec + [\\specification ["$." equivalence]]] [control ["." try ("#\." functor)] diff --git a/stdlib/source/test/aedifex/artifact/versioning.lux b/stdlib/source/test/aedifex/artifact/versioning.lux index 9efdca98a..a16794e98 100644 --- a/stdlib/source/test/aedifex/artifact/versioning.lux +++ b/stdlib/source/test/aedifex/artifact/versioning.lux @@ -4,7 +4,7 @@ ["_" test (#+ Test)] [abstract [monad (#+ do)] - [\\spec + [\\specification ["$." equivalence]]] [control ["." try ("#\." functor)] diff --git a/stdlib/source/test/aedifex/cli.lux b/stdlib/source/test/aedifex/cli.lux index d2eed16d7..71ea72b8c 100644 --- a/stdlib/source/test/aedifex/cli.lux +++ b/stdlib/source/test/aedifex/cli.lux @@ -4,7 +4,7 @@ ["_" test (#+ Test)] [abstract [monad (#+ do)] - [\\spec + [\\specification ["$." equivalence]]] [control [pipe (#+ case>)] diff --git a/stdlib/source/test/aedifex/dependency.lux b/stdlib/source/test/aedifex/dependency.lux index d12434d1f..7ce95f716 100644 --- a/stdlib/source/test/aedifex/dependency.lux +++ b/stdlib/source/test/aedifex/dependency.lux @@ -4,7 +4,7 @@ ["_" test (#+ Test)] [abstract [monad (#+ do)] - [\\spec + [\\specification ["$." equivalence]]] [math ["." random (#+ Random)]]]] diff --git a/stdlib/source/test/aedifex/dependency/resolution.lux b/stdlib/source/test/aedifex/dependency/resolution.lux index 638199af3..deb74abcd 100644 --- a/stdlib/source/test/aedifex/dependency/resolution.lux +++ b/stdlib/source/test/aedifex/dependency/resolution.lux @@ -5,7 +5,7 @@ [abstract [monad (#+ do)] ["." predicate] - [\\spec + [\\specification ["$." equivalence]]] [control ["." try] diff --git a/stdlib/source/test/aedifex/dependency/status.lux b/stdlib/source/test/aedifex/dependency/status.lux index a3ac5df4e..f886c031f 100644 --- a/stdlib/source/test/aedifex/dependency/status.lux +++ b/stdlib/source/test/aedifex/dependency/status.lux @@ -3,7 +3,7 @@ [lux #* ["_" test (#+ Test)] [abstract - [\\spec + [\\specification ["$." equivalence]]] [math ["." random (#+ Random) ("#\." monad)]]]] diff --git a/stdlib/source/test/aedifex/hash.lux b/stdlib/source/test/aedifex/hash.lux index 9064dac8b..524110c35 100644 --- a/stdlib/source/test/aedifex/hash.lux +++ b/stdlib/source/test/aedifex/hash.lux @@ -4,7 +4,7 @@ ["_" test (#+ Test)] [abstract [monad (#+ do)] - [\\spec + [\\specification ["$." equivalence] ["$." codec]]] [control diff --git a/stdlib/source/test/aedifex/metadata/artifact.lux b/stdlib/source/test/aedifex/metadata/artifact.lux index b84eca173..5e5f67bec 100644 --- a/stdlib/source/test/aedifex/metadata/artifact.lux +++ b/stdlib/source/test/aedifex/metadata/artifact.lux @@ -4,7 +4,7 @@ ["_" test (#+ Test)] [abstract [monad (#+ do)] - [\\spec + [\\specification ["$." equivalence]]] [control ["." try ("#\." functor)] diff --git a/stdlib/source/test/aedifex/metadata/snapshot.lux b/stdlib/source/test/aedifex/metadata/snapshot.lux index d34eb60a9..5a821c452 100644 --- a/stdlib/source/test/aedifex/metadata/snapshot.lux +++ b/stdlib/source/test/aedifex/metadata/snapshot.lux @@ -4,7 +4,7 @@ ["_" test (#+ Test)] [abstract [monad (#+ do)] - [\\spec + [\\specification ["$." equivalence]]] [control ["." try ("#\." functor)] diff --git a/stdlib/source/test/aedifex/package.lux b/stdlib/source/test/aedifex/package.lux index ef23f35ce..55bca8ce3 100644 --- a/stdlib/source/test/aedifex/package.lux +++ b/stdlib/source/test/aedifex/package.lux @@ -4,7 +4,7 @@ ["_" test (#+ Test)] [abstract [monad (#+ do)] - [\\spec + [\\specification ["$." equivalence]]] [control ["." try] diff --git a/stdlib/source/test/aedifex/profile.lux b/stdlib/source/test/aedifex/profile.lux index 418756ffd..c593f1706 100644 --- a/stdlib/source/test/aedifex/profile.lux +++ b/stdlib/source/test/aedifex/profile.lux @@ -5,7 +5,7 @@ [abstract [monad (#+ do)] [hash (#+ Hash)] - [\\spec + [\\specification ["$." equivalence] ["$." monoid]]] [control diff --git a/stdlib/source/test/aedifex/project.lux b/stdlib/source/test/aedifex/project.lux index e1b4b051a..bdeee7993 100644 --- a/stdlib/source/test/aedifex/project.lux +++ b/stdlib/source/test/aedifex/project.lux @@ -4,7 +4,7 @@ ["_" test (#+ Test)] [abstract [monad (#+ do)] - [\\spec + [\\specification ["$." equivalence] ["$." monoid]]] [control diff --git a/stdlib/source/test/aedifex/repository.lux b/stdlib/source/test/aedifex/repository.lux index c86f3d52d..67cc4c10f 100644 --- a/stdlib/source/test/aedifex/repository.lux +++ b/stdlib/source/test/aedifex/repository.lux @@ -29,7 +29,7 @@ ["#." remote] [// ["@." artifact]]] - [\\spec + [\\specification ["$." /]] [\\program ["." / diff --git a/stdlib/source/test/aedifex/repository/identity.lux b/stdlib/source/test/aedifex/repository/identity.lux index 061bd9de0..74daecb4d 100644 --- a/stdlib/source/test/aedifex/repository/identity.lux +++ b/stdlib/source/test/aedifex/repository/identity.lux @@ -3,7 +3,7 @@ [lux #* ["_" test (#+ Test)] [abstract - [\\spec + [\\specification ["$." equivalence]]] [math ["." random (#+ Random)]]]] diff --git a/stdlib/source/test/aedifex/repository/origin.lux b/stdlib/source/test/aedifex/repository/origin.lux index 6531726fe..daf8e8667 100644 --- a/stdlib/source/test/aedifex/repository/origin.lux +++ b/stdlib/source/test/aedifex/repository/origin.lux @@ -3,7 +3,7 @@ [lux #* ["_" test (#+ Test)] [abstract - [\\spec + [\\specification ["$." equivalence]]] [math ["." random (#+ Random)]]]] diff --git a/stdlib/source/test/lux/abstract/comonad/cofree.lux b/stdlib/source/test/lux/abstract/comonad/cofree.lux index 82647f79d..d44c592d0 100644 --- a/stdlib/source/test/lux/abstract/comonad/cofree.lux +++ b/stdlib/source/test/lux/abstract/comonad/cofree.lux @@ -5,7 +5,7 @@ [abstract [functor (#+ Functor)] [comonad (#+ CoMonad)] - [\\spec + [\\specification ["$." functor (#+ Injection Comparison)] ["$." comonad]]] [control diff --git a/stdlib/source/test/lux/abstract/equivalence.lux b/stdlib/source/test/lux/abstract/equivalence.lux index 5b0bfced8..753494f48 100644 --- a/stdlib/source/test/lux/abstract/equivalence.lux +++ b/stdlib/source/test/lux/abstract/equivalence.lux @@ -4,7 +4,7 @@ ["_" test (#+ Test)] [abstract [monad (#+ do)] - [\\spec + [\\specification [functor ["$." contravariant]]]] [data diff --git a/stdlib/source/test/lux/abstract/hash.lux b/stdlib/source/test/lux/abstract/hash.lux index 4c9bc67f6..894860935 100644 --- a/stdlib/source/test/lux/abstract/hash.lux +++ b/stdlib/source/test/lux/abstract/hash.lux @@ -4,7 +4,7 @@ ["_" test (#+ Test)] [abstract [monad (#+ do)] - [\\spec + [\\specification [functor ["$." contravariant]]]] [data diff --git a/stdlib/source/test/lux/abstract/interval.lux b/stdlib/source/test/lux/abstract/interval.lux index 718663b4b..f5dd14646 100644 --- a/stdlib/source/test/lux/abstract/interval.lux +++ b/stdlib/source/test/lux/abstract/interval.lux @@ -5,7 +5,7 @@ [abstract [monad (#+ do)] ["." order] - [\\spec + [\\specification ["$." equivalence]]] [control [pipe (#+ case>)]] diff --git a/stdlib/source/test/lux/abstract/monad/free.lux b/stdlib/source/test/lux/abstract/monad/free.lux index a56c01fd5..2a5a562f2 100644 --- a/stdlib/source/test/lux/abstract/monad/free.lux +++ b/stdlib/source/test/lux/abstract/monad/free.lux @@ -6,7 +6,7 @@ [functor (#+ Functor)] [apply (#+ Apply)] [monad (#+ Monad do)] - [\\spec + [\\specification ["$." functor (#+ Injection Comparison)] ["$." apply] ["$." monad]]] diff --git a/stdlib/source/test/lux/abstract/order.lux b/stdlib/source/test/lux/abstract/order.lux index 2173691de..e9ced25ce 100644 --- a/stdlib/source/test/lux/abstract/order.lux +++ b/stdlib/source/test/lux/abstract/order.lux @@ -4,7 +4,7 @@ ["_" test (#+ Test)] [abstract [monad (#+ do)] - [\\spec + [\\specification [functor ["$." contravariant]]]] [data diff --git a/stdlib/source/test/lux/abstract/predicate.lux b/stdlib/source/test/lux/abstract/predicate.lux index 0535b5802..197953c49 100644 --- a/stdlib/source/test/lux/abstract/predicate.lux +++ b/stdlib/source/test/lux/abstract/predicate.lux @@ -5,7 +5,7 @@ [abstract [equivalence (#+ Equivalence)] [monad (#+ do)] - [\\spec + [\\specification ["$." monoid] [functor ["$." contravariant]]]] diff --git a/stdlib/source/test/lux/control/concurrency/frp.lux b/stdlib/source/test/lux/control/concurrency/frp.lux index 45d626600..c23428089 100644 --- a/stdlib/source/test/lux/control/concurrency/frp.lux +++ b/stdlib/source/test/lux/control/concurrency/frp.lux @@ -4,7 +4,7 @@ ["_" test (#+ Test)] [abstract [monad (#+ do)] - [\\spec + [\\specification ["$." functor (#+ Injection Comparison)] ["$." apply] ["$." monad]]] diff --git a/stdlib/source/test/lux/control/concurrency/promise.lux b/stdlib/source/test/lux/control/concurrency/promise.lux index 6b6b0ac14..be2655334 100644 --- a/stdlib/source/test/lux/control/concurrency/promise.lux +++ b/stdlib/source/test/lux/control/concurrency/promise.lux @@ -5,7 +5,7 @@ ["@" target] [abstract [monad (#+ do)] - [\\spec + [\\specification ["$." functor (#+ Injection Comparison)] ["$." apply] ["$." monad]]] diff --git a/stdlib/source/test/lux/control/concurrency/stm.lux b/stdlib/source/test/lux/control/concurrency/stm.lux index 6667274b5..23248f387 100644 --- a/stdlib/source/test/lux/control/concurrency/stm.lux +++ b/stdlib/source/test/lux/control/concurrency/stm.lux @@ -4,7 +4,7 @@ ["_" test (#+ Test)] [abstract ["." monad (#+ Monad do)] - [\\spec + [\\specification ["$." functor (#+ Injection Comparison)] ["$." apply] ["$." monad]]] diff --git a/stdlib/source/test/lux/control/continuation.lux b/stdlib/source/test/lux/control/continuation.lux index bec8160c1..d13a3ee78 100644 --- a/stdlib/source/test/lux/control/continuation.lux +++ b/stdlib/source/test/lux/control/continuation.lux @@ -4,7 +4,7 @@ ["_" test (#+ Test)] [abstract [monad (#+ do)] - [\\spec + [\\specification ["$." functor (#+ Injection Comparison)] ["$." apply] ["$." monad]]] diff --git a/stdlib/source/test/lux/control/function.lux b/stdlib/source/test/lux/control/function.lux index 8669e4220..46836db21 100644 --- a/stdlib/source/test/lux/control/function.lux +++ b/stdlib/source/test/lux/control/function.lux @@ -5,7 +5,7 @@ [abstract [equivalence (#+ Equivalence)] [monad (#+ do)] - [\\spec + [\\specification ["$." monoid]]] [data ["." text ("#!." equivalence)]] diff --git a/stdlib/source/test/lux/control/function/mixin.lux b/stdlib/source/test/lux/control/function/mixin.lux index a74ca04d4..339216526 100644 --- a/stdlib/source/test/lux/control/function/mixin.lux +++ b/stdlib/source/test/lux/control/function/mixin.lux @@ -6,7 +6,7 @@ [equivalence (#+ Equivalence)] [predicate (#+ Predicate)] [monad (#+ do)] - [\\spec + [\\specification ["$." monoid]]] [control ["." state (#+ State)]] diff --git a/stdlib/source/test/lux/control/io.lux b/stdlib/source/test/lux/control/io.lux index 1db7423e8..e101459c2 100644 --- a/stdlib/source/test/lux/control/io.lux +++ b/stdlib/source/test/lux/control/io.lux @@ -4,7 +4,7 @@ ["_" test (#+ Test)] [abstract [monad (#+ do)] - [\\spec + [\\specification ["$." functor (#+ Injection Comparison)] ["$." apply] ["$." monad]]] diff --git a/stdlib/source/test/lux/control/parser.lux b/stdlib/source/test/lux/control/parser.lux index ff8520b10..e9696fef8 100644 --- a/stdlib/source/test/lux/control/parser.lux +++ b/stdlib/source/test/lux/control/parser.lux @@ -5,7 +5,7 @@ [abstract [monad (#+ do)] [equivalence (#+ Equivalence)] - [\\spec + [\\specification ["$." functor (#+ Injection Comparison)] ["$." apply] ["$." monad]]] diff --git a/stdlib/source/test/lux/control/reader.lux b/stdlib/source/test/lux/control/reader.lux index b0edaa401..47ddbd8b2 100644 --- a/stdlib/source/test/lux/control/reader.lux +++ b/stdlib/source/test/lux/control/reader.lux @@ -4,7 +4,7 @@ ["_" test (#+ Test)] [abstract [monad (#+ do)] - [\\spec + [\\specification ["$." functor (#+ Injection Comparison)] ["$." apply] ["$." monad]]] diff --git a/stdlib/source/test/lux/control/region.lux b/stdlib/source/test/lux/control/region.lux index 2d2c5e1f9..fceb62bc7 100644 --- a/stdlib/source/test/lux/control/region.lux +++ b/stdlib/source/test/lux/control/region.lux @@ -9,7 +9,7 @@ [apply (#+ Apply)] ["." monad (#+ Monad do)] ["." enum] - [\\spec + [\\specification ["$." functor (#+ Injection Comparison)] ["$." apply] ["$." monad]]] diff --git a/stdlib/source/test/lux/control/security/policy.lux b/stdlib/source/test/lux/control/security/policy.lux index 87beb9a3a..577439ab5 100644 --- a/stdlib/source/test/lux/control/security/policy.lux +++ b/stdlib/source/test/lux/control/security/policy.lux @@ -5,7 +5,7 @@ [abstract [hash (#+ Hash)] [monad (#+ do)] - [\\spec + [\\specification ["$." functor (#+ Injection Comparison)] ["$." apply] ["$." monad]]] diff --git a/stdlib/source/test/lux/control/state.lux b/stdlib/source/test/lux/control/state.lux index 2c1541dbf..53622408d 100644 --- a/stdlib/source/test/lux/control/state.lux +++ b/stdlib/source/test/lux/control/state.lux @@ -4,7 +4,7 @@ ["_" test (#+ Test)] [abstract [monad (#+ do)] - [\\spec + [\\specification ["$." functor (#+ Injection Comparison)] ["$." apply] ["$." monad]]] diff --git a/stdlib/source/test/lux/control/thread.lux b/stdlib/source/test/lux/control/thread.lux index f3ad379dd..43d755145 100644 --- a/stdlib/source/test/lux/control/thread.lux +++ b/stdlib/source/test/lux/control/thread.lux @@ -4,7 +4,7 @@ ["_" test (#+ Test)] [abstract [monad (#+ do)] - [\\spec + [\\specification ["$." functor (#+ Injection Comparison)] ["$." apply] ["$." monad]]] diff --git a/stdlib/source/test/lux/control/try.lux b/stdlib/source/test/lux/control/try.lux index 9f131cffd..0872db2da 100644 --- a/stdlib/source/test/lux/control/try.lux +++ b/stdlib/source/test/lux/control/try.lux @@ -4,7 +4,7 @@ ["_" test (#+ Test)] [abstract [monad (#+ do)] - [\\spec + [\\specification ["$." functor (#+ Injection Comparison)] ["$." apply] ["$." monad] diff --git a/stdlib/source/test/lux/control/writer.lux b/stdlib/source/test/lux/control/writer.lux index 8d440ddd0..51f2ea36d 100644 --- a/stdlib/source/test/lux/control/writer.lux +++ b/stdlib/source/test/lux/control/writer.lux @@ -6,7 +6,7 @@ [equivalence (#+ Equivalence)] [monoid (#+ Monoid)] [monad (#+ do)] - [\\spec + [\\specification ["$." functor (#+ Injection Comparison)] ["$." apply] ["$." monad]]] diff --git a/stdlib/source/test/lux/data/binary.lux b/stdlib/source/test/lux/data/binary.lux index 347d9080b..879c0c722 100644 --- a/stdlib/source/test/lux/data/binary.lux +++ b/stdlib/source/test/lux/data/binary.lux @@ -5,7 +5,7 @@ [abstract ["." monad (#+ do)] ["." enum] - [\\spec + [\\specification ["$." equivalence] ["$." monoid]]] [control diff --git a/stdlib/source/test/lux/data/bit.lux b/stdlib/source/test/lux/data/bit.lux index 499b32779..fda210668 100644 --- a/stdlib/source/test/lux/data/bit.lux +++ b/stdlib/source/test/lux/data/bit.lux @@ -4,7 +4,7 @@ ["_" test (#+ Test)] [abstract [monad (#+ do)] - [\\spec + [\\specification ["$." equivalence] ["$." hash] ["$." monoid] diff --git a/stdlib/source/test/lux/data/collection/array.lux b/stdlib/source/test/lux/data/collection/array.lux index 20d554bea..ccf1d3484 100644 --- a/stdlib/source/test/lux/data/collection/array.lux +++ b/stdlib/source/test/lux/data/collection/array.lux @@ -4,7 +4,7 @@ ["_" test (#+ Test)] [abstract [monad (#+ do)] - [\\spec + [\\specification ["$." equivalence] ["$." monoid] ["$." fold] diff --git a/stdlib/source/test/lux/data/collection/bits.lux b/stdlib/source/test/lux/data/collection/bits.lux index f505b0fce..bc59e6b34 100644 --- a/stdlib/source/test/lux/data/collection/bits.lux +++ b/stdlib/source/test/lux/data/collection/bits.lux @@ -5,7 +5,7 @@ [abstract [monad (#+ do)] ["." predicate] - [\\spec + [\\specification ["$." equivalence]]] [math ["." random (#+ Random)] diff --git a/stdlib/source/test/lux/data/collection/dictionary.lux b/stdlib/source/test/lux/data/collection/dictionary.lux index c28ff6f51..c38df7030 100644 --- a/stdlib/source/test/lux/data/collection/dictionary.lux +++ b/stdlib/source/test/lux/data/collection/dictionary.lux @@ -5,7 +5,7 @@ [abstract [hash (#+ Hash)] [monad (#+ do)] - [\\spec + [\\specification ["$." equivalence] ["$." functor (#+ Injection)]]] [control diff --git a/stdlib/source/test/lux/data/collection/dictionary/ordered.lux b/stdlib/source/test/lux/data/collection/dictionary/ordered.lux index 66d8098d3..bfa0175bb 100644 --- a/stdlib/source/test/lux/data/collection/dictionary/ordered.lux +++ b/stdlib/source/test/lux/data/collection/dictionary/ordered.lux @@ -6,7 +6,7 @@ [monad (#+ do)] [equivalence (#+ Equivalence)] [order (#+ Order)] - [\\spec + [\\specification ["$." equivalence]]] [data ["." product] diff --git a/stdlib/source/test/lux/data/collection/dictionary/plist.lux b/stdlib/source/test/lux/data/collection/dictionary/plist.lux index 3d24c3943..450d3b733 100644 --- a/stdlib/source/test/lux/data/collection/dictionary/plist.lux +++ b/stdlib/source/test/lux/data/collection/dictionary/plist.lux @@ -4,7 +4,7 @@ ["_" test (#+ Test)] [abstract [monad (#+ do)] - [\\spec + [\\specification ["$." equivalence]]] [data ["." bit ("#\." equivalence)] diff --git a/stdlib/source/test/lux/data/collection/list.lux b/stdlib/source/test/lux/data/collection/list.lux index c46ccb681..5f1befd45 100644 --- a/stdlib/source/test/lux/data/collection/list.lux +++ b/stdlib/source/test/lux/data/collection/list.lux @@ -5,7 +5,7 @@ [abstract [monad (#+ do)] ["." enum] - [\\spec + [\\specification ["$." equivalence] ["$." hash] ["$." monoid] diff --git a/stdlib/source/test/lux/data/collection/queue.lux b/stdlib/source/test/lux/data/collection/queue.lux index 93dd8828f..3181c9bcc 100644 --- a/stdlib/source/test/lux/data/collection/queue.lux +++ b/stdlib/source/test/lux/data/collection/queue.lux @@ -4,7 +4,7 @@ ["_" test (#+ Test)] [abstract [monad (#+ do)] - [\\spec + [\\specification ["$." equivalence] ["$." functor (#+ Injection)]]] [data diff --git a/stdlib/source/test/lux/data/collection/row.lux b/stdlib/source/test/lux/data/collection/row.lux index 6f858efe6..6b7b09fdc 100644 --- a/stdlib/source/test/lux/data/collection/row.lux +++ b/stdlib/source/test/lux/data/collection/row.lux @@ -4,7 +4,7 @@ ["_" test (#+ Test)] [abstract [monad (#+ do)] - [\\spec + [\\specification ["$." equivalence] ["$." monoid] ["$." fold] diff --git a/stdlib/source/test/lux/data/collection/sequence.lux b/stdlib/source/test/lux/data/collection/sequence.lux index bbac12c34..8a8adf0a0 100644 --- a/stdlib/source/test/lux/data/collection/sequence.lux +++ b/stdlib/source/test/lux/data/collection/sequence.lux @@ -6,7 +6,7 @@ [monad (#+ do)] [equivalence (#+ Equivalence)] ["." enum] - [\\spec + [\\specification ["$." functor] ["$." comonad]]] [data diff --git a/stdlib/source/test/lux/data/collection/set.lux b/stdlib/source/test/lux/data/collection/set.lux index e543dce57..021df152d 100644 --- a/stdlib/source/test/lux/data/collection/set.lux +++ b/stdlib/source/test/lux/data/collection/set.lux @@ -5,7 +5,7 @@ [abstract [hash (#+ Hash)] [monad (#+ do)] - [\\spec + [\\specification ["$." equivalence] ["$." hash] ["$." monoid]]] diff --git a/stdlib/source/test/lux/data/collection/set/multi.lux b/stdlib/source/test/lux/data/collection/set/multi.lux index a6f95a3f0..1fd15a14f 100644 --- a/stdlib/source/test/lux/data/collection/set/multi.lux +++ b/stdlib/source/test/lux/data/collection/set/multi.lux @@ -6,7 +6,7 @@ [hash (#+ Hash)] [monad (#+ do)] ["." predicate] - [\\spec + [\\specification ["$." equivalence] ["$." hash]]] [data diff --git a/stdlib/source/test/lux/data/collection/set/ordered.lux b/stdlib/source/test/lux/data/collection/set/ordered.lux index 0a6b441b7..dd3ba8802 100644 --- a/stdlib/source/test/lux/data/collection/set/ordered.lux +++ b/stdlib/source/test/lux/data/collection/set/ordered.lux @@ -5,7 +5,7 @@ [abstract [monad (#+ do)] [order (#+ Order)] - [\\spec + [\\specification ["$." equivalence]]] [data ["." bit ("#\." equivalence)] diff --git a/stdlib/source/test/lux/data/collection/stack.lux b/stdlib/source/test/lux/data/collection/stack.lux index e671b3cee..c007ee050 100644 --- a/stdlib/source/test/lux/data/collection/stack.lux +++ b/stdlib/source/test/lux/data/collection/stack.lux @@ -4,7 +4,7 @@ ["_" test (#+ Test)] [abstract [monad (#+ do)] - [\\spec + [\\specification ["$." equivalence] ["$." functor (#+ Injection)]]] [data diff --git a/stdlib/source/test/lux/data/collection/tree.lux b/stdlib/source/test/lux/data/collection/tree.lux index ed27499c3..ff281844a 100644 --- a/stdlib/source/test/lux/data/collection/tree.lux +++ b/stdlib/source/test/lux/data/collection/tree.lux @@ -4,7 +4,7 @@ ["_" test (#+ Test)] [abstract ["." monad (#+ do)] - [\\spec + [\\specification ["$." equivalence] ["$." fold] ["$." functor]]] diff --git a/stdlib/source/test/lux/data/collection/tree/zipper.lux b/stdlib/source/test/lux/data/collection/tree/zipper.lux index b45e96213..06e53f225 100644 --- a/stdlib/source/test/lux/data/collection/tree/zipper.lux +++ b/stdlib/source/test/lux/data/collection/tree/zipper.lux @@ -4,7 +4,7 @@ ["_" test (#+ Test)] [abstract [monad (#+ do)] - [\\spec + [\\specification ["$." equivalence] ["$." functor] ["$." comonad]]] diff --git a/stdlib/source/test/lux/data/color.lux b/stdlib/source/test/lux/data/color.lux index b218a15ed..578771b59 100644 --- a/stdlib/source/test/lux/data/color.lux +++ b/stdlib/source/test/lux/data/color.lux @@ -4,7 +4,7 @@ ["_" test (#+ Test)] [abstract [monad (#+ do)] - [\\spec + [\\specification ["$." equivalence] ["$." hash] ["$." monoid]]] diff --git a/stdlib/source/test/lux/data/format/binary.lux b/stdlib/source/test/lux/data/format/binary.lux index 3457833ae..547f90f63 100644 --- a/stdlib/source/test/lux/data/format/binary.lux +++ b/stdlib/source/test/lux/data/format/binary.lux @@ -5,7 +5,7 @@ [abstract [equivalence (#+ Equivalence)] [monad (#+ do)] - [\\spec + [\\specification ["$." monoid]]] [data ["." binary ("#\." equivalence)]] diff --git a/stdlib/source/test/lux/data/format/json.lux b/stdlib/source/test/lux/data/format/json.lux index 8fa74ed9e..9bd1c09b5 100644 --- a/stdlib/source/test/lux/data/format/json.lux +++ b/stdlib/source/test/lux/data/format/json.lux @@ -5,7 +5,7 @@ ["." meta] [abstract [monad (#+ do)] - [\\spec + [\\specification ["$." equivalence] ["$." codec]]] [control diff --git a/stdlib/source/test/lux/data/format/xml.lux b/stdlib/source/test/lux/data/format/xml.lux index 5e4585d7f..7c9267b16 100644 --- a/stdlib/source/test/lux/data/format/xml.lux +++ b/stdlib/source/test/lux/data/format/xml.lux @@ -4,7 +4,7 @@ ["_" test (#+ Test)] [abstract [monad (#+ Monad do)] - [\\spec + [\\specification ["$." equivalence] ["$." codec]]] [control diff --git a/stdlib/source/test/lux/data/identity.lux b/stdlib/source/test/lux/data/identity.lux index c1359fd42..030d441b1 100644 --- a/stdlib/source/test/lux/data/identity.lux +++ b/stdlib/source/test/lux/data/identity.lux @@ -4,7 +4,7 @@ ["_" test (#+ Test)] [abstract [monad (#+ do)] - [\\spec + [\\specification ["$." functor (#+ Injection Comparison)] ["$." apply] ["$." monad] diff --git a/stdlib/source/test/lux/data/lazy.lux b/stdlib/source/test/lux/data/lazy.lux index 9972de30d..0c93ae612 100644 --- a/stdlib/source/test/lux/data/lazy.lux +++ b/stdlib/source/test/lux/data/lazy.lux @@ -4,7 +4,7 @@ ["_" test (#+ Test)] [abstract [monad (#+ do)] - [\\spec + [\\specification ["$." functor (#+ Injection Comparison)] ["$." apply] ["$." monad] diff --git a/stdlib/source/test/lux/data/maybe.lux b/stdlib/source/test/lux/data/maybe.lux index 51388c7a2..4f5accd9b 100644 --- a/stdlib/source/test/lux/data/maybe.lux +++ b/stdlib/source/test/lux/data/maybe.lux @@ -4,7 +4,7 @@ ["_" test (#+ Test)] [abstract [monad (#+ do)] - [\\spec + [\\specification ["$." equivalence] ["$." hash] ["$." monoid] diff --git a/stdlib/source/test/lux/data/name.lux b/stdlib/source/test/lux/data/name.lux index 958d236bf..e6f8b46c0 100644 --- a/stdlib/source/test/lux/data/name.lux +++ b/stdlib/source/test/lux/data/name.lux @@ -4,7 +4,7 @@ ["_" test (#+ Test)] [abstract [monad (#+ do)] - [\\spec + [\\specification ["$." equivalence] ["$." hash] ["$." order] diff --git a/stdlib/source/test/lux/data/product.lux b/stdlib/source/test/lux/data/product.lux index ed086d66a..fd361c2f6 100644 --- a/stdlib/source/test/lux/data/product.lux +++ b/stdlib/source/test/lux/data/product.lux @@ -4,7 +4,7 @@ ["_" test (#+ Test)] [abstract [monad (#+ do)] - [\\spec + [\\specification ["$." equivalence]]] [math ["." random] diff --git a/stdlib/source/test/lux/data/sum.lux b/stdlib/source/test/lux/data/sum.lux index b06d4ea79..cff19b801 100644 --- a/stdlib/source/test/lux/data/sum.lux +++ b/stdlib/source/test/lux/data/sum.lux @@ -4,7 +4,7 @@ ["_" test (#+ Test)] [abstract [monad (#+ do)] - [\\spec + [\\specification ["$." equivalence]]] [control pipe] diff --git a/stdlib/source/test/lux/data/text.lux b/stdlib/source/test/lux/data/text.lux index 5b13a9076..73696ae46 100644 --- a/stdlib/source/test/lux/data/text.lux +++ b/stdlib/source/test/lux/data/text.lux @@ -4,7 +4,7 @@ ["_" test (#+ Test)] [abstract [monad (#+ do)] - [\\spec + [\\specification ["$." equivalence] ["$." hash] ["$." order] diff --git a/stdlib/source/test/lux/data/text/encoding.lux b/stdlib/source/test/lux/data/text/encoding.lux index 53bc78299..ea8605b82 100644 --- a/stdlib/source/test/lux/data/text/encoding.lux +++ b/stdlib/source/test/lux/data/text/encoding.lux @@ -4,7 +4,7 @@ ["_" test (#+ Test)] [abstract [monad (#+ do)] - [\\spec + [\\specification ["$." codec]]] [control ["." try]] diff --git a/stdlib/source/test/lux/data/text/encoding/utf8.lux b/stdlib/source/test/lux/data/text/encoding/utf8.lux index 222e6e19b..a537a0277 100644 --- a/stdlib/source/test/lux/data/text/encoding/utf8.lux +++ b/stdlib/source/test/lux/data/text/encoding/utf8.lux @@ -3,7 +3,7 @@ [lux #* ["_" test (#+ Test)] [abstract - [\\spec + [\\specification ["$." codec]]] [data ["." text]] diff --git a/stdlib/source/test/lux/data/text/format.lux b/stdlib/source/test/lux/data/text/format.lux index f35683b33..e7a34a90c 100644 --- a/stdlib/source/test/lux/data/text/format.lux +++ b/stdlib/source/test/lux/data/text/format.lux @@ -6,7 +6,7 @@ [monad (#+ do)] [equivalence (#+ Equivalence)] [functor - [\\spec + [\\specification ["$." contravariant]]]] [control ["." try]] diff --git a/stdlib/source/test/lux/data/text/unicode/block.lux b/stdlib/source/test/lux/data/text/unicode/block.lux index e4affc97a..3b1f3866c 100644 --- a/stdlib/source/test/lux/data/text/unicode/block.lux +++ b/stdlib/source/test/lux/data/text/unicode/block.lux @@ -4,7 +4,7 @@ ["_" test (#+ Test)] [abstract [monad (#+ do)] - [\\spec + [\\specification ["$." equivalence] ["$." hash] ["$." monoid]]] diff --git a/stdlib/source/test/lux/data/text/unicode/set.lux b/stdlib/source/test/lux/data/text/unicode/set.lux index 3ef15de08..e70816efe 100644 --- a/stdlib/source/test/lux/data/text/unicode/set.lux +++ b/stdlib/source/test/lux/data/text/unicode/set.lux @@ -4,7 +4,7 @@ ["_" test (#+ Test)] [abstract [monad (#+ do)] - [\\spec + [\\specification ["$." equivalence]]] [data ["." product] diff --git a/stdlib/source/test/lux/ffi.lua.lux b/stdlib/source/test/lux/ffi.lua.lux index c8d4ea6d5..a1f181edc 100644 --- a/stdlib/source/test/lux/ffi.lua.lux +++ b/stdlib/source/test/lux/ffi.lua.lux @@ -5,21 +5,57 @@ [abstract [monad (#+ do)]] [control - ["." try]] - [data - ["." text ("#\." equivalence)]] + ["." io]] [math - ["." random (#+ Random)] + ["." random] [number - ["." nat] - ["." frac]]]]] + ["i" int]]]]] [\\library ["." /]]) +(/.import: (os/getenv [/.String] #io #? /.String)) + (def: #export test Test (do {! random.monad} - [] + [boolean random.bit + integer random.int + float random.frac + string (random.ascii/lower 1)] (<| (_.covering /._) - (_.test "TBD" - true)))) + (`` ($_ _.and + (~~ (template [ ] + [(_.cover [] + (exec + (: ) + true))] + + [/.Boolean boolean] + [/.Integer integer] + [/.Float float] + [/.String string] + )) + (_.for [/.Object] + ($_ _.and + (~~ (template [] + [(_.cover [] + (exec + (|> [] + (:as ) + (: (Ex [a] (/.Object a)))) + true))] + + [/.Nil] + [/.Table] + )))) + (_.cover [/.Function /.closure] + (exec + (|> (/.closure [input/0] input/0) + (: /.Function) + (: (Ex [a] (/.Object a)))) + true)) + (_.cover [/.import:] + (case (io.run (..os/getenv string)) + (#.Some _) true + #.None true)) + ))))) diff --git a/stdlib/source/test/lux/locale.lux b/stdlib/source/test/lux/locale.lux index 54b29cff7..3bb0be6ab 100644 --- a/stdlib/source/test/lux/locale.lux +++ b/stdlib/source/test/lux/locale.lux @@ -4,7 +4,7 @@ ["_" test (#+ Test)] [abstract [monad (#+ do)] - [\\spec + [\\specification ["$." equivalence] ["$." hash]]] [math diff --git a/stdlib/source/test/lux/locale/language.lux b/stdlib/source/test/lux/locale/language.lux index 39bc71aae..19bdd5f25 100644 --- a/stdlib/source/test/lux/locale/language.lux +++ b/stdlib/source/test/lux/locale/language.lux @@ -5,7 +5,7 @@ [abstract [monad (#+ do)] [hash (#+ Hash)] - [\\spec + [\\specification ["$." hash]]] [data ["." maybe] diff --git a/stdlib/source/test/lux/locale/territory.lux b/stdlib/source/test/lux/locale/territory.lux index fadbe2890..0d2b463c6 100644 --- a/stdlib/source/test/lux/locale/territory.lux +++ b/stdlib/source/test/lux/locale/territory.lux @@ -5,7 +5,7 @@ [abstract [monad (#+ do)] [hash (#+ Hash)] - [\\spec + [\\specification ["$." hash]]] [data ["." maybe] diff --git a/stdlib/source/test/lux/macro/code.lux b/stdlib/source/test/lux/macro/code.lux index 576ccb54a..8a037cc08 100644 --- a/stdlib/source/test/lux/macro/code.lux +++ b/stdlib/source/test/lux/macro/code.lux @@ -4,7 +4,7 @@ ["_" test (#+ Test)] [abstract [monad (#+ do)] - [\\spec + [\\specification ["$." equivalence]]] [control ["." try (#+ Try)]] diff --git a/stdlib/source/test/lux/macro/poly/equivalence.lux b/stdlib/source/test/lux/macro/poly/equivalence.lux index c8cd7c7bf..6682c2375 100644 --- a/stdlib/source/test/lux/macro/poly/equivalence.lux +++ b/stdlib/source/test/lux/macro/poly/equivalence.lux @@ -8,7 +8,7 @@ [equivalence (#+ Equivalence) [\\poly ["." /]]] - [\\spec + [\\specification ["$." equivalence]]] [data ["." bit] diff --git a/stdlib/source/test/lux/macro/poly/json.lux b/stdlib/source/test/lux/macro/poly/json.lux index e369dac92..4137ad271 100644 --- a/stdlib/source/test/lux/macro/poly/json.lux +++ b/stdlib/source/test/lux/macro/poly/json.lux @@ -8,7 +8,7 @@ [monad (#+ do)] ["." equivalence (#+ Equivalence) ["poly/#" \\poly]] - [\\spec + [\\specification ["$." equivalence] ["$." codec]]] [control diff --git a/stdlib/source/test/lux/macro/syntax/annotations.lux b/stdlib/source/test/lux/macro/syntax/annotations.lux index 00d71c949..cd6396535 100644 --- a/stdlib/source/test/lux/macro/syntax/annotations.lux +++ b/stdlib/source/test/lux/macro/syntax/annotations.lux @@ -4,7 +4,7 @@ ["_" test (#+ Test)] [abstract [monad (#+ do)] - [\\spec + [\\specification ["$." equivalence]]] [control ["." try] diff --git a/stdlib/source/test/lux/macro/syntax/check.lux b/stdlib/source/test/lux/macro/syntax/check.lux index 626471c73..36ad565a2 100644 --- a/stdlib/source/test/lux/macro/syntax/check.lux +++ b/stdlib/source/test/lux/macro/syntax/check.lux @@ -4,7 +4,7 @@ ["_" test (#+ Test)] [abstract [monad (#+ do)] - [\\spec + [\\specification ["$." equivalence]]] [control ["." try] diff --git a/stdlib/source/test/lux/macro/syntax/declaration.lux b/stdlib/source/test/lux/macro/syntax/declaration.lux index 761ba87cc..0d1e61874 100644 --- a/stdlib/source/test/lux/macro/syntax/declaration.lux +++ b/stdlib/source/test/lux/macro/syntax/declaration.lux @@ -4,7 +4,7 @@ ["_" test (#+ Test)] [abstract [monad (#+ do)] - [\\spec + [\\specification ["$." equivalence]]] [control ["." try] diff --git a/stdlib/source/test/lux/macro/syntax/definition.lux b/stdlib/source/test/lux/macro/syntax/definition.lux index c98b1e853..e6acc2847 100644 --- a/stdlib/source/test/lux/macro/syntax/definition.lux +++ b/stdlib/source/test/lux/macro/syntax/definition.lux @@ -4,7 +4,7 @@ ["_" test (#+ Test)] [abstract [monad (#+ do)] - [\\spec + [\\specification ["$." equivalence]]] [control ["." try] diff --git a/stdlib/source/test/lux/macro/syntax/input.lux b/stdlib/source/test/lux/macro/syntax/input.lux index 34357f79a..e292cde72 100644 --- a/stdlib/source/test/lux/macro/syntax/input.lux +++ b/stdlib/source/test/lux/macro/syntax/input.lux @@ -4,7 +4,7 @@ ["_" test (#+ Test)] [abstract [monad (#+ do)] - [\\spec + [\\specification ["$." equivalence]]] [control ["." try] diff --git a/stdlib/source/test/lux/macro/syntax/type/variable.lux b/stdlib/source/test/lux/macro/syntax/type/variable.lux index 8ff84f36f..18197bf3e 100644 --- a/stdlib/source/test/lux/macro/syntax/type/variable.lux +++ b/stdlib/source/test/lux/macro/syntax/type/variable.lux @@ -4,7 +4,7 @@ ["_" test (#+ Test)] [abstract [monad (#+ do)] - [\\spec + [\\specification ["$." equivalence]]] [control ["." try ("#\." functor)] diff --git a/stdlib/source/test/lux/math.lux b/stdlib/source/test/lux/math.lux index a43d63a2b..db314f400 100644 --- a/stdlib/source/test/lux/math.lux +++ b/stdlib/source/test/lux/math.lux @@ -77,6 +77,17 @@ (let [round'd (/.round sample)] (and (|> round'd f.int i.frac (f.= round'd)) (f.<= +1.0 (f.abs (f.- sample round'd)))))) + (_.cover [/.root/2] + (let [sample (f.abs sample)] + (|> sample + /.root/2 + (/.pow +2.0) + (f.approximately? ..margin_of_error sample)))) + (_.cover [/.root/3] + (|> sample + /.root/3 + (/.pow +3.0) + (f.approximately? ..margin_of_error sample))) )) (do {! random.monad} [#let [~= (f.approximately? ..margin_of_error)] diff --git a/stdlib/source/test/lux/math/logic/continuous.lux b/stdlib/source/test/lux/math/logic/continuous.lux index 5ff4c46cc..ab7049221 100644 --- a/stdlib/source/test/lux/math/logic/continuous.lux +++ b/stdlib/source/test/lux/math/logic/continuous.lux @@ -4,7 +4,7 @@ ["_" test (#+ Test)] [abstract [monad (#+ do)] - [\\spec + [\\specification ["$." monoid]]] [math ["." random] diff --git a/stdlib/source/test/lux/math/logic/fuzzy.lux b/stdlib/source/test/lux/math/logic/fuzzy.lux index ea39da68a..657285025 100644 --- a/stdlib/source/test/lux/math/logic/fuzzy.lux +++ b/stdlib/source/test/lux/math/logic/fuzzy.lux @@ -5,7 +5,7 @@ [abstract [equivalence (#+ Equivalence)] [monad (#+ do)] - [\\spec + [\\specification [functor ["$." contravariant]]]] [data diff --git a/stdlib/source/test/lux/math/modular.lux b/stdlib/source/test/lux/math/modular.lux index 5322b162b..090481806 100644 --- a/stdlib/source/test/lux/math/modular.lux +++ b/stdlib/source/test/lux/math/modular.lux @@ -6,7 +6,7 @@ [abstract [monad (#+ do)] ["." predicate] - [\\spec + [\\specification ["$." equivalence] ["$." order] ["$." monoid] diff --git a/stdlib/source/test/lux/math/number/complex.lux b/stdlib/source/test/lux/math/number/complex.lux index 2670d53dc..cd4f1146c 100644 --- a/stdlib/source/test/lux/math/number/complex.lux +++ b/stdlib/source/test/lux/math/number/complex.lux @@ -5,7 +5,7 @@ ["_" test (#+ Test)] [abstract [monad (#+ do)] - [\\spec + [\\specification ["$." equivalence] ["$." order] ["$." codec]]] diff --git a/stdlib/source/test/lux/math/number/frac.lux b/stdlib/source/test/lux/math/number/frac.lux index 093511510..9a5133a97 100644 --- a/stdlib/source/test/lux/math/number/frac.lux +++ b/stdlib/source/test/lux/math/number/frac.lux @@ -6,7 +6,7 @@ ["." ffi] [abstract [monad (#+ do)] - [\\spec + [\\specification ["$." equivalence] ["$." hash] ["$." order] diff --git a/stdlib/source/test/lux/math/number/i16.lux b/stdlib/source/test/lux/math/number/i16.lux index 4720a13b7..5a9e36f88 100644 --- a/stdlib/source/test/lux/math/number/i16.lux +++ b/stdlib/source/test/lux/math/number/i16.lux @@ -4,7 +4,7 @@ ["_" test (#+ Test)] [abstract [monad (#+ do)] - [\\spec + [\\specification ["$." equivalence]]] [math ["." random (#+ Random)]]]] diff --git a/stdlib/source/test/lux/math/number/i32.lux b/stdlib/source/test/lux/math/number/i32.lux index 66d65fa40..4cced31ad 100644 --- a/stdlib/source/test/lux/math/number/i32.lux +++ b/stdlib/source/test/lux/math/number/i32.lux @@ -4,7 +4,7 @@ ["_" test (#+ Test)] [abstract [monad (#+ do)] - [\\spec + [\\specification ["$." equivalence]]] [math ["." random (#+ Random)]]]] diff --git a/stdlib/source/test/lux/math/number/i64.lux b/stdlib/source/test/lux/math/number/i64.lux index 942930af0..94260d6ee 100644 --- a/stdlib/source/test/lux/math/number/i64.lux +++ b/stdlib/source/test/lux/math/number/i64.lux @@ -6,7 +6,7 @@ ["." bit ("#\." equivalence)]] [abstract [monad (#+ do)] - [\\spec + [\\specification ["$." equivalence] ["$." hash] ["$." monoid]]] diff --git a/stdlib/source/test/lux/math/number/i8.lux b/stdlib/source/test/lux/math/number/i8.lux index c5fee1fcf..8b454883d 100644 --- a/stdlib/source/test/lux/math/number/i8.lux +++ b/stdlib/source/test/lux/math/number/i8.lux @@ -4,7 +4,7 @@ ["_" test (#+ Test)] [abstract [monad (#+ do)] - [\\spec + [\\specification ["$." equivalence]]] [math ["." random (#+ Random)]]]] diff --git a/stdlib/source/test/lux/math/number/int.lux b/stdlib/source/test/lux/math/number/int.lux index 47e381985..9b650e795 100644 --- a/stdlib/source/test/lux/math/number/int.lux +++ b/stdlib/source/test/lux/math/number/int.lux @@ -4,7 +4,7 @@ ["_" test (#+ Test)] [abstract [monad (#+ do)] - [\\spec + [\\specification ["$." equivalence] ["$." hash] ["$." order] diff --git a/stdlib/source/test/lux/math/number/nat.lux b/stdlib/source/test/lux/math/number/nat.lux index ff3eb64d1..9577b25db 100644 --- a/stdlib/source/test/lux/math/number/nat.lux +++ b/stdlib/source/test/lux/math/number/nat.lux @@ -4,7 +4,7 @@ ["_" test (#+ Test)] [abstract [monad (#+ do)] - [\\spec + [\\specification ["$." equivalence] ["$." hash] ["$." order] diff --git a/stdlib/source/test/lux/math/number/ratio.lux b/stdlib/source/test/lux/math/number/ratio.lux index 838e8ca81..0d67d6f69 100644 --- a/stdlib/source/test/lux/math/number/ratio.lux +++ b/stdlib/source/test/lux/math/number/ratio.lux @@ -4,7 +4,7 @@ ["_" test (#+ Test)] [abstract [monad (#+ do)] - [\\spec + [\\specification ["$." equivalence] ["$." order] ["$." monoid] diff --git a/stdlib/source/test/lux/math/number/rev.lux b/stdlib/source/test/lux/math/number/rev.lux index 70ab24c61..1a2eb29e5 100644 --- a/stdlib/source/test/lux/math/number/rev.lux +++ b/stdlib/source/test/lux/math/number/rev.lux @@ -4,7 +4,7 @@ ["_" test (#+ Test)] [abstract [monad (#+ do)] - [\\spec + [\\specification ["$." equivalence] ["$." hash] ["$." order] diff --git a/stdlib/source/test/lux/meta.lux b/stdlib/source/test/lux/meta.lux index 3b3bf1ae2..9276f4a18 100644 --- a/stdlib/source/test/lux/meta.lux +++ b/stdlib/source/test/lux/meta.lux @@ -6,7 +6,7 @@ [abstract [equivalence (#+ Equivalence)] [monad (#+ do)] - [\\spec + [\\specification ["$." functor (#+ Injection Comparison)] ["$." apply] ["$." monad]]] diff --git a/stdlib/source/test/lux/meta/location.lux b/stdlib/source/test/lux/meta/location.lux index 2aaa797a0..421c872dd 100644 --- a/stdlib/source/test/lux/meta/location.lux +++ b/stdlib/source/test/lux/meta/location.lux @@ -4,7 +4,7 @@ ["_" test (#+ Test)] [abstract [monad (#+ do)] - [\\spec + [\\specification ["$." equivalence]]] [data ["." text]] diff --git a/stdlib/source/test/lux/test.lux b/stdlib/source/test/lux/test.lux index 9c3e0f506..d7c05641c 100644 --- a/stdlib/source/test/lux/test.lux +++ b/stdlib/source/test/lux/test.lux @@ -12,7 +12,8 @@ [data ["." text ("#\." equivalence)] [collection - ["." list]]] + ["." list] + ["." set]]] [math ["." random] [number @@ -162,6 +163,58 @@ ran_all_tests!)))))) )) +(def: #export dummy_target + "YOLO") + +(def: coverage + /.Test + ($_ /.and + (do random.monad + [not_covering (/.test "" true) + covering (/.covering .._ (/.test "" true))] + (wrap (do promise.monad + [[not_covering _] not_covering + [covering _] covering] + (/.cover' [/.covering] + (and (and (set.empty? (get@ #/.expected_coverage not_covering)) + (set.empty? (get@ #/.actual_coverage not_covering))) + (and (not (set.empty? (get@ #/.expected_coverage covering))) + (set.empty? (get@ #/.actual_coverage covering)))))))) + (do random.monad + [not_covering (/.covering .._ (/.test "" true)) + covering (/.covering .._ (/.cover [..dummy_target] true))] + (wrap (do promise.monad + [[not_covering _] not_covering + [covering _] covering] + (/.cover' [/.cover] + (and (and (not (set.empty? (get@ #/.expected_coverage not_covering))) + (not (set.member? (get@ #/.actual_coverage not_covering) (name_of ..dummy_target)))) + (and (not (set.empty? (get@ #/.expected_coverage covering))) + (set.member? (get@ #/.actual_coverage covering) (name_of ..dummy_target)))))))) + (do random.monad + [not_covering (/.covering .._ (/.test "" true)) + covering (/.covering .._ (wrap (/.cover' [..dummy_target] true)))] + (wrap (do promise.monad + [[not_covering _] not_covering + [covering _] covering] + (/.cover' [/.cover'] + (and (and (not (set.empty? (get@ #/.expected_coverage not_covering))) + (not (set.member? (get@ #/.actual_coverage not_covering) (name_of ..dummy_target)))) + (and (not (set.empty? (get@ #/.expected_coverage covering))) + (set.member? (get@ #/.actual_coverage covering) (name_of ..dummy_target)))))))) + (do random.monad + [not_covering (/.covering .._ (/.test "" true)) + covering (/.covering .._ (/.for [..dummy_target] (/.test "" true)))] + (wrap (do promise.monad + [[not_covering _] not_covering + [covering _] covering] + (/.cover' [/.for] + (and (and (not (set.empty? (get@ #/.expected_coverage not_covering))) + (not (set.member? (get@ #/.actual_coverage not_covering) (name_of ..dummy_target)))) + (and (not (set.empty? (get@ #/.expected_coverage covering))) + (set.member? (get@ #/.actual_coverage covering) (name_of ..dummy_target)))))))) + )) + (def: #export test /.Test (<| (/.covering /._) @@ -247,4 +300,5 @@ (n.= 1 (get@ #/.failures failure_tally)))))))) ..times ..in_parallel + ..coverage )))) diff --git a/stdlib/source/test/lux/time.lux b/stdlib/source/test/lux/time.lux index 17b17c61a..77933544c 100644 --- a/stdlib/source/test/lux/time.lux +++ b/stdlib/source/test/lux/time.lux @@ -4,7 +4,7 @@ ["_" test (#+ Test)] [abstract [monad (#+ do)] - [\\spec + [\\specification ["$." equivalence] ["$." order] ["$." enum] diff --git a/stdlib/source/test/lux/time/date.lux b/stdlib/source/test/lux/time/date.lux index cb9d46978..cb8ab50c8 100644 --- a/stdlib/source/test/lux/time/date.lux +++ b/stdlib/source/test/lux/time/date.lux @@ -4,7 +4,7 @@ ["_" test (#+ Test)] [abstract [monad (#+ do)] - [\\spec + [\\specification ["$." equivalence] ["$." order] ["$." enum] diff --git a/stdlib/source/test/lux/time/day.lux b/stdlib/source/test/lux/time/day.lux index d2499309b..03544b180 100644 --- a/stdlib/source/test/lux/time/day.lux +++ b/stdlib/source/test/lux/time/day.lux @@ -4,7 +4,7 @@ ["_" test (#+ Test)] [abstract [monad (#+ do)] - [\\spec + [\\specification ["$." equivalence] ["$." order] ["$." enum] diff --git a/stdlib/source/test/lux/time/duration.lux b/stdlib/source/test/lux/time/duration.lux index a3014cc1a..1d2fa1ce7 100644 --- a/stdlib/source/test/lux/time/duration.lux +++ b/stdlib/source/test/lux/time/duration.lux @@ -4,7 +4,7 @@ ["_" test (#+ Test)] [abstract [monad (#+ do)] - [\\spec + [\\specification ["$." equivalence] ["$." order] ["$." enum] diff --git a/stdlib/source/test/lux/time/instant.lux b/stdlib/source/test/lux/time/instant.lux index 6fef2f55e..377a47db1 100644 --- a/stdlib/source/test/lux/time/instant.lux +++ b/stdlib/source/test/lux/time/instant.lux @@ -4,7 +4,7 @@ ["_" test (#+ Test)] [abstract [monad (#+ do)] - [\\spec + [\\specification ["$." equivalence] ["$." order] ["$." enum] diff --git a/stdlib/source/test/lux/time/month.lux b/stdlib/source/test/lux/time/month.lux index 202048cac..d6f124244 100644 --- a/stdlib/source/test/lux/time/month.lux +++ b/stdlib/source/test/lux/time/month.lux @@ -5,7 +5,7 @@ [abstract [monad (#+ do)] ["." predicate] - [\\spec + [\\specification ["$." equivalence] ["$." hash] ["$." order] diff --git a/stdlib/source/test/lux/time/year.lux b/stdlib/source/test/lux/time/year.lux index ba364eaab..b1e2691db 100644 --- a/stdlib/source/test/lux/time/year.lux +++ b/stdlib/source/test/lux/time/year.lux @@ -4,7 +4,7 @@ ["_" test (#+ Test)] [abstract [monad (#+ do)] - [\\spec + [\\specification ["$." equivalence] ["$." order] ["$." codec]]] diff --git a/stdlib/source/test/lux/type.lux b/stdlib/source/test/lux/type.lux index 3a01acaab..b6c24bde2 100644 --- a/stdlib/source/test/lux/type.lux +++ b/stdlib/source/test/lux/type.lux @@ -4,7 +4,7 @@ ["_" test (#+ Test)] [abstract ["." monad (#+ do)] - [\\spec + [\\specification ["$." equivalence]]] [control [pipe (#+ case>)]] diff --git a/stdlib/source/test/lux/type/check.lux b/stdlib/source/test/lux/type/check.lux index 949009d5b..40079eae9 100644 --- a/stdlib/source/test/lux/type/check.lux +++ b/stdlib/source/test/lux/type/check.lux @@ -4,7 +4,7 @@ ["_" test (#+ Test)] [abstract ["." monad (#+ do)] - [\\spec + [\\specification ["$." functor (#+ Injection Comparison)] ["$." apply] ["$." monad]]] diff --git a/stdlib/source/test/lux/type/quotient.lux b/stdlib/source/test/lux/type/quotient.lux index 11d711ac7..5d39b91f2 100644 --- a/stdlib/source/test/lux/type/quotient.lux +++ b/stdlib/source/test/lux/type/quotient.lux @@ -4,7 +4,7 @@ ["_" test (#+ Test)] [abstract ["." monad (#+ do)] - [\\spec + [\\specification ["$." equivalence]]] [data ["." text ("#\." equivalence) diff --git a/stdlib/source/test/lux/type/unit.lux b/stdlib/source/test/lux/type/unit.lux index 6789d7b65..1bed08707 100644 --- a/stdlib/source/test/lux/type/unit.lux +++ b/stdlib/source/test/lux/type/unit.lux @@ -7,7 +7,7 @@ [abstract [monad (#+ do)] [equivalence (#+ Equivalence)] - [\\spec + [\\specification ["$." equivalence] ["$." order] ["$." enum]]] diff --git a/stdlib/source/test/lux/world/console.lux b/stdlib/source/test/lux/world/console.lux index 055ee1466..c34a5c488 100644 --- a/stdlib/source/test/lux/world/console.lux +++ b/stdlib/source/test/lux/world/console.lux @@ -15,7 +15,7 @@ ["." random]]]] [\\library ["." /]] - [\\spec + [\\specification ["$." /]]) (exception: dead) diff --git a/stdlib/source/test/lux/world/file.lux b/stdlib/source/test/lux/world/file.lux index 1074749f4..ecc596399 100644 --- a/stdlib/source/test/lux/world/file.lux +++ b/stdlib/source/test/lux/world/file.lux @@ -12,7 +12,7 @@ ["#." watch]] [\\library ["." /]] - [\\spec + [\\specification ["$." /]]) (def: #export test diff --git a/stdlib/source/test/lux/world/file/watch.lux b/stdlib/source/test/lux/world/file/watch.lux index a4a8748ed..bbbcdf680 100644 --- a/stdlib/source/test/lux/world/file/watch.lux +++ b/stdlib/source/test/lux/world/file/watch.lux @@ -183,4 +183,17 @@ after_deletion!)))] (_.cover' [/.mock /.polling] (try.default false verdict))))) + (do random.monad + [directory (random.ascii/alpha 5) + #let [/ "/" + [fs watcher] (/.mock /)]] + (wrap (do promise.monad + [started? ( \ watcher start /.all directory)] + (_.cover' [/.cannot_poll_a_non_existent_directory] + (case started? + (#try.Success _) + false + + (#try.Failure error) + (exception.match? /.cannot_poll_a_non_existent_directory error)))))) ))) diff --git a/stdlib/source/test/lux/world/output/video/resolution.lux b/stdlib/source/test/lux/world/output/video/resolution.lux index 1cfcd0ae8..671b1952c 100644 --- a/stdlib/source/test/lux/world/output/video/resolution.lux +++ b/stdlib/source/test/lux/world/output/video/resolution.lux @@ -4,7 +4,7 @@ ["_" test (#+ Test)] [abstract [monad (#+ do)] - [\\spec + [\\specification ["$." equivalence] ["$." hash]]] [data diff --git a/stdlib/source/test/lux/world/program.lux b/stdlib/source/test/lux/world/program.lux index fafda5f91..0028cfe9c 100644 --- a/stdlib/source/test/lux/world/program.lux +++ b/stdlib/source/test/lux/world/program.lux @@ -25,7 +25,7 @@ ["." / [// [file (#+ Path)]]]] - [\\spec + [\\specification ["$." /]]) (def: (environment env_size) diff --git a/stdlib/source/test/lux/world/shell.lux b/stdlib/source/test/lux/world/shell.lux index 8d117eefa..749441a7a 100644 --- a/stdlib/source/test/lux/world/shell.lux +++ b/stdlib/source/test/lux/world/shell.lux @@ -25,7 +25,7 @@ ["." / [// [file (#+ Path)]]]] - [\\spec + [\\specification ["$." /]]) (exception: dead) -- cgit v1.2.3