From 6c24a9830cfbf32fbbb6fbfd6f2b7354cb994605 Mon Sep 17 00:00:00 2001 From: Eduardo Julian Date: Thu, 19 Oct 2017 00:22:47 -0400 Subject: - Compilation for method invocation. --- .../test/luxc/generator/procedure/host.jvm.lux | 73 +++++++++++++++++++++- 1 file changed, 72 insertions(+), 1 deletion(-) (limited to 'new-luxc/test') diff --git a/new-luxc/test/test/luxc/generator/procedure/host.jvm.lux b/new-luxc/test/test/luxc/generator/procedure/host.jvm.lux index 0cfd47538..ba90a00e3 100644 --- a/new-luxc/test/test/luxc/generator/procedure/host.jvm.lux +++ b/new-luxc/test/test/luxc/generator/procedure/host.jvm.lux @@ -7,7 +7,7 @@ ["e" error] [bit] [bool "bool/" Eq] - [number "int/" Number] + [number "int/" Number Codec] [text "text/" Eq] text/format (coll [list])) @@ -470,3 +470,74 @@ (test "jvm member virtual put" false) )) + +(host;import java.lang.Object) + +(host;import (java.util.ArrayList a)) + +(context: "Member [Method]" + [sample (|> r;int (:: @ map (|>. int/abs (i.% 100)))) + #let [object-longS (|> (#ls;Int sample) + (list (#ls;Text "java.lang.Object")) #ls;Tuple) + intS (|> (#ls;Int sample) + (list) (#ls;Procedure "jvm convert long-to-int") + (list (#ls;Text "int")) #ls;Tuple) + coded-intS (|> (#ls;Text (int/encode sample)) + (list (#ls;Text "java.lang.String")) #ls;Tuple) + array-listS (#ls;Procedure "jvm member invoke constructor" (list (#ls;Text "java.util.ArrayList") intS))]] + ($_ seq + (test "jvm member invoke static" + (|> (do meta;Monad + [sampleI (@;generate (#ls;Procedure "jvm member invoke static" + (list (#ls;Text "java.lang.Long") + (#ls;Text "decode") + (#ls;Text "java.lang.Long") + coded-intS)))] + (@eval;eval sampleI)) + (meta;run (init-compiler [])) + (case> (#e;Success outputG) + (i.= sample (:! Int outputG)) + + (#e;Error error) + false))) + (test "jvm member invoke virtual" + (|> (do meta;Monad + [sampleI (@;generate (|> object-longS + (list (#ls;Text "java.lang.Object") + (#ls;Text "equals") + (#ls;Text "boolean") + (#ls;Int sample)) + (#ls;Procedure "jvm member invoke virtual")))] + (@eval;eval sampleI)) + (meta;run (init-compiler [])) + (case> (#e;Success outputG) + (:! Bool outputG) + + (#e;Error error) + false))) + (test "jvm member invoke interface" + (|> (do meta;Monad + [sampleI (@;generate (#ls;Procedure "jvm member invoke interface" + (list (#ls;Text "java.util.Collection") + (#ls;Text "add") + (#ls;Text "boolean") + array-listS + object-longS)))] + (@eval;eval sampleI)) + (meta;run (init-compiler [])) + (case> (#e;Success outputG) + (:! Bool outputG) + + (#e;Error error) + false))) + (test "jvm member invoke constructor" + (|> (do meta;Monad + [sampleI (@;generate array-listS)] + (@eval;eval sampleI)) + (meta;run (init-compiler [])) + (case> (#e;Success outputG) + (host;instance? ArrayList (:! Object outputG)) + + (#e;Error error) + false))) + )) -- cgit v1.2.3