diff options
Diffstat (limited to 'stdlib/source/test')
-rw-r--r-- | stdlib/source/test/lux/meta.lux | 142 | ||||
-rw-r--r-- | stdlib/source/test/lux/tool.lux | 4 | ||||
-rw-r--r-- | stdlib/source/test/lux/tool/compiler/meta/archive/key.lux | 27 |
3 files changed, 122 insertions, 51 deletions
diff --git a/stdlib/source/test/lux/meta.lux b/stdlib/source/test/lux/meta.lux index f950abaa0..914e02d92 100644 --- a/stdlib/source/test/lux/meta.lux +++ b/stdlib/source/test/lux/meta.lux @@ -1,38 +1,38 @@ (.using - [library - [lux "*" - ["_" test {"+" Test}] - ["[0]" type ("[1]#[0]" equivalence)] - [abstract - [equivalence {"+" Equivalence}] - [monad {"+" do}] - [\\specification - ["$[0]" functor {"+" Injection Comparison}] - ["$[0]" apply] - ["$[0]" monad]]] - [control - ["[0]" maybe] - ["[0]" try {"+" Try} ("[1]#[0]" functor)]] - [data - ["[0]" product] - ["[0]" bit ("[1]#[0]" equivalence)] - ["[0]" text ("[1]#[0]" equivalence) - ["%" format {"+" format}]] - [collection - ["[0]" list ("[1]#[0]" functor monoid)] - ["[0]" set]]] - [meta - ["[0]" location] - ["[0]" symbol ("[1]#[0]" equivalence)]] - [math - ["[0]" random {"+" Random}] - [number - ["n" nat]]]]] - [\\library - ["[0]" /]] - ["[0]" / "_" - ["[1][0]" location] - ["[1][0]" symbol]]) + [library + [lux "*" + ["_" test {"+" Test}] + ["[0]" type ("[1]#[0]" equivalence)] + [abstract + [equivalence {"+" Equivalence}] + [monad {"+" do}] + [\\specification + ["$[0]" functor {"+" Injection Comparison}] + ["$[0]" apply] + ["$[0]" monad]]] + [control + ["[0]" maybe] + ["[0]" try {"+" Try} ("[1]#[0]" functor)]] + [data + ["[0]" product] + ["[0]" bit ("[1]#[0]" equivalence)] + ["[0]" text ("[1]#[0]" equivalence) + ["%" format {"+" format}]] + [collection + ["[0]" list ("[1]#[0]" functor monoid)] + ["[0]" set]]] + [meta + ["[0]" location] + ["[0]" symbol ("[1]#[0]" equivalence)]] + [math + ["[0]" random {"+" Random}] + [number + ["n" nat]]]]] + [\\library + ["[0]" /]] + ["[0]" / "_" + ["[1][0]" location] + ["[1][0]" symbol]]) (template: (!expect <pattern> <value>) [(case <value> @@ -159,6 +159,16 @@ (!expect (^multi {try.#Success actual} (n.= expected actual)))) )) + (_.cover [/.try] + (and (|> (/.try (/.failure expected_error)) + (/.result expected_lux) + (!expect (^multi {try.#Success {try.#Failure actual_error}} + (text#= (location.with location.dummy expected_error) + actual_error)))) + (|> (/.try (# /.monad in expected)) + (/.result expected_lux) + (!expect (^multi {try.#Success {try.#Success actual}} + (same? expected actual)))))) ))) (def: module_related @@ -310,6 +320,11 @@ .#eval (:as (-> Type Code (Meta Any)) []) .#host []]]] ($_ _.and + (_.cover [/.target] + (|> /.target + (/.result expected_lux) + (try#each (same? target)) + (try.else false))) (_.cover [/.seed] (|> (do /.monad [pre /.seed @@ -623,18 +638,18 @@ alias!))) ))) -(def: tags_related +(def: label_related Test (do [! random.monad] [current_module (random.ascii/upper 1) - tag_module (random.only (|>> (text#= current_module) not) - (random.ascii/upper 1)) + label_module (random.only (|>> (text#= current_module) not) + (random.ascii/upper 1)) name_0 (random.ascii/upper 1) name_1 (random.only (|>> (text#= name_0) not) (random.ascii/upper 1)) - .let [random_tag (# ! each (|>> [tag_module]) + .let [random_tag (# ! each (|>> [label_module]) (random.ascii/upper 1)) random_labels (: (Random [Text (List Text)]) (do ! @@ -665,18 +680,18 @@ [.#module_hash 0 .#module_aliases (list) .#definitions (list) - .#imports (list tag_module) + .#imports (list label_module) .#module_state {.#Active}]] - [tag_module + [label_module [.#module_hash 0 .#module_aliases (list) - .#definitions (list& [name_0 {.#Type [false type_0 {.#Left tags_0}]}] + .#definitions (list& [name_0 {.#Type [true type_0 {.#Left tags_0}]}] [name_1 {.#Type [true type_1 {.#Right tags_1}]}] ($_ list#composite (|> {.#Item tags_0} list.enumeration (list#each (function (_ [index short]) - [short {.#Tag [false type_0 {.#Item tags_0} index]}]))) + [short {.#Tag [true type_0 {.#Item tags_0} index]}]))) (|> {.#Item tags_1} list.enumeration (list#each (function (_ [index short]) @@ -699,21 +714,47 @@ (product.equivalence (list.equivalence symbol.equivalence) type.equivalence))] - (|> (/.tag_lists tag_module) + (|> (/.tag_lists label_module) (/.result expected_lux) - (try#each (# equivalence = (list [(list#each (|>> [tag_module]) {.#Item tags_1}) + (try#each (# equivalence = (list [(list#each (|>> [label_module]) {.#Item tags_0}) + type_0] + [(list#each (|>> [label_module]) {.#Item tags_1}) type_1]))) (try.else false)))) (_.cover [/.tags_of] - (|> (/.tags_of [tag_module name_1]) + (|> (/.tags_of [label_module name_1]) (/.result expected_lux) - (try#each (# (maybe.equivalence (list.equivalence symbol.equivalence)) = {.#Some (list#each (|>> [tag_module]) {.#Item tags_1})})) + (try#each (# (maybe.equivalence (list.equivalence symbol.equivalence)) = {.#Some (list#each (|>> [label_module]) {.#Item tags_1})})) (try.else false))) + (_.cover [/.tag] + (|> {.#Item tags_0} + list.enumeration + (list.every? (function (_ [expected_index label]) + (|> [label_module label] + /.tag + (/.result expected_lux) + (!expect (^multi {try.#Success [actual_index actual_tags actual_type]} + (let [correct_index! + (n.= expected_index + actual_index) + + correct_tags! + (# (list.equivalence symbol.equivalence) = + (list#each (|>> [label_module]) {.#Item tags_0}) + actual_tags) + + correct_type! + (type#= type_0 + actual_type)] + (and correct_index! + correct_tags! + correct_type!)))) + ))))) (_.cover [/.slot] (|> {.#Item tags_1} list.enumeration - (list.every? (function (_ [expected_index tag]) - (|> [tag_module tag] + (list.every? (function (_ [expected_index label]) + (|> [label_module label] /.slot (/.result expected_lux) (!expect (^multi {try.#Success [actual_index actual_tags actual_type]} @@ -723,7 +764,7 @@ correct_tags! (# (list.equivalence symbol.equivalence) = - (list#each (|>> [tag_module]) {.#Item tags_1}) + (list#each (|>> [label_module]) {.#Item tags_1}) actual_tags) correct_type! @@ -943,8 +984,9 @@ ..context_related ..definition_related ..search_related - ..tags_related ..locals_related + (_.for [.Label] + ..label_related) )) /location.test diff --git a/stdlib/source/test/lux/tool.lux b/stdlib/source/test/lux/tool.lux index 761192245..c60d3ba2d 100644 --- a/stdlib/source/test/lux/tool.lux +++ b/stdlib/source/test/lux/tool.lux @@ -20,7 +20,8 @@ ]] ["[1][0]" meta "_" ["[1]/[0]" archive "_" - ["[1]/[0]" signature]]] + ["[1]/[0]" signature] + ["[1]/[0]" key]]] ]]) (def: .public test @@ -33,6 +34,7 @@ /analysis/composite.test /analysis/pattern.test /meta/archive/signature.test + /meta/archive/key.test ... /syntax.test ... /analysis.test ... /synthesis.test diff --git a/stdlib/source/test/lux/tool/compiler/meta/archive/key.lux b/stdlib/source/test/lux/tool/compiler/meta/archive/key.lux new file mode 100644 index 000000000..45d29931d --- /dev/null +++ b/stdlib/source/test/lux/tool/compiler/meta/archive/key.lux @@ -0,0 +1,27 @@ +(.using + [library + [lux "*" + ["_" test {"+" Test}] + [abstract + [monad {"+" do}]] + [math + ["[0]" random]]]] + [\\library + ["[0]" /]] + ["[0]" // "_" + ["[1][0]" signature]]) + +(def: .public test + Test + (<| (_.covering /._) + (_.for [/.Key]) + (do random.monad + [expected //signature.random + document random.nat] + ($_ _.and + (_.cover [/.key /.signature] + (|> document + (/.key expected) + /.signature + (same? expected))) + )))) |