From f44a285e7424c53b22496e539c22f857c660ea92 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rados=C5=82aw=20Wa=C5=9Bko?= Date: Sat, 16 Dec 2023 14:58:18 +0100 Subject: [PATCH] reformat after rebase --- .../argument/ReadArgumentCheckNode.java | 1 - .../org/enso/compiler/ExecCompilerTest.java | 37 +++-- .../enso/interpreter/test/SignatureTest.java | 140 ++++++++++++------ 3 files changed, 116 insertions(+), 62 deletions(-) diff --git a/engine/runtime/src/main/java/org/enso/interpreter/node/callable/argument/ReadArgumentCheckNode.java b/engine/runtime/src/main/java/org/enso/interpreter/node/callable/argument/ReadArgumentCheckNode.java index 86e203cb18d9..2abbb6f802fe 100644 --- a/engine/runtime/src/main/java/org/enso/interpreter/node/callable/argument/ReadArgumentCheckNode.java +++ b/engine/runtime/src/main/java/org/enso/interpreter/node/callable/argument/ReadArgumentCheckNode.java @@ -19,7 +19,6 @@ import java.util.List; import java.util.stream.Collectors; import java.util.stream.Stream; -import org.enso.compiler.core.ir.Name; import org.enso.interpreter.EnsoLanguage; import org.enso.interpreter.node.BaseNode.TailStatus; import org.enso.interpreter.node.EnsoRootNode; diff --git a/engine/runtime/src/test/java/org/enso/compiler/ExecCompilerTest.java b/engine/runtime/src/test/java/org/enso/compiler/ExecCompilerTest.java index cedfe6839944..d8b00705bc62 100644 --- a/engine/runtime/src/test/java/org/enso/compiler/ExecCompilerTest.java +++ b/engine/runtime/src/test/java/org/enso/compiler/ExecCompilerTest.java @@ -9,7 +9,6 @@ import java.net.URI; import java.nio.file.Paths; import java.util.logging.Level; - import org.enso.polyglot.MethodNames; import org.enso.polyglot.RuntimeOptions; import org.graalvm.polyglot.Context; @@ -249,7 +248,10 @@ member_foo self (y : Integer) z -> Integer = 100*z + 10*y + self.x @Test public void inlineReturnSignatureOnLocalFunction() throws Exception { - var module = ctx.eval("enso", """ + var module = + ctx.eval( + "enso", + """ foo x y = inner_foo (z : Integer) -> Integer = 100*z + 10*y + x a = 3 @@ -271,19 +273,24 @@ public void inlineReturnSignatureWithoutArguments() throws Exception { } /** - * This test demonstrates a slightly un-intuitive, but apparently needed by our rules, behaviour of `->` with ascriptions: - * 1. for `foo a:Integer -> Integer` it is interpreted as foo (a:Integer) -> Integer - i.e. a function taking an Integer and returning an Integer. - * 2. for `foo a : Integer -> Integer`, this results in a compile error currently. + * This test demonstrates a slightly un-intuitive, but apparently needed by our rules, behaviour + * of `->` with ascriptions: 1. for `foo a:Integer -> Integer` it is interpreted as foo + * (a:Integer) -> Integer - i.e. a function taking an Integer and returning an Integer. 2. for + * `foo a : Integer -> Integer`, this results in a compile error currently. */ @Test public void weirdReturnTypeSignature1() throws Exception { final URI uri = new URI("memory://rts.enso"); - final Source src = Source.newBuilder("enso", """ + final Source src = + Source.newBuilder( + "enso", + """ from Standard.Base import Integer foo a:Integer -> Integer = a+10 - """,uri.getAuthority()) - .uri(uri) - .buildLiteral(); + """, + uri.getAuthority()) + .uri(uri) + .buildLiteral(); var module = ctx.eval(src); var foo = module.invokeMember(MethodNames.Module.EVAL_EXPRESSION, "foo"); @@ -293,12 +300,16 @@ public void weirdReturnTypeSignature1() throws Exception { @Test public void weirdReturnTypeSignature2() throws Exception { final URI uri = new URI("memory://rts.enso"); - final Source src = Source.newBuilder("enso", """ + final Source src = + Source.newBuilder( + "enso", + """ from Standard.Base import Integer foo a : Integer -> Integer = a+10 - """,uri.getAuthority()) - .uri(uri) - .buildLiteral(); + """, + uri.getAuthority()) + .uri(uri) + .buildLiteral(); try { var module = ctx.eval(src); diff --git a/engine/runtime/src/test/java/org/enso/interpreter/test/SignatureTest.java b/engine/runtime/src/test/java/org/enso/interpreter/test/SignatureTest.java index fe915cada17a..808b072f7243 100644 --- a/engine/runtime/src/test/java/org/enso/interpreter/test/SignatureTest.java +++ b/engine/runtime/src/test/java/org/enso/interpreter/test/SignatureTest.java @@ -811,11 +811,12 @@ public void andConversions() throws Exception { @Test public void unresolvedReturnTypeSignature() throws Exception { final URI uri = new URI("memory://neg.enso"); - final Source src = Source.newBuilder("enso", """ + final Source src = + Source.newBuilder("enso", """ neg a -> Xyz = 0 - a - """,uri.getAuthority()) - .uri(uri) - .buildLiteral(); + """, uri.getAuthority()) + .uri(uri) + .buildLiteral(); try { var module = ctx.eval(src); @@ -830,13 +831,17 @@ public void unresolvedReturnTypeSignature() throws Exception { @Test public void validReturnTypeSignature() throws Exception { final URI uri = new URI("memory://rts.enso"); - final Source src = Source.newBuilder("enso", """ + final Source src = + Source.newBuilder( + "enso", + """ from Standard.Base import Integer add1 a b -> Integer = a+b add2 (a : Integer) (b : Integer) -> Integer = a+b - """,uri.getAuthority()) - .uri(uri) - .buildLiteral(); + """, + uri.getAuthority()) + .uri(uri) + .buildLiteral(); var module = ctx.eval(src); var add1 = module.invokeMember(MethodNames.Module.EVAL_EXPRESSION, "add1"); @@ -849,12 +854,16 @@ public void validReturnTypeSignature() throws Exception { @Test public void returnTypeCheckOptInError() throws Exception { final URI uri = new URI("memory://rts.enso"); - final Source src = Source.newBuilder("enso", """ + final Source src = + Source.newBuilder( + "enso", + """ from Standard.Base import Integer plusChecked a b -> Integer = b+a - """,uri.getAuthority()) - .uri(uri) - .buildLiteral(); + """, + uri.getAuthority()) + .uri(uri) + .buildLiteral(); var module = ctx.eval(src); var plusChecked = module.invokeMember(MethodNames.Module.EVAL_EXPRESSION, "plusChecked"); @@ -867,17 +876,24 @@ public void returnTypeCheckOptInError() throws Exception { } } - /** Similar scenario to {@code returnTypeCheckOptInError}, but with the opt out signature the check is not currently performed. */ + /** + * Similar scenario to {@code returnTypeCheckOptInError}, but with the opt out signature the check + * is not currently performed. + */ @Test public void returnTypeCheckOptOut() throws Exception { final URI uri = new URI("memory://rts.enso"); - final Source src = Source.newBuilder("enso", """ + final Source src = + Source.newBuilder( + "enso", + """ from Standard.Base import Integer plusUnchecked : Integer -> Integer -> Integer plusUnchecked a b = b+a - """,uri.getAuthority()) - .uri(uri) - .buildLiteral(); + """, + uri.getAuthority()) + .uri(uri) + .buildLiteral(); var module = ctx.eval(src); var plusChecked = module.invokeMember(MethodNames.Module.EVAL_EXPRESSION, "plusUnchecked"); @@ -889,13 +905,17 @@ public void returnTypeCheckOptOut() throws Exception { @Test public void returnTypeCheckOptInErrorZeroArguments() throws Exception { final URI uri = new URI("memory://rts.enso"); - final Source src = Source.newBuilder("enso", """ + final Source src = + Source.newBuilder( + "enso", + """ from Standard.Base import Integer constant -> Integer = "foo" foo a b = a + constant + b - """,uri.getAuthority()) - .uri(uri) - .buildLiteral(); + """, + uri.getAuthority()) + .uri(uri) + .buildLiteral(); var module = ctx.eval(src); var plusChecked = module.invokeMember(MethodNames.Module.EVAL_EXPRESSION, "foo"); @@ -907,18 +927,21 @@ public void returnTypeCheckOptInErrorZeroArguments() throws Exception { } } - @Test public void returnTypeCheckOptInErrorZeroArgumentsExpression() throws Exception { final URI uri = new URI("memory://rts.enso"); - final Source src = Source.newBuilder("enso", """ + final Source src = + Source.newBuilder( + "enso", + """ from Standard.Base import Integer foo a = x -> Integer = a+a x+x - """,uri.getAuthority()) - .uri(uri) - .buildLiteral(); + """, + uri.getAuthority()) + .uri(uri) + .buildLiteral(); var module = ctx.eval(src); var plusChecked = module.invokeMember(MethodNames.Module.EVAL_EXPRESSION, "foo"); @@ -934,15 +957,19 @@ public void returnTypeCheckOptInErrorZeroArgumentsExpression() throws Exception @Test public void returnTypeCheckOptInErrorZeroArgumentsBlock() throws Exception { final URI uri = new URI("memory://rts.enso"); - final Source src = Source.newBuilder("enso", """ + final Source src = + Source.newBuilder( + "enso", + """ from Standard.Base import Integer, IO foo a = x -> Integer = a+a x+x - """,uri.getAuthority()) - .uri(uri) - .buildLiteral(); + """, + uri.getAuthority()) + .uri(uri) + .buildLiteral(); var module = ctx.eval(src); var plusChecked = module.invokeMember(MethodNames.Module.EVAL_EXPRESSION, "foo"); @@ -958,16 +985,20 @@ public void returnTypeCheckOptInErrorZeroArgumentsBlock() throws Exception { @Test public void returnTypeCheckOptInAllowDataflowErrors() throws Exception { final URI uri = new URI("memory://rts.enso"); - final Source src = Source.newBuilder("enso", """ + final Source src = + Source.newBuilder( + "enso", + """ from Standard.Base import Integer, Error foo x -> Integer = case x of 1 -> 100 2 -> "TWO" 3 -> Error.throw "My error" _ -> x+1 - """,uri.getAuthority()) - .uri(uri) - .buildLiteral(); + """, + uri.getAuthority()) + .uri(uri) + .buildLiteral(); var module = ctx.eval(src); var foo = module.invokeMember(MethodNames.Module.EVAL_EXPRESSION, "foo"); @@ -988,7 +1019,10 @@ public void returnTypeCheckOptInAllowDataflowErrors() throws Exception { @Test public void returnTypeCheckOptInTailRec() throws Exception { final URI uri = new URI("memory://rts.enso"); - final Source src = Source.newBuilder("enso", """ + final Source src = + Source.newBuilder( + "enso", + """ from Standard.Base import Integer, Error factorial (x : Integer) -> Integer = go n acc -> Integer = @@ -996,9 +1030,10 @@ public void returnTypeCheckOptInTailRec() throws Exception { if n == 10 then "TEN :)" else @Tail_Call go (n-1) (acc*n) go x 1 - """,uri.getAuthority()) - .uri(uri) - .buildLiteral(); + """, + uri.getAuthority()) + .uri(uri) + .buildLiteral(); var module = ctx.eval(src); var factorial = module.invokeMember(MethodNames.Module.EVAL_EXPRESSION, "factorial"); @@ -1014,13 +1049,17 @@ public void returnTypeCheckOptInTailRec() throws Exception { } /** - * An additional test to ensure that the way the return type check is implemented does not break the TCO. We execute a - * recursive computation that goes 100k frames deep - if TCO did not kick in here, we'd get a stack overflow. + * An additional test to ensure that the way the return type check is implemented does not break + * the TCO. We execute a recursive computation that goes 100k frames deep - if TCO did not kick in + * here, we'd get a stack overflow. */ @Test public void returnTypeCheckOptInTCO() throws Exception { final URI uri = new URI("memory://rts.enso"); - final Source src = Source.newBuilder("enso", """ + final Source src = + Source.newBuilder( + "enso", + """ from Standard.Base import Integer, Error foo (counter : Integer) (trap : Integer) -> Integer = go i acc -> Integer = @@ -1028,9 +1067,10 @@ public void returnTypeCheckOptInTCO() throws Exception { if i == trap then "TRAP!" else @Tail_Call go (i-1) (acc+1) go counter 1 - """,uri.getAuthority()) - .uri(uri) - .buildLiteral(); + """, + uri.getAuthority()) + .uri(uri) + .buildLiteral(); var module = ctx.eval(src); var foo = module.invokeMember(MethodNames.Module.EVAL_EXPRESSION, "foo"); @@ -1047,7 +1087,10 @@ public void returnTypeCheckOptInTCO() throws Exception { @Test public void returnTypeCheckOptInTCO2() throws Exception { final URI uri = new URI("memory://rts.enso"); - final Source src = Source.newBuilder("enso", """ + final Source src = + Source.newBuilder( + "enso", + """ from Standard.Base import Integer, Error foo_ok counter -> Integer = if counter == 0 then 0 else @@ -1055,9 +1098,10 @@ public void returnTypeCheckOptInTCO2() throws Exception { foo_bad counter -> Integer = if counter == 0 then "ZERO" else @Tail_Call foo_bad (counter-1) - """,uri.getAuthority()) - .uri(uri) - .buildLiteral(); + """, + uri.getAuthority()) + .uri(uri) + .buildLiteral(); var module = ctx.eval(src); var foo_ok = module.invokeMember(MethodNames.Module.EVAL_EXPRESSION, "foo_ok");