diff options
author | Eduardo Julian | 2022-01-07 03:15:45 -0400 |
---|---|---|
committer | Eduardo Julian | 2022-01-07 03:15:45 -0400 |
commit | 8665dee72f0e2be39ef1c2d15f733bb7b30b6a73 (patch) | |
tree | 9f2c52d9f0ff41ef3f9385e678f0c74d1bfdf216 /stdlib/source/test | |
parent | d0f33f630aedb67d2888e32ceb7bc237839b274e (diff) |
Fixes for the pure-Lux JVM compiler machinery. [Part 3]
Diffstat (limited to 'stdlib/source/test')
-rw-r--r-- | stdlib/source/test/lux/target/ruby.lux | 59 | ||||
-rw-r--r-- | stdlib/source/test/lux/tool.lux | 32 | ||||
-rw-r--r-- | stdlib/source/test/lux/tool/compiler/language/lux/analysis/primitive.lux | 44 |
3 files changed, 117 insertions, 18 deletions
diff --git a/stdlib/source/test/lux/target/ruby.lux b/stdlib/source/test/lux/target/ruby.lux index 87e781ebc..86a817703 100644 --- a/stdlib/source/test/lux/target/ruby.lux +++ b/stdlib/source/test/lux/target/ruby.lux @@ -11,7 +11,8 @@ ["[0]" try {"+" Try} ("[1]#[0]" functor)]] [data ["[0]" bit ("[1]#[0]" equivalence)] - ["[0]" text ("[1]#[0]" equivalence)] + ["[0]" text ("[1]#[0]" equivalence) + ["%" format {"+" format}]] [collection ["[0]" list ("[1]#[0]" functor)]]] ["[0]" math @@ -20,7 +21,14 @@ ["n" nat] ["i" int] ["f" frac] - ["[0]" i64]]]]] + ["[0]" i64]]] + [tool + [compiler + [meta + ["[0]" packager "_" + ["[1]" ruby]]]]] + [world + ["[0]" file]]]] [\\library ["[0]" /]]) @@ -580,15 +588,58 @@ ..test/location) ))) +(def: test|global + Test + ($_ _.and + (_.cover [/.script_name] + (expression (let [file (format (# file.default separator) packager.main_file)] + (|>> (:as Text) + (predicate.or (text.ends_with? file) + (text#= "<script>")))) + /.script_name)) + (_.cover [/.input_record_separator] + (expression (|>> (:as Text) + (text#= text.\n)) + /.input_record_separator)) + (_.cover [/.output_record_separator] + (|> /.output_record_separator + /.code + ..eval + (try#each (function (_ it) + (case it + {.#None} true + {.#Some _} false))) + (try.else false))) + )) + +(def: random_expression + (Random /.Expression) + (let [literal (: (Random /.Literal) + ($_ random.either + (random#each /.bool random.bit) + (random#each /.float random.frac) + (random#each /.int random.int) + (random#each /.string (random.ascii/lower 5)) + ))] + ($_ random.either + literal + ))) + (def: .public test Test (do [! random.monad] - [] + [expected ..random_expression] (<| (_.covering /._) - (_.for [/.Code /.code]) + (_.for [/.Code]) ($_ _.and + (_.cover [/.code /.manual] + (|> (/.manual (/.code expected)) + (: /.Expression) + (# /.code_equivalence = expected))) (_.for [/.Expression] ..test|expression) (_.for [/.Statement] ..test|statement) + (_.for [/.GVar] + ..test|global) )))) diff --git a/stdlib/source/test/lux/tool.lux b/stdlib/source/test/lux/tool.lux index ef83286b4..f7734328b 100644 --- a/stdlib/source/test/lux/tool.lux +++ b/stdlib/source/test/lux/tool.lux @@ -1,24 +1,28 @@ (.using - [library - [lux "*" - ["_" test {"+" Test}]]] - ["[0]" / "_" - [compiler - ["[1][0]" arity] - ["[1][0]" reference] - ... [language - ... [lux - ... ["[1][0]" syntax] - ... [phase - ... ["[1][0]" analysis] - ... ["[1][0]" synthesis]]]] - ]]) + [library + [lux "*" + ["_" test {"+" Test}]]] + ["[0]" / "_" + [compiler + ["[1][0]" arity] + ["[1][0]" reference] + [language + [lux + ... ["[1][0]" syntax] + ["[1][0]" analysis "_" + ["[1]/[0]" primitive]] + ... [phase + ... ["[1][0]" analysis] + ... ["[1][0]" synthesis]] + ]] + ]]) (def: .public test Test ($_ _.and /arity.test /reference.test + /analysis/primitive.test ... /syntax.test ... /analysis.test ... /synthesis.test diff --git a/stdlib/source/test/lux/tool/compiler/language/lux/analysis/primitive.lux b/stdlib/source/test/lux/tool/compiler/language/lux/analysis/primitive.lux new file mode 100644 index 000000000..4d67a47f9 --- /dev/null +++ b/stdlib/source/test/lux/tool/compiler/language/lux/analysis/primitive.lux @@ -0,0 +1,44 @@ +(.using + [library + [lux "*" + ["_" test {"+" Test}] + [abstract + [monad {"+" do}] + [\\specification + ["$[0]" equivalence]]] + [data + ["[0]" bit ("[1]#[0]" equivalence)] + ["[0]" text ("[1]#[0]" equivalence)]] + [math + ["[0]" random {"+" Random} ("[1]#[0]" monad)] + [number + ["f" frac]]]]] + [\\library + ["[0]" /]]) + +(def: .public random + (Random /.Primitive) + ($_ random.or + (random#in []) + random.bit + random.nat + random.int + random.rev + (random.only (|>> f.not_a_number? not) random.frac) + (random.ascii/lower 5) + )) + +(def: .public test + Test + (<| (_.covering /._) + (_.for [/.Primitive]) + ($_ _.and + (_.for [/.equivalence] + ($equivalence.spec /.equivalence ..random)) + (do random.monad + [left ..random + right ..random] + (_.cover [/.format] + (bit#= (# /.equivalence = left right) + (text#= (/.format left) (/.format right))))) + ))) |