From e1af5374ba4d969f866867db47af7ecf60cc9933 Mon Sep 17 00:00:00 2001 From: Eduardo Julian Date: Sat, 15 Jan 2022 02:17:35 -0400 Subject: Fixed a logging/reporting issue for Lux/JS. --- stdlib/source/test/lux/tool.lux | 8 +- .../compiler/language/lux/analysis/pattern.lux | 4 +- .../compiler/language/lux/analysis/primitive.lux | 45 ----------- .../tool/compiler/language/lux/analysis/simple.lux | 45 +++++++++++ .../lux/tool/compiler/meta/archive/document.lux | 93 ++++++++++++++++++++++ 5 files changed, 145 insertions(+), 50 deletions(-) delete mode 100644 stdlib/source/test/lux/tool/compiler/language/lux/analysis/primitive.lux create mode 100644 stdlib/source/test/lux/tool/compiler/language/lux/analysis/simple.lux create mode 100644 stdlib/source/test/lux/tool/compiler/meta/archive/document.lux (limited to 'stdlib/source/test') diff --git a/stdlib/source/test/lux/tool.lux b/stdlib/source/test/lux/tool.lux index 79d25b75e..736c8757c 100644 --- a/stdlib/source/test/lux/tool.lux +++ b/stdlib/source/test/lux/tool.lux @@ -12,7 +12,7 @@ [lux ... ["[1][0]" syntax] ["[1][0]" analysis "_" - ["[1]/[0]" primitive] + ["[1]/[0]" simple] ["[1]/[0]" composite] ["[1]/[0]" pattern]] ... [phase @@ -22,7 +22,8 @@ ["[1][0]" meta "_" ["[1]/[0]" archive "_" ["[1]/[0]" signature] - ["[1]/[0]" key]]] + ["[1]/[0]" key] + ["[1]/[0]" document]]] ]]) (def: .public test @@ -32,11 +33,12 @@ /version.test /reference.test /phase.test - /analysis/primitive.test + /analysis/simple.test /analysis/composite.test /analysis/pattern.test /meta/archive/signature.test /meta/archive/key.test + /meta/archive/document.test ... /syntax.test ... /analysis.test ... /synthesis.test diff --git a/stdlib/source/test/lux/tool/compiler/language/lux/analysis/pattern.lux b/stdlib/source/test/lux/tool/compiler/language/lux/analysis/pattern.lux index b4ee9e9c8..7a1d4c66d 100644 --- a/stdlib/source/test/lux/tool/compiler/language/lux/analysis/pattern.lux +++ b/stdlib/source/test/lux/tool/compiler/language/lux/analysis/pattern.lux @@ -16,7 +16,7 @@ [\\library ["[0]" /]] ["[0]" // "_" - ["[1][0]" primitive] + ["[1][0]" simple] ["[1][0]" composite]]) (def: .public random @@ -24,7 +24,7 @@ (random.rec (function (_ random) ($_ random.or - //primitive.random + //simple.random (//composite.random 4 random) random.nat )))) 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 deleted file mode 100644 index 3c88cd1e5..000000000 --- a/stdlib/source/test/lux/tool/compiler/language/lux/analysis/primitive.lux +++ /dev/null @@ -1,45 +0,0 @@ -(.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))))) - ))) diff --git a/stdlib/source/test/lux/tool/compiler/language/lux/analysis/simple.lux b/stdlib/source/test/lux/tool/compiler/language/lux/analysis/simple.lux new file mode 100644 index 000000000..e7c22559f --- /dev/null +++ b/stdlib/source/test/lux/tool/compiler/language/lux/analysis/simple.lux @@ -0,0 +1,45 @@ +(.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 /.Simple) + ($_ 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 [/.Simple]) + ($_ _.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))))) + ))) diff --git a/stdlib/source/test/lux/tool/compiler/meta/archive/document.lux b/stdlib/source/test/lux/tool/compiler/meta/archive/document.lux new file mode 100644 index 000000000..749dcdd09 --- /dev/null +++ b/stdlib/source/test/lux/tool/compiler/meta/archive/document.lux @@ -0,0 +1,93 @@ +(.using + [library + [lux "*" + ["_" test {"+" Test}] + [abstract + [monad {"+" do}]] + [control + [pipe {"+" case>}] + ["[0]" try ("[1]#[0]" functor)] + ["[0]" exception] + [parser + ["<[0]>" binary]]] + [data + [format + ["[0]F" binary]]] + [math + ["[0]" random] + [number + ["[0]" nat]]]]] + [\\library + ["[0]" / + [// + ["[1][0]" signature ("[1]#[0]" equivalence)] + ["[1][0]" key]]]] + ["[0]" // "_" + ["[1][0]" signature]]) + +(def: .public test + Test + (<| (_.covering /._) + (_.for [/.Document]) + (do random.monad + [signature/0 //signature.random + signature/1 (random.only (|>> (/signature#= signature/0) not) + //signature.random) + .let [key/0 (/key.key signature/0 0) + key/1 (/key.key signature/1 0)] + expected random.nat] + ($_ _.and + (_.cover [/.document /.content] + (|> expected + (/.document key/0) + (/.content key/0) + (try#each (same? expected)) + (try.else false))) + (_.cover [/.signature] + (|> expected + (/.document key/0) + /.signature + (same? signature/0))) + (_.cover [/.marked?] + (and (|> expected + (/.document key/0) + (/.marked? key/0) + (case> {try.#Success it} true + {try.#Failure error} false)) + (|> expected + (/.document key/0) + (/.marked? key/1) + (case> {try.#Success it} false + {try.#Failure error} true)))) + (_.cover [/.invalid_signature] + (and (|> expected + (/.document key/0) + (/.content key/1) + (case> {try.#Success it} + false + + {try.#Failure error} + (exception.match? /.invalid_signature error))) + (|> expected + (/.document key/0) + (/.marked? key/1) + (case> {try.#Success it} + false + + {try.#Failure error} + (exception.match? /.invalid_signature error))))) + (_.cover [/.writer /.parser] + (|> expected + (/.document key/0) + (binaryF.result (/.writer binaryF.nat)) + (.result (/.parser .nat)) + (case> {try.#Success it} + (and (/signature#= signature/0 (/.signature it)) + (|> it + (/.content key/0) + (try#each (nat.= expected)) + (try.else false))) + + {try.#Failure error} + false))) + )))) -- cgit v1.2.3