From 6a98c0fb63a2be654bb220051b4cb5e5cae6daa3 Mon Sep 17 00:00:00 2001 From: Eduardo Julian Date: Thu, 22 Feb 2018 01:31:50 -0400 Subject: - Unified translation tests. --- new-luxc/test/test/luxc/common.lux | 18 +- new-luxc/test/test/luxc/lang/translation/case.lux | 125 ++++ .../test/test/luxc/lang/translation/common.lux | 473 +++++++++++++++ .../test/test/luxc/lang/translation/function.lux | 116 ++++ .../test/test/luxc/lang/translation/js/case.lux | 107 ---- .../test/luxc/lang/translation/js/function.lux | 103 ---- .../test/luxc/lang/translation/js/primitive.lux | 64 -- .../lang/translation/js/procedure/common.jvm.lux | 405 ------------- .../test/luxc/lang/translation/js/reference.lux | 82 --- .../test/luxc/lang/translation/js/structure.lux | 113 ---- new-luxc/test/test/luxc/lang/translation/jvm.lux | 645 ++++++++++++++++++++ .../test/test/luxc/lang/translation/jvm/case.lux | 108 ---- .../test/luxc/lang/translation/jvm/function.lux | 103 ---- .../test/luxc/lang/translation/jvm/primitive.lux | 65 --- .../lang/translation/jvm/procedure/common.jvm.lux | 385 ------------ .../lang/translation/jvm/procedure/host.jvm.lux | 646 --------------------- .../test/luxc/lang/translation/jvm/reference.lux | 76 --- .../test/luxc/lang/translation/jvm/structure.lux | 113 ---- .../test/test/luxc/lang/translation/primitive.lux | 80 +++ .../test/test/luxc/lang/translation/reference.lux | 113 ++++ .../test/test/luxc/lang/translation/structure.lux | 143 +++++ new-luxc/test/tests.lux | 23 +- 22 files changed, 1713 insertions(+), 2393 deletions(-) create mode 100644 new-luxc/test/test/luxc/lang/translation/case.lux create mode 100644 new-luxc/test/test/luxc/lang/translation/common.lux create mode 100644 new-luxc/test/test/luxc/lang/translation/function.lux delete mode 100644 new-luxc/test/test/luxc/lang/translation/js/case.lux delete mode 100644 new-luxc/test/test/luxc/lang/translation/js/function.lux delete mode 100644 new-luxc/test/test/luxc/lang/translation/js/primitive.lux delete mode 100644 new-luxc/test/test/luxc/lang/translation/js/procedure/common.jvm.lux delete mode 100644 new-luxc/test/test/luxc/lang/translation/js/reference.lux delete mode 100644 new-luxc/test/test/luxc/lang/translation/js/structure.lux create mode 100644 new-luxc/test/test/luxc/lang/translation/jvm.lux delete mode 100644 new-luxc/test/test/luxc/lang/translation/jvm/case.lux delete mode 100644 new-luxc/test/test/luxc/lang/translation/jvm/function.lux delete mode 100644 new-luxc/test/test/luxc/lang/translation/jvm/primitive.lux delete mode 100644 new-luxc/test/test/luxc/lang/translation/jvm/procedure/common.jvm.lux delete mode 100644 new-luxc/test/test/luxc/lang/translation/jvm/procedure/host.jvm.lux delete mode 100644 new-luxc/test/test/luxc/lang/translation/jvm/reference.lux delete mode 100644 new-luxc/test/test/luxc/lang/translation/jvm/structure.lux create mode 100644 new-luxc/test/test/luxc/lang/translation/primitive.lux create mode 100644 new-luxc/test/test/luxc/lang/translation/reference.lux create mode 100644 new-luxc/test/test/luxc/lang/translation/structure.lux diff --git a/new-luxc/test/test/luxc/common.lux b/new-luxc/test/test/luxc/common.lux index b9f5af6bd..c2082dc81 100644 --- a/new-luxc/test/test/luxc/common.lux +++ b/new-luxc/test/test/luxc/common.lux @@ -1,14 +1,18 @@ (.module: lux - (lux [io]) + (lux (control [monad #+ do]) + [io #+ IO]) (luxc (lang ["&." host] [".L" init] (translation [js])))) -(def: #export (init-compiler _) - (-> Top Compiler) - (initL.compiler (io.run &host.init-host))) +(do-template [ ] + [(def: #export + (IO Compiler) + (do io.Monad + [host ] + (wrap (initL.compiler host))))] -(def: #export (init-js _) - (-> Top Compiler) - (initL.compiler (io.run js.init))) + [init-jvm &host.init-host] + [init-js js.init] + ) diff --git a/new-luxc/test/test/luxc/lang/translation/case.lux b/new-luxc/test/test/luxc/lang/translation/case.lux new file mode 100644 index 000000000..9bc7a69da --- /dev/null +++ b/new-luxc/test/test/luxc/lang/translation/case.lux @@ -0,0 +1,125 @@ +(.module: + lux + (lux [io #+ IO] + (control [monad #+ do] + pipe) + (data ["e" error] + text/format + (coll [list])) + ["r" math/random "r/" Monad] + [macro] + (macro [code]) + test) + (luxc [lang] + (lang ["ls" synthesis] + (translation (jvm ["/_jvm" case] + [".T_jvm" expression] + [".T_jvm" eval] + [".T_jvm" runtime]) + (js ["/_js" case] + [".T_js" expression] + [".T_js" eval] + [".T_js" runtime])))) + (test/luxc common)) + +(def: struct-limit Nat +10) + +(def: (tail? size idx) + (-> Nat Nat Bool) + (n/= (n/dec size) idx)) + +(def: gen-case + (r.Random [ls.Synthesis ls.Path]) + (<| r.rec (function [gen-case]) + (`` ($_ r.either + (r/wrap [(' []) (' ("lux case pop"))]) + (~~ (do-template [ ] + [(do r.Monad + [value ] + (wrap [( value) ( value)]))] + + [r.bool code.bool] + [r.nat code.nat] + [r.int code.int] + [r.deg code.deg] + [r.frac code.frac] + [(r.text +5) code.text])) + (do r.Monad + [size (|> r.nat (:: @ map (|>> (n/% struct-limit) (n/max +2)))) + idx (|> r.nat (:: @ map (n/% size))) + [subS subP] gen-case + #let [caseS (` [(~+ (list.concat (list (list.repeat idx (' [])) + (list subS) + (list.repeat (|> size n/dec (n/- idx)) (' [])))))]) + caseP (` ("lux case seq" + (~ (if (tail? size idx) + (` ("lux case tuple right" (~ (code.nat idx)))) + (` ("lux case tuple left" (~ (code.nat idx)))))) + (~ subP)))]] + (wrap [caseS caseP])) + (do r.Monad + [size (|> r.nat (:: @ map (|>> (n/% struct-limit) (n/max +2)))) + idx (|> r.nat (:: @ map (n/% size))) + [subS subP] gen-case + #let [caseS (` ((~ (code.nat idx)) (~ (code.bool (tail? size idx))) (~ subS))) + caseP (` ("lux case seq" + (~ (if (tail? size idx) + (` ("lux case variant right" (~ (code.nat idx)))) + (` ("lux case variant left" (~ (code.nat idx)))))) + (~ subP)))]] + (wrap [caseS caseP])) + )))) + +(def: (pattern-matching-spec translate-expression eval translate-runtime init + translate-case) + (All [a] + (-> (-> ls.Synthesis (Meta a)) (-> a (Meta Top)) (Meta Top) (IO Compiler) + (-> (-> ls.Synthesis (Meta a)) ls.Synthesis ls.Path (Meta a)) + Test)) + (do r.Monad + [[valueS pathS] gen-case + to-bind r.nat] + ($_ seq + (test "Can translate pattern-matching." + (|> (do macro.Monad + [_ translate-runtime + sampleO (translate-case translate-expression + valueS + (` ("lux case alt" + ("lux case seq" (~ pathS) + ("lux case exec" true)) + ("lux case seq" ("lux case bind" +0) + ("lux case exec" false)))))] + (eval sampleO)) + (lang.with-current-module "") + (macro.run (io.run init)) + (case> (#e.Success valueT) + (:! Bool valueT) + + (#e.Error error) + false))) + (test "Can bind values." + (|> (do macro.Monad + [_ translate-runtime + sampleO (translate-case translate-expression + (code.nat to-bind) + (` ("lux case seq" ("lux case bind" +0) + ("lux case exec" (0)))))] + (eval sampleO)) + (lang.with-current-module "") + (macro.run (io.run init)) + (case> (#e.Success valueT) + (n/= to-bind (:! Nat valueT)) + + (#e.Error error) + false)))))) + +(context: "[JVM] Pattern-matching." + (<| (times +100) + (pattern-matching-spec expressionT_jvm.translate evalT_jvm.eval runtimeT_jvm.translate init-jvm + /_jvm.translate-case))) + +(context: "[JS] Pattern-matching." + (<| (times +100) + (pattern-matching-spec expressionT_js.translate evalT_js.eval runtimeT_js.translate init-js + /_js.translate-case))) diff --git a/new-luxc/test/test/luxc/lang/translation/common.lux b/new-luxc/test/test/luxc/lang/translation/common.lux new file mode 100644 index 000000000..7b7445737 --- /dev/null +++ b/new-luxc/test/test/luxc/lang/translation/common.lux @@ -0,0 +1,473 @@ +(.module: + lux + (lux [io #+ IO] + (control [monad #+ do] + pipe) + (data text/format + [bit] + ["e" error] + [bool "bool/" Eq] + [text "text/" Eq] + [number "nat/" Interval "int/" Number Interval "frac/" Number Interval "deg/" Interval] + (coll ["a" array] + [list])) + ["r" math/random] + [macro] + (macro [code]) + [host] + test) + (luxc [lang] + (lang ["ls" synthesis] + (translation (jvm [".T_jvm" eval] + [".T_jvm" expression] + [".T_jvm" runtime]) + (js [".T_js" eval] + [".T_js" expression] + [".T_js" runtime])))) + (test/luxc common)) + +(def: (bit-spec translate-expression eval translate-runtime init) + (All [a] + (-> (-> ls.Synthesis (Meta a)) (-> a (Meta Top)) (Meta Top) (IO Compiler) + Test)) + (do r.Monad + [param r.nat + subject r.nat] + (with-expansions [ (do-template [ ] + [(test + (|> (do macro.Monad + [_ translate-runtime + sampleJS (translate-expression (` ( (~ (code.nat subject)) + (~ (code.nat param)))))] + (eval sampleJS)) + (lang.with-current-module "") + (macro.run (io.run init)) + (case> (#e.Success valueT) + (n/= ( param subject) (:! Nat valueT)) + + (#e.Error error) + false) + (let [param ])))] + + ["lux bit and" bit.and param] + ["lux bit or" bit.or param] + ["lux bit xor" bit.xor param] + ["lux bit shift-left" bit.shift-left (n/% +64 param)] + ["lux bit unsigned-shift-right" bit.shift-right (n/% +64 param)] + )] + ($_ seq + (test "lux bit count" + (|> (do macro.Monad + [_ translate-runtime + sampleJS (translate-expression (` ("lux bit count" (~ (code.nat subject)))))] + (eval sampleJS)) + (lang.with-current-module "") + (macro.run (io.run init)) + (case> (#e.Success valueT) + (n/= (bit.count subject) (:! Nat valueT)) + + (#e.Error error) + false))) + + + (test "lux bit shift-right" + (|> (do macro.Monad + [_ translate-runtime + sampleJS (translate-expression (` ("lux bit shift-right" + (~ (code.int (nat-to-int subject))) + (~ (code.nat param)))))] + (eval sampleJS)) + (lang.with-current-module "") + (macro.run (io.run init)) + (case> (#e.Success valueT) + (i/= (bit.signed-shift-right param (nat-to-int subject)) + (:! Int valueT)) + + (#e.Error error) + false) + (let [param (n/% +64 param)]))) + )))) + +(def: (nat-spec translate-expression eval translate-runtime init) + (All [a] + (-> (-> ls.Synthesis (Meta a)) (-> a (Meta Top)) (Meta Top) (IO Compiler) + Test)) + (do r.Monad + [param (|> r.nat (r.filter (|>> (n/= +0) not))) + subject r.nat] + (`` ($_ seq + (~~ (do-template [ ] + [(test + (|> (do macro.Monad + [_ translate-runtime + sampleJS (translate-expression (` ()))] + (eval sampleJS)) + (lang.with-current-module "") + (macro.run (io.run init)) + (case> (#e.Success valueT) + (n/= (:! Nat valueT)) + + (#e.Error error) + false)))] + + ["lux nat min" nat/bottom] + ["lux nat max" nat/top] + )) + (~~ (do-template [ ] + [(test + (|> (do macro.Monad + [_ translate-runtime + sampleJS (translate-expression (` ( (~ (code.nat subject)))))] + (eval sampleJS)) + (lang.with-current-module "") + (macro.run (io.run init)) + (case> (#e.Success valueT) + ( ( subject) (:! valueT)) + + (#e.Error error) + false) + (let [subject ])))] + + ["lux nat to-int" Int nat-to-int i/= subject] + ["lux nat char" Text text.from-code text/= (n/% (bit.shift-left +32 +1) subject)] + )) + (~~ (do-template [ ] + [(test + (|> (do macro.Monad + [_ translate-runtime + sampleJS (translate-expression (` ( (~ (code.nat subject)) (~ (code.nat param)))))] + (eval sampleJS)) + (lang.with-current-module "") + (macro.run (io.run init)) + (case> (#e.Success valueT) + ( ( param subject) (:! valueT)) + + _ + false)))] + + ["lux nat +" n/+ Nat n/=] + ["lux nat -" n/- Nat n/=] + ["lux nat *" n/* Nat n/=] + ["lux nat /" n// Nat n/=] + ["lux nat %" n/% Nat n/=] + ["lux nat =" n/= Bool bool/=] + ["lux nat <" n/< Bool bool/=] + )) + )))) + +(def: (int-spec translate-expression eval translate-runtime init) + (All [a] + (-> (-> ls.Synthesis (Meta a)) (-> a (Meta Top)) (Meta Top) (IO Compiler) + Test)) + (do r.Monad + [param (|> r.int (r.filter (|>> (i/= 0) not))) + subject r.int] + (with-expansions [ (do-template [ ] + [(test + (|> (do macro.Monad + [_ translate-runtime + sampleJS (translate-expression (` ()))] + (eval sampleJS)) + (lang.with-current-module "") + (macro.run (io.run init)) + (case> (#e.Success valueT) + (i/= (:! Int valueT)) + + (#e.Error error) + false)))] + + ["lux int min" int/bottom] + ["lux int max" int/top] + ) + (do-template [ ] + [(test + (|> (do macro.Monad + [_ translate-runtime + sampleJS (translate-expression (` ( (~ (code.int subject)))))] + (eval sampleJS)) + (lang.with-current-module "") + (macro.run (io.run init)) + (case> (#e.Success valueT) + ( ( subject) (:! valueT)) + + (#e.Error error) + false)))] + + ["lux int to-nat" Nat int-to-nat n/=] + ["lux int to-frac" Frac int-to-frac f/=] + ) + (do-template [ ] + [(test + (|> (do macro.Monad + [_ translate-runtime + sampleJS (translate-expression (` ( (~ (code.int subject)) (~ (code.int param)))))] + (eval sampleJS)) + (lang.with-current-module "") + (macro.run (io.run init)) + (case> (#e.Success valueT) + ( ( param subject) (:! valueT)) + + _ + false)))] + + ["lux int +" i/+ Int i/=] + ["lux int -" i/- Int i/=] + ["lux int *" i/* Int i/=] + ["lux int /" i// Int i/=] + ["lux int %" i/% Int i/=] + ["lux int =" i/= Bool bool/=] + ["lux int <" i/< Bool bool/=] + )] + ($_ seq + + + + )))) + +(def: (frac-spec|0 translate-expression eval translate-runtime init) + (All [a] + (-> (-> ls.Synthesis (Meta a)) (-> a (Meta Top)) (Meta Top) (IO Compiler) + Test)) + (do r.Monad + [param (|> r.frac (r.filter (|>> (f/= 0.0) not))) + subject r.frac] + (with-expansions [ (do-template [ ] + [(test + (|> (do macro.Monad + [_ translate-runtime + sampleJS (translate-expression (` ( (~ (code.frac subject)) (~ (code.frac param)))))] + (eval sampleJS)) + (lang.with-current-module "") + (macro.run (io.run init)) + (case> (#e.Success valueT) + ( ( param subject) (:! valueT)) + + _ + false)))] + + ["lux frac +" f/+ Frac f/=] + ["lux frac -" f/- Frac f/=] + ["lux frac *" f/* Frac f/=] + ["lux frac /" f// Frac f/=] + ["lux frac %" f/% Frac f/=] + ["lux frac =" f/= Bool bool/=] + ["lux frac <" f/< Bool bool/=] + )] + ($_ seq + + )))) + +(def: (frac-spec|1 translate-expression eval translate-runtime init) + (All [a] + (-> (-> ls.Synthesis (Meta a)) (-> a (Meta Top)) (Meta Top) (IO Compiler) + Test)) + (do r.Monad + [param (|> r.frac (r.filter (|>> (f/= 0.0) not))) + subject r.frac] + (with-expansions [ (do-template [ ] + [(test + (|> (do macro.Monad + [_ translate-runtime + sampleJS (translate-expression (` ()))] + (eval sampleJS)) + (lang.with-current-module "") + (macro.run (io.run init)) + (case> (#e.Success valueT) + ( (:! Frac valueT)) + + _ + false)))] + + ["lux frac min" (f/= frac/bottom)] + ["lux frac max" (f/= frac/top)] + ["lux frac not-a-number" number.not-a-number?] + ["lux frac positive-infinity" (f/= number.positive-infinity)] + ["lux frac negative-infinity" (f/= number.negative-infinity)] + ["lux frac smallest" (f/= ("lux frac smallest"))] + ) + (do-template [ ] + [(test + (|> (do macro.Monad + [_ translate-runtime + sampleJS (translate-expression (` ( ( (~ (code.frac subject))))))] + (eval sampleJS)) + (lang.with-current-module "") + (macro.run (io.run init)) + (case> (#e.Success valueT) + (|> valueT (:! Frac) (f/- subject) frac/abs ) + + (#e.Error error) + false)))] + + ["lux frac to-int" "lux int to-frac" (f/< 1.0)] + ["lux frac to-deg" "lux deg to-frac" (f/<= 0.000000001)])] + ($_ seq + + + (test "frac encode|decode" + (|> (do macro.Monad + [_ translate-runtime + sampleJS (translate-expression (` ("lux frac decode" ("lux frac encode" (~ (code.frac subject))))))] + (eval sampleJS)) + (lang.with-current-module "") + (macro.run (io.run init)) + (case> (^multi (#e.Success valueT) + [(:! (Maybe Frac) valueT) (#.Some value)]) + (f/= subject value) + + _ + false))) + )))) + +(def: (frac-spec translate-expression eval translate-runtime init) + (All [a] + (-> (-> ls.Synthesis (Meta a)) (-> a (Meta Top)) (Meta Top) (IO Compiler) + Test)) + ($_ seq + (frac-spec|0 translate-expression eval translate-runtime init) + (frac-spec|1 translate-expression eval translate-runtime init))) + +(def: deg-threshold + {#.doc "1/(2^30)"} + Deg + .000000001) + +(def: (above-threshold value) + (-> Deg Deg) + (if (d/< deg-threshold value) + (d/+ deg-threshold value) + value)) + +(def: (deg-difference reference sample) + (-> Deg Deg Deg) + (if (d/> reference sample) + (d/- reference sample) + (d/- sample reference))) + +(def: (deg-spec translate-expression eval translate-runtime init) + (All [a] + (-> (-> ls.Synthesis (Meta a)) (-> a (Meta Top)) (Meta Top) (IO Compiler) + Test)) + (do r.Monad + [param (|> r.deg (:: @ map above-threshold)) + special r.nat + subject (|> r.deg (:: @ map above-threshold))] + (`` ($_ seq + (~~ (do-template [ ] + [(test + (|> (do macro.Monad + [_ translate-runtime + sampleJS (translate-expression (` ()))] + (eval sampleJS)) + (lang.with-current-module "") + (macro.run (io.run init)) + (case> (#e.Success valueT) + (d/= (:! Deg valueT)) + + _ + false)))] + + ["lux deg min" deg/bottom] + ["lux deg max" deg/top] + )) + (~~ (do-template [ ] + [(test + (|> (do macro.Monad + [_ translate-runtime + sampleJS (translate-expression (` ( ( (~ (code.deg subject))))))] + (eval sampleJS)) + (lang.with-current-module "") + (macro.run (io.run init)) + (case> (#e.Success valueV) + (d/<= deg-threshold (deg-difference subject (:! valueV))) + + _ + false)))] + + ["lux deg to-frac" "lux frac to-deg" Deg] + )) + (~~ (do-template [ ] + [(test + (|> (do macro.Monad + [_ translate-runtime + sampleJS (translate-expression (` ( (~ (code.deg subject)) (~ (code.deg param)))))] + (eval sampleJS)) + (lang.with-current-module "") + (macro.run (io.run init)) + (case> (#e.Success valueT) + ( ( param subject) (:! valueT)) + + _ + false)))] + + ["lux deg +" d/+ Deg d/=] + ["lux deg -" d/- Deg d/=] + ["lux deg *" d/* Deg d/=] + ["lux deg /" d// Deg d/=] + ["lux deg %" d/% Deg d/=] + ["lux deg =" d/= Bool bool/=] + ["lux deg <" d/< Bool bool/=] + )) + (~~ (do-template [ ] + [(test + (|> (do macro.Monad + [_ translate-runtime + sampleJS (translate-expression (` ( (~ (code.deg subject)) (~ (code.nat special)))))] + (eval sampleJS)) + (lang.with-current-module "") + (macro.run (io.run init)) + (case> (#e.Success valueT) + ( ( special subject) (:! valueT)) + + _ + false)))] + + ["lux deg scale" d/scale Deg d/=] + ["lux deg reciprocal" d/reciprocal Deg d/=] + )) + )))) + +## Bit +(context: "[JVM] Bit procedures" + (<| (times +100) + (bit-spec expressionT_jvm.translate evalT_jvm.eval runtimeT_jvm.translate init-jvm))) + +(context: "[JS] Bit procedures" + (<| (times +100) + (bit-spec expressionT_js.translate evalT_js.eval runtimeT_js.translate init-js))) + +## Nat +(context: "[JVM] Nat procedures" + (<| (times +100) + (nat-spec expressionT_jvm.translate evalT_jvm.eval runtimeT_jvm.translate init-jvm))) + +(context: "[JS] Nat procedures" + (<| (times +100) + (nat-spec expressionT_js.translate evalT_js.eval runtimeT_js.translate init-js))) + +## Int +(context: "[JVM] Int procedures" + (<| (times +100) + (int-spec expressionT_jvm.translate evalT_jvm.eval runtimeT_jvm.translate init-jvm))) + +(context: "[JS] Int procedures" + (<| (times +100) + (int-spec expressionT_js.translate evalT_js.eval runtimeT_js.translate init-js))) + +## Frac +(context: "[JVM] Frac procedures" + (<| (times +100) + (frac-spec expressionT_jvm.translate evalT_jvm.eval runtimeT_jvm.translate init-jvm))) + +(context: "[JS] Frac procedures" + (<| (times +100) + (frac-spec expressionT_js.translate evalT_js.eval runtimeT_js.translate init-js))) + +## Deg +(context: "[JVM] Deg procedures" + (<| (times +100) + (deg-spec expressionT_jvm.translate evalT_jvm.eval runtimeT_jvm.translate init-jvm))) + +(context: "[JS] Deg procedures" + (<| (times +100) + (deg-spec expressionT_js.translate evalT_js.eval runtimeT_js.translate init-js))) diff --git a/new-luxc/test/test/luxc/lang/translation/function.lux b/new-luxc/test/test/luxc/lang/translation/function.lux new file mode 100644 index 000000000..777cea55c --- /dev/null +++ b/new-luxc/test/test/luxc/lang/translation/function.lux @@ -0,0 +1,116 @@ +(.module: + lux + (lux [io #+ IO] + (control [monad #+ do] + pipe) + (data [product] + [maybe] + ["e" error] + (coll ["a" array] + [list "list/" Functor])) + ["r" math/random "r/" Monad] + [macro] + (macro [code]) + [host] + test) + (luxc [lang] + (lang ["ls" synthesis] + (translation (jvm [".T_jvm" eval] + [".T_jvm" expression] + [".T_jvm" runtime]) + (js [".T_js" eval] + [".T_js" expression] + [".T_js" runtime])))) + (test/luxc common)) + +(def: arity-limit Nat +10) + +(def: arity + (r.Random ls.Arity) + (|> r.nat (r/map (|>> (n/% arity-limit) (n/max +1))))) + +(def: gen-function + (r.Random [ls.Arity Nat ls.Synthesis]) + (do r.Monad + [arity arity + arg (|> r.nat (:: @ map (n/% arity))) + #let [functionS (` ("lux function" (~ (code.nat arity)) [] + ((~ (code.int (nat-to-int (n/inc arg)))))))]] + (wrap [arity arg functionS]))) + +(def: (function-spec translate-expression eval translate-runtime init) + (All [a] + (-> (-> ls.Synthesis (Meta a)) (-> a (Meta Top)) (Meta Top) (IO Compiler) + Test)) + (do r.Monad + [[arity arg functionS] gen-function + cut-off (|> r.nat (:: @ map (n/% arity))) + args (r.list arity r.nat) + #let [arg-value (maybe.assume (list.nth arg args)) + argsS (list/map code.nat args) + last-arg (n/dec arity) + cut-off (|> cut-off (n/min (n/dec last-arg)))]] + ($_ seq + (test "Can read arguments." + (|> (do macro.Monad + [_ translate-runtime + sampleO (translate-expression (` ("lux call" (~ functionS) (~+ argsS))))] + (eval sampleO)) + (lang.with-current-module "") + (macro.run (io.run init)) + (case> (#e.Success valueT) + (n/= arg-value (:! Nat valueT)) + + (#e.Error error) + false))) + (test "Can partially apply functions." + (or (n/= +1 arity) + (|> (do macro.Monad + [#let [partial-arity (n/inc cut-off) + preS (list.take partial-arity argsS) + postS (list.drop partial-arity argsS)] + _ translate-runtime + sampleO (translate-expression (` ("lux call" + ("lux call" (~ functionS) (~+ preS)) + (~+ postS))))] + (eval sampleO)) + (lang.with-current-module "") + (macro.run (io.run init)) + (case> (#e.Success valueT) + (n/= arg-value (:! Nat valueT)) + + (#e.Error error) + false)))) + (test "Can read environment." + (or (n/= +1 arity) + (|> (do macro.Monad + [#let [env (|> (list.n/range +0 cut-off) + (list/map (|>> n/inc nat-to-int))) + super-arity (n/inc cut-off) + arg-var (if (n/<= cut-off arg) + (|> arg n/inc nat-to-int (i/* -1)) + (|> arg n/inc (n/- super-arity) nat-to-int)) + sub-arity (|> arity (n/- super-arity)) + functionS (` ("lux function" (~ (code.nat super-arity)) [] + ("lux function" (~ (code.nat sub-arity)) [(~+ (list/map code.int env))] + ((~ (code.int arg-var))))))] + _ translate-runtime + sampleO (translate-expression (` ("lux call" (~ functionS) (~+ argsS))))] + (eval sampleO)) + (lang.with-current-module "") + (macro.run (io.run init)) + (case> (#e.Success valueT) + (n/= arg-value (:! Nat valueT)) + + (#e.Error error) + (exec (log! error) + false))))) + ))) + +(context: "[JVM] Function." + (<| (times +100) + (function-spec expressionT_jvm.translate evalT_jvm.eval runtimeT_jvm.translate init-jvm))) + +(context: "[JS] Function." + (<| (times +100) + (function-spec expressionT_js.translate evalT_js.eval runtimeT_js.translate init-js))) diff --git a/new-luxc/test/test/luxc/lang/translation/js/case.lux b/new-luxc/test/test/luxc/lang/translation/js/case.lux deleted file mode 100644 index ea527b86b..000000000 --- a/new-luxc/test/test/luxc/lang/translation/js/case.lux +++ /dev/null @@ -1,107 +0,0 @@ -(.module: - lux - (lux [io] - (control [monad #+ do] - pipe) - (data ["e" error] - text/format - (coll [list])) - ["r" math/random "r/" Monad] - [macro] - (macro [code]) - test) - (luxc [lang] - (lang ["ls" synthesis] - (translation (js ["/" case] - [".T" expression] - [".T" eval] - [".T" runtime])))) - (test/luxc common)) - -(def: struct-limit Nat +10) - -(def: (tail? size idx) - (-> Nat Nat Bool) - (n/= (n/dec size) idx)) - -(def: gen-case - (r.Random [ls.Synthesis ls.Path]) - (<| r.rec (function [gen-case]) - (`` ($_ r.either - (r/wrap [(' []) (' ("lux case pop"))]) - (~~ (do-template [ ] - [(do r.Monad - [value ] - (wrap [( value) ( value)]))] - - [r.bool code.bool] - [r.nat code.nat] - [r.int code.int] - [r.deg code.deg] - [r.frac code.frac] - [(r.text +5) code.text])) - (do r.Monad - [size (|> r.nat (:: @ map (|>> (n/% struct-limit) (n/max +2)))) - idx (|> r.nat (:: @ map (n/% size))) - [subS subP] gen-case - #let [caseS (` [(~+ (list.concat (list (list.repeat idx (' [])) - (list subS) - (list.repeat (|> size n/dec (n/- idx)) (' [])))))]) - caseP (` ("lux case seq" - (~ (if (tail? size idx) - (` ("lux case tuple right" (~ (code.nat idx)))) - (` ("lux case tuple left" (~ (code.nat idx)))))) - (~ subP)))]] - (wrap [caseS caseP])) - (do r.Monad - [size (|> r.nat (:: @ map (|>> (n/% struct-limit) (n/max +2)))) - idx (|> r.nat (:: @ map (n/% size))) - [subS subP] gen-case - #let [caseS (` ((~ (code.nat idx)) (~ (code.bool (tail? size idx))) (~ subS))) - caseP (` ("lux case seq" - (~ (if (tail? size idx) - (` ("lux case variant right" (~ (code.nat idx)))) - (` ("lux case variant left" (~ (code.nat idx)))))) - (~ subP)))]] - (wrap [caseS caseP])) - )))) - -(context: "Pattern-matching." - (<| (times +100) - (do @ - [[valueS pathS] gen-case - to-bind r.nat] - ($_ seq - (test "Can translate pattern-matching." - (|> (do macro.Monad - [_ runtimeT.translate - sampleJS (/.translate-case expressionT.translate - valueS - (` ("lux case alt" - ("lux case seq" (~ pathS) - ("lux case exec" true)) - ("lux case seq" ("lux case bind" +0) - ("lux case exec" false)))))] - (evalT.eval sampleJS)) - (lang.with-current-module "") - (macro.run (init-js [])) - (case> (#e.Success valueT) - (:! Bool valueT) - - (#e.Error error) - false))) - (test "Can bind values." - (|> (do macro.Monad - [_ runtimeT.translate - sampleJS (/.translate-case expressionT.translate - (code.nat to-bind) - (` ("lux case seq" ("lux case bind" +0) - ("lux case exec" (0)))))] - (evalT.eval sampleJS)) - (lang.with-current-module "") - (macro.run (init-js [])) - (case> (#e.Success valueT) - (n/= to-bind (:! Nat valueT)) - - _ - false))))))) diff --git a/new-luxc/test/test/luxc/lang/translation/js/function.lux b/new-luxc/test/test/luxc/lang/translation/js/function.lux deleted file mode 100644 index 6cb1e64cc..000000000 --- a/new-luxc/test/test/luxc/lang/translation/js/function.lux +++ /dev/null @@ -1,103 +0,0 @@ -(.module: - lux - (lux [io] - (control [monad #+ do] - pipe) - (data [product] - [maybe] - ["e" error] - (coll ["a" array] - [list "list/" Functor])) - ["r" math/random "r/" Monad] - [macro] - (macro [code]) - [host] - test) - (luxc [lang] - (lang ["ls" synthesis] - (translation (js [".T" expression] - [".T" eval] - [".T" runtime])))) - (test/luxc common)) - -(def: arity-limit Nat +10) - -(def: arity - (r.Random ls.Arity) - (|> r.nat (r/map (|>> (n/% arity-limit) (n/max +1))))) - -(def: gen-function - (r.Random [ls.Arity Nat ls.Synthesis]) - (do r.Monad - [arity arity - arg (|> r.nat (:: @ map (n/% arity))) - #let [functionS (` ("lux function" (~ (code.nat arity)) [] - ((~ (code.int (nat-to-int (n/inc arg)))))))]] - (wrap [arity arg functionS]))) - -(context: "Function." - (<| (times +100) - (do @ - [[arity arg functionS] gen-function - cut-off (|> r.nat (:: @ map (n/% arity))) - args (r.list arity r.nat) - #let [arg-value (maybe.assume (list.nth arg args)) - argsS (list/map code.nat args) - last-arg (n/dec arity) - cut-off (|> cut-off (n/min (n/dec last-arg)))]] - ($_ seq - (test "Can read arguments." - (|> (do macro.Monad - [_ runtimeT.translate - sampleJS (expressionT.translate (` ("lux call" (~ functionS) (~+ argsS))))] - (evalT.eval sampleJS)) - (lang.with-current-module "") - (macro.run (init-js [])) - (case> (#e.Success valueT) - (n/= arg-value (:! Nat valueT)) - - (#e.Error error) - false))) - (test "Can partially apply functions." - (or (n/= +1 arity) - (|> (do macro.Monad - [#let [partial-arity (n/inc cut-off) - preS (list.take partial-arity argsS) - postS (list.drop partial-arity argsS)] - _ runtimeT.translate - sampleJS (expressionT.translate (` ("lux call" - ("lux call" (~ functionS) (~+ preS)) - (~+ postS))))] - (evalT.eval sampleJS)) - (lang.with-current-module "") - (macro.run (init-js [])) - (case> (#e.Success valueT) - (n/= arg-value (:! Nat valueT)) - - (#e.Error error) - false)))) - (test "Can read environment." - (or (n/= +1 arity) - (|> (do macro.Monad - [#let [env (|> (list.n/range +0 cut-off) - (list/map (|>> n/inc nat-to-int))) - super-arity (n/inc cut-off) - arg-var (if (n/<= cut-off arg) - (|> arg n/inc nat-to-int (i/* -1)) - (|> arg n/inc (n/- super-arity) nat-to-int)) - sub-arity (|> arity (n/- super-arity)) - functionS (` ("lux function" (~ (code.nat super-arity)) [] - ("lux function" (~ (code.nat sub-arity)) [(~+ (list/map code.int env))] - ((~ (code.int arg-var))))))] - _ runtimeT.translate - sampleJS (expressionT.translate (` ("lux call" (~ functionS) (~+ argsS))))] - (evalT.eval sampleJS)) - (lang.with-current-module "") - (macro.run (init-js [])) - (case> (#e.Success valueT) - (n/= arg-value (:! Nat valueT)) - - (#e.Error error) - (exec (log! error) - false))))) - )))) diff --git a/new-luxc/test/test/luxc/lang/translation/js/primitive.lux b/new-luxc/test/test/luxc/lang/translation/js/primitive.lux deleted file mode 100644 index 91828eb3b..000000000 --- a/new-luxc/test/test/luxc/lang/translation/js/primitive.lux +++ /dev/null @@ -1,64 +0,0 @@ -(.module: - lux - (lux [io] - (control [monad #+ do] - pipe) - (data text/format - ["e" error] - [bool "bool/" Eq] - [text "text/" Eq]) - ["r" math/random] - [macro] - (macro [code]) - test) - (luxc [lang] - (lang [".L" host] - ["ls" synthesis] - (translation (js [".T" expression] - [".T" runtime] - [".T" eval])))) - (test/luxc common)) - -(context: "Primitives." - (<| (times +100) - (do @ - [%bool% r.bool - %nat% r.nat - %int% r.int - %deg% r.deg - %frac% r.frac - %text% (r.text +5)] - (`` ($_ seq - (test "Can translate unit." - (|> (do macro.Monad - [_ runtimeT.translate - sampleI (expressionT.translate (' []))] - (evalT.eval sampleI)) - (lang.with-current-module "") - (macro.run (init-js [])) - (case> (#e.Success valueT) - (is hostL.unit (:! Text valueT)) - - _ - false))) - (~~ (do-template [ ] - [(test (format "Can translate " ".") - (|> (do macro.Monad - [_ runtimeT.translate - sampleI (expressionT.translate ( ))] - (evalT.eval sampleI)) - (lang.with-current-module "") - (macro.run (init-js [])) - (case> (#e.Success valueT) - ( (:! valueT)) - - (#e.Error error) - false)))] - - ["bool" Bool code.bool %bool% bool/=] - ["nat" Nat code.nat %nat% n/=] - ["int" Int code.int %int% i/=] - ["deg" Deg code.deg %deg% d/=] - ["frac" Frac code.frac %frac% f/=] - ["text" Text code.text %text% text/=])) - ))))) diff --git a/new-luxc/test/test/luxc/lang/translation/js/procedure/common.jvm.lux b/new-luxc/test/test/luxc/lang/translation/js/procedure/common.jvm.lux deleted file mode 100644 index 1c52d9e7b..000000000 --- a/new-luxc/test/test/luxc/lang/translation/js/procedure/common.jvm.lux +++ /dev/null @@ -1,405 +0,0 @@ -(.module: - lux - (lux [io] - (control [monad #+ do] - pipe) - (data text/format - [bit] - ["e" error] - [bool "bool/" Eq] - [text "text/" Eq] - [number "nat/" Interval "int/" Number Interval "frac/" Number Interval "deg/" Interval] - (coll ["a" array] - [list])) - ["r" math/random] - [macro] - (macro [code]) - [host] - test) - (luxc [lang] - (lang ["ls" synthesis] - (translation (js [".T" expression] - [".T" eval] - [".T" runtime])))) - (test/luxc common)) - -(context: "Bit procedures" - (<| (times +100) - (do @ - [param r.nat - subject r.nat] - (with-expansions [ (do-template [ ] - [(test - (|> (do macro.Monad - [_ runtimeT.translate - sampleJS (expressionT.translate (` ( (~ (code.nat subject)) - (~ (code.nat param)))))] - (evalT.eval sampleJS)) - (lang.with-current-module "") - (macro.run (init-js [])) - (case> (#e.Success valueT) - (n/= ( param subject) (:! Nat valueT)) - - (#e.Error error) - false) - (let [param ])))] - - ["lux bit and" bit.and param] - ["lux bit or" bit.or param] - ["lux bit xor" bit.xor param] - ["lux bit shift-left" bit.shift-left (n/% +64 param)] - ["lux bit unsigned-shift-right" bit.shift-right (n/% +64 param)] - )] - ($_ seq - (test "lux bit count" - (|> (do macro.Monad - [_ runtimeT.translate - sampleJS (expressionT.translate (` ("lux bit count" (~ (code.nat subject)))))] - (evalT.eval sampleJS)) - (lang.with-current-module "") - (macro.run (init-js [])) - (case> (#e.Success valueT) - (n/= (bit.count subject) (:! Nat valueT)) - - (#e.Error error) - false))) - - - (test "lux bit shift-right" - (|> (do macro.Monad - [_ runtimeT.translate - sampleJS (expressionT.translate (` ("lux bit shift-right" - (~ (code.int (nat-to-int subject))) - (~ (code.nat param)))))] - (evalT.eval sampleJS)) - (lang.with-current-module "") - (macro.run (init-js [])) - (case> (#e.Success valueT) - (i/= (bit.signed-shift-right param (nat-to-int subject)) - (:! Int valueT)) - - (#e.Error error) - false) - (let [param (n/% +64 param)]))) - ))))) - -(context: "Nat procedures" - (<| (times +100) - (do @ - [param (|> r.nat (r.filter (|>> (n/= +0) not))) - subject r.nat] - (`` ($_ seq - (~~ (do-template [ ] - [(test - (|> (do macro.Monad - [_ runtimeT.translate - sampleJS (expressionT.translate (` ()))] - (evalT.eval sampleJS)) - (lang.with-current-module "") - (macro.run (init-js [])) - (case> (#e.Success valueT) - (n/= (:! Nat valueT)) - - (#e.Error error) - false)))] - - ["lux nat min" nat/bottom] - ["lux nat max" nat/top] - )) - (~~ (do-template [ ] - [(test - (|> (do macro.Monad - [_ runtimeT.translate - sampleJS (expressionT.translate (` ( (~ (code.nat subject)))))] - (evalT.eval sampleJS)) - (lang.with-current-module "") - (macro.run (init-js [])) - (case> (#e.Success valueT) - ( ( subject) (:! valueT)) - - (#e.Error error) - false) - (let [subject ])))] - - ["lux nat to-int" Int nat-to-int i/= subject] - ["lux nat char" Text text.from-code text/= (n/% (bit.shift-left +32 +1) subject)] - )) - (~~ (do-template [ ] - [(test - (|> (do macro.Monad - [_ runtimeT.translate - sampleJS (expressionT.translate (` ( (~ (code.nat subject)) (~ (code.nat param)))))] - (evalT.eval sampleJS)) - (lang.with-current-module "") - (macro.run (init-js [])) - (case> (#e.Success valueT) - ( ( param subject) (:! valueT)) - - _ - false)))] - - ["lux nat +" n/+ Nat n/=] - ["lux nat -" n/- Nat n/=] - ["lux nat *" n/* Nat n/=] - ["lux nat /" n// Nat n/=] - ["lux nat %" n/% Nat n/=] - ["lux nat =" n/= Bool bool/=] - ["lux nat <" n/< Bool bool/=] - )) - ))))) - -(context: "Int procedures" - (<| (times +100) - (do @ - [param (|> r.int (r.filter (|>> (i/= 0) not))) - subject r.int] - (with-expansions [ (do-template [ ] - [(test - (|> (do macro.Monad - [_ runtimeT.translate - sampleJS (expressionT.translate (` ()))] - (evalT.eval sampleJS)) - (lang.with-current-module "") - (macro.run (init-js [])) - (case> (#e.Success valueT) - (i/= (:! Int valueT)) - - (#e.Error error) - false)))] - - ["lux int min" int/bottom] - ["lux int max" int/top] - ) - (do-template [ ] - [(test - (|> (do macro.Monad - [_ runtimeT.translate - sampleJS (expressionT.translate (` ( (~ (code.int subject)))))] - (evalT.eval sampleJS)) - (lang.with-current-module "") - (macro.run (init-js [])) - (case> (#e.Success valueT) - ( ( subject) (:! valueT)) - - (#e.Error error) - false)))] - - ["lux int to-nat" Nat int-to-nat n/=] - ["lux int to-frac" Frac int-to-frac f/=] - ) - (do-template [ ] - [(test - (|> (do macro.Monad - [_ runtimeT.translate - sampleJS (expressionT.translate (` ( (~ (code.int subject)) (~ (code.int param)))))] - (evalT.eval sampleJS)) - (lang.with-current-module "") - (macro.run (init-js [])) - (case> (#e.Success valueT) - ( ( param subject) (:! valueT)) - - _ - false)))] - - ["lux int +" i/+ Int i/=] - ["lux int -" i/- Int i/=] - ["lux int *" i/* Int i/=] - ["lux int /" i// Int i/=] - ["lux int %" i/% Int i/=] - ["lux int =" i/= Bool bool/=] - ["lux int <" i/< Bool bool/=] - )] - ($_ seq - - - - ))))) - -(context: "Frac procedures [Part 1]" - (<| (times +100) - (do @ - [param (|> r.frac (r.filter (|>> (f/= 0.0) not))) - subject r.frac] - (with-expansions [ (do-template [ ] - [(test - (|> (do macro.Monad - [_ runtimeT.translate - sampleJS (expressionT.translate (` ( (~ (code.frac subject)) (~ (code.frac param)))))] - (evalT.eval sampleJS)) - (lang.with-current-module "") - (macro.run (init-js [])) - (case> (#e.Success valueT) - ( ( param subject) (:! valueT)) - - _ - false)))] - - ["lux frac +" f/+ Frac f/=] - ["lux frac -" f/- Frac f/=] - ["lux frac *" f/* Frac f/=] - ["lux frac /" f// Frac f/=] - ["lux frac %" f/% Frac f/=] - ["lux frac =" f/= Bool bool/=] - ["lux frac <" f/< Bool bool/=] - )] - ($_ seq - - ))))) - -(context: "Frac procedures [Part 2]" - (<| (times +100) - (do @ - [param (|> r.frac (r.filter (|>> (f/= 0.0) not))) - subject r.frac] - (with-expansions [ (do-template [ ] - [(test - (|> (do macro.Monad - [_ runtimeT.translate - sampleJS (expressionT.translate (` ()))] - (evalT.eval sampleJS)) - (lang.with-current-module "") - (macro.run (init-js [])) - (case> (#e.Success valueT) - ( (:! Frac valueT)) - - _ - false)))] - - ["lux frac min" (f/= frac/bottom)] - ["lux frac max" (f/= frac/top)] - ["lux frac not-a-number" number.not-a-number?] - ["lux frac positive-infinity" (f/= number.positive-infinity)] - ["lux frac negative-infinity" (f/= number.negative-infinity)] - ["lux frac smallest" (f/= ("lux frac smallest"))] - ) - (do-template [ ] - [(test - (|> (do macro.Monad - [_ runtimeT.translate - sampleJS (expressionT.translate (` ( ( (~ (code.frac subject))))))] - (evalT.eval sampleJS)) - (lang.with-current-module "") - (macro.run (init-js [])) - (case> (#e.Success valueT) - (|> valueT (:! Frac) (f/- subject) frac/abs ) - - (#e.Error error) - false)))] - - ["lux frac to-int" "lux int to-frac" (f/< 1.0)] - ["lux frac to-deg" "lux deg to-frac" (f/<= 0.000000001)])] - ($_ seq - - - (test "frac encode|decode" - (|> (do macro.Monad - [_ runtimeT.translate - sampleJS (expressionT.translate (` ("lux frac decode" ("lux frac encode" (~ (code.frac subject))))))] - (evalT.eval sampleJS)) - (lang.with-current-module "") - (macro.run (init-js [])) - (case> (^multi (#e.Success valueT) - [(:! (Maybe Frac) valueT) (#.Some value)]) - (f/= subject value) - - _ - false))) - ))))) - -(def: deg-threshold - {#.doc "1/(2^30)"} - Deg - .000000001) - -(def: (above-threshold value) - (-> Deg Deg) - (if (d/< deg-threshold value) - (d/+ deg-threshold value) - value)) - -(def: (deg-difference reference sample) - (-> Deg Deg Deg) - (if (d/> reference sample) - (d/- reference sample) - (d/- sample reference))) - -(context: "Deg procedures" - (<| (times +100) - (do @ - [param (|> r.deg (:: @ map above-threshold)) - special r.nat - subject (|> r.deg (:: @ map above-threshold))] - (`` ($_ seq - (~~ (do-template [ ] - [(test - (|> (do macro.Monad - [_ runtimeT.translate - sampleJS (expressionT.translate (` ()))] - (evalT.eval sampleJS)) - (lang.with-current-module "") - (macro.run (init-js [])) - (case> (#e.Success valueT) - (d/= (:! Deg valueT)) - - _ - false)))] - - ["lux deg min" deg/bottom] - ["lux deg max" deg/top] - )) - (~~ (do-template [ ] - [(test - (|> (do macro.Monad - [_ runtimeT.translate - sampleJS (expressionT.translate (` ( ( (~ (code.deg subject))))))] - (evalT.eval sampleJS)) - (lang.with-current-module "") - (macro.run (init-js [])) - (case> (#e.Success valueV) - (d/<= deg-threshold (deg-difference subject (:! valueV))) - - _ - false)))] - - ["lux deg to-frac" "lux frac to-deg" Deg] - )) - (~~ (do-template [ ] - [(test - (|> (do macro.Monad - [_ runtimeT.translate - sampleJS (expressionT.translate (` ( (~ (code.deg subject)) (~ (code.deg param)))))] - (evalT.eval sampleJS)) - (lang.with-current-module "") - (macro.run (init-js [])) - (case> (#e.Success valueT) - ( ( param subject) (:! valueT)) - - _ - false)))] - - ["lux deg +" d/+ Deg d/=] - ["lux deg -" d/- Deg d/=] - ["lux deg *" d/* Deg d/=] - ["lux deg /" d// Deg d/=] - ["lux deg %" d/% Deg d/=] - ["lux deg =" d/= Bool bool/=] - ["lux deg <" d/< Bool bool/=] - )) - (~~ (do-template [ ] - [(test - (|> (do macro.Monad - [_ runtimeT.translate - sampleJS (expressionT.translate (` ( (~ (code.deg subject)) (~ (code.nat special)))))] - (evalT.eval sampleJS)) - (lang.with-current-module "") - (macro.run (init-js [])) - (case> (#e.Success valueT) - ( ( special subject) (:! valueT)) - - _ - false)))] - - ["lux deg scale" d/scale Deg d/=] - ["lux deg reciprocal" d/reciprocal Deg d/=] - )) - ))))) diff --git a/new-luxc/test/test/luxc/lang/translation/js/reference.lux b/new-luxc/test/test/luxc/lang/translation/js/reference.lux deleted file mode 100644 index 80ccd3123..000000000 --- a/new-luxc/test/test/luxc/lang/translation/js/reference.lux +++ /dev/null @@ -1,82 +0,0 @@ -(.module: - lux - (lux [io] - (control [monad #+ do] - pipe) - (data ["e" error] - [text]) - ["r" math/random] - [macro] - (macro [code]) - test) - (luxc [lang] - (lang ["_." module] - ["ls" synthesis] - (translation (js [".T" statement] - [".T" eval] - [".T" expression] - [".T" case] - [".T" runtime])))) - (test/luxc common)) - -(def: upper-alpha-ascii - (r.Random Nat) - (|> r.nat (:: r.Functor map (|>> (n/% +91) (n/max +65))))) - -(def: ident-part - (r.Random Text) - (|> (r.text' upper-alpha-ascii +5) - (r.filter (function [sample] - (not (or (text.contains? "/" sample) - (text.contains? "[" sample) - (text.contains? "]" sample))))))) - -(context: "Definitions." - (<| (times +100) - (do @ - [module-name ident-part - def-name ident-part - def-value r.int] - ($_ seq - (test "Can refer to definitions." - (|> (do macro.Monad - [_ runtimeT.translate - valueJS (expressionT.translate (code.int def-value)) - _ (_module.with-module +0 module-name - (statementT.translate-def def-name Int valueJS (' {}))) - sampleJS (expressionT.translate (code.symbol [module-name def-name]))] - (evalT.eval sampleJS)) - (lang.with-current-module "") - (macro.run (init-js [])) - (case> (#e.Success valueT) - (i/= def-value (:! Int valueT)) - - (#e.Error error) - (exec (log! error) - false)))) - )))) - -(context: "Variables." - (<| (times +100) - (do @ - [module-name (|> (r.text +5) (r.filter (|>> (text.contains? "/") not))) - register (|> r.nat (:: @ map (n/% +100))) - value r.int] - ($_ seq - (test "Can refer to local variables/registers." - (|> (do macro.Monad - [_ runtimeT.translate - sampleJS (caseT.translate-let expressionT.translate - register - (code.int value) - (` ((~ (code.int (nat-to-int register))))))] - (evalT.eval sampleJS)) - (lang.with-current-module "") - (macro.run (init-js [])) - (case> (#e.Success outputT) - (i/= value (:! Int outputT)) - - (#e.Error error) - (exec (log! error) - false)))) - )))) diff --git a/new-luxc/test/test/luxc/lang/translation/js/structure.lux b/new-luxc/test/test/luxc/lang/translation/js/structure.lux deleted file mode 100644 index fde45c1cb..000000000 --- a/new-luxc/test/test/luxc/lang/translation/js/structure.lux +++ /dev/null @@ -1,113 +0,0 @@ -(.module: - lux - (lux [io] - (control [monad #+ do] - pipe) - (data ["e" error] - [maybe] - [bool "bool/" Eq] - [text "text/" Eq] - text/format - (coll [array] - [list])) - ["r" math/random "r/" Monad] - [macro] - (macro [code]) - [host] - test) - (luxc [lang] - (lang [".L" host] - ["ls" synthesis] - (translation (js [".T" expression] - [".T" runtime] - [".T" eval])))) - (test/luxc common)) - -(host.import java/lang/Long) - -(def: gen-primitive - (r.Random ls.Synthesis) - (r.either (r.either (r.either (r/wrap (' [])) - (r/map code.bool r.bool)) - (r.either (r/map code.nat r.nat) - (r/map code.int r.int))) - (r.either (r.either (r/map code.deg r.deg) - (r/map code.frac r.frac)) - (r/map code.text (r.text +5))))) - -(def: (corresponds? [prediction sample]) - (-> [ls.Synthesis Top] Bool) - (case prediction - [_ (#.Tuple #.Nil)] - (text/= hostL.unit (:! Text sample)) - - (^template [ ] - [_ ( prediction')] - (case (host.try ( prediction' (:! sample))) - (#e.Success result) - result - - (#e.Error error) - false)) - ([#.Bool Bool bool/=] - [#.Nat Nat n/=] - [#.Int Int i/=] - [#.Deg Deg d/=] - [#.Frac Frac f/=] - [#.Text Text text/=]) - - _ - false - )) - -(context: "Tuples." - (<| (times +100) - (do @ - [size (|> r.nat (:: @ map (|>> (n/% +10) (n/max +2)))) - members (r.list size gen-primitive)] - (test "Can translate tuple." - (|> (do macro.Monad - [_ runtimeT.translate - sampleI (expressionT.translate (code.tuple members))] - (evalT.eval sampleI)) - (lang.with-current-module "") - (macro.run (init-js [])) - (case> (#e.Success valueT) - (let [valueT (:! (Array Top) valueT)] - (and (n/= size (array.size valueT)) - (list.every? corresponds? (list.zip2 members (array.to-list valueT))))) - - (#e.Error error) - false)))))) - -(context: "Variants." - (<| (times +100) - (do @ - [num-tags (|> r.nat (:: @ map (|>> (n/% +10) (n/max +2)))) - tag (|> r.nat (:: @ map (n/% num-tags))) - #let [last? (n/= (n/dec num-tags) tag)] - member gen-primitive] - (test "Can translate variant." - (|> (do macro.Monad - [_ runtimeT.translate - sampleI (expressionT.translate (` ((~ (code.nat tag)) (~ (code.bool last?)) (~ member))))] - (evalT.eval sampleI)) - (lang.with-current-module "") - (macro.run (init-js [])) - (case> (#e.Success valueT) - (let [valueT (:! (Array Top) valueT)] - (and (n/= +3 (array.size valueT)) - (let [_tag (:! Long (maybe.assume (array.read +0 valueT))) - _last? (array.read +1 valueT) - _value (:! Top (maybe.assume (array.read +2 valueT)))] - (and (n/= tag (|> _tag (:! Nat))) - (case _last? - (#.Some _last?') - (and last? (text/= "" (:! Text _last?'))) - - #.None - (not last?)) - (corresponds? [member _value]))))) - - (#e.Error error) - false)))))) diff --git a/new-luxc/test/test/luxc/lang/translation/jvm.lux b/new-luxc/test/test/luxc/lang/translation/jvm.lux new file mode 100644 index 000000000..a0c8a5ed5 --- /dev/null +++ b/new-luxc/test/test/luxc/lang/translation/jvm.lux @@ -0,0 +1,645 @@ +(.module: + lux + (lux [io] + (control [monad #+ do] + pipe) + (data [maybe] + ["e" error] + [bit] + [bool "bool/" Eq] + [number "int/" Number Codec] + [text "text/" Eq] + text/format + (coll [list])) + ["r" math/random "r/" Monad] + [macro] + (macro [code]) + [host] + test) + (luxc [lang] + (lang [".L" host] + ["ls" synthesis] + (translation (jvm [".T" expression] + [".T" eval] + [".T" runtime])))) + (test/luxc common)) + +(context: "Conversions [Part 1]" + (<| (times +100) + (do @ + [int-sample (|> r.int (:: @ map (i/% 128))) + #let [frac-sample (int-to-frac int-sample)]] + (with-expansions [<2step> (do-template [ ] + [(test (format " / " ) + (|> (do macro.Monad + [sampleI (expressionT.translate (|> (~ ( )) (`)))] + (evalT.eval sampleI)) + (lang.with-current-module "") + (macro.run (io.run init-jvm)) + (case> (#e.Success valueT) + ( (:! valueT)) + + (#e.Error error) + false)))] + + ["jvm convert double-to-float" "jvm convert float-to-double" code.frac frac-sample Frac f/=] + ["jvm convert double-to-int" "jvm convert int-to-double" code.frac frac-sample Frac f/=] + ["jvm convert double-to-long" "jvm convert long-to-double" code.frac frac-sample Frac f/=] + + ["jvm convert long-to-float" "jvm convert float-to-long" code.int int-sample Int i/=] + ["jvm convert long-to-int" "jvm convert int-to-long" code.int int-sample Int i/=] + ["jvm convert long-to-short" "jvm convert short-to-long" code.int int-sample Int i/=] + ["jvm convert long-to-byte" "jvm convert byte-to-long" code.int int-sample Int i/=] + )] + ($_ seq + <2step> + ))))) + +(context: "Conversions [Part 2]" + (<| (times +100) + (do @ + [int-sample (|> r.int (:: @ map (|>> (i/% 128) int/abs))) + #let [frac-sample (int-to-frac int-sample)]] + (`` ($_ seq + (~~ (do-template [ ] + [(test (format " / " " / " ) + (|> (do macro.Monad + [sampleI (expressionT.translate (|> (~ ( )) (`)))] + (evalT.eval sampleI)) + (lang.with-current-module "") + (macro.run (io.run init-jvm)) + (case> (#e.Success valueT) + ( (:! valueT)) + + (#e.Error error) + false)))] + + ["jvm convert long-to-int" "jvm convert int-to-char" "jvm convert char-to-long" code.int int-sample Int i/=] + ["jvm convert long-to-int" "jvm convert int-to-byte" "jvm convert byte-to-long" code.int int-sample Int i/=] + ["jvm convert long-to-int" "jvm convert int-to-short" "jvm convert short-to-long" code.int int-sample Int i/=] + ["jvm convert long-to-float" "jvm convert float-to-int" "jvm convert int-to-long" code.int int-sample Int i/=] + ["jvm convert long-to-int" "jvm convert int-to-float" "jvm convert float-to-long" code.int int-sample Int i/=] + )) + ))))) + +(context: "Conversions [Part 3]" + (<| (times +100) + (do @ + [int-sample (|> r.int (:: @ map (|>> (i/% 128) int/abs))) + #let [frac-sample (int-to-frac int-sample)]] + (`` ($_ seq + (~~ (do-template [ ] + [(test (format " / " " / " ) + (|> (do macro.Monad + [sampleI (expressionT.translate (|> (~ ( )) (`)))] + (evalT.eval sampleI)) + (lang.with-current-module "") + (macro.run (io.run init-jvm)) + (case> (#e.Success valueT) + ( (:! valueT)) + + (#e.Error error) + false)))] + + ["jvm convert long-to-int" "jvm convert int-to-char" "jvm convert char-to-byte" "jvm convert byte-to-long" code.int int-sample Int i/=] + ["jvm convert long-to-int" "jvm convert int-to-char" "jvm convert char-to-short" "jvm convert short-to-long" code.int int-sample Int i/=] + ["jvm convert long-to-int" "jvm convert int-to-char" "jvm convert char-to-int" "jvm convert int-to-long" code.int int-sample Int i/=] + )) + ))))) + +(def: gen-nat + (r.Random Nat) + (|> r.nat + (r/map (n/% +128)) + (r.filter (|>> (n/= +0) not)))) + +(def: gen-int + (r.Random Int) + (|> gen-nat (r/map nat-to-int))) + +(def: gen-frac + (r.Random Frac) + (|> gen-int (r/map int-to-frac))) + +(do-template [ <+> <-> <*> <%>
 ]
+  [(context: (format "Arithmetic ["  "]")
+     (<| (times +100)
+         (do @
+           [param 
+            #let [subject ( param)]]
+           (with-expansions [ (do-template [ ]
+                                       [(test 
+                                              (|> (do macro.Monad
+                                                    [sampleI (expressionT.translate (` ( ((~ (code.text ))
+                                                                                                (
 (~ ( subject)))
+                                                                                                (
 (~ ( param)))))))]
+                                                    (evalT.eval sampleI))
+                                                  (lang.with-current-module "")
+                                                  (macro.run (io.run init-jvm))
+                                                  (case> (#e.Success valueT)
+                                                         ( ( param subject)
+                                                                 (:!  valueT))
+
+                                                         (#e.Error error)
+                                                         false)))]
+
+                                       [(format "jvm "  " +") <+>]
+                                       [(format "jvm "  " -") <->]
+                                       [(format "jvm "  " *") <*>]
+                                       [(format "jvm "  " /") ]
+                                       [(format "jvm "  " %") <%>]
+                                       )]
+             ($_ seq
+                 
+                 )))))]
+
+  ["int" gen-int code.int Int i/= (i/* 10) i/+ i/- i/* i// i/% "jvm convert long-to-int" "jvm convert int-to-long"]
+  ["long" gen-int code.int Int i/= (i/* 10) i/+ i/- i/* i// i/% "lux noop" "lux noop"]
+  ["float" gen-frac code.frac Frac f/= (f/* 10.0) f/+ f/- f/* f// f/% "jvm convert double-to-float" "jvm convert float-to-double"]
+  ["double" gen-frac code.frac Frac f/= (f/* 10.0) f/+ f/- f/* f// f/% "lux noop" "lux noop"]
+  )
+
+(do-template [  ]
+  [(context: (format "Bit-wise ["  "] { Combiners ]")
+     (<| (times +100)
+         (do @
+           [param gen-nat
+            subject gen-nat]
+           (`` ($_ seq
+                   (~~ (do-template [ ]
+                         [(test 
+                                (|> (do macro.Monad
+                                      [sampleI (expressionT.translate (` ( ((~ (code.text ))
+                                                                                  ( (~ (code.nat subject)))
+                                                                                  ( (~ (code.nat param)))))))]
+                                      (evalT.eval sampleI))
+                                    (lang.with-current-module "")
+                                    (macro.run (io.run init-jvm))
+                                    (case> (#e.Success valueT)
+                                           (n/= ( param subject)
+                                                (:! Nat valueT))
+
+                                           (#e.Error error)
+                                           false)))]
+
+                         [(format "jvm "  " and") bit.and]
+                         [(format "jvm "  " or") bit.or]
+                         [(format "jvm "  " xor") bit.xor]
+                         ))
+                   )))))]
+
+  ["int" "jvm convert int-to-long" "jvm convert long-to-int"]
+  ["long" "lux noop" "lux noop"]
+  )
+
+(do-template [  ]
+  [(context: (format "Bit-wise ["  "] { Shifters }")
+     (<| (times +100)
+         (do @
+           [param gen-nat
+            subject gen-nat
+            #let [shift (n/% +10 param)]]
+           (`` ($_ seq
+                   (~~ (do-template [     
]
+                         [(test 
+                                (|> (do macro.Monad
+                                      [sampleI (expressionT.translate (` ( ((~ (code.text ))
+                                                                                  ( (~ (
 subject)))
+                                                                                  ("jvm convert long-to-int" (~ (code.nat shift)))))))]
+                                      (evalT.eval sampleI))
+                                    (lang.with-current-module "")
+                                    (macro.run (io.run init-jvm))
+                                    (case> (#e.Success valueT)
+                                           ( ( shift ( subject))
+                                                   (:!  valueT))
+
+                                           (#e.Error error)
+                                           false)))]
+
+                         [(format "jvm "  " shl") bit.shift-left Nat n/= id code.nat]
+                         [(format "jvm "  " shr") bit.signed-shift-right Int i/= nat-to-int (|>> nat-to-int code.int)]
+                         [(format "jvm "  " ushr") bit.shift-right Nat n/= id code.nat]
+                         ))
+                   )))))]
+
+  ["int" "jvm convert int-to-long" "jvm convert long-to-int"]
+  ["long" "lux noop" "lux noop"]
+  )
+
+(do-template [   <=> <<> 
]
+  [(context: (format "Order ["  "]")
+     (<| (times +100)
+         (do @
+           [param 
+            subject ]
+           (with-expansions [ (do-template [ ]
+                                       [(test 
+                                              (|> (do macro.Monad
+                                                    [sampleI (expressionT.translate (` ((~ (code.text ))
+                                                                                        (
 (~ ( subject)))
+                                                                                        (
 (~ ( param))))))]
+                                                    (evalT.eval sampleI))
+                                                  (lang.with-current-module "")
+                                                  (macro.run (io.run init-jvm))
+                                                  (case> (#e.Success valueT)
+                                                         (bool/= ( param subject)
+                                                                 (:! Bool valueT))
+
+                                                         (#e.Error error)
+                                                         false)))]
+
+                                       [(format "jvm "  " =") <=>]
+                                       [(format "jvm "  " <") <<>]
+                                       )]
+             ($_ seq
+                 
+                 )))))]
+
+  ["int" gen-int code.int i/= i/< "jvm convert long-to-int"]
+  ["long" gen-int code.int i/= i/< "lux noop"]
+  ["float" gen-frac code.frac f/= f/< "jvm convert double-to-float"]
+  ["double" gen-frac code.frac f/= f/< "lux noop"]
+  ["char" gen-int code.int i/= i/< "jvm convert long-to-char"]
+  )
+
+(def: (jvm//array//new dimension class size)
+  (-> Nat Text Nat ls.Synthesis)
+  (` ("jvm array new" (~ (code.nat dimension)) (~ (code.text class)) (~ (code.nat size)))))
+
+(def: (jvm//array//write class idx inputS arrayS)
+  (-> Text Nat ls.Synthesis ls.Synthesis ls.Synthesis)
+  (` ("jvm array write" (~ (code.text class)) (~ (code.nat idx)) (~ inputS) (~ arrayS))))
+
+(def: (jvm//array//read class idx arrayS)
+  (-> Text Nat ls.Synthesis ls.Synthesis)
+  (` ("jvm array read" (~ (code.text class)) (~ (code.nat idx)) (~ arrayS))))
+
+(context: "Array [Part 1]"
+  (<| (times +100)
+      (do @
+        [size (|> r.nat (:: @ map (|>> (n/% +10) (n/max +1))))
+         idx (|> r.nat (:: @ map (n/% size)))
+         valueZ r.bool
+         valueB gen-int
+         valueS gen-int
+         valueI gen-int
+         valueL r.int
+         valueF gen-frac
+         valueD r.frac
+         valueC gen-int]
+        (with-expansions [ (do-template [     ]
+                                    [(test 
+                                           (|> (do macro.Monad
+                                                 [sampleI (expressionT.translate (|> (jvm//array//new +0  size)
+                                                                                     (jvm//array//write  idx )
+                                                                                     (jvm//array//read  idx)
+                                                                                     (~)
+                                                                                     
+                                                                                     (`)))]
+                                                 (evalT.eval sampleI))
+                                               (lang.with-current-module "")
+                                               (macro.run (io.run init-jvm))
+                                               (case> (#e.Success outputZ)
+                                                      (  (:!  outputZ))
+
+                                                      (#e.Error error)
+                                                      false)))]
+
+                                    ["boolean" Bool valueZ bool/= (code.bool valueZ)
+                                     "lux noop"]
+                                    ["byte" Int valueB i/= (|> (code.int valueB) (~) "jvm convert long-to-byte" (`))
+                                     "jvm convert byte-to-long"]
+                                    ["short" Int valueS i/= (|> (code.int valueS) (~) "jvm convert long-to-short" (`))
+                                     "jvm convert short-to-long"]
+                                    ["int" Int valueI i/= (|> (code.int valueI) (~) "jvm convert long-to-int" (`))
+                                     "jvm convert int-to-long"]
+                                    ["long" Int valueL i/= (code.int valueL)
+                                     "lux noop"]
+                                    ["float" Frac valueF f/= (|> (code.frac valueF) (~) "jvm convert double-to-float" (`))
+                                     "jvm convert float-to-double"]
+                                    ["double" Frac valueD f/= (code.frac valueD)
+                                     "lux noop"]
+                                    )]
+          ($_ seq
+              
+              )))))
+
+(context: "Array [Part 2]"
+  (<| (times +100)
+      (do @
+        [size (|> r.nat (:: @ map (|>> (n/% +10) (n/max +1))))
+         idx (|> r.nat (:: @ map (n/% size)))
+         valueZ r.bool
+         valueB gen-int
+         valueS gen-int
+         valueI gen-int
+         valueL r.int
+         valueF gen-frac
+         valueD r.frac
+         valueC gen-int]
+        (with-expansions [ (do-template [     ]
+                                    [(test 
+                                           (|> (do macro.Monad
+                                                 [sampleI (expressionT.translate (|> (jvm//array//new +0  size)
+                                                                                     (jvm//array//write  idx )
+                                                                                     (jvm//array//read  idx)
+                                                                                     (~)
+                                                                                     
+                                                                                     (`)))]
+                                                 (evalT.eval sampleI))
+                                               (lang.with-current-module "")
+                                               (macro.run (io.run init-jvm))
+                                               (case> (#e.Success outputT)
+                                                      (  (:!  outputT))
+
+                                                      (#e.Error error)
+                                                      false)))]
+
+                                    ["char" Int valueC i/=
+                                     (|> (code.int valueC) (~) "jvm convert long-to-int" "jvm convert int-to-char" (`))
+                                     "jvm convert char-to-long"]
+                                    ["java.lang.Long" Int valueL i/=
+                                     (code.int valueL)
+                                     "lux noop"]
+                                    )]
+          ($_ seq
+              
+              (test "java.lang.Double (level 1)"
+                    (|> (do macro.Monad
+                          [#let [inner (|> ("jvm array new" +0 "java.lang.Double" (~ (code.nat size)))
+                                           ("jvm array write" "java.lang.Double" (~ (code.nat idx)) (~ (code.frac valueD)))
+                                           (`))]
+                           sampleI (expressionT.translate (|> ("jvm array new" +1 "java.lang.Double" (~ (code.nat size)))
+                                                              ("jvm array write" "#Array" (~ (code.nat idx)) (~ inner))
+                                                              ("jvm array read" "#Array" (~ (code.nat idx)))
+                                                              ("jvm array read" "java.lang.Double" (~ (code.nat idx)))
+                                                              (`)))]
+                          (evalT.eval sampleI))
+                        (lang.with-current-module "")
+                        (macro.run (io.run init-jvm))
+                        (case> (#e.Success outputT)
+                               (f/= valueD (:! Frac outputT))
+
+                               (#e.Error error)
+                               false)))
+              (test "jvm array length"
+                    (|> (do macro.Monad
+                          [sampleI (expressionT.translate (` ("jvm array length" ("jvm array new" +0 "java.lang.Object" (~ (code.nat size))))))]
+                          (evalT.eval sampleI))
+                        (lang.with-current-module "")
+                        (macro.run (io.run init-jvm))
+                        (case> (#e.Success outputT)
+                               (n/= size (:! Nat outputT))
+
+                               (#e.Error error)
+                               false)))
+              )))))
+
+(host.import java/lang/Class
+  (getName [] String))
+
+(def: classes
+  (List Text)
+  (list "java.lang.Object" "java.lang.Class"
+        "java.lang.String" "java.lang.Number"))
+
+(def: instances
+  (List [Text (r.Random ls.Synthesis)])
+  (let [gen-boolean (|> r.bool (:: r.Functor map code.bool))
+        gen-integer (|> r.int (:: r.Functor map code.int))
+        gen-double (|> r.frac (:: r.Functor map code.frac))
+        gen-string (|> (r.text +5) (:: r.Functor map code.text))]
+    (list ["java.lang.Boolean" gen-boolean]
+          ["java.lang.Long" gen-integer]
+          ["java.lang.Double" gen-double]
+          ["java.lang.String" gen-string]
+          ["java.lang.Object" (r.either (r.either gen-boolean
+                                                  gen-integer)
+                                        (r.either gen-double
+                                                  gen-string))])))
+
+(context: "Object."
+  (<| (times +100)
+      (do @
+        [#let [num-classes (list.size classes)]
+         #let [num-instances (list.size instances)]
+         class-idx (|> r.nat (:: @ map (n/% num-classes)))
+         instance-idx (|> r.nat (:: @ map (n/% num-instances)))
+         exception-message (r.text +5)
+         #let [class (maybe.assume (list.nth class-idx classes))
+               [instance-class instance-gen] (maybe.assume (list.nth instance-idx instances))
+               exception-message$ (` ["java.lang.String" (~ (code.text exception-message))])]
+         sample r.int
+         monitor r.int
+         instance instance-gen]
+        ($_ seq
+            (test "jvm object null"
+                  (|> (do macro.Monad
+                        [sampleI (expressionT.translate (` ("jvm object null?" ("jvm object null"))))]
+                        (evalT.eval sampleI))
+                      (lang.with-current-module "")
+                      (macro.run (io.run init-jvm))
+                      (case> (#e.Success outputT)
+                             (:! Bool outputT)
+
+                             (#e.Error error)
+                             false)))
+            (test "jvm object null?"
+                  (|> (do macro.Monad
+                        [sampleI (expressionT.translate (` ("jvm object null?" (~ (code.int sample)))))]
+                        (evalT.eval sampleI))
+                      (lang.with-current-module "")
+                      (macro.run (io.run init-jvm))
+                      (case> (#e.Success outputT)
+                             (not (:! Bool outputT))
+
+                             (#e.Error error)
+                             false)))
+            (test "jvm object synchronized"
+                  (|> (do macro.Monad
+                        [sampleI (expressionT.translate (` ("jvm object synchronized" (~ (code.int monitor)) (~ (code.int sample)))))]
+                        (evalT.eval sampleI))
+                      (lang.with-current-module "")
+                      (macro.run (io.run init-jvm))
+                      (case> (#e.Success outputT)
+                             (i/= sample (:! Int outputT))
+
+                             (#e.Error error)
+                             false)))
+            (test "jvm object throw"
+                  (|> (do macro.Monad
+                        [_ runtimeT.translate
+                         sampleI (expressionT.translate (` ("lux try" ("lux function" +1 []
+                                                                       ("jvm object throw" ("jvm member invoke constructor"
+                                                                                            "java.lang.Throwable"
+                                                                                            (~ exception-message$)))))))]
+                        (evalT.eval sampleI))
+                      (lang.with-current-module "")
+                      (macro.run (io.run init-jvm))
+                      (case> (#e.Success outputT)
+                             (case (:! (e.Error Top) outputT)
+                               (#e.Error error)
+                               (text.contains? exception-message error)
+
+                               (#e.Success outputT)
+                               false)
+
+                             (#e.Error error)
+                             false)))
+            (test "jvm object class"
+                  (|> (do macro.Monad
+                        [sampleI (expressionT.translate (` ("jvm object class" (~ (code.text class)))))]
+                        (evalT.eval sampleI))
+                      (lang.with-current-module "")
+                      (macro.run (io.run init-jvm))
+                      (case> (#e.Success outputT)
+                             (|> outputT (:! Class) (Class::getName []) (text/= class))
+
+                             (#e.Error error)
+                             false)))
+            (test "jvm object instance?"
+                  (|> (do macro.Monad
+                        [sampleI (expressionT.translate (` ("jvm object instance?" (~ (code.text instance-class)) (~ instance))))]
+                        (evalT.eval sampleI))
+                      (lang.with-current-module "")
+                      (macro.run (io.run init-jvm))
+                      (case> (#e.Success outputT)
+                             (:! Bool outputT)
+
+                             (#e.Error error)
+                             false)))
+            ))))
+
+(host.import java/util/GregorianCalendar
+  (#static AD int))
+
+(context: "Member [Field]"
+  (<| (times +100)
+      (do @
+        [sample-short (|> r.int (:: @ map (|>> int/abs (i/% 100))))
+         sample-string (r.text +5)
+         other-sample-string (r.text +5)
+         #let [shortS (` ["short" ("jvm object cast" "java.lang.Short" "short"
+                                   ("jvm convert long-to-short" (~ (code.int sample-short))))])
+               stringS (` ["java.lang.String" (~ (code.text sample-string))])
+               type-codeS (` ["org.omg.CORBA.TypeCode" ("jvm object null")])
+               idl-typeS (` ["org.omg.CORBA.IDLType" ("jvm object null")])
+               value-memberS (` ("jvm member invoke constructor"
+                                 "org.omg.CORBA.ValueMember"
+                                 (~ stringS) (~ stringS) (~ stringS) (~ stringS)
+                                 (~ type-codeS) (~ idl-typeS) (~ shortS)))]]
+        ($_ seq
+            (test "jvm member static get"
+                  (|> (do macro.Monad
+                        [sampleI (expressionT.translate (` ("jvm convert int-to-long" ("jvm member static get" "java.util.GregorianCalendar" "AD" "int"))))]
+                        (evalT.eval sampleI))
+                      (lang.with-current-module "")
+                      (macro.run (io.run init-jvm))
+                      (case> (#e.Success outputT)
+                             (i/= GregorianCalendar::AD (:! Int outputT))
+
+                             (#e.Error error)
+                             false)))
+            (test "jvm member static put"
+                  (|> (do macro.Monad
+                        [sampleI (expressionT.translate (` ("jvm member static put" "java.awt.datatransfer.DataFlavor" "allHtmlFlavor" "java.awt.datatransfer.DataFlavor"
+                                                            ("jvm member static get" "java.awt.datatransfer.DataFlavor" "allHtmlFlavor" "java.awt.datatransfer.DataFlavor"))))]
+                        (evalT.eval sampleI))
+                      (lang.with-current-module "")
+                      (macro.run (io.run init-jvm))
+                      (case> (#e.Success outputT)
+                             (is hostL.unit (:! Text outputT))
+
+                             (#e.Error error)
+                             false)))
+            (test "jvm member virtual get"
+                  (|> (do macro.Monad
+                        [sampleI (expressionT.translate (` ("jvm member virtual get" "org.omg.CORBA.ValueMember" "name" "java.lang.String" (~ value-memberS))))]
+                        (evalT.eval sampleI))
+                      (lang.with-current-module "")
+                      (macro.run (io.run init-jvm))
+                      (case> (#e.Success outputT)
+                             (text/= sample-string (:! Text outputT))
+
+                             (#e.Error error)
+                             false)))
+            (test "jvm member virtual put"
+                  (|> (do macro.Monad
+                        [sampleI (expressionT.translate (` ("jvm member virtual get" "org.omg.CORBA.ValueMember" "name" "java.lang.String"
+                                                            ("jvm member virtual put" "org.omg.CORBA.ValueMember" "name" "java.lang.String"
+                                                             (~ (code.text other-sample-string)) (~ value-memberS)))))]
+                        (evalT.eval sampleI))
+                      (lang.with-current-module "")
+                      (macro.run (io.run init-jvm))
+                      (case> (#e.Success outputT)
+                             (text/= other-sample-string (:! Text outputT))
+
+                             (#e.Error error)
+                             false)))
+            ))))
+
+(host.import java/lang/Object)
+
+(host.import (java/util/ArrayList a))
+
+(context: "Member [Method]"
+  (<| (times +100)
+      (do @
+        [sample (|> r.int (:: @ map (|>> int/abs (i/% 100))))
+         #let [object-longS (` ["java.lang.Object" (~ (code.int sample))])
+               intS (` ["int" ("jvm object cast" "java.lang.Integer" "int"
+                               ("jvm convert long-to-int" (~ (code.int sample))))])
+               coded-intS (` ["java.lang.String" (~ (code.text (int/encode sample)))])
+               array-listS (` ("jvm member invoke constructor" "java.util.ArrayList" (~ intS)))]]
+        ($_ seq
+            (test "jvm member invoke static"
+                  (|> (do macro.Monad
+                        [sampleI (expressionT.translate (` ("jvm member invoke static" "java.lang.Long"
+                                                            "decode" "java.lang.Long"
+                                                            (~ coded-intS))))]
+                        (evalT.eval sampleI))
+                      (lang.with-current-module "")
+                      (macro.run (io.run init-jvm))
+                      (case> (#e.Success outputT)
+                             (i/= sample (:! Int outputT))
+
+                             (#e.Error error)
+                             false)))
+            (test "jvm member invoke virtual"
+                  (|> (do macro.Monad
+                        [sampleI (expressionT.translate (` ("jvm object cast" "boolean" "java.lang.Boolean"
+                                                            ("jvm member invoke virtual" "java.lang.Object" "equals" "boolean"
+                                                             (~ (code.int sample)) (~ object-longS)))))]
+                        (evalT.eval sampleI))
+                      (lang.with-current-module "")
+                      (macro.run (io.run init-jvm))
+                      (case> (#e.Success outputT)
+                             (:! Bool outputT)
+
+                             (#e.Error error)
+                             false)))
+            (test "jvm member invoke interface"
+                  (|> (do macro.Monad
+                        [sampleI (expressionT.translate (` ("jvm object cast" "boolean" "java.lang.Boolean"
+                                                            ("jvm member invoke interface" "java.util.Collection" "add" "boolean"
+                                                             (~ array-listS) (~ object-longS)))))]
+                        (evalT.eval sampleI))
+                      (lang.with-current-module "")
+                      (macro.run (io.run init-jvm))
+                      (case> (#e.Success outputT)
+                             (:! Bool outputT)
+
+                             (#e.Error error)
+                             false)))
+            (test "jvm member invoke constructor"
+                  (|> (do macro.Monad
+                        [sampleI (expressionT.translate array-listS)]
+                        (evalT.eval sampleI))
+                      (lang.with-current-module "")
+                      (macro.run (io.run init-jvm))
+                      (case> (#e.Success outputT)
+                             (host.instance? ArrayList (:! Object outputT))
+
+                             (#e.Error error)
+                             false)))
+            ))))
diff --git a/new-luxc/test/test/luxc/lang/translation/jvm/case.lux b/new-luxc/test/test/luxc/lang/translation/jvm/case.lux
deleted file mode 100644
index 2df52d78b..000000000
--- a/new-luxc/test/test/luxc/lang/translation/jvm/case.lux
+++ /dev/null
@@ -1,108 +0,0 @@
-(.module:
-  lux
-  (lux [io]
-       (control [monad #+ do]
-                pipe)
-       (data ["e" error]
-             text/format
-             (coll [list]))
-       ["r" math/random "r/" Monad]
-       [macro]
-       (macro [code])
-       test)
-  (luxc [lang]
-        (lang ["ls" synthesis]
-              (translation (jvm ["@" case]
-                                [".T" expression]
-                                ["@." eval]
-                                ["@." runtime]
-                                ["@." common]))))
-  (test/luxc common))
-
-(def: struct-limit Nat +10)
-
-(def: (tail? size idx)
-  (-> Nat Nat Bool)
-  (n/= (n/dec size) idx))
-
-(def: gen-case
-  (r.Random [ls.Synthesis ls.Path])
-  (<| r.rec (function [gen-case])
-      (`` ($_ r.either
-              (r/wrap [(' []) (' ("lux case pop"))])
-              (~~ (do-template [ ]
-                    [(do r.Monad
-                       [value ]
-                       (wrap [( value) ( value)]))]
-
-                    [r.bool code.bool]
-                    [r.nat code.nat]
-                    [r.int code.int]
-                    [r.deg code.deg]
-                    [r.frac code.frac]
-                    [(r.text +5) code.text]))
-              (do r.Monad
-                [size (|> r.nat (:: @ map (|>> (n/% struct-limit) (n/max +2))))
-                 idx (|> r.nat (:: @ map (n/% size)))
-                 [subS subP] gen-case
-                 #let [caseS (` [(~+ (list.concat (list (list.repeat idx (' []))
-                                                        (list subS)
-                                                        (list.repeat (|> size n/dec (n/- idx)) (' [])))))])
-                       caseP (` ("lux case seq"
-                                 (~ (if (tail? size idx)
-                                      (` ("lux case tuple right" (~ (code.nat idx))))
-                                      (` ("lux case tuple left" (~ (code.nat idx))))))
-                                 (~ subP)))]]
-                (wrap [caseS caseP]))
-              (do r.Monad
-                [size (|> r.nat (:: @ map (|>> (n/% struct-limit) (n/max +2))))
-                 idx (|> r.nat (:: @ map (n/% size)))
-                 [subS subP] gen-case
-                 #let [caseS (` ((~ (code.nat idx)) (~ (code.bool (tail? size idx))) (~ subS)))
-                       caseP (` ("lux case seq"
-                                 (~ (if (tail? size idx)
-                                      (` ("lux case variant right" (~ (code.nat idx))))
-                                      (` ("lux case variant left" (~ (code.nat idx))))))
-                                 (~ subP)))]]
-                (wrap [caseS caseP]))
-              ))))
-
-(context: "Pattern-matching."
-  (<| (times +100)
-      (do @
-        [[valueS pathS] gen-case
-         to-bind r.nat]
-        ($_ seq
-            (test "Can translate pattern-matching."
-                  (|> (do macro.Monad
-                        [runtime-bytecode @runtime.translate
-                         sampleI (@.translate-case expressionT.translate
-                                                   valueS
-                                                   (` ("lux case alt"
-                                                       ("lux case seq" (~ pathS)
-                                                        ("lux case exec" true))
-                                                       ("lux case seq" ("lux case bind" +0)
-                                                        ("lux case exec" false)))))]
-                        (@eval.eval sampleI))
-                      (lang.with-current-module "")
-                      (macro.run (init-compiler []))
-                      (case> (#e.Success valueT)
-                             (:! Bool valueT)
-
-                             (#e.Error error)
-                             false)))
-            (test "Can bind values."
-                  (|> (do macro.Monad
-                        [runtime-bytecode @runtime.translate
-                         sampleI (@.translate-case expressionT.translate
-                                                   (code.nat to-bind)
-                                                   (` ("lux case seq" ("lux case bind" +0)
-                                                       ("lux case exec" (0)))))]
-                        (@eval.eval sampleI))
-                      (lang.with-current-module "")
-                      (macro.run (init-compiler []))
-                      (case> (#e.Success valueT)
-                             (n/= to-bind (:! Nat valueT))
-
-                             _
-                             false)))))))
diff --git a/new-luxc/test/test/luxc/lang/translation/jvm/function.lux b/new-luxc/test/test/luxc/lang/translation/jvm/function.lux
deleted file mode 100644
index d9ee7ac71..000000000
--- a/new-luxc/test/test/luxc/lang/translation/jvm/function.lux
+++ /dev/null
@@ -1,103 +0,0 @@
-(.module:
-  lux
-  (lux [io]
-       (control [monad #+ do]
-                pipe)
-       (data [product]
-             [maybe]
-             ["e" error]
-             (coll ["a" array]
-                   [list "list/" Functor]))
-       ["r" math/random "r/" Monad]
-       [macro]
-       (macro [code])
-       [host]
-       test)
-  (luxc [lang]
-        (lang ["ls" synthesis]
-              (translation (jvm [".T" expression]
-                                ["@." eval]
-                                ["@." runtime]
-                                ["@." common]))))
-  (test/luxc common))
-
-(def: arity-limit Nat +10)
-
-(def: arity
-  (r.Random ls.Arity)
-  (|> r.nat (r/map (|>> (n/% arity-limit) (n/max +1)))))
-
-(def: gen-function
-  (r.Random [ls.Arity Nat ls.Synthesis])
-  (do r.Monad
-    [arity arity
-     arg (|> r.nat (:: @ map (n/% arity)))
-     #let [functionS (` ("lux function" (~ (code.nat arity)) []
-                         ((~ (code.int (nat-to-int (n/inc arg)))))))]]
-    (wrap [arity arg functionS])))
-
-(context: "Function."
-  (<| (times +100)
-      (do @
-        [[arity arg functionS] gen-function
-         cut-off (|> r.nat (:: @ map (n/% arity)))
-         args (r.list arity r.nat)
-         #let [arg-value (maybe.assume (list.nth arg args))
-               argsS (list/map code.nat args)
-               last-arg (n/dec arity)
-               cut-off (|> cut-off (n/min (n/dec last-arg)))]]
-        ($_ seq
-            (test "Can read arguments."
-                  (|> (do macro.Monad
-                        [runtime-bytecode @runtime.translate
-                         sampleI (expressionT.translate (` ("lux call" (~ functionS) (~+ argsS))))]
-                        (@eval.eval sampleI))
-                      (lang.with-current-module "")
-                      (macro.run (init-compiler []))
-                      (case> (#e.Success valueT)
-                             (n/= arg-value (:! Nat valueT))
-
-                             (#e.Error error)
-                             false)))
-            (test "Can partially apply functions."
-                  (or (n/= +1 arity)
-                      (|> (do macro.Monad
-                            [#let [partial-arity (n/inc cut-off)
-                                   preS (list.take partial-arity argsS)
-                                   postS (list.drop partial-arity argsS)]
-                             runtime-bytecode @runtime.translate
-                             sampleI (expressionT.translate (` ("lux call"
-                                                                ("lux call" (~ functionS) (~+ preS))
-                                                                (~+ postS))))]
-                            (@eval.eval sampleI))
-                          (lang.with-current-module "")
-                          (macro.run (init-compiler []))
-                          (case> (#e.Success valueT)
-                                 (n/= arg-value (:! Nat valueT))
-
-                                 (#e.Error error)
-                                 false))))
-            (test "Can read environment."
-                  (or (n/= +1 arity)
-                      (|> (do macro.Monad
-                            [#let [env (|> (list.n/range +0 cut-off)
-                                           (list/map (|>> n/inc nat-to-int)))
-                                   super-arity (n/inc cut-off)
-                                   arg-var (if (n/<= cut-off arg)
-                                             (|> arg n/inc nat-to-int (i/* -1))
-                                             (|> arg n/inc (n/- super-arity) nat-to-int))
-                                   sub-arity (|> arity (n/- super-arity))
-                                   functionS (` ("lux function" (~ (code.nat super-arity)) []
-                                                 ("lux function" (~ (code.nat sub-arity)) [(~+ (list/map code.int env))]
-                                                  ((~ (code.int arg-var))))))]
-                             runtime-bytecode @runtime.translate
-                             sampleI (expressionT.translate (` ("lux call" (~ functionS) (~+ argsS))))]
-                            (@eval.eval sampleI))
-                          (lang.with-current-module "")
-                          (macro.run (init-compiler []))
-                          (case> (#e.Success valueT)
-                                 (n/= arg-value (:! Nat valueT))
-
-                                 (#e.Error error)
-                                 false))))
-            ))))
diff --git a/new-luxc/test/test/luxc/lang/translation/jvm/primitive.lux b/new-luxc/test/test/luxc/lang/translation/jvm/primitive.lux
deleted file mode 100644
index 9d51490e2..000000000
--- a/new-luxc/test/test/luxc/lang/translation/jvm/primitive.lux
+++ /dev/null
@@ -1,65 +0,0 @@
-(.module:
-  lux
-  (lux [io]
-       (control [monad #+ do]
-                pipe)
-       (data text/format
-             ["e" error]
-             [bool "B/" Eq]
-             [text "T/" Eq])
-       ["r" math/random]
-       [macro]
-       (macro [code])
-       test)
-  (luxc [lang]
-        (lang [".L" host]
-              ["ls" synthesis]
-              (translation (jvm [".T" expression]
-                                ["@." runtime]
-                                ["@." eval]
-                                ["@." common]))))
-  (test/luxc common))
-
-(context: "Primitives."
-  (<| (times +100)
-      (do @
-        [%bool% r.bool
-         %nat% r.nat
-         %int% r.int
-         %deg% r.deg
-         %frac% r.frac
-         %text% (r.text +5)]
-        (with-expansions
-          [ (do-template [    ]
-                     [(test (format "Can translate "  ".")
-                            (|> (do macro.Monad
-                                  [sampleI (expressionT.translate ( ))]
-                                  (@eval.eval sampleI))
-                                (lang.with-current-module "")
-                                (macro.run (init-compiler []))
-                                (case> (#e.Success valueT)
-                                       (  (:!  valueT))
-
-                                       (#e.Error error)
-                                       false)))]
-
-                     ["bool" Bool code.bool %bool% B/=]
-                     ["nat"  Nat  code.nat  %nat%  n/=]
-                     ["int"  Int  code.int  %int%  i/=]
-                     ["deg"  Deg  code.deg  %deg%  d/=]
-                     ["frac" Frac code.frac %frac% f/=]
-                     ["text" Text code.text %text% T/=])]
-          ($_ seq
-              (test "Can translate unit."
-                    (|> (do macro.Monad
-                          [sampleI (expressionT.translate (' []))]
-                          (@eval.eval sampleI))
-                        (lang.with-current-module "")
-                        (macro.run (init-compiler []))
-                        (case> (#e.Success valueT)
-                               (is hostL.unit (:! Text valueT))
-
-                               _
-                               false)))
-              
-              )))))
diff --git a/new-luxc/test/test/luxc/lang/translation/jvm/procedure/common.jvm.lux b/new-luxc/test/test/luxc/lang/translation/jvm/procedure/common.jvm.lux
deleted file mode 100644
index d81058e17..000000000
--- a/new-luxc/test/test/luxc/lang/translation/jvm/procedure/common.jvm.lux
+++ /dev/null
@@ -1,385 +0,0 @@
-(.module:
-  lux
-  (lux [io]
-       (control [monad #+ do]
-                pipe)
-       (data text/format
-             [bit]
-             ["e" error]
-             [bool "bool/" Eq]
-             [text "text/" Eq]
-             [number "nat/" Interval "int/" Interval "real/" Interval "deg/" Interval]
-             (coll ["a" array]
-                   [list]))
-       ["r" math/random]
-       [macro]
-       (macro [code])
-       [host]
-       test)
-  (luxc [lang]
-        (lang ["ls" synthesis]
-              (translation (jvm [".T" expression]
-                                ["@." eval]
-                                ["@." runtime]
-                                ["@." common]))))
-  (test/luxc common))
-
-(context: "Bit procedures"
-  (<| (times +100)
-      (do @
-        [param r.nat
-         subject r.nat]
-        (with-expansions [ (do-template [ ]
-                                     [(test 
-                                            (|> (do macro.Monad
-                                                  [sampleI (expressionT.translate (` ( (~ (code.nat subject))
-                                                                                             (~ (code.nat param)))))]
-                                                  (@eval.eval sampleI))
-                                                (lang.with-current-module "")
-                                                (macro.run (init-compiler []))
-                                                (case> (#e.Success valueT)
-                                                       (n/= ( param subject) (:! Nat valueT))
-
-                                                       _
-                                                       false)))]
-
-                                     ["lux bit and"                  bit.and]
-                                     ["lux bit or"                   bit.or]
-                                     ["lux bit xor"                  bit.xor]
-                                     ["lux bit shift-left"           bit.shift-left]
-                                     ["lux bit unsigned-shift-right" bit.shift-right]
-                                     )]
-          ($_ seq
-              (test "lux bit count"
-                    (|> (do macro.Monad
-                          [sampleI (expressionT.translate (` ("lux bit count" (~ (code.nat subject)))))]
-                          (@eval.eval sampleI))
-                        (lang.with-current-module "")
-                        (macro.run (init-compiler []))
-                        (case> (#e.Success valueT)
-                               (n/= (bit.count subject) (:! Nat valueT))
-
-                               _
-                               false)))
-
-              
-              (test "lux bit shift-right"
-                    (|> (do macro.Monad
-                          [sampleI (expressionT.translate (` ("lux bit shift-right"
-                                                              (~ (code.int (nat-to-int subject)))
-                                                              (~ (code.nat param)))))]
-                          (@eval.eval sampleI))
-                        (lang.with-current-module "")
-                        (macro.run (init-compiler []))
-                        (case> (#e.Success valueT)
-                               (i/= (bit.signed-shift-right param (nat-to-int subject))
-                                    (:! Int valueT))
-
-                               _
-                               false)))
-              )))))
-
-(context: "Nat procedures"
-  (<| (times +100)
-      (do @
-        [param (|> r.nat (r.filter (|>> (n/= +0) not)))
-         subject r.nat]
-        (`` ($_ seq
-                (~~ (do-template [ ]
-                      [(test 
-                             (|> (do macro.Monad
-                                   [sampleI (expressionT.translate (` ()))]
-                                   (@eval.eval sampleI))
-                                 (lang.with-current-module "")
-                                 (macro.run (init-compiler []))
-                                 (case> (#e.Success valueT)
-                                        (n/=  (:! Nat valueT))
-
-                                        _
-                                        false)))]
-
-                      ["lux nat min" nat/bottom]
-                      ["lux nat max" nat/top]
-                      ))
-                (~~ (do-template [   ]
-                      [(test 
-                             (|> (do macro.Monad
-                                   [sampleI (expressionT.translate (` ( (~ (code.nat subject)))))]
-                                   (@eval.eval sampleI))
-                                 (lang.with-current-module "")
-                                 (macro.run (init-compiler []))
-                                 (case> (#e.Success valueT)
-                                        ( ( subject) (:!  valueT))
-
-                                        _
-                                        false)))]
-
-                      ["lux nat to-int" Int  nat-to-int     i/=]
-                      ["lux nat char"   Text text.from-code text/=]
-                      ))
-                (~~ (do-template [   ]
-                      [(test 
-                             (|> (do macro.Monad
-                                   [runtime-bytecode @runtime.translate
-                                    sampleI (expressionT.translate (` ( (~ (code.nat subject)) (~ (code.nat param)))))]
-                                   (@eval.eval sampleI))
-                                 (lang.with-current-module "")
-                                 (macro.run (init-compiler []))
-                                 (case> (#e.Success valueT)
-                                        ( ( param subject) (:!  valueT))
-
-                                        _
-                                        false)))]
-
-                      ["lux nat +" n/+ Nat  n/=]
-                      ["lux nat -" n/- Nat  n/=]
-                      ["lux nat *" n/* Nat  n/=]
-                      ["lux nat /" n// Nat  n/=]
-                      ["lux nat %" n/% Nat  n/=]
-                      ["lux nat =" n/= Bool bool/=]
-                      ["lux nat <" n/< Bool bool/=]
-                      ))
-                )))))
-
-(context: "Int procedures"
-  (<| (times +100)
-      (do @
-        [param (|> r.int (r.filter (|>> (i/= 0) not)))
-         subject r.int]
-        (with-expansions [ (do-template [ ]
-                                      [(test 
-                                             (|> (do macro.Monad
-                                                   [sampleI (expressionT.translate (` ()))]
-                                                   (@eval.eval sampleI))
-                                                 (lang.with-current-module "")
-                                                 (macro.run (init-compiler []))
-                                                 (case> (#e.Success valueT)
-                                                        (i/=  (:! Int valueT))
-
-                                                        _
-                                                        false)))]
-
-                                      ["lux int min" int/bottom]
-                                      ["lux int max" int/top]
-                                      )
-                           (do-template [   ]
-                                    [(test 
-                                           (|> (do macro.Monad
-                                                 [sampleI (expressionT.translate (` ( (~ (code.int subject)))))]
-                                                 (@eval.eval sampleI))
-                                               (lang.with-current-module "")
-                                               (macro.run (init-compiler []))
-                                               (case> (#e.Success valueT)
-                                                      ( ( subject) (:!  valueT))
-
-                                                      _
-                                                      false)))]
-
-                                    ["lux int to-nat"  Nat  int-to-nat  n/=]
-                                    ["lux int to-frac" Frac int-to-frac f/=]
-                                    )
-                           (do-template [   ]
-                                     [(test 
-                                            (|> (do macro.Monad
-                                                  [runtime-bytecode @runtime.translate
-                                                   sampleI (expressionT.translate (` ( (~ (code.int subject)) (~ (code.int param)))))]
-                                                  (@eval.eval sampleI))
-                                                (lang.with-current-module "")
-                                                (macro.run (init-compiler []))
-                                                (case> (#e.Success valueT)
-                                                       ( ( param subject) (:!  valueT))
-
-                                                       _
-                                                       false)))]
-
-                                     ["lux int +" i/+ Int  i/=]
-                                     ["lux int -" i/- Int  i/=]
-                                     ["lux int *" i/* Int  i/=]
-                                     ["lux int /" i// Int  i/=]
-                                     ["lux int %" i/% Int  i/=]
-                                     ["lux int =" i/= Bool bool/=]
-                                     ["lux int <" i/< Bool bool/=]
-                                     )]
-          ($_ seq
-              
-              
-              
-              )))))
-
-(context: "Frac procedures [Part 1]"
-  (<| (times +100)
-      (do @
-        [param (|> r.frac (r.filter (|>> (f/= 0.0) not)))
-         subject r.frac]
-        (with-expansions [ (do-template [   ]
-                                     [(test 
-                                            (|> (do macro.Monad
-                                                  [runtime-bytecode @runtime.translate
-                                                   sampleI (expressionT.translate (` ( (~ (code.frac subject)) (~ (code.frac param)))))]
-                                                  (@eval.eval sampleI))
-                                                (lang.with-current-module "")
-                                                (macro.run (init-compiler []))
-                                                (case> (#e.Success valueT)
-                                                       ( ( param subject) (:!  valueT))
-
-                                                       _
-                                                       false)))]
-
-                                     ["lux frac +" f/+ Frac f/=]
-                                     ["lux frac -" f/- Frac f/=]
-                                     ["lux frac *" f/* Frac f/=]
-                                     ["lux frac /" f// Frac f/=]
-                                     ["lux frac %" f/% Frac f/=]
-                                     ["lux frac =" f/= Bool bool/=]
-                                     ["lux frac <" f/< Bool bool/=]
-                                     )]
-          ($_ seq
-              
-              )))))
-
-(context: "Frac procedures [Part 2]"
-  (<| (times +100)
-      (do @
-        [param (|> r.frac (r.filter (|>> (f/= 0.0) not)))
-         subject r.frac]
-        (with-expansions [ (do-template [ ]
-                                      [(test 
-                                             (|> (do macro.Monad
-                                                   [sampleI (expressionT.translate (` ()))]
-                                                   (@eval.eval sampleI))
-                                                 (lang.with-current-module "")
-                                                 (macro.run (init-compiler []))
-                                                 (case> (#e.Success valueT)
-                                                        ( (:! Frac valueT))
-
-                                                        _
-                                                        false)))]
-
-                                      ["lux frac min" (f/= real/bottom)]
-                                      ["lux frac max" (f/= real/top)]
-                                      ["lux frac not-a-number" number.not-a-number?]
-                                      ["lux frac positive-infinity" (f/= number.positive-infinity)]
-                                      ["lux frac negative-infinity" (f/= number.negative-infinity)]
-                                      ["lux frac smallest" (f/= ("lux frac smallest"))]
-                                      )
-                           (do-template [   ]
-                                    [(test 
-                                           (|> (do macro.Monad
-                                                 [runtime-bytecode @runtime.translate
-                                                  sampleI (expressionT.translate (` ( (~ (code.frac subject)))))]
-                                                 (@eval.eval sampleI))
-                                               (lang.with-current-module "")
-                                               (macro.run (init-compiler []))
-                                               (case> (#e.Success valueT)
-                                                      ( ( subject) (:!  valueT))
-
-                                                      _
-                                                      false)))]
-
-                                    ["lux frac to-int" Int frac-to-int i/=]
-                                    ["lux frac to-deg" Deg frac-to-deg d/=]
-                                    )]
-          ($_ seq
-              
-              
-              (test "frac encode|decode"
-                    (|> (do macro.Monad
-                          [runtime-bytecode @runtime.translate
-                           sampleI (expressionT.translate (` ("lux frac decode" ("lux frac encode" (~ (code.frac subject))))))]
-                          (@eval.eval sampleI))
-                        (lang.with-current-module "")
-                        (macro.run (init-compiler []))
-                        (case> (^multi (#e.Success valueT)
-                                       [(:! (Maybe Frac) valueT) (#.Some value)])
-                               (f/= subject value)
-
-                               _
-                               false)))
-              )))))
-
-(def: (above-threshold value)
-  (-> Deg Deg)
-  (let [threshold .000000001 #( 1/(2^30) )#]
-    (if (d/< threshold value)
-      (d/+ threshold value)
-      value)))
-
-(context: "Deg procedures"
-  (<| (times +100)
-      (do @
-        [param (|> r.deg (:: @ map above-threshold))
-         special r.nat
-         subject (|> r.deg (:: @ map above-threshold))]
-        (`` ($_ seq
-                (~~ (do-template [ ]
-                      [(test 
-                             (|> (do macro.Monad
-                                   [sampleI (expressionT.translate (` ()))]
-                                   (@eval.eval sampleI))
-                                 (lang.with-current-module "")
-                                 (macro.run (init-compiler []))
-                                 (case> (#e.Success valueT)
-                                        (d/=  (:! Deg valueT))
-
-                                        _
-                                        false)))]
-
-                      ["lux deg min" deg/bottom]
-                      ["lux deg max" deg/top]
-                      ))
-                (~~ (do-template [   ]
-                      [(test 
-                             (|> (do macro.Monad
-                                   [runtime-bytecode @runtime.translate
-                                    sampleI (expressionT.translate (` ( (~ (code.deg subject)))))]
-                                   (@eval.eval sampleI))
-                                 (lang.with-current-module "")
-                                 (macro.run (init-compiler []))
-                                 (case> (#e.Success valueT)
-                                        ( ( subject) (:!  valueT))
-
-                                        _
-                                        false)))]
-
-                      ["lux deg to-frac" Frac deg-to-frac f/=]
-                      ))
-                (~~ (do-template [   ]
-                      [(test 
-                             (|> (do macro.Monad
-                                   [runtime-bytecode @runtime.translate
-                                    sampleI (expressionT.translate (` ( (~ (code.deg subject)) (~ (code.deg param)))))]
-                                   (@eval.eval sampleI))
-                                 (lang.with-current-module "")
-                                 (macro.run (init-compiler []))
-                                 (case> (#e.Success valueT)
-                                        ( ( param subject) (:!  valueT))
-
-                                        _
-                                        false)))]
-
-                      ["lux deg +" d/+ Deg  d/=]
-                      ["lux deg -" d/- Deg  d/=]
-                      ["lux deg *" d/* Deg  d/=]
-                      ["lux deg /" d// Deg  d/=]
-                      ["lux deg %" d/% Deg  d/=]
-                      ["lux deg =" d/= Bool bool/=]
-                      ["lux deg <" d/< Bool bool/=]
-                      ))
-                (~~ (do-template [   ]
-                      [(test 
-                             (|> (do macro.Monad
-                                   [runtime-bytecode @runtime.translate
-                                    sampleI (expressionT.translate (` ( (~ (code.deg subject)) (~ (code.nat special)))))]
-                                   (@eval.eval sampleI))
-                                 (lang.with-current-module "")
-                                 (macro.run (init-compiler []))
-                                 (case> (#e.Success valueT)
-                                        ( ( special subject) (:!  valueT))
-
-                                        _
-                                        false)))]
-
-                      ["lux deg scale"      d/scale      Deg d/=]
-                      ["lux deg reciprocal" d/reciprocal Deg d/=]
-                      ))
-                )))))
diff --git a/new-luxc/test/test/luxc/lang/translation/jvm/procedure/host.jvm.lux b/new-luxc/test/test/luxc/lang/translation/jvm/procedure/host.jvm.lux
deleted file mode 100644
index 0db10f82a..000000000
--- a/new-luxc/test/test/luxc/lang/translation/jvm/procedure/host.jvm.lux
+++ /dev/null
@@ -1,646 +0,0 @@
-(.module:
-  lux
-  (lux [io]
-       (control [monad #+ do]
-                pipe)
-       (data [maybe]
-             ["e" error]
-             [bit]
-             [bool "bool/" Eq]
-             [number "int/" Number Codec]
-             [text "text/" Eq]
-             text/format
-             (coll [list]))
-       ["r" math/random "r/" Monad]
-       [macro]
-       (macro [code])
-       [host]
-       test)
-  (luxc [lang]
-        (lang [".L" host]
-              ["ls" synthesis]
-              (translation (jvm [".T" expression]
-                                ["@." eval]
-                                ["@." runtime]
-                                ["@." common]))))
-  (test/luxc common))
-
-(context: "Conversions [Part 1]"
-  (<| (times +100)
-      (do @
-        [int-sample (|> r.int (:: @ map (i/% 128)))
-         #let [frac-sample (int-to-frac int-sample)]]
-        (with-expansions [<2step> (do-template [     ]
-                                    [(test (format  " / " )
-                                           (|> (do macro.Monad
-                                                 [sampleI (expressionT.translate (|> (~ ( ))   (`)))]
-                                                 (@eval.eval sampleI))
-                                               (lang.with-current-module "")
-                                               (macro.run (init-compiler []))
-                                               (case> (#e.Success valueT)
-                                                      (  (:!  valueT))
-
-                                                      (#e.Error error)
-                                                      false)))]
-
-                                    ["jvm convert double-to-float" "jvm convert float-to-double" code.frac frac-sample Frac f/=]
-                                    ["jvm convert double-to-int"   "jvm convert int-to-double" code.frac frac-sample Frac f/=]
-                                    ["jvm convert double-to-long"  "jvm convert long-to-double" code.frac frac-sample Frac f/=]
-
-                                    ["jvm convert long-to-float" "jvm convert float-to-long" code.int int-sample Int i/=]
-                                    ["jvm convert long-to-int" "jvm convert int-to-long" code.int int-sample Int i/=]
-                                    ["jvm convert long-to-short" "jvm convert short-to-long" code.int int-sample Int i/=]
-                                    ["jvm convert long-to-byte" "jvm convert byte-to-long" code.int int-sample Int i/=]
-                                    )]
-          ($_ seq
-              <2step>
-              )))))
-
-(context: "Conversions [Part 2]"
-  (<| (times +100)
-      (do @
-        [int-sample (|> r.int (:: @ map (|>> (i/% 128) int/abs)))
-         #let [frac-sample (int-to-frac int-sample)]]
-        (`` ($_ seq
-                (~~ (do-template [      ]
-                      [(test (format  " / "  " / " )
-                             (|> (do macro.Monad
-                                   [sampleI (expressionT.translate (|> (~ ( ))    (`)))]
-                                   (@eval.eval sampleI))
-                                 (lang.with-current-module "")
-                                 (macro.run (init-compiler []))
-                                 (case> (#e.Success valueT)
-                                        (  (:!  valueT))
-
-                                        (#e.Error error)
-                                        false)))]
-
-                      ["jvm convert long-to-int"   "jvm convert int-to-char"  "jvm convert char-to-long"  code.int int-sample Int i/=]
-                      ["jvm convert long-to-int"   "jvm convert int-to-byte"  "jvm convert byte-to-long"  code.int int-sample Int i/=]
-                      ["jvm convert long-to-int"   "jvm convert int-to-short" "jvm convert short-to-long" code.int int-sample Int i/=]
-                      ["jvm convert long-to-float" "jvm convert float-to-int" "jvm convert int-to-long"   code.int int-sample Int i/=]
-                      ["jvm convert long-to-int"   "jvm convert int-to-float" "jvm convert float-to-long" code.int int-sample Int i/=]
-                      ))
-                )))))
-
-(context: "Conversions [Part 3]"
-  (<| (times +100)
-      (do @
-        [int-sample (|> r.int (:: @ map (|>> (i/% 128) int/abs)))
-         #let [frac-sample (int-to-frac int-sample)]]
-        (`` ($_ seq
-                (~~ (do-template [       ]
-                      [(test (format  " / "  " / " )
-                             (|> (do macro.Monad
-                                   [sampleI (expressionT.translate (|> (~ ( ))     (`)))]
-                                   (@eval.eval sampleI))
-                                 (lang.with-current-module "")
-                                 (macro.run (init-compiler []))
-                                 (case> (#e.Success valueT)
-                                        (  (:!  valueT))
-
-                                        (#e.Error error)
-                                        false)))]
-
-                      ["jvm convert long-to-int" "jvm convert int-to-char" "jvm convert char-to-byte" "jvm convert byte-to-long" code.int int-sample Int i/=]
-                      ["jvm convert long-to-int" "jvm convert int-to-char" "jvm convert char-to-short" "jvm convert short-to-long" code.int int-sample Int i/=]
-                      ["jvm convert long-to-int" "jvm convert int-to-char" "jvm convert char-to-int" "jvm convert int-to-long" code.int int-sample Int i/=]
-                      ))
-                )))))
-
-(def: gen-nat
-  (r.Random Nat)
-  (|> r.nat
-      (r/map (n/% +128))
-      (r.filter (|>> (n/= +0) not))))
-
-(def: gen-int
-  (r.Random Int)
-  (|> gen-nat (r/map nat-to-int)))
-
-(def: gen-frac
-  (r.Random Frac)
-  (|> gen-int (r/map int-to-frac)))
-
-(do-template [      <+> <-> <*>  <%> 
 ]
-  [(context: (format "Arithmetic ["  "]")
-     (<| (times +100)
-         (do @
-           [param 
-            #let [subject ( param)]]
-           (with-expansions [ (do-template [ ]
-                                       [(test 
-                                              (|> (do macro.Monad
-                                                    [sampleI (expressionT.translate (` ( ((~ (code.text ))
-                                                                                                (
 (~ ( subject)))
-                                                                                                (
 (~ ( param)))))))]
-                                                    (@eval.eval sampleI))
-                                                  (lang.with-current-module "")
-                                                  (macro.run (init-compiler []))
-                                                  (case> (#e.Success valueT)
-                                                         ( ( param subject)
-                                                                 (:!  valueT))
-
-                                                         (#e.Error error)
-                                                         false)))]
-
-                                       [(format "jvm "  " +") <+>]
-                                       [(format "jvm "  " -") <->]
-                                       [(format "jvm "  " *") <*>]
-                                       [(format "jvm "  " /") ]
-                                       [(format "jvm "  " %") <%>]
-                                       )]
-             ($_ seq
-                 
-                 )))))]
-
-  ["int" gen-int code.int Int i/= (i/* 10) i/+ i/- i/* i// i/% "jvm convert long-to-int" "jvm convert int-to-long"]
-  ["long" gen-int code.int Int i/= (i/* 10) i/+ i/- i/* i// i/% "lux noop" "lux noop"]
-  ["float" gen-frac code.frac Frac f/= (f/* 10.0) f/+ f/- f/* f// f/% "jvm convert double-to-float" "jvm convert float-to-double"]
-  ["double" gen-frac code.frac Frac f/= (f/* 10.0) f/+ f/- f/* f// f/% "lux noop" "lux noop"]
-  )
-
-(do-template [  ]
-  [(context: (format "Bit-wise ["  "] { Combiners ]")
-     (<| (times +100)
-         (do @
-           [param gen-nat
-            subject gen-nat]
-           (`` ($_ seq
-                   (~~ (do-template [ ]
-                         [(test 
-                                (|> (do macro.Monad
-                                      [sampleI (expressionT.translate (` ( ((~ (code.text ))
-                                                                                  ( (~ (code.nat subject)))
-                                                                                  ( (~ (code.nat param)))))))]
-                                      (@eval.eval sampleI))
-                                    (lang.with-current-module "")
-                                    (macro.run (init-compiler []))
-                                    (case> (#e.Success valueT)
-                                           (n/= ( param subject)
-                                                (:! Nat valueT))
-
-                                           (#e.Error error)
-                                           false)))]
-
-                         [(format "jvm "  " and") bit.and]
-                         [(format "jvm "  " or") bit.or]
-                         [(format "jvm "  " xor") bit.xor]
-                         ))
-                   )))))]
-
-  ["int" "jvm convert int-to-long" "jvm convert long-to-int"]
-  ["long" "lux noop" "lux noop"]
-  )
-
-(do-template [  ]
-  [(context: (format "Bit-wise ["  "] { Shifters }")
-     (<| (times +100)
-         (do @
-           [param gen-nat
-            subject gen-nat
-            #let [shift (n/% +10 param)]]
-           (`` ($_ seq
-                   (~~ (do-template [     
]
-                         [(test 
-                                (|> (do macro.Monad
-                                      [sampleI (expressionT.translate (` ( ((~ (code.text ))
-                                                                                  ( (~ (
 subject)))
-                                                                                  ("jvm convert long-to-int" (~ (code.nat shift)))))))]
-                                      (@eval.eval sampleI))
-                                    (lang.with-current-module "")
-                                    (macro.run (init-compiler []))
-                                    (case> (#e.Success valueT)
-                                           ( ( shift ( subject))
-                                                   (:!  valueT))
-
-                                           (#e.Error error)
-                                           false)))]
-
-                         [(format "jvm "  " shl") bit.shift-left Nat n/= id code.nat]
-                         [(format "jvm "  " shr") bit.signed-shift-right Int i/= nat-to-int (|>> nat-to-int code.int)]
-                         [(format "jvm "  " ushr") bit.shift-right Nat n/= id code.nat]
-                         ))
-                   )))))]
-
-  ["int" "jvm convert int-to-long" "jvm convert long-to-int"]
-  ["long" "lux noop" "lux noop"]
-  )
-
-(do-template [   <=> <<> 
]
-  [(context: (format "Order ["  "]")
-     (<| (times +100)
-         (do @
-           [param 
-            subject ]
-           (with-expansions [ (do-template [ ]
-                                       [(test 
-                                              (|> (do macro.Monad
-                                                    [sampleI (expressionT.translate (` ((~ (code.text ))
-                                                                                        (
 (~ ( subject)))
-                                                                                        (
 (~ ( param))))))]
-                                                    (@eval.eval sampleI))
-                                                  (lang.with-current-module "")
-                                                  (macro.run (init-compiler []))
-                                                  (case> (#e.Success valueT)
-                                                         (bool/= ( param subject)
-                                                                 (:! Bool valueT))
-
-                                                         (#e.Error error)
-                                                         false)))]
-
-                                       [(format "jvm "  " =") <=>]
-                                       [(format "jvm "  " <") <<>]
-                                       )]
-             ($_ seq
-                 
-                 )))))]
-
-  ["int" gen-int code.int i/= i/< "jvm convert long-to-int"]
-  ["long" gen-int code.int i/= i/< "lux noop"]
-  ["float" gen-frac code.frac f/= f/< "jvm convert double-to-float"]
-  ["double" gen-frac code.frac f/= f/< "lux noop"]
-  ["char" gen-int code.int i/= i/< "jvm convert long-to-char"]
-  )
-
-(def: (jvm//array//new dimension class size)
-  (-> Nat Text Nat ls.Synthesis)
-  (` ("jvm array new" (~ (code.nat dimension)) (~ (code.text class)) (~ (code.nat size)))))
-
-(def: (jvm//array//write class idx inputS arrayS)
-  (-> Text Nat ls.Synthesis ls.Synthesis ls.Synthesis)
-  (` ("jvm array write" (~ (code.text class)) (~ (code.nat idx)) (~ inputS) (~ arrayS))))
-
-(def: (jvm//array//read class idx arrayS)
-  (-> Text Nat ls.Synthesis ls.Synthesis)
-  (` ("jvm array read" (~ (code.text class)) (~ (code.nat idx)) (~ arrayS))))
-
-(context: "Array [Part 1]"
-  (<| (times +100)
-      (do @
-        [size (|> r.nat (:: @ map (|>> (n/% +10) (n/max +1))))
-         idx (|> r.nat (:: @ map (n/% size)))
-         valueZ r.bool
-         valueB gen-int
-         valueS gen-int
-         valueI gen-int
-         valueL r.int
-         valueF gen-frac
-         valueD r.frac
-         valueC gen-int]
-        (with-expansions [ (do-template [     ]
-                                    [(test 
-                                           (|> (do macro.Monad
-                                                 [sampleI (expressionT.translate (|> (jvm//array//new +0  size)
-                                                                                     (jvm//array//write  idx )
-                                                                                     (jvm//array//read  idx)
-                                                                                     (~)
-                                                                                     
-                                                                                     (`)))]
-                                                 (@eval.eval sampleI))
-                                               (lang.with-current-module "")
-                                               (macro.run (init-compiler []))
-                                               (case> (#e.Success outputZ)
-                                                      (  (:!  outputZ))
-
-                                                      (#e.Error error)
-                                                      false)))]
-
-                                    ["boolean" Bool valueZ bool/= (code.bool valueZ)
-                                     "lux noop"]
-                                    ["byte" Int valueB i/= (|> (code.int valueB) (~) "jvm convert long-to-byte" (`))
-                                     "jvm convert byte-to-long"]
-                                    ["short" Int valueS i/= (|> (code.int valueS) (~) "jvm convert long-to-short" (`))
-                                     "jvm convert short-to-long"]
-                                    ["int" Int valueI i/= (|> (code.int valueI) (~) "jvm convert long-to-int" (`))
-                                     "jvm convert int-to-long"]
-                                    ["long" Int valueL i/= (code.int valueL)
-                                     "lux noop"]
-                                    ["float" Frac valueF f/= (|> (code.frac valueF) (~) "jvm convert double-to-float" (`))
-                                     "jvm convert float-to-double"]
-                                    ["double" Frac valueD f/= (code.frac valueD)
-                                     "lux noop"]
-                                    )]
-          ($_ seq
-              
-              )))))
-
-(context: "Array [Part 2]"
-  (<| (times +100)
-      (do @
-        [size (|> r.nat (:: @ map (|>> (n/% +10) (n/max +1))))
-         idx (|> r.nat (:: @ map (n/% size)))
-         valueZ r.bool
-         valueB gen-int
-         valueS gen-int
-         valueI gen-int
-         valueL r.int
-         valueF gen-frac
-         valueD r.frac
-         valueC gen-int]
-        (with-expansions [ (do-template [     ]
-                                    [(test 
-                                           (|> (do macro.Monad
-                                                 [sampleI (expressionT.translate (|> (jvm//array//new +0  size)
-                                                                                     (jvm//array//write  idx )
-                                                                                     (jvm//array//read  idx)
-                                                                                     (~)
-                                                                                     
-                                                                                     (`)))]
-                                                 (@eval.eval sampleI))
-                                               (lang.with-current-module "")
-                                               (macro.run (init-compiler []))
-                                               (case> (#e.Success outputT)
-                                                      (  (:!  outputT))
-
-                                                      (#e.Error error)
-                                                      false)))]
-
-                                    ["char" Int valueC i/=
-                                     (|> (code.int valueC) (~) "jvm convert long-to-int" "jvm convert int-to-char" (`))
-                                     "jvm convert char-to-long"]
-                                    ["java.lang.Long" Int valueL i/=
-                                     (code.int valueL)
-                                     "lux noop"]
-                                    )]
-          ($_ seq
-              
-              (test "java.lang.Double (level 1)"
-                    (|> (do macro.Monad
-                          [#let [inner (|> ("jvm array new" +0 "java.lang.Double" (~ (code.nat size)))
-                                           ("jvm array write" "java.lang.Double" (~ (code.nat idx)) (~ (code.frac valueD)))
-                                           (`))]
-                           sampleI (expressionT.translate (|> ("jvm array new" +1 "java.lang.Double" (~ (code.nat size)))
-                                                              ("jvm array write" "#Array" (~ (code.nat idx)) (~ inner))
-                                                              ("jvm array read" "#Array" (~ (code.nat idx)))
-                                                              ("jvm array read" "java.lang.Double" (~ (code.nat idx)))
-                                                              (`)))]
-                          (@eval.eval sampleI))
-                        (lang.with-current-module "")
-                        (macro.run (init-compiler []))
-                        (case> (#e.Success outputT)
-                               (f/= valueD (:! Frac outputT))
-
-                               (#e.Error error)
-                               false)))
-              (test "jvm array length"
-                    (|> (do macro.Monad
-                          [sampleI (expressionT.translate (` ("jvm array length" ("jvm array new" +0 "java.lang.Object" (~ (code.nat size))))))]
-                          (@eval.eval sampleI))
-                        (lang.with-current-module "")
-                        (macro.run (init-compiler []))
-                        (case> (#e.Success outputT)
-                               (n/= size (:! Nat outputT))
-
-                               (#e.Error error)
-                               false)))
-              )))))
-
-(host.import java/lang/Class
-  (getName [] String))
-
-(def: classes
-  (List Text)
-  (list "java.lang.Object" "java.lang.Class"
-        "java.lang.String" "java.lang.Number"))
-
-(def: instances
-  (List [Text (r.Random ls.Synthesis)])
-  (let [gen-boolean (|> r.bool (:: r.Functor map code.bool))
-        gen-integer (|> r.int (:: r.Functor map code.int))
-        gen-double (|> r.frac (:: r.Functor map code.frac))
-        gen-string (|> (r.text +5) (:: r.Functor map code.text))]
-    (list ["java.lang.Boolean" gen-boolean]
-          ["java.lang.Long" gen-integer]
-          ["java.lang.Double" gen-double]
-          ["java.lang.String" gen-string]
-          ["java.lang.Object" (r.either (r.either gen-boolean
-                                                  gen-integer)
-                                        (r.either gen-double
-                                                  gen-string))])))
-
-(context: "Object."
-  (<| (times +100)
-      (do @
-        [#let [num-classes (list.size classes)]
-         #let [num-instances (list.size instances)]
-         class-idx (|> r.nat (:: @ map (n/% num-classes)))
-         instance-idx (|> r.nat (:: @ map (n/% num-instances)))
-         exception-message (r.text +5)
-         #let [class (maybe.assume (list.nth class-idx classes))
-               [instance-class instance-gen] (maybe.assume (list.nth instance-idx instances))
-               exception-message$ (` ["java.lang.String" (~ (code.text exception-message))])]
-         sample r.int
-         monitor r.int
-         instance instance-gen]
-        ($_ seq
-            (test "jvm object null"
-                  (|> (do macro.Monad
-                        [sampleI (expressionT.translate (` ("jvm object null?" ("jvm object null"))))]
-                        (@eval.eval sampleI))
-                      (lang.with-current-module "")
-                      (macro.run (init-compiler []))
-                      (case> (#e.Success outputT)
-                             (:! Bool outputT)
-
-                             (#e.Error error)
-                             false)))
-            (test "jvm object null?"
-                  (|> (do macro.Monad
-                        [sampleI (expressionT.translate (` ("jvm object null?" (~ (code.int sample)))))]
-                        (@eval.eval sampleI))
-                      (lang.with-current-module "")
-                      (macro.run (init-compiler []))
-                      (case> (#e.Success outputT)
-                             (not (:! Bool outputT))
-
-                             (#e.Error error)
-                             false)))
-            (test "jvm object synchronized"
-                  (|> (do macro.Monad
-                        [sampleI (expressionT.translate (` ("jvm object synchronized" (~ (code.int monitor)) (~ (code.int sample)))))]
-                        (@eval.eval sampleI))
-                      (lang.with-current-module "")
-                      (macro.run (init-compiler []))
-                      (case> (#e.Success outputT)
-                             (i/= sample (:! Int outputT))
-
-                             (#e.Error error)
-                             false)))
-            (test "jvm object throw"
-                  (|> (do macro.Monad
-                        [_ @runtime.translate
-                         sampleI (expressionT.translate (` ("lux try" ("lux function" +1 []
-                                                                       ("jvm object throw" ("jvm member invoke constructor"
-                                                                                            "java.lang.Throwable"
-                                                                                            (~ exception-message$)))))))]
-                        (@eval.eval sampleI))
-                      (lang.with-current-module "")
-                      (macro.run (init-compiler []))
-                      (case> (#e.Success outputT)
-                             (case (:! (e.Error Top) outputT)
-                               (#e.Error error)
-                               (text.contains? exception-message error)
-
-                               (#e.Success outputT)
-                               false)
-
-                             (#e.Error error)
-                             false)))
-            (test "jvm object class"
-                  (|> (do macro.Monad
-                        [sampleI (expressionT.translate (` ("jvm object class" (~ (code.text class)))))]
-                        (@eval.eval sampleI))
-                      (lang.with-current-module "")
-                      (macro.run (init-compiler []))
-                      (case> (#e.Success outputT)
-                             (|> outputT (:! Class) (Class::getName []) (text/= class))
-
-                             (#e.Error error)
-                             false)))
-            (test "jvm object instance?"
-                  (|> (do macro.Monad
-                        [sampleI (expressionT.translate (` ("jvm object instance?" (~ (code.text instance-class)) (~ instance))))]
-                        (@eval.eval sampleI))
-                      (lang.with-current-module "")
-                      (macro.run (init-compiler []))
-                      (case> (#e.Success outputT)
-                             (:! Bool outputT)
-
-                             (#e.Error error)
-                             false)))
-            ))))
-
-(host.import java/util/GregorianCalendar
-  (#static AD int))
-
-(context: "Member [Field]"
-  (<| (times +100)
-      (do @
-        [sample-short (|> r.int (:: @ map (|>> int/abs (i/% 100))))
-         sample-string (r.text +5)
-         other-sample-string (r.text +5)
-         #let [shortS (` ["short" ("jvm object cast" "java.lang.Short" "short"
-                                   ("jvm convert long-to-short" (~ (code.int sample-short))))])
-               stringS (` ["java.lang.String" (~ (code.text sample-string))])
-               type-codeS (` ["org.omg.CORBA.TypeCode" ("jvm object null")])
-               idl-typeS (` ["org.omg.CORBA.IDLType" ("jvm object null")])
-               value-memberS (` ("jvm member invoke constructor"
-                                 "org.omg.CORBA.ValueMember"
-                                 (~ stringS) (~ stringS) (~ stringS) (~ stringS)
-                                 (~ type-codeS) (~ idl-typeS) (~ shortS)))]]
-        ($_ seq
-            (test "jvm member static get"
-                  (|> (do macro.Monad
-                        [sampleI (expressionT.translate (` ("jvm convert int-to-long" ("jvm member static get" "java.util.GregorianCalendar" "AD" "int"))))]
-                        (@eval.eval sampleI))
-                      (lang.with-current-module "")
-                      (macro.run (init-compiler []))
-                      (case> (#e.Success outputT)
-                             (i/= GregorianCalendar::AD (:! Int outputT))
-
-                             (#e.Error error)
-                             false)))
-            (test "jvm member static put"
-                  (|> (do macro.Monad
-                        [sampleI (expressionT.translate (` ("jvm member static put" "java.awt.datatransfer.DataFlavor" "allHtmlFlavor" "java.awt.datatransfer.DataFlavor"
-                                                            ("jvm member static get" "java.awt.datatransfer.DataFlavor" "allHtmlFlavor" "java.awt.datatransfer.DataFlavor"))))]
-                        (@eval.eval sampleI))
-                      (lang.with-current-module "")
-                      (macro.run (init-compiler []))
-                      (case> (#e.Success outputT)
-                             (is hostL.unit (:! Text outputT))
-
-                             (#e.Error error)
-                             false)))
-            (test "jvm member virtual get"
-                  (|> (do macro.Monad
-                        [sampleI (expressionT.translate (` ("jvm member virtual get" "org.omg.CORBA.ValueMember" "name" "java.lang.String" (~ value-memberS))))]
-                        (@eval.eval sampleI))
-                      (lang.with-current-module "")
-                      (macro.run (init-compiler []))
-                      (case> (#e.Success outputT)
-                             (text/= sample-string (:! Text outputT))
-
-                             (#e.Error error)
-                             false)))
-            (test "jvm member virtual put"
-                  (|> (do macro.Monad
-                        [sampleI (expressionT.translate (` ("jvm member virtual get" "org.omg.CORBA.ValueMember" "name" "java.lang.String"
-                                                            ("jvm member virtual put" "org.omg.CORBA.ValueMember" "name" "java.lang.String"
-                                                             (~ (code.text other-sample-string)) (~ value-memberS)))))]
-                        (@eval.eval sampleI))
-                      (lang.with-current-module "")
-                      (macro.run (init-compiler []))
-                      (case> (#e.Success outputT)
-                             (text/= other-sample-string (:! Text outputT))
-
-                             (#e.Error error)
-                             false)))
-            ))))
-
-(host.import java/lang/Object)
-
-(host.import (java/util/ArrayList a))
-
-(context: "Member [Method]"
-  (<| (times +100)
-      (do @
-        [sample (|> r.int (:: @ map (|>> int/abs (i/% 100))))
-         #let [object-longS (` ["java.lang.Object" (~ (code.int sample))])
-               intS (` ["int" ("jvm object cast" "java.lang.Integer" "int"
-                               ("jvm convert long-to-int" (~ (code.int sample))))])
-               coded-intS (` ["java.lang.String" (~ (code.text (int/encode sample)))])
-               array-listS (` ("jvm member invoke constructor" "java.util.ArrayList" (~ intS)))]]
-        ($_ seq
-            (test "jvm member invoke static"
-                  (|> (do macro.Monad
-                        [sampleI (expressionT.translate (` ("jvm member invoke static" "java.lang.Long"
-                                                            "decode" "java.lang.Long"
-                                                            (~ coded-intS))))]
-                        (@eval.eval sampleI))
-                      (lang.with-current-module "")
-                      (macro.run (init-compiler []))
-                      (case> (#e.Success outputT)
-                             (i/= sample (:! Int outputT))
-
-                             (#e.Error error)
-                             false)))
-            (test "jvm member invoke virtual"
-                  (|> (do macro.Monad
-                        [sampleI (expressionT.translate (` ("jvm object cast" "boolean" "java.lang.Boolean"
-                                                            ("jvm member invoke virtual" "java.lang.Object" "equals" "boolean"
-                                                             (~ (code.int sample)) (~ object-longS)))))]
-                        (@eval.eval sampleI))
-                      (lang.with-current-module "")
-                      (macro.run (init-compiler []))
-                      (case> (#e.Success outputT)
-                             (:! Bool outputT)
-
-                             (#e.Error error)
-                             false)))
-            (test "jvm member invoke interface"
-                  (|> (do macro.Monad
-                        [sampleI (expressionT.translate (` ("jvm object cast" "boolean" "java.lang.Boolean"
-                                                            ("jvm member invoke interface" "java.util.Collection" "add" "boolean"
-                                                             (~ array-listS) (~ object-longS)))))]
-                        (@eval.eval sampleI))
-                      (lang.with-current-module "")
-                      (macro.run (init-compiler []))
-                      (case> (#e.Success outputT)
-                             (:! Bool outputT)
-
-                             (#e.Error error)
-                             false)))
-            (test "jvm member invoke constructor"
-                  (|> (do macro.Monad
-                        [sampleI (expressionT.translate array-listS)]
-                        (@eval.eval sampleI))
-                      (lang.with-current-module "")
-                      (macro.run (init-compiler []))
-                      (case> (#e.Success outputT)
-                             (host.instance? ArrayList (:! Object outputT))
-
-                             (#e.Error error)
-                             false)))
-            ))))
diff --git a/new-luxc/test/test/luxc/lang/translation/jvm/reference.lux b/new-luxc/test/test/luxc/lang/translation/jvm/reference.lux
deleted file mode 100644
index 8de6c4fa5..000000000
--- a/new-luxc/test/test/luxc/lang/translation/jvm/reference.lux
+++ /dev/null
@@ -1,76 +0,0 @@
-(.module:
-  lux
-  (lux [io]
-       (control [monad #+ do]
-                pipe)
-       (data ["e" error]
-             [text])
-       ["r" math/random]
-       [macro]
-       (macro [code])
-       test)
-  (luxc [lang]
-        (lang ["_." module]
-              (host ["$" jvm]
-                    (jvm ["$i" inst]))
-              ["ls" synthesis]
-              (translation (jvm [".T" statement]
-                                [".T" eval]
-                                [".T" expression]
-                                [".T" case]
-                                [".T" runtime]))))
-  (test/luxc common))
-
-(def: ident-part
-  (r.Random Text)
-  (|> (r.text +5)
-      (r.filter (function [sample]
-                  (not (or (text.contains? "/" sample)
-                           (text.contains? "[" sample)
-                           (text.contains? "]" sample)))))))
-
-(context: "Definitions."
-  (<| (times +100)
-      (do @
-        [module-name ident-part
-         def-name ident-part
-         def-value r.int
-         #let [valueI (|>> ($i.long def-value) ($i.wrap #$.Long))]]
-        ($_ seq
-            (test "Can refer to definitions."
-                  (|> (do macro.Monad
-                        [_ (_module.with-module +0 module-name
-                             (statementT.translate-def def-name Int valueI (' {})))
-                         sampleI (expressionT.translate (code.symbol [module-name def-name]))]
-                        (evalT.eval sampleI))
-                      (lang.with-current-module "")
-                      (macro.run (init-compiler []))
-                      (case> (#e.Success valueT)
-                             (i/= def-value (:! Int valueT))
-
-                             (#e.Error error)
-                             false)))
-            ))))
-
-(context: "Variables."
-  (<| (times +100)
-      (do @
-        [module-name (|> (r.text +5) (r.filter (|>> (text.contains? "/") not)))
-         register (|> r.nat (:: @ map (n/% +100)))
-         value r.int]
-        ($_ seq
-            (test "Can refer to local variables/registers."
-                  (|> (do macro.Monad
-                        [sampleI (caseT.translate-let expressionT.translate
-                                                      register
-                                                      (code.int value)
-                                                      (` ((~ (code.int (nat-to-int register))))))]
-                        (evalT.eval sampleI))
-                      (lang.with-current-module "")
-                      (macro.run (init-compiler []))
-                      (case> (#e.Success outputT)
-                             (i/= value (:! Int outputT))
-
-                             (#e.Error error)
-                             false)))
-            ))))
diff --git a/new-luxc/test/test/luxc/lang/translation/jvm/structure.lux b/new-luxc/test/test/luxc/lang/translation/jvm/structure.lux
deleted file mode 100644
index 2fc377bd6..000000000
--- a/new-luxc/test/test/luxc/lang/translation/jvm/structure.lux
+++ /dev/null
@@ -1,113 +0,0 @@
-(.module:
-  lux
-  (lux [io]
-       (control [monad #+ do]
-                pipe)
-       (data ["e" error]
-             [maybe]
-             [bool "bool/" Eq]
-             [text "text/" Eq]
-             text/format
-             (coll [array]
-                   [list]))
-       ["r" math/random "r/" Monad]
-       [macro]
-       (macro [code])
-       [host]
-       test)
-  (luxc [lang]
-        (lang [".L" host]
-              ["ls" synthesis]
-              (translation (jvm [".T" expression]
-                                ["@." eval]
-                                ["@." runtime]
-                                ["@." common]))))
-  (test/luxc common))
-
-(host.import java/lang/Integer)
-
-(def: gen-primitive
-  (r.Random ls.Synthesis)
-  (r.either (r.either (r.either (r/wrap (' []))
-                                (r/map code.bool r.bool))
-                      (r.either (r/map code.nat r.nat)
-                                (r/map code.int r.int)))
-            (r.either (r.either (r/map code.deg r.deg)
-                                (r/map code.frac r.frac))
-                      (r/map code.text (r.text +5)))))
-
-(def: (corresponds? [prediction sample])
-  (-> [ls.Synthesis Top] Bool)
-  (case prediction
-    [_ (#.Tuple #.Nil)]
-    (is hostL.unit (:! Text sample))
-
-    (^template [  ]
-      [_ ( prediction')]
-      (case (host.try ( prediction' (:!  sample)))
-        (#e.Success result)
-        result
-
-        (#e.Error error)
-        false))
-    ([#.Bool Bool bool/=]
-     [#.Nat  Nat n/=]
-     [#.Int  Int i/=]
-     [#.Deg  Deg d/=]
-     [#.Frac Frac f/=]
-     [#.Text Text text/=])
-
-    _
-    false
-    ))
-
-(context: "Tuples."
-  (<| (times +100)
-      (do @
-        [size (|> r.nat (:: @ map (|>> (n/% +10) (n/max +2))))
-         members (r.list size gen-primitive)]
-        (test "Can translate tuple."
-              (|> (do macro.Monad
-                    [sampleI (expressionT.translate (code.tuple members))]
-                    (@eval.eval sampleI))
-                  (lang.with-current-module "")
-                  (macro.run (init-compiler []))
-                  (case> (#e.Success valueT)
-                         (let [valueT (:! (Array Top) valueT)]
-                           (and (n/= size (array.size valueT))
-                                (list.every? corresponds? (list.zip2 members (array.to-list valueT)))))
-
-                         _
-                         false))))))
-
-(context: "Variants."
-  (<| (times +100)
-      (do @
-        [num-tags (|> r.nat (:: @ map (|>> (n/% +10) (n/max +2))))
-         tag (|> r.nat (:: @ map (n/% num-tags)))
-         #let [last? (n/= (n/dec num-tags) tag)]
-         member gen-primitive]
-        (test "Can translate variant."
-              (|> (do macro.Monad
-                    [runtime-bytecode @runtime.translate
-                     sampleI (expressionT.translate (` ((~ (code.nat tag)) (~ (code.bool last?)) (~ member))))]
-                    (@eval.eval sampleI))
-                  (lang.with-current-module "")
-                  (macro.run (init-compiler []))
-                  (case> (#e.Success valueT)
-                         (let [valueT (:! (Array Top) valueT)]
-                           (and (n/= +3 (array.size valueT))
-                                (let [_tag (:! Integer (maybe.assume (array.read +0 valueT)))
-                                      _last? (array.read +1 valueT)
-                                      _value (:! Top (maybe.assume (array.read +2 valueT)))]
-                                  (and (n/= tag (|> _tag host.int-to-long int-to-nat))
-                                       (case _last?
-                                         (#.Some _last?')
-                                         (and last? (text/= "" (:! Text _last?')))
-
-                                         #.None
-                                         (not last?))
-                                       (corresponds? [member _value])))))
-
-                         _
-                         false))))))
diff --git a/new-luxc/test/test/luxc/lang/translation/primitive.lux b/new-luxc/test/test/luxc/lang/translation/primitive.lux
new file mode 100644
index 000000000..1f5552bce
--- /dev/null
+++ b/new-luxc/test/test/luxc/lang/translation/primitive.lux
@@ -0,0 +1,80 @@
+(.module:
+  lux
+  (lux [io #+ IO]
+       (control [monad #+ do]
+                pipe)
+       (data text/format
+             ["e" error]
+             [bool "bool/" Eq]
+             [text "text/" Eq])
+       ["r" math/random]
+       [macro]
+       (macro [code])
+       test)
+  (luxc [lang]
+        (lang [".L" host]
+              ["ls" synthesis]
+              (translation (jvm [".T_jvm" expression]
+                                [".T_jvm" runtime]
+                                [".T_jvm" eval])
+                           (js [".T_js" expression]
+                               [".T_js" runtime]
+                               [".T_js" eval]))))
+  (test/luxc common))
+
+(def: (spec translate-expression eval translate-runtime init)
+  (All [a]
+    (-> (-> ls.Synthesis (Meta a))
+        (-> a (Meta Top))
+        (Meta Top)
+        (IO Compiler)
+        Test))
+  (do r.Monad
+    [%bool% r.bool
+     %nat% r.nat
+     %int% r.int
+     %deg% r.deg
+     %frac% r.frac
+     %text% (r.text +5)]
+    (`` ($_ seq
+            (test "Can translate unit."
+                  (|> (do macro.Monad
+                        [_ translate-runtime
+                         sampleO (translate-expression (' []))]
+                        (eval sampleO))
+                      (lang.with-current-module "")
+                      (macro.run (io.run init))
+                      (case> (#e.Success valueT)
+                             (is hostL.unit (:! Text valueT))
+
+                             _
+                             false)))
+            (~~ (do-template [    ]
+                  [(test (format "Can translate "  ".")
+                         (|> (do macro.Monad
+                               [_ translate-runtime
+                                sampleO (translate-expression ( ))]
+                               (eval sampleO))
+                             (lang.with-current-module "")
+                             (macro.run (io.run init))
+                             (case> (#e.Success valueT)
+                                    (  (:!  valueT))
+
+                                    (#e.Error error)
+                                    false)))]
+
+                  ["bool" Bool code.bool %bool% bool/=]
+                  ["nat"  Nat  code.nat  %nat%  n/=]
+                  ["int"  Int  code.int  %int%  i/=]
+                  ["deg"  Deg  code.deg  %deg%  d/=]
+                  ["frac" Frac code.frac %frac% f/=]
+                  ["text" Text code.text %text% text/=]))
+            ))))
+
+(context: "[JVM] Primitives."
+  (<| (times +100)
+      (spec expressionT_jvm.translate evalT_jvm.eval runtimeT_jvm.translate init-jvm)))
+
+(context: "[JS] Primitives."
+  (<| (times +100)
+      (spec expressionT_js.translate evalT_js.eval runtimeT_js.translate init-js)))
diff --git a/new-luxc/test/test/luxc/lang/translation/reference.lux b/new-luxc/test/test/luxc/lang/translation/reference.lux
new file mode 100644
index 000000000..c831fb33a
--- /dev/null
+++ b/new-luxc/test/test/luxc/lang/translation/reference.lux
@@ -0,0 +1,113 @@
+(.module:
+  lux
+  (lux [io #+ IO]
+       (control [monad #+ do]
+                pipe)
+       (data ["e" error]
+             [text])
+       ["r" math/random]
+       [macro]
+       (macro [code])
+       test)
+  (luxc [lang]
+        (lang ["_." module]
+              ["ls" synthesis]
+              (translation (jvm [".T_jvm" statement]
+                                [".T_jvm" eval]
+                                [".T_jvm" expression]
+                                [".T_jvm" case]
+                                [".T_jvm" runtime])
+                           (js [".T_js" statement]
+                               [".T_js" eval]
+                               [".T_js" expression]
+                               [".T_js" case]
+                               [".T_js" runtime]))))
+  (test/luxc common))
+
+(def: upper-alpha-ascii
+  (r.Random Nat)
+  (|> r.nat (:: r.Functor map (|>> (n/% +91) (n/max +65)))))
+
+(def: ident-part
+  (r.Random Text)
+  (|> (r.text' upper-alpha-ascii +5)
+      (r.filter (function [sample]
+                  (not (or (text.contains? "/" sample)
+                           (text.contains? "[" sample)
+                           (text.contains? "]" sample)))))))
+
+(def: (definitions-spec translate-expression eval translate-runtime init
+                        translate-def)
+  (All [a]
+    (-> (-> ls.Synthesis (Meta a)) (-> a (Meta Top)) (Meta Top) (IO Compiler)
+        (-> Text Type a Code (Meta Unit))
+        Test))
+  (do r.Monad
+    [module-name ident-part
+     def-name ident-part
+     def-value r.int]
+    ($_ seq
+        (test "Can refer to definitions."
+              (|> (do macro.Monad
+                    [_ translate-runtime
+                     valueO (translate-expression (code.int def-value))
+                     _ (_module.with-module +0 module-name
+                         (translate-def def-name Int valueO (' {})))
+                     sampleO (translate-expression (code.symbol [module-name def-name]))]
+                    (eval sampleO))
+                  (lang.with-current-module "")
+                  (macro.run (io.run init))
+                  (case> (#e.Success valueT)
+                         (i/= def-value (:! Int valueT))
+
+                         (#e.Error error)
+                         false)))
+        )))
+
+(def: (variables-spec translate-expression eval translate-runtime init
+                      translate-let)
+  (All [a]
+    (-> (-> ls.Synthesis (Meta a)) (-> a (Meta Top)) (Meta Top) (IO Compiler)
+        (-> (-> ls.Synthesis (Meta a)) Nat ls.Synthesis ls.Synthesis (Meta a))
+        Test))
+  (do r.Monad
+    [module-name (|> (r.text +5) (r.filter (|>> (text.contains? "/") not)))
+     register (|> r.nat (:: @ map (n/% +100)))
+     value r.int]
+    ($_ seq
+        (test "Can refer to local variables/registers."
+              (|> (do macro.Monad
+                    [_ translate-runtime
+                     sampleO (translate-let translate-expression
+                                            register
+                                            (code.int value)
+                                            (` ((~ (code.int (nat-to-int register))))))]
+                    (eval sampleO))
+                  (lang.with-current-module "")
+                  (macro.run (io.run init))
+                  (case> (#e.Success outputT)
+                         (i/= value (:! Int outputT))
+
+                         (#e.Error error)
+                         false)))
+        )))
+
+(context: "[JVM] Definitions."
+  (<| (times +100)
+      (definitions-spec expressionT_jvm.translate evalT_jvm.eval runtimeT_jvm.translate init-jvm
+                        statementT_jvm.translate-def)))
+
+(context: "[JVM] Variables."
+  (<| (times +100)
+      (variables-spec expressionT_jvm.translate evalT_jvm.eval runtimeT_jvm.translate init-jvm
+                      caseT_jvm.translate-let)))
+
+(context: "[JS] Definitions."
+  (<| (times +100)
+      (definitions-spec expressionT_js.translate evalT_js.eval runtimeT_js.translate init-js
+                        statementT_js.translate-def)))
+
+(context: "[JS] Variables."
+  (<| (times +100)
+      (variables-spec expressionT_js.translate evalT_js.eval runtimeT_js.translate init-js
+                      caseT_js.translate-let)))
diff --git a/new-luxc/test/test/luxc/lang/translation/structure.lux b/new-luxc/test/test/luxc/lang/translation/structure.lux
new file mode 100644
index 000000000..7443c3317
--- /dev/null
+++ b/new-luxc/test/test/luxc/lang/translation/structure.lux
@@ -0,0 +1,143 @@
+(.module:
+  lux
+  (lux [io #+ IO]
+       (control [monad #+ do]
+                pipe)
+       (data ["e" error]
+             [maybe]
+             [bool "bool/" Eq]
+             [text "text/" Eq]
+             text/format
+             (coll [array]
+                   [list]))
+       ["r" math/random "r/" Monad]
+       [macro]
+       (macro [code])
+       [host]
+       test)
+  (luxc [lang]
+        (lang [".L" host]
+              ["ls" synthesis]
+              (translation (jvm [".T_jvm" expression]
+                                [".T_jvm" runtime]
+                                [".T_jvm" eval])
+                           (js [".T_js" expression]
+                               [".T_js" runtime]
+                               [".T_js" eval]))))
+  (test/luxc common))
+
+(host.import java/lang/Integer)
+(host.import java/lang/Long)
+
+(def: gen-primitive
+  (r.Random ls.Synthesis)
+  (r.either (r.either (r.either (r/wrap (' []))
+                                (r/map code.bool r.bool))
+                      (r.either (r/map code.nat r.nat)
+                                (r/map code.int r.int)))
+            (r.either (r.either (r/map code.deg r.deg)
+                                (r/map code.frac r.frac))
+                      (r/map code.text (r.text +5)))))
+
+(def: (corresponds? [prediction sample])
+  (-> [ls.Synthesis Top] Bool)
+  (case prediction
+    [_ (#.Tuple #.Nil)]
+    (text/= hostL.unit (:! Text sample))
+
+    (^template [  ]
+      [_ ( prediction')]
+      (case (host.try ( prediction' (:!  sample)))
+        (#e.Success result)
+        result
+
+        (#e.Error error)
+        false))
+    ([#.Bool Bool bool/=]
+     [#.Nat  Nat n/=]
+     [#.Int  Int i/=]
+     [#.Deg  Deg d/=]
+     [#.Frac Frac f/=]
+     [#.Text Text text/=])
+
+    _
+    false
+    ))
+
+(def: (tuples-spec translate-expression eval translate-runtime init)
+  (All [a]
+    (-> (-> ls.Synthesis (Meta a))
+        (-> a (Meta Top))
+        (Meta Top)
+        (IO Compiler)
+        Test))
+  (do r.Monad
+    [size (|> r.nat (:: @ map (|>> (n/% +10) (n/max +2))))
+     members (r.list size gen-primitive)]
+    (test "Can translate tuple."
+          (|> (do macro.Monad
+                [_ translate-runtime
+                 sampleO (translate-expression (code.tuple members))]
+                (eval sampleO))
+              (lang.with-current-module "")
+              (macro.run (io.run init))
+              (case> (#e.Success valueT)
+                     (let [valueT (:! (Array Top) valueT)]
+                       (and (n/= size (array.size valueT))
+                            (list.every? corresponds? (list.zip2 members (array.to-list valueT)))))
+
+                     (#e.Error error)
+                     false)))))
+
+(def: (variants-spec translate-expression eval translate-runtime init)
+  (All [a]
+    (-> (-> ls.Synthesis (Meta a))
+        (-> a (Meta Top))
+        (Meta Top)
+        (IO Compiler)
+        Test))
+  (do r.Monad
+    [num-tags (|> r.nat (:: @ map (|>> (n/% +10) (n/max +2))))
+     tag (|> r.nat (:: @ map (n/% num-tags)))
+     #let [last? (n/= (n/dec num-tags) tag)]
+     member gen-primitive]
+    (test "Can translate variant."
+          (|> (do macro.Monad
+                [_ translate-runtime
+                 sampleO (translate-expression (` ((~ (code.nat tag)) (~ (code.bool last?)) (~ member))))]
+                (eval sampleO))
+              (lang.with-current-module "")
+              (macro.run (io.run init))
+              (case> (#e.Success valueT)
+                     (let [valueT (:! (Array Top) valueT)]
+                       (and (n/= +3 (array.size valueT))
+                            (let [_tag (:! Integer (maybe.assume (array.read +0 valueT)))
+                                  _last? (array.read +1 valueT)
+                                  _value (:! Top (maybe.assume (array.read +2 valueT)))]
+                              (and (n/= tag (|> _tag host.int-to-long (:! Nat)))
+                                   (case _last?
+                                     (#.Some _last?')
+                                     (and last? (text/= "" (:! Text _last?')))
+
+                                     #.None
+                                     (not last?))
+                                   (corresponds? [member _value])))))
+
+                     (#e.Error error)
+                     false)))))
+
+(context: "[JVM] Tuples."
+  (<| (times +100)
+      (tuples-spec expressionT_jvm.translate evalT_jvm.eval runtimeT_jvm.translate init-jvm)))
+
+(context: "[JVM] Variants."
+  (<| (times +100)
+      (variants-spec expressionT_jvm.translate evalT_jvm.eval runtimeT_jvm.translate init-jvm)))
+
+(context: "[JS] Tuples."
+  (<| (times +100)
+      (tuples-spec expressionT_js.translate evalT_js.eval runtimeT_js.translate init-js)))
+
+(context: "[JS] Variants."
+  (<| (times +100)
+      (variants-spec expressionT_js.translate evalT_js.eval runtimeT_js.translate init-js)))
diff --git a/new-luxc/test/tests.lux b/new-luxc/test/tests.lux
index e6d6490e6..d33bcebd8 100644
--- a/new-luxc/test/tests.lux
+++ b/new-luxc/test/tests.lux
@@ -19,22 +19,13 @@
                                ["_.S" function]
                                ["_.S" procedure]
                                ["_.S" loop])
-                    (translation (jvm ["_.T_jvm" primitive]
-                                      ["_.T_jvm" structure]
-                                      ["_.T_jvm" case]
-                                      ["_.T_jvm" function]
-                                      ["_.T_jvm" reference]
-                                      (procedure ["_.T_jvm" common]
-                                                 ["_.T_jvm" host]))
-                                 (js ["_.T_js" primitive]
-                                     ["_.T_js" structure]
-                                     ["_.T_js" case]
-                                     ["_.T_js" function]
-                                     ["_.T_js" reference]
-                                     (procedure ["_.T_js" common]
-                                                ## ["_.T_js" host]
-                                                )
-                                     )))
+                    (translation ["_.T" primitive]
+                                 ["_.T" reference]
+                                 ["_.T" structure]
+                                 ["_.T" case]
+                                 ["_.T" function]
+                                 ["_.T" common]
+                                 ["_.T" jvm]))
               )))
 
 (program: args
-- 
cgit v1.2.3