aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEduardo Julian2017-10-26 22:18:26 -0400
committerEduardo Julian2017-10-26 22:18:26 -0400
commit2dc99a7b62fc5fc19d9982ad4398606f3aebb7a5 (patch)
tree7ee7c340be7c491ebef684fd66bcf4e963e223e8
parentd471b1990f2cbea67eb8f277a390d12d54d23767 (diff)
- Testing definition generation and reference.
Diffstat (limited to '')
-rw-r--r--new-luxc/test/test/luxc/generator/reference.lux56
-rw-r--r--new-luxc/test/tests.lux1
2 files changed, 57 insertions, 0 deletions
diff --git a/new-luxc/test/test/luxc/generator/reference.lux b/new-luxc/test/test/luxc/generator/reference.lux
new file mode 100644
index 000000000..0fa32acb3
--- /dev/null
+++ b/new-luxc/test/test/luxc/generator/reference.lux
@@ -0,0 +1,56 @@
+(;module:
+ lux
+ (lux [io]
+ (control [monad #+ do]
+ pipe)
+ (data ["e" error])
+ ["r" math/random]
+ [meta]
+ test)
+ (luxc (lang ["ls" synthesis])
+ ["_;" module]
+ (generator [";G" statement]
+ [";G" eval]
+ [";G" expr]
+ [";G" runtime]
+ (host ["$" jvm]
+ (jvm ["$i" inst]))))
+ (test/luxc common))
+
+(def: nilI $;Inst runtimeG;noneI)
+
+(def: cursorI
+ $;Inst
+ (|>. ($i;int 3)
+ ($i;array runtimeG;$Tuple)
+ $i;DUP ($i;int 0) ($i;string "") $i;AASTORE
+ $i;DUP ($i;int 1) ($i;long 0) ($i;wrap #$;Long) $i;AASTORE
+ $i;DUP ($i;int 2) ($i;long 0) ($i;wrap #$;Long) $i;AASTORE))
+
+(def: empty-metaI
+ (|>. ($i;int 2)
+ ($i;array runtimeG;$Tuple)
+ $i;DUP ($i;int 0) cursorI $i;AASTORE
+ $i;DUP ($i;int 1) nilI $i;AASTORE))
+
+(context: "Definitions."
+ (<| (times +100)
+ (do @
+ [module-name (r;text +5)
+ def-name (r;text +5)
+ def-value r;int
+ #let [valueI (|>. ($i;long def-value) ($i;wrap #$;Long))]]
+ ($_ seq
+ (test "Can refer to definitions."
+ (|> (do meta;Monad<Meta>
+ [_ (_module;with-module +0 module-name
+ (statementG;generate-def def-name Int valueI empty-metaI (' {})))
+ sampleI (exprG;generate (#ls;Definition [module-name def-name]))]
+ (evalG;eval sampleI))
+ (meta;run (init-compiler []))
+ (case> (#e;Success valueG)
+ (i.= def-value (:! Int valueG))
+
+ (#e;Error error)
+ false)))
+ ))))
diff --git a/new-luxc/test/tests.lux b/new-luxc/test/tests.lux
index 731667bdd..cde7c3714 100644
--- a/new-luxc/test/tests.lux
+++ b/new-luxc/test/tests.lux
@@ -24,6 +24,7 @@
["_;G" structure]
["_;G" case]
["_;G" function]
+ ["_;G" reference]
(procedure ["_;G" common]
["_;G" host]))
))