aboutsummaryrefslogtreecommitdiff
path: root/stdlib/source/test
diff options
context:
space:
mode:
Diffstat (limited to 'stdlib/source/test')
-rw-r--r--stdlib/source/test/lux/math/number/frac.lux14
-rw-r--r--stdlib/source/test/lux/meta/compiler.lux43
-rw-r--r--stdlib/source/test/lux/meta/compiler/language/lux/phase/translation/jvm/function.lux4
-rw-r--r--stdlib/source/test/lux/meta/compiler/language/lux/phase/translation/jvm/function/field/variable/foreign.lux96
-rw-r--r--stdlib/source/test/lux/meta/compiler/target/ruby.lux5
5 files changed, 137 insertions, 25 deletions
diff --git a/stdlib/source/test/lux/math/number/frac.lux b/stdlib/source/test/lux/math/number/frac.lux
index 7ae0e0aff..7a7f1c6bf 100644
--- a/stdlib/source/test/lux/math/number/frac.lux
+++ b/stdlib/source/test/lux/math/number/frac.lux
@@ -395,6 +395,20 @@
(|> expected /.opposite /.opposite (/.= expected))]
(and subtraction!
inverse!))))
+ (do [! random.monad]
+ [it (of ! each /.abs random.safe_frac)]
+ (_.coverage [/.degree]
+ (/.> it
+ (/.degree it))))
+ (do [! random.monad]
+ [it (of ! each /.abs random.safe_frac)]
+ (_.coverage [/.percentage /.permille /.permyriad]
+ (and (/.> it
+ (/.percentage it))
+ (/.> (/.percentage it)
+ (/.permille it))
+ (/.> (/.permille it)
+ (/.permyriad it)))))
..constant
..predicate
diff --git a/stdlib/source/test/lux/meta/compiler.lux b/stdlib/source/test/lux/meta/compiler.lux
index 682c7f96f..baa92d71f 100644
--- a/stdlib/source/test/lux/meta/compiler.lux
+++ b/stdlib/source/test/lux/meta/compiler.lux
@@ -31,28 +31,27 @@
"Ruby" (.,, (.these ["[1]/[0]" ruby]))
(.,, (.these))))]])))
-(`` (`` (def .public test
- Test
- (<| (_.covering /._)
- (do [! random.monad]
- [])
- (all _.and
- (_.coverage [/.Code /.Parameter /.Input]
- true)
+(`` (def .public test
+ Test
+ (<| (_.covering /._)
+ (do [! random.monad]
+ [])
+ (all _.and
+ (_.coverage [/.Code /.Parameter /.Input]
+ true)
- /arity.test
- /version.test
- /reference.test
-
- /language/lux.test
+ /arity.test
+ /version.test
+ /reference.test
+
+ /language/lux.test
- /meta.test
+ /meta.test
- /target.test
- (,, (for @.jvm (,, (these /target/jvm.test))
- @.old (,, (these /target/jvm.test))
- @.js (,, (these /target/js.test))
- @.lua (,, (these /target/lua.test))
- @.python (,, (these /target/python.test))
- @.ruby (,, (these /target/ruby.test))))
- )))))
+ /target.test
+ (,, (for @.jvm /target/jvm.test
+ @.js /target/js.test
+ @.lua /target/lua.test
+ @.python /target/python.test
+ @.ruby /target/ruby.test))
+ ))))
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
index fc26af607..16df01422 100644
--- 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
@@ -47,7 +47,8 @@
[constant
["[0]T" arity]]
[variable
- ["[0]T" count]]]
+ ["[0]T" count]
+ ["[0]T" foreign]]]
[//
["[0]T" complex]]])
@@ -154,4 +155,5 @@
/method.test
arityT.test
countT.test
+ foreignT.test
)))
diff --git a/stdlib/source/test/lux/meta/compiler/language/lux/phase/translation/jvm/function/field/variable/foreign.lux b/stdlib/source/test/lux/meta/compiler/language/lux/phase/translation/jvm/function/field/variable/foreign.lux
new file mode 100644
index 000000000..372439c33
--- /dev/null
+++ b/stdlib/source/test/lux/meta/compiler/language/lux/phase/translation/jvm/function/field/variable/foreign.lux
@@ -0,0 +1,96 @@
+... 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 (.use "[1]#[0]" functor)]
+ ["[0]" function]]
+ [data
+ ["[0]" bit (.use "[1]#[0]" equivalence)]
+ [collection
+ ["[0]" list]]]
+ [math
+ ["[0]" random (.only Random)]
+ [number
+ ["n" nat (.use "[1]#[0]" equivalence)]
+ ["[0]" i64 (.use "[1]#[0]" equivalence)]]]
+ [meta
+ ["[0]" location]
+ [compiler
+ [target
+ [jvm
+ ["!" bytecode]
+ ["[0]" type]]]
+ [meta
+ ["[0]" archive]]]]
+ [test
+ ["_" property (.only Test)]]]]
+ [\\library
+ ["[0]" / (.only)
+ [///
+ [constant
+ ["[0]" arity]]
+ [//
+ ["[0]" abstract]
+ [///
+ ["[0]" jvm (.only)
+ ["[0]" host]
+ ["[0]" runtime]
+ ["[0]" value]
+ ["[0]" complex
+ ["[1]T" \\test]]
+ [///
+ ["[0]" extension]
+ [//
+ ["[0]" phase]
+ ["[0]" synthesis]
+ ["[0]" translation]]]]]]]]])
+
+(def .public test
+ Test
+ (<| (_.covering /._)
+ (do [! random.monad]
+ [module (random.lower_cased 1)
+
+ expected_i64 random.i64
+ dummy_i64 (random.only (|>> (i64#= expected_i64) not) random.i64)
+
+ .let [extender (is extension.Extender
+ (function (_ _)
+ (undefined)))
+ next (jvm.translate extender complexT.lux)
+ @ [module 0 0]]])
+ (all _.and
+ (_.coverage [/.closure /.variables
+ /.get /.put]
+ (|> (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 (next archive (<| (synthesis.function/abstraction @)
+ [(list) 1]
+ (synthesis.function/abstraction @)
+ [(list (synthesis.variable/local @ 1)) 1]
+ (synthesis.variable/foreign @ 0)))]
+ (in (|> it
+ [{.#None}]
+ (of host evaluate)
+ (try#each (function (_ it)
+ (i64#= expected_i64
+ ((as (-> I64 I64 I64)
+ it)
+ expected_i64
+ dummy_i64))))
+ (try.else false))))))
+ (try.else false)))
+ )))
diff --git a/stdlib/source/test/lux/meta/compiler/target/ruby.lux b/stdlib/source/test/lux/meta/compiler/target/ruby.lux
index f706adfa5..ab02eea80 100644
--- a/stdlib/source/test/lux/meta/compiler/target/ruby.lux
+++ b/stdlib/source/test/lux/meta/compiler/target/ruby.lux
@@ -7,13 +7,14 @@
["[0]" ffi]
[abstract
[monad (.only do)]
- ["[0]" predicate]
["[0]" equivalence
["[1]T" \\test]]]
[control
["[0]" pipe]
["[0]" maybe (.use "[1]#[0]" functor)]
- ["[0]" try (.only Try) (.use "[1]#[0]" functor)]]
+ ["[0]" try (.only Try) (.use "[1]#[0]" functor)]
+ [function
+ ["[0]" predicate]]]
[data
["[0]" bit (.use "[1]#[0]" equivalence)]
["[0]" text (.use "[1]#[0]" equivalence)