diff options
author | Eduardo Julian | 2022-06-12 20:05:43 -0400 |
---|---|---|
committer | Eduardo Julian | 2022-06-12 20:05:43 -0400 |
commit | 1643be20cb10baf3cabcab502f0013b7faebe322 (patch) | |
tree | 4b4f4619921bf5749e404e7f644e5dfe30d69055 /stdlib/source/test | |
parent | 94c0bc5d12ed44540543bd6772d357baeb32bb45 (diff) |
Generalized macro-let.
Diffstat (limited to 'stdlib/source/test')
-rw-r--r-- | stdlib/source/test/lux/macro/local.lux | 37 |
1 files changed, 37 insertions, 0 deletions
diff --git a/stdlib/source/test/lux/macro/local.lux b/stdlib/source/test/lux/macro/local.lux index de1073f55..bb03574a1 100644 --- a/stdlib/source/test/lux/macro/local.lux +++ b/stdlib/source/test/lux/macro/local.lux @@ -27,6 +27,12 @@ [\\library ["[0]" /]]) +(/.let [!pow/2 (template (_ <scalar>) + [(n.* <scalar> <scalar>)])] + (def: pow/2 + (-> Nat Nat) + (|>> !pow/2))) + (def: macro_error (syntax (_ [macro <code>.any]) (function (_ compiler) @@ -90,4 +96,35 @@ (<| ..macro_error (..with ["" "actual"] expected #1) (n.= expected (..actual))))) + (do ! + [scalar random.nat] + (_.coverage [/.let] + (let [can_use_with_statements! + (n.= (all n.* scalar scalar) + (..pow/2 scalar))] + (and can_use_with_statements! + (/.let [pow/3 (template (_ <scalar>) + [(all n.* <scalar> <scalar> <scalar>)]) + pow/9 (template (_ <scalar>) + [(pow/3 (pow/3 <scalar>))])] + (let [can_use_with_expressions! + (n.= (all n.* scalar scalar scalar) + (pow/3 scalar)) + + can_refer! + (n.= (all n.* + scalar scalar scalar + scalar scalar scalar + scalar scalar scalar) + (pow/9 scalar)) + + can_shadow! + (let [pow/3 (function (_ scalar) + (all n.+ scalar scalar scalar))] + (n.= (all n.+ scalar scalar scalar) + (pow/3 scalar)))] + (and can_use_with_expressions! + can_refer! + can_shadow!))) + )))) )))) |