From 7065801a9ad1724c6a82e9803c218b2981bc59b3 Mon Sep 17 00:00:00 2001 From: Eduardo Julian Date: Sun, 6 Feb 2022 22:07:51 -0400 Subject: Fixes for JVM interop. --- stdlib/source/test/lux/control/parser/code.lux | 79 +++++++++++++--------- .../tool/compiler/language/lux/analysis/scope.lux | 20 +++--- stdlib/source/test/lux/tool/compiler/meta/cli.lux | 23 +++---- .../test/lux/tool/compiler/meta/cli/compiler.lux | 48 +++++++++++++ 4 files changed, 115 insertions(+), 55 deletions(-) create mode 100644 stdlib/source/test/lux/tool/compiler/meta/cli/compiler.lux (limited to 'stdlib/source/test') diff --git a/stdlib/source/test/lux/control/parser/code.lux b/stdlib/source/test/lux/control/parser/code.lux index d4fac4fa6..d851a79d1 100644 --- a/stdlib/source/test/lux/control/parser/code.lux +++ b/stdlib/source/test/lux/control/parser/code.lux @@ -1,31 +1,31 @@ (.using - [library - [lux "*" - ["_" test {"+" Test}] - [abstract - [monad {"+" do}]] - [control - ["[0]" function] - ["[0]" try] - ["<>" parser]] - [data - ["[0]" bit] - ["[0]" text] - [collection - ["[0]" list]]] - [macro - ["[0]" code]] - [math - ["[0]" random {"+" Random}] - [number - ["[0]" nat] - ["[0]" int] - ["[0]" rev] - ["[0]" frac]]] - [meta - ["[0]" symbol]]]] - [\\library - ["[0]" /]]) + [library + [lux "*" + ["_" test {"+" Test}] + [abstract + [monad {"+" do}]] + [control + ["[0]" function] + ["[0]" try] + ["<>" parser]] + [data + ["[0]" bit] + ["[0]" text] + [collection + ["[0]" list]]] + [macro + ["[0]" code]] + [math + ["[0]" random {"+" Random} ("[1]#[0]" functor)] + [number + ["[0]" nat] + ["[0]" int] + ["[0]" rev] + ["[0]" frac]]] + [meta + ["[0]" symbol]]]] + [\\library + ["[0]" /]]) (template: (!expect ) [(case @@ -35,10 +35,24 @@ _ false)]) -(def: random_symbol +(def: local_symbol + (Random Text) + (random.ascii/lower 1)) + +(def: global_symbol + (Random Symbol) + ($_ random.and + (random.ascii/lower 1) + (random.ascii/lower 1) + )) + +(def: any_symbol (Random Symbol) - (random.and (random.unicode 1) - (random.unicode 1))) + ($_ random.either + (random#each (|>> [""]) + ..local_symbol) + ..global_symbol + )) (def: .public test Test @@ -75,8 +89,9 @@ [/.rev /.rev! random.rev code.rev rev.equivalence] [/.frac /.frac! random.safe_frac code.frac frac.equivalence] [/.text /.text! (random.unicode 1) code.text text.equivalence] - [/.symbol /.symbol! ..random_symbol code.symbol symbol.equivalence] - [/.local_symbol /.local_symbol! (random.unicode 1) code.local_symbol text.equivalence] + [/.local_symbol /.local_symbol! ..local_symbol code.local_symbol text.equivalence] + [/.global_symbol /.global_symbol! ..global_symbol code.symbol symbol.equivalence] + [/.symbol /.symbol! ..any_symbol code.symbol symbol.equivalence] )) (~~ (template [ ] [(do [! random.monad] diff --git a/stdlib/source/test/lux/tool/compiler/language/lux/analysis/scope.lux b/stdlib/source/test/lux/tool/compiler/language/lux/analysis/scope.lux index dbd1f83de..3338cc9a2 100644 --- a/stdlib/source/test/lux/tool/compiler/language/lux/analysis/scope.lux +++ b/stdlib/source/test/lux/tool/compiler/language/lux/analysis/scope.lux @@ -59,8 +59,8 @@ type/0 ($type.random 0) type/1 ($type.random 0)] ($_ _.and - (_.cover [/.find] - (|> (/.find name/0) + (_.cover [/.variable] + (|> (/.variable name/0) /.with (//phase.result state) (try#each (|>> product.right @@ -69,7 +69,7 @@ (try.else false))) (_.cover [/.with_local] (|> (/.with_local [name/0 type/0] - (/.find name/0)) + (/.variable name/0)) /.with (//phase.result state) (try#each (|>> product.right @@ -81,12 +81,12 @@ [register/0 /.next]) (/.with_local [name/0 type/0]) (do ! - [var/0 (/.find name/0)]) + [var/0 (/.variable name/0)]) (do ! [register/1 /.next]) (/.with_local [name/1 type/1]) (do ! - [var/1 (/.find name/1)]) + [var/1 (/.variable name/1)]) (in (do maybe.monad [var/0 var/0 var/1 var/1] @@ -138,8 +138,8 @@ (|> (<| /.with (/.with_local [name/0 type/0]) (do //phase.monad - [var/0' (/.find name/0) - [scope/1 var/0''] (/.with (/.find name/0))] + [var/0' (/.variable name/0) + [scope/1 var/0''] (/.with (/.variable name/0))] (<| //phase.lifted try.of_maybe (do maybe.monad @@ -174,7 +174,7 @@ (/.with_local [name/0 type/0]) (/.with_local [name/1 type/1]) (do ! - [[scope/1 _] (/.with (/.find name/0))] + [[scope/1 _] (/.with (/.variable name/0))] (in [register/0 (/.environment scope/1)]))) (//phase.result state) (try#each (function (_ [_ [register/0 environment]]) @@ -190,8 +190,8 @@ (/.with_local [name/1 type/1]) (do [! //phase.monad] [[scope/1 _] (/.with (do ! - [_ (/.find name/1) - _ (/.find name/0)] + [_ (/.variable name/1) + _ (/.variable name/0)] (in [])))] (in [register/0 register/1 (/.environment scope/1)]))) (//phase.result state) diff --git a/stdlib/source/test/lux/tool/compiler/meta/cli.lux b/stdlib/source/test/lux/tool/compiler/meta/cli.lux index 5a128b0ff..15441533e 100644 --- a/stdlib/source/test/lux/tool/compiler/meta/cli.lux +++ b/stdlib/source/test/lux/tool/compiler/meta/cli.lux @@ -22,15 +22,10 @@ ["[0]" symbol "_" ["$[1]" \\test]]]]] [\\library - ["[0]" /]]) - -(def: random_compiler - (Random /.Compiler) - (do [! random.monad] - [definition ($symbol.random 1 1) - amount (# ! each (n.% 5) random.nat) - parameters (random.list amount (random.ascii/lower 2))] - (in [definition parameters]))) + ["[0]" / + ["[1][0]" compiler {"+" Compiler}]]] + ["$[0]" / "_" + ["[1][0]" compiler]]) (def: .public test Test @@ -44,11 +39,11 @@ libraries (random.list amount (random.ascii/lower 3)) target (random.ascii/lower 4) module (random.ascii/lower 5) - compilers (random.list amount ..random_compiler) + compilers (random.list amount $/compiler.random) .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 (|>> /compiler.format (list "--compiler")) compilers)) (list#conjoint (list#each (|>> (list "--source")) sources)) (list "--target" target) (list "--module" module)) @@ -73,7 +68,7 @@ [/.Host_Dependency /.#host_dependencies (list#= host_dependencies)] [/.Library /.#libraries (list#= libraries)] - [/.Compiler /.#compilers (# (list.equivalence /.compiler_equivalence) = compilers)] + [/compiler.Compiler /.#compilers (# (list.equivalence /compiler.equivalence) = compilers)] [/.Source /.#sources (list#= sources)] [/.Target /.#target (same? target)] [/.Module /.#module (same? module)] @@ -94,7 +89,7 @@ [/.#host_dependencies (list#= host_dependencies)] [/.#libraries (list#= libraries)] - [/.#compilers (# (list.equivalence /.compiler_equivalence) = compilers)] + [/.#compilers (# (list.equivalence /compiler.equivalence) = compilers)] [/.#sources (list#= sources)] [/.#target (same? target)] [/.#module (same? module)] @@ -133,4 +128,6 @@ /.#module module]}] [{/.#Export [sources target]}] ))))) + + $/compiler.test )))) diff --git a/stdlib/source/test/lux/tool/compiler/meta/cli/compiler.lux b/stdlib/source/test/lux/tool/compiler/meta/cli/compiler.lux new file mode 100644 index 000000000..69a9db048 --- /dev/null +++ b/stdlib/source/test/lux/tool/compiler/meta/cli/compiler.lux @@ -0,0 +1,48 @@ +(.using + [library + [lux "*" + ["_" test {"+" Test}] + [abstract + [monad {"+" do}] + [\\specification + ["$[0]" equivalence]]] + [control + ["[0]" try ("[1]#[0]" functor)] + ["<>" parser + ["<[0]>" text]]] + [math + ["[0]" random {"+" Random}] + [number + ["n" nat]]] + [meta + ["[0]" symbol "_" + ["$[1]" \\test]]]]] + [\\library + ["[0]" /]]) + +(def: .public random + (Random /.Compiler) + (do [! random.monad] + [definition ($symbol.random 1 1) + amount (# ! each (n.% 5) random.nat) + parameters (random.list amount (random.ascii/lower 2))] + (in [/.#definition definition + /.#parameters parameters]))) + +(def: .public test + Test + (<| (_.covering /._) + (_.for [/.Compiler]) + (do [! random.monad] + [expected ..random] + ($_ _.and + (_.for [/.equivalence] + ($equivalence.spec /.equivalence ..random)) + + (_.cover [/.format /.parser] + (|> expected + /.format + (.result /.parser) + (try#each (# /.equivalence = expected)) + (try.else false))) + )))) -- cgit v1.2.3