aboutsummaryrefslogtreecommitdiff
path: root/stdlib/source/test
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--stdlib/source/test/lux/macro.lux115
-rw-r--r--stdlib/source/test/lux/static.lux20
-rw-r--r--stdlib/source/test/lux/tool.lux10
-rw-r--r--stdlib/source/test/lux/tool/compiler/meta/archive/module.lux21
4 files changed, 119 insertions, 47 deletions
diff --git a/stdlib/source/test/lux/macro.lux b/stdlib/source/test/lux/macro.lux
index 1f28f0e21..ef7463d4e 100644
--- a/stdlib/source/test/lux/macro.lux
+++ b/stdlib/source/test/lux/macro.lux
@@ -1,36 +1,37 @@
(.using
- [library
- [lux "*"
- ["_" test {"+" Test}]
- [abstract
- [monad {"+" do}]]
- [control
- ["[0]" try ("[1]#[0]" functor)]
- [parser
- ["<[0]>" code]]]
- [data
- ["[0]" bit ("[1]#[0]" equivalence)]
- ["[0]" text
- ["%" format {"+" format}]]
- [collection
- ["[0]" list]]]
- [math
- ["[0]" random {"+" Random}]
- [number
- ["[0]" nat]]]
- ["[0]" meta
- ["[0]" location]
- ["[0]" symbol]]]]
- [\\library
- ["[0]" /
- [syntax {"+" syntax:}]
- ["[0]" code ("[1]#[0]" equivalence)]
- ["[0]" template]]]
- ["[0]" / "_"
- ["[1][0]" code]
- ["[1][0]" local]
- ["[1][0]" syntax]
- ["[1][0]" template]])
+ [library
+ [lux "*"
+ ["_" test {"+" Test}]
+ ["[0]" static]
+ [abstract
+ [monad {"+" do}]]
+ [control
+ ["[0]" try ("[1]#[0]" functor)]
+ [parser
+ ["<[0]>" code]]]
+ [data
+ ["[0]" bit ("[1]#[0]" equivalence)]
+ ["[0]" text
+ ["%" format {"+" format}]]
+ [collection
+ ["[0]" list]]]
+ [math
+ ["[0]" random {"+" Random} ("[1]#[0]" functor)]
+ [number
+ ["n" nat]]]
+ ["[0]" meta
+ ["[0]" location]
+ ["[0]" symbol]]]]
+ [\\library
+ ["[0]" /
+ [syntax {"+" syntax:}]
+ ["[0]" code ("[1]#[0]" equivalence)]
+ ["[0]" template]]]
+ ["[0]" / "_"
+ ["[1][0]" code]
+ ["[1][0]" local]
+ ["[1][0]" syntax]
+ ["[1][0]" template]])
(template: (!expect <pattern> <value>)
[(case <value>
@@ -42,7 +43,7 @@
[(template.text [<definition>]) {.#Definition [true .Macro <definition>]}])])
(syntax: (pow/2 [number <code>.any])
- (in (list (` (nat.* (~ number) (~ number))))))
+ (in (list (` (n.* (~ number) (~ number))))))
(syntax: (pow/4 [number <code>.any])
(in (list (` (..pow/2 (..pow/2 (~ number)))))))
@@ -100,19 +101,25 @@
.#eval (:as (-> Type Code (Meta Any)) [])
.#host []]])))
-(def: expander
+(syntax: (iterated [cycle <code>.nat
+ it <code>.any])
+ (in (list (case cycle
+ 0 it
+ _ (` (..iterated (~ (code.nat (-- cycle))) (~ it)))))))
+
+(def: test|expansion
Test
(do [! random.monad]
[[seed symbol_prefix lux] ..random_lux
pow/1 (# ! each code.nat random.nat)
- repetitions (# ! each (nat.% 10) random.nat)
+ repetitions (# ! each (n.% 10) random.nat)
.let [single_expansion (` (..pow/2 (..pow/2 (~ pow/1))))
- expansion (` (nat.* (..pow/2 (~ pow/1))
- (..pow/2 (~ pow/1))))
- full_expansion (` (nat.* (nat.* (~ pow/1) (~ pow/1))
- (nat.* (~ pow/1) (~ pow/1))))]]
+ expansion (` (n.* (..pow/2 (~ pow/1))
+ (..pow/2 (~ pow/1))))
+ full_expansion (` (n.* (n.* (~ pow/1) (~ pow/1))
+ (n.* (~ pow/1) (~ pow/1))))]]
(`` ($_ _.and
(~~ (template [<expander> <logger> <expansion>]
[(_.cover [<expander>]
@@ -137,10 +144,36 @@
[/.full_expansion /.log_full_expansion! full_expansion]
))
(_.cover [/.one_expansion]
- (bit#= (not (nat.= 1 repetitions))
+ (bit#= (not (n.= 1 repetitions))
(|> (/.one_expansion (` (..repeated (~ (code.nat repetitions)) (~ pow/1))))
(meta.result lux)
(!expect {try.#Failure _}))))
+ (_.cover [/.final]
+ (with_expansions [<expected> (static.random_nat)
+ <cycles> (static.random code.nat
+ (random#each (|>> (n.% 5) ++) random.nat))
+ <actual> (/.final (..iterated <cycles> <expected>))]
+ (case (' <actual>)
+ [_ {.#Nat actual}]
+ (n.= <expected> actual)
+
+ _
+ false)))
+ (_.cover [/.times]
+ (with_expansions [<expected> (static.random_nat)
+ <max> (static.random code.nat
+ (random#each (|>> (n.% 10) (n.+ 2)) random.nat))
+ <cycles> (static.random code.nat
+ (random#each (|>> (n.% <max>) ++) random.nat))
+ <actual> (/.times <cycles> (..iterated <max> <expected>))]
+ (let [expected_remaining (n.- <cycles> <max>)]
+ (case (` <actual>)
+ (^code (..iterated (~ [_ {.#Nat actual_remaining}]) (~ [_ {.#Nat actual}])))
+ (and (n.= expected_remaining actual_remaining)
+ (n.= <expected> actual))
+
+ _
+ false))))
))))
(def: .public test
@@ -173,7 +206,7 @@
actual))))))
))
- ..expander
+ ..test|expansion
/code.test
/local.test
diff --git a/stdlib/source/test/lux/static.lux b/stdlib/source/test/lux/static.lux
index c8425f21d..691749810 100644
--- a/stdlib/source/test/lux/static.lux
+++ b/stdlib/source/test/lux/static.lux
@@ -6,11 +6,13 @@
["[0]" meta]
[data
["[0]" text ("[1]#[0]" equivalence)
- ["%" format {"+" format}]]]
+ ["%" format {"+" format}]]
+ [collection
+ ["[0]" list ("[1]#[0]" mix)]]]
[macro
["[0]" code]]
[math
- ["[0]" random]
+ ["[0]" random ("[1]#[0]" functor)]
[number
["n" nat]
["i" int]
@@ -65,6 +67,13 @@
_
false)))
+ (_.cover [/.randoms]
+ (with_expansions [<amount> (/.random code.nat
+ (random#each (|>> (n.% 10) ++) random.nat))
+ l/* (/.randoms code.nat (random.list <amount> random.nat))]
+ (and (n.= <amount> (list.size (list l/*)))
+ (n.= (list#mix n.+ 0 (list l/*))
+ ($_ n.+ l/*)))))
(_.cover [/.literal]
(with_expansions [<left> (/.random code.text (random.ascii/alpha_num 1))
<right> (/.random code.text (random.ascii/alpha_num 1))
@@ -75,4 +84,11 @@
_
false)))
+ (_.cover [/.literals]
+ (with_expansions [l/0 (/.random_nat)
+ l/1 (/.random_nat)
+ l/2 (/.random_nat)
+ l/* (/.literals code.nat (list l/0 l/1 l/2))]
+ (n.= ($_ n.+ l/0 l/1 l/2)
+ ($_ n.+ l/*))))
))))
diff --git a/stdlib/source/test/lux/tool.lux b/stdlib/source/test/lux/tool.lux
index 25f869808..c0e7fd739 100644
--- a/stdlib/source/test/lux/tool.lux
+++ b/stdlib/source/test/lux/tool.lux
@@ -20,11 +20,12 @@
]]]
["[1][0]" meta "_"
["[1]/[0]" archive "_"
- ["[1]/[0]" artifact]
["[1]/[0]" signature]
["[1]/[0]" key]
- ["[1]/[0]" document]
+ ["[1]/[0]" artifact]
["[1]/[0]" registry]
+ ["[1]/[0]" module]
+ ["[1]/[0]" document]
["[1]/[0]" descriptor]]]
]])
@@ -36,11 +37,12 @@
/reference.test
/phase.test
/analysis.test
- /meta/archive/artifact.test
/meta/archive/signature.test
/meta/archive/key.test
- /meta/archive/document.test
+ /meta/archive/artifact.test
/meta/archive/registry.test
+ /meta/archive/module.test
+ /meta/archive/document.test
/meta/archive/descriptor.test
/phase/extension.test
/phase/analysis/simple.test
diff --git a/stdlib/source/test/lux/tool/compiler/meta/archive/module.lux b/stdlib/source/test/lux/tool/compiler/meta/archive/module.lux
new file mode 100644
index 000000000..3d0bc262e
--- /dev/null
+++ b/stdlib/source/test/lux/tool/compiler/meta/archive/module.lux
@@ -0,0 +1,21 @@
+(.using
+ [library
+ [lux "*"
+ ["_" test {"+" Test}]
+ [abstract
+ [monad {"+" do}]]
+ [math
+ ["[0]" random]
+ [number
+ ["n" nat]]]]]
+ [\\library
+ ["[0]" /]])
+
+(def: .public test
+ Test
+ (<| (_.covering /._)
+ (_.for [/.Module])
+ ($_ _.and
+ (_.cover [/.ID /.runtime]
+ (n.= 0 /.runtime))
+ )))