diff options
author | Eduardo Julian | 2023-01-16 03:14:45 -0400 |
---|---|---|
committer | Eduardo Julian | 2023-01-16 03:14:45 -0400 |
commit | a7f2679f1372f222c1610ed4d1226b1b893fcc1a (patch) | |
tree | 5743222c78bcab68b70493d54555d4b14510de09 /stdlib/source/test | |
parent | 33188f943329296ff4c19ad3fcf717194e3b237e (diff) |
Can now compile the JVM back-end using itself.
Diffstat (limited to 'stdlib/source/test')
7 files changed, 175 insertions, 57 deletions
diff --git a/stdlib/source/test/lux/math/arithmetic.lux b/stdlib/source/test/lux/math/arithmetic.lux index fea070edd..9b21d2633 100644 --- a/stdlib/source/test/lux/math/arithmetic.lux +++ b/stdlib/source/test/lux/math/arithmetic.lux @@ -36,12 +36,18 @@ (in @8) )] left power_of_two - right power_of_two] + right (random.only (|>> (= left) not) + power_of_two)] (<| (_.covering /._) (_.for [/.Arithmetic]) (all _.and (_.coverage [/.+ /.-] - (and (|> left (+ right) (- right) (= left)) + (and (= (+ left right) + (+ right left)) + (not (= (- left right) + (- right left))) + + (|> left (+ right) (- right) (= left)) (|> left (- right) (+ right) (= left)) (|> left (+ @0) (= left)) @@ -49,12 +55,17 @@ (|> left (- left) (= @0)))) (_.coverage [/.* /./] - (and (|> left (* @0) (= @0)) + (and (= (* left right) + (* right left)) + (not (= (/ left right) + (/ right left))) + + (|> left (* @0) (= @0)) + (|> left (/ left) (= @1)) (|> left (* @1) (= left)) (|> left (/ @1) (= left)) - (|> left (/ left) (= @1)) - - (|> left (* @2) (/ @2) (= left)))) + (|> left (* right) (/ right) (= left)) + )) )))) diff --git a/stdlib/source/test/lux/math/number/rev.lux b/stdlib/source/test/lux/math/number/rev.lux index 4a589bc66..0f2a31633 100644 --- a/stdlib/source/test/lux/math/number/rev.lux +++ b/stdlib/source/test/lux/math/number/rev.lux @@ -23,9 +23,7 @@ [data ["[0]" bit (.use "[1]#[0]" equivalence)]] [math - ["[0]" random] - ["[0]" arithmetic - ["[1]T" \\test]]] + ["[0]" random]] [test ["_" property (.only Test)]]]] [\\library @@ -63,8 +61,11 @@ [/.binary] [/.octal] [/.decimal] [/.hex] )) - (_.for [/.arithmetic] - (arithmeticT.spec /.equivalence /.arithmetic random.rev)) + (_.coverage [/.arithmetic] + (and (same? /.+ (of /.arithmetic +)) + (same? /.- (of /.arithmetic -)) + (same? /.* (of /.arithmetic *)) + (same? /./ (of /.arithmetic /)))) ))) (def .public test diff --git a/stdlib/source/test/lux/meta/compiler/language/lux/phase.lux b/stdlib/source/test/lux/meta/compiler/language/lux/phase.lux index 6998809be..1ccb40e7f 100644 --- a/stdlib/source/test/lux/meta/compiler/language/lux/phase.lux +++ b/stdlib/source/test/lux/meta/compiler/language/lux/phase.lux @@ -36,7 +36,8 @@ ["[1]/[0]" type] ["[1]/[0]" value] ["[1]/[0]" runtime] - ["[1]/[0]" complex]]]]) + ["[1]/[0]" complex] + ["[1]/[0]" function]]]]) (def (injection value) (All (_ of) @@ -226,4 +227,5 @@ /translation/jvm/value.test /translation/jvm/runtime.test /translation/jvm/complex.test + /translation/jvm/function.test ))) diff --git a/stdlib/source/test/lux/meta/compiler/language/lux/phase/translation/jvm/complex.lux b/stdlib/source/test/lux/meta/compiler/language/lux/phase/translation/jvm/complex.lux index 4e8d8b010..bf08c727a 100644 --- a/stdlib/source/test/lux/meta/compiler/language/lux/phase/translation/jvm/complex.lux +++ b/stdlib/source/test/lux/meta/compiler/language/lux/phase/translation/jvm/complex.lux @@ -43,7 +43,7 @@ (type Tuple/3 (And Bit (I64 Any) Text)) -(def lux +(def .public lux Lux [.#info [.#target "" .#version "" @@ -85,24 +85,23 @@ [(|> (do try.monad [.let [[_ host] (io.run! host.host) state (is runtime.State - (translation.state host module))] - _ (phase.result state - (do phase.monad - [_ (translation.set_buffer translation.empty_buffer) - it (/.variant phase archive.empty - [<lefts> <right?> (<synthesis> location.dummy <expected>)])] - (in (when (of host evaluate $unit [{.#None} it]) - {try.#Success actual} - (when (as Variant/3 actual) - {<lefts> <right?> actual} - (<=> <expected> actual) + (translation.state host module))]] + (<| (phase.result state) + (do phase.monad + [_ (translation.set_buffer translation.empty_buffer) + it (/.variant phase archive.empty + [<lefts> <right?> (<synthesis> location.dummy <expected>)])] + (in (when (of host evaluate $unit [{.#None} it]) + {try.#Success actual} + (when (as Variant/3 actual) + {<lefts> <right?> actual} + (<=> <expected> actual) - _ - false) - - {try.#Failure error} - false))))] - (in true)) + _ + false) + + {try.#Failure error} + false))))) (try.else false))] [0 #0 synthesis.bit expected_bit bit#=] @@ -113,23 +112,22 @@ (|> (do try.monad [.let [[_ host] (io.run! host.host) state (is runtime.State - (translation.state host module))] - _ (phase.result state - (do phase.monad - [_ (translation.set_buffer translation.empty_buffer) - it (/.tuple phase archive.empty - (list (synthesis.bit location.dummy expected_bit) - (synthesis.i64 location.dummy expected_i64) - (synthesis.text location.dummy expected_text)))] - (in (when (of host evaluate $unit [{.#None} it]) - {try.#Success actual} - (let [[actual_bit actual_i64 actual_text] (as Tuple/3 actual)] - (and (bit#= expected_bit actual_bit) - (i64#= expected_i64 actual_i64) - (text#= expected_text actual_text))) - - {try.#Failure error} - false))))] - (in true)) + (translation.state host module))]] + (<| (phase.result state) + (do phase.monad + [_ (translation.set_buffer translation.empty_buffer) + it (/.tuple phase archive.empty + (list (synthesis.bit location.dummy expected_bit) + (synthesis.i64 location.dummy expected_i64) + (synthesis.text location.dummy expected_text)))] + (in (when (of host evaluate $unit [{.#None} it]) + {try.#Success actual} + (let [[actual_bit actual_i64 actual_text] (as Tuple/3 actual)] + (and (bit#= expected_bit actual_bit) + (i64#= expected_i64 actual_i64) + (text#= expected_text actual_text))) + + {try.#Failure error} + false))))) (try.else false))) ))) diff --git a/stdlib/source/test/lux/meta/compiler/language/lux/phase/translation/jvm/function.lux b/stdlib/source/test/lux/meta/compiler/language/lux/phase/translation/jvm/function.lux new file mode 100644 index 000000000..c8d1d3e75 --- /dev/null +++ b/stdlib/source/test/lux/meta/compiler/language/lux/phase/translation/jvm/function.lux @@ -0,0 +1,102 @@ +... This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0. +... If a copy of the MPL was not distributed with this file, You can obtain one at https://mozilla.org/MPL/2.0/. + +(.require + [library + [lux (.except) + [abstract + [monad (.only do)]] + [control + ["[0]" io] + ["[0]" try]] + [data + ["[0]" bit (.use "[1]#[0]" equivalence)] + [collection + ["[0]" list]]] + [math + ["[0]" random (.only Random)] + [number + ["[0]" i64 (.use "[1]#[0]" equivalence)] + ["n" nat]]] + [meta + ["[0]" location] + [compiler + [language + [lux + ["[0]" synthesis]]] + [meta + ["[0]" archive]]]] + [test + ["_" property (.only Test)]]]] + [\\library + ["[0]" / (.only) + ["[0]" // (.only) + ["[0]" host] + ["[0]" runtime] + [/// + ["[0]" extension] + [// + ["[0]" phase] + ["[0]" translation]]]]]] + [// + ["[0]T" complex]]) + +(def .public test + Test + (<| (_.covering /._) + (do [! random.monad] + [module (random.lower_cased 1) + + expected_bit random.bit + expected_i64 random.i64 + + .let [extender (is extension.Extender + (function (_ _) + (undefined))) + phase (//.translate extender complexT.lux) + @ [module 0 0] + $unit [0 0]] + + arity (of ! each (|>> (n.% 16) ++) random.nat)]) + (all _.and + (_.coverage [/.abstraction] + (|> (do try.monad + [[_ archive] (archive.reserve "" archive.empty) + [_ archive] (archive.reserve module archive) + .let [[_ host] (io.run! host.host) + state (is runtime.State + (translation.state host module))]] + (<| (phase.result state) + (do phase.monad + [_ (translation.set_buffer translation.empty_buffer) + _ runtime.translation + it (/.abstraction phase archive + [(list) 1 (synthesis.i64 @ expected_i64)])] + (in (when (of host evaluate $unit [{.#None} it]) + {try.#Success it} + (i64#= expected_i64 ((as (-> [] I64) it) [])) + + {try.#Failure error} + false))))) + (try.else false))) + (_.coverage [/.apply] + (|> (do try.monad + [[_ archive] (archive.reserve "" archive.empty) + [_ archive] (archive.reserve module archive) + .let [[_ host] (io.run! host.host) + state (is runtime.State + (translation.state host module))]] + (<| (phase.result state) + (do phase.monad + [_ (translation.set_buffer translation.empty_buffer) + it (/.apply phase archive + [(synthesis.function/abstraction @ [(list) arity (synthesis.i64 @ expected_i64)]) + (list.repeated arity (synthesis.bit @ expected_bit))])] + (in (when (of host evaluate $unit [{.#None} it]) + {try.#Success actual_i64} + (i64#= expected_i64 (as I64 actual_i64)) + + {try.#Failure error} + false))))) + (try.else false))) + ))) diff --git a/stdlib/source/test/lux/meta/extension.lux b/stdlib/source/test/lux/meta/extension.lux index 8d1befa13..e55c0a7f5 100644 --- a/stdlib/source/test/lux/meta/extension.lux +++ b/stdlib/source/test/lux/meta/extension.lux @@ -88,10 +88,10 @@ (let [! phase.monad] (|> parameters (monad.each ! (phase archive)) - (of ! each (|>> (is (List analysis.Analysis)) + (of ! each (|>> (is (List analysis.Term)) {analysis.#Extension (symbol ..my_synthesis|synthesis)} [location.dummy] - (is analysis.Analysis))))))) + (is analysis.Term))))))) ... Translation (def my_translation|translation @@ -107,7 +107,7 @@ (monad.each ! (phase archive)) (of ! each (|>> {synthesis.#Extension (symbol ..my_translation|translation)} [location.dummy] - (is synthesis.Synthesis))))))) + (is synthesis.Term))))))) (def my_translation Analysis @@ -115,10 +115,10 @@ (let [! phase.monad] (|> parameters (monad.each ! (phase archive)) - (of ! each (|>> (is (List analysis.Analysis)) + (of ! each (|>> (is (List analysis.Term)) {analysis.#Extension (symbol ..my_translation|synthesis)} [location.dummy] - (is analysis.Analysis))))))) + (is analysis.Term))))))) (def dummy_translation|translation Translation @@ -136,13 +136,13 @@ (def dummy_translation|synthesis Synthesis (synthesis (_ phase archive []) - (of phase.monad in (is synthesis.Synthesis + (of phase.monad in (is synthesis.Term [location.dummy {synthesis.#Extension (symbol ..dummy_translation|translation) (list)}])))) (def dummy_translation Analysis (analysis (_ phase archive []) - (of phase.monad in (is analysis.Analysis + (of phase.monad in (is analysis.Term [location.dummy {analysis.#Extension (symbol ..dummy_translation|synthesis) (list)}])))) ... Declaration diff --git a/stdlib/source/test/lux/world/console.lux b/stdlib/source/test/lux/world/console.lux index c13b4a1ae..31fc77161 100644 --- a/stdlib/source/test/lux/world/console.lux +++ b/stdlib/source/test/lux/world/console.lux @@ -59,7 +59,8 @@ _ false)]] - (unit.coverage [/.Console] + (unit.coverage [/.Console + /.read /.read_line /.write /.close] (and can_write! can_read! can_close!)))))) @@ -98,7 +99,10 @@ Test (<| (_.covering /._) (all _.and - (_.for [/.async /.mock /.Mock] + (_.for [/.Mock + /.on_read /.on_read_line /.on_write /.on_close + + /.async /.mock] (..spec (io.io (/.async (/.mock ..mock [false ""]))))) (do random.monad [expected (random.alphabetic 10) |