From 16bfbba4bd206d9199a358ee50c4723255f4437e Mon Sep 17 00:00:00 2001 From: Eduardo Julian Date: Thu, 14 Jun 2018 21:08:38 -0400 Subject: - Refactored references. --- stdlib/test/test/lux/lang/analysis/function.lux | 3 ++- stdlib/test/test/lux/lang/analysis/reference.lux | 7 ++++--- stdlib/test/test/lux/lang/synthesis/case.lux | 5 +++-- stdlib/test/test/lux/lang/synthesis/function.lux | 19 ++++++++++--------- 4 files changed, 19 insertions(+), 15 deletions(-) (limited to 'stdlib/test') diff --git a/stdlib/test/test/lux/lang/analysis/function.lux b/stdlib/test/test/lux/lang/analysis/function.lux index 97ab808a0..a99504045 100644 --- a/stdlib/test/test/lux/lang/analysis/function.lux +++ b/stdlib/test/test/lux/lang/analysis/function.lux @@ -15,6 +15,7 @@ [lang] (lang [type "type/" Eq] [".L" init] + [".L" reference] [".L" analysis #+ Analysis] (analysis [".A" type] [".A" expression] @@ -91,7 +92,7 @@ partial-polyT2 (<| (type.univ-q +1) (type.function (#.Cons varT partial-poly-inputsT)) varT) - dummy-function (#analysisL.Function (list) (#analysisL.Variable (#analysisL.Local +1)))]] + dummy-function (#analysisL.Function (list) (#analysisL.Reference (referenceL.local +1)))]] ($_ seq (test "Can analyse monomorphic type application." (|> (/.apply ..analyse funcT dummy-function inputsC) diff --git a/stdlib/test/test/lux/lang/analysis/reference.lux b/stdlib/test/test/lux/lang/analysis/reference.lux index e67756d55..6551e3cba 100644 --- a/stdlib/test/test/lux/lang/analysis/reference.lux +++ b/stdlib/test/test/lux/lang/analysis/reference.lux @@ -13,6 +13,7 @@ [".L" scope] [".L" module] [".L" init] + [".L" reference] [".L" analysis] (analysis [".A" type] [".A" expression])) @@ -34,9 +35,9 @@ (|> (scopeL.with-scope scope-name (scopeL.with-local [var-name expectedT] (typeA.with-inference - (..analyse (code.symbol ["" var-name]))))) + (..analyse (code.local-symbol var-name))))) (macro.run (initL.compiler [])) - (case> (^ (#e.Success [inferredT (analysisL.variable/local var)])) + (case> (^ (#e.Success [inferredT (#analysisL.Reference (referenceL.local var))])) (and (type/= expectedT inferredT) (n/= +0 var)) @@ -49,7 +50,7 @@ (..analyse (code.symbol def-name)))) (moduleL.with-module +0 module-name) (macro.run (initL.compiler [])) - (case> (^ (#e.Success [_ inferredT (analysisL.reference/constant constant-name)])) + (case> (^ (#e.Success [_ inferredT (#analysisL.Reference (referenceL.constant constant-name))])) (and (type/= expectedT inferredT) (ident/= def-name constant-name)) diff --git a/stdlib/test/test/lux/lang/synthesis/case.lux b/stdlib/test/test/lux/lang/synthesis/case.lux index 23ed6726c..f2541ee0e 100644 --- a/stdlib/test/test/lux/lang/synthesis/case.lux +++ b/stdlib/test/test/lux/lang/synthesis/case.lux @@ -3,7 +3,8 @@ (lux (control [monad #+ do] pipe) (data [error "error/" Functor]) - (lang [".L" analysis #+ Branch Analysis] + (lang ["///." reference] + [".L" analysis #+ Branch Analysis] ["//" synthesis #+ Synthesis] (synthesis [".S" expression]) [".L" extension]) @@ -19,7 +20,7 @@ #let [maskA (analysisL.control/case [maskedA [[(#analysisL.Bind temp) - (analysisL.variable/local temp)] + (#analysisL.Reference (///reference.local temp))] (list)]])]] (test "Dummy variables created to mask expressions get eliminated during synthesis." (|> maskA diff --git a/stdlib/test/test/lux/lang/synthesis/function.lux b/stdlib/test/test/lux/lang/synthesis/function.lux index 93ca5d40d..c0cfc5587 100644 --- a/stdlib/test/test/lux/lang/synthesis/function.lux +++ b/stdlib/test/test/lux/lang/synthesis/function.lux @@ -11,7 +11,8 @@ (coll [list "list/" Functor Fold] (dictionary ["dict" unordered #+ Dict]) (set ["set" unordered]))) - (lang [".L" analysis #+ Variable Analysis "variable/" Equality] + (lang ["///." reference #+ Variable "variable/" Equality] + [".L" analysis #+ Analysis] ["//" synthesis #+ Arity Synthesis] (synthesis [".S" expression]) [".L" extension]) @@ -44,8 +45,8 @@ (do r.Monad [num-locals (|> r.nat (:: @ map (|>> (n/% +100) (n/max +10)))) #let [indices (list.n/range +0 (dec num-locals)) - local-env (list/map (|>> #analysisL.Local) indices) - foreign-env (list/map (|>> #analysisL.Foreign) indices)] + local-env (list/map (|>> #///reference.Local) indices) + foreign-env (list/map (|>> #///reference.Foreign) indices)] [arity bodyA predictionA] (: (r.Random [Arity Analysis Variable]) (loop [arity +1 current-env foreign-env] @@ -66,14 +67,14 @@ (list/map (function (_ pick) (maybe.assume (list.nth pick current-env))) picks)) - #let [picked-env (list/map (|>> #analysisL.Foreign) picks)]] + #let [picked-env (list/map (|>> #///reference.Foreign) picks)]] (wrap [arity (#analysisL.Function picked-env bodyA) predictionA])) (do @ [chosen (pick (list.size current-env))] (wrap [arity - (analysisL.variable/foreign chosen) + (#analysisL.Reference (///reference.foreign chosen)) (maybe.assume (dict.get chosen resolver))])))))))] (wrap [arity (#analysisL.Function local-env bodyA) @@ -93,8 +94,8 @@ (do r.Monad [chosen (|> r.nat (:: @ map (|>> (n/% +100) (n/max +2))))] (wrap [arity - (analysisL.variable/local chosen) - (|> chosen (n/+ (dec arity)) #analysisL.Local)]))))) + (#analysisL.Reference (///reference.local chosen)) + (|> chosen (n/+ (dec arity)) #///reference.Local)]))))) (context: "Function definition." (<| (times +100) @@ -115,7 +116,7 @@ (test "Folded functions provide direct access to environment variables." (|> function//environment (//.run (expressionS.synthesizer extensionL.empty)) - (case> (^ (#error.Success (//.function/abstraction [environment arity (analysisL.reference/variable output)]))) + (case> (^ (#error.Success (//.function/abstraction [environment arity (#//.Reference (///reference.variable output))]))) (and (n/= arity//environment arity) (variable/= prediction//environment output)) @@ -124,7 +125,7 @@ (test "Folded functions properly offset local variables." (|> function//local (//.run (expressionS.synthesizer extensionL.empty)) - (case> (^ (#error.Success (//.function/abstraction [environment arity (analysisL.reference/variable output)]))) + (case> (^ (#error.Success (//.function/abstraction [environment arity (#//.Reference (///reference.variable output))]))) (and (n/= arity//local arity) (variable/= prediction//local output)) -- cgit v1.2.3