aboutsummaryrefslogtreecommitdiff
path: root/stdlib/source/test/lux/tool/compiler
diff options
context:
space:
mode:
authorEduardo Julian2022-01-25 21:26:50 -0400
committerEduardo Julian2022-01-25 21:26:50 -0400
commit7661faaa22a253bb4703992b638038d96ead0ade (patch)
tree748bca72a2aad0d33a4268ad0d0d39fa4e24b384 /stdlib/source/test/lux/tool/compiler
parent9a08039adfe40f76b9d5a5351005671c15b557bf (diff)
Bug fixes for eval in general and in Lux/Ruby.
Diffstat (limited to 'stdlib/source/test/lux/tool/compiler')
-rw-r--r--stdlib/source/test/lux/tool/compiler/language/lux/analysis.lux2
-rw-r--r--stdlib/source/test/lux/tool/compiler/language/lux/analysis/type.lux119
-rw-r--r--stdlib/source/test/lux/tool/compiler/language/lux/phase/analysis/simple.lux25
3 files changed, 133 insertions, 13 deletions
diff --git a/stdlib/source/test/lux/tool/compiler/language/lux/analysis.lux b/stdlib/source/test/lux/tool/compiler/language/lux/analysis.lux
index c1bc9d62e..f19111e2d 100644
--- a/stdlib/source/test/lux/tool/compiler/language/lux/analysis.lux
+++ b/stdlib/source/test/lux/tool/compiler/language/lux/analysis.lux
@@ -28,6 +28,7 @@
["[1][0]" complex]
["[1][0]" pattern]
["[1][0]" macro]
+ ["[1][0]" type]
[////
["[1][0]" reference
["[2][0]" variable]]
@@ -438,4 +439,5 @@
/complex.test
/pattern.test
/macro.test
+ /type.test
))))
diff --git a/stdlib/source/test/lux/tool/compiler/language/lux/analysis/type.lux b/stdlib/source/test/lux/tool/compiler/language/lux/analysis/type.lux
new file mode 100644
index 000000000..66876be3c
--- /dev/null
+++ b/stdlib/source/test/lux/tool/compiler/language/lux/analysis/type.lux
@@ -0,0 +1,119 @@
+(.using
+ [library
+ [lux "*"
+ ["_" test {"+" Test}]
+ ["[0]" meta]
+ [abstract
+ [monad {"+" do}]
+ [\\specification
+ ["$[0]" equivalence]]]
+ [control
+ [pipe {"+" case>}]
+ ["[0]" maybe ("[1]#[0]" functor)]
+ ["[0]" try ("[1]#[0]" functor)]
+ ["[0]" exception]]
+ [data
+ ["[0]" product]
+ ["[0]" bit ("[1]#[0]" equivalence)]
+ ["[0]" text ("[1]#[0]" equivalence)]
+ [collection
+ ["[0]" list ("[1]#[0]" monad)]]]
+ [macro
+ ["[0]" code ("[1]#[0]" equivalence)]]
+ [math
+ ["[0]" random {"+" Random} ("[1]#[0]" monad)]
+ [number
+ ["n" nat]]]
+ ["[0]" type ("[1]#[0]" equivalence)
+ ["[0]" check]]]]
+ ["$" /////// "_"
+ [macro
+ ["[1][0]" code]]
+ [meta
+ ["[1][0]" symbol]]]
+ [\\library
+ ["[0]" /
+ ["/[1]" //
+ [//
+ [phase
+ ["[2][0]" extension]]
+ [///
+ ["[2][0]" phase]]]]]])
+
+(def: random_state
+ (Random Lux)
+ (do random.monad
+ [version random.nat
+ host (random.ascii/lower 1)]
+ (in (//.state (//.info version host)))))
+
+(def: primitive
+ (Random Type)
+ (do random.monad
+ [name (random.ascii/lower 1)]
+ (in {.#Primitive name (list)})))
+
+(def: .public test
+ Test
+ (<| (_.covering /._)
+ (do [! random.monad]
+ [lux ..random_state
+ .let [state [/extension.#bundle /extension.empty
+ /extension.#state lux]]
+ expected ..primitive
+ dummy (random.only (|>> (type#= expected) not)
+ ..primitive)]
+ ($_ _.and
+ (_.cover [/.expecting /.inference]
+ (and (|> (/.inference expected)
+ (/.expecting expected)
+ (/phase.result state)
+ (case> {try.#Success _} true
+ {try.#Failure _} false))
+ (|> (/.inference dummy)
+ (/.expecting expected)
+ (/phase.result state)
+ (case> {try.#Success _} false
+ {try.#Failure _} true))
+ (|> (/.inference expected)
+ (/.expecting dummy)
+ (/phase.result state)
+ (case> {try.#Success _} false
+ {try.#Failure _} true))))
+ (_.cover [/.inferring]
+ (|> (/.inference expected)
+ /.inferring
+ (/phase.result state)
+ (try#each (|>> product.left (type#= expected)))
+ (try.else false)))
+ (_.cover [/.check]
+ (|> (do /phase.monad
+ [exT (/.check (do check.monad
+ [[id type] check.existential]
+ (in type)))]
+ (|> (/.inference exT)
+ (/.expecting exT)))
+ (/phase.result state)
+ (case> {try.#Success _} true
+ {try.#Failure _} false)))
+ (_.cover [/.fresh]
+ (and (|> (do /phase.monad
+ [varT (/.check (do check.monad
+ [[id type] check.var]
+ (in type)))]
+ (|> (/.inference expected)
+ (/.expecting varT)))
+ (/phase.result state)
+ (case> {try.#Success _} true
+ {try.#Failure _} false))
+ (|> (do /phase.monad
+ [varT (/.check (do check.monad
+ [[id type] check.var]
+ (in type)))]
+ (|> (/.inference expected)
+ (/.expecting varT)
+ /.fresh))
+ (/phase.result state)
+ (case> {try.#Success _} false
+ {try.#Failure _} true))))
+ ))))
diff --git a/stdlib/source/test/lux/tool/compiler/language/lux/phase/analysis/simple.lux b/stdlib/source/test/lux/tool/compiler/language/lux/phase/analysis/simple.lux
index 015c9d362..a93b4c3e1 100644
--- a/stdlib/source/test/lux/tool/compiler/language/lux/phase/analysis/simple.lux
+++ b/stdlib/source/test/lux/tool/compiler/language/lux/phase/analysis/simple.lux
@@ -12,19 +12,18 @@
["[0]" random]]]]
[\\library
["[0]" /
- [//
- ["[1][0]" type]
+ [///
+ ["[1][0]" extension]
[//
- ["[1][0]" extension]
- [//
- ["[1][0]" analysis {"+" Analysis Operation}]
- [///
- ["[1][0]" phase]]]]]]])
+ ["[1][0]" analysis {"+" Analysis Operation}
+ ["[2][0]" type]]
+ [///
+ ["[1][0]" phase]]]]]])
(def: (analysis state type it ?)
(-> Lux Type (Operation Analysis) (-> Analysis Bit) Bit)
- (and (|> (/type.with_type type
- it)
+ (and (|> it
+ (/type.expecting type)
(/phase.result [/extension.#bundle /extension.empty
/extension.#state state])
(case> (^ {try.#Success analysis})
@@ -32,8 +31,8 @@
_
false))
- (|> (/type.with_type .Nothing
- it)
+ (|> it
+ (/type.expecting .Nothing)
(/phase.result [/extension.#bundle /extension.empty
/extension.#state state])
(case> (^ {try.#Failure error})
@@ -41,8 +40,8 @@
_
false))
- (|> (/type.with_inference
- it)
+ (|> it
+ /type.inferring
(/phase.result [/extension.#bundle /extension.empty
/extension.#state state])
(case> (^ {try.#Success [inferred analysis]})