aboutsummaryrefslogtreecommitdiff
path: root/stdlib/source/test/lux/meta/macro/context.lux
diff options
context:
space:
mode:
Diffstat (limited to 'stdlib/source/test/lux/meta/macro/context.lux')
-rw-r--r--stdlib/source/test/lux/meta/macro/context.lux192
1 files changed, 126 insertions, 66 deletions
diff --git a/stdlib/source/test/lux/meta/macro/context.lux b/stdlib/source/test/lux/meta/macro/context.lux
index cbcdf60e0..095fed836 100644
--- a/stdlib/source/test/lux/meta/macro/context.lux
+++ b/stdlib/source/test/lux/meta/macro/context.lux
@@ -18,7 +18,8 @@
["<[1]>" \\parser]]
[macro
[syntax (.only syntax)]
- ["[0]" expansion]]]
+ ["[0]" expansion]
+ ["[0]" template]]]
[test
["_" property (.only Test)]]]]
[\\library
@@ -34,70 +35,129 @@
{try.#Success _}
{try.#Failure "OOPS!"}))))
-(/.def [stack expression declaration] Nat)
+(template.with_locals [<real_stack>' <real_expression> <real_declaration>
+ <fake_stack>' <fake_expression> <fake_declaration>]
+ (these (/.def [<real_stack>' <real_expression> <real_declaration>] Nat)
-(with_expansions [<top> (static.random_nat)]
- (<| static.expansion
- (declaration <top>)
- (` (def (,' declaration!) true))))
-
-(def .public test
- Test
- (<| (_.covering /._)
- (all _.and
- (_.coverage [/.def]
- (and declaration!
- (with_expansions [<top> (static.random_nat)]
- (<| static.expansion
- (do meta.monad
- [it (expression <top> (` true))]
- (in (list it)))))))
- (_.coverage [/.peek /.peek'
- /.push /.push']
- (with_expansions [<expected> (static.random_nat)]
- (n.= <expected>
- (<| static.expansion
- (do meta.monad
- [_ (/.push <expected> ..stack)
- actual (/.peek ..stack)
- _ (/.pop ..stack)]
- (in (list (code.nat actual))))))))
- (_.coverage [/.no_active_context]
- (<| (text.contains? (the exception.#label /.no_active_context))
- macro_error
- static.expansion
- (do meta.monad
- [top (/.peek ..stack)]
- (in (list (code.nat top))))))
- (_.coverage [/.pop /.pop' /.pop'']
- (with_expansions [<dummy> (static.random_nat)
- <expected> (static.nat (++ <dummy>))]
- (n.= <expected>
+ (with_expansions [<real_stack> (template.symbol [.._] [<real_stack>'])
+ <fake_stack> (template.symbol [.._] [<fake_stack>'])]
+ (these (with_expansions [<top> (static.random_nat)]
(<| static.expansion
- (do meta.monad
- [_ (/.push <dummy> ..stack)
- _ (/.pop ..stack)
- _ (/.push <expected> ..stack)
- actual (/.peek ..stack)
- _ (/.pop ..stack)]
- (in (list (code.nat actual))))))))
- (_.coverage [/.search /.search']
- (with_expansions [<expected> (static.random_nat)]
- (n.= <expected>
- (<| static.expansion
- (do meta.monad
- [_ (/.push <expected> ..stack)
- actual (/.search (n.= <expected>) ..stack)
- _ (/.pop ..stack)]
- (in (list (code.nat actual))))))))
- (_.coverage [/.no_example]
- (with_expansions [<expected> (static.random_nat)]
- (<| (text.contains? (the exception.#label /.no_example))
- macro_error
- static.expansion
- (do meta.monad
- [_ (/.push <expected> ..stack)
- actual (/.search (|>> (n.= <expected>) not) ..stack)
- _ (/.pop ..stack)]
- (in (list (code.nat actual)))))))
- )))
+ (<real_declaration> <top>)
+ (` (def (,' declaration!) true))))
+
+ (def .public test
+ Test
+ (<| (_.covering /._)
+ (_.for [/.Stack])
+ (all _.and
+ (_.coverage [/.def]
+ (and declaration!
+ (with_expansions [<top> (static.random_nat)]
+ (<| static.expansion
+ (do meta.monad
+ [it (<real_expression> <top> (` true))]
+ (in (list it)))))))
+ (_.coverage [/.peek /.peek'
+ /.push /.push']
+ (with_expansions [<expected> (static.random_nat)]
+ (n.= <expected>
+ (<| static.expansion
+ (do meta.monad
+ [_ (/.push <expected> <real_stack>)
+ actual (/.peek <real_stack>)
+ _ (/.pop <real_stack>)]
+ (in (list (code.nat actual))))))))
+ (_.coverage [/.no_active_context]
+ (<| (text.contains? (the exception.#label /.no_active_context))
+ macro_error
+ static.expansion
+ (do meta.monad
+ [top (/.peek <real_stack>)]
+ (in (list (code.nat top))))))
+ (_.coverage [/.pop /.pop' /.pop'']
+ (with_expansions [<dummy> (static.random_nat)
+ <expected> (static.nat (++ <dummy>))]
+ (n.= <expected>
+ (<| static.expansion
+ (do meta.monad
+ [_ (/.push <dummy> <real_stack>)
+ _ (/.pop <real_stack>)
+ _ (/.push <expected> <real_stack>)
+ actual (/.peek <real_stack>)
+ _ (/.pop <real_stack>)]
+ (in (list (code.nat actual))))))))
+ (_.coverage [/.search /.search']
+ (with_expansions [<expected> (static.random_nat)]
+ (n.= <expected>
+ (<| static.expansion
+ (do meta.monad
+ [_ (/.push <expected> <real_stack>)
+ actual (/.search (n.= <expected>) <real_stack>)
+ _ (/.pop <real_stack>)]
+ (in (list (code.nat actual))))))))
+ (_.coverage [/.no_example]
+ (with_expansions [<expected> (static.random_nat)]
+ (and (<| (text.contains? (the exception.#label /.no_example))
+ macro_error
+ static.expansion
+ (do meta.monad
+ [_ (/.push <expected> <real_stack>)
+ actual (/.search (|>> (n.= <expected>) not) <real_stack>)
+ _ (/.pop <real_stack>)]
+ (in (list (code.nat actual)))))
+ (<| (text.contains? (the exception.#label /.no_example))
+ macro_error
+ static.expansion
+ (do meta.monad
+ [_ (/.revised {.#None} ++ <real_stack>)]
+ (in (list)))))))
+ (_.coverage [/.not_a_definition]
+ (and (<| (text.contains? (the exception.#label /.not_a_definition))
+ macro_error
+ static.expansion
+ (do meta.monad
+ [actual (/.peek' [<real_stack> (symbol <fake_stack>)])]
+ (in (list))))
+ (with_expansions [<expected> (static.random_nat)]
+ (<| (text.contains? (the exception.#label /.not_a_definition))
+ macro_error
+ static.expansion
+ (do meta.monad
+ [_ (/.push' <expected> [<real_stack> (symbol .#Item)])]
+ (in (list)))))))
+ (_.coverage [/.not_a_global]
+ (with_expansions [<expected> (static.random_nat)]
+ (<| (text.contains? (the exception.#label /.not_a_global))
+ macro_error
+ static.expansion
+ (do meta.monad
+ [_ (/.push' <expected> [<real_stack> (symbol <fake_stack>)])]
+ (in (list))))))
+ (_.coverage [/.not_a_module]
+ (with_expansions [<expected> (static.random_nat)]
+ (<| (text.contains? (the exception.#label /.not_a_module))
+ macro_error
+ static.expansion
+ (do meta.monad
+ [_ (/.push' <expected> [<real_stack> [(%.nat <expected>) (%.nat <expected>)]])]
+ (in (list))))))
+ (_.coverage [/.revised /.revised']
+ (with_expansions [<expected> (static.random_nat)]
+ (and (n.= (++ <expected>)
+ (<| static.expansion
+ (do meta.monad
+ [_ (/.push <expected> <real_stack>)
+ _ (/.revised {.#None} ++ <real_stack>)
+ actual (/.peek <real_stack>)
+ _ (/.pop <real_stack>)]
+ (in (list (code.nat actual))))))
+ (n.= (++ <expected>)
+ (<| static.expansion
+ (do meta.monad
+ [_ (/.push <expected> <real_stack>)
+ _ (/.revised {.#Some (n.= <expected>)} ++ <real_stack>)
+ actual (/.peek <real_stack>)
+ _ (/.pop <real_stack>)]
+ (in (list (code.nat actual)))))))))
+ )))))))