diff options
author | Eduardo Julian | 2022-10-24 16:58:07 -0400 |
---|---|---|
committer | Eduardo Julian | 2022-10-24 16:58:07 -0400 |
commit | 45c599e49ae2659331d13222948f7e755967fdf9 (patch) | |
tree | 1f1b0be2423b69562d7479fd8db9abb509aaaf7f /stdlib/source/test/lux/world | |
parent | 99d196a528804b3b136ac6c45cb872a5e7c70cde (diff) |
New module just for the Char type + fixes to JSON parsing.
Diffstat (limited to 'stdlib/source/test/lux/world')
-rw-r--r-- | stdlib/source/test/lux/world/net.lux | 2 | ||||
-rw-r--r-- | stdlib/source/test/lux/world/net/uri/encoding.lux | 55 |
2 files changed, 57 insertions, 0 deletions
diff --git a/stdlib/source/test/lux/world/net.lux b/stdlib/source/test/lux/world/net.lux index f9b3417ed..e7780f688 100644 --- a/stdlib/source/test/lux/world/net.lux +++ b/stdlib/source/test/lux/world/net.lux @@ -17,6 +17,7 @@ ["[1]/[0]" status] ["[1]/[0]" version]] ["[1][0]" uri + ["[1]/[0]" encoding] ["[1]/[0]" scheme] ["[1]/[0]" path]]]) @@ -41,6 +42,7 @@ /http/status.test /http/version.test + /uri/encoding.test /uri/scheme.test /uri/path.test ))) diff --git a/stdlib/source/test/lux/world/net/uri/encoding.lux b/stdlib/source/test/lux/world/net/uri/encoding.lux new file mode 100644 index 000000000..f9a627e25 --- /dev/null +++ b/stdlib/source/test/lux/world/net/uri/encoding.lux @@ -0,0 +1,55 @@ +(.require + [library + [lux (.except) + [abstract + [monad (.only do)]] + [control + ["[0]" maybe] + ["[0]" try (.use "[1]#[0]" functor)]] + [data + ["[0]" text (.use "[1]#[0]" equivalence) + ["%" \\format]] + [collection + ["[0]" list] + ["[0]" set]]] + [math + ["[0]" random (.only Random)] + [number + ["n" nat]]] + [test + ["_" property (.only Test)]]]] + [\\library + ["[0]" /]]) + +(def .public test + Test + (<| (_.covering /._) + (let [choices (set.list /.reserved) + variety (list.size choices)]) + (do [! random.monad] + [safe (random.lower_case 1) + + left (random.lower_case 1) + middle (random.lower_case 1) + right (random.lower_case 1) + left_choice (at ! each (n.% variety) random.nat) + right_choice (at ! each (n.% variety) random.nat) + .let [left_choice (maybe.trusted (list.item left_choice choices)) + right_choice (maybe.trusted (list.item right_choice choices)) + unsafe (%.format left + (text.of_char left_choice) middle + (text.of_char right_choice) right)]]) + (_.for [/.URI_Encoded]) + (all _.and + (_.coverage [/.reserved] + (not (set.empty? /.reserved))) + (_.coverage [/.encoded] + (and (text#= safe (/.encoded safe)) + (not (text#= unsafe (/.encoded unsafe))))) + (_.coverage [/.decoded] + (|> unsafe + /.encoded + /.decoded + (try#each (text#= unsafe)) + (try.else false))) + ))) |