aboutsummaryrefslogtreecommitdiff
path: root/stdlib/source/test
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--stdlib/source/test/lux/target/jvm.lux26
-rw-r--r--stdlib/source/test/lux/tool.lux4
-rw-r--r--stdlib/source/test/lux/tool/compiler/language/lux/analysis.lux52
-rw-r--r--stdlib/source/test/lux/tool/compiler/meta/export.lux115
4 files changed, 171 insertions, 26 deletions
diff --git a/stdlib/source/test/lux/target/jvm.lux b/stdlib/source/test/lux/target/jvm.lux
index b6762f168..6a85e0354 100644
--- a/stdlib/source/test/lux/target/jvm.lux
+++ b/stdlib/source/test/lux/target/jvm.lux
@@ -116,7 +116,7 @@
(list)
(list (/method.method ..method_modifier
method_name
- (/type.method [(list) (list) ..$Object (list)])
+ #0 (/type.method [(list) (list) ..$Object (list)])
(list)
{.#Some (do /.monad
[_ bytecode]
@@ -857,11 +857,11 @@
{.#None}
(/name.internal "java.lang.Object")
(list)
- (list (/field.field /field.static class_field /type.long false (sequence.sequence))
- (/field.field /field.public object_field /type.long false (sequence.sequence)))
+ (list (/field.field /field.static class_field #0 /type.long (sequence.sequence))
+ (/field.field /field.public object_field #0 /type.long (sequence.sequence)))
(list (/method.method /method.private
constructor
- constructor::type
+ #0 constructor::type
(list)
{.#Some (do /.monad
[_ /.aload_0
@@ -876,7 +876,7 @@
/method.public
/method.static)
static_method
- (/type.method [(list) (list) ..$Long (list)])
+ #0 (/type.method [(list) (list) ..$Long (list)])
(list)
{.#Some (do /.monad
[_ (/.new $Self)
@@ -1338,14 +1338,14 @@
(list)
(list (/method.method ..method_modifier
primitive_method_name
- primitive_method_type
+ #0 primitive_method_type
(list)
{.#Some (do /.monad
[_ ((value@ #literal primitive) expected)]
return)})
(/method.method ..method_modifier
object_method_name
- (/type.method [(list) (list) (value@ #boxed primitive) (list)])
+ #0 (/type.method [(list) (list) (value@ #boxed primitive) (list)])
(list)
{.#Some (do /.monad
[_ (/.invokestatic $Self primitive_method_name primitive_method_type)
@@ -1624,7 +1624,7 @@
(function (_ name value)
(/method.method /method.public
name
- method::type
+ #0 method::type
(list)
{.#Some (do /.monad
[_ (..$Long::literal value)]
@@ -1637,7 +1637,7 @@
(list)
(list)
(list (/method.method ($_ /modifier#composite /method.public /method.abstract)
- interface_method method::type (list) {.#None}))
+ interface_method #0 method::type (list) {.#None}))
(sequence.sequence))
try.trusted
(format.result /class.writer))
@@ -1649,7 +1649,7 @@
(list)
(list (/method.method /method.public
"<init>"
- constructor::type
+ #0 constructor::type
(list)
{.#Some (do /.monad
[_ /.aload_0
@@ -1658,7 +1658,7 @@
(method inherited_method part0)
(method overriden_method fake_part2)
(/method.method ($_ /modifier#composite /method.public /method.abstract)
- abstract_method method::type (list) {.#None}))
+ abstract_method #0 method::type (list) {.#None}))
(sequence.sequence))
try.trusted
(format.result /class.writer))
@@ -1675,7 +1675,7 @@
(list)
(list (/method.method /method.public
"<init>"
- constructor::type
+ #0 constructor::type
(list)
{.#Some (do /.monad
[_ /.aload_0
@@ -1689,7 +1689,7 @@
/method.public
/method.static)
static_method
- (/type.method [(list) (list) ..$Long (list)])
+ #0 (/type.method [(list) (list) ..$Long (list)])
(list)
{.#Some (do /.monad
[_ (/.new $Concrete)
diff --git a/stdlib/source/test/lux/tool.lux b/stdlib/source/test/lux/tool.lux
index 9d9d6c3a2..0f42f81db 100644
--- a/stdlib/source/test/lux/tool.lux
+++ b/stdlib/source/test/lux/tool.lux
@@ -22,7 +22,8 @@
]]]
["[1][0]" meta "_"
["[1]/[0]" archive]
- ["[1]/[0]" cli]]
+ ["[1]/[0]" cli]
+ ["[1]/[0]" export]]
]])
(def: .public test
@@ -35,6 +36,7 @@
/analysis.test
/meta/archive.test
/meta/cli.test
+ /meta/export.test
/phase/extension.test
/phase/analysis/simple.test
/phase/analysis/complex.test
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 135ac5840..858a294ae 100644
--- a/stdlib/source/test/lux/tool/compiler/language/lux/analysis.lux
+++ b/stdlib/source/test/lux/tool/compiler/language/lux/analysis.lux
@@ -9,6 +9,7 @@
["$[0]" equivalence]]]
[control
[pipe {"+" case>}]
+ ["[0]" function]
["[0]" maybe]
["[0]" try]
["[0]" exception {"+" exception:}]]
@@ -240,46 +241,73 @@
(def: test|phase
Test
(do random.monad
- [version random.nat
- host (random.ascii/lower 5)
+ [version/0 random.nat
+ host/0 (random.ascii/lower 5)
+ version/1 random.nat
+ host/1 (random.ascii/lower 5)
expected_error (random.ascii/lower 10)
- location /location.random
- .let [state (with@ .#location location
- (/.state (/.info version host)))]]
+ location/0 /location.random
+ location/1 /location.random
+ .let [state/0 (with@ .#location location/0
+ (/.state (/.info version/0 host/0)))
+ state/1 (with@ .#location location/1
+ (/.state (/.info version/1 host/1)))]]
($_ _.and
+ (_.cover [/.set_state]
+ (|> (do phase.monad
+ [pre (extension.read function.identity)
+ _ (/.set_state state/1)
+ post (extension.read function.identity)]
+ (in (and (same? state/0 pre)
+ (same? state/1 post))))
+ (phase.result [extension.#bundle extension.empty
+ extension.#state state/0])
+ (try.else false)))
(_.cover [/.failure]
(|> (/.failure expected_error)
(phase.result [extension.#bundle extension.empty
- extension.#state state])
+ extension.#state state/0])
(case> {try.#Failure actual_error}
(and (text.contains? expected_error actual_error)
- (text.contains? (location.format location) actual_error))
+ (text.contains? (location.format location/0) actual_error))
_
false)))
(_.cover [/.except]
(|> (/.except <exception> [])
(phase.result [extension.#bundle extension.empty
- extension.#state state])
+ extension.#state state/0])
(case> {try.#Failure actual_error}
(and (text.contains? (exception.error <exception> []) actual_error)
- (text.contains? (location.format location) actual_error))
+ (text.contains? (location.format location/0) actual_error))
+
+ _
+ false)))
+ (_.cover [/.with_exception]
+ (|> (/.failure expected_error)
+ (/.with_exception <exception> [])
+ (phase.result [extension.#bundle extension.empty
+ extension.#state state/0])
+ (case> {try.#Failure actual_error}
+ (and (text.contains? expected_error actual_error)
+ (text.contains? (exception.error <exception> []) actual_error)
+ (text.contains? (location.format location/0) actual_error))
_
false)))
(_.cover [/.assertion]
(and (|> (/.assertion <exception> [] false)
(phase.result [extension.#bundle extension.empty
- extension.#state state])
+ extension.#state state/0])
(case> {try.#Failure actual_error}
(and (text.contains? (exception.error <exception> []) actual_error)
- (text.contains? (location.format location) actual_error))
+ (text.contains? (location.format location/0) actual_error))
_
false))
(|> (/.assertion <exception> [] true)
(phase.result [extension.#bundle extension.empty
- extension.#state state])
+ extension.#state state/0])
(case> {try.#Success _}
true
diff --git a/stdlib/source/test/lux/tool/compiler/meta/export.lux b/stdlib/source/test/lux/tool/compiler/meta/export.lux
new file mode 100644
index 000000000..11a6ea9ce
--- /dev/null
+++ b/stdlib/source/test/lux/tool/compiler/meta/export.lux
@@ -0,0 +1,115 @@
+(.using
+ [library
+ [lux "*"
+ ["_" test {"+" Test}]
+ [abstract
+ [monad {"+" do}]]
+ [control
+ [pipe {"+" case>}]
+ ["[0]" try ("[1]#[0]" functor)]
+ [concurrency
+ ["[0]" async]]
+ [parser
+ ["<[0]>" binary]]]
+ [data
+ ["[0]" product]
+ ["[0]" binary {"+" Binary} ("[1]#[0]" equivalence)]
+ ["[0]" bit ("[1]#[0]" equivalence)]
+ [format
+ ["[0]" tar]]
+ ["[0]" text ("[1]#[0]" equivalence)
+ ["%" format {"+" format}]
+ [encoding
+ ["[0]" utf8]]]
+ [collection
+ ["[0]" sequence]]]
+ [math
+ ["[0]" random {"+" Random}]
+ [number
+ ["n" nat]]]
+ [world
+ ["[0]" file]]]]
+ [\\library
+ ["[0]" /
+ [//
+ ["[0]" io "_"
+ ["[1]" context]]]]])
+
+(def: .public test
+ Test
+ (<| (_.covering /._)
+ (do [! random.monad]
+ [.let [/ .module_separator]
+ source/0 (random.ascii/lower 1)
+ source/1 (random.ascii/lower 2)
+ target (random.ascii/lower 3)
+
+ .let [random_file (: (Random file.Path)
+ (# ! each (text.suffix io.lux_extension) (random.ascii/lower 4)))]
+ file/0' random_file
+ .let [file/0 (format source/0 / file/0')]
+
+ dir/0 (random.ascii/lower 5)
+ file/1' (# ! each (|>> (format dir/0 /)) random_file)
+ .let [file/1 (format source/1 / file/1')]
+
+ .let [random_content (: (Random Binary)
+ (# ! each (|>> %.nat (# utf8.codec encoded)) random.nat))]
+ content/0 random_content
+ content/1 random_content]
+ ($_ _.and
+ (in (do [! async.monad]
+ [it (do (try.with !)
+ [.let [fs (file.mock /)]
+ _ (# fs make_directory source/0)
+ _ (# fs write content/0 file/0)
+
+ _ (# fs make_directory source/1)
+ _ (# fs make_directory (format source/1 / dir/0))
+ _ (# fs write content/1 file/1)
+
+ _ (# fs make_directory target)
+ library_tar (/.library fs (list source/0 source/1))
+ _ (/.export fs [(list source/0 source/1) target])
+ export_tar (# fs read (format target / /.file))
+ export_tar (# ! in (<binary>.result tar.parser export_tar))]
+ (in [library_tar export_tar]))]
+ ($_ _.and'
+ (_.cover' [/.library]
+ (|> it
+ (try#each (|>> product.left
+ sequence.list
+ (case> (^ (list {tar.#Normal [actual_path/0 _ _ _ actual_content/0]}
+ {tar.#Normal [actual_path/1 _ _ _ actual_content/1]}))
+ (with_expansions [<test> (and (and (text#= file/0' (tar.from_path actual_path/0))
+ (binary#= content/0 (tar.data actual_content/0)))
+ (and (text#= file/1' (tar.from_path actual_path/1))
+ (binary#= content/1 (tar.data actual_content/1))))]
+ (or <test>
+ (let [[[actual_path/0 actual_content/0] [actual_path/1 actual_content/1]]
+ [[actual_path/1 actual_content/1] [actual_path/0 actual_content/0]]]
+ <test>)))
+
+ _
+ false)))
+ (try.else false)))
+ (_.cover' [/.export /.file]
+ (|> it
+ (try#each (|>> product.right
+ sequence.list
+ (case> (^ (list {tar.#Normal [actual_path/0 _ _ _ actual_content/0]}
+ {tar.#Normal [actual_path/1 _ _ _ actual_content/1]}))
+ (with_expansions [<test> (and (and (text#= file/0' (tar.from_path actual_path/0))
+ (binary#= content/0 (tar.data actual_content/0)))
+ (and (text#= file/1' (tar.from_path actual_path/1))
+ (binary#= content/1 (tar.data actual_content/1))))]
+ (or <test>
+ (let [[[actual_path/0 actual_content/0] [actual_path/1 actual_content/1]]
+ [[actual_path/1 actual_content/1] [actual_path/0 actual_content/0]]]
+ <test>)))
+
+ _
+ false)))
+ (try.else false)))
+ )))
+ ))))