aboutsummaryrefslogtreecommitdiff
path: root/stdlib/source/test
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--stdlib/source/test/lux.lux75
-rw-r--r--stdlib/source/test/lux/ffi.jvm.lux53
-rw-r--r--stdlib/source/test/lux/tool.lux4
-rw-r--r--stdlib/source/test/lux/tool/compiler/meta/cli.lux119
4 files changed, 204 insertions, 47 deletions
diff --git a/stdlib/source/test/lux.lux b/stdlib/source/test/lux.lux
index b859f456f..e8a6a482d 100644
--- a/stdlib/source/test/lux.lux
+++ b/stdlib/source/test/lux.lux
@@ -449,78 +449,89 @@
<m2/1> (template.text [<module/2> "/" <module/1>])
<m0/1/2> (template.text [<module/0> "/" <module/1> "/" <module/2>])
<open/0> (template.text [<module/0> "#[0]"])]
- (and (~~ (template [<input> <pattern>]
+ (and (~~ (template [<input> <module> <referrals>]
[(with_expansions [<input>' (macro.final <input>)]
(let [scenario (: (-> Any Bit)
(function (_ _)
- (case (' [<input>'])
- (^code <pattern>)
- true
-
- _
- false)))]
+ ... TODO: Remove this hack once Jython is no longer being used as the Python interpreter.
+ (`` (for [@.python (case (' [<input>'])
+ (^code [<module>
+ ("lux def" (~ [_ {.#Symbol ["" _]}]) [] #0)
+ (~~ (template.spliced <referrals>))])
+ true
+
+ _
+ false)]
+ (case (' [<input>'])
+ (^code [<module> (~~ (template.spliced <referrals>))])
+ true
+
+ _
+ false)))))]
(scenario [])))]
[(.using [<module/0>'])
- [("lux def module" [])]]
+ ("lux def module" [])
+ []]
[(.using [<alias> <module/0>' "*"])
- [("lux def module" [[<module/0> <alias>]])
- (<referral> <module/0> "*")]]
+ ("lux def module" [[<module/0> <alias>]])
+ [(<referral> <module/0> "*")]]
[(.using [<alias> <module/0>' {"+" <definition>}])
- [("lux def module" [[<module/0> <alias>]])
- (<referral> <module/0> {"+" <definition>})]]
+ ("lux def module" [[<module/0> <alias>]])
+ [(<referral> <module/0> {"+" <definition>})]]
[(.using [<alias> <module/0>' {"-" <definition>}])
- [("lux def module" [[<module/0> <alias>]])
- (<referral> <module/0> {"-" <definition>})]]
+ ("lux def module" [[<module/0> <alias>]])
+ [(<referral> <module/0> {"-" <definition>})]]
[(.using [<alias> <module/0>' "_"])
- [("lux def module" [])]]
+ ("lux def module" [])
+ []]
[(.using [<module/0>'
[<alias> <module/1>']])
- [("lux def module" [[<m0/1> <alias>]])
- (<referral> <m0/1>)]]
+ ("lux def module" [[<m0/1> <alias>]])
+ [(<referral> <m0/1>)]]
[(.using ["[0]" <module/0>'
["[0]" <module/1>']])
- [("lux def module" [[<module/0> <module/0>]
- [<m0/1> <module/1>]])
- (<referral> <module/0>)
+ ("lux def module" [[<module/0> <module/0>]
+ [<m0/1> <module/1>]])
+ [(<referral> <module/0>)
(<referral> <m0/1>)]]
[(.using ["[0]" <module/0>' "_"
["[1]" <module/1>']])
- [("lux def module" [[<m0/1> <module/0>]])
- (<referral> <m0/1>)]]
+ ("lux def module" [[<m0/1> <module/0>]])
+ [(<referral> <m0/1>)]]
[(.using ["[0]" <module/0>' "_"
["[1]" <module/1>' "_"
["[2]" <module/2>']]])
- [("lux def module" [[<m0/1/2> <module/0>]])
- (<referral> <m0/1/2>)]]
+ ("lux def module" [[<m0/1/2> <module/0>]])
+ [(<referral> <m0/1/2>)]]
[(.using [<module/0>'
["[0]" <module/1>'
["[0]" <//>']]])
- [("lux def module" [[<m0/1> <module/1>]
- [<m0/2> <//>]])
- (<referral> <m0/1>)
+ ("lux def module" [[<m0/1> <module/1>]
+ [<m0/2> <//>]])
+ [(<referral> <m0/1>)
(<referral> <m0/2>)]]
[(.using ["[0]" <module/0>'
[<module/1>'
["[0]" <\\>']]])
- [("lux def module" [[<module/0> <module/0>]
- [<m2/1> <\\>]])
- (<referral> <module/0>)
+ ("lux def module" [[<module/0> <module/0>]
+ [<m2/1> <\\>]])
+ [(<referral> <module/0>)
(<referral> <m2/1>)]]
[(.using ["[0]" <module/0>' ("[1]#[0]" <definition>)])
- [("lux def module" [[<module/0> <module/0>]])
- (<referral> <module/0> (<open/0> <definition>))]]
+ ("lux def module" [[<module/0> <module/0>]])
+ [(<referral> <module/0> (<open/0> <definition>))]]
))))))
))))))
diff --git a/stdlib/source/test/lux/ffi.jvm.lux b/stdlib/source/test/lux/ffi.jvm.lux
index f77fbc54f..7684d7b96 100644
--- a/stdlib/source/test/lux/ffi.jvm.lux
+++ b/stdlib/source/test/lux/ffi.jvm.lux
@@ -4,11 +4,12 @@
["_" test {"+" Test}]
["[0]" type ("[1]#[0]" equivalence)]
["[0]" meta]
+ ["[0]" debug]
[abstract
[monad {"+" do}]]
[control
[pipe {"+" case>}]
- ["[0]" try]
+ ["[0]" try ("[1]#[0]" functor)]
["[0]" exception]
[parser
["<[0]>" code]]]
@@ -27,7 +28,10 @@
[number
["n" nat]
["i" int ("[1]#[0]" equivalence)]
- ["f" frac ("[1]#[0]" equivalence)]]]]]
+ ["f" frac ("[1]#[0]" equivalence)]]]
+ [target
+ ["[0]" jvm "_"
+ ["[1]" type ("[1]#[0]" equivalence)]]]]]
[\\library
["[0]" /]])
@@ -597,18 +601,39 @@
(def: for_exception
Test
- ($_ _.and
- (_.cover [/.class_names_cannot_contain_periods]
- (with_expansions [<class> (template.symbol ["java.lang.Float"])]
- (not (expands? (/.import: <class>)))))
- (_.cover [/.class_name_cannot_be_a_type_variable]
- (and (not (expands? (/.import: (java/lang/Double a)
- ["[1]::[0]"
- (invalid [] (a java/lang/String))])))
- (not (expands? (/.import: java/lang/Double
- ["[1]::[0]"
- ([a] invalid [] (a java/lang/String))])))))
- ))
+ (do [! random.monad]
+ [var/0 (random.ascii/lower 1)
+ var/1 (random.ascii/lower 2)
+ var/2 (random.ascii/lower 3)]
+ ($_ _.and
+ (_.cover [/.class_names_cannot_contain_periods]
+ (with_expansions [<class> (template.symbol ["java.lang.Float"])]
+ (not (expands? (/.import: <class>)))))
+ (_.cover [/.class_name_cannot_be_a_type_variable]
+ (and (not (expands? (/.import: (java/lang/Double a)
+ ["[1]::[0]"
+ (invalid [] (a java/lang/String))])))
+ (not (expands? (/.import: java/lang/Double
+ ["[1]::[0]"
+ ([a] invalid [] (a java/lang/String))])))))
+ (_.cover [/.unknown_type_variable]
+ (let [type_variable ((debug.private /.type_variable) (list (jvm.var var/0) (jvm.var var/1)))]
+ (and (|> (list (code.local_symbol var/0))
+ (<code>.result type_variable)
+ (try#each (|>> (jvm#= (jvm.var var/0))))
+ (try.else false))
+ (|> (list (code.local_symbol var/1))
+ (<code>.result type_variable)
+ (try#each (|>> (jvm#= (jvm.var var/1))))
+ (try.else false))
+ (|> (list (code.local_symbol var/2))
+ (<code>.result type_variable)
+ (case> {try.#Failure error}
+ (exception.match? /.unknown_type_variable error)
+
+ _
+ false)))))
+ )))
(def: .public test
(<| (_.covering /._)
diff --git a/stdlib/source/test/lux/tool.lux b/stdlib/source/test/lux/tool.lux
index 6fa62a7da..2291880ec 100644
--- a/stdlib/source/test/lux/tool.lux
+++ b/stdlib/source/test/lux/tool.lux
@@ -20,7 +20,8 @@
... ["[1]/[0]" synthesis]
]]]
["[1][0]" meta "_"
- ["[1]/[0]" archive]]
+ ["[1]/[0]" archive]
+ ["[1]/[0]" cli]]
]])
(def: .public test
@@ -32,6 +33,7 @@
/phase.test
/analysis.test
/meta/archive.test
+ /meta/cli.test
/phase/extension.test
/phase/analysis/simple.test
/phase/analysis/complex.test
diff --git a/stdlib/source/test/lux/tool/compiler/meta/cli.lux b/stdlib/source/test/lux/tool/compiler/meta/cli.lux
new file mode 100644
index 000000000..7c5f0266e
--- /dev/null
+++ b/stdlib/source/test/lux/tool/compiler/meta/cli.lux
@@ -0,0 +1,119 @@
+(.using
+ [library
+ [lux "*"
+ ["_" test {"+" Test}]
+ [abstract
+ [monad {"+" do}]]
+ [control
+ [pipe {"+" case>}]
+ ["[0]" try ("[1]#[0]" functor)]
+ ["<>" parser
+ ["<[0]>" cli]]]
+ [data
+ ["[0]" product]
+ ["[0]" text]
+ [collection
+ ["[0]" list ("[1]#[0]" monoid monad)]]]
+ [math
+ ["[0]" random]
+ [number
+ ["n" nat]]]]]
+ [\\library
+ ["[0]" /]])
+
+(def: .public test
+ Test
+ (<| (_.covering /._)
+ (_.for [/.Service /.service])
+ (let [(^open "list#[0]") (list.equivalence text.equivalence)])
+ (do [! random.monad]
+ [amount (# ! each (|>> (n.% 5) ++) random.nat)
+ sources (random.list amount (random.ascii/lower 1))
+ host_dependencies (random.list amount (random.ascii/lower 2))
+ libraries (random.list amount (random.ascii/lower 3))
+ target (random.ascii/lower 4)
+ module (random.ascii/lower 5)
+ .let [compilation' ($_ list#composite
+ (list#conjoint (list#each (|>> (list "--source")) sources))
+ (list#conjoint (list#each (|>> (list "--host_dependency")) host_dependencies))
+ (list#conjoint (list#each (|>> (list "--library")) libraries))
+ (list "--target" target)
+ (list "--module" module))
+ export ($_ list#composite
+ (list#conjoint (list#each (|>> (list "--source")) sources))
+ (list "--target" target))]]
+ ($_ _.and
+ (_.for [/.Compilation]
+ (`` ($_ _.and
+ (~~ (template [<type> <slot> <?>]
+ [(_.cover [<type>]
+ (|> (list& "build" compilation')
+ (<cli>.result /.service)
+ (try#each (|>> (case> {/.#Compilation it}
+ (|> it
+ (value@ <slot>)
+ <?>)
+
+ _
+ false)))
+ (try.else false)))]
+
+ [/.Source /.#sources (list#= sources)]
+ [/.Host_Dependency /.#host_dependencies (list#= host_dependencies)]
+ [/.Library /.#libraries (list#= libraries)]
+ [/.Target /.#target (same? target)]
+ [/.Module /.#module (same? module)]
+ ))
+ )))
+ (_.cover [/.Interpretation]
+ (`` (and (~~ (template [<slot> <?>]
+ [(|> (list& "repl" compilation')
+ (<cli>.result /.service)
+ (try#each (|>> (case> {/.#Interpretation it}
+ (|> it
+ (value@ <slot>)
+ <?>)
+
+ _
+ false)))
+ (try.else false))]
+
+ [/.#sources (list#= sources)]
+ [/.#host_dependencies (list#= host_dependencies)]
+ [/.#libraries (list#= libraries)]
+ [/.#target (same? target)]
+ [/.#module (same? module)]
+ )))))
+ (_.cover [/.Export]
+ (`` (and (~~ (template [<side> <?>]
+ [(|> (list& "export" export)
+ (<cli>.result /.service)
+ (try#each (|>> (case> {/.#Export it}
+ (|> it
+ <side>
+ <?>)
+
+ _
+ false)))
+ (try.else false))]
+
+ [product.left (list#= sources)]
+ [product.right (same? target)]
+ )))))
+ (_.cover [/.target]
+ (`` (and (~~ (template [<it>]
+ [(same? target (/.target <it>))]
+
+ [{/.#Compilation [/.#sources sources
+ /.#host_dependencies host_dependencies
+ /.#libraries libraries
+ /.#target target
+ /.#module module]}]
+ [{/.#Interpretation [/.#sources sources
+ /.#host_dependencies host_dependencies
+ /.#libraries libraries
+ /.#target target
+ /.#module module]}]
+ [{/.#Export [sources target]}]
+ )))))
+ ))))