From 54bb56a07e6d8f1e76bd447436fb721a74f09f66 Mon Sep 17 00:00:00 2001 From: Eduardo Julian Date: Sat, 5 Feb 2022 14:51:37 -0400 Subject: Updated copyright notices. --- stdlib/source/test/lux.lux | 75 ++++++++------ stdlib/source/test/lux/ffi.jvm.lux | 53 +++++++--- stdlib/source/test/lux/tool.lux | 4 +- stdlib/source/test/lux/tool/compiler/meta/cli.lux | 119 ++++++++++++++++++++++ 4 files changed, 204 insertions(+), 47 deletions(-) create mode 100644 stdlib/source/test/lux/tool/compiler/meta/cli.lux (limited to 'stdlib/source/test') diff --git a/stdlib/source/test/lux.lux b/stdlib/source/test/lux.lux index b859f456f..e8a6a482d 100644 --- a/stdlib/source/test/lux.lux +++ b/stdlib/source/test/lux.lux @@ -449,78 +449,89 @@ (template.text [ "/" ]) (template.text [ "/" "/" ]) (template.text [ "#[0]"])] - (and (~~ (template [ ] + (and (~~ (template [ ] [(with_expansions [' (macro.final )] (let [scenario (: (-> Any Bit) (function (_ _) - (case (' [']) - (^code ) - true - - _ - false)))] + ... TODO: Remove this hack once Jython is no longer being used as the Python interpreter. + (`` (for [@.python (case (' [']) + (^code [ + ("lux def" (~ [_ {.#Symbol ["" _]}]) [] #0) + (~~ (template.spliced ))]) + true + + _ + false)] + (case (' [']) + (^code [ (~~ (template.spliced ))]) + true + + _ + false)))))] (scenario [])))] [(.using [']) - [("lux def module" [])]] + ("lux def module" []) + []] [(.using [ ' "*"]) - [("lux def module" [[ ]]) - ( "*")]] + ("lux def module" [[ ]]) + [( "*")]] [(.using [ ' {"+" }]) - [("lux def module" [[ ]]) - ( {"+" })]] + ("lux def module" [[ ]]) + [( {"+" })]] [(.using [ ' {"-" }]) - [("lux def module" [[ ]]) - ( {"-" })]] + ("lux def module" [[ ]]) + [( {"-" })]] [(.using [ ' "_"]) - [("lux def module" [])]] + ("lux def module" []) + []] [(.using [' [ ']]) - [("lux def module" [[ ]]) - ( )]] + ("lux def module" [[ ]]) + [( )]] [(.using ["[0]" ' ["[0]" ']]) - [("lux def module" [[ ] - [ ]]) - ( ) + ("lux def module" [[ ] + [ ]]) + [( ) ( )]] [(.using ["[0]" ' "_" ["[1]" ']]) - [("lux def module" [[ ]]) - ( )]] + ("lux def module" [[ ]]) + [( )]] [(.using ["[0]" ' "_" ["[1]" ' "_" ["[2]" ']]]) - [("lux def module" [[ ]]) - ( )]] + ("lux def module" [[ ]]) + [( )]] [(.using [' ["[0]" ' ["[0]" ']]]) - [("lux def module" [[ ] - [ ]]) - ( ) + ("lux def module" [[ ] + [ ]]) + [( ) ( )]] [(.using ["[0]" ' [' ["[0]" <\\>']]]) - [("lux def module" [[ ] - [ <\\>]]) - ( ) + ("lux def module" [[ ] + [ <\\>]]) + [( ) ( )]] [(.using ["[0]" ' ("[1]#[0]" )]) - [("lux def module" [[ ]]) - ( ( ))]] + ("lux def module" [[ ]]) + [( ( ))]] )))))) )))))) diff --git a/stdlib/source/test/lux/ffi.jvm.lux b/stdlib/source/test/lux/ffi.jvm.lux index f77fbc54f..7684d7b96 100644 --- a/stdlib/source/test/lux/ffi.jvm.lux +++ b/stdlib/source/test/lux/ffi.jvm.lux @@ -4,11 +4,12 @@ ["_" test {"+" Test}] ["[0]" type ("[1]#[0]" equivalence)] ["[0]" meta] + ["[0]" debug] [abstract [monad {"+" do}]] [control [pipe {"+" case>}] - ["[0]" try] + ["[0]" try ("[1]#[0]" functor)] ["[0]" exception] [parser ["<[0]>" code]]] @@ -27,7 +28,10 @@ [number ["n" nat] ["i" int ("[1]#[0]" equivalence)] - ["f" frac ("[1]#[0]" equivalence)]]]]] + ["f" frac ("[1]#[0]" equivalence)]]] + [target + ["[0]" jvm "_" + ["[1]" type ("[1]#[0]" equivalence)]]]]] [\\library ["[0]" /]]) @@ -597,18 +601,39 @@ (def: for_exception Test - ($_ _.and - (_.cover [/.class_names_cannot_contain_periods] - (with_expansions [ (template.symbol ["java.lang.Float"])] - (not (expands? (/.import: ))))) - (_.cover [/.class_name_cannot_be_a_type_variable] - (and (not (expands? (/.import: (java/lang/Double a) - ["[1]::[0]" - (invalid [] (a java/lang/String))]))) - (not (expands? (/.import: java/lang/Double - ["[1]::[0]" - ([a] invalid [] (a java/lang/String))]))))) - )) + (do [! random.monad] + [var/0 (random.ascii/lower 1) + var/1 (random.ascii/lower 2) + var/2 (random.ascii/lower 3)] + ($_ _.and + (_.cover [/.class_names_cannot_contain_periods] + (with_expansions [ (template.symbol ["java.lang.Float"])] + (not (expands? (/.import: ))))) + (_.cover [/.class_name_cannot_be_a_type_variable] + (and (not (expands? (/.import: (java/lang/Double a) + ["[1]::[0]" + (invalid [] (a java/lang/String))]))) + (not (expands? (/.import: java/lang/Double + ["[1]::[0]" + ([a] invalid [] (a java/lang/String))]))))) + (_.cover [/.unknown_type_variable] + (let [type_variable ((debug.private /.type_variable) (list (jvm.var var/0) (jvm.var var/1)))] + (and (|> (list (code.local_symbol var/0)) + (.result type_variable) + (try#each (|>> (jvm#= (jvm.var var/0)))) + (try.else false)) + (|> (list (code.local_symbol var/1)) + (.result type_variable) + (try#each (|>> (jvm#= (jvm.var var/1)))) + (try.else false)) + (|> (list (code.local_symbol var/2)) + (.result type_variable) + (case> {try.#Failure error} + (exception.match? /.unknown_type_variable error) + + _ + false))))) + ))) (def: .public test (<| (_.covering /._) diff --git a/stdlib/source/test/lux/tool.lux b/stdlib/source/test/lux/tool.lux index 6fa62a7da..2291880ec 100644 --- a/stdlib/source/test/lux/tool.lux +++ b/stdlib/source/test/lux/tool.lux @@ -20,7 +20,8 @@ ... ["[1]/[0]" synthesis] ]]] ["[1][0]" meta "_" - ["[1]/[0]" archive]] + ["[1]/[0]" archive] + ["[1]/[0]" cli]] ]]) (def: .public test @@ -32,6 +33,7 @@ /phase.test /analysis.test /meta/archive.test + /meta/cli.test /phase/extension.test /phase/analysis/simple.test /phase/analysis/complex.test diff --git a/stdlib/source/test/lux/tool/compiler/meta/cli.lux b/stdlib/source/test/lux/tool/compiler/meta/cli.lux new file mode 100644 index 000000000..7c5f0266e --- /dev/null +++ b/stdlib/source/test/lux/tool/compiler/meta/cli.lux @@ -0,0 +1,119 @@ +(.using + [library + [lux "*" + ["_" test {"+" Test}] + [abstract + [monad {"+" do}]] + [control + [pipe {"+" case>}] + ["[0]" try ("[1]#[0]" functor)] + ["<>" parser + ["<[0]>" cli]]] + [data + ["[0]" product] + ["[0]" text] + [collection + ["[0]" list ("[1]#[0]" monoid monad)]]] + [math + ["[0]" random] + [number + ["n" nat]]]]] + [\\library + ["[0]" /]]) + +(def: .public test + Test + (<| (_.covering /._) + (_.for [/.Service /.service]) + (let [(^open "list#[0]") (list.equivalence text.equivalence)]) + (do [! random.monad] + [amount (# ! each (|>> (n.% 5) ++) random.nat) + sources (random.list amount (random.ascii/lower 1)) + host_dependencies (random.list amount (random.ascii/lower 2)) + libraries (random.list amount (random.ascii/lower 3)) + target (random.ascii/lower 4) + module (random.ascii/lower 5) + .let [compilation' ($_ list#composite + (list#conjoint (list#each (|>> (list "--source")) sources)) + (list#conjoint (list#each (|>> (list "--host_dependency")) host_dependencies)) + (list#conjoint (list#each (|>> (list "--library")) libraries)) + (list "--target" target) + (list "--module" module)) + export ($_ list#composite + (list#conjoint (list#each (|>> (list "--source")) sources)) + (list "--target" target))]] + ($_ _.and + (_.for [/.Compilation] + (`` ($_ _.and + (~~ (template [ ] + [(_.cover [] + (|> (list& "build" compilation') + (.result /.service) + (try#each (|>> (case> {/.#Compilation it} + (|> it + (value@ ) + ) + + _ + false))) + (try.else false)))] + + [/.Source /.#sources (list#= sources)] + [/.Host_Dependency /.#host_dependencies (list#= host_dependencies)] + [/.Library /.#libraries (list#= libraries)] + [/.Target /.#target (same? target)] + [/.Module /.#module (same? module)] + )) + ))) + (_.cover [/.Interpretation] + (`` (and (~~ (template [ ] + [(|> (list& "repl" compilation') + (.result /.service) + (try#each (|>> (case> {/.#Interpretation it} + (|> it + (value@ ) + ) + + _ + false))) + (try.else false))] + + [/.#sources (list#= sources)] + [/.#host_dependencies (list#= host_dependencies)] + [/.#libraries (list#= libraries)] + [/.#target (same? target)] + [/.#module (same? module)] + ))))) + (_.cover [/.Export] + (`` (and (~~ (template [ ] + [(|> (list& "export" export) + (.result /.service) + (try#each (|>> (case> {/.#Export it} + (|> it + + ) + + _ + false))) + (try.else false))] + + [product.left (list#= sources)] + [product.right (same? target)] + ))))) + (_.cover [/.target] + (`` (and (~~ (template [] + [(same? target (/.target ))] + + [{/.#Compilation [/.#sources sources + /.#host_dependencies host_dependencies + /.#libraries libraries + /.#target target + /.#module module]}] + [{/.#Interpretation [/.#sources sources + /.#host_dependencies host_dependencies + /.#libraries libraries + /.#target target + /.#module module]}] + [{/.#Export [sources target]}] + ))))) + )))) -- cgit v1.2.3