(.using [library [lux (.except) ["_" test (.only Test)] ["[0]" meta] [abstract [monad (.only do)]] [control ["[0]" try] ["[0]" exception] [parser ["<[0]>" code]]] [data ["[0]" text (.open: "[1]#[0]" equivalence)]] ["[0]" macro (.only) [syntax (.only syntax)] ["[0]" code] ["[0]" template]] ["[0]" math (.only) ["[0]" random] [number ["n" nat]]]]] [\\library ["[0]" /]]) (template.with_locals [g!Foo g!Bar] (these (with_template [ ] [(def (syntax (_ []) (do meta.monad [frame ] (in (list (code.text (the /.#name frame)))))))] [current /.current] [specific (/.specific (template.text [g!Foo]))] ) (def with_no_active_frames (syntax (_ [macro .any]) (function (_ compiler) (let [verdict (case ((macro.expansion macro) compiler) {try.#Failure error} (exception.match? /.no_active_frames error) {try.#Success _} false)] {try.#Success [compiler (list (code.bit verdict))]})))) (with_expansions [no_current! (..with_no_active_frames (..current)) no_specific! (..with_no_active_frames (..specific))] (/.primitive (g!Foo a) Text (/.primitive (g!Bar a) Nat (def .public test Test (<| (_.covering /._) (_.for [/.primitive]) (do random.monad [expected_foo (random.lower_case 5) expected_bar random.nat] (all _.and (_.coverage [/.abstraction] (and (exec (is (g!Foo Text) (/.abstraction g!Foo expected_foo)) true) (exec (is (g!Bar Text) (/.abstraction expected_bar)) true))) (_.coverage [/.representation] (and (|> expected_foo (/.abstraction g!Foo) (is (g!Foo Bit)) (/.representation g!Foo) (text#= expected_foo)) (|> (/.abstraction expected_bar) (is (g!Bar Bit)) /.representation (n.= expected_bar)))) (_.coverage [/.transmutation] (and (exec (|> expected_foo (/.abstraction g!Foo) (is (g!Foo .Macro)) (/.transmutation g!Foo) (is (g!Foo .Lux))) true) (exec (|> (/.abstraction expected_bar) (is (g!Bar .Macro)) /.transmutation (is (g!Bar .Lux))) true))) (_.for [/.Frame] (all _.and (_.coverage [/.current] (text#= (template.text [g!Bar]) (..current))) (_.coverage [/.specific] (text#= (template.text [g!Foo]) (..specific))) (_.coverage [/.no_active_frames] (and no_current! no_specific!)) )) )))))))))