diff options
Diffstat (limited to '')
-rw-r--r-- | stdlib/source/test/lux/meta/compiler/language/lux/phase/translation/jvm/function/method/implementation.lux | 110 |
1 files changed, 110 insertions, 0 deletions
diff --git a/stdlib/source/test/lux/meta/compiler/language/lux/phase/translation/jvm/function/method/implementation.lux b/stdlib/source/test/lux/meta/compiler/language/lux/phase/translation/jvm/function/method/implementation.lux new file mode 100644 index 000000000..1c09977e9 --- /dev/null +++ b/stdlib/source/test/lux/meta/compiler/language/lux/phase/translation/jvm/function/method/implementation.lux @@ -0,0 +1,110 @@ +... 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]" io] + ["[0]" try (.use "[1]#[0]" functor)]] + [math + ["[0]" random (.only Random)] + [number + ["[0]" i64 (.use "[1]#[0]" equivalence)] + ["n" nat]]] + [meta + [compiler + [target + [jvm + ["[0]" modifier (.only Modifier)] + ["[0]" method (.only Method)] + ["[0]" type] + ["!" bytecode]]] + [meta + ["[0]" archive]]]] + [test + ["_" property (.only Test)]]]] + [\\library + ["[0]" / (.only) + [/// + [field + [constant + ["[0]" arity]]] + ["[0]" // (.only) + ["[0]" host] + ["[0]" runtime] + [/// + ["[0]" extension] + [// + ["[0]" phase] + ["[0]" synthesis] + ["[0]" translation]]]]]]] + [//// + ["[0]T" complex]]) + +(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))) + +(def .public (test valid_modifier?) + (-> (-> (Modifier Method) Bit) + Test) + (<| (_.covering /._) + (do [! random.monad] + [module (random.lower_cased 1) + + expected_i64 random.i64 + + .let [extender (is extension.Extender + (function (_ _) + (undefined))) + next (//.translate extender complexT.lux) + @ [module 0 0]] + + arity (of ! each (|>> (n.% (-- arity.maximum)) (n.+ 2)) random.nat) + inner_arity (of ! each (|>> (n.% arity) (n.+ 1)) random.nat)]) + (all _.and + (_.coverage [/.modifier] + (and (valid_modifier? /.modifier) + (modifier.has? method.static /.modifier))) + (_.coverage [/.name /.type /.method /.call] + (|> (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) + parameter (next archive (synthesis.i64 @ expected_i64)) + function (next archive (synthesis.function/abstraction @ [(list) 1 (synthesis.variable/local @ 1)])) + it (|> function + [{.#None}] + (of host evaluate) + phase.of_try) + .let [class (type.class (|> it + (as java/lang/Object) + java/lang/Object::getClass + java/lang/Class::getCanonicalName + ffi.of_string) + (list))]] + (in (|> (do !.monad + [_ function + _ parameter] + (/.call class 1)) + [{.#None}] + (of host evaluate) + (try#each (|>> (as I64) + (i64#= expected_i64))) + (try.else false) + ))))) + (try.else false))) + ))) |