diff options
Diffstat (limited to '')
-rw-r--r-- | stdlib/source/test/lux/world/net/uri/encoding.lux | 55 |
1 files changed, 55 insertions, 0 deletions
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))) + ))) |