aboutsummaryrefslogtreecommitdiff
path: root/stdlib/test
diff options
context:
space:
mode:
authorEduardo Julian2018-08-15 21:29:58 -0400
committerEduardo Julian2018-08-15 21:29:58 -0400
commit70152bea7b43320cf5f7f0c4d136664245f25039 (patch)
tree17604e035d6fb0dfe8058f7e0c4e98c8c185dd35 /stdlib/test
parent196c1843d1a4a32ab92b9ba5c549933a5ce30c17 (diff)
Fixes for function synthesis.
Diffstat (limited to 'stdlib/test')
-rw-r--r--stdlib/test/test/lux/compiler/default/phase/synthesis/case.lux6
-rw-r--r--stdlib/test/test/lux/compiler/default/phase/synthesis/function.lux17
-rw-r--r--stdlib/test/test/lux/compiler/default/phase/synthesis/primitive.lux2
-rw-r--r--stdlib/test/test/lux/compiler/default/phase/synthesis/structure.lux4
4 files changed, 14 insertions, 15 deletions
diff --git a/stdlib/test/test/lux/compiler/default/phase/synthesis/case.lux b/stdlib/test/test/lux/compiler/default/phase/synthesis/case.lux
index f3c3b9d2e..2084ee46b 100644
--- a/stdlib/test/test/lux/compiler/default/phase/synthesis/case.lux
+++ b/stdlib/test/test/lux/compiler/default/phase/synthesis/case.lux
@@ -31,7 +31,7 @@
(list)]])]]
(test "Dummy variables created to mask expressions get eliminated during synthesis."
(|> maskA
- expression.synthesize
+ expression.phase
(phase.run [bundle.empty //.init])
(error/map (//primitive.corresponds? maskedA))
(error.default #0))))))
@@ -49,7 +49,7 @@
(list)]])]]
(test "Can detect and reify simple 'let' expressions."
(|> letA
- expression.synthesize
+ expression.phase
(phase.run [bundle.empty //.init])
(case> (^ (#error.Success (//.branch/let [inputS registerS outputS])))
(and (n/= registerA registerS)
@@ -77,7 +77,7 @@
(analysis.control/case [inputA [elseB (list thenB)]]))]]
(test "Can detect and reify simple 'if' expressions."
(|> ifA
- expression.synthesize
+ expression.phase
(phase.run [bundle.empty //.init])
(case> (^ (#error.Success (//.branch/if [inputS thenS elseS])))
(and (//primitive.corresponds? inputA inputS)
diff --git a/stdlib/test/test/lux/compiler/default/phase/synthesis/function.lux b/stdlib/test/test/lux/compiler/default/phase/synthesis/function.lux
index fae0e0fdf..133048936 100644
--- a/stdlib/test/test/lux/compiler/default/phase/synthesis/function.lux
+++ b/stdlib/test/test/lux/compiler/default/phase/synthesis/function.lux
@@ -105,9 +105,8 @@
(#analysis.Reference (reference.local chosen))
(|> chosen (n/+ (dec arity)) #reference.Local)])))))
-(context: "Function definition."
- (<| (seed 13007429814532219492)
- ## (times 100)
+(context: "Abstraction."
+ (<| (times 100)
(do @
[[arity//constant function//constant prediction//constant] constant-function
[arity//environment function//environment prediction//environment] function-with-environment
@@ -115,7 +114,7 @@
($_ seq
(test "Nested functions will get folded together."
(|> function//constant
- expression.synthesize
+ expression.phase
(phase.run [bundle.empty //.init])
(case> (^ (#error.Success (//.function/abstraction [environment arity output])))
(and (n/= arity//constant arity)
@@ -125,7 +124,7 @@
(n/= 0 arity//constant))))
(test "Folded functions provide direct access to environment variables."
(|> function//environment
- expression.synthesize
+ expression.phase
(phase.run [bundle.empty //.init])
(case> (^ (#error.Success (//.function/abstraction [environment arity (#//.Reference (reference.variable output))])))
(and (n/= arity//environment arity)
@@ -135,7 +134,7 @@
#0)))
(test "Folded functions properly offset local variables."
(|> function//local
- expression.synthesize
+ expression.phase
(phase.run [bundle.empty //.init])
(case> (^ (#error.Success (//.function/abstraction [environment arity (#//.Reference (reference.variable output))])))
(and (n/= arity//local arity)
@@ -145,7 +144,7 @@
#0)))
))))
-(context: "Function application."
+(context: "Application."
(<| (times 100)
(do @
[arity (|> r.nat (:: @ map (|>> (n/% 10) (n/max 1))))
@@ -154,7 +153,7 @@
($_ seq
(test "Can synthesize function application."
(|> (analysis.apply [funcA argsA])
- expression.synthesize
+ expression.phase
(phase.run [bundle.empty //.init])
(case> (^ (#error.Success (//.function/apply [funcS argsS])))
(and (//primitive.corresponds? funcA funcS)
@@ -165,7 +164,7 @@
#0)))
(test "Function application on no arguments just synthesizes to the function itself."
(|> (analysis.apply [funcA (list)])
- expression.synthesize
+ expression.phase
(phase.run [bundle.empty //.init])
(case> (#error.Success funcS)
(//primitive.corresponds? funcA funcS)
diff --git a/stdlib/test/test/lux/compiler/default/phase/synthesis/primitive.lux b/stdlib/test/test/lux/compiler/default/phase/synthesis/primitive.lux
index fbe190a93..0a55fbcf6 100644
--- a/stdlib/test/test/lux/compiler/default/phase/synthesis/primitive.lux
+++ b/stdlib/test/test/lux/compiler/default/phase/synthesis/primitive.lux
@@ -80,7 +80,7 @@
(~~ (do-template [<desc> <analysis> <synthesis> <sample>]
[(test (format "Can synthesize " <desc> ".")
(|> (#analysis.Primitive (<analysis> <sample>))
- expression.synthesize
+ expression.phase
(phase.run [bundle.empty //.init])
(case> (#error.Success (#//.Primitive (<synthesis> value)))
(is? <sample> value)
diff --git a/stdlib/test/test/lux/compiler/default/phase/synthesis/structure.lux b/stdlib/test/test/lux/compiler/default/phase/synthesis/structure.lux
index 90fd155b0..a78aa1a09 100644
--- a/stdlib/test/test/lux/compiler/default/phase/synthesis/structure.lux
+++ b/stdlib/test/test/lux/compiler/default/phase/synthesis/structure.lux
@@ -31,7 +31,7 @@
($_ seq
(test "Can synthesize variants."
(|> (analysis.sum-analysis size tagA memberA)
- expression.synthesize
+ expression.phase
(phase.run [bundle.empty //.init])
(case> (#error.Success (#//.Structure (#//.Variant [leftsS right?S valueS])))
(let [tagS (if right?S (inc leftsS) leftsS)]
@@ -51,7 +51,7 @@
($_ seq
(test "Can synthesize tuple."
(|> (analysis.product-analysis membersA)
- expression.synthesize
+ expression.phase
(phase.run [bundle.empty //.init])
(case> (#error.Success (#//.Structure (#//.Tuple membersS)))
(and (n/= size (list.size membersS))