aboutsummaryrefslogtreecommitdiff
path: root/stdlib/source/test
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--stdlib/source/test/aedifex/parser.lux7
-rw-r--r--stdlib/source/test/lux.lux27
-rw-r--r--stdlib/source/test/lux/control/parser.lux13
-rw-r--r--stdlib/source/test/lux/control/parser/code.lux161
-rw-r--r--stdlib/source/test/lux/control/parser/type.lux323
-rw-r--r--stdlib/source/test/lux/control/remember.lux9
-rw-r--r--stdlib/source/test/lux/data/text.lux8
-rw-r--r--stdlib/source/test/lux/data/text/escape.lux9
-rw-r--r--stdlib/source/test/lux/data/text/regex.lux7
-rw-r--r--stdlib/source/test/lux/debug.lux7
-rw-r--r--stdlib/source/test/lux/documentation.lux7
-rw-r--r--stdlib/source/test/lux/extension.lux9
-rw-r--r--stdlib/source/test/lux/ffi.jvm.lux9
-rw-r--r--stdlib/source/test/lux/macro.lux9
-rw-r--r--stdlib/source/test/lux/macro/code.lux150
-rw-r--r--stdlib/source/test/lux/macro/local.lux8
-rw-r--r--stdlib/source/test/lux/macro/syntax.lux8
-rw-r--r--stdlib/source/test/lux/macro/syntax/check.lux8
-rw-r--r--stdlib/source/test/lux/macro/syntax/declaration.lux9
-rw-r--r--stdlib/source/test/lux/macro/syntax/definition.lux8
-rw-r--r--stdlib/source/test/lux/macro/syntax/export.lux7
-rw-r--r--stdlib/source/test/lux/macro/syntax/input.lux9
-rw-r--r--stdlib/source/test/lux/macro/syntax/type/variable.lux9
-rw-r--r--stdlib/source/test/lux/macro/template.lux7
-rw-r--r--stdlib/source/test/lux/meta/configuration.lux8
-rw-r--r--stdlib/source/test/lux/meta/version.lux7
-rw-r--r--stdlib/source/test/lux/program.lux5
-rw-r--r--stdlib/source/test/lux/type.lux312
-rw-r--r--stdlib/source/test/lux/type/primitive.lux9
-rw-r--r--stdlib/source/test/lux/type/resource.lux7
30 files changed, 564 insertions, 612 deletions
diff --git a/stdlib/source/test/aedifex/parser.lux b/stdlib/source/test/aedifex/parser.lux
index c07e675a4..cd49c6417 100644
--- a/stdlib/source/test/aedifex/parser.lux
+++ b/stdlib/source/test/aedifex/parser.lux
@@ -7,9 +7,7 @@
[hash (.only Hash)]]
[control
["[0]" pipe]
- ["[0]" try]
- [parser
- ["<[0]>" code]]]
+ ["[0]" try]]
[data
["[0]" text]
[collection
@@ -21,7 +19,8 @@
[number
["n" nat]]]
[macro
- ["[0]" code]]]]
+ ["[0]" code (.only)
+ ["<[1]>" \\parser]]]]]
[//
["@[0]" profile]]
[\\program
diff --git a/stdlib/source/test/lux.lux b/stdlib/source/test/lux.lux
index 35ba915da..7f9d94809 100644
--- a/stdlib/source/test/lux.lux
+++ b/stdlib/source/test/lux.lux
@@ -11,9 +11,7 @@
["[0]" io]
["[0]" maybe (.use "[1]#[0]" functor)]
[concurrency
- ["[0]" atom (.only Atom)]]
- [parser
- ["<[0]>" code]]]
+ ["[0]" atom (.only Atom)]]]
[data
["[0]" product]
["[0]" bit (.use "[1]#[0]" equivalence)]
@@ -27,8 +25,9 @@
["[0]" macro (.only)
[syntax (.only syntax)]
["^" pattern]
- ["[0]" code (.use "[1]#[0]" equivalence)]
- ["[0]" template]]
+ ["[0]" template]
+ ["[0]" code (.use "[1]#[0]" equivalence)
+ ["<[1]>" \\parser]]]
["[0]" math
["[0]" random (.use "[1]#[0]" functor)]
[number
@@ -464,39 +463,39 @@
[]]
[(.require [<module/0>'
- [<alias> <module/1>']])
+ [<alias> <module/1>']])
("lux def module" [[<m0/1> <alias>]])
[(<referral> <m0/1>)]]
[(.require ["[0]" <module/0>'
- ["[0]" <module/1>']])
+ ["[0]" <module/1>']])
("lux def module" [[<module/0> <module/0>]
[<m0/1> <module/1>]])
[(<referral> <module/0>)
(<referral> <m0/1>)]]
[(.require ["[0]" <module/0>'
- ["[1]" <module/1>']])
+ ["[1]" <module/1>']])
("lux def module" [[<m0/1> <module/0>]])
[(<referral> <m0/1>)]]
[(.require ["[0]" <module/0>'
- ["[1]" <module/1>'
- ["[2]" <module/2>']]])
+ ["[1]" <module/1>'
+ ["[2]" <module/2>']]])
("lux def module" [[<m0/1/2> <module/0>]])
[(<referral> <m0/1/2>)]]
[(.require [<module/0>'
- ["[0]" <module/1>'
- ["[0]" <//>']]])
+ ["[0]" <module/1>'
+ ["[0]" <//>']]])
("lux def module" [[<m0/1> <module/1>]
[<m0/2> <//>]])
[(<referral> <m0/1>)
(<referral> <m0/2>)]]
[(.require ["[0]" <module/0>'
- [<module/1>'
- ["[0]" <\\>']]])
+ [<module/1>'
+ ["[0]" <\\>']]])
("lux def module" [[<module/0> <module/0>]
[<m2/1> <\\>]])
[(<referral> <module/0>)
diff --git a/stdlib/source/test/lux/control/parser.lux b/stdlib/source/test/lux/control/parser.lux
index b9a6da76f..e977e9df3 100644
--- a/stdlib/source/test/lux/control/parser.lux
+++ b/stdlib/source/test/lux/control/parser.lux
@@ -10,9 +10,7 @@
["$[0]" apply]
["$[0]" monad]]]
[control
- ["[0]" try (.only Try)]
- [parser
- ["<[0]>" code]]]
+ ["[0]" try (.only Try)]]
[data
["[0]" text (.use "[1]#[0]" equivalence)
["%" \\format (.only format)]]
@@ -24,15 +22,14 @@
["n" nat]]]
[macro
[syntax (.only syntax)]
- ["[0]" code]]]]
+ ["[0]" code (.only)
+ ["<[1]>" \\parser]]]]]
[\\library
["[0]" / (.only Parser)]]
["[0]" /
["[1][0]" cli]
- ["[1][0]" code]
["[1][0]" environment]
- ["[1][0]" tree]
- ["[1][0]" type]])
+ ["[1][0]" tree]])
(def (should_fail expected input)
(All (_ a) (-> Text (Try a) Bit))
@@ -381,8 +378,6 @@
..combinators_2
/cli.test
- /code.test
/environment.test
/tree.test
- /type.test
))))
diff --git a/stdlib/source/test/lux/control/parser/code.lux b/stdlib/source/test/lux/control/parser/code.lux
deleted file mode 100644
index a3ba95629..000000000
--- a/stdlib/source/test/lux/control/parser/code.lux
+++ /dev/null
@@ -1,161 +0,0 @@
-(.require
- [library
- [lux (.except local global)
- ["_" test (.only Test)]
- [abstract
- [monad (.only do)]]
- [control
- ["[0]" function]
- ["[0]" try]
- ["<>" parser]]
- [data
- ["[0]" bit]
- ["[0]" text]
- [collection
- ["[0]" list]]]
- [macro
- ["^" pattern]
- ["[0]" code]]
- [math
- ["[0]" random (.only Random) (.use "[1]#[0]" functor)]
- [number
- ["[0]" nat]
- ["[0]" int]
- ["[0]" rev]
- ["[0]" frac]]]
- [meta
- ["[0]" symbol]]]]
- [\\library
- ["[0]" /]])
-
-(def !expect
- (template (_ <pattern> <value>)
- [(case <value>
- <pattern>
- true
-
- _
- false)]))
-
-(def local
- (Random Text)
- (random.lower_case 1))
-
-(def global
- (Random Symbol)
- (all random.and
- (random.lower_case 1)
- (random.lower_case 1)
- ))
-
-(def any_symbol
- (Random Symbol)
- (all random.either
- (random#each (|>> [""])
- ..local)
- ..global
- ))
-
-(def .public test
- Test
- (<| (_.covering /._)
- (_.for [/.Parser])
- (`` (all _.and
- (do [! random.monad]
- [expected (at ! each code.bit random.bit)]
- (_.coverage [/.result]
- (and (|> (/.result /.any (list expected))
- (!expect {try.#Success _}))
- (|> (/.result /.any (list))
- (!expect {try.#Failure _})))))
- (~~ (with_template [<query> <check> <random> <code> <equivalence>]
- [(do [! random.monad]
- [expected <random>
- dummy (|> <random> (random.only (|>> (at <equivalence> = expected) not)))]
- (all _.and
- (_.coverage [<query>]
- (|> (/.result <query> (list (<code> expected)))
- (!expect (^.multi {try.#Success actual}
- (at <equivalence> = expected actual)))))
- (_.coverage [<check>]
- (and (|> (/.result (<check> expected) (list (<code> expected)))
- (!expect {try.#Success []}))
- (|> (/.result (<check> expected) (list (<code> dummy)))
- (!expect {try.#Failure _}))))
- ))]
-
- [/.any /.this (at ! each code.bit random.bit) function.identity code.equivalence]
- [/.bit /.this_bit random.bit code.bit bit.equivalence]
- [/.nat /.this_nat random.nat code.nat nat.equivalence]
- [/.int /.this_int random.int code.int int.equivalence]
- [/.rev /.this_rev random.rev code.rev rev.equivalence]
- [/.frac /.this_frac random.safe_frac code.frac frac.equivalence]
- [/.text /.this_text (random.unicode 1) code.text text.equivalence]
- [/.local /.this_local ..local code.local text.equivalence]
- [/.global /.this_global ..global code.symbol symbol.equivalence]
- [/.symbol /.this_symbol ..any_symbol code.symbol symbol.equivalence]
- ))
- (~~ (with_template [<query> <code>]
- [(do [! random.monad]
- [expected_left random.nat
- expected_right random.int]
- (_.coverage [<query>]
- (|> (/.result (<query> (<>.and /.nat /.int))
- (list (<code> (list (code.nat expected_left)
- (code.int expected_right)))))
- (!expect (^.multi {try.#Success [actual_left actual_right]}
- (and (at nat.equivalence = expected_left actual_left)
- (at int.equivalence = expected_right actual_right)))))))]
-
- [/.form code.form]
- [/.variant code.variant]
- [/.tuple code.tuple]
- ))
- (do [! random.monad]
- [expected_local random.nat
- expected_global random.int]
- (_.coverage [/.locally]
- (|> (/.result (<>.and (/.locally (list (code.nat expected_local)) /.nat)
- /.int)
- (list (code.int expected_global)))
- (!expect (^.multi {try.#Success [actual_local actual_global]}
- (and (at nat.equivalence = expected_local actual_local)
- (at int.equivalence = expected_global actual_global)))))))
- (do [! random.monad]
- [dummy (at ! each code.bit random.bit)]
- (_.coverage [/.end?]
- (|> (/.result (do <>.monad
- [pre /.end?
- _ /.any
- post /.end?]
- (in (and (not pre)
- post)))
- (list dummy))
- (!expect (^.multi {try.#Success verdict}
- verdict)))))
- (do [! random.monad]
- [dummy (at ! each code.bit random.bit)]
- (_.coverage [/.end]
- (and (|> (/.result /.end (list))
- (!expect {try.#Success []}))
- (|> (/.result /.end (list dummy))
- (!expect {try.#Failure _})))))
- (do [! random.monad]
- [expected (at ! each code.bit random.bit)]
- (_.coverage [/.next]
- (|> (/.result (do <>.monad
- [pre /.next
- post /.any]
- (in (and (same? expected pre)
- (same? pre post))))
- (list expected))
- (!expect {try.#Success _}))))
- (do [! random.monad]
- [expected (at ! each code.bit random.bit)]
- (_.coverage [/.not]
- (and (|> (/.result (/.not /.nat) (list expected))
- (!expect (^.multi {try.#Success actual}
- (same? expected actual))))
- (|> (/.result (/.not /.bit) (list expected))
- (!expect {try.#Failure _})))))
- ))))
diff --git a/stdlib/source/test/lux/control/parser/type.lux b/stdlib/source/test/lux/control/parser/type.lux
deleted file mode 100644
index 11f7b7796..000000000
--- a/stdlib/source/test/lux/control/parser/type.lux
+++ /dev/null
@@ -1,323 +0,0 @@
-(.require
- [library
- [lux (.except)
- ["_" test (.only Test)]
- ["[0]" type (.use "[1]#[0]" equivalence)]
- [abstract
- [monad (.only do)]]
- [control
- ["[0]" try]
- ["[0]" exception]]
- [data
- [text
- ["%" \\format (.only format)]]
- [collection
- ["[0]" list]]]
- [macro
- ["^" pattern]]
- [math
- ["[0]" random (.only Random)]
- [number
- ["n" nat]]]
- [meta
- ["[0]" symbol (.use "[1]#[0]" equivalence)]]]]
- [\\library
- ["[0]" / (.only)
- ["/[1]" //]]])
-
-(def !expect
- (template (_ <pattern> <value>)
- [(case <value>
- <pattern>
- true
-
- _
- false)]))
-
-(def primitive
- (Random Type)
- (|> (random.alpha_numeric 1)
- (at random.monad each (function (_ name)
- {.#Primitive name (list)}))))
-
-(def test|matches
- Test
- (<| (_.for [/.types_do_not_match])
- (do [! random.monad]
- [expected ..primitive
- dummy (random.only (|>> (type#= expected) not)
- ..primitive)])
- (all _.and
- (_.coverage [/.exactly]
- (and (|> (/.result (/.exactly expected) expected)
- (!expect {try.#Success []}))
- (|> (/.result (/.exactly expected) dummy)
- (!expect (^.multi {try.#Failure error}
- (exception.match? /.types_do_not_match error))))))
- (_.coverage [/.sub]
- (and (|> (/.result (/.sub expected) expected)
- (!expect {try.#Success []}))
- (|> (/.result (/.sub Any) expected)
- (!expect {try.#Success []}))
- (|> (/.result (/.sub expected) Nothing)
- (!expect {try.#Success []}))
- (|> (/.result (/.sub expected) dummy)
- (!expect (^.multi {try.#Failure error}
- (exception.match? /.types_do_not_match error))))))
- (_.coverage [/.super]
- (and (|> (/.result (/.super expected) expected)
- (!expect {try.#Success []}))
- (|> (/.result (/.super expected) Any)
- (!expect {try.#Success []}))
- (|> (/.result (/.super Nothing) expected)
- (!expect {try.#Success []}))
- (|> (/.result (/.super expected) dummy)
- (!expect (^.multi {try.#Failure error}
- (exception.match? /.types_do_not_match error))))))
- )))
-
-(def test|aggregate
- Test
- (do [! random.monad]
- [expected_left ..primitive
- expected_middle ..primitive
- expected_right ..primitive]
- (`` (all _.and
- (~~ (with_template [<parser> <exception> <good_constructor> <bad_constructor>]
- [(_.coverage [<parser> <exception>]
- (and (|> (/.result (<parser> (all //.and /.any /.any /.any))
- (<good_constructor> (list expected_left expected_middle expected_right)))
- (!expect (^.multi {try.#Success [actual_left actual_middle actual_right]}
- (and (type#= expected_left actual_left)
- (type#= expected_middle actual_middle)
- (type#= expected_right actual_right)))))
- (|> (/.result (<parser> (all //.and /.any /.any /.any))
- (<bad_constructor> (list expected_left expected_middle expected_right)))
- (!expect (^.multi {try.#Failure error}
- (exception.match? <exception> error))))))]
-
- [/.variant /.not_variant type.variant type.tuple]
- [/.tuple /.not_tuple type.tuple type.variant]
- ))
-
- (_.coverage [/.function /.not_function]
- (and (|> (/.result (/.function (all //.and /.any /.any) /.any)
- (type.function (list expected_left expected_middle) expected_right))
- (!expect (^.multi {try.#Success [[actual_left actual_middle] actual_right]}
- (and (type#= expected_left actual_left)
- (type#= expected_middle actual_middle)
- (type#= expected_right actual_right)))))
- (|> (/.result (/.function (all //.and /.any /.any) /.any)
- (type.variant (list expected_left expected_middle expected_right)))
- (!expect (^.multi {try.#Failure error}
- (exception.match? /.not_function error))))))
- (_.coverage [/.applied /.not_application]
- (and (|> (/.result (/.applied (all //.and /.any /.any /.any))
- (type.application (list expected_middle expected_right) expected_left))
- (!expect (^.multi {try.#Success [actual_left actual_middle actual_right]}
- (and (type#= expected_left actual_left)
- (type#= expected_middle actual_middle)
- (type#= expected_right actual_right)))))
- (|> (/.result (/.applied (all //.and /.any /.any /.any))
- (type.variant (list expected_left expected_middle expected_right)))
- (!expect (^.multi {try.#Failure error}
- (exception.match? /.not_application error))))))
- ))))
-
-(def test|parameter
- Test
- (do random.monad
- [quantification ..primitive
- argument ..primitive
- not_parameter ..primitive
- parameter random.nat]
- (all _.and
- (_.coverage [/.not_parameter]
- (|> (/.result /.parameter not_parameter)
- (!expect (^.multi {try.#Failure error}
- (exception.match? /.not_parameter error)))))
- (_.coverage [/.unknown_parameter]
- (|> (/.result /.parameter {.#Parameter parameter})
- (!expect (^.multi {try.#Failure error}
- (exception.match? /.unknown_parameter error)))))
- (_.coverage [/.with_extension]
- (|> (/.result (<| (/.with_extension quantification)
- (/.with_extension argument)
- /.any)
- not_parameter)
- (!expect (^.multi {try.#Success [quantification::binding argument::binding actual]}
- (same? not_parameter actual)))))
- (_.coverage [/.parameter]
- (|> (/.result (<| (/.with_extension quantification)
- (/.with_extension argument)
- /.parameter)
- {.#Parameter 0})
- (!expect {try.#Success [quantification::binding argument::binding _]})))
- (_.coverage [/.argument]
- (let [argument? (is (-> Nat Nat Bit)
- (function (_ @ expected)
- (|> (/.result (<| (/.with_extension quantification)
- (/.with_extension argument)
- (/.with_extension quantification)
- (/.with_extension argument)
- (do //.monad
- [env /.env
- _ /.any]
- (in (/.argument env @))))
- not_parameter)
- (!expect (^.multi {try.#Success [_ _ _ _ actual]}
- (n.= expected actual))))))]
- (and (argument? 0 2)
- (argument? 1 3)
- (argument? 2 0))))
- (_.coverage [/.wrong_parameter]
- (|> (/.result (<| (/.with_extension quantification)
- (/.with_extension argument)
- (/.this_parameter 1))
- {.#Parameter 0})
- (!expect (^.multi {try.#Failure error}
- (exception.match? /.wrong_parameter error)))))
- (_.coverage [/.this_parameter]
- (|> (/.result (<| (/.with_extension quantification)
- (/.with_extension argument)
- (/.this_parameter 0))
- {.#Parameter 0})
- (!expect {try.#Success [quantification::binding argument::binding _]})))
- )))
-
-(def test|polymorphic
- Test
- (do [! random.monad]
- [not_polymorphic ..primitive
- expected_inputs (at ! each (|>> (n.% 10) ++) random.nat)]
- (all _.and
- (_.coverage [/.not_polymorphic]
- (and (|> (/.result (/.polymorphic /.any)
- not_polymorphic)
- (!expect (^.multi {try.#Failure error}
- (exception.match? /.not_polymorphic error))))
- (|> (/.result (/.polymorphic /.any)
- (type.univ_q 0 not_polymorphic))
- (!expect (^.multi {try.#Failure error}
- (exception.match? /.not_polymorphic error))))))
- (_.coverage [/.polymorphic]
- (|> (/.result (/.polymorphic /.any)
- (type.univ_q expected_inputs not_polymorphic))
- (!expect (^.multi {try.#Success [g!poly actual_inputs bodyT]}
- (and (n.= expected_inputs (list.size actual_inputs))
- (same? not_polymorphic bodyT))))))
- )))
-
-(def test|recursive
- Test
- (do random.monad
- [expected ..primitive]
- (all _.and
- (_.coverage [/.recursive]
- (|> (.type_literal (Rec @ expected))
- (/.result (/.recursive /.any))
- (!expect (^.multi {try.#Success [@self actual]}
- (type#= expected actual)))))
- (_.coverage [/.recursive_self]
- (|> (.type_literal (Rec @ @))
- (/.result (/.recursive /.recursive_self))
- (!expect (^.multi {try.#Success [@expected @actual]}
- (same? @expected @actual)))))
- (_.coverage [/.recursive_call]
- (|> (.type_literal (All (self input) (self input)))
- (/.result (/.polymorphic /.recursive_call))
- (!expect {try.#Success [@self inputs ???]})))
- (_.coverage [/.not_recursive]
- (and (|> expected
- (/.result (/.recursive /.any))
- (!expect (^.multi {try.#Failure error}
- (exception.match? /.not_recursive error))))
- (|> expected
- (/.result /.recursive_self)
- (!expect (^.multi {try.#Failure error}
- (exception.match? /.not_recursive error))))))
- )))
-
-(def .public test
- Test
- (<| (_.covering /._)
- (_.for [/.Parser])
- (all _.and
- (do [! random.monad]
- [expected ..primitive]
- (_.coverage [/.result /.any]
- (|> (/.result /.any expected)
- (!expect (^.multi {try.#Success actual}
- (type#= expected actual))))))
- (do [! random.monad]
- [expected ..primitive]
- (_.coverage [/.next /.unconsumed_input]
- (and (|> (/.result (do //.monad
- [actual /.next
- _ /.any]
- (in actual))
- expected)
- (!expect (^.multi {try.#Success actual}
- (type#= expected actual))))
- (|> (/.result /.next expected)
- (!expect (^.multi {try.#Failure error}
- (exception.match? /.unconsumed_input error)))))))
- (do [! random.monad]
- [expected ..primitive]
- (_.coverage [/.empty_input]
- (`` (and (~~ (with_template [<parser>]
- [(|> (/.result (do //.monad
- [_ /.any]
- <parser>)
- expected)
- (!expect (^.multi {try.#Failure error}
- (exception.match? /.empty_input error))))]
-
- [/.any]
- [/.next]
- ))))))
- (do [! random.monad]
- [expected ..primitive]
- (_.coverage [/.Env /.env /.fresh]
- (|> (/.result (do //.monad
- [env /.env
- _ /.any]
- (in env))
- expected)
- (!expect (^.multi {try.#Success environment}
- (same? /.fresh environment))))))
- (do [! random.monad]
- [expected ..primitive
- dummy (random.only (|>> (type#= expected) not)
- ..primitive)]
- (_.coverage [/.local]
- (|> (/.result (do //.monad
- [_ /.any]
- (/.local (list expected)
- /.any))
- dummy)
- (!expect (^.multi {try.#Success actual}
- (type#= expected actual))))))
- (do [! random.monad]
- [expected random.nat]
- (_.coverage [/.existential /.not_existential]
- (|> (/.result /.existential
- {.#Ex expected})
- (!expect (^.multi {try.#Success actual}
- (n.= expected actual))))))
- (do [! random.monad]
- [expected_name (random.and (random.alpha_numeric 1)
- (random.alpha_numeric 1))
- expected_type ..primitive]
- (_.coverage [/.named /.not_named]
- (|> (/.result /.named
- {.#Named expected_name expected_type})
- (!expect (^.multi {try.#Success [actual_name actual_type]}
- (and (symbol#= expected_name actual_name)
- (type#= expected_type actual_type)))))))
- ..test|aggregate
- ..test|matches
- ..test|parameter
- ..test|polymorphic
- ..test|recursive
- )))
diff --git a/stdlib/source/test/lux/control/remember.lux b/stdlib/source/test/lux/control/remember.lux
index 0ddedd7bd..44216d17d 100644
--- a/stdlib/source/test/lux/control/remember.lux
+++ b/stdlib/source/test/lux/control/remember.lux
@@ -8,9 +8,7 @@
[control
["[0]" io]
["[0]" try (.only Try)]
- ["[0]" exception]
- [parser
- ["<[0]>" code]]]
+ ["[0]" exception]]
[data
["[0]" product]
["[0]" text (.only)
@@ -23,8 +21,9 @@
["[0]" instant]
["[0]" duration]]
["[0]" macro (.only)
- ["[0]" code]
- ["[0]" syntax (.only syntax)]]]]
+ ["[0]" syntax (.only syntax)]
+ ["[0]" code (.only)
+ ["<[1]>" \\parser]]]]]
[\\library
["[0]" /]])
diff --git a/stdlib/source/test/lux/data/text.lux b/stdlib/source/test/lux/data/text.lux
index 8a71ca938..0f7e49f03 100644
--- a/stdlib/source/test/lux/data/text.lux
+++ b/stdlib/source/test/lux/data/text.lux
@@ -14,13 +14,12 @@
[functor
["$[0]" contravariant]]]]
[control
+ ["<>" parser]
["[0]" pipe]
["[0]" maybe]
["[0]" try (.only Try)]
["[0]" exception (.only Exception)]
- ["[0]" function]
- ["<>" parser (.only)
- ["<[0]>" code]]]
+ ["[0]" function]]
[data
["[0]" bit]
[collection
@@ -37,7 +36,8 @@
["[1]/[0]" block]]]]
[macro
["^" pattern]
- ["[0]" code]]
+ ["[0]" code (.only)
+ ["<[1]>" \\parser]]]
[math
["[0]" random (.only Random) (.use "[1]#[0]" monad)]
["[0]" modulus]
diff --git a/stdlib/source/test/lux/data/text/escape.lux b/stdlib/source/test/lux/data/text/escape.lux
index b2536f305..86e2a645a 100644
--- a/stdlib/source/test/lux/data/text/escape.lux
+++ b/stdlib/source/test/lux/data/text/escape.lux
@@ -8,9 +8,7 @@
[monad (.only do)]]
[control
["[0]" try]
- ["[0]" exception]
- [parser
- ["<[0]>" code]]]
+ ["[0]" exception]]
[data
["[0]" bit (.use "[1]#[0]" equivalence)]
["[0]" text (.only Char) (.use "[1]#[0]" equivalence)
@@ -19,8 +17,9 @@
["[0]" set (.only Set)]]]
[macro
[syntax (.only syntax)]
- ["[0]" code]
- ["[0]" template]]
+ ["[0]" template]
+ ["[0]" code (.only)
+ ["<[1]>" \\parser]]]
[math
["[0]" random (.only Random)]
[number (.only hex)
diff --git a/stdlib/source/test/lux/data/text/regex.lux b/stdlib/source/test/lux/data/text/regex.lux
index 08403a42d..5988210cd 100644
--- a/stdlib/source/test/lux/data/text/regex.lux
+++ b/stdlib/source/test/lux/data/text/regex.lux
@@ -6,16 +6,15 @@
[monad (.only do)]]
[control
["[0]" pipe]
- ["[0]" try]
- [parser
- ["<[0]>" code]]]
+ ["[0]" try]]
[data
["[0]" text (.use "[1]#[0]" equivalence)
["%" \\format (.only format)]
["<[1]>" \\parser (.only Parser)]]]
["[0]" macro (.only)
[syntax (.only syntax)]
- ["[0]" code]]
+ ["[0]" code (.only)
+ ["<[1]>" \\parser]]]
[math
[number (.only hex)]
["[0]" random]]]]
diff --git a/stdlib/source/test/lux/debug.lux b/stdlib/source/test/lux/debug.lux
index a789cdaf6..978f42916 100644
--- a/stdlib/source/test/lux/debug.lux
+++ b/stdlib/source/test/lux/debug.lux
@@ -7,9 +7,7 @@
[monad (.only do)]]
[control
["[0]" try (.use "[1]#[0]" functor)]
- ["[0]" exception]
- [parser
- ["<[0]>" code]]]
+ ["[0]" exception]]
[data
["[0]" text (.use "[1]#[0]" equivalence)
["%" \\format (.only format)]]
@@ -20,7 +18,8 @@
[xml (.only XML)]]]
["[0]" macro (.only)
[syntax (.only syntax)]
- ["[0]" code]]
+ ["[0]" code (.only)
+ ["<[1]>" \\parser]]]
[math
["[0]" random (.only Random)]
[number
diff --git a/stdlib/source/test/lux/documentation.lux b/stdlib/source/test/lux/documentation.lux
index 001e79cfc..8054dbbcc 100644
--- a/stdlib/source/test/lux/documentation.lux
+++ b/stdlib/source/test/lux/documentation.lux
@@ -5,9 +5,7 @@
["[0]" meta]
[control
["[0]" try]
- ["[0]" exception]
- [parser
- ["<[0]>" code]]]
+ ["[0]" exception]]
[data
["[0]" text (.use "[1]#[0]" equivalence)
["%" \\format]]
@@ -16,7 +14,8 @@
["[0]" macro (.only)
[syntax (.only syntax)]
["[0]" template]
- ["[0]" code]]]]
+ ["[0]" code (.only)
+ ["<[1]>" \\parser]]]]]
[\\library
["[0]" /]])
diff --git a/stdlib/source/test/lux/extension.lux b/stdlib/source/test/lux/extension.lux
index c61e11805..e23bd23ea 100644
--- a/stdlib/source/test/lux/extension.lux
+++ b/stdlib/source/test/lux/extension.lux
@@ -19,9 +19,8 @@
[abstract
["[0]" monad (.only do)]]
[control
- ["[0]" try (.use "[1]#[0]" functor)]
- ["<>" parser (.only)
- ["<[0]>" code]]]
+ ["<>" parser]
+ ["[0]" try (.use "[1]#[0]" functor)]]
[data
["[0]" product]
["[0]" binary (.only)
@@ -32,7 +31,9 @@
["[0]" sequence]
["[0]" list (.use "[1]#[0]" functor)]]]
[macro
- ["[0]" template]]
+ ["[0]" template]
+ ["[0]" code
+ ["<[1]>" \\parser]]]
[math
["[0]" random]
[number
diff --git a/stdlib/source/test/lux/ffi.jvm.lux b/stdlib/source/test/lux/ffi.jvm.lux
index 3c6ded17e..f22bb70c1 100644
--- a/stdlib/source/test/lux/ffi.jvm.lux
+++ b/stdlib/source/test/lux/ffi.jvm.lux
@@ -12,9 +12,7 @@
["[0]" io]
["[0]" pipe]
["[0]" try (.use "[1]#[0]" functor)]
- ["[0]" exception]
- [parser
- ["<[0]>" code]]]
+ ["[0]" exception]]
[data
["[0]" bit (.use "[1]#[0]" equivalence)]
["[0]" text (.use "[1]#[0]" equivalence)
@@ -23,8 +21,9 @@
["[0]" array (.only Array)]]]
["[0]" macro (.only)
[syntax (.only syntax)]
- ["[0]" code]
- ["[0]" template]]
+ ["[0]" template]
+ ["[0]" code (.only)
+ ["<[1]>" \\parser]]]
[math
["[0]" random (.only Random) (.use "[1]#[0]" monad)]
[number (.only hex)
diff --git a/stdlib/source/test/lux/macro.lux b/stdlib/source/test/lux/macro.lux
index 9368e2a0f..3f6e3fe92 100644
--- a/stdlib/source/test/lux/macro.lux
+++ b/stdlib/source/test/lux/macro.lux
@@ -6,9 +6,7 @@
[abstract
[monad (.only do)]]
[control
- ["[0]" try (.use "[1]#[0]" functor)]
- [parser
- ["<[0]>" code]]]
+ ["[0]" try (.use "[1]#[0]" functor)]]
[data
["[0]" bit (.use "[1]#[0]" equivalence)]
["[0]" text (.only)
@@ -27,8 +25,9 @@
[\\library
["[0]" / (.only)
[syntax (.only syntax)]
- ["[0]" code (.use "[1]#[0]" equivalence)]
- ["[0]" template]]]
+ ["[0]" template]
+ ["[0]" code (.use "[1]#[0]" equivalence)
+ ["<[1]>" \\parser]]]]
["[0]" /
["[1][0]" code]
["[1][0]" local]
diff --git a/stdlib/source/test/lux/macro/code.lux b/stdlib/source/test/lux/macro/code.lux
index 172aeb2ee..a566b030d 100644
--- a/stdlib/source/test/lux/macro/code.lux
+++ b/stdlib/source/test/lux/macro/code.lux
@@ -1,32 +1,174 @@
(.require
[library
- [lux (.except)
+ [lux (.except local global)
["_" test (.only Test)]
[abstract
[monad (.only do)]
[\\specification
["$[0]" equivalence]]]
[control
+ ["<>" parser]
+ ["[0]" function]
["[0]" try (.only Try)]]
[data
+ ["[0]" bit]
["[0]" product]
["[0]" text]
[collection
["[0]" list (.use "[1]#[0]" functor)]]]
+ [macro
+ ["^" pattern]]
[math
["[0]" random (.only Random) (.use "[1]#[0]" monad)]
[number
- ["n" nat]]]
+ ["[0]" nat]
+ ["[0]" int]
+ ["[0]" rev]
+ ["[0]" frac]]]
[meta
+ ["[0]" symbol]
["[0]" location]]
[tool
[compiler
[language
[lux
["[0]" syntax]]]]]]]
+ ["[0]" \\parser]
[\\library
["[0]" /]])
+(def !expect
+ (template (_ <pattern> <value>)
+ [(case <value>
+ <pattern>
+ true
+
+ _
+ false)]))
+
+(def local
+ (Random Text)
+ (random.lower_case 1))
+
+(def global
+ (Random Symbol)
+ (all random.and
+ (random.lower_case 1)
+ (random.lower_case 1)
+ ))
+
+(def any_symbol
+ (Random Symbol)
+ (all random.either
+ (random#each (|>> [""])
+ ..local)
+ ..global
+ ))
+
+(def \\parser
+ Test
+ (<| (_.covering \\parser._)
+ (_.for [\\parser.Parser])
+ (`` (all _.and
+ (do [! random.monad]
+ [expected (at ! each /.bit random.bit)]
+ (_.coverage [\\parser.result]
+ (and (|> (\\parser.result \\parser.any (list expected))
+ (!expect {try.#Success _}))
+ (|> (\\parser.result \\parser.any (list))
+ (!expect {try.#Failure _})))))
+ (~~ (with_template [<query> <check> <random> <code> <equivalence>]
+ [(do [! random.monad]
+ [expected <random>
+ dummy (|> <random> (random.only (|>> (at <equivalence> = expected) not)))]
+ (all _.and
+ (_.coverage [<query>]
+ (|> (\\parser.result <query> (list (<code> expected)))
+ (!expect (^.multi {try.#Success actual}
+ (at <equivalence> = expected actual)))))
+ (_.coverage [<check>]
+ (and (|> (\\parser.result (<check> expected) (list (<code> expected)))
+ (!expect {try.#Success []}))
+ (|> (\\parser.result (<check> expected) (list (<code> dummy)))
+ (!expect {try.#Failure _}))))
+ ))]
+
+ [\\parser.any \\parser.this (at ! each /.bit random.bit) function.identity /.equivalence]
+ [\\parser.bit \\parser.this_bit random.bit /.bit bit.equivalence]
+ [\\parser.nat \\parser.this_nat random.nat /.nat nat.equivalence]
+ [\\parser.int \\parser.this_int random.int /.int int.equivalence]
+ [\\parser.rev \\parser.this_rev random.rev /.rev rev.equivalence]
+ [\\parser.frac \\parser.this_frac random.safe_frac /.frac frac.equivalence]
+ [\\parser.text \\parser.this_text (random.unicode 1) /.text text.equivalence]
+ [\\parser.local \\parser.this_local ..local /.local text.equivalence]
+ [\\parser.global \\parser.this_global ..global /.symbol symbol.equivalence]
+ [\\parser.symbol \\parser.this_symbol ..any_symbol /.symbol symbol.equivalence]
+ ))
+ (~~ (with_template [<query> <code>]
+ [(do [! random.monad]
+ [expected_left random.nat
+ expected_right random.int]
+ (_.coverage [<query>]
+ (|> (\\parser.result (<query> (<>.and \\parser.nat \\parser.int))
+ (list (<code> (list (/.nat expected_left)
+ (/.int expected_right)))))
+ (!expect (^.multi {try.#Success [actual_left actual_right]}
+ (and (at nat.equivalence = expected_left actual_left)
+ (at int.equivalence = expected_right actual_right)))))))]
+
+ [\\parser.form /.form]
+ [\\parser.variant /.variant]
+ [\\parser.tuple /.tuple]
+ ))
+ (do [! random.monad]
+ [expected_local random.nat
+ expected_global random.int]
+ (_.coverage [\\parser.locally]
+ (|> (\\parser.result (<>.and (\\parser.locally (list (/.nat expected_local)) \\parser.nat)
+ \\parser.int)
+ (list (/.int expected_global)))
+ (!expect (^.multi {try.#Success [actual_local actual_global]}
+ (and (at nat.equivalence = expected_local actual_local)
+ (at int.equivalence = expected_global actual_global)))))))
+ (do [! random.monad]
+ [dummy (at ! each /.bit random.bit)]
+ (_.coverage [\\parser.end?]
+ (|> (\\parser.result (do <>.monad
+ [pre \\parser.end?
+ _ \\parser.any
+ post \\parser.end?]
+ (in (and (not pre)
+ post)))
+ (list dummy))
+ (!expect (^.multi {try.#Success verdict}
+ verdict)))))
+ (do [! random.monad]
+ [dummy (at ! each /.bit random.bit)]
+ (_.coverage [\\parser.end]
+ (and (|> (\\parser.result \\parser.end (list))
+ (!expect {try.#Success []}))
+ (|> (\\parser.result \\parser.end (list dummy))
+ (!expect {try.#Failure _})))))
+ (do [! random.monad]
+ [expected (at ! each /.bit random.bit)]
+ (_.coverage [\\parser.next]
+ (|> (\\parser.result (do <>.monad
+ [pre \\parser.next
+ post \\parser.any]
+ (in (and (same? expected pre)
+ (same? pre post))))
+ (list expected))
+ (!expect {try.#Success _}))))
+ (do [! random.monad]
+ [expected (at ! each /.bit random.bit)]
+ (_.coverage [\\parser.not]
+ (and (|> (\\parser.result (\\parser.not \\parser.nat) (list expected))
+ (!expect (^.multi {try.#Success actual}
+ (same? expected actual))))
+ (|> (\\parser.result (\\parser.not \\parser.bit) (list expected))
+ (!expect {try.#Failure _})))))
+ ))))
+
(def random_text
(Random Text)
(random.alphabetic 10))
@@ -38,7 +180,7 @@
(def (random_sequence random)
(All (_ a) (-> (Random a) (Random (List a))))
(do [! random.monad]
- [size (|> random.nat (at ! each (n.% 3)))]
+ [size (|> random.nat (at ! each (nat.% 3)))]
(random.list size random)))
(def .public random
@@ -171,4 +313,6 @@
(at /.equivalence =
expected
(/.replaced original substitute sample))))
+
+ ..\\parser
)))
diff --git a/stdlib/source/test/lux/macro/local.lux b/stdlib/source/test/lux/macro/local.lux
index 708741dfe..b86a299b8 100644
--- a/stdlib/source/test/lux/macro/local.lux
+++ b/stdlib/source/test/lux/macro/local.lux
@@ -6,10 +6,9 @@
[abstract
[monad (.only do)]]
[control
+ ["<>" parser]
["[0]" try]
- ["[0]" exception]
- ["<>" parser (.only)
- ["<[0]>" code]]]
+ ["[0]" exception]]
[data
[text
["%" \\format]]
@@ -19,7 +18,8 @@
["[0]" plist]]]]
["[0]" macro (.only)
[syntax (.only syntax)]
- ["[0]" code]]
+ ["[0]" code (.only)
+ ["<[1]>" \\parser]]]
[math
["[0]" random (.only Random)]
[number
diff --git a/stdlib/source/test/lux/macro/syntax.lux b/stdlib/source/test/lux/macro/syntax.lux
index f39809d9b..c973ed03c 100644
--- a/stdlib/source/test/lux/macro/syntax.lux
+++ b/stdlib/source/test/lux/macro/syntax.lux
@@ -4,15 +4,15 @@
["_" test (.only Test)]
[abstract
[monad (.only do)]]
- [control
- [parser
- ["<[0]>" code]]]
[math
["[0]" random]
[number
["n" nat]]]]]
[\\library
- ["[0]" /]]
+ ["[0]" / (.only)
+ [//
+ ["[0]" code
+ ["<[1]>" \\parser]]]]]
["[0]" /
["[1][0]" check]
["[1][0]" declaration]
diff --git a/stdlib/source/test/lux/macro/syntax/check.lux b/stdlib/source/test/lux/macro/syntax/check.lux
index b671b807e..b8e3aa34b 100644
--- a/stdlib/source/test/lux/macro/syntax/check.lux
+++ b/stdlib/source/test/lux/macro/syntax/check.lux
@@ -7,13 +7,13 @@
[\\specification
["$[0]" equivalence]]]
[control
- ["[0]" try]
- ["<>" parser (.only)
- ["<[0]>" code]]]
+ ["<>" parser]
+ ["[0]" try]]
[math
["[0]" random (.only Random)]]
[macro
- ["[0]" code (.use "[1]#[0]" equivalence)]]]]
+ ["[0]" code (.use "[1]#[0]" equivalence)
+ ["<[1]>" \\parser]]]]]
[\\library
["[0]" /]]
["$[0]" ///
diff --git a/stdlib/source/test/lux/macro/syntax/declaration.lux b/stdlib/source/test/lux/macro/syntax/declaration.lux
index 9a23d3051..b6c571170 100644
--- a/stdlib/source/test/lux/macro/syntax/declaration.lux
+++ b/stdlib/source/test/lux/macro/syntax/declaration.lux
@@ -7,15 +7,16 @@
[\\specification
["$[0]" equivalence]]]
[control
- ["[0]" try]
- [parser
- ["<[0]>" code]]]
+ ["[0]" try]]
[math
["[0]" random (.only Random)]
[number
["n" nat]]]]]
[\\library
- ["[0]" /]])
+ ["[0]" / (.only)
+ [///
+ ["[0]" code
+ ["<[1]>" \\parser]]]]])
(def .public random
(Random /.Declaration)
diff --git a/stdlib/source/test/lux/macro/syntax/definition.lux b/stdlib/source/test/lux/macro/syntax/definition.lux
index 8238856c9..eab4879a0 100644
--- a/stdlib/source/test/lux/macro/syntax/definition.lux
+++ b/stdlib/source/test/lux/macro/syntax/definition.lux
@@ -7,12 +7,12 @@
[\\specification
["$[0]" equivalence]]]
[control
+ ["<>" parser]
["[0]" try]
- ["[0]" exception]
- ["<>" parser (.only)
- ["<[0]>" code]]]
+ ["[0]" exception]]
[macro
- ["[0]" code (.use "[1]#[0]" equivalence)]]
+ ["[0]" code (.use "[1]#[0]" equivalence)
+ ["<[1]>" \\parser]]]
[math
["[0]" random (.only Random)]]
[meta
diff --git a/stdlib/source/test/lux/macro/syntax/export.lux b/stdlib/source/test/lux/macro/syntax/export.lux
index 5d2a0d23a..3ef76a0bb 100644
--- a/stdlib/source/test/lux/macro/syntax/export.lux
+++ b/stdlib/source/test/lux/macro/syntax/export.lux
@@ -6,11 +6,10 @@
[monad (.only do)]]
[control
["[0]" maybe]
- ["[0]" try (.use "[1]#[0]" functor)]
- [parser
- ["<[0]>" code]]]
+ ["[0]" try (.use "[1]#[0]" functor)]]
[macro
- ["[0]" code (.use "[1]#[0]" equivalence)]]
+ ["[0]" code (.use "[1]#[0]" equivalence)
+ ["<[1]>" \\parser]]]
[math
["[0]" random (.only Random)]
[number
diff --git a/stdlib/source/test/lux/macro/syntax/input.lux b/stdlib/source/test/lux/macro/syntax/input.lux
index 9a865ff13..7768f7c6b 100644
--- a/stdlib/source/test/lux/macro/syntax/input.lux
+++ b/stdlib/source/test/lux/macro/syntax/input.lux
@@ -7,9 +7,7 @@
[\\specification
["$[0]" equivalence]]]
[control
- ["[0]" try]
- [parser
- ["<[0]>" code]]]
+ ["[0]" try]]
[data
[collection
["[0]" list]]]
@@ -18,7 +16,10 @@
[number
["n" nat]]]]]
[\\library
- ["[0]" /]]
+ ["[0]" / (.only)
+ [///
+ ["[0]" code
+ ["<[1]>" \\parser]]]]]
["$[0]" ///
["[1][0]" code]])
diff --git a/stdlib/source/test/lux/macro/syntax/type/variable.lux b/stdlib/source/test/lux/macro/syntax/type/variable.lux
index f242a972a..1970a6ef8 100644
--- a/stdlib/source/test/lux/macro/syntax/type/variable.lux
+++ b/stdlib/source/test/lux/macro/syntax/type/variable.lux
@@ -7,13 +7,14 @@
[\\specification
["$[0]" equivalence]]]
[control
- ["[0]" try (.use "[1]#[0]" functor)]
- [parser
- ["<[0]>" code]]]
+ ["[0]" try (.use "[1]#[0]" functor)]]
[math
["[0]" random (.only Random)]]]]
[\\library
- ["[0]" /]])
+ ["[0]" / (.only)
+ [////
+ ["[0]" code
+ ["<[1]>" \\parser]]]]])
(def .public random
(Random /.Variable)
diff --git a/stdlib/source/test/lux/macro/template.lux b/stdlib/source/test/lux/macro/template.lux
index 2b8733643..4c48e5561 100644
--- a/stdlib/source/test/lux/macro/template.lux
+++ b/stdlib/source/test/lux/macro/template.lux
@@ -6,15 +6,14 @@
[monad (.only do)]]
[control
["[0]" try]
- ["[0]" exception]
- [parser
- ["<[0]>" code]]]
+ ["[0]" exception]]
[data
[collection
["[0]" list]]]
["[0]" macro (.only)
[syntax (.only syntax)]
- ["[0]" code]]
+ ["[0]" code (.only)
+ ["<[1]>" \\parser]]]
[math
["[0]" random (.only Random)]
[number
diff --git a/stdlib/source/test/lux/meta/configuration.lux b/stdlib/source/test/lux/meta/configuration.lux
index c6c78c549..e1a546d82 100644
--- a/stdlib/source/test/lux/meta/configuration.lux
+++ b/stdlib/source/test/lux/meta/configuration.lux
@@ -9,10 +9,9 @@
["$[0]" equivalence]
["$[0]" monoid]]]
[control
+ ["<>" parser]
["[0]" try (.use "[1]#[0]" functor)]
- ["[0]" exception]
- ["<>" parser (.only)
- ["<[0]>" code]]]
+ ["[0]" exception]]
[data
["[0]" text (.only)
["<[1]>" \\parser]]
@@ -20,7 +19,8 @@
["[0]" list]]]
["[0]" macro (.only)
[syntax (.only syntax)]
- ["[0]" code]]
+ ["[0]" code (.only)
+ ["<[1]>" \\parser]]]
[math
["[0]" random (.only Random) (.use "[1]#[0]" monad)]]]]
[\\library
diff --git a/stdlib/source/test/lux/meta/version.lux b/stdlib/source/test/lux/meta/version.lux
index 360cbaa5f..ff70f25a0 100644
--- a/stdlib/source/test/lux/meta/version.lux
+++ b/stdlib/source/test/lux/meta/version.lux
@@ -8,14 +8,13 @@
[monad (.only do)]]
[control
["[0]" try]
- ["[0]" exception]
- [parser
- ["<[0]>" code]]]
+ ["[0]" exception]]
[data
["[0]" text]]
["[0]" macro (.only)
[syntax (.only syntax)]
- ["[0]" code]]
+ ["[0]" code (.only)
+ ["<[1]>" \\parser]]]
[math
["[0]" random]
[number
diff --git a/stdlib/source/test/lux/program.lux b/stdlib/source/test/lux/program.lux
index fb87397ee..6b462da5e 100644
--- a/stdlib/source/test/lux/program.lux
+++ b/stdlib/source/test/lux/program.lux
@@ -8,14 +8,15 @@
["[0]" io]
["[0]" try]
["<>" parser (.only)
- ["<[0]>" code]
["<[0]>" cli]]]
[data
["[0]" text]
[collection
["[0]" list]]]
[macro
- [syntax (.only syntax)]]
+ [syntax (.only syntax)]
+ ["[0]" code
+ ["<[1]>" \\parser]]]
[math
["[0]" random]]]]
[\\library
diff --git a/stdlib/source/test/lux/type.lux b/stdlib/source/test/lux/type.lux
index 436dc4e85..9f753b1d0 100644
--- a/stdlib/source/test/lux/type.lux
+++ b/stdlib/source/test/lux/type.lux
@@ -7,11 +7,15 @@
[\\specification
["$[0]" equivalence]]]
[control
+ ["<>" parser]
["[0]" pipe]
- ["[0]" maybe]]
+ ["[0]" maybe]
+ ["[0]" try]
+ ["[0]" exception]]
[data
["[0]" bit (.use "[1]#[0]" equivalence)]
- ["[0]" text (.use "[1]#[0]" equivalence)]
+ ["[0]" text (.use "[1]#[0]" equivalence)
+ ["%" \\format (.only format)]]
[collection
["[0]" list]
["[0]" array]]]
@@ -21,7 +25,10 @@
[math
["[0]" random (.only Random) (.use "[1]#[0]" monad)]
[number
- ["n" nat]]]]]
+ ["n" nat]]]
+ [meta
+ ["[0]" symbol (.use "[1]#[0]" equivalence)]]]]
+ ["[0]" \\parser]
[\\library
["[0]" / (.use "[1]#[0]" equivalence)]]
["[0]" /
@@ -35,6 +42,303 @@
["[1][0]" unit]
["[1][0]" variance]])
+(def !expect
+ (template (_ <pattern> <value>)
+ [(case <value>
+ <pattern>
+ true
+
+ _
+ false)]))
+
+(def primitive
+ (Random Type)
+ (|> (random.alpha_numeric 1)
+ (at random.monad each (function (_ name)
+ {.#Primitive name (list)}))))
+
+(def test|matches
+ Test
+ (<| (_.for [\\parser.types_do_not_match])
+ (do [! random.monad]
+ [expected ..primitive
+ dummy (random.only (|>> (/#= expected) not)
+ ..primitive)])
+ (all _.and
+ (_.coverage [\\parser.exactly]
+ (and (|> (\\parser.result (\\parser.exactly expected) expected)
+ (!expect {try.#Success []}))
+ (|> (\\parser.result (\\parser.exactly expected) dummy)
+ (!expect (^.multi {try.#Failure error}
+ (exception.match? \\parser.types_do_not_match error))))))
+ (_.coverage [\\parser.sub]
+ (and (|> (\\parser.result (\\parser.sub expected) expected)
+ (!expect {try.#Success []}))
+ (|> (\\parser.result (\\parser.sub Any) expected)
+ (!expect {try.#Success []}))
+ (|> (\\parser.result (\\parser.sub expected) Nothing)
+ (!expect {try.#Success []}))
+ (|> (\\parser.result (\\parser.sub expected) dummy)
+ (!expect (^.multi {try.#Failure error}
+ (exception.match? \\parser.types_do_not_match error))))))
+ (_.coverage [\\parser.super]
+ (and (|> (\\parser.result (\\parser.super expected) expected)
+ (!expect {try.#Success []}))
+ (|> (\\parser.result (\\parser.super expected) Any)
+ (!expect {try.#Success []}))
+ (|> (\\parser.result (\\parser.super Nothing) expected)
+ (!expect {try.#Success []}))
+ (|> (\\parser.result (\\parser.super expected) dummy)
+ (!expect (^.multi {try.#Failure error}
+ (exception.match? \\parser.types_do_not_match error))))))
+ )))
+
+(def test|aggregate
+ Test
+ (do [! random.monad]
+ [expected_left ..primitive
+ expected_middle ..primitive
+ expected_right ..primitive]
+ (`` (all _.and
+ (~~ (with_template [<parser> <exception> <good_constructor> <bad_constructor>]
+ [(_.coverage [<parser> <exception>]
+ (and (|> (\\parser.result (<parser> (all <>.and \\parser.any \\parser.any \\parser.any))
+ (<good_constructor> (list expected_left expected_middle expected_right)))
+ (!expect (^.multi {try.#Success [actual_left actual_middle actual_right]}
+ (and (/#= expected_left actual_left)
+ (/#= expected_middle actual_middle)
+ (/#= expected_right actual_right)))))
+ (|> (\\parser.result (<parser> (all <>.and \\parser.any \\parser.any \\parser.any))
+ (<bad_constructor> (list expected_left expected_middle expected_right)))
+ (!expect (^.multi {try.#Failure error}
+ (exception.match? <exception> error))))))]
+
+ [\\parser.variant \\parser.not_variant /.variant /.tuple]
+ [\\parser.tuple \\parser.not_tuple /.tuple /.variant]
+ ))
+
+ (_.coverage [\\parser.function \\parser.not_function]
+ (and (|> (\\parser.result (\\parser.function (all <>.and \\parser.any \\parser.any) \\parser.any)
+ (/.function (list expected_left expected_middle) expected_right))
+ (!expect (^.multi {try.#Success [[actual_left actual_middle] actual_right]}
+ (and (/#= expected_left actual_left)
+ (/#= expected_middle actual_middle)
+ (/#= expected_right actual_right)))))
+ (|> (\\parser.result (\\parser.function (all <>.and \\parser.any \\parser.any) \\parser.any)
+ (/.variant (list expected_left expected_middle expected_right)))
+ (!expect (^.multi {try.#Failure error}
+ (exception.match? \\parser.not_function error))))))
+ (_.coverage [\\parser.applied \\parser.not_application]
+ (and (|> (\\parser.result (\\parser.applied (all <>.and \\parser.any \\parser.any \\parser.any))
+ (/.application (list expected_middle expected_right) expected_left))
+ (!expect (^.multi {try.#Success [actual_left actual_middle actual_right]}
+ (and (/#= expected_left actual_left)
+ (/#= expected_middle actual_middle)
+ (/#= expected_right actual_right)))))
+ (|> (\\parser.result (\\parser.applied (all <>.and \\parser.any \\parser.any \\parser.any))
+ (/.variant (list expected_left expected_middle expected_right)))
+ (!expect (^.multi {try.#Failure error}
+ (exception.match? \\parser.not_application error))))))
+ ))))
+
+(def test|parameter
+ Test
+ (do random.monad
+ [quantification ..primitive
+ argument ..primitive
+ not_parameter ..primitive
+ parameter random.nat]
+ (all _.and
+ (_.coverage [\\parser.not_parameter]
+ (|> (\\parser.result \\parser.parameter not_parameter)
+ (!expect (^.multi {try.#Failure error}
+ (exception.match? \\parser.not_parameter error)))))
+ (_.coverage [\\parser.unknown_parameter]
+ (|> (\\parser.result \\parser.parameter {.#Parameter parameter})
+ (!expect (^.multi {try.#Failure error}
+ (exception.match? \\parser.unknown_parameter error)))))
+ (_.coverage [\\parser.with_extension]
+ (|> (\\parser.result (<| (\\parser.with_extension quantification)
+ (\\parser.with_extension argument)
+ \\parser.any)
+ not_parameter)
+ (!expect (^.multi {try.#Success [quantification::binding argument::binding actual]}
+ (same? not_parameter actual)))))
+ (_.coverage [\\parser.parameter]
+ (|> (\\parser.result (<| (\\parser.with_extension quantification)
+ (\\parser.with_extension argument)
+ \\parser.parameter)
+ {.#Parameter 0})
+ (!expect {try.#Success [quantification::binding argument::binding _]})))
+ (_.coverage [\\parser.argument]
+ (let [argument? (is (-> Nat Nat Bit)
+ (function (_ @ expected)
+ (|> (\\parser.result (<| (\\parser.with_extension quantification)
+ (\\parser.with_extension argument)
+ (\\parser.with_extension quantification)
+ (\\parser.with_extension argument)
+ (do <>.monad
+ [env \\parser.env
+ _ \\parser.any]
+ (in (\\parser.argument env @))))
+ not_parameter)
+ (!expect (^.multi {try.#Success [_ _ _ _ actual]}
+ (n.= expected actual))))))]
+ (and (argument? 0 2)
+ (argument? 1 3)
+ (argument? 2 0))))
+ (_.coverage [\\parser.wrong_parameter]
+ (|> (\\parser.result (<| (\\parser.with_extension quantification)
+ (\\parser.with_extension argument)
+ (\\parser.this_parameter 1))
+ {.#Parameter 0})
+ (!expect (^.multi {try.#Failure error}
+ (exception.match? \\parser.wrong_parameter error)))))
+ (_.coverage [\\parser.this_parameter]
+ (|> (\\parser.result (<| (\\parser.with_extension quantification)
+ (\\parser.with_extension argument)
+ (\\parser.this_parameter 0))
+ {.#Parameter 0})
+ (!expect {try.#Success [quantification::binding argument::binding _]})))
+ )))
+
+(def test|polymorphic
+ Test
+ (do [! random.monad]
+ [not_polymorphic ..primitive
+ expected_inputs (at ! each (|>> (n.% 10) ++) random.nat)]
+ (all _.and
+ (_.coverage [\\parser.not_polymorphic]
+ (and (|> (\\parser.result (\\parser.polymorphic \\parser.any)
+ not_polymorphic)
+ (!expect (^.multi {try.#Failure error}
+ (exception.match? \\parser.not_polymorphic error))))
+ (|> (\\parser.result (\\parser.polymorphic \\parser.any)
+ (/.univ_q 0 not_polymorphic))
+ (!expect (^.multi {try.#Failure error}
+ (exception.match? \\parser.not_polymorphic error))))))
+ (_.coverage [\\parser.polymorphic]
+ (|> (\\parser.result (\\parser.polymorphic \\parser.any)
+ (/.univ_q expected_inputs not_polymorphic))
+ (!expect (^.multi {try.#Success [g!poly actual_inputs bodyT]}
+ (and (n.= expected_inputs (list.size actual_inputs))
+ (same? not_polymorphic bodyT))))))
+ )))
+
+(def test|recursive
+ Test
+ (do random.monad
+ [expected ..primitive]
+ (all _.and
+ (_.coverage [\\parser.recursive]
+ (|> (.type_literal (Rec @ expected))
+ (\\parser.result (\\parser.recursive \\parser.any))
+ (!expect (^.multi {try.#Success [@self actual]}
+ (/#= expected actual)))))
+ (_.coverage [\\parser.recursive_self]
+ (|> (.type_literal (Rec @ @))
+ (\\parser.result (\\parser.recursive \\parser.recursive_self))
+ (!expect (^.multi {try.#Success [@expected @actual]}
+ (same? @expected @actual)))))
+ (_.coverage [\\parser.recursive_call]
+ (|> (.type_literal (All (self input) (self input)))
+ (\\parser.result (\\parser.polymorphic \\parser.recursive_call))
+ (!expect {try.#Success [@self inputs ???]})))
+ (_.coverage [\\parser.not_recursive]
+ (and (|> expected
+ (\\parser.result (\\parser.recursive \\parser.any))
+ (!expect (^.multi {try.#Failure error}
+ (exception.match? \\parser.not_recursive error))))
+ (|> expected
+ (\\parser.result \\parser.recursive_self)
+ (!expect (^.multi {try.#Failure error}
+ (exception.match? \\parser.not_recursive error))))))
+ )))
+
+(def \\parser
+ Test
+ (<| (_.covering \\parser._)
+ (_.for [\\parser.Parser])
+ (all _.and
+ (do [! random.monad]
+ [expected ..primitive]
+ (_.coverage [\\parser.result \\parser.any]
+ (|> (\\parser.result \\parser.any expected)
+ (!expect (^.multi {try.#Success actual}
+ (/#= expected actual))))))
+ (do [! random.monad]
+ [expected ..primitive]
+ (_.coverage [\\parser.next \\parser.unconsumed_input]
+ (and (|> (\\parser.result (do <>.monad
+ [actual \\parser.next
+ _ \\parser.any]
+ (in actual))
+ expected)
+ (!expect (^.multi {try.#Success actual}
+ (/#= expected actual))))
+ (|> (\\parser.result \\parser.next expected)
+ (!expect (^.multi {try.#Failure error}
+ (exception.match? \\parser.unconsumed_input error)))))))
+ (do [! random.monad]
+ [expected ..primitive]
+ (_.coverage [\\parser.empty_input]
+ (`` (and (~~ (with_template [<parser>]
+ [(|> (\\parser.result (do <>.monad
+ [_ \\parser.any]
+ <parser>)
+ expected)
+ (!expect (^.multi {try.#Failure error}
+ (exception.match? \\parser.empty_input error))))]
+
+ [\\parser.any]
+ [\\parser.next]
+ ))))))
+ (do [! random.monad]
+ [expected ..primitive]
+ (_.coverage [\\parser.Env \\parser.env \\parser.fresh]
+ (|> (\\parser.result (do <>.monad
+ [env \\parser.env
+ _ \\parser.any]
+ (in env))
+ expected)
+ (!expect (^.multi {try.#Success environment}
+ (same? \\parser.fresh environment))))))
+ (do [! random.monad]
+ [expected ..primitive
+ dummy (random.only (|>> (/#= expected) not)
+ ..primitive)]
+ (_.coverage [\\parser.local]
+ (|> (\\parser.result (do <>.monad
+ [_ \\parser.any]
+ (\\parser.local (list expected)
+ \\parser.any))
+ dummy)
+ (!expect (^.multi {try.#Success actual}
+ (/#= expected actual))))))
+ (do [! random.monad]
+ [expected random.nat]
+ (_.coverage [\\parser.existential \\parser.not_existential]
+ (|> (\\parser.result \\parser.existential
+ {.#Ex expected})
+ (!expect (^.multi {try.#Success actual}
+ (n.= expected actual))))))
+ (do [! random.monad]
+ [expected_name (random.and (random.alpha_numeric 1)
+ (random.alpha_numeric 1))
+ expected_type ..primitive]
+ (_.coverage [\\parser.named \\parser.not_named]
+ (|> (\\parser.result \\parser.named
+ {.#Named expected_name expected_type})
+ (!expect (^.multi {try.#Success [actual_name actual_type]}
+ (and (symbol#= expected_name actual_name)
+ (/#= expected_type actual_type)))))))
+ ..test|aggregate
+ ..test|matches
+ ..test|parameter
+ ..test|polymorphic
+ ..test|recursive
+ )))
+
(def short
(Random Text)
(do [! random.monad]
@@ -249,6 +553,8 @@
(text#= (/.format left) (/.format right))))
))
+ ..\\parser
+
/primitive.test
/check.test
/dynamic.test
diff --git a/stdlib/source/test/lux/type/primitive.lux b/stdlib/source/test/lux/type/primitive.lux
index 619b2b3f9..7b4500c00 100644
--- a/stdlib/source/test/lux/type/primitive.lux
+++ b/stdlib/source/test/lux/type/primitive.lux
@@ -7,15 +7,14 @@
[monad (.only do)]]
[control
["[0]" try]
- ["[0]" exception]
- [parser
- ["<[0]>" code]]]
+ ["[0]" exception]]
[data
["[0]" text (.use "[1]#[0]" equivalence)]]
["[0]" macro (.only)
[syntax (.only syntax)]
- ["[0]" code]
- ["[0]" template]]
+ ["[0]" template]
+ ["[0]" code (.only)
+ ["<[1]>" \\parser]]]
["[0]" math (.only)
["[0]" random]
[number
diff --git a/stdlib/source/test/lux/type/resource.lux b/stdlib/source/test/lux/type/resource.lux
index f8e44bcb4..a23f1cacf 100644
--- a/stdlib/source/test/lux/type/resource.lux
+++ b/stdlib/source/test/lux/type/resource.lux
@@ -11,16 +11,15 @@
["[0]" try]
["[0]" exception (.only Exception)]
[concurrency
- ["[0]" async (.only Async)]]
- [parser
- ["<[0]>" code]]]
+ ["[0]" async (.only Async)]]]
[data
["[0]" identity (.only Identity)]
["[0]" text (.use "[1]#[0]" equivalence)
["%" \\format (.only format)]]]
["[0]" macro (.only)
[syntax (.only syntax)]
- ["[0]" code]]
+ ["[0]" code (.only)
+ ["<[1]>" \\parser]]]
[math
["[0]" random]]]]
[\\library