diff options
author | Eduardo Julian | 2019-10-15 00:50:03 -0400 |
---|---|---|
committer | Eduardo Julian | 2019-10-15 00:50:03 -0400 |
commit | 2b5351eb4624ce3c3ada994caaaea77c9d397eb8 (patch) | |
tree | e886dc45f96fcaa21687747dd6481fed1ca1c769 /stdlib/source/test | |
parent | 7d2607a34183662bb640644888fb52281a2d3ab4 (diff) |
Compiler extensions have been tested to work.
Diffstat (limited to '')
-rw-r--r-- | stdlib/source/test/lux.lux | 9 | ||||
-rw-r--r-- | stdlib/source/test/lux/extension.lux | 46 |
2 files changed, 52 insertions, 3 deletions
diff --git a/stdlib/source/test/lux.lux b/stdlib/source/test/lux.lux index d9fbc7b1d..4be2dcf27 100644 --- a/stdlib/source/test/lux.lux +++ b/stdlib/source/test/lux.lux @@ -136,6 +136,7 @@ ["#." type] ["#." world] ["#." host] + ["#." extension] ["#." target #_ ["#/." jvm]]] )) @@ -368,9 +369,11 @@ /tool.test /type.test /world.test)) - /host.test - ($_ _.and - /target/jvm.test) + (!bundle ($_ _.and + /host.test + /extension.test + ($_ _.and + /target/jvm.test))) ))) (program: args diff --git a/stdlib/source/test/lux/extension.lux b/stdlib/source/test/lux/extension.lux new file mode 100644 index 000000000..f73ad63a1 --- /dev/null +++ b/stdlib/source/test/lux/extension.lux @@ -0,0 +1,46 @@ +(.module: + [lux #* + [abstract + [monad (#+ do)]] + [control + ["<>" parser + ["<c>" code] + ["<a>" analysis]]] + [data + ["." text ("#@." equivalence) + ["%" format (#+ format)]]] + [tool + [compiler + ["." analysis] + ["." synthesis] + ["." directive] + [phase + [analysis + ["." type]]]]] + ["_" test (#+ Test)]] + {1 + ["." / (#+ analysis: synthesis: directive:)]}) + +(def: my-extension "example YOLO") + +(analysis: (..my-extension self phase {parameters (<>.some <c>.any)}) + (do @ + [_ (type.infer .Text)] + (wrap (#analysis.Extension self (list))))) + +(synthesis: (..my-extension self phase {parameters (<>.some <a>.any)}) + (wrap (synthesis.text self))) + +(directive: (..my-extension self phase {parameters (<>.some <c>.any)}) + (do @ + [#let [_ (log! (format "directive: " (%.text self)))]] + (wrap directive.no-requirements))) + +("example YOLO") + +(def: #export test + Test + (<| (_.context (%.name (name-of /._))) + (_.test "Can define and user analysis & synthesis extensions." + (text@= ("example YOLO") + "example YOLO")))) |