aboutsummaryrefslogtreecommitdiff
path: root/stdlib/source/test
diff options
context:
space:
mode:
authorEduardo Julian2019-12-28 17:00:04 -0400
committerEduardo Julian2019-12-28 17:00:04 -0400
commitecb53b05a226d8d3d8e612f949cb3ad6ac0600ce (patch)
treeb45698c29c29ac9171b05b62cef0fc31df5af0c5 /stdlib/source/test
parent581ccee156457b0f84696def59fc324c1cbbdaba (diff)
Implemented an alternative method for extensible JVM bytecode generation.
Diffstat (limited to 'stdlib/source/test')
-rw-r--r--stdlib/source/test/lux/extension.lux65
1 files changed, 51 insertions, 14 deletions
diff --git a/stdlib/source/test/lux/extension.lux b/stdlib/source/test/lux/extension.lux
index 7b2d9ffd5..23c33c620 100644
--- a/stdlib/source/test/lux/extension.lux
+++ b/stdlib/source/test/lux/extension.lux
@@ -1,9 +1,11 @@
(.module:
[lux #*
- ["@" target]
+ ["@" target
+ ["." jvm]]
[abstract
[monad (#+ do)]]
[control
+ ["." try]
["<>" parser
["<c>" code]
["<a>" analysis]]]
@@ -20,33 +22,68 @@
["." type]]]]]
["_" test (#+ Test)]]
{1
- ["." / (#+ analysis: synthesis: directive:)]})
+ ["." / (#+ analysis: synthesis: generation: directive:)]})
-(def: my-extension "example YOLO")
+(def: my-analysis "my analysis")
+(def: my-synthesis "my synthesis")
+(def: my-generation "my generation")
+(def: my-directive "my directive")
(`` (for {(~~ (static @.old))
- (as-is)}
- (as-is (analysis: (..my-extension self phase {parameters (<>.some <c>.any)})
+ (as-is)
+
+ (~~ (static @.jvm))
+ (as-is (generation: (..my-generation self phase {parameters (<>.some <a>.any)})
+ (#try.Success (#jvm.Constant (#jvm.LDC (#jvm.String Text))))))}
+ (as-is (analysis: (..my-analysis self phase {parameters (<>.some <c>.any)})
+ (do @
+ [_ (type.infer .Text)]
+ (wrap (#analysis.Text self))))
+
+ ## Synthesis
+ (analysis: (..my-synthesis self phase {parameters (<>.some <c>.any)})
(do @
[_ (type.infer .Text)]
(wrap (#analysis.Extension self (list)))))
- (synthesis: (..my-extension self phase {parameters (<>.some <a>.any)})
+ (synthesis: (..my-synthesis self phase {parameters (<>.some <a>.any)})
(wrap (synthesis.text self)))
+
+ ## Generation
+ (analysis: (..my-generation self phase {parameters (<>.some <c>.any)})
+ (do @
+ [_ (type.infer .Text)]
+ (wrap (#analysis.Extension self (list)))))
+
+ (synthesis: (..my-generation self phase {parameters (<>.some <a>.any)})
+ (wrap (#synthesis.Extension self (list))))
- (directive: (..my-extension self phase {parameters (<>.some <c>.any)})
+ ## Directive
+ (directive: (..my-directive self phase {parameters (<>.some <c>.any)})
(do @
- [#let [_ (log! (format "directive: " (%.text self)))]]
+ [#let [_ (log! (format "Successfully installed directive " (%.text self) "!"))]]
(wrap directive.no-requirements)))
- ("example YOLO")
+ (`` ((~~ (static ..my-directive))))
)))
(def: #export test
Test
(<| (_.context (%.name (name-of /._)))
- (_.test "Can define and use analysis & synthesis extensions."
- (`` (for {(~~ (static @.old))
- false}
- (text@= ("example YOLO")
- "example YOLO"))))))
+ ($_ _.and
+ (_.test "Can define and use analysis extensions."
+ (`` (for {(~~ (static @.old))
+ false}
+ (text@= ((~~ (static ..my-analysis)))
+ ..my-analysis))))
+ (_.test "Can define and use synthesis extensions."
+ (`` (for {(~~ (static @.old))
+ false}
+ (text@= ((~~ (static ..my-synthesis)))
+ ..my-synthesis))))
+ (_.test "Can define and use generation extensions."
+ (`` (for {(~~ (static @.old))
+ false}
+ (text@= ((~~ (static ..my-generation)))
+ ..my-generation))))
+ )))