aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEduardo Julian2022-06-16 02:16:07 -0400
committerEduardo Julian2022-06-16 02:16:07 -0400
commite00e0b5f1e5fb509cf8f32424397110f524b8148 (patch)
treead15496975ea945d5f8fb2c795414d561561d2b6
parent9e2f1e76f2c8df01ed7687d934c3210fcf676bd6 (diff)
New "parser" hierarchy. [Part 3]
-rw-r--r--licentia/source/program/licentia.lux6
-rw-r--r--licentia/source/program/licentia/input.lux8
-rw-r--r--stdlib/source/library/lux/world/net/http/request.lux9
-rw-r--r--stdlib/source/parser/lux/data/format/json.lux (renamed from stdlib/source/library/lux/control/parser/json.lux)8
-rw-r--r--stdlib/source/parser/lux/data/format/xml.lux (renamed from stdlib/source/library/lux/control/parser/xml.lux)8
-rw-r--r--stdlib/source/polytypic/lux/data/format/json.lux4
-rw-r--r--stdlib/source/program/aedifex/artifact/snapshot.lux6
-rw-r--r--stdlib/source/program/aedifex/artifact/snapshot/build.lux6
-rw-r--r--stdlib/source/program/aedifex/artifact/snapshot/stamp.lux6
-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/versioning.lux6
-rw-r--r--stdlib/source/program/aedifex/dependency/resolution.lux5
-rw-r--r--stdlib/source/program/aedifex/metadata/artifact.lux6
-rw-r--r--stdlib/source/program/aedifex/metadata/snapshot.lux6
-rw-r--r--stdlib/source/program/aedifex/package.lux7
-rw-r--r--stdlib/source/program/aedifex/pom.lux58
-rw-r--r--stdlib/source/test/aedifex/artifact/snapshot.lux8
-rw-r--r--stdlib/source/test/aedifex/artifact/snapshot/build.lux8
-rw-r--r--stdlib/source/test/aedifex/artifact/snapshot/stamp.lux8
-rw-r--r--stdlib/source/test/aedifex/artifact/snapshot/version.lux8
-rw-r--r--stdlib/source/test/aedifex/artifact/versioning.lux8
-rw-r--r--stdlib/source/test/aedifex/metadata/artifact.lux6
-rw-r--r--stdlib/source/test/aedifex/metadata/snapshot.lux6
-rw-r--r--stdlib/source/test/aedifex/pom.lux6
-rw-r--r--stdlib/source/test/lux/control/parser.lux6
-rw-r--r--stdlib/source/test/lux/control/parser/json.lux167
-rw-r--r--stdlib/source/test/lux/control/parser/xml.lux182
-rw-r--r--stdlib/source/test/lux/data/format/json.lux159
-rw-r--r--stdlib/source/test/lux/data/format/xml.lux174
30 files changed, 433 insertions, 474 deletions
diff --git a/licentia/source/program/licentia.lux b/licentia/source/program/licentia.lux
index 11819681d..d736a5fa7 100644
--- a/licentia/source/program/licentia.lux
+++ b/licentia/source/program/licentia.lux
@@ -25,8 +25,7 @@
["[0]" maybe]
["[0]" try (.only Try)]
["[0]" parser
- ["<[0]>" cli]
- ["<[0]>" json]]
+ ["<[0]>" cli]]
[security
["!" capability]]]
[data
@@ -35,7 +34,8 @@
[encoding
["[0]" utf8]]]
[format
- ["[0]" json]]]
+ ["[0]" json (.only)
+ ["<[1]>" \\parser (.only Parser)]]]]
[world
["[0]" file]]]]
["[0]" /
diff --git a/licentia/source/program/licentia/input.lux b/licentia/source/program/licentia/input.lux
index b11f1a576..aa63f81d7 100644
--- a/licentia/source/program/licentia/input.lux
+++ b/licentia/source/program/licentia/input.lux
@@ -5,11 +5,13 @@
[monad (.only do)]]
[control
["[0]" exception (.only exception:)]
- ["<>" parser
- ["<[0]>" json (.only Parser)]]]
+ ["<>" parser]]
[data
[text
- ["%" \\format (.only format)]]]
+ ["%" \\format (.only format)]]
+ [format
+ ["[0]" json
+ ["<[1]>" \\parser (.only Parser)]]]]
[math
[number
["n" nat]
diff --git a/stdlib/source/library/lux/world/net/http/request.lux b/stdlib/source/library/lux/world/net/http/request.lux
index d3a970d14..13c57ed23 100644
--- a/stdlib/source/library/lux/world/net/http/request.lux
+++ b/stdlib/source/library/lux/world/net/http/request.lux
@@ -8,17 +8,16 @@
["[0]" try (.only Try)]
[concurrency
["[0]" async (.only Async)]
- ["[0]" frp]]
- [parser
- ["<[0]>" json]]]
+ ["[0]" frp]]]
[data
["[0]" number
["n" nat]]
["[0]" text
["[0]" encoding]]
[format
- ["[0]" json (.only JSON)]
- ["[0]" context (.only Context Property)]]
+ ["[0]" context (.only Context Property)]
+ ["[0]" json (.only JSON)
+ ["<[1]>" \\parser]]]
[collection
["[0]" list (.open: "[1]#[0]" functor mix)]
["[0]" dictionary]]]
diff --git a/stdlib/source/library/lux/control/parser/json.lux b/stdlib/source/parser/lux/data/format/json.lux
index 308c8c918..2f54560e9 100644
--- a/stdlib/source/library/lux/control/parser/json.lux
+++ b/stdlib/source/parser/lux/data/format/json.lux
@@ -4,6 +4,7 @@
[abstract
["[0]" monad (.only do)]]
[control
+ ["//" parser (.open: "[1]#[0]" functor)]
["[0]" try (.only Try)]
["[0]" exception (.only exception:)]]
[data
@@ -12,15 +13,14 @@
[collection
["[0]" list (.open: "[1]#[0]" functor)]
["[0]" sequence]
- ["[0]" dictionary (.only Dictionary)]]
- [format
- ["/" json (.only JSON)]]]
+ ["[0]" dictionary (.only Dictionary)]]]
[macro
["[0]" code]]
[math
[number
["[0]" frac]]]]]
- ["[0]" // (.open: "[1]#[0]" functor)])
+ [\\library
+ ["[0]" / (.only JSON)]])
(type: .public (Parser a)
(//.Parser (List JSON) a))
diff --git a/stdlib/source/library/lux/control/parser/xml.lux b/stdlib/source/parser/lux/data/format/xml.lux
index 16802de51..6b2ddf79c 100644
--- a/stdlib/source/library/lux/control/parser/xml.lux
+++ b/stdlib/source/parser/lux/data/format/xml.lux
@@ -4,6 +4,7 @@
[abstract
[monad (.only do)]]
[control
+ ["//" parser]
["[0]" try (.only Try) (.open: "[1]#[0]" functor)]
["[0]" exception (.only exception:)]]
[data
@@ -11,12 +12,11 @@
["%" \\format (.only format)]]
[collection
["[0]" list]
- ["[0]" dictionary]]
- [format
- ["/" xml (.only Attribute Attrs Tag XML)]]]
+ ["[0]" dictionary]]]
[meta
["[0]" symbol (.open: "[1]#[0]" equivalence codec)]]]]
- ["[0]" //])
+ [\\library
+ ["[0]" / (.only Attribute Attrs Tag XML)]])
(type: .public (Parser a)
(//.Parser [Attrs (List XML)] a))
diff --git a/stdlib/source/polytypic/lux/data/format/json.lux b/stdlib/source/polytypic/lux/data/format/json.lux
index 972e074a5..6c0f18430 100644
--- a/stdlib/source/polytypic/lux/data/format/json.lux
+++ b/stdlib/source/polytypic/lux/data/format/json.lux
@@ -7,12 +7,14 @@
[control
["[0]" try]
["<>" parser (.only)
- ["</>" json]
["<[0]>" type]
["<[0]>" code]]]
[data
["[0]" text (.only)
["%" \\format (.only format)]]
+ [format
+ [json
+ ["</>" \\parser]]]
[collection
["[0]" list (.open: "[1]#[0]" monad)]
["[0]" sequence (.only sequence)]
diff --git a/stdlib/source/program/aedifex/artifact/snapshot.lux b/stdlib/source/program/aedifex/artifact/snapshot.lux
index 4966eb80f..45b54e2cd 100644
--- a/stdlib/source/program/aedifex/artifact/snapshot.lux
+++ b/stdlib/source/program/aedifex/artifact/snapshot.lux
@@ -5,14 +5,14 @@
[equivalence (.only Equivalence)]
[monad (.only do)]]
[control
- ["<>" parser (.only)
- ["<[0]>" xml (.only Parser)]]]
+ ["<>" parser]]
[data
["[0]" sum]
["[0]" text
["<[1]>" \\parser]]
[format
- ["[0]" xml (.only XML)]]]]]
+ ["[0]" xml (.only XML)
+ ["<[1]>" \\parser (.only Parser)]]]]]]
["[0]" /
["[1][0]" stamp (.only Stamp)]])
diff --git a/stdlib/source/program/aedifex/artifact/snapshot/build.lux b/stdlib/source/program/aedifex/artifact/snapshot/build.lux
index f0a0c7d18..05570de3e 100644
--- a/stdlib/source/program/aedifex/artifact/snapshot/build.lux
+++ b/stdlib/source/program/aedifex/artifact/snapshot/build.lux
@@ -5,14 +5,14 @@
[equivalence (.only Equivalence)]
[monad (.only do)]]
[control
- ["<>" parser
- ["<[0]>" xml (.only Parser)]]]
+ ["<>" parser]]
[data
["[0]" text
["%" \\format]
["<[1]>" \\parser]]
[format
- ["[0]" xml (.only XML)]]]
+ ["[0]" xml (.only XML)
+ ["<[1]>" \\parser (.only Parser)]]]]
[math
[number
["[0]" nat]]]]])
diff --git a/stdlib/source/program/aedifex/artifact/snapshot/stamp.lux b/stdlib/source/program/aedifex/artifact/snapshot/stamp.lux
index 2f82cf020..1886b5b3e 100644
--- a/stdlib/source/program/aedifex/artifact/snapshot/stamp.lux
+++ b/stdlib/source/program/aedifex/artifact/snapshot/stamp.lux
@@ -5,14 +5,14 @@
[equivalence (.only Equivalence)]
[monad (.only do)]]
[control
- ["<>" parser (.only)
- ["<[0]>" xml (.only Parser)]]]
+ ["<>" parser]]
[data
["[0]" text
["<[1]>" \\parser]]
["[0]" product]
[format
- ["[0]" xml (.only XML)]]]]]
+ ["[0]" xml (.only XML)
+ ["<[1]>" \\parser (.only Parser)]]]]]]
["[0]" //
["[1][0]" time (.only Time)]
["[1][0]" build (.only Build)]])
diff --git a/stdlib/source/program/aedifex/artifact/snapshot/time.lux b/stdlib/source/program/aedifex/artifact/snapshot/time.lux
index 38a60ede0..87203845f 100644
--- a/stdlib/source/program/aedifex/artifact/snapshot/time.lux
+++ b/stdlib/source/program/aedifex/artifact/snapshot/time.lux
@@ -6,14 +6,14 @@
[monad (.only do)]]
[control
["[0]" exception (.only exception:)]
- ["<>" parser (.only)
- ["<[0]>" xml (.only Parser)]]]
+ ["<>" parser]]
[data
["[0]" text
["%" \\format]
["<[1]>" \\parser]]
[format
- ["[0]" xml (.only XML)]]]
+ ["[0]" xml (.only XML)
+ ["<[1]>" \\parser (.only Parser)]]]]
[time
["[0]" instant (.only Instant)]]]]
["[0]" ///
diff --git a/stdlib/source/program/aedifex/artifact/snapshot/version.lux b/stdlib/source/program/aedifex/artifact/snapshot/version.lux
index e38534c8f..48af92b72 100644
--- a/stdlib/source/program/aedifex/artifact/snapshot/version.lux
+++ b/stdlib/source/program/aedifex/artifact/snapshot/version.lux
@@ -5,14 +5,14 @@
[equivalence (.only Equivalence)]
[monad (.only do)]]
[control
- ["<>" parser (.only)
- ["<[0]>" xml (.only Parser)]]]
+ ["<>" parser]]
[data
["[0]" product]
["[0]" text
["<[1]>" \\parser]]
[format
- ["[0]" xml (.only XML)]]]]]
+ ["[0]" xml (.only XML)
+ ["<[1]>" \\parser (.only Parser)]]]]]]
["[0]" ///
["[1][0]" type (.only Type)]
["[1][0]" time (.only Time)]])
diff --git a/stdlib/source/program/aedifex/artifact/versioning.lux b/stdlib/source/program/aedifex/artifact/versioning.lux
index 811db7ab9..62a6e8fd2 100644
--- a/stdlib/source/program/aedifex/artifact/versioning.lux
+++ b/stdlib/source/program/aedifex/artifact/versioning.lux
@@ -6,15 +6,15 @@
[monad (.only do)]]
[control
["[0]" exception (.only exception:)]
- ["<>" parser (.only)
- ["<[0]>" xml (.only Parser)]]]
+ ["<>" parser]]
[data
["[0]" product]
["[0]" text (.only)
["%" \\format]
["<[1]>" \\parser]]
[format
- ["[0]" xml (.only XML)]]
+ ["[0]" xml (.only XML)
+ ["<[1]>" \\parser (.only Parser)]]]
[collection
["[0]" list (.open: "[1]#[0]" functor)]]]
[math
diff --git a/stdlib/source/program/aedifex/dependency/resolution.lux b/stdlib/source/program/aedifex/dependency/resolution.lux
index 08ca4d1a8..dc647464a 100644
--- a/stdlib/source/program/aedifex/dependency/resolution.lux
+++ b/stdlib/source/program/aedifex/dependency/resolution.lux
@@ -13,8 +13,6 @@
["[0]" maybe]
["[0]" try (.only Try) (.open: "[1]#[0]" functor)]
["[0]" exception (.only Exception exception:)]
- ["<>" parsernone
- ["<[0]>" xml (.only Parser)]]
[concurrency
["[0]" async (.only Async)]]]
[data
@@ -24,7 +22,8 @@
[encoding
["[0]" utf8]]]
[format
- ["[0]" xml (.only Tag XML)]]
+ ["[0]" xml (.only Tag XML)
+ ["<[1]>" \\parser (.only Parser)]]]
[collection
["[0]" dictionary (.only Dictionary)]
["[0]" set]
diff --git a/stdlib/source/program/aedifex/metadata/artifact.lux b/stdlib/source/program/aedifex/metadata/artifact.lux
index 01271437e..9bbb002bb 100644
--- a/stdlib/source/program/aedifex/metadata/artifact.lux
+++ b/stdlib/source/program/aedifex/metadata/artifact.lux
@@ -7,8 +7,7 @@
[control
["[0]" pipe]
["[0]" try (.only Try)]
- ["<>" parser (.only)
- ["<[0]>" xml (.only Parser)]]
+ ["<>" parser]
[concurrency
["[0]" async (.only Async)]]]
[data
@@ -19,7 +18,8 @@
[encoding
["[0]" utf8]]]
[format
- ["[0]" xml (.only XML)]]
+ ["[0]" xml (.only XML)
+ ["<[1]>" \\parser (.only Parser)]]]
[collection
["[0]" list (.open: "[1]#[0]" functor)]]]
[math
diff --git a/stdlib/source/program/aedifex/metadata/snapshot.lux b/stdlib/source/program/aedifex/metadata/snapshot.lux
index 4479fe244..1ea744765 100644
--- a/stdlib/source/program/aedifex/metadata/snapshot.lux
+++ b/stdlib/source/program/aedifex/metadata/snapshot.lux
@@ -8,8 +8,7 @@
["[0]" pipe]
["[0]" try (.only Try)]
["[0]" exception (.only exception:)]
- ["<>" parser (.only)
- ["<[0]>" xml (.only Parser)]]
+ ["<>" parser]
[concurrency
["[0]" async (.only Async)]]]
[data
@@ -20,7 +19,8 @@
[encoding
["[0]" utf8]]]
[format
- ["[0]" xml (.only XML)]]
+ ["[0]" xml (.only XML)
+ ["<[1]>" \\parser (.only Parser)]]]
[collection
["[0]" list (.open: "[1]#[0]" functor)]]]
[math
diff --git a/stdlib/source/program/aedifex/package.lux b/stdlib/source/program/aedifex/package.lux
index 258a80c2f..46a40927b 100644
--- a/stdlib/source/program/aedifex/package.lux
+++ b/stdlib/source/program/aedifex/package.lux
@@ -4,9 +4,7 @@
[abstract
[equivalence (.only Equivalence)]]
[control
- ["[0]" try (.only Try) (.open: "[1]#[0]" functor)]
- [parser
- ["<[0]>" xml]]]
+ ["[0]" try (.only Try) (.open: "[1]#[0]" functor)]]
[data
["[0]" sum]
["[0]" product]
@@ -15,7 +13,8 @@
[encoding
["[0]" utf8]]]
[format
- ["[0]" xml (.only XML)]]
+ ["[0]" xml (.only XML)
+ ["<[1]>" \\parser]]]
[collection
[set (.only Set)]]]]]
["[0]" //
diff --git a/stdlib/source/program/aedifex/pom.lux b/stdlib/source/program/aedifex/pom.lux
index 0f5d3b50e..334a06f46 100644
--- a/stdlib/source/program/aedifex/pom.lux
+++ b/stdlib/source/program/aedifex/pom.lux
@@ -8,12 +8,12 @@
["[0]" maybe (.open: "[1]#[0]" functor)]
["[0]" try (.only Try)]
["[0]" exception]
- ["<>" parser (.only)
- ["<[0]>" xml (.only Parser)]]]
+ ["<>" parser]]
[data
["[0]" text]
[format
- ["_" xml (.only Tag XML)]]
+ ["[0]" xml (.only Tag XML)
+ ["<[1]>" \\parser (.only Parser)]]]
[collection
["[0]" list (.open: "[1]#[0]" monoid functor mix)]
["[0]" set]
@@ -48,14 +48,14 @@
(def version
XML
- {_.#Node ["" "modelVersion"] _.attributes
- (list {_.#Text "4.0.0"})})
+ {xml.#Node ["" "modelVersion"] xml.attributes
+ (list {xml.#Text "4.0.0"})})
(def (property tag value)
(-> Text Text XML)
- {_.#Node ["" tag]
- _.attributes
- (list {_.#Text value})})
+ {xml.#Node ["" tag]
+ xml.attributes
+ (list {xml.#Text value})})
(def (artifact value)
(-> Artifact (List XML))
@@ -75,36 +75,36 @@
(|> (list (..property "name" name)
(..property ..url_tag url)
(..distribution distribution))
- {_.#Node ["" "license"] _.attributes}))
+ {xml.#Node ["" "license"] xml.attributes}))
(def repository
(-> Address XML)
(|>> (..property ..url_tag)
list
- {_.#Node ["" ..repository_tag] _.attributes}))
+ {xml.#Node ["" ..repository_tag] xml.attributes}))
(def (dependency value)
(-> Dependency XML)
- {_.#Node ["" ..dependency_tag]
- _.attributes
- (list#composite (..artifact (the //dependency.#artifact value))
- (list (..property "type" (the //dependency.#type value))))})
+ {xml.#Node ["" ..dependency_tag]
+ xml.attributes
+ (list#composite (..artifact (the //dependency.#artifact value))
+ (list (..property "type" (the //dependency.#type value))))})
(def (group tag)
(-> Text (-> (List XML) XML))
- (|>> {_.#Node ["" tag] _.attributes}))
+ (|>> {xml.#Node ["" tag] xml.attributes}))
(def scm
(-> /.SCM XML)
(|>> (..property ..url_tag)
list
- {_.#Node ["" "scm"] _.attributes}))
+ {xml.#Node ["" "scm"] xml.attributes}))
(def (organization [name url])
(-> /.Organization XML)
(|> (list (..property "name" name)
(..property ..url_tag url))
- {_.#Node ["" "organization"] _.attributes}))
+ {xml.#Node ["" "organization"] xml.attributes}))
(def (developer_organization [name url])
(-> /.Organization (List XML))
@@ -120,7 +120,7 @@
(with_template [<name> <type> <tag>]
[(def <name>
(-> <type> XML)
- (|>> ..developer' {_.#Node ["" <tag>] _.attributes}))]
+ (|>> ..developer' {xml.#Node ["" <tag>] xml.attributes}))]
[developer /.Developer "developer"]
[contributor /.Contributor "contributor"]
@@ -144,17 +144,17 @@
(case (the /.#identity value)
{.#Some identity}
{try.#Success
- {_.#Node ["" ..project_tag] _.attributes
- (all list#composite
- (list ..version)
- (..artifact identity)
- (|> value
- (the /.#info)
- (maybe#each ..info)
- (maybe.else (list)))
- (|> value (the /.#repositories) set.list (list#each ..repository) (..group "repositories") list)
- (|> value (the /.#dependencies) set.list (list#each ..dependency) (..group ..dependencies_tag) list)
- )}}
+ {xml.#Node ["" ..project_tag] xml.attributes
+ (all list#composite
+ (list ..version)
+ (..artifact identity)
+ (|> value
+ (the /.#info)
+ (maybe#each ..info)
+ (maybe.else (list)))
+ (|> value (the /.#repositories) set.list (list#each ..repository) (..group "repositories") list)
+ (|> value (the /.#dependencies) set.list (list#each ..dependency) (..group ..dependencies_tag) list)
+ )}}
_
(exception.except /.no_identity [])))
diff --git a/stdlib/source/test/aedifex/artifact/snapshot.lux b/stdlib/source/test/aedifex/artifact/snapshot.lux
index 8888dc848..a318672eb 100644
--- a/stdlib/source/test/aedifex/artifact/snapshot.lux
+++ b/stdlib/source/test/aedifex/artifact/snapshot.lux
@@ -7,9 +7,11 @@
[\\specification
["$[0]" equivalence]]]
[control
- ["[0]" try (.open: "[1]#[0]" functor)]
- [parser
- ["<[0]>" xml]]]
+ ["[0]" try (.open: "[1]#[0]" functor)]]
+ [data
+ [format
+ ["[0]" xml
+ ["<[1]>" \\parser]]]]
[math
["[0]" random (.only Random) (.open: "[1]#[0]" monad)]]]]
["$[0]" /
diff --git a/stdlib/source/test/aedifex/artifact/snapshot/build.lux b/stdlib/source/test/aedifex/artifact/snapshot/build.lux
index f6224dd0b..259698287 100644
--- a/stdlib/source/test/aedifex/artifact/snapshot/build.lux
+++ b/stdlib/source/test/aedifex/artifact/snapshot/build.lux
@@ -7,9 +7,11 @@
[\\specification
["$[0]" equivalence]]]
[control
- ["[0]" try (.open: "[1]#[0]" functor)]
- [parser
- ["<[0]>" xml]]]
+ ["[0]" try (.open: "[1]#[0]" functor)]]
+ [data
+ [format
+ ["[0]" xml
+ ["<[1]>" \\parser]]]]
[math
["[0]" random (.only Random)]]]]
[\\program
diff --git a/stdlib/source/test/aedifex/artifact/snapshot/stamp.lux b/stdlib/source/test/aedifex/artifact/snapshot/stamp.lux
index c24a06f5a..36b72daa8 100644
--- a/stdlib/source/test/aedifex/artifact/snapshot/stamp.lux
+++ b/stdlib/source/test/aedifex/artifact/snapshot/stamp.lux
@@ -7,9 +7,11 @@
[\\specification
["$[0]" equivalence]]]
[control
- ["[0]" try (.open: "[1]#[0]" functor)]
- [parser
- ["<[0]>" xml]]]
+ ["[0]" try (.open: "[1]#[0]" functor)]]
+ [data
+ [format
+ ["[0]" xml
+ ["<[1]>" \\parser]]]]
[math
["[0]" random (.only Random)]]
[time
diff --git a/stdlib/source/test/aedifex/artifact/snapshot/version.lux b/stdlib/source/test/aedifex/artifact/snapshot/version.lux
index d2a3e01e4..97b51465d 100644
--- a/stdlib/source/test/aedifex/artifact/snapshot/version.lux
+++ b/stdlib/source/test/aedifex/artifact/snapshot/version.lux
@@ -7,9 +7,11 @@
[\\specification
["$[0]" equivalence]]]
[control
- ["[0]" try (.open: "[1]#[0]" functor)]
- [parser
- ["<[0]>" xml]]]
+ ["[0]" try (.open: "[1]#[0]" functor)]]
+ [data
+ [format
+ ["[0]" xml
+ ["<[1]>" \\parser]]]]
[math
["[0]" random (.only Random)]]]]
[\\program
diff --git a/stdlib/source/test/aedifex/artifact/versioning.lux b/stdlib/source/test/aedifex/artifact/versioning.lux
index 451d0b824..ecd2ed616 100644
--- a/stdlib/source/test/aedifex/artifact/versioning.lux
+++ b/stdlib/source/test/aedifex/artifact/versioning.lux
@@ -7,9 +7,11 @@
[\\specification
["$[0]" equivalence]]]
[control
- ["[0]" try (.open: "[1]#[0]" functor)]
- [parser
- ["<[0]>" xml]]]
+ ["[0]" try (.open: "[1]#[0]" functor)]]
+ [data
+ [format
+ ["[0]" xml
+ ["<[1]>" \\parser]]]]
[math
["[0]" random (.only Random)]]]]
[\\program
diff --git a/stdlib/source/test/aedifex/metadata/artifact.lux b/stdlib/source/test/aedifex/metadata/artifact.lux
index a43777707..8dd0ef2b1 100644
--- a/stdlib/source/test/aedifex/metadata/artifact.lux
+++ b/stdlib/source/test/aedifex/metadata/artifact.lux
@@ -10,12 +10,14 @@
["[0]" maybe]
["[0]" try (.open: "[1]#[0]" functor)]
[parser
- ["[0]" environment]
- ["<[0]>" xml]]
+ ["[0]" environment]]
[concurrency
["[0]" async]]]
[data
["[0]" text (.open: "[1]#[0]" equivalence)]
+ [format
+ ["[0]" xml
+ ["<[1]>" \\parser]]]
[collection
["[0]" list]]]
[macro
diff --git a/stdlib/source/test/aedifex/metadata/snapshot.lux b/stdlib/source/test/aedifex/metadata/snapshot.lux
index a40ed0553..77975ddad 100644
--- a/stdlib/source/test/aedifex/metadata/snapshot.lux
+++ b/stdlib/source/test/aedifex/metadata/snapshot.lux
@@ -10,12 +10,14 @@
["[0]" maybe]
["[0]" try (.open: "[1]#[0]" functor)]
[parser
- ["[0]" environment]
- ["<[0]>" xml]]
+ ["[0]" environment]]
[concurrency
["[0]" async]]]
[data
["[0]" text (.open: "[1]#[0]" equivalence)]
+ [format
+ ["[0]" xml
+ ["<[1]>" \\parser]]]
[collection
["[0]" list]]]
[macro
diff --git a/stdlib/source/test/aedifex/pom.lux b/stdlib/source/test/aedifex/pom.lux
index e72eef0ef..a4956b3a4 100644
--- a/stdlib/source/test/aedifex/pom.lux
+++ b/stdlib/source/test/aedifex/pom.lux
@@ -7,12 +7,12 @@
[control
["[0]" try]
["[0]" exception]
- ["<>" parser (.only)
- ["<[0]>" xml]]]
+ ["<>" parser]]
[data
["[0]" text (.open: "[1]#[0]" equivalence)]
[format
- ["[0]" xml]]]
+ ["[0]" xml (.only)
+ ["<[1]>" \\parser]]]]
[math
["[0]" random]]]]
[//
diff --git a/stdlib/source/test/lux/control/parser.lux b/stdlib/source/test/lux/control/parser.lux
index 8bd0632d5..9d852ad86 100644
--- a/stdlib/source/test/lux/control/parser.lux
+++ b/stdlib/source/test/lux/control/parser.lux
@@ -31,10 +31,8 @@
["[1][0]" cli]
["[1][0]" code]
["[1][0]" environment]
- ["[1][0]" json]
["[1][0]" tree]
- ["[1][0]" type]
- ["[1][0]" xml]])
+ ["[1][0]" type]])
(def (should_fail expected input)
(All (_ a) (-> Text (Try a) Bit))
@@ -385,8 +383,6 @@
/cli.test
/code.test
/environment.test
- /json.test
/tree.test
/type.test
- /xml.test
))))
diff --git a/stdlib/source/test/lux/control/parser/json.lux b/stdlib/source/test/lux/control/parser/json.lux
deleted file mode 100644
index cf4faf7c4..000000000
--- a/stdlib/source/test/lux/control/parser/json.lux
+++ /dev/null
@@ -1,167 +0,0 @@
-(.using
- [library
- [lux (.except)
- ["_" test (.only Test)]
- [abstract
- [monad (.only do)]]
- [control
- ["[0]" pipe]
- ["[0]" maybe]
- ["[0]" try]
- ["[0]" exception]
- ["<>" parser]]
- [data
- ["[0]" bit]
- ["[0]" text]
- [collection
- ["[0]" list (.open: "[1]#[0]" functor)]
- ["[0]" set]
- ["[0]" dictionary]
- ["[0]" sequence (.only sequence) (.open: "[1]#[0]" functor)]]
- [format
- ["[0]" json]]]
- [macro
- ["^" pattern]]
- [math
- ["[0]" random (.only Random)]
- [number
- ["n" nat]
- ["[0]" frac]]]]]
- [\\library
- ["[0]" /]])
-
-(def !expect
- (template (_ <pattern> <value>)
- [(case <value>
- <pattern>
- true
-
- _
- false)]))
-
-(def safe_frac
- (Random Frac)
- (random.only (|>> frac.not_a_number? not) random.frac))
-
-(def .public test
- Test
- (<| (_.covering /._)
- (_.for [/.Parser])
- (`` (all _.and
- (do [! random.monad]
- [expected (at ! each (|>> {json.#String}) (random.unicode 1))]
- (_.coverage [/.result /.any]
- (|> (/.result /.any expected)
- (!expect (^.multi {try.#Success actual}
- (at json.equivalence = expected actual))))))
- (_.coverage [/.null]
- (|> (/.result /.null {json.#Null})
- (!expect {try.#Success _})))
- (~~ (with_template [<query> <test> <check> <random> <json> <equivalence>]
- [(do [! random.monad]
- [expected <random>
- dummy (|> <random> (random.only (|>> (at <equivalence> = expected) not)))]
- (all _.and
- (_.coverage [<query>]
- (|> (/.result <query> {<json> expected})
- (!expect (^.multi {try.#Success actual}
- (at <equivalence> = expected actual)))))
- (_.coverage [<test>]
- (and (|> (/.result (<test> expected) {<json> expected})
- (!expect {try.#Success #1}))
- (|> (/.result (<test> expected) {<json> dummy})
- (!expect {try.#Success #0}))))
- (_.coverage [<check>]
- (and (|> (/.result (<check> expected) {<json> expected})
- (!expect {try.#Success _}))
- (|> (/.result (<check> expected) {<json> dummy})
- (!expect {try.#Failure _}))))))]
-
- [/.boolean /.boolean? /.this_boolean random.bit json.#Boolean bit.equivalence]
- [/.number /.number? /.this_number ..safe_frac json.#Number frac.equivalence]
- [/.string /.string? /.this_string (random.unicode 1) json.#String text.equivalence]
- ))
- (do [! random.monad]
- [expected (random.unicode 1)
- dummy random.bit]
- (_.coverage [/.unexpected_value]
- (|> (/.result /.string {json.#Boolean dummy})
- (!expect (^.multi {try.#Failure error}
- (exception.match? /.unexpected_value error))))))
- (do [! random.monad]
- [expected (random.unicode 1)
- dummy (|> (random.unicode 1) (random.only (|>> (at text.equivalence = expected) not)))]
- (_.coverage [/.value_mismatch]
- (|> (/.result (/.this_string expected) {json.#String dummy})
- (!expect (^.multi {try.#Failure error}
- (exception.match? /.value_mismatch error))))))
- (do [! random.monad]
- [expected (random.unicode 1)]
- (_.coverage [/.nullable]
- (and (|> (/.result (/.nullable /.string) {json.#Null})
- (!expect (^.multi {try.#Success actual}
- (at (maybe.equivalence text.equivalence) = {.#None} actual))))
- (|> (/.result (/.nullable /.string) {json.#String expected})
- (!expect (^.multi {try.#Success actual}
- (at (maybe.equivalence text.equivalence) = {.#Some expected} actual)))))))
- (do [! random.monad]
- [size (at ! each (n.% 10) random.nat)
- expected (|> (random.unicode 1)
- (random.list size)
- (at ! each sequence.of_list))]
- (_.coverage [/.array]
- (|> (/.result (/.array (<>.some /.string))
- {json.#Array (sequence#each (|>> {json.#String}) expected)})
- (!expect (^.multi {try.#Success actual}
- (at (sequence.equivalence text.equivalence) = expected (sequence.of_list actual)))))))
- (do [! random.monad]
- [expected (at ! each (|>> {json.#String}) (random.unicode 1))]
- (_.coverage [/.unconsumed_input]
- (|> (/.result (/.array /.any) {json.#Array (sequence expected expected)})
- (!expect (^.multi {try.#Failure error}
- (exception.match? /.unconsumed_input error))))))
- (_.coverage [/.empty_input]
- (|> (/.result (/.array /.any) {json.#Array (sequence)})
- (!expect (^.multi {try.#Failure error}
- (exception.match? /.empty_input error)))))
- (do [! random.monad]
- [expected_boolean random.bit
- expected_number ..safe_frac
- expected_string (random.unicode 1)
- [boolean_field number_field string_field] (|> (random.set text.hash 3 (random.unicode 3))
- (at ! each (|>> set.list
- (pipe.case
- (pattern (list boolean_field number_field string_field))
- [boolean_field number_field string_field]
-
- _
- (undefined)))))]
- (_.coverage [/.object /.field]
- (|> (/.result (/.object (all <>.and
- (/.field boolean_field /.boolean)
- (/.field number_field /.number)
- (/.field string_field /.string)))
- {json.#Object
- (dictionary.of_list text.hash
- (list [boolean_field {json.#Boolean expected_boolean}]
- [number_field {json.#Number expected_number}]
- [string_field {json.#String expected_string}]))})
- (!expect (^.multi {try.#Success [actual_boolean actual_number actual_string]}
- (and (at bit.equivalence = expected_boolean actual_boolean)
- (at frac.equivalence = expected_number actual_number)
- (at text.equivalence = expected_string actual_string)))))))
- (do [! random.monad]
- [size (at ! each (n.% 10) random.nat)
- keys (random.list size (random.unicode 1))
- values (random.list size (random.unicode 1))
- .let [expected (dictionary.of_list text.hash (list.zipped_2 keys values))]]
- (_.coverage [/.dictionary]
- (|> (/.result (/.dictionary /.string)
- {json.#Object
- (|> values
- (list#each (|>> {json.#String}))
- (list.zipped_2 keys)
- (dictionary.of_list text.hash))})
- (!expect (^.multi {try.#Success actual}
- (at (dictionary.equivalence text.equivalence) = expected actual))))))
- ))))
diff --git a/stdlib/source/test/lux/control/parser/xml.lux b/stdlib/source/test/lux/control/parser/xml.lux
deleted file mode 100644
index b671c071e..000000000
--- a/stdlib/source/test/lux/control/parser/xml.lux
+++ /dev/null
@@ -1,182 +0,0 @@
-(.using
- [library
- [lux (.except)
- ["_" test (.only Test)]
- ["[0]" type (.open: "[1]#[0]" equivalence)]
- [abstract
- [monad (.only do)]]
- [control
- ["[0]" try (.open: "[1]#[0]" functor)]
- ["[0]" exception]]
- [data
- ["[0]" text (.open: "[1]#[0]" equivalence)]
- [format
- ["[0]" xml (.open: "[1]#[0]" equivalence)]]
- [collection
- ["[0]" dictionary]
- ["[0]" list]]]
- [macro
- ["^" pattern]
- ["[0]" template]]
- [math
- ["[0]" random (.only Random)]
- [number
- ["n" nat]]]
- [meta
- ["[0]" symbol (.open: "[1]#[0]" equivalence)]]]]
- [\\library
- ["[0]" / (.only)
- ["/[1]" // (.open: "[1]#[0]" monad)]]])
-
-(def !expect
- (template (_ <pattern> <value>)
- [(case <value>
- <pattern>
- true
-
- _
- false)]))
-
-(def !failure
- (template (_ <exception> <cases>)
- [(with_expansions [<<cases>> (template.spliced <cases>)]
- (do [! random.monad]
- [expected (random.alphabetic 1)]
- (_.coverage [<exception>]
- (`` (and (~~ (with_template [<parser> <input>]
- [(|> (/.result <parser> (list <input>))
- (!expect (^.multi {try.#Failure error}
- (exception.match? <exception> error))))]
-
- <<cases>>)))))))]))
-
-(def random_label
- (Random Symbol)
- (random.and (random.alphabetic 1)
- (random.alphabetic 1)))
-
-(def random_tag ..random_label)
-(def random_attribute ..random_label)
-
-(def .public test
- Test
- (<| (_.covering /._)
- (_.for [/.Parser])
- (all _.and
- (do [! random.monad]
- [expected (random.alphabetic 1)]
- (_.coverage [/.result /.text]
- (|> (/.result /.text (list {xml.#Text expected}))
- (!expect (^.multi {try.#Success actual}
- (text#= expected actual))))))
- (!failure /.unconsumed_inputs
- [[(//#in expected)
- {xml.#Text expected}]])
- (do [! random.monad]
- [expected (at ! each (|>> {xml.#Text}) (random.alphabetic 1))]
- (_.coverage [/.any]
- (|> (/.result /.any (list expected))
- (try#each (xml#= expected))
- (try.else false))))
- (do [! random.monad]
- [expected ..random_tag]
- (_.coverage [/.tag]
- (|> (/.result (do //.monad
- [actual /.tag
- _ /.any]
- (in (symbol#= expected actual)))
- (list {xml.#Node expected (dictionary.empty symbol.hash) (list)}))
- (!expect {try.#Success #1}))))
- (do [! random.monad]
- [expected ..random_tag]
- (_.coverage [/.node]
- (|> (/.result (/.node expected (//#in []))
- (list {xml.#Node expected (dictionary.empty symbol.hash) (list)}))
- (!expect {try.#Success []}))))
- (!failure /.wrong_tag
- [[(/.node ["" expected] (//#in []))
- {xml.#Node [expected ""] (dictionary.empty symbol.hash) (list)}]])
- (do [! random.monad]
- [expected_tag ..random_tag
- expected_attribute ..random_attribute
- expected_value (random.alphabetic 1)]
- (_.coverage [/.attribute]
- (|> (/.result (<| (/.node expected_tag)
- (//.after (/.attribute expected_attribute))
- (//#in []))
- (list {xml.#Node expected_tag
- (|> (dictionary.empty symbol.hash)
- (dictionary.has expected_attribute expected_value))
- (list)}))
- (!expect {try.#Success []}))))
- (!failure /.unknown_attribute
- [[(/.attribute ["" expected])
- {xml.#Node [expected expected]
- (|> (dictionary.empty symbol.hash)
- (dictionary.has [expected ""] expected))
- (list)}]])
- (!failure /.empty_input
- [[(do //.monad
- [_ /.any]
- /.any)
- {xml.#Text expected}]
- [(do //.monad
- [_ /.any]
- /.text)
- {xml.#Text expected}]
- [(do //.monad
- [_ /.any]
- (/.node [expected expected]
- (//#in [])))
- {xml.#Node [expected expected]
- (dictionary.empty symbol.hash)
- (list)}]
- [(do //.monad
- [_ /.any]
- (/.node [expected expected]
- (/.attribute [expected expected])))
- {xml.#Node [expected expected]
- (|> (dictionary.empty symbol.hash)
- (dictionary.has [expected expected] expected))
- (list)}]])
- (!failure /.unexpected_input
- [[/.text
- {xml.#Node [expected expected] (dictionary.empty symbol.hash) (list)}]
- [(/.node [expected expected]
- (//#in []))
- {xml.#Text expected}]
- [(/.node [expected expected]
- (/.attribute [expected expected]))
- {xml.#Text expected}]])
- (do [! random.monad]
- [.let [node (is (-> xml.Tag (List xml.XML) xml.XML)
- (function (_ tag children)
- {xml.#Node tag (dictionary.empty symbol.hash) children}))]
- parent ..random_tag
- right ..random_tag
- wrong (random.only (|>> (symbol#= right) not)
- ..random_tag)
- .let [parser (<| (/.node parent)
- (do //.monad
- [_ (<| /.somewhere
- (/.node right)
- (//#in []))
- _ (//.some /.any)]
- (in [])))]
- repetitions (at ! each (n.% 10) random.nat)]
- (all _.and
- (_.coverage [/.somewhere]
- (|> (/.result parser
- (list (node parent
- (list.together (list (list.repeated repetitions (node wrong (list)))
- (list (node right (list)))
- (list.repeated repetitions (node wrong (list))))))))
- (!expect {try.#Success []})))
- (_.coverage [/.nowhere]
- (|> (/.result parser
- (list (node parent
- (list.repeated repetitions (node wrong (list))))))
- (!expect (^.multi {try.#Failure error}
- (exception.match? /.nowhere error)))))
- ))
- )))
diff --git a/stdlib/source/test/lux/data/format/json.lux b/stdlib/source/test/lux/data/format/json.lux
index 13d7f11cc..1f626c15d 100644
--- a/stdlib/source/test/lux/data/format/json.lux
+++ b/stdlib/source/test/lux/data/format/json.lux
@@ -13,41 +13,179 @@
["$[0]" equivalence]
["$[0]" codec]]]
[control
- ["[0]" try (.open: "[1]#[0]" functor)]
- ["p" parser
- ... TODO: Get rid of this import ASAP
- [json (.only)]]]
+ ["<>" parser]
+ ["[0]" pipe]
+ ["[0]" maybe]
+ ["[0]" exception]
+ ["[0]" try (.open: "[1]#[0]" functor)]]
[data
["[0]" product]
["[0]" bit]
["[0]" text (.only)
["%" \\format (.only format)]]
[collection
- ["[0]" sequence (.only sequence)]
+ ["[0]" sequence (.only sequence) (.open: "[1]#[0]" functor)]
["[0]" dictionary (.only Dictionary)]
["[0]" set]
["[0]" list (.open: "[1]#[0]" functor)]]]
+ ["[0]" macro (.only)
+ ["^" pattern]
+ ["[0]" syntax (.only syntax)]
+ ["[0]" code]]
[math
["[0]" random (.only Random)]
[number
["n" nat]
["[0]" frac]]]
- ["[0]" macro (.only)
- ["[0]" syntax (.only syntax)]
- ["[0]" code]]
[time
["[0]" date]
["[0]" instant
["[0]/[1]" \\test]]
["[0]" duration
- ["[0]/[1]" \\test]]
- ]
+ ["[0]/[1]" \\test]]]
[type
["[0]" unit]]]]
["[0]" \\polytypic]
+ ["[0]" \\parser]
[\\library
["[0]" / (.only JSON) (.open: "[1]#[0]" equivalence)]])
+(def !expect
+ (template (_ <pattern> <value>)
+ [(case <value>
+ <pattern>
+ true
+
+ _
+ false)]))
+
+(def safe_frac
+ (Random Frac)
+ (random.only (|>> frac.not_a_number? not) random.frac))
+
+(def \\parser
+ Test
+ (<| (_.covering \\parser._)
+ (_.for [\\parser.Parser])
+ (`` (all _.and
+ (do [! random.monad]
+ [expected (at ! each (|>> {/.#String}) (random.unicode 1))]
+ (_.coverage [\\parser.result \\parser.any]
+ (|> (\\parser.result \\parser.any expected)
+ (!expect (^.multi {try.#Success actual}
+ (at /.equivalence = expected actual))))))
+ (_.coverage [\\parser.null]
+ (|> (\\parser.result \\parser.null {/.#Null})
+ (!expect {try.#Success _})))
+ (~~ (with_template [<query> <test> <check> <random> <json> <equivalence>]
+ [(do [! random.monad]
+ [expected <random>
+ dummy (|> <random> (random.only (|>> (at <equivalence> = expected) not)))]
+ (all _.and
+ (_.coverage [<query>]
+ (|> (\\parser.result <query> {<json> expected})
+ (!expect (^.multi {try.#Success actual}
+ (at <equivalence> = expected actual)))))
+ (_.coverage [<test>]
+ (and (|> (\\parser.result (<test> expected) {<json> expected})
+ (!expect {try.#Success #1}))
+ (|> (\\parser.result (<test> expected) {<json> dummy})
+ (!expect {try.#Success #0}))))
+ (_.coverage [<check>]
+ (and (|> (\\parser.result (<check> expected) {<json> expected})
+ (!expect {try.#Success _}))
+ (|> (\\parser.result (<check> expected) {<json> dummy})
+ (!expect {try.#Failure _}))))))]
+
+ [\\parser.boolean \\parser.boolean? \\parser.this_boolean random.bit /.#Boolean bit.equivalence]
+ [\\parser.number \\parser.number? \\parser.this_number ..safe_frac /.#Number frac.equivalence]
+ [\\parser.string \\parser.string? \\parser.this_string (random.unicode 1) /.#String text.equivalence]
+ ))
+ (do [! random.monad]
+ [expected (random.unicode 1)
+ dummy random.bit]
+ (_.coverage [\\parser.unexpected_value]
+ (|> (\\parser.result \\parser.string {/.#Boolean dummy})
+ (!expect (^.multi {try.#Failure error}
+ (exception.match? \\parser.unexpected_value error))))))
+ (do [! random.monad]
+ [expected (random.unicode 1)
+ dummy (|> (random.unicode 1) (random.only (|>> (at text.equivalence = expected) not)))]
+ (_.coverage [\\parser.value_mismatch]
+ (|> (\\parser.result (\\parser.this_string expected) {/.#String dummy})
+ (!expect (^.multi {try.#Failure error}
+ (exception.match? \\parser.value_mismatch error))))))
+ (do [! random.monad]
+ [expected (random.unicode 1)]
+ (_.coverage [\\parser.nullable]
+ (and (|> (\\parser.result (\\parser.nullable \\parser.string) {/.#Null})
+ (!expect (^.multi {try.#Success actual}
+ (at (maybe.equivalence text.equivalence) = {.#None} actual))))
+ (|> (\\parser.result (\\parser.nullable \\parser.string) {/.#String expected})
+ (!expect (^.multi {try.#Success actual}
+ (at (maybe.equivalence text.equivalence) = {.#Some expected} actual)))))))
+ (do [! random.monad]
+ [size (at ! each (n.% 10) random.nat)
+ expected (|> (random.unicode 1)
+ (random.list size)
+ (at ! each sequence.of_list))]
+ (_.coverage [\\parser.array]
+ (|> (\\parser.result (\\parser.array (<>.some \\parser.string))
+ {/.#Array (sequence#each (|>> {/.#String}) expected)})
+ (!expect (^.multi {try.#Success actual}
+ (at (sequence.equivalence text.equivalence) = expected (sequence.of_list actual)))))))
+ (do [! random.monad]
+ [expected (at ! each (|>> {/.#String}) (random.unicode 1))]
+ (_.coverage [\\parser.unconsumed_input]
+ (|> (\\parser.result (\\parser.array \\parser.any) {/.#Array (sequence expected expected)})
+ (!expect (^.multi {try.#Failure error}
+ (exception.match? \\parser.unconsumed_input error))))))
+ (_.coverage [\\parser.empty_input]
+ (|> (\\parser.result (\\parser.array \\parser.any) {/.#Array (sequence)})
+ (!expect (^.multi {try.#Failure error}
+ (exception.match? \\parser.empty_input error)))))
+ (do [! random.monad]
+ [expected_boolean random.bit
+ expected_number ..safe_frac
+ expected_string (random.unicode 1)
+ [boolean_field number_field string_field] (|> (random.set text.hash 3 (random.unicode 3))
+ (at ! each (|>> set.list
+ (pipe.case
+ (pattern (list boolean_field number_field string_field))
+ [boolean_field number_field string_field]
+
+ _
+ (undefined)))))]
+ (_.coverage [\\parser.object \\parser.field]
+ (|> (\\parser.result (\\parser.object (all <>.and
+ (\\parser.field boolean_field \\parser.boolean)
+ (\\parser.field number_field \\parser.number)
+ (\\parser.field string_field \\parser.string)))
+ {/.#Object
+ (dictionary.of_list text.hash
+ (list [boolean_field {/.#Boolean expected_boolean}]
+ [number_field {/.#Number expected_number}]
+ [string_field {/.#String expected_string}]))})
+ (!expect (^.multi {try.#Success [actual_boolean actual_number actual_string]}
+ (and (at bit.equivalence = expected_boolean actual_boolean)
+ (at frac.equivalence = expected_number actual_number)
+ (at text.equivalence = expected_string actual_string)))))))
+ (do [! random.monad]
+ [size (at ! each (n.% 10) random.nat)
+ keys (random.list size (random.unicode 1))
+ values (random.list size (random.unicode 1))
+ .let [expected (dictionary.of_list text.hash (list.zipped_2 keys values))]]
+ (_.coverage [\\parser.dictionary]
+ (|> (\\parser.result (\\parser.dictionary \\parser.string)
+ {/.#Object
+ (|> values
+ (list#each (|>> {/.#String}))
+ (list.zipped_2 keys)
+ (dictionary.of_list text.hash))})
+ (!expect (^.multi {try.#Success actual}
+ (at (dictionary.equivalence text.equivalence) = expected actual))))))
+ ))))
+
(type: Variant
(.Variant
{#Bit Bit}
@@ -294,4 +432,5 @@
)))
..\\polytypic
+ ..\\parser
))))
diff --git a/stdlib/source/test/lux/data/format/xml.lux b/stdlib/source/test/lux/data/format/xml.lux
index 0798b1d83..d003276e9 100644
--- a/stdlib/source/test/lux/data/format/xml.lux
+++ b/stdlib/source/test/lux/data/format/xml.lux
@@ -2,16 +2,17 @@
[library
[lux (.except char symbol)
["_" test (.only Test)]
+ ["[0]" type (.open: "[1]#[0]" equivalence)]
[abstract
- [monad (.only Monad do)]
+ [monad (.only do)]
[\\specification
["$[0]" equivalence]
["$[0]" codec]]]
[control
+ ["<>" parser (.open: "[1]#[0]" monad)]
["[0]" maybe]
- ["[0]" try]
- ["p" parser
- ["</>" xml]]]
+ ["[0]" try (.open: "[1]#[0]" functor)]
+ ["[0]" exception]]
[data
["[0]" text (.open: "[1]#[0]" equivalence)
["%" \\format (.only format)]]
@@ -19,15 +20,170 @@
["[0]" dictionary]
["[0]" list (.open: "[1]#[0]" functor)]]]
[macro
- ["^" pattern]]
+ ["^" pattern]
+ ["[0]" template]]
[math
["[0]" random (.only Random) (.open: "[1]#[0]" monad)]
[number
["n" nat]]]
[meta
- ["[0]" symbol]]]]
+ ["[0]" symbol (.open: "[1]#[0]" equivalence)]]]]
+ ["[0]" \\parser]
[\\library
- ["[0]" / (.only XML)]])
+ ["[0]" / (.open: "[1]#[0]" equivalence)]])
+
+(def !expect
+ (template (_ <pattern> <value>)
+ [(case <value>
+ <pattern>
+ true
+
+ _
+ false)]))
+
+(def !failure
+ (template (_ <exception> <cases>)
+ [(with_expansions [<<cases>> (template.spliced <cases>)]
+ (do [! random.monad]
+ [expected (random.alphabetic 1)]
+ (_.coverage [<exception>]
+ (`` (and (~~ (with_template [<parser> <input>]
+ [(|> (\\parser.result <parser> (list <input>))
+ (!expect (^.multi {try.#Failure error}
+ (exception.match? <exception> error))))]
+
+ <<cases>>)))))))]))
+
+(def random_label
+ (Random Symbol)
+ (random.and (random.alphabetic 1)
+ (random.alphabetic 1)))
+
+(def random_tag ..random_label)
+(def random_attribute ..random_label)
+
+(def \\parser
+ Test
+ (<| (_.covering \\parser._)
+ (_.for [\\parser.Parser])
+ (all _.and
+ (do [! random.monad]
+ [expected (random.alphabetic 1)]
+ (_.coverage [\\parser.result \\parser.text]
+ (|> (\\parser.result \\parser.text (list {/.#Text expected}))
+ (!expect (^.multi {try.#Success actual}
+ (text#= expected actual))))))
+ (!failure \\parser.unconsumed_inputs
+ [[(<>#in expected)
+ {/.#Text expected}]])
+ (do [! random.monad]
+ [expected (at ! each (|>> {/.#Text}) (random.alphabetic 1))]
+ (_.coverage [\\parser.any]
+ (|> (\\parser.result \\parser.any (list expected))
+ (try#each (/#= expected))
+ (try.else false))))
+ (do [! random.monad]
+ [expected ..random_tag]
+ (_.coverage [\\parser.tag]
+ (|> (\\parser.result (do <>.monad
+ [actual \\parser.tag
+ _ \\parser.any]
+ (in (symbol#= expected actual)))
+ (list {/.#Node expected (dictionary.empty symbol.hash) (list)}))
+ (!expect {try.#Success #1}))))
+ (do [! random.monad]
+ [expected ..random_tag]
+ (_.coverage [\\parser.node]
+ (|> (\\parser.result (\\parser.node expected (<>#in []))
+ (list {/.#Node expected (dictionary.empty symbol.hash) (list)}))
+ (!expect {try.#Success []}))))
+ (!failure \\parser.wrong_tag
+ [[(\\parser.node ["" expected] (<>#in []))
+ {/.#Node [expected ""] (dictionary.empty symbol.hash) (list)}]])
+ (do [! random.monad]
+ [expected_tag ..random_tag
+ expected_attribute ..random_attribute
+ expected_value (random.alphabetic 1)]
+ (_.coverage [\\parser.attribute]
+ (|> (\\parser.result (<| (\\parser.node expected_tag)
+ (<>.after (\\parser.attribute expected_attribute))
+ (<>#in []))
+ (list {/.#Node expected_tag
+ (|> (dictionary.empty symbol.hash)
+ (dictionary.has expected_attribute expected_value))
+ (list)}))
+ (!expect {try.#Success []}))))
+ (!failure \\parser.unknown_attribute
+ [[(\\parser.attribute ["" expected])
+ {/.#Node [expected expected]
+ (|> (dictionary.empty symbol.hash)
+ (dictionary.has [expected ""] expected))
+ (list)}]])
+ (!failure \\parser.empty_input
+ [[(do <>.monad
+ [_ \\parser.any]
+ \\parser.any)
+ {/.#Text expected}]
+ [(do <>.monad
+ [_ \\parser.any]
+ \\parser.text)
+ {/.#Text expected}]
+ [(do <>.monad
+ [_ \\parser.any]
+ (\\parser.node [expected expected]
+ (<>#in [])))
+ {/.#Node [expected expected]
+ (dictionary.empty symbol.hash)
+ (list)}]
+ [(do <>.monad
+ [_ \\parser.any]
+ (\\parser.node [expected expected]
+ (\\parser.attribute [expected expected])))
+ {/.#Node [expected expected]
+ (|> (dictionary.empty symbol.hash)
+ (dictionary.has [expected expected] expected))
+ (list)}]])
+ (!failure \\parser.unexpected_input
+ [[\\parser.text
+ {/.#Node [expected expected] (dictionary.empty symbol.hash) (list)}]
+ [(\\parser.node [expected expected]
+ (<>#in []))
+ {/.#Text expected}]
+ [(\\parser.node [expected expected]
+ (\\parser.attribute [expected expected]))
+ {/.#Text expected}]])
+ (do [! random.monad]
+ [.let [node (is (-> /.Tag (List /.XML) /.XML)
+ (function (_ tag children)
+ {/.#Node tag (dictionary.empty symbol.hash) children}))]
+ parent ..random_tag
+ right ..random_tag
+ wrong (random.only (|>> (symbol#= right) not)
+ ..random_tag)
+ .let [parser (<| (\\parser.node parent)
+ (do <>.monad
+ [_ (<| \\parser.somewhere
+ (\\parser.node right)
+ (<>#in []))
+ _ (<>.some \\parser.any)]
+ (in [])))]
+ repetitions (at ! each (n.% 10) random.nat)]
+ (all _.and
+ (_.coverage [\\parser.somewhere]
+ (|> (\\parser.result parser
+ (list (node parent
+ (list.together (list (list.repeated repetitions (node wrong (list)))
+ (list (node right (list)))
+ (list.repeated repetitions (node wrong (list))))))))
+ (!expect {try.#Success []})))
+ (_.coverage [\\parser.nowhere]
+ (|> (\\parser.result parser
+ (list (node parent
+ (list.repeated repetitions (node wrong (list))))))
+ (!expect (^.multi {try.#Failure error}
+ (exception.match? \\parser.nowhere error)))))
+ ))
+ )))
(def char_range
Text
@@ -58,7 +214,7 @@
(..text 1 10)))
(def .public random
- (Random XML)
+ (Random /.XML)
(random.rec (function (_ random)
(random.or (..text 1 10)
(do random.monad
@@ -94,4 +250,6 @@
(_.coverage [/.Attrs /.attributes]
(dictionary.empty? /.attributes))
)))
+
+ ..\\parser
)))