aboutsummaryrefslogtreecommitdiff
path: root/stdlib/source/test/lux/meta
diff options
context:
space:
mode:
Diffstat (limited to 'stdlib/source/test/lux/meta')
-rw-r--r--stdlib/source/test/lux/meta/compiler/language/lux/phase.lux4
-rw-r--r--stdlib/source/test/lux/meta/compiler/language/lux/phase/translation/jvm/complex.lux135
-rw-r--r--stdlib/source/test/lux/meta/compiler/target/jvm.lux8
-rw-r--r--stdlib/source/test/lux/meta/symbol.lux8
-rw-r--r--stdlib/source/test/lux/meta/type.lux4
5 files changed, 148 insertions, 11 deletions
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