diff options
Diffstat (limited to '')
-rw-r--r-- | stdlib/source/test/lux/meta/type/unit.lux | 80 |
1 files changed, 49 insertions, 31 deletions
diff --git a/stdlib/source/test/lux/meta/type/unit.lux b/stdlib/source/test/lux/meta/type/unit.lux index c31abd6b0..734400ade 100644 --- a/stdlib/source/test/lux/meta/type/unit.lux +++ b/stdlib/source/test/lux/meta/type/unit.lux @@ -8,10 +8,16 @@ ["$[0]" equivalence] ["$[0]" order] ["$[0]" enum]]] + [data + ["[0]" text (.use "[1]#[0]" equivalence) + ["%" \\format]]] [math ["[0]" random (.only Random)] [number ["i" int]]] + [meta + ["[0]" static] + ["[0]" code]] [test ["_" property (.only Test)]]]] [\\library @@ -42,39 +48,51 @@ ($enum.spec /.enum (..meter 1,000))) )) -(def what (/.unit [])) -(def What (/.type what)) +(with_expansions [<descriptor> (static.random code.text + (random.upper_cased 1))] + (def what (/.unit <descriptor>)) + (def What (/.type what)) -(def unit - Test - (do random.monad - [expected random.int] - (_.for [/.Unit] - (`` (all _.and - (,, (with_template [<type> <unit>] - [(_.coverage [<type> <unit>] - (|> expected - (at <unit> in) - (at <unit> out) - (i.= expected)))] + (def unit + Test + (do random.monad + [expected random.int] + (_.for [/.Unit] + (`` (all _.and + (,, (with_template [<type> <unit>] + [(_.coverage [<type> <unit>] + (and (|> expected + (at <unit> in) + (at <unit> out) + (i.= expected)) + (let [it (|> expected + (at <unit> in) + (at <unit> format))] + (and (not (text#= (%.int expected) it)) + (text.starts_with? (%.int expected) it)))))] - [/.Gram /.gram] - [/.Meter /.meter] - [/.Litre /.litre] - [/.Second /.second] - )) - (_.coverage [/.measure /.number] - (|> expected - /.measure - /.number - (i.= expected))) - (_.coverage [/.unit /.type] - (|> expected - (at ..what in) - (is (/.Measure Any What)) - (at ..what out) - (i.= expected))) - ))))) + [/.Gram /.gram] + [/.Meter /.meter] + [/.Litre /.litre] + [/.Second /.second] + )) + (_.coverage [/.measure /.number] + (|> expected + /.measure + /.number + (i.= expected))) + (_.coverage [/.unit /.type] + (and (|> expected + (at ..what in) + (is (/.Measure Any What)) + (at ..what out) + (i.= expected)) + (let [it (|> expected + (at ..what in) + (at ..what format))] + (and (text.contains? (%.int expected) it) + (text.contains? <descriptor> it))))) + )))))) (def arithmetic Test |