diff options
Diffstat (limited to 'stdlib/source/test')
13 files changed, 244 insertions, 50 deletions
diff --git a/stdlib/source/test/lux/macro.lux b/stdlib/source/test/lux/macro.lux index ef7463d4e..f2e29ec1a 100644 --- a/stdlib/source/test/lux/macro.lux +++ b/stdlib/source/test/lux/macro.lux @@ -66,9 +66,10 @@ current_module (symbol.module (symbol .._))]] (in [seed symbol_prefix - [.#info [.#target "" + [.#info [.#target "" .#version "" - .#mode {.#Build}] + .#mode {.#Build} + .#configuration (list)] .#source [location.dummy 0 ""] .#location location.dummy .#current_module {.#Some current_module} diff --git a/stdlib/source/test/lux/macro/syntax/definition.lux b/stdlib/source/test/lux/macro/syntax/definition.lux index 82fc97e3e..faf667534 100644 --- a/stdlib/source/test/lux/macro/syntax/definition.lux +++ b/stdlib/source/test/lux/macro/syntax/definition.lux @@ -34,9 +34,10 @@ )) (def: compiler - [.#info [.#target "FAKE" + [.#info [.#target "FAKE" .#version "0.0.0" - .#mode {.#Build}] + .#mode {.#Build} + .#configuration (list)] .#source [location.dummy 0 ""] .#location location.dummy .#current_module {.#None} diff --git a/stdlib/source/test/lux/meta.lux b/stdlib/source/test/lux/meta.lux index 914e02d92..871cc155c 100644 --- a/stdlib/source/test/lux/meta.lux +++ b/stdlib/source/test/lux/meta.lux @@ -32,7 +32,9 @@ ["[0]" /]] ["[0]" / "_" ["[1][0]" location] - ["[1][0]" symbol]]) + ["[1][0]" symbol] + ["[1][0]" configuration] + ["[1][0]" version]]) (template: (!expect <pattern> <value>) [(case <value> @@ -50,9 +52,10 @@ expected_seed random.nat expected random.nat dummy (random.only (|>> (n.= expected) not) random.nat) - .let [expected_lux [.#info [.#target target + .let [expected_lux [.#info [.#target target .#version version - .#mode {.#Build}] + .#mode {.#Build} + .#configuration (list)] .#source [location.dummy 0 source_code] .#location location.dummy .#current_module {.#Some expected_current_module} @@ -98,9 +101,10 @@ expected random.nat dummy (random.only (|>> (n.= expected) not) random.nat) expected_error (random.ascii/upper 1) - .let [expected_lux [.#info [.#target target + .let [expected_lux [.#info [.#target target .#version version - .#mode {.#Build}] + .#mode {.#Build} + .#configuration (list)] .#source [location.dummy 0 source_code] .#location location.dummy .#current_module {.#Some expected_current_module} @@ -203,9 +207,10 @@ expected_module] [imported_module_name imported_module]) - expected_lux [.#info [.#target target + expected_lux [.#info [.#target target .#version version - .#mode {.#Build}] + .#mode {.#Build} + .#configuration (list)] .#source [location.dummy 0 source_code] .#location location.dummy .#current_module {.#Some expected_current_module} @@ -304,9 +309,10 @@ .let [type_context [.#ex_counter 0 .#var_counter 0 .#var_bindings (list)] - expected_lux [.#info [.#target target + expected_lux [.#info [.#target target .#version version - .#mode {.#Build}] + .#mode {.#Build} + .#configuration (list)] .#source [location.dummy 0 source_code] .#location expected_location .#current_module {.#Some expected_current_module} @@ -382,9 +388,10 @@ (list)))] [current_globals macro_globals - [.#info [.#target "" + [.#info [.#target "" .#version "" - .#mode {.#Build}] + .#mode {.#Build} + .#configuration (list)] .#source [location.dummy 0 ""] .#location location.dummy .#current_module {.#Some expected_current_module} @@ -497,9 +504,10 @@ (list)))] [current_globals macro_globals - [.#info [.#target "" + [.#info [.#target "" .#version "" - .#mode {.#Build}] + .#mode {.#Build} + .#configuration (list)] .#source [location.dummy 0 ""] .#location location.dummy .#current_module {.#Some expected_current_module} @@ -670,9 +678,10 @@ expected_lux (: Lux - [.#info [.#target "" + [.#info [.#target "" .#version "" - .#mode {.#Build}] + .#mode {.#Build} + .#configuration (list)] .#source [location.dummy 0 ""] .#location location.dummy .#current_module {.#Some current_module} @@ -821,9 +830,10 @@ .#mappings (list)]])] .let [expected_lux (: Lux - [.#info [.#target "" + [.#info [.#target "" .#version "" - .#mode {.#Build}] + .#mode {.#Build} + .#configuration (list)] .#source [location.dummy 0 ""] .#location location.dummy .#current_module {.#Some current_module} @@ -933,9 +943,10 @@ expected random.nat dummy (random.only (|>> (n.= expected) not) random.nat) expected_location ..random_location - .let [expected_lux [.#info [.#target target + .let [expected_lux [.#info [.#target target .#version version - .#mode {.#Build}] + .#mode {.#Build} + .#configuration (list)] .#source [expected_location 0 source_code] .#location expected_location .#current_module {.#Some expected_current_module} @@ -991,4 +1002,6 @@ /location.test /symbol.test + /configuration.test + /version.test ))) diff --git a/stdlib/source/test/lux/meta/configuration.lux b/stdlib/source/test/lux/meta/configuration.lux new file mode 100644 index 000000000..9776472d5 --- /dev/null +++ b/stdlib/source/test/lux/meta/configuration.lux @@ -0,0 +1,90 @@ +(.using + [library + [lux "*" + ["_" test {"+" Test}] + ["[0]" meta] + [abstract + [monad {"+" do}] + [\\specification + ["$[0]" equivalence] + ["$[0]" monoid]]] + [control + ["[0]" try ("[1]#[0]" functor)] + ["[0]" exception] + ["<>" parser + ["<[0]>" text] + ["<[0]>" code]]] + [data + ["[0]" text] + [collection + ["[0]" list]]] + ["[0]" macro + [syntax {"+" syntax:}] + ["[0]" code]] + [math + ["[0]" random {"+" Random} ("[1]#[0]" monad)]]]] + [\\library + ["[0]" /]]) + +(def: .public (random amount) + (-> Nat (Random /.Configuration)) + (case amount + 0 (random#in /.empty) + _ (do [! random.monad] + [feature (random.ascii/upper amount) + value (random.ascii/lower amount)] + (# ! each (|>> (list& [feature value])) + (random (-- amount)))))) + +(syntax: (failure [it <code>.any]) + (function (_ lux) + (case (macro.expansion it lux) + {try.#Failure error} + {try.#Success [lux (list (code.text error))]} + + {try.#Success _} + {try.#Failure ""}))) + +(def: .public test + Test + (<| (_.covering /._) + (_.for [/.Configuration]) + (do [! random.monad] + [expected (..random 5)] + ($_ _.and + (_.for [/.equivalence] + ($equivalence.spec /.equivalence (..random 5))) + (_.for [/.monoid] + ($monoid.spec /.equivalence /.monoid (..random 5))) + + (_.cover [/.empty] + (list.empty? /.empty)) + (_.cover [/.format /.parser] + (|> expected + /.format + (<text>.result /.parser) + (try#each (# /.equivalence = expected)) + (try.else false))) + (_.cover [/.for] + (and (and (/.for [["left" "<<<" + "right" ">>>"] + true] + false) + (/.for [["left" "<<<"] + true] + false) + (/.for [["right" ">>>"] + true] + false)) + (and (/.for [["yolo" ""] + false] + true) + (/.for [["left" "yolo"] + false] + true)))) + (_.cover [/.invalid] + (and (text.contains? (value@ exception.#label /.invalid) + (..failure (/.for []))) + (text.contains? (value@ exception.#label /.invalid) + (..failure (/.for [["left" "yolo"] false]))))) + )))) diff --git a/stdlib/source/test/lux/meta/version.lux b/stdlib/source/test/lux/meta/version.lux new file mode 100644 index 000000000..a279158ab --- /dev/null +++ b/stdlib/source/test/lux/meta/version.lux @@ -0,0 +1,55 @@ +(.using + [library + [lux "*" + ["_" test {"+" Test}] + ["[0]" static] + ["[0]" meta] + [abstract + [monad {"+" do}]] + [control + ["[0]" try] + ["[0]" exception] + [parser + ["<[0]>" code]]] + [data + ["[0]" text]] + ["[0]" macro + [syntax {"+" syntax:}] + ["[0]" code]] + [math + ["[0]" random] + [number + ["n" nat]]]]] + [\\library + ["[0]" /]]) + +(syntax: (failure [it <code>.any]) + (function (_ lux) + (case (macro.expansion it lux) + {try.#Failure error} + {try.#Success [lux (list (code.text error))]} + + {try.#Success _} + {try.#Failure ""}))) + +(def: .public test + Test + (<| (_.covering /._) + (with_expansions [<current> (/.current) + <fake> (static.random code.text (random.ascii/lower 1))]) + ($_ _.and + (_.cover [/.latest] + (n.> 0 /.latest)) + (_.cover [/.current] + (not (text.empty? (/.current)))) + (_.cover [/.for] + (and (/.for [<current> true] + false) + (/.for [<fake> false] + true))) + (_.cover [/.invalid] + (and (text.contains? (value@ exception.#label /.invalid) + (..failure (/.for []))) + (text.contains? (value@ exception.#label /.invalid) + (..failure (/.for [<fake> false]))))) + ))) 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 75f0d5d1c..ee058760a 100644 --- a/stdlib/source/test/lux/tool/compiler/language/lux/analysis.lux +++ b/stdlib/source/test/lux/tool/compiler/language/lux/analysis.lux @@ -23,7 +23,10 @@ [math ["[0]" random {"+" Random} ("[1]#[0]" monad)] [number - ["f" frac]]]]] + ["f" frac]]] + [meta + ["[0]" configuration "_" + ["$[1]" \\test]]]]] ["[0]" / "_" ["[1][0]" complex] ["[1][0]" inference] @@ -249,10 +252,11 @@ expected_error (random.ascii/lower 10) location/0 /location.random location/1 /location.random + configuration ($configuration.random 5) .let [state/0 (with@ .#location location/0 - (/.state (/.info version/0 host/0))) + (/.state (/.info version/0 host/0 configuration))) state/1 (with@ .#location location/1 - (/.state (/.info version/1 host/1)))]] + (/.state (/.info version/1 host/1 configuration)))]] ($_ _.and (_.cover [/.set_state] (|> (do phase.monad @@ -330,18 +334,20 @@ expected_file (random.ascii/lower 12) expected_code (random.ascii/lower 13) + configuration ($configuration.random 5) .let [state (with@ .#location location - (/.state (/.info version host)))]] + (/.state (/.info version host configuration)))]] ($_ _.and (_.cover [/.info] - (let [it (/.info version host)] + (let [it (/.info version host configuration)] (and (text#= (version.format version) (value@ .#version it)) (same? host (value@ .#target it)) - (..tagged? .#Build (value@ .#mode it))))) + (..tagged? .#Build (value@ .#mode it)) + (same? configuration (value@ .#configuration it))))) (_.cover [/.state] - (let [info (/.info version host) + (let [info (/.info version host configuration) it (/.state info)] (and (same? info (value@ .#info it)) diff --git a/stdlib/source/test/lux/tool/compiler/language/lux/analysis/inference.lux b/stdlib/source/test/lux/tool/compiler/language/lux/analysis/inference.lux index 3eec3a5b4..63038413d 100644 --- a/stdlib/source/test/lux/tool/compiler/language/lux/analysis/inference.lux +++ b/stdlib/source/test/lux/tool/compiler/language/lux/analysis/inference.lux @@ -22,6 +22,8 @@ ["n" nat]]] [meta ["[0]" symbol "_" + ["$[1]" \\test]] + ["[0]" configuration "_" ["$[1]" \\test]]] ["[0]" type ("[1]#[0]" equivalence) ["[0]" check {"+" Check}]]]] @@ -56,8 +58,9 @@ (Random Lux) (do random.monad [version random.nat - host (random.ascii/lower 1)] - (in (//.state (//.info version host))))) + host (random.ascii/lower 1) + configuration ($configuration.random 5)] + (in (//.state (//.info version host configuration))))) (def: primitive (Random Type) diff --git a/stdlib/source/test/lux/tool/compiler/language/lux/analysis/macro.lux b/stdlib/source/test/lux/tool/compiler/language/lux/analysis/macro.lux index b976dab87..d3f1ff62d 100644 --- a/stdlib/source/test/lux/tool/compiler/language/lux/analysis/macro.lux +++ b/stdlib/source/test/lux/tool/compiler/language/lux/analysis/macro.lux @@ -2,7 +2,6 @@ [library [lux "*" ["_" test {"+" Test}] - ["[0]" meta] [abstract [monad {"+" do}] [\\specification @@ -22,7 +21,10 @@ [math ["[0]" random {"+" Random} ("[1]#[0]" monad)] [number - ["n" nat]]]]] + ["n" nat]]] + ["[0]" meta + ["[0]" configuration "_" + ["$[1]" \\test]]]]] ["$" /////// "_" [macro ["[1][0]" code]] @@ -36,8 +38,9 @@ (Random Lux) (do random.monad [version random.nat - host (random.ascii/lower 1)] - (in (//.state (//.info version host))))) + host (random.ascii/lower 1) + configuration ($configuration.random 5)] + (in (//.state (//.info version host configuration))))) (def: (expander macro inputs state) /.Expander diff --git a/stdlib/source/test/lux/tool/compiler/language/lux/analysis/module.lux b/stdlib/source/test/lux/tool/compiler/language/lux/analysis/module.lux index d5cc7e0b8..69e7970f8 100644 --- a/stdlib/source/test/lux/tool/compiler/language/lux/analysis/module.lux +++ b/stdlib/source/test/lux/tool/compiler/language/lux/analysis/module.lux @@ -2,7 +2,6 @@ [library [lux "*" ["_" test {"+" Test}] - ["[0]" meta] [abstract ["[0]" monad {"+" do}]] [control @@ -18,7 +17,10 @@ [math ["[0]" random {"+" Random}] [number - ["n" nat]]]]] + ["n" nat]]] + ["[0]" meta + ["[0]" configuration "_" + ["$[1]" \\test]]]]] [\\library ["[0]" / ["/[1]" // @@ -32,8 +34,9 @@ (Random Lux) (do random.monad [version random.nat - host (random.ascii/lower 1)] - (in (//.state (//.info version host))))) + host (random.ascii/lower 1) + configuration ($configuration.random 5)] + (in (//.state (//.info version host configuration))))) (def: primitive (Random Type) diff --git a/stdlib/source/test/lux/tool/compiler/language/lux/analysis/type.lux b/stdlib/source/test/lux/tool/compiler/language/lux/analysis/type.lux index 867ef7e5a..a5f1b5797 100644 --- a/stdlib/source/test/lux/tool/compiler/language/lux/analysis/type.lux +++ b/stdlib/source/test/lux/tool/compiler/language/lux/analysis/type.lux @@ -11,6 +11,9 @@ ["[0]" product]] [math ["[0]" random {"+" Random}]] + [meta + ["[0]" configuration "_" + ["$[1]" \\test]]] ["[0]" type ("[1]#[0]" equivalence) ["[0]" check]]]] [\\library @@ -27,8 +30,9 @@ (Random Lux) (do random.monad [version random.nat - host (random.ascii/lower 1)] - (in (//.state (//.info version host))))) + host (random.ascii/lower 1) + configuration ($configuration.random 5)] + (in (//.state (//.info version host configuration))))) (def: primitive (Random Type) diff --git a/stdlib/source/test/lux/tool/compiler/language/lux/phase/analysis/complex.lux b/stdlib/source/test/lux/tool/compiler/language/lux/phase/analysis/complex.lux index 21813bb01..e7f6a5093 100644 --- a/stdlib/source/test/lux/tool/compiler/language/lux/phase/analysis/complex.lux +++ b/stdlib/source/test/lux/tool/compiler/language/lux/phase/analysis/complex.lux @@ -26,6 +26,8 @@ ["f" frac]]] [meta ["[0]" symbol + ["$[1]" \\test]] + ["[0]" configuration "_" ["$[1]" \\test]]] ["[0]" type ("[1]#[0]" equivalence) ["[0]" check]]]] @@ -61,8 +63,9 @@ (Random Lux) (do random.monad [version random.nat - host (random.ascii/lower 1)] - (in (//analysis.state (//analysis.info version host))))) + host (random.ascii/lower 1) + configuration ($configuration.random 5)] + (in (//analysis.state (//analysis.info version host configuration))))) (def: primitive (Random Type) diff --git a/stdlib/source/test/lux/tool/compiler/language/lux/phase/analysis/simple.lux b/stdlib/source/test/lux/tool/compiler/language/lux/phase/analysis/simple.lux index 45c22f1ec..86f813b1d 100644 --- a/stdlib/source/test/lux/tool/compiler/language/lux/phase/analysis/simple.lux +++ b/stdlib/source/test/lux/tool/compiler/language/lux/phase/analysis/simple.lux @@ -11,7 +11,10 @@ [data ["[0]" product]] [math - ["[0]" random]]]] + ["[0]" random]] + [meta + ["[0]" configuration "_" + ["$[1]" \\test]]]]] [\\library ["[0]" / [/// @@ -75,7 +78,8 @@ [version random.nat host (random.ascii/lower 1) module (random.ascii/lower 2) - .let [state (/analysis.state (/analysis.info version host))]] + configuration ($configuration.random 5) + .let [state (/analysis.state (/analysis.info version host configuration))]] (`` ($_ _.and (_.cover [/.unit] (..analysis state module .Any /.unit diff --git a/stdlib/source/test/lux/tool/compiler/meta/cli.lux b/stdlib/source/test/lux/tool/compiler/meta/cli.lux index 15441533e..b90b8a0b3 100644 --- a/stdlib/source/test/lux/tool/compiler/meta/cli.lux +++ b/stdlib/source/test/lux/tool/compiler/meta/cli.lux @@ -20,6 +20,8 @@ ["n" nat]]] [meta ["[0]" symbol "_" + ["$[1]" \\test]] + ["[0]" configuration ("[1]#[0]" equivalence) ["$[1]" \\test]]]]] [\\library ["[0]" / @@ -40,13 +42,15 @@ target (random.ascii/lower 4) module (random.ascii/lower 5) compilers (random.list amount $/compiler.random) + configuration ($configuration.random 5) .let [compilation' ($_ list#composite (list#conjoint (list#each (|>> (list "--host_dependency")) host_dependencies)) (list#conjoint (list#each (|>> (list "--library")) libraries)) (list#conjoint (list#each (|>> /compiler.format (list "--compiler")) compilers)) (list#conjoint (list#each (|>> (list "--source")) sources)) - (list "--target" target) - (list "--module" module)) + (list "--target" target + "--module" module + "--configuration" (configuration.format configuration))) export ($_ list#composite (list#conjoint (list#each (|>> (list "--source")) sources)) (list "--target" target))]] @@ -72,6 +76,7 @@ [/.Source /.#sources (list#= sources)] [/.Target /.#target (same? target)] [/.Module /.#module (same? module)] + [configuration.Configuration /.#configuration (configuration#= configuration)] )) ))) (_.cover [/.Interpretation] @@ -93,6 +98,7 @@ [/.#sources (list#= sources)] [/.#target (same? target)] [/.#module (same? module)] + [/.#configuration (configuration#= configuration)] ))))) (_.cover [/.Export] (`` (and (~~ (template [<side> <?>] @@ -119,13 +125,15 @@ /.#compilers compilers /.#sources sources /.#target target - /.#module module]}] + /.#module module + /.#configuration configuration]}] [{/.#Interpretation [/.#host_dependencies host_dependencies /.#libraries libraries /.#compilers compilers /.#sources sources /.#target target - /.#module module]}] + /.#module module + /.#configuration configuration]}] [{/.#Export [sources target]}] ))))) |