aboutsummaryrefslogtreecommitdiff
path: root/stdlib/source
diff options
context:
space:
mode:
authorEduardo Julian2022-06-12 02:29:28 -0400
committerEduardo Julian2022-06-12 02:29:28 -0400
commit9c21fd1f33eb52fb971d493ad21a67036d68b841 (patch)
tree525d0f841edfa94645317ac905cb69c8a7983a5c /stdlib/source
parentb48ea68a83d01903554c7696c77eedaaf1035680 (diff)
Re-named the "poly" hierarchy to "polytypic".
Diffstat (limited to 'stdlib/source')
-rw-r--r--stdlib/source/library/lux/data/format/json.lux4
-rw-r--r--stdlib/source/library/lux/data/format/xml.lux6
-rw-r--r--stdlib/source/library/lux/data/text/regex.lux3
-rw-r--r--stdlib/source/library/lux/extension.lux7
-rw-r--r--stdlib/source/library/lux/ffi/export.rb.lux8
-rw-r--r--stdlib/source/library/lux/math/modular.lux4
-rw-r--r--stdlib/source/library/lux/meta/configuration.lux4
-rw-r--r--stdlib/source/library/lux/target/jvm/reflection.lux7
-rw-r--r--stdlib/source/library/lux/target/jvm/type/alias.lux6
-rw-r--r--stdlib/source/library/lux/target/jvm/type/lux.lux6
-rw-r--r--stdlib/source/library/lux/target/jvm/type/parser.lux10
-rw-r--r--stdlib/source/library/lux/time.lux8
-rw-r--r--stdlib/source/library/lux/time/date.lux8
-rw-r--r--stdlib/source/library/lux/time/duration.lux8
-rw-r--r--stdlib/source/library/lux/time/instant.lux8
-rw-r--r--stdlib/source/library/lux/time/year.lux8
-rw-r--r--stdlib/source/library/lux/tool/compiler/language/lux/phase/extension/analysis/jvm.lux6
-rw-r--r--stdlib/source/library/lux/tool/compiler/language/lux/phase/extension/directive/jvm.lux6
-rw-r--r--stdlib/source/library/lux/tool/compiler/language/lux/phase/extension/generation/jvm/host.lux4
-rw-r--r--stdlib/source/library/lux/tool/compiler/language/lux/syntax.lux2
-rw-r--r--stdlib/source/library/lux/tool/compiler/meta/cli.lux6
-rw-r--r--stdlib/source/library/lux/tool/compiler/meta/cli/compiler.lux6
-rw-r--r--stdlib/source/parser/lux/data/text.lux (renamed from stdlib/source/library/lux/control/parser/text.lux)4
-rw-r--r--stdlib/source/parser/lux/tool/compiler/language/lux/analysis.lux (renamed from stdlib/source/library/lux/control/parser/analysis.lux)8
-rw-r--r--stdlib/source/polytypic/lux/abstract/equivalence.lux (renamed from stdlib/source/poly/lux/abstract/equivalence.lux)0
-rw-r--r--stdlib/source/polytypic/lux/abstract/functor.lux (renamed from stdlib/source/poly/lux/abstract/functor.lux)0
-rw-r--r--stdlib/source/polytypic/lux/data/format/json.lux (renamed from stdlib/source/poly/lux/data/format/json.lux)0
-rw-r--r--stdlib/source/program/aedifex/artifact/snapshot.lux5
-rw-r--r--stdlib/source/program/aedifex/artifact/snapshot/build.lux8
-rw-r--r--stdlib/source/program/aedifex/artifact/snapshot/stamp.lux5
-rw-r--r--stdlib/source/program/aedifex/artifact/snapshot/time.lux6
-rw-r--r--stdlib/source/program/aedifex/artifact/snapshot/version.lux6
-rw-r--r--stdlib/source/program/aedifex/artifact/time.lux10
-rw-r--r--stdlib/source/program/aedifex/artifact/time/date.lux10
-rw-r--r--stdlib/source/program/aedifex/artifact/time/time.lux8
-rw-r--r--stdlib/source/program/aedifex/artifact/versioning.lux6
-rw-r--r--stdlib/source/program/aedifex/metadata/artifact.lux4
-rw-r--r--stdlib/source/program/aedifex/metadata/snapshot.lux4
-rw-r--r--stdlib/source/test/aedifex/artifact/snapshot/time.lux7
-rw-r--r--stdlib/source/test/aedifex/artifact/snapshot/version/value.lux7
-rw-r--r--stdlib/source/test/aedifex/artifact/time.lux7
-rw-r--r--stdlib/source/test/aedifex/artifact/time/date.lux7
-rw-r--r--stdlib/source/test/aedifex/artifact/time/time.lux7
-rw-r--r--stdlib/source/test/lux/abstract/equivalence.lux79
-rw-r--r--stdlib/source/test/lux/abstract/functor.lux31
-rw-r--r--stdlib/source/test/lux/control/parser.lux4
-rw-r--r--stdlib/source/test/lux/control/parser/analysis.lux156
-rw-r--r--stdlib/source/test/lux/control/parser/text.lux444
-rw-r--r--stdlib/source/test/lux/data/format/json.lux106
-rw-r--r--stdlib/source/test/lux/data/text.lux440
-rw-r--r--stdlib/source/test/lux/data/text/regex.lux4
-rw-r--r--stdlib/source/test/lux/extension.lux4
-rw-r--r--stdlib/source/test/lux/meta/configuration.lux4
-rw-r--r--stdlib/source/test/lux/time.lux7
-rw-r--r--stdlib/source/test/lux/time/date.lux9
-rw-r--r--stdlib/source/test/lux/tool/compiler/language/lux/analysis.lux162
-rw-r--r--stdlib/source/test/lux/tool/compiler/meta/cli/compiler.lux7
-rw-r--r--stdlib/source/test/lux/type.lux2
-rw-r--r--stdlib/source/test/lux/type/poly.lux20
-rw-r--r--stdlib/source/test/lux/type/poly/equivalence.lux89
-rw-r--r--stdlib/source/test/lux/type/poly/functor.lux38
-rw-r--r--stdlib/source/test/lux/type/poly/json.lux124
62 files changed, 938 insertions, 1046 deletions
diff --git a/stdlib/source/library/lux/data/format/json.lux b/stdlib/source/library/lux/data/format/json.lux
index 4f95615ed..3a0e69a6c 100644
--- a/stdlib/source/library/lux/data/format/json.lux
+++ b/stdlib/source/library/lux/data/format/json.lux
@@ -12,12 +12,12 @@
["[0]" maybe]
["[0]" try (.only Try)]
["<>" parser (.open: "[1]#[0]" monad)
- ["<[0]>" text (.only Parser)]
["<[0]>" code]]]
[data
["[0]" bit]
["[0]" product]
- ["[0]" text (.open: "[1]#[0]" equivalence monoid)]
+ ["[0]" text (.open: "[1]#[0]" equivalence monoid)
+ ["<[1]>" \\parser (.only Parser)]]
[collection
["[0]" list (.open: "[1]#[0]" mix functor)]
["[0]" sequence (.only Sequence sequence) (.open: "[1]#[0]" monad)]
diff --git a/stdlib/source/library/lux/data/format/xml.lux b/stdlib/source/library/lux/data/format/xml.lux
index 1fa0a04ac..dfab48227 100644
--- a/stdlib/source/library/lux/data/format/xml.lux
+++ b/stdlib/source/library/lux/data/format/xml.lux
@@ -7,11 +7,11 @@
[codec (.only Codec)]]
[control
[try (.only Try)]
- ["<>" parser (.open: "[1]#[0]" monad)
- ["<[0]>" text (.only Parser Slice)]]]
+ ["<>" parser (.open: "[1]#[0]" monad)]]
[data
["[0]" product]
- ["[0]" text (.only \n) (.open: "[1]#[0]" equivalence monoid)]
+ ["[0]" text (.only \n) (.open: "[1]#[0]" equivalence monoid)
+ ["<[1]>" \\parser (.only Parser Slice)]]
[collection
["[0]" list (.open: "[1]#[0]" functor)]
["[0]" dictionary (.only Dictionary)]]]
diff --git a/stdlib/source/library/lux/data/text/regex.lux b/stdlib/source/library/lux/data/text/regex.lux
index 8e48c00d4..38908a999 100644
--- a/stdlib/source/library/lux/data/text/regex.lux
+++ b/stdlib/source/library/lux/data/text/regex.lux
@@ -9,10 +9,11 @@
["[0]" try]
["[0]" exception (.only exception:)]
["<>" parser (.open: "[1]#[0]" monad)
- ["<[0]>" text (.only Parser)]
["<[0]>" code]]]
[data
["[0]" product]
+ ["[0]" text
+ ["<[1]>" \\parser (.only Parser)]]
[collection
["[0]" list (.open: "[1]#[0]" mix monad)]]]
[macro (.only with_symbols)
diff --git a/stdlib/source/library/lux/extension.lux b/stdlib/source/library/lux/extension.lux
index ffe7a4a78..90033a988 100644
--- a/stdlib/source/library/lux/extension.lux
+++ b/stdlib/source/library/lux/extension.lux
@@ -6,7 +6,6 @@
[control
["<>" parser (.open: "[1]#[0]" monad)
["<c>" code (.only Parser)]
- ["<a>" analysis]
["<s>" synthesis]]]
[data
["[0]" product]
@@ -17,7 +16,11 @@
["[0]" code]]
[tool
[compiler
- ["[0]" phase]]]]])
+ ["[0]" phase]
+ [language
+ [lux
+ [analysis
+ ["<a>" \\parser]]]]]]]])
(type: Declaration
(Record
diff --git a/stdlib/source/library/lux/ffi/export.rb.lux b/stdlib/source/library/lux/ffi/export.rb.lux
index 46c259fbe..00702d7cf 100644
--- a/stdlib/source/library/lux/ffi/export.rb.lux
+++ b/stdlib/source/library/lux/ffi/export.rb.lux
@@ -9,11 +9,11 @@
["[0]" monad (.only do)]]
[control
["<>" parser (.only)
- ["<[0]>" code]
- ["<[0]>" text (.only Parser)]]]
+ ["<[0]>" code]]]
[data
- [text
- ["%" format]]
+ ["[0]" text
+ ["%" format]
+ ["<[1]>" \\parser (.only Parser)]]
[collection
["[0]" list (.open: "[1]#[0]" monad mix)]
["[0]" set]]]
diff --git a/stdlib/source/library/lux/math/modular.lux b/stdlib/source/library/lux/math/modular.lux
index 09e1b6a31..a46f67418 100644
--- a/stdlib/source/library/lux/math/modular.lux
+++ b/stdlib/source/library/lux/math/modular.lux
@@ -11,11 +11,11 @@
["[0]" try (.only Try)]
["[0]" exception (.only exception:)]
["<>" parser (.only)
- ["<[0]>" text (.only Parser)]
["<[0]>" code]]]
[data
["[0]" product]
- ["[0]" text (.open: "[1]#[0]" monoid)]]
+ ["[0]" text (.open: "[1]#[0]" monoid)
+ ["<[1]>" \\parser (.only Parser)]]]
[macro
["[0]" code]]
[math
diff --git a/stdlib/source/library/lux/meta/configuration.lux b/stdlib/source/library/lux/meta/configuration.lux
index cf6675195..6e6ed68bb 100644
--- a/stdlib/source/library/lux/meta/configuration.lux
+++ b/stdlib/source/library/lux/meta/configuration.lux
@@ -10,11 +10,11 @@
["[0]" maybe (.open: "[1]#[0]" functor)]
["[0]" exception (.only exception:)]
["<>" parser (.only)
- ["<[0]>" text (.only Parser)]
["<[0]>" code]]]
[data
["[0]" text (.open: "[1]#[0]" equivalence)
- ["%" format]]
+ ["%" format]
+ ["<[1]>" \\parser (.only Parser)]]
[collection
["[0]" list (.open: "[1]#[0]" functor mix)]
[dictionary
diff --git a/stdlib/source/library/lux/target/jvm/reflection.lux b/stdlib/source/library/lux/target/jvm/reflection.lux
index 5a76db47d..3548f5c19 100644
--- a/stdlib/source/library/lux/target/jvm/reflection.lux
+++ b/stdlib/source/library/lux/target/jvm/reflection.lux
@@ -7,12 +7,11 @@
["[0]" monad (.only do)]]
[control
["[0]" try (.only Try) (.open: "[1]#[0]" functor)]
- ["[0]" exception (.only exception:)]
- [parser
- ["<t>" text]]]
+ ["[0]" exception (.only exception:)]]
[data
["[0]" text (.open: "[1]#[0]" equivalence)
- ["%" format (.only format)]]
+ ["%" format (.only format)]
+ ["<t>" \\parser]]
[collection
["[0]" list (.open: "[1]#[0]" mix functor)]
["[0]" array]
diff --git a/stdlib/source/library/lux/target/jvm/type/alias.lux b/stdlib/source/library/lux/target/jvm/type/alias.lux
index 2d6cb7c49..eb1dc6341 100644
--- a/stdlib/source/library/lux/target/jvm/type/alias.lux
+++ b/stdlib/source/library/lux/target/jvm/type/alias.lux
@@ -7,11 +7,11 @@
["[0]" maybe]
["[0]" try]
["[0]" exception (.only exception:)]
- ["<>" parser (.only)
- ["<[0]>" text (.only Parser)]]]
+ ["<>" parser (.only)]]
[data
["[0]" text (.only)
- ["%" format (.only format)]]
+ ["%" format (.only format)]
+ ["<[1]>" \\parser (.only Parser)]]
[collection
["[0]" dictionary (.only Dictionary)]]]]]
["[0]" // (.only Type)
diff --git a/stdlib/source/library/lux/target/jvm/type/lux.lux b/stdlib/source/library/lux/target/jvm/type/lux.lux
index 96fa31b11..351d9c490 100644
--- a/stdlib/source/library/lux/target/jvm/type/lux.lux
+++ b/stdlib/source/library/lux/target/jvm/type/lux.lux
@@ -6,12 +6,12 @@
[control
["[0]" try]
["[0]" exception (.only exception:)]
- ["<>" parser (.open: "[1]#[0]" monad)
- ["<[0]>" text (.only Parser)]]]
+ ["<>" parser (.open: "[1]#[0]" monad)]]
[data
["[0]" product]
["[0]" text (.open: "[1]#[0]" equivalence)
- ["%" format (.only format)]]
+ ["%" format (.only format)]
+ ["<[1]>" \\parser (.only Parser)]]
[collection
["[0]" array]
["[0]" dictionary (.only Dictionary)]]]
diff --git a/stdlib/source/library/lux/target/jvm/type/parser.lux b/stdlib/source/library/lux/target/jvm/type/parser.lux
index 166b2d984..53bd29aa0 100644
--- a/stdlib/source/library/lux/target/jvm/type/parser.lux
+++ b/stdlib/source/library/lux/target/jvm/type/parser.lux
@@ -4,14 +4,14 @@
[abstract
[monad (.only do)]]
[control
+ ["<>" parser (.open: "[1]#[0]" monad)]
["[0]" try]
- ["[0]" function]
- ["<>" parser (.open: "[1]#[0]" monad)
- ["<[0]>" text (.only Parser)]]]
+ ["[0]" function]]
[data
["[0]" product]
- [text
- ["%" format (.only format)]]
+ ["[0]" text
+ ["%" format (.only format)]
+ ["<[1]>" \\parser (.only Parser)]]
[collection
["[0]" list]]]]]
["[0]" // (.only Type)
diff --git a/stdlib/source/library/lux/time.lux b/stdlib/source/library/lux/time.lux
index 532961dcb..07f3dcb94 100644
--- a/stdlib/source/library/lux/time.lux
+++ b/stdlib/source/library/lux/time.lux
@@ -8,13 +8,13 @@
[codec (.only Codec)]
[monad (.only Monad do)]]
[control
+ ["<>" parser (.only)]
["[0]" pipe]
["[0]" try (.only Try)]
- ["[0]" exception (.only exception:)]
- ["<>" parser (.only)
- ["<[0]>" text (.only Parser)]]]
+ ["[0]" exception (.only exception:)]]
[data
- ["[0]" text (.open: "[1]#[0]" monoid)]]
+ ["[0]" text (.open: "[1]#[0]" monoid)
+ ["<[1]>" \\parser (.only Parser)]]]
[math
[number
["n" nat (.open: "[1]#[0]" decimal)]]]
diff --git a/stdlib/source/library/lux/time/date.lux b/stdlib/source/library/lux/time/date.lux
index 54d7a90ff..3419b07ea 100644
--- a/stdlib/source/library/lux/time/date.lux
+++ b/stdlib/source/library/lux/time/date.lux
@@ -8,13 +8,13 @@
[codec (.only Codec)]
[monad (.only do)]]
[control
+ ["<>" parser (.only)]
["[0]" maybe]
["[0]" try (.only Try)]
- ["[0]" exception (.only exception:)]
- ["<>" parser (.only)
- ["<[0]>" text (.only Parser)]]]
+ ["[0]" exception (.only exception:)]]
[data
- ["[0]" text (.open: "[1]#[0]" monoid)]
+ ["[0]" text (.open: "[1]#[0]" monoid)
+ ["<[1]>" \\parser (.only Parser)]]
[collection
["[0]" list (.open: "[1]#[0]" mix)]
["[0]" dictionary (.only Dictionary)]]]
diff --git a/stdlib/source/library/lux/time/duration.lux b/stdlib/source/library/lux/time/duration.lux
index c9869c08c..e59e4c9f2 100644
--- a/stdlib/source/library/lux/time/duration.lux
+++ b/stdlib/source/library/lux/time/duration.lux
@@ -9,11 +9,11 @@
[monoid (.only Monoid)]
[monad (.only do)]]
[control
- ["[0]" try]
- ["<>" parser (.only)
- ["<[0]>" text (.only Parser)]]]
+ ["<>" parser (.only)]
+ ["[0]" try]]
[data
- ["[0]" text (.open: "[1]#[0]" monoid)]]
+ ["[0]" text (.open: "[1]#[0]" monoid)
+ ["<[1]>" \\parser (.only Parser)]]]
[math
[number
["i" int]
diff --git a/stdlib/source/library/lux/time/instant.lux b/stdlib/source/library/lux/time/instant.lux
index 366bfe020..2f8bbd980 100644
--- a/stdlib/source/library/lux/time/instant.lux
+++ b/stdlib/source/library/lux/time/instant.lux
@@ -10,13 +10,13 @@
[monad (.only Monad do)]]
[control
[io (.only IO io)]
+ ["<>" parser (.only)]
["[0]" maybe]
["[0]" try]
- ["[0]" exception (.only exception:)]
- ["<>" parser (.only)
- ["<[0]>" text (.only Parser)]]]
+ ["[0]" exception (.only exception:)]]
[data
- ["[0]" text (.open: "[1]#[0]" monoid)]]
+ ["[0]" text (.open: "[1]#[0]" monoid)
+ ["<[1]>" \\parser (.only Parser)]]]
[math
[number
["i" int]
diff --git a/stdlib/source/library/lux/time/year.lux b/stdlib/source/library/lux/time/year.lux
index 135607980..a815cbd1c 100644
--- a/stdlib/source/library/lux/time/year.lux
+++ b/stdlib/source/library/lux/time/year.lux
@@ -7,12 +7,12 @@
[equivalence (.only Equivalence)]
[order (.only Order)]]
[control
+ ["<>" parser (.only)]
["[0]" try (.only Try)]
- ["[0]" exception (.only exception:)]
- ["<>" parser (.only)
- ["<[0]>" text (.only Parser)]]]
+ ["[0]" exception (.only exception:)]]
[data
- ["[0]" text (.open: "[1]#[0]" monoid)]]
+ ["[0]" text (.open: "[1]#[0]" monoid)
+ ["<[1]>" \\parser (.only Parser)]]]
[math
[number
["n" nat (.open: "[1]#[0]" decimal)]
diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/phase/extension/analysis/jvm.lux b/stdlib/source/library/lux/tool/compiler/language/lux/phase/extension/analysis/jvm.lux
index c5044dba6..7835a454b 100644
--- a/stdlib/source/library/lux/tool/compiler/language/lux/phase/extension/analysis/jvm.lux
+++ b/stdlib/source/library/lux/tool/compiler/language/lux/phase/extension/analysis/jvm.lux
@@ -12,13 +12,13 @@
["[0]" try (.only Try) (.open: "[1]#[0]" monad)]
["[0]" exception (.only exception:)]
["<>" parser (.only)
- ["<[0]>" code (.only Parser)]
- ["<[0]>" text]]]
+ ["<[0]>" code (.only Parser)]]]
[data
[binary (.only Binary)]
["[0]" product]
["[0]" text (.open: "[1]#[0]" equivalence)
- ["%" format (.only format)]]
+ ["%" format (.only format)]
+ ["<[1]>" \\parser]]
[collection
["[0]" list (.open: "[1]#[0]" mix monad monoid)]
["[0]" array]
diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/phase/extension/directive/jvm.lux b/stdlib/source/library/lux/tool/compiler/language/lux/phase/extension/directive/jvm.lux
index e6c308b21..ff87daec1 100644
--- a/stdlib/source/library/lux/tool/compiler/language/lux/phase/extension/directive/jvm.lux
+++ b/stdlib/source/library/lux/tool/compiler/language/lux/phase/extension/directive/jvm.lux
@@ -10,13 +10,13 @@
["[0]" exception]
["<>" parser (.open: "[1]#[0]" monad)
["<[0]>" code (.only Parser)]
- ["<[0]>" text]
["<[0]>" synthesis]]]
[data
[binary (.only Binary)]
["[0]" product]
- [text
- ["%" format (.only format)]]
+ ["[0]" text
+ ["%" format (.only format)]
+ ["<[1]>" \\parser]]
[collection
["[0]" list (.open: "[1]#[0]" functor mix)]
["[0]" dictionary]
diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/phase/extension/generation/jvm/host.lux b/stdlib/source/library/lux/tool/compiler/language/lux/phase/extension/generation/jvm/host.lux
index 202f4b5e0..3bb78789c 100644
--- a/stdlib/source/library/lux/tool/compiler/language/lux/phase/extension/generation/jvm/host.lux
+++ b/stdlib/source/library/lux/tool/compiler/language/lux/phase/extension/generation/jvm/host.lux
@@ -7,12 +7,12 @@
["[0]" maybe (.open: "[1]#[0]" functor)]
["[0]" exception (.only exception:)]
["<>" parser (.only)
- ["<[0]>" text]
["<[0]>" synthesis (.only Parser)]]]
[data
["[0]" product]
["[0]" text (.open: "[1]#[0]" equivalence)
- ["%" format]]
+ ["%" format]
+ ["<[1]>" \\parser]]
[collection
["[0]" list (.open: "[1]#[0]" monad mix monoid)]
["[0]" dictionary (.only Dictionary)]
diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/syntax.lux b/stdlib/source/library/lux/tool/compiler/language/lux/syntax.lux
index d0bc4dbdc..6bde519da 100644
--- a/stdlib/source/library/lux/tool/compiler/language/lux/syntax.lux
+++ b/stdlib/source/library/lux/tool/compiler/language/lux/syntax.lux
@@ -34,10 +34,10 @@
["[0]" maybe]
["[0]" exception (.only exception:)]
["<>" parser (.only)
- [text (.only Offset)]
["<[0]>" code]]]
[data
["[0]" text (.only)
+ [\\parser (.only Offset)]
["%" format (.only format)]]
[collection
["[0]" list]
diff --git a/stdlib/source/library/lux/tool/compiler/meta/cli.lux b/stdlib/source/library/lux/tool/compiler/meta/cli.lux
index 40ae2eb84..d8ea47bf1 100644
--- a/stdlib/source/library/lux/tool/compiler/meta/cli.lux
+++ b/stdlib/source/library/lux/tool/compiler/meta/cli.lux
@@ -7,12 +7,12 @@
[control
["[0]" pipe]
["<>" parser (.only)
- ["<[0]>" cli (.only Parser)]
- ["<[0]>" text]]]
+ ["<[0]>" cli (.only Parser)]]]
[data
["[0]" product]
["[0]" text (.only)
- ["%" format]]
+ ["%" format]
+ ["<[1]>" \\parser]]
[collection
["[0]" list (.open: "[1]#[0]" functor)]]]
[macro
diff --git a/stdlib/source/library/lux/tool/compiler/meta/cli/compiler.lux b/stdlib/source/library/lux/tool/compiler/meta/cli/compiler.lux
index 84107e91d..317506075 100644
--- a/stdlib/source/library/lux/tool/compiler/meta/cli/compiler.lux
+++ b/stdlib/source/library/lux/tool/compiler/meta/cli/compiler.lux
@@ -5,12 +5,12 @@
[monad (.only do)]
[equivalence (.only Equivalence)]]
[control
- ["<>" parser (.only)
- ["<[0]>" text (.only Parser)]]]
+ ["<>" parser (.only)]]
[data
["[0]" product]
["[0]" text (.only)
- ["%" format]]
+ ["%" format]
+ ["<[1]>" \\parser (.only Parser)]]
[collection
["[0]" list (.open: "[1]#[0]" functor)]]]
[math
diff --git a/stdlib/source/library/lux/control/parser/text.lux b/stdlib/source/parser/lux/data/text.lux
index fbe318d12..e02733f77 100644
--- a/stdlib/source/library/lux/control/parser/text.lux
+++ b/stdlib/source/parser/lux/data/text.lux
@@ -4,6 +4,7 @@
[abstract
[monad (.only Monad do)]]
[control
+ ["//" parser]
["[0]" maybe]
["[0]" try (.only Try)]
["[0]" exception (.only exception:)]]
@@ -18,8 +19,7 @@
["[0]" template]]
[math
[number
- ["n" nat (.open: "[1]#[0]" decimal)]]]]]
- ["[0]" //])
+ ["n" nat (.open: "[1]#[0]" decimal)]]]]])
(type: .public Offset
Nat)
diff --git a/stdlib/source/library/lux/control/parser/analysis.lux b/stdlib/source/parser/lux/tool/compiler/language/lux/analysis.lux
index ebf4f2ec6..159c1c62e 100644
--- a/stdlib/source/library/lux/control/parser/analysis.lux
+++ b/stdlib/source/parser/lux/tool/compiler/language/lux/analysis.lux
@@ -4,6 +4,7 @@
[abstract
[monad (.only do)]]
[control
+ ["//" parser]
["[0]" try (.only Try)]
["[0]" exception (.only exception:)]]
[data
@@ -27,11 +28,8 @@
[compiler
[arity (.only Arity)]
[reference (.only)
- [variable (.only)]]
- [language
- [lux
- ["/" analysis (.only Environment Analysis)]]]]]]]
- ["[0]" //])
+ [variable (.only)]]]]]]
+ ["/" \\library (.only Environment Analysis)])
(def: (remaining_inputs asts)
(-> (List Analysis) Text)
diff --git a/stdlib/source/poly/lux/abstract/equivalence.lux b/stdlib/source/polytypic/lux/abstract/equivalence.lux
index 1e882e32d..1e882e32d 100644
--- a/stdlib/source/poly/lux/abstract/equivalence.lux
+++ b/stdlib/source/polytypic/lux/abstract/equivalence.lux
diff --git a/stdlib/source/poly/lux/abstract/functor.lux b/stdlib/source/polytypic/lux/abstract/functor.lux
index 310c3ff9a..310c3ff9a 100644
--- a/stdlib/source/poly/lux/abstract/functor.lux
+++ b/stdlib/source/polytypic/lux/abstract/functor.lux
diff --git a/stdlib/source/poly/lux/data/format/json.lux b/stdlib/source/polytypic/lux/data/format/json.lux
index 391556a50..391556a50 100644
--- a/stdlib/source/poly/lux/data/format/json.lux
+++ b/stdlib/source/polytypic/lux/data/format/json.lux
diff --git a/stdlib/source/program/aedifex/artifact/snapshot.lux b/stdlib/source/program/aedifex/artifact/snapshot.lux
index 59053e368..7784faa1f 100644
--- a/stdlib/source/program/aedifex/artifact/snapshot.lux
+++ b/stdlib/source/program/aedifex/artifact/snapshot.lux
@@ -6,10 +6,11 @@
[monad (.only do)]]
[control
["<>" parser (.only)
- ["<[0]>" xml (.only Parser)]
- ["<[0]>" text]]]
+ ["<[0]>" xml (.only Parser)]]]
[data
["[0]" sum]
+ ["[0]" text
+ ["<[1]>" \\parser]]
[format
["[0]" xml (.only XML)]]]]]
["[0]" /
diff --git a/stdlib/source/program/aedifex/artifact/snapshot/build.lux b/stdlib/source/program/aedifex/artifact/snapshot/build.lux
index 79c7ba794..641b37105 100644
--- a/stdlib/source/program/aedifex/artifact/snapshot/build.lux
+++ b/stdlib/source/program/aedifex/artifact/snapshot/build.lux
@@ -6,11 +6,11 @@
[monad (.only do)]]
[control
["<>" parser
- ["<[0]>" xml (.only Parser)]
- ["<[0]>" text]]]
+ ["<[0]>" xml (.only Parser)]]]
[data
- [text
- ["%" format]]
+ ["[0]" text
+ ["%" format]
+ ["<[1]>" \\parser]]
[format
["[0]" xml (.only XML)]]]
[math
diff --git a/stdlib/source/program/aedifex/artifact/snapshot/stamp.lux b/stdlib/source/program/aedifex/artifact/snapshot/stamp.lux
index 0831be2b6..3365d685c 100644
--- a/stdlib/source/program/aedifex/artifact/snapshot/stamp.lux
+++ b/stdlib/source/program/aedifex/artifact/snapshot/stamp.lux
@@ -6,9 +6,10 @@
[monad (.only do)]]
[control
["<>" parser (.only)
- ["<[0]>" xml (.only Parser)]
- ["<[0]>" text]]]
+ ["<[0]>" xml (.only Parser)]]]
[data
+ ["[0]" text
+ ["<[1]>" \\parser]]
["[0]" product]
[format
["[0]" xml (.only XML)]]]]]
diff --git a/stdlib/source/program/aedifex/artifact/snapshot/time.lux b/stdlib/source/program/aedifex/artifact/snapshot/time.lux
index 732423ad2..64f0173d3 100644
--- a/stdlib/source/program/aedifex/artifact/snapshot/time.lux
+++ b/stdlib/source/program/aedifex/artifact/snapshot/time.lux
@@ -7,11 +7,11 @@
[control
["[0]" exception (.only exception:)]
["<>" parser (.only)
- ["<[0]>" text]
["<[0]>" xml (.only Parser)]]]
[data
- [text
- ["%" format]]
+ ["[0]" text
+ ["%" format]
+ ["<[1]>" \\parser]]
[format
["[0]" xml (.only XML)]]]
[time
diff --git a/stdlib/source/program/aedifex/artifact/snapshot/version.lux b/stdlib/source/program/aedifex/artifact/snapshot/version.lux
index a8ee8cbef..bf26ae259 100644
--- a/stdlib/source/program/aedifex/artifact/snapshot/version.lux
+++ b/stdlib/source/program/aedifex/artifact/snapshot/version.lux
@@ -6,11 +6,11 @@
[monad (.only do)]]
[control
["<>" parser (.only)
- ["<[0]>" xml (.only Parser)]
- ["<[0]>" text]]]
+ ["<[0]>" xml (.only Parser)]]]
[data
["[0]" product]
- ["[0]" text]
+ ["[0]" text
+ ["<[1]>" \\parser]]
[format
["[0]" xml (.only XML)]]]]]
["[0]" ///
diff --git a/stdlib/source/program/aedifex/artifact/time.lux b/stdlib/source/program/aedifex/artifact/time.lux
index c702b10b4..73f170d55 100644
--- a/stdlib/source/program/aedifex/artifact/time.lux
+++ b/stdlib/source/program/aedifex/artifact/time.lux
@@ -6,13 +6,13 @@
[equivalence (.only Equivalence)]
[monad (.only do)]]
[control
- ["[0]" try (.only Try)]
- ["<>" parser (.only)
- ["<[0]>" text (.only Parser)]]]
+ ["<>" parser (.only)]
+ ["[0]" try (.only Try)]]
[data
["[0]" product]
- [text
- ["%" format (.only Format)]]]
+ ["[0]" text
+ ["%" format (.only Format)]
+ ["<[1]>" \\parser (.only Parser)]]]
[time
["[0]" instant (.only Instant)]]]]
["[0]" /
diff --git a/stdlib/source/program/aedifex/artifact/time/date.lux b/stdlib/source/program/aedifex/artifact/time/date.lux
index 31a2f0f2a..85dee4278 100644
--- a/stdlib/source/program/aedifex/artifact/time/date.lux
+++ b/stdlib/source/program/aedifex/artifact/time/date.lux
@@ -5,13 +5,13 @@
[monad (.only do)]
[equivalence (.only Equivalence)]]
[control
+ ["<>" parser]
["[0]" try (.only Try)]
- ["[0]" exception (.only exception:)]
- ["<>" parser
- ["<[0]>" text (.only Parser)]]]
+ ["[0]" exception (.only exception:)]]
[data
- [text
- ["%" format]]]
+ ["[0]" text
+ ["%" format]
+ ["<[1]>" \\parser (.only Parser)]]]
[math
[number
["n" nat]
diff --git a/stdlib/source/program/aedifex/artifact/time/time.lux b/stdlib/source/program/aedifex/artifact/time/time.lux
index e890d0231..4b4936563 100644
--- a/stdlib/source/program/aedifex/artifact/time/time.lux
+++ b/stdlib/source/program/aedifex/artifact/time/time.lux
@@ -5,11 +5,11 @@
[abstract
[monad (.only do)]]
[control
- ["<>" parser (.only)
- ["<[0]>" text (.only Parser)]]]
+ ["<>" parser (.only)]]
[data
- [text
- ["%" format]]]
+ ["[0]" text
+ ["%" format]
+ ["<[1]>" \\parser (.only Parser)]]]
[math
[number
["n" nat]]]]]
diff --git a/stdlib/source/program/aedifex/artifact/versioning.lux b/stdlib/source/program/aedifex/artifact/versioning.lux
index fb641b897..bc03b35bd 100644
--- a/stdlib/source/program/aedifex/artifact/versioning.lux
+++ b/stdlib/source/program/aedifex/artifact/versioning.lux
@@ -7,12 +7,12 @@
[control
["[0]" exception (.only exception:)]
["<>" parser (.only)
- ["<[0]>" xml (.only Parser)]
- ["<[0]>" text]]]
+ ["<[0]>" xml (.only Parser)]]]
[data
["[0]" product]
["[0]" text (.only)
- ["%" format]]
+ ["%" format]
+ ["<[1]>" \\parser]]
[format
["[0]" xml (.only XML)]]
[collection
diff --git a/stdlib/source/program/aedifex/metadata/artifact.lux b/stdlib/source/program/aedifex/metadata/artifact.lux
index 7f491f3fd..c198845e6 100644
--- a/stdlib/source/program/aedifex/metadata/artifact.lux
+++ b/stdlib/source/program/aedifex/metadata/artifact.lux
@@ -8,14 +8,14 @@
["[0]" pipe]
["[0]" try (.only Try)]
["<>" parser (.only)
- ["<[0]>" xml (.only Parser)]
- ["<[0]>" text]]
+ ["<[0]>" xml (.only Parser)]]
[concurrency
["[0]" async (.only Async)]]]
[data
["[0]" product]
["[0]" text (.only)
["%" format]
+ ["<[1]>" \\parser]
[encoding
["[0]" utf8]]]
[format
diff --git a/stdlib/source/program/aedifex/metadata/snapshot.lux b/stdlib/source/program/aedifex/metadata/snapshot.lux
index 2d68d194b..c7b538232 100644
--- a/stdlib/source/program/aedifex/metadata/snapshot.lux
+++ b/stdlib/source/program/aedifex/metadata/snapshot.lux
@@ -9,14 +9,14 @@
["[0]" try (.only Try)]
["[0]" exception (.only exception:)]
["<>" parser (.only)
- ["<[0]>" xml (.only Parser)]
- ["<[0]>" text]]
+ ["<[0]>" xml (.only Parser)]]
[concurrency
["[0]" async (.only Async)]]]
[data
["[0]" product]
["[0]" text (.only)
["%" format]
+ ["<[1]>" \\parser]
[encoding
["[0]" utf8]]]
[format
diff --git a/stdlib/source/test/aedifex/artifact/snapshot/time.lux b/stdlib/source/test/aedifex/artifact/snapshot/time.lux
index d93d9070c..a26532ce1 100644
--- a/stdlib/source/test/aedifex/artifact/snapshot/time.lux
+++ b/stdlib/source/test/aedifex/artifact/snapshot/time.lux
@@ -7,9 +7,10 @@
[\\specification
["$[0]" equivalence]]]
[control
- ["[0]" try (.open: "[1]#[0]" functor)]
- [parser
- ["<[0]>" text]]]
+ ["[0]" try (.open: "[1]#[0]" functor)]]
+ [data
+ ["[0]" text
+ ["<[1]>" \\parser]]]
[math
["[0]" random (.only Random)]]]]
[\\program
diff --git a/stdlib/source/test/aedifex/artifact/snapshot/version/value.lux b/stdlib/source/test/aedifex/artifact/snapshot/version/value.lux
index 27ef6062c..34599cf81 100644
--- a/stdlib/source/test/aedifex/artifact/snapshot/version/value.lux
+++ b/stdlib/source/test/aedifex/artifact/snapshot/version/value.lux
@@ -7,12 +7,11 @@
[\\specification
["$[0]" equivalence]]]
[control
- ["[0]" try (.open: "[1]#[0]" functor)]
- [parser
- ["<[0]>" text]]]
+ ["[0]" try (.open: "[1]#[0]" functor)]]
[data
["[0]" text (.open: "[1]#[0]" equivalence)
- ["%" format (.only format)]]]
+ ["%" format (.only format)]
+ ["<[1]>" \\parser]]]
[math
["[0]" random (.only Random) (.open: "[1]#[0]" monad)]
[number
diff --git a/stdlib/source/test/aedifex/artifact/time.lux b/stdlib/source/test/aedifex/artifact/time.lux
index 56ffe1ea1..8ee637360 100644
--- a/stdlib/source/test/aedifex/artifact/time.lux
+++ b/stdlib/source/test/aedifex/artifact/time.lux
@@ -7,9 +7,10 @@
[\\specification
["$[0]" equivalence]]]
[control
- ["[0]" try (.open: "[1]#[0]" functor)]
- [parser
- ["<[0]>" text]]]
+ ["[0]" try (.open: "[1]#[0]" functor)]]
+ [data
+ ["[0]" text
+ ["<[1]>" \\parser]]]
[time
["[0]" instant (.open: "[1]#[0]" equivalence)]]
[math
diff --git a/stdlib/source/test/aedifex/artifact/time/date.lux b/stdlib/source/test/aedifex/artifact/time/date.lux
index ca23a1d2a..b53420e0a 100644
--- a/stdlib/source/test/aedifex/artifact/time/date.lux
+++ b/stdlib/source/test/aedifex/artifact/time/date.lux
@@ -8,9 +8,10 @@
["$[0]" equivalence]]]
[control
["[0]" try (.open: "[1]#[0]" functor)]
- ["[0]" exception]
- [parser
- ["<[0]>" text]]]
+ ["[0]" exception]]
+ [data
+ ["[0]" text
+ ["<[1]>" \\parser]]]
[math
["[0]" random (.only Random)]
[number
diff --git a/stdlib/source/test/aedifex/artifact/time/time.lux b/stdlib/source/test/aedifex/artifact/time/time.lux
index a242ae3a4..9a7189e33 100644
--- a/stdlib/source/test/aedifex/artifact/time/time.lux
+++ b/stdlib/source/test/aedifex/artifact/time/time.lux
@@ -6,9 +6,10 @@
[abstract
[monad (.only do)]]
[control
- ["[0]" try (.open: "[1]#[0]" functor)]
- [parser
- ["<[0]>" text]]]
+ ["[0]" try (.open: "[1]#[0]" functor)]]
+ [data
+ ["[0]" text
+ ["<[1]>" \\parser]]]
[math
["[0]" random (.only Random)]
[number
diff --git a/stdlib/source/test/lux/abstract/equivalence.lux b/stdlib/source/test/lux/abstract/equivalence.lux
index f3be4cd4a..7740565ed 100644
--- a/stdlib/source/test/lux/abstract/equivalence.lux
+++ b/stdlib/source/test/lux/abstract/equivalence.lux
@@ -1,22 +1,95 @@
(.using
[library
- [lux (.except)
+ [lux (.except Variant Record)
["_" test (.only Test)]
+ ["@" target]
[abstract
[monad (.only do)]
[\\specification
[functor
["$[0]" contravariant]]]]
+ [control
+ ["[0]" maybe]]
[data
- ["[0]" bit (.open: "[1]#[0]" equivalence)]]
+ ["[0]" bit (.open: "[1]#[0]" equivalence)]
+ ["[0]" text]
+ [collection
+ ["[0]" list]]]
[math
["[0]" random (.only Random)]
[number
["n" nat]
["i" int]]]]]
+ ["[0]" \\polytypic]
+ ["[0]" \\specification]
[\\library
["[0]" / (.only Equivalence)]])
+(type: Variant
+ (.Variant
+ {#Case0 Bit}
+ {#Case1 Int}
+ {#Case2 Frac}))
+
+(type: Recursive
+ (Rec Recursive
+ (.Variant
+ {#Number Frac}
+ {#Addition Frac Recursive})))
+
+(type: Record
+ (.Record
+ [#bit Bit
+ #int Int
+ #frac Frac
+ #text Text
+ #maybe (Maybe Int)
+ #list (List Int)
+ #variant Variant
+ #tuple [Int Frac Text]
+ #recursive Recursive]))
+
+(def: gen_recursive
+ (Random Recursive)
+ (random.rec (function (_ gen_recursive)
+ (random.or random.safe_frac
+ (random.and random.safe_frac
+ gen_recursive)))))
+
+(def: random
+ (Random Record)
+ (do [! random.monad]
+ [size (at ! each (n.% 2) random.nat)
+ .let [gen_int (|> random.int (at ! each (|>> i.abs (i.% +1,000,000))))]]
+ (all random.and
+ random.bit
+ gen_int
+ random.safe_frac
+ (random.unicode size)
+ (random.maybe gen_int)
+ (random.list size gen_int)
+ (all random.or
+ random.bit
+ gen_int
+ random.safe_frac)
+ (all random.and
+ gen_int
+ random.safe_frac
+ (random.unicode size))
+ gen_recursive)))
+
+(for @.old (these)
+ (these (def: equivalence
+ (Equivalence ..Record)
+ (\\polytypic.equivalence ..Record))))
+
+(def: \\polytypic
+ Test
+ (<| (_.covering \\polytypic._)
+ (_.for [\\polytypic.equivalence]
+ (for @.old (_.property "PLACEHOLDER" true)
+ (\\specification.spec ..equivalence ..random)))))
+
(def: .public test
Test
(do random.monad
@@ -57,4 +130,6 @@
(and (at equivalence = (list sample sample) (list sample sample))
(not (at equivalence = (list sample sample) (list sample)))
(not (at equivalence = (list sample sample) (list different different))))))
+
+ ..\\polytypic
))))
diff --git a/stdlib/source/test/lux/abstract/functor.lux b/stdlib/source/test/lux/abstract/functor.lux
index 9249ba171..5bef11061 100644
--- a/stdlib/source/test/lux/abstract/functor.lux
+++ b/stdlib/source/test/lux/abstract/functor.lux
@@ -2,20 +2,47 @@
[library
[lux (.except)
["_" test (.only Test)]
+ ["@" target]
[abstract
[monad (.only do)]]
[control
- ["[0]" maybe]]
+ ["[0]" maybe]
+ ["[0]" state]]
[data
+ ["[0]" identity]
[collection
["[0]" list]]]
[math
["[0]" random]
[number
["n" nat]]]]]
+ ["[0]" \\polytypic]
[\\library
["[0]" / (.only Functor)]])
+(for @.old (these)
+ (these (def: maybe_functor
+ (Functor .Maybe)
+ (\\polytypic.functor .Maybe))
+
+ (def: list_functor
+ (Functor .List)
+ (\\polytypic.functor .List))
+
+ (def: state_functor
+ (All (_ s) (Functor (state.State s)))
+ (\\polytypic.functor state.State))
+
+ (def: identity_functor
+ (Functor identity.Identity)
+ (\\polytypic.functor identity.Identity))))
+
+(def: \\polytypic
+ Test
+ (<| (_.covering \\polytypic._)
+ (_.coverage [\\polytypic.functor]
+ true)))
+
(def: .public test
Test
(do random.monad
@@ -60,4 +87,6 @@
_
false))
+
+ ..\\polytypic
))))
diff --git a/stdlib/source/test/lux/control/parser.lux b/stdlib/source/test/lux/control/parser.lux
index 656c8b988..8995346a9 100644
--- a/stdlib/source/test/lux/control/parser.lux
+++ b/stdlib/source/test/lux/control/parser.lux
@@ -28,14 +28,12 @@
[\\library
["[0]" / (.only Parser)]]
["[0]" /
- ["[1][0]" analysis]
["[1][0]" binary]
["[1][0]" cli]
["[1][0]" code]
["[1][0]" environment]
["[1][0]" json]
["[1][0]" synthesis]
- ["[1][0]" text]
["[1][0]" tree]
["[1][0]" type]
["[1][0]" xml]])
@@ -386,14 +384,12 @@
..combinators_1
..combinators_2
- /analysis.test
/binary.test
/cli.test
/code.test
/environment.test
/json.test
/synthesis.test
- /text.test
/tree.test
/type.test
/xml.test
diff --git a/stdlib/source/test/lux/control/parser/analysis.lux b/stdlib/source/test/lux/control/parser/analysis.lux
deleted file mode 100644
index 41b24f031..000000000
--- a/stdlib/source/test/lux/control/parser/analysis.lux
+++ /dev/null
@@ -1,156 +0,0 @@
-(.using
- [library
- [lux (.except)
- ["_" test (.only Test)]
- [abstract
- [monad (.only do)]]
- [control
- ["[0]" pipe]
- ["[0]" try]
- ["[0]" exception]
- ["<>" parser]]
- [data
- ["[0]" bit (.open: "[1]#[0]" equivalence)]
- ["[0]" text (.open: "[1]#[0]" equivalence)]
- [collection
- ["[0]" list]]]
- [math
- ["[0]" random (.only Random)]
- [number
- ["n" nat]
- ["i" int]
- ["f" frac]
- ["r" rev]]]
- [meta
- ["[0]" symbol (.open: "[1]#[0]" equivalence)]]
- [tool
- [compiler
- [reference (.only Constant)
- [variable (.only)]]
- [language
- [lux
- ["[0]" analysis]]]]]]]
- [\\library
- ["[0]" /]])
-
-(def: !expect
- (template (_ <expectation> <computation>)
- [(case <computation>
- <expectation>
- true
-
- _
- false)]))
-
-(def: constant
- (Random Constant)
- (random.and (random.unicode 10)
- (random.unicode 10)))
-
-(def: .public test
- Test
- (<| (_.covering /._)
- (_.for [/.Parser])
- (do [! random.monad]
- []
- (`` (all _.and
- (do [! random.monad]
- [expected (at ! each (|>> analysis.bit) random.bit)]
- (_.coverage [/.result /.any]
- (|> (list expected)
- (/.result /.any)
- (pipe.case
- {try.#Success actual}
- (at analysis.equivalence = expected actual)
-
- {try.#Failure _}
- false))))
- (~~ (with_template [<query> <check> <random> <analysis> <=>]
- [(do [! random.monad]
- [expected <random>]
- (_.coverage [<query>]
- (|> (list (<analysis> expected))
- (/.result <query>)
- (pipe.case
- {try.#Success actual}
- (<=> expected actual)
-
- {try.#Failure _}
- false))))
- (do [! random.monad]
- [expected <random>]
- (_.coverage [<check>]
- (|> (list (<analysis> expected))
- (/.result (<check> expected))
- (!expect {try.#Success _}))))]
-
- [/.bit /.this_bit random.bit analysis.bit bit#=]
- [/.nat /.this_nat random.nat analysis.nat n.=]
- [/.int /.this_int random.int analysis.int i.=]
- [/.frac /.this_frac random.safe_frac analysis.frac f.=]
- [/.rev /.this_rev random.rev analysis.rev r.=]
- [/.text /.this_text (random.unicode 10) analysis.text text#=]
- [/.local /.this_local random.nat analysis.local n.=]
- [/.foreign /.this_foreign random.nat analysis.foreign n.=]
- [/.constant /.this_constant ..constant analysis.constant symbol#=]
- ))
- (do [! random.monad]
- [expected random.bit]
- (_.coverage [/.tuple]
- (|> (list (analysis.tuple (list (analysis.bit expected))))
- (/.result (/.tuple /.bit))
- (pipe.case
- {try.#Success actual}
- (bit#= expected actual)
-
- {try.#Failure _}
- false))))
- (do [! random.monad]
- [dummy random.bit]
- (_.coverage [/.end?]
- (and (|> (/.result /.end? (list))
- (!expect {try.#Success #1}))
- (|> (/.result (do <>.monad
- [verdict /.end?
- _ /.bit]
- (in verdict))
- (list (analysis.bit dummy)))
- (!expect {try.#Success #0})))))
- (do [! random.monad]
- [dummy random.bit]
- (_.coverage [/.end]
- (and (|> (/.result /.end (list))
- (!expect {try.#Success _}))
- (|> (/.result /.end (list (analysis.bit dummy)))
- (!expect {try.#Failure _})))))
- (do [! random.monad]
- [expected random.bit]
- (_.coverage [/.cannot_parse]
- (and (|> (list (analysis.bit expected))
- (/.result /.nat)
- (pipe.case
- {try.#Success _}
- false
-
- {try.#Failure error}
- (exception.match? /.cannot_parse error)))
- (|> (list)
- (/.result /.bit)
- (pipe.case
- {try.#Success _}
- false
-
- {try.#Failure error}
- (exception.match? /.cannot_parse error))))))
- (do [! random.monad]
- [expected random.bit]
- (_.coverage [/.unconsumed_input]
- (|> (list (analysis.bit expected) (analysis.bit expected))
- (/.result /.bit)
- (pipe.case
- {try.#Success _}
- false
-
- {try.#Failure error}
- (exception.match? /.unconsumed_input error)))))
- )))))
diff --git a/stdlib/source/test/lux/control/parser/text.lux b/stdlib/source/test/lux/control/parser/text.lux
deleted file mode 100644
index 1c8390cfc..000000000
--- a/stdlib/source/test/lux/control/parser/text.lux
+++ /dev/null
@@ -1,444 +0,0 @@
-(.using
- [library
- [lux (.except)
- ["_" test (.only Test)]
- [abstract
- [monad (.only do)]]
- [control
- ["[0]" maybe]
- ["[0]" try (.only Try)]
- ["[0]" exception (.only Exception)]
- ["[0]" function]]
- [data
- ["[0]" text (.open: "[1]#[0]" equivalence)
- ["%" format (.only format)]
- ["[0]" unicode
- ["[1]" set]
- ["[1]/[0]" block]]]
- [collection
- ["[0]" set]
- ["[0]" list (.open: "[1]#[0]" functor)]
- [tree
- ["[0]" finger]]]]
- [math
- ["[0]" random]
- [number (.only hex)
- ["n" nat]]]
- [macro
- ["^" pattern]
- ["[0]" code]]]]
- [\\library
- ["[0]" / (.only)
- ["<>" // (.only)
- ["<c>" code]]]])
-
-(def: !expect
- (template (_ <pattern> <value>)
- [(case <value>
- <pattern>
- true
-
- _
- false)]))
-
-(def: (should_fail' sample parser exception)
- (All (_ a e) (-> Text (/.Parser a) (Exception e) Bit))
- (case (/.result parser sample)
- {try.#Failure error}
- (exception.match? exception error)
-
- _
- false))
-
-(def: (should_fail sample parser)
- (All (_ a) (-> Text (/.Parser a) Bit))
- (case (/.result parser sample)
- {try.#Failure _}
- true
-
- _
- false))
-
-(def: (should_pass expected parser)
- (-> Text (/.Parser Text) Bit)
- (|> expected
- (/.result parser)
- (at try.functor each (text#= expected))
- (try.else false)))
-
-(def: (should_pass! expected parser)
- (-> Text (/.Parser /.Slice) Bit)
- (..should_pass expected (/.slice parser)))
-
-(def: character_classes
- Test
- (all _.and
- (do [! random.monad]
- [offset (at ! each (n.% 50) random.nat)
- range (at ! each (|>> (n.% 50) (n.+ 10)) random.nat)
- .let [limit (n.+ offset range)]
- expected (at ! each (|>> (n.% range) (n.+ offset) text.of_char) random.nat)
- out_of_range (case offset
- 0 (at ! each (|>> (n.% 10) ++ (n.+ limit) text.of_char) random.nat)
- _ (at ! each (|>> (n.% offset) text.of_char) random.nat))]
- (_.coverage [/.range]
- (and (..should_pass expected (/.range offset limit))
- (..should_fail out_of_range (/.range offset limit)))))
- (do [! random.monad]
- [expected (random.char unicode.upper_case)
- invalid (random.only (|>> (unicode/block.within? unicode/block.upper_case) not)
- (random.char unicode.character))]
- (_.coverage [/.upper]
- (and (..should_pass (text.of_char expected) /.upper)
- (..should_fail (text.of_char invalid) /.upper))))
- (do [! random.monad]
- [expected (random.char unicode.lower_case)
- invalid (random.only (|>> (unicode/block.within? unicode/block.lower_case) not)
- (random.char unicode.character))]
- (_.coverage [/.lower]
- (and (..should_pass (text.of_char expected) /.lower)
- (..should_fail (text.of_char invalid) /.lower))))
- (do [! random.monad]
- [expected (at ! each (n.% 10) random.nat)
- invalid (random.char (unicode.set [unicode/block.number_forms (list)]))]
- (_.coverage [/.decimal]
- (and (..should_pass (at n.decimal encoded expected) /.decimal)
- (..should_fail (text.of_char invalid) /.decimal))))
- (do [! random.monad]
- [expected (at ! each (n.% 8) random.nat)
- invalid (random.char (unicode.set [unicode/block.number_forms (list)]))]
- (_.coverage [/.octal]
- (and (..should_pass (at n.octal encoded expected) /.octal)
- (..should_fail (text.of_char invalid) /.octal))))
- (do [! random.monad]
- [expected (at ! each (n.% 16) random.nat)
- invalid (random.char (unicode.set [unicode/block.number_forms (list)]))]
- (_.coverage [/.hexadecimal]
- (and (..should_pass (at n.hex encoded expected) /.hexadecimal)
- (..should_fail (text.of_char invalid) /.hexadecimal))))
- (do [! random.monad]
- [expected (random.char unicode.alphabetic)
- invalid (random.only (function (_ char)
- (not (or (unicode/block.within? unicode/block.upper_case char)
- (unicode/block.within? unicode/block.lower_case char))))
- (random.char unicode.character))]
- (_.coverage [/.alpha]
- (and (..should_pass (text.of_char expected) /.alpha)
- (..should_fail (text.of_char invalid) /.alpha))))
- (do [! random.monad]
- [expected (random.char unicode.alpha_numeric)
- invalid (random.only (function (_ char)
- (not (or (unicode/block.within? unicode/block.upper_case char)
- (unicode/block.within? unicode/block.lower_case char)
- (unicode/block.within? unicode/block.numeric char))))
- (random.char unicode.character))]
- (_.coverage [/.alpha_num]
- (and (..should_pass (text.of_char expected) /.alpha_num)
- (..should_fail (text.of_char invalid) /.alpha_num))))
- (do [! random.monad]
- [expected (all random.either
- (in text.tab)
- (in text.vertical_tab)
- (in text.space)
- (in text.new_line)
- (in text.carriage_return)
- (in text.form_feed))
- invalid (|> (random.unicode 1) (random.only (function (_ char)
- (not (or (text#= text.tab char)
- (text#= text.vertical_tab char)
- (text#= text.space char)
- (text#= text.new_line char)
- (text#= text.carriage_return char)
- (text#= text.form_feed char))))))]
- (_.coverage [/.space]
- (and (..should_pass expected /.space)
- (..should_fail invalid /.space))))
- (do [! random.monad]
- [.let [num_options 3]
- options (|> (random.char unicode.character)
- (random.set n.hash num_options)
- (at ! each (|>> set.list
- (list#each text.of_char)
- text.together)))
- expected (at ! each (function (_ value)
- (|> options
- (text.char (n.% num_options value))
- maybe.trusted))
- random.nat)
- invalid (random.only (function (_ char)
- (not (text.contains? (text.of_char char) options)))
- (random.char unicode.character))]
- (_.coverage [/.one_of /.one_of! /.character_should_be]
- (and (..should_pass (text.of_char expected) (/.one_of options))
- (..should_fail (text.of_char invalid) (/.one_of options))
- (..should_fail' (text.of_char invalid) (/.one_of options)
- /.character_should_be)
-
- (..should_pass! (text.of_char expected) (/.one_of! options))
- (..should_fail (text.of_char invalid) (/.one_of! options))
- (..should_fail' (text.of_char invalid) (/.one_of! options)
- /.character_should_be)
- )))
- (do [! random.monad]
- [.let [num_options 3]
- options (|> (random.char unicode.character)
- (random.set n.hash num_options)
- (at ! each (|>> set.list
- (list#each text.of_char)
- text.together)))
- invalid (at ! each (function (_ value)
- (|> options
- (text.char (n.% num_options value))
- maybe.trusted))
- random.nat)
- expected (random.only (function (_ char)
- (not (text.contains? (text.of_char char) options)))
- (random.char unicode.character))]
- (_.coverage [/.none_of /.none_of! /.character_should_not_be]
- (and (..should_pass (text.of_char expected) (/.none_of options))
- (..should_fail (text.of_char invalid) (/.none_of options))
- (..should_fail' (text.of_char invalid) (/.none_of options)
- /.character_should_not_be)
-
- (..should_pass! (text.of_char expected) (/.none_of! options))
- (..should_fail (text.of_char invalid) (/.none_of! options))
- (..should_fail' (text.of_char invalid) (/.none_of! options)
- /.character_should_not_be)
- )))
- ))
-
-(def: runs
- Test
- (let [octal! (/.one_of! "01234567")]
- (all _.and
- (do [! random.monad]
- [left (at ! each (|>> (n.% 8) (at n.octal encoded)) random.nat)
- right (at ! each (|>> (n.% 8) (at n.octal encoded)) random.nat)
- .let [expected (format left right)]
- invalid (|> random.nat
- (at ! each (n.% 16))
- (random.only (n.>= 8))
- (at ! each (at n.hex encoded)))]
- (_.coverage [/.many /.many!]
- (and (..should_pass expected (/.many /.octal))
- (..should_fail invalid (/.many /.octal))
-
- (..should_pass! expected (/.many! octal!)))))
- (do [! random.monad]
- [left (at ! each (|>> (n.% 8) (at n.octal encoded)) random.nat)
- right (at ! each (|>> (n.% 8) (at n.octal encoded)) random.nat)
- .let [expected (format left right)]
- invalid (|> random.nat
- (at ! each (n.% 16))
- (random.only (n.>= 8))
- (at ! each (at n.hex encoded)))]
- (_.coverage [/.some /.some!]
- (and (..should_pass expected (/.some /.octal))
- (..should_pass "" (/.some /.octal))
- (..should_fail invalid (/.some /.octal))
-
- (..should_pass! expected (/.some! octal!))
- (..should_pass! "" (/.some! octal!)))))
- (do [! random.monad]
- [.let [octal (at ! each (|>> (n.% 8) (at n.octal encoded)) random.nat)]
- first octal
- second octal
- third octal]
- (_.coverage [/.exactly /.exactly!]
- (and (..should_pass (format first second) (/.exactly 2 /.octal))
- (..should_fail (format first second third) (/.exactly 2 /.octal))
- (..should_fail (format first) (/.exactly 2 /.octal))
-
- (..should_pass! (format first second) (/.exactly! 2 octal!))
- (..should_fail (format first second third) (/.exactly! 2 octal!))
- (..should_fail (format first) (/.exactly! 2 octal!)))))
- (do [! random.monad]
- [.let [octal (at ! each (|>> (n.% 8) (at n.octal encoded)) random.nat)]
- first octal
- second octal
- third octal]
- (_.coverage [/.at_most /.at_most!]
- (and (..should_pass (format first second) (/.at_most 2 /.octal))
- (..should_pass (format first) (/.at_most 2 /.octal))
- (..should_fail (format first second third) (/.at_most 2 /.octal))
-
- (..should_pass! (format first second) (/.at_most! 2 octal!))
- (..should_pass! (format first) (/.at_most! 2 octal!))
- (..should_fail (format first second third) (/.at_most! 2 octal!)))))
- (do [! random.monad]
- [.let [octal (at ! each (|>> (n.% 8) (at n.octal encoded)) random.nat)]
- first octal
- second octal
- third octal]
- (_.coverage [/.at_least /.at_least!]
- (and (..should_pass (format first second) (/.at_least 2 /.octal))
- (..should_pass (format first second third) (/.at_least 2 /.octal))
- (..should_fail (format first) (/.at_least 2 /.octal))
-
- (..should_pass! (format first second) (/.at_least! 2 octal!))
- (..should_pass! (format first second third) (/.at_least! 2 octal!))
- (..should_fail (format first) (/.at_least! 2 octal!)))))
- (do [! random.monad]
- [.let [octal (at ! each (|>> (n.% 8) (at n.octal encoded)) random.nat)]
- first octal
- second octal
- third octal]
- (_.coverage [/.between /.between!]
- (and (..should_pass (format first second) (/.between 2 1 /.octal))
- (..should_pass (format first second third) (/.between 2 1 /.octal))
- (..should_fail (format first) (/.between 2 1 /.octal))
-
- (..should_pass! (format first second) (/.between! 2 1 octal!))
- (..should_pass! (format first second third) (/.between! 2 1 octal!))
- (..should_fail (format first) (/.between! 2 1 octal!)))))
- )))
-
-(def: .public test
- Test
- (<| (_.covering /._)
- (_.for [/.Parser])
- (all _.and
- (do [! random.monad]
- [sample (random.unicode 1)]
- (_.coverage [/.result /.end]
- (and (|> (/.result /.end
- "")
- (!expect {try.#Success _}))
- (|> (/.result /.end
- sample)
- (!expect {try.#Failure _})))))
- (do [! random.monad]
- [.let [size 10]
- expected (random.unicode size)
- dummy (|> (random.unicode size)
- (random.only (|>> (text#= expected) not)))]
- (_.coverage [/.this /.cannot_match]
- (and (|> (/.result (/.this expected)
- expected)
- (!expect {try.#Success []}))
- (|> (/.result (/.this expected)
- dummy)
- (!expect (^.multi {try.#Failure error}
- (exception.match? /.cannot_match error)))))))
- (_.coverage [/.Slice /.slice /.cannot_slice]
- (|> ""
- (/.result (/.slice /.any!))
- (!expect (^.multi {try.#Failure error}
- (exception.match? /.cannot_slice error)))))
- (do [! random.monad]
- [expected (random.unicode 1)]
- (_.coverage [/.any /.any!]
- (and (..should_pass expected /.any)
- (..should_fail "" /.any)
-
- (..should_pass! expected /.any!)
- (..should_fail "" /.any!))))
- (do [! random.monad]
- [expected (random.unicode 1)]
- (_.coverage [/.next /.cannot_parse]
- (and (..should_pass expected (<>.before /.any /.next))
- (|> ""
- (/.result (<>.before /.any /.next))
- (!expect (^.multi {try.#Failure error}
- (exception.match? /.cannot_parse error)))))))
- (do [! random.monad]
- [dummy (random.unicode 1)]
- (_.coverage [/.unconsumed_input]
- (|> (format dummy dummy)
- (/.result /.any)
- (!expect (^.multi {try.#Failure error}
- (exception.match? /.unconsumed_input error))))))
- (do [! random.monad]
- [sample (random.unicode 1)]
- (_.coverage [/.Offset /.offset]
- (|> sample
- (/.result (do <>.monad
- [pre /.offset
- _ /.any
- post /.offset]
- (in [pre post])))
- (!expect {try.#Success [0 1]}))))
- (do [! random.monad]
- [left (random.unicode 1)
- right (random.unicode 1)
- .let [input (format left right)]]
- (_.coverage [/.remaining]
- (|> input
- (/.result (do <>.monad
- [pre /.remaining
- _ /.any
- post /.remaining
- _ /.any]
- (in (and (text#= input pre)
- (text#= right post)))))
- (!expect {try.#Success #1}))))
- (do [! random.monad]
- [left (random.unicode 1)
- right (random.unicode 1)
- expected (random.only (|>> (text#= right) not)
- (random.unicode 1))]
- (_.coverage [/.enclosed]
- (|> (format left expected right)
- (/.result (/.enclosed [left right] (/.this expected)))
- (!expect {try.#Success _}))))
- (do [! random.monad]
- [input (random.unicode 1)
- output (random.unicode 1)]
- (_.coverage [/.local]
- (|> output
- (/.result (do <>.monad
- [_ (/.local input (/.this input))]
- (/.this output)))
- (!expect {try.#Success _}))))
- (do [! random.monad]
- [expected (at ! each (|>> (n.% 8) (at n.octal encoded)) random.nat)]
- (_.coverage [/.then]
- (|> (list (code.text expected))
- (<c>.result (/.then /.octal <c>.text))
- (!expect (^.multi {try.#Success actual}
- (text#= expected actual))))))
- (do [! random.monad]
- [invalid (random.upper_case 1)
- expected (random.only (|>> (unicode/block.within? unicode/block.upper_case)
- not)
- (random.char unicode.character))
- .let [upper! (/.one_of! "ABCDEFGHIJKLMNOPQRSTUVWXYZ")]]
- (_.coverage [/.not /.not! /.expected_to_fail]
- (and (..should_pass (text.of_char expected) (/.not /.upper))
- (|> invalid
- (/.result (/.not /.upper))
- (!expect (^.multi {try.#Failure error}
- (exception.match? /.expected_to_fail error))))
-
- (..should_pass! (text.of_char expected) (/.not! upper!))
- (|> invalid
- (/.result (/.not! upper!))
- (!expect (^.multi {try.#Failure error}
- (exception.match? /.expected_to_fail error)))))))
- (do [! random.monad]
- [upper (random.upper_case 1)
- lower (random.lower_case 1)
- invalid (random.only (function (_ char)
- (not (or (unicode/block.within? unicode/block.upper_case char)
- (unicode/block.within? unicode/block.lower_case char))))
- (random.char unicode.character))
- .let [upper! (/.one_of! "ABCDEFGHIJKLMNOPQRSTUVWXYZ")
- lower! (/.one_of! "abcdefghijklmnopqrstuvwxyz")]]
- (_.coverage [/.and /.and!]
- (and (..should_pass (format upper lower) (/.and /.upper /.lower))
- (..should_fail (format (text.of_char invalid) lower) (/.and /.upper /.lower))
- (..should_fail (format upper (text.of_char invalid)) (/.and /.upper /.lower))
-
- (..should_pass! (format upper lower) (/.and! upper! lower!))
- (..should_fail (format (text.of_char invalid) lower) (/.and! upper! lower!))
- (..should_fail (format upper (text.of_char invalid)) (/.and! upper! lower!)))))
- (do [! random.monad]
- [expected (random.unicode 1)
- invalid (random.unicode 1)]
- (_.coverage [/.satisfies /.character_does_not_satisfy_predicate]
- (and (..should_pass expected (/.satisfies (function.constant true)))
- (..should_fail' invalid (/.satisfies (function.constant false))
- /.character_does_not_satisfy_predicate))))
- ..character_classes
- ..runs
- )))
diff --git a/stdlib/source/test/lux/data/format/json.lux b/stdlib/source/test/lux/data/format/json.lux
index 394c9f1c1..d96c0a92c 100644
--- a/stdlib/source/test/lux/data/format/json.lux
+++ b/stdlib/source/test/lux/data/format/json.lux
@@ -1,23 +1,31 @@
(.using
[library
- [lux (.except)
+ [lux (.except Variant Record)
["_" test (.only Test)]
+ ["@" target]
+ ["[0]" debug]
["[0]" meta]
[abstract
+ [codec (.except)]
[monad (.only do)]
+ ["[0]" equivalence (.only Equivalence)
+ ["[0]/[1]" \\polytypic]]
[\\specification
["$[0]" equivalence]
["$[0]" codec]]]
[control
- ["[0]" try (.open: "[1]#[0]" functor)]]
+ ["[0]" try (.open: "[1]#[0]" functor)]
+ ["p" parser
+ ... TODO: Get rid of this import ASAP
+ [json (.only)]]]
[data
["[0]" product]
["[0]" bit]
["[0]" text (.only)
["%" format (.only format)]]
[collection
- ["[0]" sequence]
- ["[0]" dictionary]
+ ["[0]" sequence (.only sequence)]
+ ["[0]" dictionary (.only Dictionary)]
["[0]" set]
["[0]" list (.open: "[1]#[0]" functor)]]]
[math
@@ -27,10 +35,96 @@
["[0]" frac]]]
["[0]" macro (.only)
["[0]" syntax (.only syntax)]
- ["[0]" code]]]]
+ ["[0]" code]]
+ [time
+ ["[0]" date]
+ ["[0]" instant
+ ["[0]/[1]" \\test]]
+ ["[0]" duration
+ ["[0]/[1]" \\test]]
+ ]
+ [type
+ ["[0]" unit]]]]
+ ["[0]" \\polytypic]
[\\library
["[0]" / (.only JSON) (.open: "[1]#[0]" equivalence)]])
+(type: Variant
+ (.Variant
+ {#Bit Bit}
+ {#Text Text}
+ {#Frac Frac}))
+
+(type: Recursive
+ (Rec Recursive
+ (.Variant
+ {#Number Frac}
+ {#Addition Frac Recursive})))
+
+(type: Record
+ (.Record
+ [#bit Bit
+ #frac Frac
+ #text Text
+ #maybe (Maybe Frac)
+ #list (List Frac)
+ #dictionary (Dictionary Text Frac)
+ #variant Variant
+ #tuple [Bit Text Frac]
+ #recursive Recursive
+ ... #instant instant.Instant
+ ... #duration duration.Duration
+ #date date.Date
+ #grams (unit.Qty unit.Gram)]))
+
+(def: gen_recursive
+ (Random Recursive)
+ (random.rec
+ (function (_ gen_recursive)
+ (random.or random.safe_frac
+ (random.and random.safe_frac
+ gen_recursive)))))
+
+(def: qty
+ (All (_ unit) (Random (unit.Qty unit)))
+ (at random.monad each (debug.private unit.in') random.int))
+
+(def: gen_record
+ (Random Record)
+ (do [! random.monad]
+ [size (at ! each (n.% 2) random.nat)]
+ (all random.and
+ random.bit
+ random.safe_frac
+ (random.unicode size)
+ (random.maybe random.safe_frac)
+ (random.list size random.safe_frac)
+ (random.dictionary text.hash size (random.unicode size) random.safe_frac)
+ (all random.or random.bit (random.unicode size) random.safe_frac)
+ (all random.and random.bit (random.unicode size) random.safe_frac)
+ ..gen_recursive
+ ... \\test/instant.instant
+ ... \\test/duration.duration
+ random.date
+ ..qty
+ )))
+
+(for @.old (these)
+ (these (def: equivalence
+ (Equivalence Record)
+ (\\polytypic/equivalence.equivalence Record))
+
+ (def: codec
+ (Codec JSON Record)
+ (\\polytypic.codec Record))))
+
+(def: \\polytypic
+ Test
+ (<| (_.covering \\polytypic._)
+ (_.for [\\polytypic.codec]
+ (for @.old (_.property "PLACEHOLDER" true)
+ ($codec.spec ..equivalence ..codec ..gen_record)))))
+
(def: .public random
(Random /.JSON)
(random.rec
@@ -199,4 +293,6 @@
(/#= {/.#Array <array_sequence>} value4)
(/#= {/.#Number <number>} value6))))))
)))
+
+ ..\\polytypic
))))
diff --git a/stdlib/source/test/lux/data/text.lux b/stdlib/source/test/lux/data/text.lux
index ebda04668..e283b6081 100644
--- a/stdlib/source/test/lux/data/text.lux
+++ b/stdlib/source/test/lux/data/text.lux
@@ -11,14 +11,29 @@
["$[0]" monoid]]]
[control
["[0]" pipe]
- ["[0]" maybe]]
+ ["[0]" maybe]
+ ["[0]" try (.only Try)]
+ ["[0]" exception (.only Exception)]
+ ["[0]" function]
+ ["<>" parser (.only)
+ ["<c>" code]]]
[data
[collection
- ["[0]" list]
- ["[0]" set]]]
+ ["[0]" set]
+ ["[0]" list (.open: "[1]#[0]" functor)]
+ [tree
+ ["[0]" finger]]]
+ [text
+ ["%" format (.only format)]
+ ["[0]" unicode
+ ["[1]" set]
+ ["[1]/[0]" block]]]]
+ [macro
+ ["^" pattern]
+ ["[0]" code]]
[math
["[0]" random]
- [number
+ [number (.only hex)
["n" nat]]]]]
["[0]" /
["[1][0]" buffer]
@@ -29,7 +44,420 @@
["[1][0]" unicode
["[1]" set]]]
[\\library
- ["[0]" /]])
+ ["[0]" / (.open: "[1]#[0]" equivalence)]]
+ ["[0]" \\parser])
+
+(def: !expect
+ (template (_ <pattern> <value>)
+ [(case <value>
+ <pattern>
+ true
+
+ _
+ false)]))
+
+(def: (should_fail' sample parser exception)
+ (All (_ a e) (-> Text (\\parser.Parser a) (Exception e) Bit))
+ (case (\\parser.result parser sample)
+ {try.#Failure error}
+ (exception.match? exception error)
+
+ _
+ false))
+
+(def: (should_fail sample parser)
+ (All (_ a) (-> Text (\\parser.Parser a) Bit))
+ (case (\\parser.result parser sample)
+ {try.#Failure _}
+ true
+
+ _
+ false))
+
+(def: (should_pass expected parser)
+ (-> Text (\\parser.Parser Text) Bit)
+ (|> expected
+ (\\parser.result parser)
+ (at try.functor each (/#= expected))
+ (try.else false)))
+
+(def: (should_pass! expected parser)
+ (-> Text (\\parser.Parser \\parser.Slice) Bit)
+ (..should_pass expected (\\parser.slice parser)))
+
+(def: \\parser#character_classes
+ Test
+ (all _.and
+ (do [! random.monad]
+ [offset (at ! each (n.% 50) random.nat)
+ range (at ! each (|>> (n.% 50) (n.+ 10)) random.nat)
+ .let [limit (n.+ offset range)]
+ expected (at ! each (|>> (n.% range) (n.+ offset) /.of_char) random.nat)
+ out_of_range (case offset
+ 0 (at ! each (|>> (n.% 10) ++ (n.+ limit) /.of_char) random.nat)
+ _ (at ! each (|>> (n.% offset) /.of_char) random.nat))]
+ (_.coverage [\\parser.range]
+ (and (..should_pass expected (\\parser.range offset limit))
+ (..should_fail out_of_range (\\parser.range offset limit)))))
+ (do [! random.monad]
+ [expected (random.char unicode.upper_case)
+ invalid (random.only (|>> (unicode/block.within? unicode/block.upper_case) not)
+ (random.char unicode.character))]
+ (_.coverage [\\parser.upper]
+ (and (..should_pass (/.of_char expected) \\parser.upper)
+ (..should_fail (/.of_char invalid) \\parser.upper))))
+ (do [! random.monad]
+ [expected (random.char unicode.lower_case)
+ invalid (random.only (|>> (unicode/block.within? unicode/block.lower_case) not)
+ (random.char unicode.character))]
+ (_.coverage [\\parser.lower]
+ (and (..should_pass (/.of_char expected) \\parser.lower)
+ (..should_fail (/.of_char invalid) \\parser.lower))))
+ (do [! random.monad]
+ [expected (at ! each (n.% 10) random.nat)
+ invalid (random.char (unicode.set [unicode/block.number_forms (list)]))]
+ (_.coverage [\\parser.decimal]
+ (and (..should_pass (at n.decimal encoded expected) \\parser.decimal)
+ (..should_fail (/.of_char invalid) \\parser.decimal))))
+ (do [! random.monad]
+ [expected (at ! each (n.% 8) random.nat)
+ invalid (random.char (unicode.set [unicode/block.number_forms (list)]))]
+ (_.coverage [\\parser.octal]
+ (and (..should_pass (at n.octal encoded expected) \\parser.octal)
+ (..should_fail (/.of_char invalid) \\parser.octal))))
+ (do [! random.monad]
+ [expected (at ! each (n.% 16) random.nat)
+ invalid (random.char (unicode.set [unicode/block.number_forms (list)]))]
+ (_.coverage [\\parser.hexadecimal]
+ (and (..should_pass (at n.hex encoded expected) \\parser.hexadecimal)
+ (..should_fail (/.of_char invalid) \\parser.hexadecimal))))
+ (do [! random.monad]
+ [expected (random.char unicode.alphabetic)
+ invalid (random.only (function (_ char)
+ (not (or (unicode/block.within? unicode/block.upper_case char)
+ (unicode/block.within? unicode/block.lower_case char))))
+ (random.char unicode.character))]
+ (_.coverage [\\parser.alpha]
+ (and (..should_pass (/.of_char expected) \\parser.alpha)
+ (..should_fail (/.of_char invalid) \\parser.alpha))))
+ (do [! random.monad]
+ [expected (random.char unicode.alpha_numeric)
+ invalid (random.only (function (_ char)
+ (not (or (unicode/block.within? unicode/block.upper_case char)
+ (unicode/block.within? unicode/block.lower_case char)
+ (unicode/block.within? unicode/block.numeric char))))
+ (random.char unicode.character))]
+ (_.coverage [\\parser.alpha_num]
+ (and (..should_pass (/.of_char expected) \\parser.alpha_num)
+ (..should_fail (/.of_char invalid) \\parser.alpha_num))))
+ (do [! random.monad]
+ [expected (all random.either
+ (in /.tab)
+ (in /.vertical_tab)
+ (in /.space)
+ (in /.new_line)
+ (in /.carriage_return)
+ (in /.form_feed))
+ invalid (|> (random.unicode 1) (random.only (function (_ char)
+ (not (or (/#= /.tab char)
+ (/#= /.vertical_tab char)
+ (/#= /.space char)
+ (/#= /.new_line char)
+ (/#= /.carriage_return char)
+ (/#= /.form_feed char))))))]
+ (_.coverage [\\parser.space]
+ (and (..should_pass expected \\parser.space)
+ (..should_fail invalid \\parser.space))))
+ (do [! random.monad]
+ [.let [num_options 3]
+ options (|> (random.char unicode.character)
+ (random.set n.hash num_options)
+ (at ! each (|>> set.list
+ (list#each /.of_char)
+ /.together)))
+ expected (at ! each (function (_ value)
+ (|> options
+ (/.char (n.% num_options value))
+ maybe.trusted))
+ random.nat)
+ invalid (random.only (function (_ char)
+ (not (/.contains? (/.of_char char) options)))
+ (random.char unicode.character))]
+ (_.coverage [\\parser.one_of \\parser.one_of! \\parser.character_should_be]
+ (and (..should_pass (/.of_char expected) (\\parser.one_of options))
+ (..should_fail (/.of_char invalid) (\\parser.one_of options))
+ (..should_fail' (/.of_char invalid) (\\parser.one_of options)
+ \\parser.character_should_be)
+
+ (..should_pass! (/.of_char expected) (\\parser.one_of! options))
+ (..should_fail (/.of_char invalid) (\\parser.one_of! options))
+ (..should_fail' (/.of_char invalid) (\\parser.one_of! options)
+ \\parser.character_should_be)
+ )))
+ (do [! random.monad]
+ [.let [num_options 3]
+ options (|> (random.char unicode.character)
+ (random.set n.hash num_options)
+ (at ! each (|>> set.list
+ (list#each /.of_char)
+ /.together)))
+ invalid (at ! each (function (_ value)
+ (|> options
+ (/.char (n.% num_options value))
+ maybe.trusted))
+ random.nat)
+ expected (random.only (function (_ char)
+ (not (/.contains? (/.of_char char) options)))
+ (random.char unicode.character))]
+ (_.coverage [\\parser.none_of \\parser.none_of! \\parser.character_should_not_be]
+ (and (..should_pass (/.of_char expected) (\\parser.none_of options))
+ (..should_fail (/.of_char invalid) (\\parser.none_of options))
+ (..should_fail' (/.of_char invalid) (\\parser.none_of options)
+ \\parser.character_should_not_be)
+
+ (..should_pass! (/.of_char expected) (\\parser.none_of! options))
+ (..should_fail (/.of_char invalid) (\\parser.none_of! options))
+ (..should_fail' (/.of_char invalid) (\\parser.none_of! options)
+ \\parser.character_should_not_be)
+ )))
+ ))
+
+(def: \\parser#runs
+ Test
+ (let [octal! (\\parser.one_of! "01234567")]
+ (all _.and
+ (do [! random.monad]
+ [left (at ! each (|>> (n.% 8) (at n.octal encoded)) random.nat)
+ right (at ! each (|>> (n.% 8) (at n.octal encoded)) random.nat)
+ .let [expected (format left right)]
+ invalid (|> random.nat
+ (at ! each (n.% 16))
+ (random.only (n.>= 8))
+ (at ! each (at n.hex encoded)))]
+ (_.coverage [\\parser.many \\parser.many!]
+ (and (..should_pass expected (\\parser.many \\parser.octal))
+ (..should_fail invalid (\\parser.many \\parser.octal))
+
+ (..should_pass! expected (\\parser.many! octal!)))))
+ (do [! random.monad]
+ [left (at ! each (|>> (n.% 8) (at n.octal encoded)) random.nat)
+ right (at ! each (|>> (n.% 8) (at n.octal encoded)) random.nat)
+ .let [expected (format left right)]
+ invalid (|> random.nat
+ (at ! each (n.% 16))
+ (random.only (n.>= 8))
+ (at ! each (at n.hex encoded)))]
+ (_.coverage [\\parser.some \\parser.some!]
+ (and (..should_pass expected (\\parser.some \\parser.octal))
+ (..should_pass "" (\\parser.some \\parser.octal))
+ (..should_fail invalid (\\parser.some \\parser.octal))
+
+ (..should_pass! expected (\\parser.some! octal!))
+ (..should_pass! "" (\\parser.some! octal!)))))
+ (do [! random.monad]
+ [.let [octal (at ! each (|>> (n.% 8) (at n.octal encoded)) random.nat)]
+ first octal
+ second octal
+ third octal]
+ (_.coverage [\\parser.exactly \\parser.exactly!]
+ (and (..should_pass (format first second) (\\parser.exactly 2 \\parser.octal))
+ (..should_fail (format first second third) (\\parser.exactly 2 \\parser.octal))
+ (..should_fail (format first) (\\parser.exactly 2 \\parser.octal))
+
+ (..should_pass! (format first second) (\\parser.exactly! 2 octal!))
+ (..should_fail (format first second third) (\\parser.exactly! 2 octal!))
+ (..should_fail (format first) (\\parser.exactly! 2 octal!)))))
+ (do [! random.monad]
+ [.let [octal (at ! each (|>> (n.% 8) (at n.octal encoded)) random.nat)]
+ first octal
+ second octal
+ third octal]
+ (_.coverage [\\parser.at_most \\parser.at_most!]
+ (and (..should_pass (format first second) (\\parser.at_most 2 \\parser.octal))
+ (..should_pass (format first) (\\parser.at_most 2 \\parser.octal))
+ (..should_fail (format first second third) (\\parser.at_most 2 \\parser.octal))
+
+ (..should_pass! (format first second) (\\parser.at_most! 2 octal!))
+ (..should_pass! (format first) (\\parser.at_most! 2 octal!))
+ (..should_fail (format first second third) (\\parser.at_most! 2 octal!)))))
+ (do [! random.monad]
+ [.let [octal (at ! each (|>> (n.% 8) (at n.octal encoded)) random.nat)]
+ first octal
+ second octal
+ third octal]
+ (_.coverage [\\parser.at_least \\parser.at_least!]
+ (and (..should_pass (format first second) (\\parser.at_least 2 \\parser.octal))
+ (..should_pass (format first second third) (\\parser.at_least 2 \\parser.octal))
+ (..should_fail (format first) (\\parser.at_least 2 \\parser.octal))
+
+ (..should_pass! (format first second) (\\parser.at_least! 2 octal!))
+ (..should_pass! (format first second third) (\\parser.at_least! 2 octal!))
+ (..should_fail (format first) (\\parser.at_least! 2 octal!)))))
+ (do [! random.monad]
+ [.let [octal (at ! each (|>> (n.% 8) (at n.octal encoded)) random.nat)]
+ first octal
+ second octal
+ third octal]
+ (_.coverage [\\parser.between \\parser.between!]
+ (and (..should_pass (format first second) (\\parser.between 2 1 \\parser.octal))
+ (..should_pass (format first second third) (\\parser.between 2 1 \\parser.octal))
+ (..should_fail (format first) (\\parser.between 2 1 \\parser.octal))
+
+ (..should_pass! (format first second) (\\parser.between! 2 1 octal!))
+ (..should_pass! (format first second third) (\\parser.between! 2 1 octal!))
+ (..should_fail (format first) (\\parser.between! 2 1 octal!)))))
+ )))
+
+(def: \\parser
+ Test
+ (<| (_.covering \\parser._)
+ (_.for [\\parser.Parser])
+ (all _.and
+ (do [! random.monad]
+ [sample (random.unicode 1)]
+ (_.coverage [\\parser.result \\parser.end]
+ (and (|> (\\parser.result \\parser.end
+ "")
+ (!expect {try.#Success _}))
+ (|> (\\parser.result \\parser.end
+ sample)
+ (!expect {try.#Failure _})))))
+ (do [! random.monad]
+ [.let [size 10]
+ expected (random.unicode size)
+ dummy (|> (random.unicode size)
+ (random.only (|>> (/#= expected) not)))]
+ (_.coverage [\\parser.this \\parser.cannot_match]
+ (and (|> (\\parser.result (\\parser.this expected)
+ expected)
+ (!expect {try.#Success []}))
+ (|> (\\parser.result (\\parser.this expected)
+ dummy)
+ (!expect (^.multi {try.#Failure error}
+ (exception.match? \\parser.cannot_match error)))))))
+ (_.coverage [\\parser.Slice \\parser.slice \\parser.cannot_slice]
+ (|> ""
+ (\\parser.result (\\parser.slice \\parser.any!))
+ (!expect (^.multi {try.#Failure error}
+ (exception.match? \\parser.cannot_slice error)))))
+ (do [! random.monad]
+ [expected (random.unicode 1)]
+ (_.coverage [\\parser.any \\parser.any!]
+ (and (..should_pass expected \\parser.any)
+ (..should_fail "" \\parser.any)
+
+ (..should_pass! expected \\parser.any!)
+ (..should_fail "" \\parser.any!))))
+ (do [! random.monad]
+ [expected (random.unicode 1)]
+ (_.coverage [\\parser.next \\parser.cannot_parse]
+ (and (..should_pass expected (<>.before \\parser.any \\parser.next))
+ (|> ""
+ (\\parser.result (<>.before \\parser.any \\parser.next))
+ (!expect (^.multi {try.#Failure error}
+ (exception.match? \\parser.cannot_parse error)))))))
+ (do [! random.monad]
+ [dummy (random.unicode 1)]
+ (_.coverage [\\parser.unconsumed_input]
+ (|> (format dummy dummy)
+ (\\parser.result \\parser.any)
+ (!expect (^.multi {try.#Failure error}
+ (exception.match? \\parser.unconsumed_input error))))))
+ (do [! random.monad]
+ [sample (random.unicode 1)]
+ (_.coverage [\\parser.Offset \\parser.offset]
+ (|> sample
+ (\\parser.result (do <>.monad
+ [pre \\parser.offset
+ _ \\parser.any
+ post \\parser.offset]
+ (in [pre post])))
+ (!expect {try.#Success [0 1]}))))
+ (do [! random.monad]
+ [left (random.unicode 1)
+ right (random.unicode 1)
+ .let [input (format left right)]]
+ (_.coverage [\\parser.remaining]
+ (|> input
+ (\\parser.result (do <>.monad
+ [pre \\parser.remaining
+ _ \\parser.any
+ post \\parser.remaining
+ _ \\parser.any]
+ (in (and (/#= input pre)
+ (/#= right post)))))
+ (!expect {try.#Success #1}))))
+ (do [! random.monad]
+ [left (random.unicode 1)
+ right (random.unicode 1)
+ expected (random.only (|>> (/#= right) not)
+ (random.unicode 1))]
+ (_.coverage [\\parser.enclosed]
+ (|> (format left expected right)
+ (\\parser.result (\\parser.enclosed [left right] (\\parser.this expected)))
+ (!expect {try.#Success _}))))
+ (do [! random.monad]
+ [input (random.unicode 1)
+ output (random.unicode 1)]
+ (_.coverage [\\parser.local]
+ (|> output
+ (\\parser.result (do <>.monad
+ [_ (\\parser.local input (\\parser.this input))]
+ (\\parser.this output)))
+ (!expect {try.#Success _}))))
+ (do [! random.monad]
+ [expected (at ! each (|>> (n.% 8) (at n.octal encoded)) random.nat)]
+ (_.coverage [\\parser.then]
+ (|> (list (code.text expected))
+ (<c>.result (\\parser.then \\parser.octal <c>.text))
+ (!expect (^.multi {try.#Success actual}
+ (/#= expected actual))))))
+ (do [! random.monad]
+ [invalid (random.upper_case 1)
+ expected (random.only (|>> (unicode/block.within? unicode/block.upper_case)
+ not)
+ (random.char unicode.character))
+ .let [upper! (\\parser.one_of! "ABCDEFGHIJKLMNOPQRSTUVWXYZ")]]
+ (_.coverage [\\parser.not \\parser.not! \\parser.expected_to_fail]
+ (and (..should_pass (/.of_char expected) (\\parser.not \\parser.upper))
+ (|> invalid
+ (\\parser.result (\\parser.not \\parser.upper))
+ (!expect (^.multi {try.#Failure error}
+ (exception.match? \\parser.expected_to_fail error))))
+
+ (..should_pass! (/.of_char expected) (\\parser.not! upper!))
+ (|> invalid
+ (\\parser.result (\\parser.not! upper!))
+ (!expect (^.multi {try.#Failure error}
+ (exception.match? \\parser.expected_to_fail error)))))))
+ (do [! random.monad]
+ [upper (random.upper_case 1)
+ lower (random.lower_case 1)
+ invalid (random.only (function (_ char)
+ (not (or (unicode/block.within? unicode/block.upper_case char)
+ (unicode/block.within? unicode/block.lower_case char))))
+ (random.char unicode.character))
+ .let [upper! (\\parser.one_of! "ABCDEFGHIJKLMNOPQRSTUVWXYZ")
+ lower! (\\parser.one_of! "abcdefghijklmnopqrstuvwxyz")]]
+ (_.coverage [\\parser.and \\parser.and!]
+ (and (..should_pass (format upper lower) (\\parser.and \\parser.upper \\parser.lower))
+ (..should_fail (format (/.of_char invalid) lower) (\\parser.and \\parser.upper \\parser.lower))
+ (..should_fail (format upper (/.of_char invalid)) (\\parser.and \\parser.upper \\parser.lower))
+
+ (..should_pass! (format upper lower) (\\parser.and! upper! lower!))
+ (..should_fail (format (/.of_char invalid) lower) (\\parser.and! upper! lower!))
+ (..should_fail (format upper (/.of_char invalid)) (\\parser.and! upper! lower!)))))
+ (do [! random.monad]
+ [expected (random.unicode 1)
+ invalid (random.unicode 1)]
+ (_.coverage [\\parser.satisfies \\parser.character_does_not_satisfy_predicate]
+ (and (..should_pass expected (\\parser.satisfies (function.constant true)))
+ (..should_fail' invalid (\\parser.satisfies (function.constant false))
+ \\parser.character_does_not_satisfy_predicate))))
+
+ \\parser#character_classes
+ \\parser#runs
+ )))
(def: bounded_size
(random.Random Nat)
@@ -337,4 +765,6 @@
/regex.test
/escape.test
/unicode.test
+
+ ..\\parser
)))
diff --git a/stdlib/source/test/lux/data/text/regex.lux b/stdlib/source/test/lux/data/text/regex.lux
index 43a34d694..0f419d22a 100644
--- a/stdlib/source/test/lux/data/text/regex.lux
+++ b/stdlib/source/test/lux/data/text/regex.lux
@@ -8,11 +8,11 @@
["[0]" pipe]
["[0]" try]
[parser
- ["<[0]>" text (.only Parser)]
["<[0]>" code]]]
[data
["[0]" text (.open: "[1]#[0]" equivalence)
- ["%" format (.only format)]]]
+ ["%" format (.only format)]
+ ["<[1]>" \\parser (.only Parser)]]]
["[0]" macro (.only)
[syntax (.only syntax)]
["[0]" code]]
diff --git a/stdlib/source/test/lux/extension.lux b/stdlib/source/test/lux/extension.lux
index 0716e76d1..dd2835166 100644
--- a/stdlib/source/test/lux/extension.lux
+++ b/stdlib/source/test/lux/extension.lux
@@ -22,7 +22,6 @@
["[0]" try (.open: "[1]#[0]" functor)]
["<>" parser (.only)
["<[0]>" code]
- ["<[0]>" analysis]
["<[0]>" synthesis]]]
[data
["[0]" binary]
@@ -52,7 +51,8 @@
["[0]" generation]
["[0]" directive]
["[0]" analysis (.only)
- ["[0]" type]]
+ ["[0]" type]
+ ["<[1]>" \\parser]]
[phase
[generation
(~~ (.for "JVM" (~~ (.these ["[0]" jvm
diff --git a/stdlib/source/test/lux/meta/configuration.lux b/stdlib/source/test/lux/meta/configuration.lux
index 45dcc5e5d..f456630a0 100644
--- a/stdlib/source/test/lux/meta/configuration.lux
+++ b/stdlib/source/test/lux/meta/configuration.lux
@@ -12,10 +12,10 @@
["[0]" try (.open: "[1]#[0]" functor)]
["[0]" exception]
["<>" parser (.only)
- ["<[0]>" text]
["<[0]>" code]]]
[data
- ["[0]" text]
+ ["[0]" text (.only)
+ ["<[1]>" \\parser]]
[collection
["[0]" list]]]
["[0]" macro (.only)
diff --git a/stdlib/source/test/lux/time.lux b/stdlib/source/test/lux/time.lux
index a054a8990..4cb18d5df 100644
--- a/stdlib/source/test/lux/time.lux
+++ b/stdlib/source/test/lux/time.lux
@@ -12,12 +12,11 @@
[control
["[0]" pipe]
["[0]" try (.open: "[1]#[0]" functor)]
- ["[0]" exception]
- [parser
- ["<[0]>" text]]]
+ ["[0]" exception]]
[data
["[0]" text (.only)
- ["%" format (.only format)]]]
+ ["%" format (.only format)]
+ ["<[1]>" \\parser]]]
[math
["[0]" random]
[number
diff --git a/stdlib/source/test/lux/time/date.lux b/stdlib/source/test/lux/time/date.lux
index beaae5d9d..a95e4c10f 100644
--- a/stdlib/source/test/lux/time/date.lux
+++ b/stdlib/source/test/lux/time/date.lux
@@ -11,12 +11,11 @@
["$[0]" codec]]]
[control
["[0]" try (.open: "[1]#[0]" functor)]
- ["[0]" exception]
- [parser
- ["<[0]>" text]]]
+ ["[0]" exception]]
[data
- [text
- ["%" format (.only format)]]]
+ ["[0]" text
+ ["%" format (.only format)]
+ ["<[1]>" \\parser]]]
[math
["[0]" random (.only Random)]
[number
diff --git a/stdlib/source/test/lux/tool/compiler/language/lux/analysis.lux b/stdlib/source/test/lux/tool/compiler/language/lux/analysis.lux
index 407833523..763b3ba9f 100644
--- a/stdlib/source/test/lux/tool/compiler/language/lux/analysis.lux
+++ b/stdlib/source/test/lux/tool/compiler/language/lux/analysis.lux
@@ -8,11 +8,12 @@
[\\specification
["$[0]" equivalence]]]
[control
+ ["<>" parser]
["[0]" pipe]
- ["[0]" function]
- ["[0]" maybe]
["[0]" try]
- ["[0]" exception (.only exception:)]]
+ ["[0]" exception (.only exception:)]
+ ["[0]" function]
+ ["[0]" maybe]]
[data
["[0]" bit (.open: "[1]#[0]" equivalence)]
["[0]" text (.open: "[1]#[0]" equivalence)]
@@ -23,10 +24,27 @@
[math
["[0]" random (.only Random) (.open: "[1]#[0]" monad)]
[number
- ["f" frac]]]
+ ["n" nat]
+ ["i" int]
+ ["f" frac]
+ ["r" rev]]]
[meta
+ ["[0]" symbol (.open: "[1]#[0]" equivalence)]
["[0]" configuration
- ["$[1]" \\test]]]]]
+ ["$[1]" \\test]]]
+ [tool
+ [compiler
+ [reference (.only Constant)
+ [variable (.only)]]]]]]
+ ["[0]" \\parser]
+ [\\library
+ ["[0]" / (.only)
+ [//
+ [phase
+ ["[0]" extension]]
+ [///
+ ["[0]" phase]
+ ["[0]" version]]]]]
["[0]" /
["[1][0]" complex]
["[1][0]" inference]
@@ -45,15 +63,129 @@
["[1][0]" symbol]
["[0]" location
["[2][1]" /]
- ["[1]" \\library (.open: "[1]#[0]" equivalence)]]]]]]
- [\\library
- ["[0]" / (.only)
- [//
- [phase
- ["[0]" extension]]
- [///
- ["[0]" phase]
- ["[0]" version]]]]])
+ ["[1]" \\library (.open: "[1]#[0]" equivalence)]]]]]])
+
+(def: !expect
+ (template (_ <expectation> <computation>)
+ [(case <computation>
+ <expectation>
+ true
+
+ _
+ false)]))
+
+(def: constant
+ (Random Constant)
+ (random.and (random.unicode 10)
+ (random.unicode 10)))
+
+(def: \\parser
+ Test
+ (<| (_.covering \\parser._)
+ (_.for [\\parser.Parser])
+ (do [! random.monad]
+ []
+ (`` (all _.and
+ (do [! random.monad]
+ [expected (at ! each (|>> /.bit) random.bit)]
+ (_.coverage [\\parser.result \\parser.any]
+ (|> (list expected)
+ (\\parser.result \\parser.any)
+ (pipe.case
+ {try.#Success actual}
+ (at /.equivalence = expected actual)
+
+ {try.#Failure _}
+ false))))
+ (~~ (with_template [<query> <check> <random> <analysis> <=>]
+ [(do [! random.monad]
+ [expected <random>]
+ (_.coverage [<query>]
+ (|> (list (<analysis> expected))
+ (\\parser.result <query>)
+ (pipe.case
+ {try.#Success actual}
+ (<=> expected actual)
+
+ {try.#Failure _}
+ false))))
+ (do [! random.monad]
+ [expected <random>]
+ (_.coverage [<check>]
+ (|> (list (<analysis> expected))
+ (\\parser.result (<check> expected))
+ (!expect {try.#Success _}))))]
+
+ [\\parser.bit \\parser.this_bit random.bit /.bit bit#=]
+ [\\parser.nat \\parser.this_nat random.nat /.nat n.=]
+ [\\parser.int \\parser.this_int random.int /.int i.=]
+ [\\parser.frac \\parser.this_frac random.safe_frac /.frac f.=]
+ [\\parser.rev \\parser.this_rev random.rev /.rev r.=]
+ [\\parser.text \\parser.this_text (random.unicode 10) /.text text#=]
+ [\\parser.local \\parser.this_local random.nat /.local n.=]
+ [\\parser.foreign \\parser.this_foreign random.nat /.foreign n.=]
+ [\\parser.constant \\parser.this_constant ..constant /.constant symbol#=]
+ ))
+ (do [! random.monad]
+ [expected random.bit]
+ (_.coverage [\\parser.tuple]
+ (|> (list (/.tuple (list (/.bit expected))))
+ (\\parser.result (\\parser.tuple \\parser.bit))
+ (pipe.case
+ {try.#Success actual}
+ (bit#= expected actual)
+
+ {try.#Failure _}
+ false))))
+ (do [! random.monad]
+ [dummy random.bit]
+ (_.coverage [\\parser.end?]
+ (and (|> (\\parser.result \\parser.end? (list))
+ (!expect {try.#Success #1}))
+ (|> (\\parser.result (do <>.monad
+ [verdict \\parser.end?
+ _ \\parser.bit]
+ (in verdict))
+ (list (/.bit dummy)))
+ (!expect {try.#Success #0})))))
+ (do [! random.monad]
+ [dummy random.bit]
+ (_.coverage [\\parser.end]
+ (and (|> (\\parser.result \\parser.end (list))
+ (!expect {try.#Success _}))
+ (|> (\\parser.result \\parser.end (list (/.bit dummy)))
+ (!expect {try.#Failure _})))))
+ (do [! random.monad]
+ [expected random.bit]
+ (_.coverage [\\parser.cannot_parse]
+ (and (|> (list (/.bit expected))
+ (\\parser.result \\parser.nat)
+ (pipe.case
+ {try.#Success _}
+ false
+
+ {try.#Failure error}
+ (exception.match? \\parser.cannot_parse error)))
+ (|> (list)
+ (\\parser.result \\parser.bit)
+ (pipe.case
+ {try.#Success _}
+ false
+
+ {try.#Failure error}
+ (exception.match? \\parser.cannot_parse error))))))
+ (do [! random.monad]
+ [expected random.bit]
+ (_.coverage [\\parser.unconsumed_input]
+ (|> (list (/.bit expected) (/.bit expected))
+ (\\parser.result \\parser.bit)
+ (pipe.case
+ {try.#Success _}
+ false
+
+ {try.#Failure error}
+ (exception.match? \\parser.unconsumed_input error)))))
+ )))))
(def: (random_branch random)
(All (_ a) (-> (Random a) (Random (/.Branch' a))))
@@ -491,4 +623,6 @@
/simple.test
/type.test
/coverage.test
+
+ ..\\parser
))))
diff --git a/stdlib/source/test/lux/tool/compiler/meta/cli/compiler.lux b/stdlib/source/test/lux/tool/compiler/meta/cli/compiler.lux
index 1a7aacc6d..b66061811 100644
--- a/stdlib/source/test/lux/tool/compiler/meta/cli/compiler.lux
+++ b/stdlib/source/test/lux/tool/compiler/meta/cli/compiler.lux
@@ -7,9 +7,10 @@
[\\specification
["$[0]" equivalence]]]
[control
- ["[0]" try (.open: "[1]#[0]" functor)]
- ["<>" parser
- ["<[0]>" text]]]
+ ["[0]" try (.open: "[1]#[0]" functor)]]
+ [data
+ ["[0]" text
+ ["<[1]>" \\parser]]]
[math
["[0]" random (.only Random)]
[number
diff --git a/stdlib/source/test/lux/type.lux b/stdlib/source/test/lux/type.lux
index 299da6fc7..f14d09760 100644
--- a/stdlib/source/test/lux/type.lux
+++ b/stdlib/source/test/lux/type.lux
@@ -29,7 +29,6 @@
["[1][0]" check]
["[1][0]" dynamic]
["[1][0]" implicit]
- ["[1][0]" poly]
["[1][0]" quotient]
["[1][0]" refinement]
["[1][0]" resource]
@@ -256,7 +255,6 @@
/check.test
/dynamic.test
/implicit.test
- /poly.test
/quotient.test
/refinement.test
/resource.test
diff --git a/stdlib/source/test/lux/type/poly.lux b/stdlib/source/test/lux/type/poly.lux
deleted file mode 100644
index 10c3bbbf6..000000000
--- a/stdlib/source/test/lux/type/poly.lux
+++ /dev/null
@@ -1,20 +0,0 @@
-(.using
- [library
- [lux (.except)
- ["_" test (.only Test)]]]
- [\\library
- ["[0]" /]]
- ["[0]" /
- ["[1][0]" equivalence]
- ["[1][0]" functor]
- ["[1][0]" json]])
-
-(def: .public test
- Test
- (<| (_.covering /._)
- (_.for [/.poly: /.code])
- (all _.and
- /equivalence.test
- /functor.test
- /json.test
- )))
diff --git a/stdlib/source/test/lux/type/poly/equivalence.lux b/stdlib/source/test/lux/type/poly/equivalence.lux
deleted file mode 100644
index 9f353f55a..000000000
--- a/stdlib/source/test/lux/type/poly/equivalence.lux
+++ /dev/null
@@ -1,89 +0,0 @@
-(.using
- [library
- [lux (.except Variant Record)
- ["_" test (.only Test)]
- ["@" target]
- [abstract
- [monad (.only do)]
- [equivalence (.only Equivalence)
- [\\poly
- ["[0]" /]]]
- [\\specification
- ["$[0]" equivalence]]]
- [control
- ["[0]" maybe]]
- [data
- ["[0]" bit]
- ["[0]" text]
- [collection
- ["[0]" list]]]
- [math
- ["[0]" random (.only Random)]
- [number
- ["n" nat]
- ["i" int]]]]])
-
-(type: Variant
- (.Variant
- {#Case0 Bit}
- {#Case1 Int}
- {#Case2 Frac}))
-
-(type: Recursive
- (Rec Recursive
- (.Variant
- {#Number Frac}
- {#Addition Frac Recursive})))
-
-(type: Record
- (.Record
- [#bit Bit
- #int Int
- #frac Frac
- #text Text
- #maybe (Maybe Int)
- #list (List Int)
- #variant Variant
- #tuple [Int Frac Text]
- #recursive Recursive]))
-
-(def: gen_recursive
- (Random Recursive)
- (random.rec (function (_ gen_recursive)
- (random.or random.safe_frac
- (random.and random.safe_frac
- gen_recursive)))))
-
-(def: random
- (Random Record)
- (do [! random.monad]
- [size (at ! each (n.% 2) random.nat)
- .let [gen_int (|> random.int (at ! each (|>> i.abs (i.% +1,000,000))))]]
- (all random.and
- random.bit
- gen_int
- random.safe_frac
- (random.unicode size)
- (random.maybe gen_int)
- (random.list size gen_int)
- (all random.or
- random.bit
- gen_int
- random.safe_frac)
- (all random.and
- gen_int
- random.safe_frac
- (random.unicode size))
- gen_recursive)))
-
-(for @.old (these)
- (these (def: equivalence
- (Equivalence ..Record)
- (/.equivalence ..Record))))
-
-(def: .public test
- Test
- (<| (_.covering /._)
- (_.for [/.equivalence]
- (for @.old (_.property "PLACEHOLDER" true)
- ($equivalence.spec ..equivalence ..random)))))
diff --git a/stdlib/source/test/lux/type/poly/functor.lux b/stdlib/source/test/lux/type/poly/functor.lux
deleted file mode 100644
index 35daa7eff..000000000
--- a/stdlib/source/test/lux/type/poly/functor.lux
+++ /dev/null
@@ -1,38 +0,0 @@
-(.using
- [library
- [lux (.except)
- ["@" target]
- [abstract
- [monad (.only do)]
- [functor (.only Functor)
- [\\poly
- ["[0]" /]]]]
- ["r" math/random (.only Random)]
- ["_" test (.only Test)]
- [control
- ["[0]" state]]
- [data
- ["[0]" identity]]]])
-
-(for @.old (these)
- (these (def: maybe_functor
- (Functor .Maybe)
- (/.functor .Maybe))
-
- (def: list_functor
- (Functor .List)
- (/.functor .List))
-
- (def: state_functor
- (All (_ s) (Functor (state.State s)))
- (/.functor state.State))
-
- (def: identity_functor
- (Functor identity.Identity)
- (/.functor identity.Identity))))
-
-(def: .public test
- Test
- (<| (_.covering /._)
- (_.coverage [/.functor]
- true)))
diff --git a/stdlib/source/test/lux/type/poly/json.lux b/stdlib/source/test/lux/type/poly/json.lux
deleted file mode 100644
index 3ec8050a6..000000000
--- a/stdlib/source/test/lux/type/poly/json.lux
+++ /dev/null
@@ -1,124 +0,0 @@
-(.using
- [library
- [lux (.except Variant Record)
- ["_" test (.only Test)]
- ["@" target]
- ["[0]" debug]
- [abstract
- [codec (.except)]
- [monad (.only do)]
- ["[0]" equivalence (.only Equivalence)
- ["poly/[1]" \\poly]]
- [\\specification
- ["$[0]" equivalence]
- ["$[0]" codec]]]
- [control
- ["[0]" try]
- ["p" parser
- ... TODO: Get rid of this import ASAP
- [json (.only)]]]
- [data
- ["[0]" bit]
- ["[0]" text]
- [format
- [json (.only JSON)
- [\\poly
- ["[0]" /]]]]
- [collection
- [sequence (.only sequence)]
- ["d" dictionary]
- ["[0]" list]]]
- [type
- ["[0]" unit]]
- [math
- ["[0]" random (.only Random)]
- [number
- ["n" nat]
- ["[0]" frac]]]
- [time
- ["ti" instant]
- ["tda" date]
- ... ["tdu" duration]
- ]]]
- [test
- [lux
- [time
- ["_[0]" instant]
- ... ["_[0]" duration]
- ]]])
-
-(type: Variant
- (.Variant
- {#Bit Bit}
- {#Text Text}
- {#Frac Frac}))
-
-(type: Recursive
- (Rec Recursive
- (.Variant
- {#Number Frac}
- {#Addition Frac Recursive})))
-
-(type: Record
- (.Record
- [#bit Bit
- #frac Frac
- #text Text
- #maybe (Maybe Frac)
- #list (List Frac)
- #dictionary (d.Dictionary Text Frac)
- #variant Variant
- #tuple [Bit Text Frac]
- #recursive Recursive
- ... #instant ti.Instant
- ... #duration tdu.Duration
- #date tda.Date
- #grams (unit.Qty unit.Gram)]))
-
-(def: gen_recursive
- (Random Recursive)
- (random.rec
- (function (_ gen_recursive)
- (random.or random.safe_frac
- (random.and random.safe_frac
- gen_recursive)))))
-
-(def: qty
- (All (_ unit) (Random (unit.Qty unit)))
- (at random.monad each (debug.private unit.in') random.int))
-
-(def: gen_record
- (Random Record)
- (do [! random.monad]
- [size (at ! each (n.% 2) random.nat)]
- (all random.and
- random.bit
- random.safe_frac
- (random.unicode size)
- (random.maybe random.safe_frac)
- (random.list size random.safe_frac)
- (random.dictionary text.hash size (random.unicode size) random.safe_frac)
- (all random.or random.bit (random.unicode size) random.safe_frac)
- (all random.and random.bit (random.unicode size) random.safe_frac)
- ..gen_recursive
- ... _instant.instant
- ... _duration.duration
- random.date
- ..qty
- )))
-
-(for @.old (these)
- (these (def: equivalence
- (Equivalence Record)
- (poly/equivalence.equivalence Record))
-
- (def: codec
- (Codec JSON Record)
- (/.codec Record))))
-
-(def: .public test
- Test
- (<| (_.covering /._)
- (_.for [/.codec]
- (for @.old (_.property "PLACEHOLDER" true)
- ($codec.spec ..equivalence ..codec ..gen_record)))))