aboutsummaryrefslogtreecommitdiff
path: root/new-luxc/test
diff options
context:
space:
mode:
authorEduardo Julian2017-10-29 22:21:14 -0400
committerEduardo Julian2017-10-29 22:21:14 -0400
commit7b870a7bd124f35939d9089a2e21f0806a4c6e85 (patch)
tree076fb3544dbb1a811cfbb9dd54008b0753dead16 /new-luxc/test
parent2dc99a7b62fc5fc19d9982ad4398606f3aebb7a5 (diff)
- Fixed some bugs.
- Improved error reporting. - Implemented macro-expansion (for JVM). - Implemented "let" compilation.
Diffstat (limited to '')
-rw-r--r--new-luxc/test/test/luxc/generator/case.lux13
-rw-r--r--new-luxc/test/test/luxc/generator/primitive.lux5
-rw-r--r--new-luxc/test/test/luxc/generator/procedure/host.jvm.lux5
-rw-r--r--new-luxc/test/test/luxc/generator/reference.lux22
-rw-r--r--new-luxc/test/test/luxc/generator/structure.lux5
-rw-r--r--new-luxc/test/tests.lux3
6 files changed, 40 insertions, 13 deletions
diff --git a/new-luxc/test/test/luxc/generator/case.lux b/new-luxc/test/test/luxc/generator/case.lux
index 34846a988..f9e165c03 100644
--- a/new-luxc/test/test/luxc/generator/case.lux
+++ b/new-luxc/test/test/luxc/generator/case.lux
@@ -12,6 +12,7 @@
[analyser]
[synthesizer]
(generator ["@" case]
+ [";G" expr]
["@;" eval]
["@;" runtime]
["@;" common]))
@@ -72,9 +73,10 @@
(test "Can generate pattern-matching."
(|> (do meta;Monad<Meta>
[runtime-bytecode @runtime;generate
- sampleI (@;generate valueS
- (#ls;AltP (#ls;SeqP path (#ls;ExecP (#ls;Bool true)))
- (#ls;SeqP (#ls;BindP +0) (#ls;ExecP (#ls;Bool false)))))]
+ sampleI (@;generate-case exprG;generate
+ valueS
+ (#ls;AltP (#ls;SeqP path (#ls;ExecP (#ls;Bool true)))
+ (#ls;SeqP (#ls;BindP +0) (#ls;ExecP (#ls;Bool false)))))]
(@eval;eval sampleI))
(meta;run (init-compiler []))
(case> (#e;Success valueG)
@@ -85,8 +87,9 @@
(test "Can bind values."
(|> (do meta;Monad<Meta>
[runtime-bytecode @runtime;generate
- sampleI (@;generate (#ls;Nat to-bind)
- (#ls;SeqP (#ls;BindP +1) (#ls;ExecP (#ls;Variable 1))))]
+ sampleI (@;generate-case exprG;generate
+ (#ls;Nat to-bind)
+ (#ls;SeqP (#ls;BindP +1) (#ls;ExecP (#ls;Variable 1))))]
(@eval;eval sampleI))
(meta;run (init-compiler []))
(case> (#e;Success valueG)
diff --git a/new-luxc/test/test/luxc/generator/primitive.lux b/new-luxc/test/test/luxc/generator/primitive.lux
index 2e909dd7e..66eacca27 100644
--- a/new-luxc/test/test/luxc/generator/primitive.lux
+++ b/new-luxc/test/test/luxc/generator/primitive.lux
@@ -10,7 +10,8 @@
["r" math/random]
[meta]
test)
- (luxc (lang ["ls" synthesis])
+ (luxc [";L" host]
+ (lang ["ls" synthesis])
[analyser]
[synthesizer]
(generator ["@" expr]
@@ -54,7 +55,7 @@
(@eval;eval sampleI))
(meta;run (init-compiler []))
(case> (#e;Success valueG)
- (is @runtime;unit (:! Text valueG))
+ (is hostL;unit (:! Text valueG))
_
false)))
diff --git a/new-luxc/test/test/luxc/generator/procedure/host.jvm.lux b/new-luxc/test/test/luxc/generator/procedure/host.jvm.lux
index 097c2b802..7a047dff9 100644
--- a/new-luxc/test/test/luxc/generator/procedure/host.jvm.lux
+++ b/new-luxc/test/test/luxc/generator/procedure/host.jvm.lux
@@ -15,7 +15,8 @@
[meta #+ Monad<Meta>]
[host]
test)
- (luxc (lang ["ls" synthesis])
+ (luxc [";L" host]
+ (lang ["ls" synthesis])
[analyser]
[synthesizer]
(generator ["@" expr]
@@ -520,7 +521,7 @@
(@eval;eval sampleI))
(meta;run (init-compiler []))
(case> (#e;Success outputG)
- (is @runtime;unit (:! Text outputG))
+ (is hostL;unit (:! Text outputG))
(#e;Error error)
false)))
diff --git a/new-luxc/test/test/luxc/generator/reference.lux b/new-luxc/test/test/luxc/generator/reference.lux
index 0fa32acb3..32f9c1b80 100644
--- a/new-luxc/test/test/luxc/generator/reference.lux
+++ b/new-luxc/test/test/luxc/generator/reference.lux
@@ -12,6 +12,7 @@
(generator [";G" statement]
[";G" eval]
[";G" expr]
+ [";G" case]
[";G" runtime]
(host ["$" jvm]
(jvm ["$i" inst]))))
@@ -54,3 +55,24 @@
(#e;Error error)
false)))
))))
+
+(context: "Variables."
+ (<| (times +100)
+ (do @
+ [register (|> r;nat (:: @ map (n.% +100)))
+ value r;int]
+ ($_ seq
+ (test "Can refer to local variables/registers."
+ (|> (do meta;Monad<Meta>
+ [sampleI (caseG;generate-let exprG;generate
+ register
+ (#ls;Int value)
+ (#ls;Variable (nat-to-int register)))]
+ (evalG;eval sampleI))
+ (meta;run (init-compiler []))
+ (case> (#e;Success outputG)
+ (i.= value (:! Int outputG))
+
+ (#e;Error error)
+ false)))
+ ))))
diff --git a/new-luxc/test/test/luxc/generator/structure.lux b/new-luxc/test/test/luxc/generator/structure.lux
index 927ff9ec8..7a14788b7 100644
--- a/new-luxc/test/test/luxc/generator/structure.lux
+++ b/new-luxc/test/test/luxc/generator/structure.lux
@@ -14,7 +14,8 @@
[meta #+ Monad<Meta>]
[host]
test)
- (luxc (lang ["ls" synthesis])
+ (luxc [";L" host]
+ (lang ["ls" synthesis])
[analyser]
[synthesizer]
(generator ["@" expr]
@@ -39,7 +40,7 @@
(-> [ls;Synthesis Top] Bool)
(case prediction
#ls;Unit
- (is @runtime;unit (:! Text sample))
+ (is hostL;unit (:! Text sample))
(^template [<tag> <type> <test>]
(<tag> prediction')
diff --git a/new-luxc/test/tests.lux b/new-luxc/test/tests.lux
index cde7c3714..13eb44402 100644
--- a/new-luxc/test/tests.lux
+++ b/new-luxc/test/tests.lux
@@ -27,8 +27,7 @@
["_;G" reference]
(procedure ["_;G" common]
["_;G" host]))
- ))
- )
+ )))
(program: args
(test;run))