diff options
author | Eduardo Julian | 2022-06-29 03:15:23 -0400 |
---|---|---|
committer | Eduardo Julian | 2022-06-29 03:15:23 -0400 |
commit | 664e02d1b5e5aa479869c4e17ec4128f5cfd04e2 (patch) | |
tree | 7111d48d8a728ea30abfb6adb104425f61d65585 /stdlib/source/test | |
parent | 5232f0701cd95f260005a65d220a361dd71b6b96 (diff) |
New "parser" hierarchy. [Part 6]
Diffstat (limited to 'stdlib/source/test')
-rw-r--r-- | stdlib/source/test/lux/control/parser.lux | 6 | ||||
-rw-r--r-- | stdlib/source/test/lux/control/parser/environment.lux | 53 | ||||
-rw-r--r-- | stdlib/source/test/lux/world.lux | 4 | ||||
-rw-r--r-- | stdlib/source/test/lux/world/environment.lux (renamed from stdlib/source/test/lux/world/program.lux) | 49 | ||||
-rw-r--r-- | stdlib/source/test/lux/world/shell.lux | 8 |
5 files changed, 49 insertions, 71 deletions
diff --git a/stdlib/source/test/lux/control/parser.lux b/stdlib/source/test/lux/control/parser.lux index 624999201..aa083b543 100644 --- a/stdlib/source/test/lux/control/parser.lux +++ b/stdlib/source/test/lux/control/parser.lux @@ -25,9 +25,7 @@ ["[0]" code (.only) ["<[1]>" \\parser]]]]] [\\library - ["[0]" / (.only Parser)]] - ["[0]" / - ["[1][0]" environment]]) + ["[0]" / (.only Parser)]]) (def (should_fail expected input) (All (_ a) (-> Text (Try a) Bit)) @@ -374,6 +372,4 @@ ..combinators_0 ..combinators_1 ..combinators_2 - - /environment.test )))) diff --git a/stdlib/source/test/lux/control/parser/environment.lux b/stdlib/source/test/lux/control/parser/environment.lux deleted file mode 100644 index bc4d924b3..000000000 --- a/stdlib/source/test/lux/control/parser/environment.lux +++ /dev/null @@ -1,53 +0,0 @@ -(.require - [library - [lux (.except) - ["_" test (.only Test)] - [abstract - [monad (.only do)]] - [control - ["[0]" try] - ["[0]" exception]] - [data - ["[0]" text (.use "[1]#[0]" equivalence)] - [collection - ["[0]" dictionary]]] - [math - ["[0]" random] - [number - ["n" nat]]]]] - [\\library - ["[0]" / (.only) - ["/[1]" // (.use "[1]#[0]" monad)]]]) - -(def .public test - Test - (<| (_.covering /._) - (_.for [/.Environment /.Parser]) - (all _.and - (_.coverage [/.empty] - (dictionary.empty? /.empty)) - (do random.monad - [expected random.nat] - (_.coverage [/.result] - (|> (/.result (//#in expected) /.empty) - (at try.functor each (n.= expected)) - (try.else false)))) - (do random.monad - [property (random.alphabetic 1) - expected (random.alphabetic 1)] - (_.coverage [/.Property /.property] - (|> /.empty - (dictionary.has property expected) - (/.result (/.property property)) - (at try.functor each (text#= expected)) - (try.else false)))) - (do random.monad - [property (random.alphabetic 1)] - (_.coverage [/.unknown_property] - (case (/.result (/.property property) /.empty) - {try.#Success _} - false - - {try.#Failure error} - (exception.match? /.unknown_property error)))) - ))) diff --git a/stdlib/source/test/lux/world.lux b/stdlib/source/test/lux/world.lux index 19576d27d..37b9d2892 100644 --- a/stdlib/source/test/lux/world.lux +++ b/stdlib/source/test/lux/world.lux @@ -6,7 +6,7 @@ ["[1][0]" file] ["[1][0]" shell] ["[1][0]" console] - ["[1][0]" program] + ["[1][0]" environment] ["[1][0]" input ["[1]/[0]" keyboard]] ["[1][0]" output @@ -23,7 +23,7 @@ /file.test /shell.test /console.test - /program.test + /environment.test /input/keyboard.test /output/video/resolution.test /net/http/client.test diff --git a/stdlib/source/test/lux/world/program.lux b/stdlib/source/test/lux/world/environment.lux index 545401bee..ee9879d21 100644 --- a/stdlib/source/test/lux/world/program.lux +++ b/stdlib/source/test/lux/world/environment.lux @@ -5,13 +5,12 @@ [abstract [monad (.only do)]] [control + ["//" parser (.use "[1]#[0]" monad)] ["[0]" pipe] ["[0]" io] ["[0]" maybe (.use "[1]#[0]" functor)] ["[0]" try] - ["[0]" exception] - [parser - [environment (.only Environment)]]] + ["[0]" exception]] [data ["[0]" text (.use "[1]#[0]" equivalence)] [collection @@ -21,6 +20,7 @@ ["[0]" random (.only Random)] [number ["n" nat]]]]] + ["[0]" \\parser (.only Environment)] [\\library ["[0]" / (.only) [// @@ -28,6 +28,39 @@ [\\specification ["$[0]" /]]) +(def \\parser + Test + (<| (_.covering \\parser._) + (_.for [\\parser.Environment \\parser.Parser]) + (all _.and + (_.coverage [\\parser.empty] + (dictionary.empty? \\parser.empty)) + (do random.monad + [expected random.nat] + (_.coverage [\\parser.result] + (|> (\\parser.result (//#in expected) \\parser.empty) + (at try.functor each (n.= expected)) + (try.else false)))) + (do random.monad + [property (random.alphabetic 1) + expected (random.alphabetic 1)] + (_.coverage [\\parser.Property \\parser.property] + (|> \\parser.empty + (dictionary.has property expected) + (\\parser.result (\\parser.property property)) + (at try.functor each (text#= expected)) + (try.else false)))) + (do random.monad + [property (random.alphabetic 1)] + (_.coverage [\\parser.unknown_property] + (case (\\parser.result (\\parser.property property) \\parser.empty) + {try.#Success _} + false + + {try.#Failure error} + (exception.match? \\parser.unknown_property error)))) + ))) + (def (environment env_size) (-> Nat (Random Environment)) (random.dictionary text.hash env_size @@ -52,10 +85,10 @@ (_.for [/.mock /.async] ($/.spec (/.async (/.mock environment home directory)))) (_.coverage [/.environment] - (let [program (/.mock environment home directory)] + (let [it (/.mock environment home directory)] (io.run! (do io.monad - [actual (/.environment io.monad program)] + [actual (/.environment io.monad it)] (in (and (n.= (dictionary.size environment) (dictionary.size actual)) (|> actual @@ -66,13 +99,15 @@ (maybe#each (text#= value)) (maybe.else false))))))))))) (_.coverage [/.unknown_environment_variable] - (let [program (/.mock environment home directory)] + (let [it (/.mock environment home directory)] (|> unknown - (at program variable) + (at it variable) io.run! (pipe.case {try.#Success _} false {try.#Failure error} (exception.match? /.unknown_environment_variable error))))) + + ..\\parser )))) diff --git a/stdlib/source/test/lux/world/shell.lux b/stdlib/source/test/lux/world/shell.lux index c8738d3a3..09126a8a3 100644 --- a/stdlib/source/test/lux/world/shell.lux +++ b/stdlib/source/test/lux/world/shell.lux @@ -9,9 +9,7 @@ ["[0]" exception (.only exception)] ["[0]" io (.only IO)] [concurrency - ["[0]" async (.only Async)]] - [parser - ["[0]" environment (.only Environment)]]] + ["[0]" async (.only Async)]]] [data ["[0]" text (.use "[1]#[0]" equivalence)] [collection @@ -24,7 +22,9 @@ [\\library ["[0]" / (.only) [// - [file (.only Path)]]]] + [file (.only Path)] + ["[0]" environment + ["[1]" \\parser (.only Environment)]]]]] [\\specification ["$[0]" /]]) |