diff options
Diffstat (limited to 'stdlib/source/test/lux/data/text/format.lux')
-rw-r--r-- | stdlib/source/test/lux/data/text/format.lux | 175 |
1 files changed, 91 insertions, 84 deletions
diff --git a/stdlib/source/test/lux/data/text/format.lux b/stdlib/source/test/lux/data/text/format.lux index 54176cda3..f35683b33 100644 --- a/stdlib/source/test/lux/data/text/format.lux +++ b/stdlib/source/test/lux/data/text/format.lux @@ -1,44 +1,45 @@ (.module: - [lux #* - ["_" test (#+ Test)] - [abstract - [monad (#+ do)] - [equivalence (#+ Equivalence)] - [functor - [\spec - ["$." contravariant]]]] - [control - ["." try]] - [data - ["." text ("#\." equivalence)] - ["." bit] - ["." name] - [format - ["." xml] - ["." json]] - [collection - ["." list ("#\." functor)]]] - ["." time - ["." day] - ["." month] - ["." instant] - ["." duration] - ["." date]] - [math - ["." random (#+ Random) ("#\." monad)] - ["." modulus] - ["." modular] - [number - ["." nat] - ["." int] - ["." rev] - ["." frac] - ["." ratio]]] - [macro - ["." code]] - [meta - ["." location]] - ["." type]] + [library + [lux #* + ["_" test (#+ Test)] + [abstract + [monad (#+ do)] + [equivalence (#+ Equivalence)] + [functor + [\\spec + ["$." contravariant]]]] + [control + ["." try]] + [data + ["." text ("#\." equivalence)] + ["." bit] + ["." name] + [format + ["." xml] + ["." json]] + [collection + ["." list ("#\." functor)]]] + ["." time + ["." day] + ["." month] + ["." instant] + ["." duration] + ["." date]] + [math + ["." random (#+ Random) ("#\." monad)] + ["." modulus] + ["." modular] + [number + ["." nat] + ["." int] + ["." rev] + ["." frac] + ["." ratio]]] + [macro + ["." code]] + [meta + ["." location]] + ["." type]]] ["$." /// #_ [format ["#." xml] @@ -48,7 +49,7 @@ ["#." type] [macro ["#." code]]]] - [\\ + [\\library ["." /]]) (implementation: (equivalence example) @@ -68,6 +69,54 @@ (random\wrap [/.frac random.frac]) )) +(def: codec + Test + (`` ($_ _.and + (~~ (template [<format> <codec> <random>] + [(do random.monad + [sample <random>] + (_.cover [<format>] + (text\= (\ <codec> encode sample) + (<format> sample))))] + + [/.bit bit.codec random.bit] + [/.nat nat.decimal random.nat] + [/.int int.decimal random.int] + [/.rev rev.decimal random.rev] + [/.frac frac.decimal random.frac] + [/.ratio ratio.codec random.ratio] + [/.name name.codec ($///name.random 5 5)] + [/.xml xml.codec $///xml.random] + [/.json json.codec $///json.random] + [/.day day.codec random.day] + [/.month month.codec random.month] + [/.instant instant.codec random.instant] + [/.duration duration.codec random.duration] + [/.date date.codec random.date] + [/.time time.codec random.time] + + [/.nat/2 nat.binary random.nat] + [/.nat/8 nat.octal random.nat] + [/.nat/10 nat.decimal random.nat] + [/.nat/16 nat.hex random.nat] + + [/.int/2 int.binary random.int] + [/.int/8 int.octal random.int] + [/.int/10 int.decimal random.int] + [/.int/16 int.hex random.int] + + [/.rev/2 rev.binary random.rev] + [/.rev/8 rev.octal random.rev] + [/.rev/10 rev.decimal random.rev] + [/.rev/16 rev.hex random.rev] + + [/.frac/2 frac.binary random.frac] + [/.frac/8 frac.octal random.frac] + [/.frac/10 frac.decimal random.frac] + [/.frac/16 frac.hex random.frac] + )) + ))) + (def: #export test Test (<| (_.covering /._) @@ -88,49 +137,7 @@ (_.cover [/.format] (text\= (/.format left mid right) ($_ "lux text concat" left mid right)))) - (~~ (template [<format> <codec> <random>] - [(do random.monad - [sample <random>] - (_.cover [<format>] - (text\= (\ <codec> encode sample) - (<format> sample))))] - - [/.bit bit.codec random.bit] - [/.nat nat.decimal random.nat] - [/.int int.decimal random.int] - [/.rev rev.decimal random.rev] - [/.frac frac.decimal random.frac] - [/.ratio ratio.codec random.ratio] - [/.name name.codec ($///name.random 5 5)] - [/.xml xml.codec $///xml.random] - [/.json json.codec $///json.random] - [/.day day.codec random.day] - [/.month month.codec random.month] - [/.instant instant.codec random.instant] - [/.duration duration.codec random.duration] - [/.date date.codec random.date] - [/.time time.codec random.time] - - [/.nat/2 nat.binary random.nat] - [/.nat/8 nat.octal random.nat] - [/.nat/10 nat.decimal random.nat] - [/.nat/16 nat.hex random.nat] - - [/.int/2 int.binary random.int] - [/.int/8 int.octal random.int] - [/.int/10 int.decimal random.int] - [/.int/16 int.hex random.int] - - [/.rev/2 rev.binary random.rev] - [/.rev/8 rev.octal random.rev] - [/.rev/10 rev.decimal random.rev] - [/.rev/16 rev.hex random.rev] - - [/.frac/2 frac.binary random.frac] - [/.frac/8 frac.octal random.frac] - [/.frac/10 frac.decimal random.frac] - [/.frac/16 frac.hex random.frac] - )) + ..codec (~~ (template [<format> <alias> <random>] [(do random.monad [sample <random>] |