aboutsummaryrefslogtreecommitdiff
path: root/stdlib/source/test
diff options
context:
space:
mode:
Diffstat (limited to 'stdlib/source/test')
-rw-r--r--stdlib/source/test/lux.lux293
-rw-r--r--stdlib/source/test/lux/extension.lux4
-rw-r--r--stdlib/source/test/lux/tool.lux4
-rw-r--r--stdlib/source/test/lux/tool/compiler/meta/archive/artifact.lux7
-rw-r--r--stdlib/source/test/lux/tool/compiler/meta/archive/registry.lux7
-rw-r--r--stdlib/source/test/lux/tool/compiler/meta/archive/unit.lux36
6 files changed, 243 insertions, 108 deletions
diff --git a/stdlib/source/test/lux.lux b/stdlib/source/test/lux.lux
index 631f754e4..2b72f6dad 100644
--- a/stdlib/source/test/lux.lux
+++ b/stdlib/source/test/lux.lux
@@ -4,6 +4,7 @@
[program {"+" program:}]
["_" test {"+" Test}]
["@" target]
+ ["[0]" static]
[abstract
[monad {"+" do}]]
[control
@@ -37,7 +38,7 @@
["r" rev]
["f" frac]
["[0]" i64]]]
- ["[0]" meta
+ ["[0]" meta ("[1]#[0]" monad)
["[0]" location ("[1]#[0]" equivalence)]]]]
... TODO: Must have 100% coverage on tests.
["[0]" / "_"
@@ -47,8 +48,7 @@
["[1][0]" debug]
["[1][0]" documentation]
["[1][0]" locale]
- ["[1][0]" macro
- ["[1]/[0]" code]]
+ ["[1][0]" macro]
["[1][0]" math]
["[1][0]" meta]
["[1][0]" program]
@@ -68,47 +68,7 @@
"Lua" (~~ (.as_is ["[1]/[0]" lua]))
"Python" (~~ (.as_is ["[1]/[0]" python]))
"Ruby" (~~ (.as_is ["[1]/[0]" ruby]))]
- (~~ (.as_is))))]
- ])))
-
-... TODO: Get rid of this ASAP
-(template: (!bundle body)
- [(: Test
- (do random.monad
- [_ (in [])]
- body))])
-
-(def: sub_tests
- Test
- (`` (`` (_.in_parallel (list /abstract.test
- /control.test
- /data.test
- /debug.test
- /documentation.test
- /locale.test
- /macro.test
- /math.test
- /meta.test
- /program.test
- /static.test
- /target.test
- /test.test
- /time.test
- /tool.test
- /type.test
- /world.test
- /ffi.test
- ... TODO: Update & expand tests for this
- (~~ (for [@.jvm (~~ (as_is /target/jvm.test))
- @.old (~~ (as_is /target/jvm.test))
- @.js (~~ (as_is /target/js.test))
- @.lua (~~ (as_is /target/lua.test))
- @.python (~~ (as_is /target/python.test))
- @.ruby (~~ (as_is /target/ruby.test))]
- (~~ (as_is))))
- (~~ (for [@.old (~~ (as_is))]
- (~~ (as_is /extension.test))))
- )))))
+ (~~ (.as_is))))]])))
(def: for_bit
Test
@@ -400,9 +360,8 @@
(def: for_code
Test
- (do random.monad
- [example_nat random.nat
- example /macro/code.random]
+ (do [! random.monad]
+ [example (# ! each code.nat random.nat)]
($_ _.and
(_.for [/.Code /.Code']
($_ _.and
@@ -426,6 +385,22 @@
(let [[_ _ source_code] (value@ .#source lux)]
{.#Right [lux (list (code.bit (text.contains? ..crosshair source_code)))]}))
+(/.macro: (sum tokens)
+ (loop [tokens tokens
+ output 0]
+ (case tokens
+ {.#End}
+ (meta#in (list (code.nat output)))
+
+ {.#Item [_ {.#Nat head}] tail}
+ (again tail (n.+ head output))
+
+ _
+ (meta.failure ""))))
+
+(/.macro: (sum' tokens lux)
+ ((/.macro ..sum) tokens lux))
+
(def: for_macro
Test
(let [macro (: /.Macro'
@@ -433,24 +408,118 @@
{.#Right [lux (list)]}))]
(do random.monad
[expected random.nat]
- (with_expansions [<found_crosshair?> (for [@.old (~~ (as_is))]
- (_.cover [/.Source]
- (..found_crosshair?)))]
- (`` ($_ _.and
- (_.cover [/.Macro']
- (|> macro
- (: /.Macro')
- (same? macro)))
- (_.cover [/.Macro]
- (|> macro
- "lux macro"
- (: /.Macro)
- (: Any)
- (same? (: Any macro))))
- (_.cover [/.macro:]
- (same? expected (..identity_macro expected)))
- <found_crosshair?>
- ))))))
+ (`` (`` ($_ _.and
+ (_.cover [/.Macro']
+ (|> macro
+ (: /.Macro')
+ (same? macro)))
+ (_.cover [/.Macro]
+ (|> macro
+ "lux macro"
+ (: /.Macro)
+ (: Any)
+ (same? (: Any macro))))
+ (_.cover [/.macro:]
+ (same? expected (..identity_macro expected)))
+ (~~ (for [@.old (~~ (as_is))]
+ (_.cover [/.Source]
+ (..found_crosshair?))))
+ (_.cover [/.macro]
+ (with_expansions [n/0 (static.random_nat)
+ n/1 (static.random_nat)
+ n/1 (static.random_nat)]
+ (n.= (..sum n/0 n/1 n/1)
+ (..sum' n/0 n/1 n/1))))
+ (_.cover [/.using]
+ (with_expansions [<referral> ("lux in-module" "library/lux" library/lux.refer)
+ <alias> (static.random code.text (random.ascii/lower 1))
+ <definition> (static.random code.local_symbol (random.ascii/lower 1))
+ <module/0> (static.random code.text (random.ascii/lower 2))
+ <module/0>' (template.symbol [<module/0>])
+ <module/1> (static.random code.text (random.ascii/lower 3))
+ <module/1>' (template.symbol [<module/1>])
+ <module/2> (static.random code.text (random.ascii/lower 4))
+ <module/2>' (template.symbol [<module/2>])
+ <m0/1> (template.text [<module/0> "/" <module/1>])
+ <//> (template.text [// <module/2>'])
+ <//>' (template.symbol [<//>])
+ <\\> (template.text [\\ <module/2>'])
+ <\\>' (template.symbol [<\\>])
+ <m0/2> (template.text [<module/0> "/" <module/2>])
+ <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>]
+ [(with_expansions [<input>' (macro.final <input>)]
+ (case (' [<input>'])
+ (^code <pattern>)
+ true
+
+ _
+ false))]
+
+ [(.using [<module/0>'])
+ [("lux def module" [])]]
+
+ [(.using [<alias> <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>})]]
+
+ [(.using [<alias> <module/0>' {"-" <definition>}])
+ [("lux def module" [[<module/0> <alias>]])
+ (<referral> <module/0> {"-" <definition>})]]
+
+ [(.using [<alias> <module/0>' "_"])
+ [("lux def module" [])]]
+
+ [(.using [<module/0>'
+ [<alias> <module/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>)
+ (<referral> <m0/1>)]]
+
+ [(.using ["[0]" <module/0>' "_"
+ ["[1]" <module/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>)]]
+
+ [(.using [<module/0>'
+ ["[0]" <module/1>'
+ ["[0]" <//>']]])
+ [("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>)
+ (<referral> <m2/1>)]]
+
+ [(.using ["[0]" <module/0>' ("[1]#[0]" <definition>)])
+ [("lux def module" [[<module/0> <module/0>]])
+ (<referral> <module/0> (<open/0> <definition>))]]
+ )))))
+ ))))))
(/.type: for_type/variant
(Variant
@@ -1175,39 +1244,73 @@
verdict)))
0 1 2))))
+(def: test|lux
+ Test
+ (`` (`` ($_ _.and
+ ..for_bit
+ ..for_try
+ ..for_list
+ ..for_interface
+ ..for_module
+ ..for_pipe
+ ..for_code
+ ..for_macro
+ ..for_type
+ ..for_i64
+ ..for_function
+ ..for_template
+ ..for_static
+ ..for_slot
+ ..for_associative
+ ..for_expansion
+ ..for_value
+ ..for_case
+ ..for_control_flow
+ ..for_def:
+ ..for_meta
+ ..for_export
+ (~~ (for [@.old (~~ (as_is))]
+ (~~ (as_is ..for_bindings))))
+ ))))
+
(def: test
Test
(<| (_.covering /._)
- (with_expansions
- [<for_bindings> (for [@.old (~~ (as_is))]
- (~~ (as_is ..for_bindings)))]
- (`` ($_ _.and
- ..for_bit
- ..for_try
- ..for_list
- ..for_interface
- ..for_module
- ..for_pipe
- ..for_code
- ..for_macro
- ..for_type
- ..for_i64
- ..for_function
- ..for_template
- ..for_static
- ..for_slot
- ..for_associative
- ..for_expansion
- ..for_value
- ..for_case
- ..for_control_flow
- ..for_def:
- ..for_meta
- ..for_export
- <for_bindings>
-
- ..sub_tests
- )))))
+ (`` (`` (_.in_parallel
+ (list ..test|lux
+
+ /abstract.test
+ /control.test
+ /data.test
+ /debug.test
+
+ /documentation.test
+ /locale.test
+ /macro.test
+ /math.test
+
+ /meta.test
+ /program.test
+ /static.test
+ /target.test
+
+ /test.test
+ /time.test
+ /tool.test
+ /type.test
+
+ /world.test
+ /ffi.test
+
+ (~~ (for [@.old (~~ (as_is))]
+ (~~ (as_is /extension.test))))
+ (~~ (for [@.jvm (~~ (as_is /target/jvm.test))
+ @.old (~~ (as_is /target/jvm.test))
+ @.js (~~ (as_is /target/js.test))
+ @.lua (~~ (as_is /target/lua.test))
+ @.python (~~ (as_is /target/python.test))
+ @.ruby (~~ (as_is /target/ruby.test))]))
+ ))))))
(program: args
(let [times (for [@.old 100
diff --git a/stdlib/source/test/lux/extension.lux b/stdlib/source/test/lux/extension.lux
index a7b2afa6f..63cb46691 100644
--- a/stdlib/source/test/lux/extension.lux
+++ b/stdlib/source/test/lux/extension.lux
@@ -44,7 +44,7 @@
["[0]" phase]
[meta
[archive
- ["[0]" artifact]]]
+ ["[0]" unit]]]
[language
[lux
["[0]" synthesis]
@@ -153,7 +153,7 @@
(generation_phase archive expressionS))
_ (directive.lifted_generation
- (generation.with_new_context archive artifact.no_dependencies
+ (generation.with_new_context archive unit.none
(do !
[[module_id artifact_id] (generation.context archive)
.let [commentary (format "Successfully installed directive " (%.text self) "!")]
diff --git a/stdlib/source/test/lux/tool.lux b/stdlib/source/test/lux/tool.lux
index c0e7fd739..c05f16b50 100644
--- a/stdlib/source/test/lux/tool.lux
+++ b/stdlib/source/test/lux/tool.lux
@@ -26,7 +26,8 @@
["[1]/[0]" registry]
["[1]/[0]" module]
["[1]/[0]" document]
- ["[1]/[0]" descriptor]]]
+ ["[1]/[0]" descriptor]
+ ["[1]/[0]" unit]]]
]])
(def: .public test
@@ -44,6 +45,7 @@
/meta/archive/module.test
/meta/archive/document.test
/meta/archive/descriptor.test
+ /meta/archive/unit.test
/phase/extension.test
/phase/analysis/simple.test
... /syntax.test
diff --git a/stdlib/source/test/lux/tool/compiler/meta/archive/artifact.lux b/stdlib/source/test/lux/tool/compiler/meta/archive/artifact.lux
index 2bb161796..7e5d789a5 100644
--- a/stdlib/source/test/lux/tool/compiler/meta/archive/artifact.lux
+++ b/stdlib/source/test/lux/tool/compiler/meta/archive/artifact.lux
@@ -12,13 +12,6 @@
[\\library
["[0]" /]])
-(def: random_dependency
- (Random /.Dependency)
- ($_ random.and
- random.nat
- random.nat
- ))
-
(def: .public random
(Random /.Artifact)
($_ random.and
diff --git a/stdlib/source/test/lux/tool/compiler/meta/archive/registry.lux b/stdlib/source/test/lux/tool/compiler/meta/archive/registry.lux
index feee41b0a..f9499d442 100644
--- a/stdlib/source/test/lux/tool/compiler/meta/archive/registry.lux
+++ b/stdlib/source/test/lux/tool/compiler/meta/archive/registry.lux
@@ -25,6 +25,7 @@
[\\library
["[0]" /
[//
+ ["[0]" unit]
["[0]" artifact
["[0]" category]]]]])
@@ -37,15 +38,15 @@
false)])
(def: random_dependency
- (Random artifact.Dependency)
+ (Random unit.ID)
($_ random.and
random.nat
random.nat
))
(def: (random_dependencies amount)
- (-> Nat (Random (Set artifact.Dependency)))
- (random.set artifact.dependency_hash amount ..random_dependency))
+ (-> Nat (Random (Set unit.ID)))
+ (random.set unit.hash amount ..random_dependency))
(def: .public test
Test
diff --git a/stdlib/source/test/lux/tool/compiler/meta/archive/unit.lux b/stdlib/source/test/lux/tool/compiler/meta/archive/unit.lux
new file mode 100644
index 000000000..770ff473d
--- /dev/null
+++ b/stdlib/source/test/lux/tool/compiler/meta/archive/unit.lux
@@ -0,0 +1,36 @@
+(.using
+ [library
+ [lux "*"
+ ["_" test {"+" Test}]
+ [abstract
+ [\\specification
+ ["$[0]" equivalence]
+ ["$[0]" hash]]]
+ [data
+ [collection
+ ["[0]" set]]]
+ [math
+ ["[0]" random {"+" Random}]]]]
+ [\\library
+ ["[0]" /]])
+
+(def: .public random
+ (Random /.ID)
+ ($_ random.and
+ random.nat
+ random.nat
+ ))
+
+(def: .public test
+ Test
+ (<| (_.covering /._)
+ (_.for [/.ID])
+ ($_ _.and
+ (_.for [/.equivalence]
+ ($equivalence.spec /.equivalence ..random))
+ (_.for [/.hash]
+ ($hash.spec /.hash ..random))
+
+ (_.cover [/.none]
+ (set.empty? /.none))
+ )))