aboutsummaryrefslogtreecommitdiff
path: root/stdlib/source/test
diff options
context:
space:
mode:
authorEduardo Julian2023-01-21 19:12:00 -0400
committerEduardo Julian2023-01-21 19:12:00 -0400
commit4ec923fe46f66ba8731fc4b7334e724d63dec73e (patch)
tree8b60788689aaa09906614b02132b735d443bbba4 /stdlib/source/test
parent670438b982bbe0b662b0a65958dc4f8b289d3906 (diff)
Can now extract values from the C++ interpreter for evaluation.
Diffstat (limited to 'stdlib/source/test')
-rw-r--r--stdlib/source/test/lux/meta/compiler/language/lux/phase/translation/jvm/function.lux6
-rw-r--r--stdlib/source/test/lux/meta/compiler/language/lux/phase/translation/jvm/function/abstract.lux115
-rw-r--r--stdlib/source/test/lux/meta/compiler/language/lux/phase/translation/jvm/function/method.lux31
-rw-r--r--stdlib/source/test/lux/meta/macro/syntax/declaration.lux3
-rw-r--r--stdlib/source/test/lux/world/finance/market/price.lux9
5 files changed, 160 insertions, 4 deletions
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 906c23a71..fc26af607 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
@@ -40,7 +40,9 @@
["[0]" phase]
["[0]" synthesis]
["[0]" translation]]]]]]
- [/
+ ["[0]" /
+ ["[1][0]" abstract]
+ ["[1][0]" method]
[field
[constant
["[0]T" arity]]
@@ -148,6 +150,8 @@
(and exact_arity!
multiple_applications!)))
+ /abstract.test
+ /method.test
arityT.test
countT.test
)))
diff --git a/stdlib/source/test/lux/meta/compiler/language/lux/phase/translation/jvm/function/abstract.lux b/stdlib/source/test/lux/meta/compiler/language/lux/phase/translation/jvm/function/abstract.lux
new file mode 100644
index 000000000..79465cb59
--- /dev/null
+++ b/stdlib/source/test/lux/meta/compiler/language/lux/phase/translation/jvm/function/abstract.lux
@@ -0,0 +1,115 @@
+... 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)
+ ["[0]" ffi]
+ [abstract
+ [monad (.only do)]]
+ [control
+ ["[0]" try (.use "[1]#[0]" functor)]
+ ["[0]" io]]
+ [math
+ ["[0]" random (.only Random)]
+ [number
+ ["n" nat]]]
+ [meta
+ ["[0]" location]
+ [compiler
+ [target
+ [jvm
+ ["[0]" reflection]
+ ["[0]" type (.only)
+ ["[1]/[0]" reflection]]]]
+ [meta
+ ["[0]" archive]]]]
+ [test
+ ["_" property (.only Test)]]]]
+ [\\library
+ ["[0]" / (.only)
+ [////
+ ["[0]" jvm (.only)
+ ["[0]" host]
+ ["[0]" runtime]
+ [///
+ ["[0]" extension]
+ [//
+ ["[0]" phase]
+ ["[0]" synthesis]
+ ["[0]" translation]]]]]]]
+ [///
+ ["[0]T" complex]])
+
+(ffi.import java/lang/String
+ "[1]::[0]")
+
+(ffi.import (java/lang/Class of)
+ "[1]::[0]"
+ (getCanonicalName [] java/lang/String))
+
+(ffi.import java/lang/Object
+ "[1]::[0]"
+ (getClass [] (java/lang/Class [? < java/lang/Object])))
+
+(ffi.import java/lang/ClassLoader
+ "[1]::[0]"
+ ("static" getSystemClassLoader [] java/lang/ClassLoader))
+
+(def (function? loader it)
+ (-> java/lang/ClassLoader Any
+ Bit)
+ (let [super (type/reflection.reflection (type.reflection /.class))
+ sub (|> it
+ (as java/lang/Object)
+ java/lang/Object::getClass
+ java/lang/Class::getCanonicalName
+ ffi.of_string)]
+ (try.else false
+ (reflection.sub? loader super sub))))
+
+(def .public test
+ Test
+ (<| (_.covering /._)
+ (do [! random.monad]
+ [module (random.lower_cased 1)
+ expected_i64 random.i64
+ arity (of ! each (|>> (n.% 10) ++) random.nat)
+
+ .let [system_class_loader (java/lang/ClassLoader::getSystemClassLoader)]])
+ (all _.and
+ (_.coverage [/.id]
+ (not (n.= runtime.id /.id)))
+ (_.coverage [/.class]
+ (let [lux_makes_functions!
+ (..function? system_class_loader ..function?)
+
+ compiler_makes_functions!
+ (|> (do try.monad
+ [.let [extender (is extension.Extender
+ (function (_ _)
+ (undefined)))
+ next (jvm.translate extender complexT.lux)
+ @ [module 0 0]]
+ [_ archive] (archive.reserve "" archive.empty)
+ [_ archive] (archive.reserve module archive)
+ .let [[class_loader 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.i64 @ expected_i64)]))]
+ (in (|> it
+ [{.#None}]
+ (of host evaluate)
+ (try#each (..function? class_loader))
+ (try.else false))))))
+ (try.else false))]
+ (and lux_makes_functions!
+ compiler_makes_functions!)))
+ (_.coverage [/.init]
+ true)
+ )))
diff --git a/stdlib/source/test/lux/meta/compiler/language/lux/phase/translation/jvm/function/method.lux b/stdlib/source/test/lux/meta/compiler/language/lux/phase/translation/jvm/function/method.lux
new file mode 100644
index 000000000..b8af5f99f
--- /dev/null
+++ b/stdlib/source/test/lux/meta/compiler/language/lux/phase/translation/jvm/function/method.lux
@@ -0,0 +1,31 @@
+... 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)]]
+ [math
+ ["[0]" random (.only Random)]]
+ [meta
+ [compiler
+ [target
+ [jvm
+ ["[0]" modifier]
+ ["[0]" method]]]]]
+ [test
+ ["_" property (.only Test)]]]]
+ [\\library
+ ["[0]" /]])
+
+(def .public test
+ Test
+ (<| (_.covering /._)
+ (do [! random.monad]
+ [])
+ (all _.and
+ (_.coverage [/.modifier]
+ (and (modifier.has? method.public /.modifier)
+ (modifier.has? method.strict /.modifier)))
+ )))
diff --git a/stdlib/source/test/lux/meta/macro/syntax/declaration.lux b/stdlib/source/test/lux/meta/macro/syntax/declaration.lux
index 07b6a3a70..84e59f20a 100644
--- a/stdlib/source/test/lux/meta/macro/syntax/declaration.lux
+++ b/stdlib/source/test/lux/meta/macro/syntax/declaration.lux
@@ -35,7 +35,8 @@
(def .public test
Test
(<| (_.covering /._)
- (_.for [/.Declaration])
+ (_.for [/.Declaration
+ /.#name /.#arguments])
(all _.and
(_.for [/.equivalence]
(equivalenceT.spec /.equivalence ..random))
diff --git a/stdlib/source/test/lux/world/finance/market/price.lux b/stdlib/source/test/lux/world/finance/market/price.lux
index cef90b094..c321ac3a8 100644
--- a/stdlib/source/test/lux/world/finance/market/price.lux
+++ b/stdlib/source/test/lux/world/finance/market/price.lux
@@ -48,14 +48,19 @@
subject (..random currency.usd 1000,00)
from (moneyT.random currency.usd 1000,00)
- to (moneyT.random currency.usd 1000,00)])
+ to (moneyT.random currency.usd 1000,00)
+
+ not_free (moneyT.random currency.usd 1000,00)])
(_.for [/.Price /.Action])
(all _.and
(_.for [/.equivalence /.=]
(equivalenceT.spec /.equivalence (..random currency.usd 1000,00)))
(_.for [/.order /.<]
(orderT.spec /.order (..random currency.usd 1000,00)))
-
+
+ (_.coverage [/.free]
+ (money.<= not_free
+ (/.free currency.usd)))
(_.coverage [/.action /.currency /.movement]
(let [it (/.action from to)]
(and (same? currency.usd (/.currency it))