diff options
Diffstat (limited to 'stdlib/source/test/lux/meta/macro/syntax/definition.lux')
-rw-r--r-- | stdlib/source/test/lux/meta/macro/syntax/definition.lux | 96 |
1 files changed, 96 insertions, 0 deletions
diff --git a/stdlib/source/test/lux/meta/macro/syntax/definition.lux b/stdlib/source/test/lux/meta/macro/syntax/definition.lux new file mode 100644 index 000000000..878cc8ee9 --- /dev/null +++ b/stdlib/source/test/lux/meta/macro/syntax/definition.lux @@ -0,0 +1,96 @@ +(.require + [library + [lux (.except) + ["_" test (.only Test)] + [abstract + [monad (.only do)] + [\\specification + ["$[0]" equivalence]]] + [control + ["<>" parser] + ["[0]" try] + ["[0]" exception]] + [math + ["[0]" random (.only Random)]] + [meta + ["[0]" location] + ["[0]" code (.use "[1]#[0]" equivalence) + ["<[1]>" \\parser]]]]] + [\\library + ["[0]" /]] + ["$[0]"// + ["[1][0]" check] + ["[1]//" /// + ["[1][0]" code]]]) + +(def .public random + (Random /.Definition) + (all random.and + (random.alphabetic 5) + (random.or $//check.random + $////code.random) + random.bit + )) + +(def compiler + [.#info [.#target "FAKE" + .#version "0.0.0" + .#mode {.#Build} + .#configuration (list)] + .#source [location.dummy 0 ""] + .#location location.dummy + .#current_module {.#None} + .#modules (list) + .#scopes (list) + .#type_context [.#ex_counter 0 + .#var_counter 0 + .#var_bindings (list)] + .#expected {.#None} + .#seed 0 + .#scope_type_vars (list) + .#extensions [] + .#eval (as (-> Type Code (Meta Any)) []) + .#host []]) + +(def .public test + Test + (<| (_.covering /._) + (_.for [/.Definition]) + (all _.and + (_.for [/.equivalence] + ($equivalence.spec /.equivalence ..random)) + + (do random.monad + [expected ..random + + type $////code.random + untyped_value $////code.random] + (all _.and + (_.coverage [/.format /.parser] + (case (<code>.result (/.parser compiler) + (list (/.format expected))) + {try.#Failure error} + false + + {try.#Success actual} + (at /.equivalence = expected actual))) + (_.coverage [/.typed] + (let [expected (has /.#value {.#Left [type untyped_value]} expected)] + (case (<code>.result (/.typed compiler) + (list (/.format expected))) + {try.#Failure error} + false + + {try.#Success actual} + (at /.equivalence = expected actual)))) + (_.coverage [/.lacks_type] + (let [expected (has /.#value {.#Right untyped_value} expected)] + (case (<code>.result (/.typed compiler) + (list (/.format expected))) + {try.#Failure error} + (exception.match? /.lacks_type error) + + {try.#Success actual} + false))) + ))) + )) |