diff options
author | Eduardo Julian | 2023-01-13 22:11:05 -0400 |
---|---|---|
committer | Eduardo Julian | 2023-01-13 22:11:05 -0400 |
commit | 0f9f87286acacb520aa3ab0252131e109184b4cb (patch) | |
tree | 69b21f7466ef4418ee6e696998dda0fcb78d26e3 /stdlib/source/test | |
parent | 03eb09c1e0c6de32e45579a1adaf58c9046e632f (diff) |
Better formatting for types & symbols for compilation logging.
Diffstat (limited to 'stdlib/source/test')
-rw-r--r-- | stdlib/source/test/lux/data/text.lux | 4 | ||||
-rw-r--r-- | stdlib/source/test/lux/meta.lux | 49 | ||||
-rw-r--r-- | stdlib/source/test/lux/meta/compiler/language/lux/phase.lux | 4 | ||||
-rw-r--r-- | stdlib/source/test/lux/meta/compiler/language/lux/phase/translation/jvm/complex.lux | 135 | ||||
-rw-r--r-- | stdlib/source/test/lux/meta/compiler/target/jvm.lux | 8 | ||||
-rw-r--r-- | stdlib/source/test/lux/meta/symbol.lux | 8 | ||||
-rw-r--r-- | stdlib/source/test/lux/meta/type.lux | 4 | ||||
-rw-r--r-- | stdlib/source/test/lux/world/file.lux | 7 |
8 files changed, 181 insertions, 38 deletions
diff --git a/stdlib/source/test/lux/data/text.lux b/stdlib/source/test/lux/data/text.lux index c9b3a70d3..fb008dc84 100644 --- a/stdlib/source/test/lux/data/text.lux +++ b/stdlib/source/test/lux/data/text.lux @@ -123,7 +123,7 @@ [\\format.rev rev.decimal random.rev] [\\format.frac frac.decimal random.frac] [\\format.ratio ratio.codec random.ratio] - [\\format.symbol symbol.codec ($//symbol.random 5 5)] + [\\format.symbol symbol.absolute ($//symbol.random 5 5)] [\\format.xml xml.codec $//xml.random] [\\format.json json.codec $//json.random] [\\format.day day.codec random.day] @@ -185,7 +185,7 @@ [\\format.text /.format (random.unicode 5)] [\\format.code code.format $//code.random] - [\\format.type type.format ($//type.random 0)] + [\\format.type type.absolute_format ($//type.random 0)] [\\format.location location.format (all random.and (random.unicode 5) diff --git a/stdlib/source/test/lux/meta.lux b/stdlib/source/test/lux/meta.lux index 7b329a804..8fd22359c 100644 --- a/stdlib/source/test/lux/meta.lux +++ b/stdlib/source/test/lux/meta.lux @@ -812,7 +812,7 @@ label_module (random.upper_cased 2) name_0 (random.upper_cased 3) - ... name_1 (random.upper_cased 4) + name_1 (random.upper_cased 4) .let [random_tag (of ! each (|>> [label_module]) (random.upper_cased 1)) @@ -827,13 +827,9 @@ (of ! each set.list) (random.and (in head))))))] tags_0 (random_labels 5) - ... tags_1 (let [set/0 (set.of_list text.hash {.#Item tags_0})] - ... (random.only (|>> {.#Item} - ... (list.any? (set.member? set/0)) - ... not) - ... random_labels)) + tags_1 (random_labels 6) .let [type_0 {.#Nominal name_0 (list)} - ... type_1 {.#Nominal name_1 (list)} + type_1 {.#Nominal name_1 (list)} expected_lux (is Lux @@ -854,7 +850,7 @@ [.#module_hash 0 .#module_aliases (list) .#definitions (list.partial [name_0 [true {.#Definition [.Type type_0]}]] - ... [name_1 {.#Type [true type_1 {.#Right tags_1}]}] + [name_1 [true {.#Definition [.Type type_1]}]] (all list#composite (let [cohort (is (List Symbol) (list#each (|>> [label_module]) @@ -867,12 +863,19 @@ [short [true {.#Definition [.Tag (|> [{.#Some [index (right? index) cohort]} type_0] (is Label) - (as Tag))]}]])))) - ... (|> {.#Item tags_1} - ... list.enumeration - ... (list#each (function (_ [index short]) - ... [short {.#Slot [true type_1 {.#Item tags_1} index]}]))) - )) + (as .Tag))]}]])))) + (let [cohort (is (List Symbol) + (list#each (|>> [label_module]) + {.#Item tags_1})) + last (-- (list.size cohort)) + right? (n.= last)] + (|> {.#Item tags_1} + list.enumeration + (list#each (function (_ [index short]) + [short [true {.#Definition [.Slot + (|> [{.#Some [index (right? index) cohort]} type_1] + (is Label) + (as .Slot))]}]])))))) .#imports (list) .#module_state {.#Active}]]) .#scopes (list) @@ -893,17 +896,15 @@ type.equivalence))] (|> (/.tag_lists label_module) (/.result expected_lux) - (try#each (of equivalence = (list [(list#each (|>> [label_module]) {.#Item tags_0}) - type_0] - ... [(list#each (|>> [label_module]) {.#Item tags_1}) - ... type_1] - ))) + (try#each (of equivalence = (list [(list#each (|>> [label_module]) {.#Item tags_1}) + type_1]))) (try.else false)))) - ... (_.coverage [/.tags_of] - ... (|> (/.tags_of [label_module name_1]) - ... (/.result expected_lux) - ... (try#each (of (maybe.equivalence (list.equivalence symbol.equivalence)) = {.#Some (list#each (|>> [label_module]) {.#Item tags_1})})) - ... (try.else false))) + (_.coverage [/.tags_of] + (|> (/.tags_of [label_module name_1]) + (/.result expected_lux) + (try#each (of (maybe.equivalence (list.equivalence symbol.equivalence)) = + {.#Some (list#each (|>> [label_module]) {.#Item tags_1})})) + (try.else false))) ... (_.coverage [/.tag] ... (|> {.#Item tags_0} ... list.enumeration 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 e111c6971..6998809be 100644 --- a/stdlib/source/test/lux/meta/compiler/language/lux/phase.lux +++ b/stdlib/source/test/lux/meta/compiler/language/lux/phase.lux @@ -35,7 +35,8 @@ ["[1]/[0]" primitive] ["[1]/[0]" type] ["[1]/[0]" value] - ["[1]/[0]" runtime]]]]) + ["[1]/[0]" runtime] + ["[1]/[0]" complex]]]]) (def (injection value) (All (_ of) @@ -224,4 +225,5 @@ /translation/jvm/type.test /translation/jvm/value.test /translation/jvm/runtime.test + /translation/jvm/complex.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 new file mode 100644 index 000000000..4e8d8b010 --- /dev/null +++ b/stdlib/source/test/lux/meta/compiler/language/lux/phase/translation/jvm/complex.lux @@ -0,0 +1,135 @@ +... 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)] + ["[0]" text (.use "[1]#[0]" equivalence)]] + [math + ["[0]" random (.only Random)] + [number + ["[0]" i64 (.use "[1]#[0]" equivalence)]]] + [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]]]]]]) + +(type Variant/3 + (Or Bit (I64 Any) Text)) + +(type Tuple/3 + (And Bit (I64 Any) Text)) + +(def lux + Lux + [.#info [.#target "" + .#version "" + .#mode {.#Build} + .#configuration (list)] + .#source [location.dummy 0 ""] + .#location location.dummy + .#current_module {.#None} + .#modules (list) + .#scopes (list) + .#type_context [.#ex_counter 0 + .#var_counter 0 + .#var_bindings (list)] + .#expected {.#None} + .#seed 0 + .#scope_type_vars (list) + .#extensions [] + .#eval (as (-> Type Code (Meta Any)) []) + .#host []]) + +(def .public test + Test + (<| (_.covering /._) + (do [! random.monad] + [module (random.lower_cased 1) + + expected_bit random.bit + expected_i64 random.i64 + expected_text (random.upper_cased 2) + + .let [extender (is extension.Extender + (function (_ _) + (undefined))) + phase (//.translate extender ..lux) + $unit [0 0]]]) + (all _.and + (_.coverage [/.variant] + (`` (and (,, (with_template [<lefts> <right?> <synthesis> <expected> <=>] + [(|> (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) + + _ + false) + + {try.#Failure error} + false))))] + (in true)) + (try.else false))] + + [0 #0 synthesis.bit expected_bit bit#=] + [1 #0 synthesis.i64 expected_i64 i64#=] + [1 #1 synthesis.text expected_text text#=] + ))))) + (_.coverage [/.tuple] + (|> (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)) + (try.else false))) + ))) diff --git a/stdlib/source/test/lux/meta/compiler/target/jvm.lux b/stdlib/source/test/lux/meta/compiler/target/jvm.lux index b8a09e42a..3abe5e315 100644 --- a/stdlib/source/test/lux/meta/compiler/target/jvm.lux +++ b/stdlib/source/test/lux/meta/compiler/target/jvm.lux @@ -275,7 +275,7 @@ (def $Double::random (as (Random java/lang/Double) random.frac)) (def $Double::literal (-> java/lang/Double (Bytecode Any)) - /.double) + (|>> (as Frac) /.double)) (def valid_double (Random java/lang/Double) (random.only (|>> (as Frac) f.not_a_number? not) @@ -822,14 +822,14 @@ @.jvm (|>> (as java/lang/Double) .jvm_object_cast# (.jvm_double_=# (.jvm_object_cast# expected))))) (do /.monad - [_ (/.double expected)] + [_ (/.double (as Frac expected))] (/.invokestatic ..$Double "valueOf" (/type.method [(list) (list /type.double) ..$Double (list)])))) (<| (_.lifted "INVOKEVIRTUAL") (do random.monad [expected ..$Double::random]) (..bytecode (|>> (as Bit) (bit#= (f.not_a_number? (as Frac expected))))) (do /.monad - [_ (/.double expected) + [_ (/.double (as Frac expected)) _ ..$Double::wrap _ (/.invokevirtual ..$Double "isNaN" (/type.method [(list) (list) /type.boolean (list)]))] ..$Boolean::wrap)) @@ -845,7 +845,7 @@ (do /.monad [_ (/.new ..$Double) _ /.dup - _ (/.double expected)] + _ (/.double (as Frac expected))] (/.invokespecial ..$Double "<init>" (/type.method [(list) (list /type.double) /type.void (list)])))) (<| (_.lifted "INVOKEINTERFACE") (do random.monad diff --git a/stdlib/source/test/lux/meta/symbol.lux b/stdlib/source/test/lux/meta/symbol.lux index 0fdd94870..f7c2d7db4 100644 --- a/stdlib/source/test/lux/meta/symbol.lux +++ b/stdlib/source/test/lux/meta/symbol.lux @@ -55,15 +55,15 @@ (hashT.spec /.hash))) (_.for [/.order] (orderT.spec /.order (..random sizeM1 sizeS1))) - (_.for [/.codec] - (_.and (codecT.spec /.equivalence /.codec (..random sizeM1 sizeS1)) + (_.for [/.absolute] + (_.and (codecT.spec /.equivalence /.absolute (..random sizeM1 sizeS1)) (_.test "Encoding a symbol without a module component results in text equal to the short of the symbol." (if (text.empty? module1) - (same? short1 (of /.codec encoded symbol1)) + (same? short1 (of /.absolute encoded symbol1)) true)))) (_.coverage [/.separator] - (let [it (of /.codec encoded symbol1)] + (let [it (of /.absolute encoded symbol1)] (if (text.empty? module1) (same? short1 it) (text.contains? /.separator it)))) diff --git a/stdlib/source/test/lux/meta/type.lux b/stdlib/source/test/lux/meta/type.lux index 674c15d58..4f02f6fe8 100644 --- a/stdlib/source/test/lux/meta/type.lux +++ b/stdlib/source/test/lux/meta/type.lux @@ -559,9 +559,9 @@ (_.coverage [/.code] (bit#= (/#= left right) (code#= (/.code left) (/.code right)))) - (_.coverage [/.format] + (_.coverage [/.absolute_format] (bit#= (/#= left right) - (text#= (/.format left) (/.format right)))) + (text#= (/.absolute_format left) (/.absolute_format right)))) )) ..\\parser diff --git a/stdlib/source/test/lux/world/file.lux b/stdlib/source/test/lux/world/file.lux index 0926872ac..40eeae890 100644 --- a/stdlib/source/test/lux/world/file.lux +++ b/stdlib/source/test/lux/world/file.lux @@ -211,7 +211,12 @@ move&delete (..move&delete fs parent child alternate_child)]) - (unit.coverage [/.System] + (unit.coverage [/.System + /.separator + /.file? /.directory? + /.make_directory /.directory_files /.sub_directories + /.file_size /.last_modified /.can_execute? /.read /.delete + /.modify /.write /.append /.move] (and directory?&make_directory file?&write file_size&read&append |