From d30da41ec942bad7ed7aaf8985ccefc611ea54e3 Mon Sep 17 00:00:00 2001 From: Jaroslav Tulach Date: Fri, 20 Dec 2024 17:59:10 +0100 Subject: [PATCH] 2nd multi value argument conversions do not work --- .../org/enso/interpreter/test/AnyToTest.java | 44 ++++++++++++++++++- 1 file changed, 42 insertions(+), 2 deletions(-) diff --git a/engine/runtime-integration-tests/src/test/java/org/enso/interpreter/test/AnyToTest.java b/engine/runtime-integration-tests/src/test/java/org/enso/interpreter/test/AnyToTest.java index 15713bbe7215..0b0a3b050075 100644 --- a/engine/runtime-integration-tests/src/test/java/org/enso/interpreter/test/AnyToTest.java +++ b/engine/runtime-integration-tests/src/test/java/org/enso/interpreter/test/AnyToTest.java @@ -54,8 +54,6 @@ public void multiValueToInteger() throws Exception { conv style v = case style of 0 -> v.to Integer 1 -> v:Integer - 2 -> v.to Text - 3 -> v:Text 99 -> eq """; @@ -74,4 +72,46 @@ public void multiValueToInteger() throws Exception { }); assertTrue("Any.to and : give the same result", eq.asBoolean()); } + + @Test + public void multiValueToText() throws Exception { + multiValueToText(2); + } + + @Test + public void multiValueToTextHidden() throws Exception { + multiValueToText(1); + } + + private void multiValueToText(int dispatchLength) throws Exception { + var ensoCtx = ContextUtils.leakContext(ctx); + var types = + new Type[] {ensoCtx.getBuiltins().number().getInteger(), ensoCtx.getBuiltins().text()}; + var code = + """ + from Standard.Base import all + + private eq a b = a == b + + conv style:Integer v = case style of + 2 -> v.to Text + 3 -> v:Text + 99 -> eq + + """; + var conv = + ContextUtils.evalModule(ctx, Source.newBuilder("enso", code, "conv.enso").build(), "conv"); + var both = EnsoMultiValue.create(types, dispatchLength, new Object[] {2L, Text.create("Two")}); + var eq = + ContextUtils.executeInContext( + ctx, + () -> { + var bothValue = ctx.asValue(both); + var asIntegerCast = conv.execute(3, bothValue); + var asIntegerTo = conv.execute(2, bothValue); + var equals = conv.execute(99, null); + return equals.execute(asIntegerTo, asIntegerCast); + }); + assertTrue("Any.to and : give the same result", eq.asBoolean()); + } }