aboutsummaryrefslogtreecommitdiff
path: root/stdlib/source/test
diff options
context:
space:
mode:
authorEduardo Julian2022-07-08 19:15:02 -0400
committerEduardo Julian2022-07-08 19:15:02 -0400
commitfc2737b5226eda69c12bc593e83e22ed54e4d3af (patch)
treecc3c8bfd5b96a235ebc37f3b3a17d37533f8ded2 /stdlib/source/test
parent6a052144968df9b441df53f6aa08cbb515ff2654 (diff)
Extracted macro-expansion machinery into its own module.
Diffstat (limited to 'stdlib/source/test')
-rw-r--r--stdlib/source/test/lux/control/remember.lux13
-rw-r--r--stdlib/source/test/lux/data/text/regex.lux5
-rw-r--r--stdlib/source/test/lux/debug.lux7
-rw-r--r--stdlib/source/test/lux/documentation.lux7
-rw-r--r--stdlib/source/test/lux/ffi.jvm.lux9
-rw-r--r--stdlib/source/test/lux/meta/configuration.lux7
-rw-r--r--stdlib/source/test/lux/meta/macro.lux72
-rw-r--r--stdlib/source/test/lux/meta/macro/local.lux7
-rw-r--r--stdlib/source/test/lux/meta/macro/template.lux7
-rw-r--r--stdlib/source/test/lux/meta/type/resource.lux7
-rw-r--r--stdlib/source/test/lux/meta/version.lux7
11 files changed, 79 insertions, 69 deletions
diff --git a/stdlib/source/test/lux/control/remember.lux b/stdlib/source/test/lux/control/remember.lux
index 5f4fae4ac..5ad579363 100644
--- a/stdlib/source/test/lux/control/remember.lux
+++ b/stdlib/source/test/lux/control/remember.lux
@@ -18,8 +18,9 @@
["[0]" meta (.only)
["[0]" code (.only)
["<[1]>" \\parser]]
- ["[0]" macro (.only)
- ["[0]" syntax (.only syntax)]]]
+ [macro
+ ["[0]" syntax (.only syntax)]
+ ["[0]" expansion]]]
[world
[time
["[0]" date (.only Date)]
@@ -74,10 +75,10 @@
message (product.right (random.result prng ..message))
expected (product.right (random.result prng ..focus))]
(do meta.monad
- [should_fail0 (..attempt (macro.expansion (..memory macro yesterday message {.#None})))
- should_fail1 (..attempt (macro.expansion (..memory macro yesterday message {.#Some expected})))
- should_succeed0 (..attempt (macro.expansion (..memory macro tomorrow message {.#None})))
- should_succeed1 (..attempt (macro.expansion (..memory macro tomorrow message {.#Some expected})))]
+ [should_fail0 (..attempt (expansion.complete (..memory macro yesterday message {.#None})))
+ should_fail1 (..attempt (expansion.complete (..memory macro yesterday message {.#Some expected})))
+ should_succeed0 (..attempt (expansion.complete (..memory macro tomorrow message {.#None})))
+ should_succeed1 (..attempt (expansion.complete (..memory macro tomorrow message {.#Some expected})))]
(in (list (code.bit (and (case should_fail0
{try.#Failure error}
(and (test_failure yesterday message {.#None} error)
diff --git a/stdlib/source/test/lux/data/text/regex.lux b/stdlib/source/test/lux/data/text/regex.lux
index 48b376358..c057aeaf0 100644
--- a/stdlib/source/test/lux/data/text/regex.lux
+++ b/stdlib/source/test/lux/data/text/regex.lux
@@ -18,7 +18,8 @@
["[0]" code (.only)
["<[1]>" \\parser]]
["[0]" macro (.only)
- [syntax (.only syntax)]]]]]
+ [syntax (.only syntax)]
+ ["[0]" expansion]]]]]
[\\library
["[0]" /]])
@@ -280,7 +281,7 @@
(def expands?
(syntax (_ [form <code>.any])
(function (_ lux)
- {try.#Success [lux (list (code.bit (case (macro.single_expansion form lux)
+ {try.#Success [lux (list (code.bit (case (expansion.single form lux)
{try.#Success _}
true
diff --git a/stdlib/source/test/lux/debug.lux b/stdlib/source/test/lux/debug.lux
index 8dae4a18e..a503b00cd 100644
--- a/stdlib/source/test/lux/debug.lux
+++ b/stdlib/source/test/lux/debug.lux
@@ -23,8 +23,9 @@
["@" target]
["[0]" code (.only)
["<[1]>" \\parser]]
- ["[0]" macro (.only)
- [syntax (.only syntax)]]]
+ [macro
+ [syntax (.only syntax)]
+ ["[0]" expansion]]]
[world
[time (.only Time)
[instant (.only Instant)]
@@ -219,7 +220,7 @@
(def macro_error
(syntax (_ [macro <code>.any])
(function (_ compiler)
- (case ((macro.expansion macro) compiler)
+ (case ((expansion.complete macro) compiler)
{try.#Failure error}
{try.#Success [compiler (list (code.text error))]}
diff --git a/stdlib/source/test/lux/documentation.lux b/stdlib/source/test/lux/documentation.lux
index 4196ab09d..53296522c 100644
--- a/stdlib/source/test/lux/documentation.lux
+++ b/stdlib/source/test/lux/documentation.lux
@@ -13,16 +13,17 @@
["[0]" meta (.only)
["[0]" code (.only)
["<[1]>" \\parser]]
- ["[0]" macro (.only)
+ [macro
[syntax (.only syntax)]
- ["[0]" template]]]]]
+ ["[0]" template]
+ ["[0]" expansion]]]]]
[\\library
["[0]" /]])
(def macro_error
(syntax (_ [macro <code>.any])
(function (_ compiler)
- {try.#Success [compiler (list (code.bit (case ((macro.expansion macro) compiler)
+ {try.#Success [compiler (list (code.bit (case ((expansion.complete macro) compiler)
{try.#Failure error}
true
diff --git a/stdlib/source/test/lux/ffi.jvm.lux b/stdlib/source/test/lux/ffi.jvm.lux
index 91b97276f..b03264c22 100644
--- a/stdlib/source/test/lux/ffi.jvm.lux
+++ b/stdlib/source/test/lux/ffi.jvm.lux
@@ -28,9 +28,10 @@
["[0]" type (.use "[1]#[0]" equivalence)]
["[0]" code (.only)
["<[1]>" \\parser]]
- ["[0]" macro (.only)
+ [macro
[syntax (.only syntax)]
- ["[0]" template]]
+ ["[0]" template]
+ ["[0]" expansion]]
[target
["[0]" jvm
["[1]" type (.use "[1]#[0]" equivalence)]]]]]]
@@ -74,7 +75,7 @@
(def macro_error
(syntax (_ [expression <code>.any])
(function (_ lux)
- (|> (macro.single_expansion expression)
+ (|> (expansion.single expression)
(meta.result lux)
(pipe.case
{try.#Success expansion}
@@ -670,7 +671,7 @@
(def expands?
(syntax (_ [expression <code>.any])
(function (_ lux)
- (|> (macro.single_expansion expression)
+ (|> (expansion.single expression)
(meta.result lux)
(pipe.case
{try.#Success expansion}
diff --git a/stdlib/source/test/lux/meta/configuration.lux b/stdlib/source/test/lux/meta/configuration.lux
index 0630f5186..ed0998646 100644
--- a/stdlib/source/test/lux/meta/configuration.lux
+++ b/stdlib/source/test/lux/meta/configuration.lux
@@ -21,8 +21,9 @@
["[0]" meta (.only)
["[0]" code (.only)
["<[1]>" \\parser]]
- ["[0]" macro (.only)
- [syntax (.only syntax)]]]]]
+ [macro
+ [syntax (.only syntax)]
+ ["[0]" expansion]]]]]
[\\library
["[0]" /]])
@@ -39,7 +40,7 @@
(def failure
(syntax (_ [it <code>.any])
(function (_ lux)
- (case (macro.expansion it lux)
+ (case (expansion.complete it lux)
{try.#Failure error}
{try.#Success [lux (list (code.text error))]}
diff --git a/stdlib/source/test/lux/meta/macro.lux b/stdlib/source/test/lux/meta/macro.lux
index 80faef121..59dbf995f 100644
--- a/stdlib/source/test/lux/meta/macro.lux
+++ b/stdlib/source/test/lux/meta/macro.lux
@@ -21,13 +21,13 @@
["[0]" location]
["[0]" symbol]
["[0]" code (.use "[1]#[0]" equivalence)
- ["<[1]>" \\parser]]
- [macro
- ["^" pattern]]]]]
+ ["<[1]>" \\parser]]]]]
[\\library
["[0]" / (.only)
+ ["^" pattern]
[syntax (.only syntax)]
- ["[0]" template]]]
+ ["[0]" template]
+ ["[0]" expansion]]]
["[0]" /
["[1][0]" local]
["[1][0]" syntax]
@@ -85,9 +85,9 @@
[.#module_hash 0
.#module_aliases (list)
.#definitions (is (List [Text .Global])
- (list (!global /.log_single_expansion!)
- (!global /.log_expansion!)
- (!global /.log_full_expansion!)))
+ (list (!global expansion.log_single!)
+ (!global expansion.log_complete!)
+ (!global expansion.log_total!)))
.#imports (list)
.#module_state {.#Active}]]
[current_module
@@ -131,33 +131,33 @@
full_expansion (` (n.* (n.* (, pow/1) (, pow/1))
(n.* (, pow/1) (, pow/1))))]]
(`` (all _.and
- (,, (with_template [<expander> <logger> <expansion>]
- [(_.coverage [<expander>]
- (|> (<expander> (` (..pow/4 (, pow/1))))
- (meta.result lux)
- (try#each (at (list.equivalence code.equivalence) =
- (list <expansion>)))
- (try.else false)))
-
- (_.coverage [<logger>]
- (and (|> (/.single_expansion (` (<logger> "omit" (..pow/4 (, pow/1)))))
- (meta.result lux)
- (try#each (at (list.equivalence code.equivalence) = (list)))
- (try.else false))
- (|> (/.single_expansion (` (<logger> (..pow/4 (, pow/1)))))
- (meta.result lux)
- (try#each (at (list.equivalence code.equivalence) = (list <expansion>)))
- (try.else false))))]
-
- [/.single_expansion /.log_single_expansion! single_expansion]
- [/.expansion /.log_expansion! expansion]
- [/.full_expansion /.log_full_expansion! full_expansion]
- ))
- (_.coverage [/.one_expansion]
- (bit#= (not (n.= 1 repetitions))
- (|> (/.one_expansion (` (..repeated (, (code.nat repetitions)) (, pow/1))))
- (meta.result lux)
- (!expect {try.#Failure _}))))
+ ... (,, (with_template [<expander> <logger> <expansion>]
+ ... [(_.coverage [<expander>]
+ ... (|> (<expander> (` (..pow/4 (, pow/1))))
+ ... (meta.result lux)
+ ... (try#each (at (list.equivalence code.equivalence) =
+ ... (list <expansion>)))
+ ... (try.else false)))
+
+ ... (_.coverage [<logger>]
+ ... (and (|> (expansion.single (` (<logger> "omit" (..pow/4 (, pow/1)))))
+ ... (meta.result lux)
+ ... (try#each (at (list.equivalence code.equivalence) = (list)))
+ ... (try.else false))
+ ... (|> (expansion.single (` (<logger> (..pow/4 (, pow/1)))))
+ ... (meta.result lux)
+ ... (try#each (at (list.equivalence code.equivalence) = (list <expansion>)))
+ ... (try.else false))))]
+
+ ... [expansion.single expansion.log_single! single_expansion]
+ ... [expansion.complete expansion.log_complete! expansion]
+ ... [expansion.total expansion.log_total! full_expansion]
+ ... ))
+ ... (_.coverage [expansion.one]
+ ... (bit#= (not (n.= 1 repetitions))
+ ... (|> (expansion.one (` (..repeated (, (code.nat repetitions)) (, pow/1))))
+ ... (meta.result lux)
+ ... (!expect {try.#Failure _}))))
(_.coverage [/.final]
(with_expansions [<expected> (static.random_nat)
<cycles> (static.random code.nat
@@ -219,10 +219,10 @@
(and (text.contains? symbol_prefix actual_symbol)
(text.contains? (%.nat seed) actual_symbol))))))
(_.coverage [/.wrong_syntax_error]
- (|> (/.single_expansion (` (/.log_single_expansion!)))
+ (|> (expansion.single (` (expansion.log_single!)))
(meta.result lux)
(!expect (^.multi {try.#Failure error}
- (text.contains? (/.wrong_syntax_error (symbol /.log_single_expansion!))
+ (text.contains? (/.wrong_syntax_error (symbol expansion.log_single!))
error)))))
(_.coverage [/.with_symbols]
(with_expansions [<expected> (fresh_symbol)]
diff --git a/stdlib/source/test/lux/meta/macro/local.lux b/stdlib/source/test/lux/meta/macro/local.lux
index 1aa793639..19398b395 100644
--- a/stdlib/source/test/lux/meta/macro/local.lux
+++ b/stdlib/source/test/lux/meta/macro/local.lux
@@ -22,7 +22,8 @@
["[0]" code (.only)
["<[1]>" \\parser]]
["[0]" macro (.only)
- [syntax (.only syntax)]]]]]
+ [syntax (.only syntax)]
+ ["[0]" expansion]]]]]
[\\library
["[0]" /]])
@@ -35,7 +36,7 @@
(def macro_error
(syntax (_ [macro <code>.any])
(function (_ compiler)
- (case ((macro.expansion macro) compiler)
+ (case ((expansion.complete macro) compiler)
{try.#Failure error}
{try.#Success [compiler (list (code.text error))]}
@@ -69,7 +70,7 @@
(, pop!)
(, g!output))))]
(if pre_remove
- (macro.full_expansion pre_expansion)
+ (expansion.total pre_expansion)
(in (list pre_expansion))))))))
(def .public test
diff --git a/stdlib/source/test/lux/meta/macro/template.lux b/stdlib/source/test/lux/meta/macro/template.lux
index d2952d268..c239d6821 100644
--- a/stdlib/source/test/lux/meta/macro/template.lux
+++ b/stdlib/source/test/lux/meta/macro/template.lux
@@ -17,8 +17,9 @@
[meta
["[0]" code (.only)
["<[1]>" \\parser]]
- ["[0]" macro (.only)
- [syntax (.only syntax)]]]]]
+ [macro
+ [syntax (.only syntax)]
+ ["[0]" expansion]]]]]
[\\library
["[0]" /]])
@@ -31,7 +32,7 @@
(def macro_error
(syntax (_ [macro <code>.any])
(function (_ compiler)
- (case ((macro.expansion macro) compiler)
+ (case ((expansion.complete macro) compiler)
{try.#Failure error}
{try.#Success [compiler (list (code.text error))]}
diff --git a/stdlib/source/test/lux/meta/type/resource.lux b/stdlib/source/test/lux/meta/type/resource.lux
index 34a3bc422..65618e66a 100644
--- a/stdlib/source/test/lux/meta/type/resource.lux
+++ b/stdlib/source/test/lux/meta/type/resource.lux
@@ -20,8 +20,9 @@
["[0]" meta (.only)
["[0]" code (.only)
["<[1]>" \\parser]]
- ["[0]" macro (.only)
- [syntax (.only syntax)]]]]]
+ [macro
+ [syntax (.only syntax)]
+ ["[0]" expansion]]]]]
[\\library
["[0]" / (.only Res)]])
@@ -161,7 +162,7 @@
[[_ _ exception] (meta.export exception)]
(function (_ compiler)
{.#Right [compiler
- (list (code.bit (case ((macro.single_expansion to_expand) compiler)
+ (list (code.bit (case ((expansion.single to_expand) compiler)
{try.#Success _}
false
diff --git a/stdlib/source/test/lux/meta/version.lux b/stdlib/source/test/lux/meta/version.lux
index 1df94e003..6df9bf4e5 100644
--- a/stdlib/source/test/lux/meta/version.lux
+++ b/stdlib/source/test/lux/meta/version.lux
@@ -17,15 +17,16 @@
["[0]" static]
["[0]" code (.only)
["<[1]>" \\parser]]
- ["[0]" macro (.only)
- [syntax (.only syntax)]]]]]
+ [macro
+ [syntax (.only syntax)]
+ ["[0]" expansion]]]]]
[\\library
["[0]" /]])
(def failure
(syntax (_ [it <code>.any])
(function (_ lux)
- (case (macro.expansion it lux)
+ (case (expansion.complete it lux)
{try.#Failure error}
{try.#Success [lux (list (code.text error))]}