From 7b870a7bd124f35939d9089a2e21f0806a4c6e85 Mon Sep 17 00:00:00 2001
From: Eduardo Julian
Date: Sun, 29 Oct 2017 22:21:14 -0400
Subject: - Fixed some bugs. - Improved error reporting. - Implemented
macro-expansion (for JVM). - Implemented "let" compilation.
---
new-luxc/test/test/luxc/generator/case.lux | 13 ++++++++-----
new-luxc/test/test/luxc/generator/primitive.lux | 5 +++--
.../test/luxc/generator/procedure/host.jvm.lux | 5 +++--
new-luxc/test/test/luxc/generator/reference.lux | 22 ++++++++++++++++++++++
new-luxc/test/test/luxc/generator/structure.lux | 5 +++--
new-luxc/test/tests.lux | 3 +--
6 files changed, 40 insertions(+), 13 deletions(-)
(limited to 'new-luxc/test')
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
[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
[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]
[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
+ [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]
[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 [ ]
( 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))
--
cgit v1.2.3