diff --git a/engine/runtime-integration-tests/src/test/java/org/enso/compiler/ImportsAndFQNConsistencyTest.java b/engine/runtime-integration-tests/src/test/java/org/enso/compiler/ImportsAndFQNConsistencyTest.java index fc109ad6e387..0f35f9be46fe 100644 --- a/engine/runtime-integration-tests/src/test/java/org/enso/compiler/ImportsAndFQNConsistencyTest.java +++ b/engine/runtime-integration-tests/src/test/java/org/enso/compiler/ImportsAndFQNConsistencyTest.java @@ -15,7 +15,7 @@ import org.enso.compiler.core.ir.module.scope.definition.Method; import org.enso.interpreter.runtime.EnsoContext; import org.enso.polyglot.RuntimeOptions; -import org.enso.test.utils.TestUtils; +import org.enso.test.utils.ContextUtils; import org.graalvm.polyglot.Context; import org.junit.AfterClass; import org.junit.BeforeClass; @@ -51,17 +51,17 @@ public class ImportsAndFQNConsistencyTest { @Parameters(name = "exported symbol '{0}'") public static List symbolsToTest() { try (var ctx = - TestUtils.defaultContextBuilder(LanguageInfo.ID) + ContextUtils.defaultContextBuilder(LanguageInfo.ID) .option(RuntimeOptions.DISABLE_IR_CACHES, "false") .build()) { - var ensoCtx = TestUtils.leakContext(ctx); + var ensoCtx = ContextUtils.leakContext(ctx); var src = """ from Standard.Base import all from Standard.Table import all main = 42 """; // Ensure that the context is initialized first. - var res = TestUtils.evalModule(ctx, src); + var res = ContextUtils.evalModule(ctx, src); assertThat(res.isNumber(), is(true)); List symbolsToTest = new ArrayList<>(); gatherExportedSymbols(ensoCtx, List.of("Standard.Base.Main", "Standard.Table.Main")).stream() @@ -94,7 +94,7 @@ public static List symbolsToTest() { @BeforeClass public static void initCtx() { - ctx = TestUtils.createDefaultContext(); + ctx = ContextUtils.createDefaultContext(); } @AfterClass @@ -109,7 +109,7 @@ public ImportsAndFQNConsistencyTest(Symbol symbol) { } private void evalCode(Symbol symbol) { - var res = TestUtils.evalModule(ctx, code); + var res = ContextUtils.evalModule(ctx, code); assertThat(res.isString(), is(true)); assertThat(res.asString(), is(symbol.getLastPathItem())); } diff --git a/engine/runtime-integration-tests/src/test/java/org/enso/interpreter/caches/ModuleCacheTest.java b/engine/runtime-integration-tests/src/test/java/org/enso/interpreter/caches/ModuleCacheTest.java index 4c0470a12928..8551d7615845 100644 --- a/engine/runtime-integration-tests/src/test/java/org/enso/interpreter/caches/ModuleCacheTest.java +++ b/engine/runtime-integration-tests/src/test/java/org/enso/interpreter/caches/ModuleCacheTest.java @@ -11,7 +11,7 @@ import org.enso.compiler.CompilerTest; import org.enso.interpreter.runtime.EnsoContext; import org.enso.polyglot.RuntimeOptions; -import org.enso.test.utils.TestUtils; +import org.enso.test.utils.ContextUtils; import org.graalvm.polyglot.Context; import org.graalvm.polyglot.Source; import org.junit.BeforeClass; @@ -25,7 +25,9 @@ public ModuleCacheTest() {} @BeforeClass public static void initializeContext() throws Exception { ctx = - TestUtils.defaultContextBuilder().option(RuntimeOptions.DISABLE_IR_CACHES, "true").build(); + ContextUtils.defaultContextBuilder() + .option(RuntimeOptions.DISABLE_IR_CACHES, "true") + .build(); } @Test diff --git a/engine/runtime-integration-tests/src/test/java/org/enso/interpreter/node/callable/PolyglotCallTypeTest.java b/engine/runtime-integration-tests/src/test/java/org/enso/interpreter/node/callable/PolyglotCallTypeTest.java index 08936d1e1abe..db363ddee719 100644 --- a/engine/runtime-integration-tests/src/test/java/org/enso/interpreter/node/callable/PolyglotCallTypeTest.java +++ b/engine/runtime-integration-tests/src/test/java/org/enso/interpreter/node/callable/PolyglotCallTypeTest.java @@ -7,7 +7,7 @@ import java.math.BigInteger; import org.enso.interpreter.node.callable.resolver.HostMethodCallNode; import org.enso.interpreter.runtime.callable.UnresolvedSymbol; -import org.enso.test.utils.TestUtils; +import org.enso.test.utils.ContextUtils; import org.graalvm.polyglot.Context; import org.junit.AfterClass; import org.junit.BeforeClass; @@ -21,7 +21,7 @@ public PolyglotCallTypeTest() {} @BeforeClass public static void setupCtx() { - ctx = TestUtils.defaultContextBuilder().build(); + ctx = ContextUtils.defaultContextBuilder().build(); } @AfterClass @@ -32,7 +32,7 @@ public static void closeCtx() { @Test public void javaBigIntegerDispatch() { var big = new BigInteger("4324908174321000432143143778956741"); - var val = TestUtils.unwrapValue(ctx, ctx.asValue(big)); + var val = ContextUtils.unwrapValue(ctx, ctx.asValue(big)); var sym = UnresolvedSymbol.build("+", null); var typ = HostMethodCallNode.getPolyglotCallType(val, sym, InteropLibrary.getUncached()); assertEquals(HostMethodCallNode.PolyglotCallType.CONVERT_TO_BIG_INT, typ); diff --git a/engine/runtime-integration-tests/src/test/java/org/enso/interpreter/node/expression/builtin/meta/TypeOfNodeTest.java b/engine/runtime-integration-tests/src/test/java/org/enso/interpreter/node/expression/builtin/meta/TypeOfNodeTest.java index f70dd2c55292..1c85d1992f23 100644 --- a/engine/runtime-integration-tests/src/test/java/org/enso/interpreter/node/expression/builtin/meta/TypeOfNodeTest.java +++ b/engine/runtime-integration-tests/src/test/java/org/enso/interpreter/node/expression/builtin/meta/TypeOfNodeTest.java @@ -10,7 +10,8 @@ import org.enso.interpreter.runtime.error.DataflowError; import org.enso.interpreter.runtime.library.dispatch.TypeOfNode; import org.enso.interpreter.test.ValuesGenerator; -import org.enso.test.utils.TestUtils; +import org.enso.test.utils.ContextUtils; +import org.enso.test.utils.TestRootNode; import org.graalvm.polyglot.Context; import org.junit.AfterClass; import org.junit.Test; @@ -29,7 +30,7 @@ public class TypeOfNodeTest { private static Context ctx() { if (ctx == null) { - ctx = TestUtils.defaultContextBuilder().build(); + ctx = ContextUtils.defaultContextBuilder().build(); } return ctx; } @@ -38,7 +39,7 @@ private static Context ctx() { public static Object[][] allPossibleEnsoInterpreterValues() throws Exception { var g = ValuesGenerator.create(ctx()); var typeOf = - TestUtils.evalModule( + ContextUtils.evalModule( ctx(), """ from Standard.Base import all @@ -52,7 +53,7 @@ public static Object[][] allPossibleEnsoInterpreterValues() throws Exception { if (!v.isNull()) { assertTrue("Type of " + v + " is " + t, t.isMetaObject()); var n = t.getMetaSimpleName(); - var raw = TestUtils.unwrapValue(ctx(), v); + var raw = ContextUtils.unwrapValue(ctx(), v); data.add(new Object[] {raw, n}); } } @@ -79,11 +80,11 @@ public void typeOfCheckAfterPriming() { } private void assertType(Object symbol, String expectedTypeName, boolean withPriming) { - TestUtils.executeInContext( + ContextUtils.executeInContext( ctx(), () -> { var node = TypeOfNode.create(); - var root = new TestUtils.TestRootNode((frame) -> node.execute(frame.getArguments()[0])); + var root = new TestRootNode((frame) -> node.execute(frame.getArguments()[0])); root.insertChildren(node); var call = root.getCallTarget(); diff --git a/engine/runtime-integration-tests/src/test/java/org/enso/interpreter/runtime/ResourceManagerTest.java b/engine/runtime-integration-tests/src/test/java/org/enso/interpreter/runtime/ResourceManagerTest.java index dff35ea06f86..397d301b4c1f 100644 --- a/engine/runtime-integration-tests/src/test/java/org/enso/interpreter/runtime/ResourceManagerTest.java +++ b/engine/runtime-integration-tests/src/test/java/org/enso/interpreter/runtime/ResourceManagerTest.java @@ -10,7 +10,7 @@ import com.oracle.truffle.api.library.ExportMessage; import org.enso.common.LanguageInfo; import org.enso.common.MethodNames; -import org.enso.test.utils.TestUtils; +import org.enso.test.utils.ContextUtils; import org.junit.Test; public class ResourceManagerTest { @@ -22,7 +22,7 @@ public void runFinalizersAtTheEnd() { var obj = new ResourceToGc(); var fn = new FnCallback(); - try (var ctx = TestUtils.createDefaultContext()) { + try (var ctx = ContextUtils.createDefaultContext()) { ctx.enter(); var ensoContext = (EnsoContext) diff --git a/engine/runtime-integration-tests/src/test/java/org/enso/interpreter/test/AtomConstructorTest.java b/engine/runtime-integration-tests/src/test/java/org/enso/interpreter/test/AtomConstructorTest.java index 6bfb0b12ce5e..e177512bbc88 100644 --- a/engine/runtime-integration-tests/src/test/java/org/enso/interpreter/test/AtomConstructorTest.java +++ b/engine/runtime-integration-tests/src/test/java/org/enso/interpreter/test/AtomConstructorTest.java @@ -11,7 +11,7 @@ import org.enso.interpreter.runtime.data.atom.AtomNewInstanceNode; import org.enso.interpreter.runtime.data.atom.StructsLibrary; import org.enso.interpreter.runtime.error.PanicException; -import org.enso.test.utils.TestUtils; +import org.enso.test.utils.ContextUtils; import org.graalvm.polyglot.Context; import org.junit.AfterClass; import org.junit.BeforeClass; @@ -25,7 +25,7 @@ public AtomConstructorTest() {} @BeforeClass public static void initContext() { - ctx = TestUtils.createDefaultContext(); + ctx = ContextUtils.createDefaultContext(); } @AfterClass @@ -41,7 +41,7 @@ public void testGetUncached() { """; var module = ctx.eval("enso", code); var consA = module.invokeMember(MethodNames.Module.EVAL_EXPRESSION, "NoPrime.A"); - var raw = TestUtils.unwrapValue(ctx, consA); + var raw = ContextUtils.unwrapValue(ctx, consA); assertTrue("It is atom constructor: " + raw, raw instanceof AtomConstructor); var cons = (AtomConstructor) raw; @@ -60,7 +60,7 @@ public void testAtomNewInstanceNode() { """; var module = ctx.eval("enso", code); var xA = module.invokeMember(MethodNames.Module.EVAL_EXPRESSION, "X.A"); - var raw = TestUtils.unwrapValue(ctx, xA); + var raw = ContextUtils.unwrapValue(ctx, xA); assertTrue("It is atom constructor: " + raw, raw instanceof AtomConstructor); var cons = (AtomConstructor) raw; @@ -138,7 +138,7 @@ private static void assertAtomFactory(String msg, Function factory) { - TestUtils.executeInContext( + ContextUtils.executeInContext( ctx, () -> { try { @@ -182,7 +182,7 @@ public void endlessConstructors() throws Exception { var module = ctx.eval("enso", sb.toString()); for (var i = 0; i < constructors.length; i++) { var c = module.invokeMember(MethodNames.Module.EVAL_EXPRESSION, "T.V" + i); - constructors[i] = (AtomConstructor) TestUtils.unwrapValue(ctx, c); + constructors[i] = (AtomConstructor) ContextUtils.unwrapValue(ctx, c); } var typeValue = ctx.asValue(constructors[0].getType()); diff --git a/engine/runtime-integration-tests/src/test/java/org/enso/interpreter/test/AutoscopedConstructorTest.java b/engine/runtime-integration-tests/src/test/java/org/enso/interpreter/test/AutoscopedConstructorTest.java index ce1a1b37c440..a50de81e72b2 100644 --- a/engine/runtime-integration-tests/src/test/java/org/enso/interpreter/test/AutoscopedConstructorTest.java +++ b/engine/runtime-integration-tests/src/test/java/org/enso/interpreter/test/AutoscopedConstructorTest.java @@ -7,7 +7,7 @@ import java.io.ByteArrayOutputStream; import org.enso.common.MethodNames; -import org.enso.test.utils.TestUtils; +import org.enso.test.utils.ContextUtils; import org.graalvm.polyglot.Context; import org.graalvm.polyglot.PolyglotException; import org.junit.AfterClass; @@ -23,7 +23,7 @@ public AutoscopedConstructorTest() {} @BeforeClass public static void prepareCtx() { - ctx = TestUtils.createDefaultContext(out); + ctx = ContextUtils.createDefaultContext(out); } @Before diff --git a/engine/runtime-integration-tests/src/test/java/org/enso/interpreter/test/BigNumberTest.java b/engine/runtime-integration-tests/src/test/java/org/enso/interpreter/test/BigNumberTest.java index 78a86ee3ce5a..0a497a206ca3 100644 --- a/engine/runtime-integration-tests/src/test/java/org/enso/interpreter/test/BigNumberTest.java +++ b/engine/runtime-integration-tests/src/test/java/org/enso/interpreter/test/BigNumberTest.java @@ -9,7 +9,7 @@ import java.net.URI; import java.net.URISyntaxException; import java.util.ArrayList; -import org.enso.test.utils.TestUtils; +import org.enso.test.utils.ContextUtils; import org.graalvm.polyglot.Context; import org.graalvm.polyglot.Source; import org.graalvm.polyglot.Value; @@ -22,7 +22,7 @@ public class BigNumberTest { @BeforeClass public static void prepareCtx() { - ctx = TestUtils.createDefaultContext(); + ctx = ContextUtils.createDefaultContext(); } @AfterClass diff --git a/engine/runtime-integration-tests/src/test/java/org/enso/interpreter/test/BinaryDispatchTest.java b/engine/runtime-integration-tests/src/test/java/org/enso/interpreter/test/BinaryDispatchTest.java index 2c6d6842508e..c0eaac928288 100644 --- a/engine/runtime-integration-tests/src/test/java/org/enso/interpreter/test/BinaryDispatchTest.java +++ b/engine/runtime-integration-tests/src/test/java/org/enso/interpreter/test/BinaryDispatchTest.java @@ -8,7 +8,7 @@ import org.enso.common.MethodNames; import org.enso.interpreter.runtime.error.PanicException; -import org.enso.test.utils.TestUtils; +import org.enso.test.utils.ContextUtils; import org.graalvm.polyglot.Context; import org.graalvm.polyglot.PolyglotException; import org.graalvm.polyglot.Source; @@ -26,7 +26,7 @@ public BinaryDispatchTest() {} @BeforeClass public static void initCtx() throws Exception { - ctx = TestUtils.createDefaultContext(); + ctx = ContextUtils.createDefaultContext(); var prelude = Source.newBuilder( diff --git a/engine/runtime-integration-tests/src/test/java/org/enso/interpreter/test/BinaryOpFloatTest.java b/engine/runtime-integration-tests/src/test/java/org/enso/interpreter/test/BinaryOpFloatTest.java index 7880972ad4fa..5a5638bd30a4 100644 --- a/engine/runtime-integration-tests/src/test/java/org/enso/interpreter/test/BinaryOpFloatTest.java +++ b/engine/runtime-integration-tests/src/test/java/org/enso/interpreter/test/BinaryOpFloatTest.java @@ -8,7 +8,7 @@ import java.util.Random; import java.util.stream.Stream; import org.enso.common.MethodNames; -import org.enso.test.utils.TestUtils; +import org.enso.test.utils.ContextUtils; import org.graalvm.polyglot.Context; import org.graalvm.polyglot.PolyglotException; import org.graalvm.polyglot.Value; @@ -57,7 +57,7 @@ public static Object[][] parameters() { @BeforeClass public static void initContext() { - ctx = TestUtils.createDefaultContext(); + ctx = ContextUtils.createDefaultContext(); wrapReal = ctx.eval( "enso", @@ -103,7 +103,7 @@ public BinaryOpFloatTest(String operation, double n1, double n2) { @Test public void verifyOperationOnForeignObject() { - TestUtils.executeInContext( + ContextUtils.executeInContext( ctx, () -> { var code = """ @@ -123,7 +123,7 @@ public void verifyOperationOnForeignObject() { @Test public void verifyOperationWithConvertibleObject() { - TestUtils.executeInContext( + ContextUtils.executeInContext( ctx, () -> { var code = """ @@ -148,7 +148,7 @@ public void verifyOperationWithConvertibleObject() { @Test public void verifyOperationOnConvertibleObject() { - TestUtils.executeInContext( + ContextUtils.executeInContext( ctx, () -> { var code = """ diff --git a/engine/runtime-integration-tests/src/test/java/org/enso/interpreter/test/BinaryOpIntegerTest.java b/engine/runtime-integration-tests/src/test/java/org/enso/interpreter/test/BinaryOpIntegerTest.java index 7cbdaa4cfc28..c93e7addb567 100644 --- a/engine/runtime-integration-tests/src/test/java/org/enso/interpreter/test/BinaryOpIntegerTest.java +++ b/engine/runtime-integration-tests/src/test/java/org/enso/interpreter/test/BinaryOpIntegerTest.java @@ -8,7 +8,7 @@ import java.util.Random; import java.util.stream.Stream; import org.enso.common.MethodNames; -import org.enso.test.utils.TestUtils; +import org.enso.test.utils.ContextUtils; import org.graalvm.polyglot.Context; import org.graalvm.polyglot.Value; import org.junit.AfterClass; @@ -71,7 +71,7 @@ public static Object[][] parameters() { @BeforeClass public static void initContext() { - ctx = TestUtils.createDefaultContext(); + ctx = ContextUtils.createDefaultContext(); wrapInt = ctx.eval( "enso", @@ -122,7 +122,7 @@ public BinaryOpIntegerTest(String operation, long n1, long n2) { @Test public void verifyOperationOnForeignObject() { - TestUtils.executeInContext( + ContextUtils.executeInContext( ctx, () -> { var code = """ @@ -142,7 +142,7 @@ public void verifyOperationOnForeignObject() { @Test public void verifyOperationWithConvertibleObject() { - TestUtils.executeInContext( + ContextUtils.executeInContext( ctx, () -> { var code = """ @@ -169,7 +169,7 @@ public void verifyOperationWithConvertibleObject() { @Test public void verifyOperationOnConvertibleObject() { - TestUtils.executeInContext( + ContextUtils.executeInContext( ctx, () -> { var code = """ diff --git a/engine/runtime-integration-tests/src/test/java/org/enso/interpreter/test/ConversionMethodTests.java b/engine/runtime-integration-tests/src/test/java/org/enso/interpreter/test/ConversionMethodTests.java index 203cf33fa9d8..2f560f39850f 100644 --- a/engine/runtime-integration-tests/src/test/java/org/enso/interpreter/test/ConversionMethodTests.java +++ b/engine/runtime-integration-tests/src/test/java/org/enso/interpreter/test/ConversionMethodTests.java @@ -5,7 +5,7 @@ import java.io.ByteArrayOutputStream; import java.nio.charset.StandardCharsets; -import org.enso.test.utils.TestUtils; +import org.enso.test.utils.ContextUtils; import org.graalvm.polyglot.Context; import org.graalvm.polyglot.Value; import org.hamcrest.MatcherAssert; @@ -22,7 +22,7 @@ public class ConversionMethodTests { @BeforeClass public static void initCtx() { - ctx = TestUtils.createDefaultContext(out); + ctx = ContextUtils.createDefaultContext(out); } @AfterClass @@ -55,7 +55,7 @@ public void testSimpleConversion() { main = (Foo.from (Baz.Mk_Baz 10)).foo + (Foo.from (Bar.Mk_Bar 20)).foo """; - Value res = TestUtils.evalModule(ctx, src); + Value res = ContextUtils.evalModule(ctx, src); assertEquals(30, res.asInt()); } @@ -75,7 +75,7 @@ public void testDispatchOnHostMap() { jmap = Java_Map.of "A" 1 "B" 2 "C" 3 Foo.from jmap . data . size """; - Value res = TestUtils.evalModule(ctx, src); + Value res = ContextUtils.evalModule(ctx, src); assertEquals(3, res.asInt()); } @@ -99,7 +99,7 @@ public void testDispatchOnJSMap() { main = Foo.from js_map . data . size """; - Value res = TestUtils.evalModule(ctx, src); + Value res = ContextUtils.evalModule(ctx, src); assertEquals(2, res.asInt()); } @@ -120,7 +120,7 @@ public void testDispatchOnJSDateTime() { main = Foo.from (js_date 2023 2 7 23 59 0 10) . data . day """; - Value res = TestUtils.evalModule(ctx, src); + Value res = ContextUtils.evalModule(ctx, src); assertEquals(7, res.asInt()); } @@ -139,7 +139,7 @@ public void testAmbiguousConversionStrictUnused() { main = 42 """; try { - Value res = TestUtils.evalModule(ctx, src); + Value res = ContextUtils.evalModule(ctx, src); fail("Expected an exception, but got " + res); } catch (Exception e) { MatcherAssert.assertThat(e.getMessage(), Matchers.containsString("Ambiguous conversion:")); diff --git a/engine/runtime-integration-tests/src/test/java/org/enso/interpreter/test/EqualsConversionsTest.java b/engine/runtime-integration-tests/src/test/java/org/enso/interpreter/test/EqualsConversionsTest.java index fb6dffe62ca0..5ba51f0db31e 100644 --- a/engine/runtime-integration-tests/src/test/java/org/enso/interpreter/test/EqualsConversionsTest.java +++ b/engine/runtime-integration-tests/src/test/java/org/enso/interpreter/test/EqualsConversionsTest.java @@ -5,7 +5,7 @@ import static org.junit.Assert.fail; import java.util.List; -import org.enso.test.utils.TestUtils; +import org.enso.test.utils.ContextUtils; import org.graalvm.polyglot.Context; import org.graalvm.polyglot.PolyglotException; import org.junit.AfterClass; @@ -17,7 +17,7 @@ public class EqualsConversionsTest { @BeforeClass public static void initContextAndData() { - context = TestUtils.createDefaultContext(); + context = ContextUtils.createDefaultContext(); } @AfterClass @@ -28,7 +28,7 @@ public static void disposeContext() { @Test public void testBasicInequalities() { var results = - TestUtils.evalModule( + ContextUtils.evalModule( context, """ from Standard.Base import all @@ -168,7 +168,8 @@ boolean evaluate() { r0 """; var res = - TestUtils.evalModule(context, block0 + block1 + block2 + block3 + mainBlock + extraBlock); + ContextUtils.evalModule( + context, block0 + block1 + block2 + block3 + mainBlock + extraBlock); return res.asBoolean(); } } diff --git a/engine/runtime-integration-tests/src/test/java/org/enso/interpreter/test/EqualsTest.java b/engine/runtime-integration-tests/src/test/java/org/enso/interpreter/test/EqualsTest.java index eb5ace46273e..6d62fb048326 100644 --- a/engine/runtime-integration-tests/src/test/java/org/enso/interpreter/test/EqualsTest.java +++ b/engine/runtime-integration-tests/src/test/java/org/enso/interpreter/test/EqualsTest.java @@ -1,9 +1,9 @@ package org.enso.interpreter.test; -import static org.enso.test.utils.TestUtils.createDefaultContext; -import static org.enso.test.utils.TestUtils.createValue; -import static org.enso.test.utils.TestUtils.executeInContext; -import static org.enso.test.utils.TestUtils.unwrapValue; +import static org.enso.test.utils.ContextUtils.createDefaultContext; +import static org.enso.test.utils.ContextUtils.createValue; +import static org.enso.test.utils.ContextUtils.executeInContext; +import static org.enso.test.utils.ContextUtils.unwrapValue; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertNotEquals; @@ -24,7 +24,7 @@ import org.enso.interpreter.node.expression.builtin.meta.EqualsNode; import org.enso.interpreter.runtime.callable.UnresolvedConversion; import org.enso.interpreter.runtime.number.EnsoBigInteger; -import org.enso.test.utils.TestUtils.TestRootNode; +import org.enso.test.utils.TestRootNode; import org.graalvm.polyglot.Context; import org.graalvm.polyglot.Source; import org.graalvm.polyglot.Value; diff --git a/engine/runtime-integration-tests/src/test/java/org/enso/interpreter/test/ExtensionMethodResolutionTest.java b/engine/runtime-integration-tests/src/test/java/org/enso/interpreter/test/ExtensionMethodResolutionTest.java index c0f4ba87e600..d28e6d9dd060 100644 --- a/engine/runtime-integration-tests/src/test/java/org/enso/interpreter/test/ExtensionMethodResolutionTest.java +++ b/engine/runtime-integration-tests/src/test/java/org/enso/interpreter/test/ExtensionMethodResolutionTest.java @@ -14,8 +14,9 @@ import org.enso.polyglot.PolyglotContext; import org.enso.polyglot.RuntimeOptions; import org.enso.polyglot.TopScope; +import org.enso.test.utils.ContextUtils; +import org.enso.test.utils.ProjectUtils; import org.enso.test.utils.SourceModule; -import org.enso.test.utils.TestUtils; import org.graalvm.polyglot.PolyglotException; import org.hamcrest.Matcher; import org.junit.Rule; @@ -81,8 +82,8 @@ public void firstResolutionIsInTypesScope() throws IOException { main = T.foo """); var projDir = tempFolder.newFolder().toPath(); - TestUtils.createProject("Proj", Set.of(xMod, yMod, mainMod), projDir); - TestUtils.testProjectRun( + ProjectUtils.createProject("Proj", Set.of(xMod, yMod, mainMod), projDir); + ProjectUtils.testProjectRun( projDir, res -> { assertThat( @@ -113,8 +114,8 @@ public void secondResolutionIsInCurrentModuleScope() throws IOException { main = T.foo """); var projDir = tempFolder.newFolder().toPath(); - TestUtils.createProject("Proj", Set.of(xMod, yMod, mainMod), projDir); - TestUtils.testProjectRun( + ProjectUtils.createProject("Proj", Set.of(xMod, yMod, mainMod), projDir); + ProjectUtils.testProjectRun( projDir, res -> { assertThat( @@ -154,8 +155,8 @@ public void resolutionFromImportedModulesIsDeterministic1() throws IOException { main = T.foo """); var projDir = tempFolder.newFolder().toPath(); - TestUtils.createProject("Proj", Set.of(xMod, yMod, zMod, mainMod), projDir); - TestUtils.testProjectRun( + ProjectUtils.createProject("Proj", Set.of(xMod, yMod, zMod, mainMod), projDir); + ProjectUtils.testProjectRun( projDir, res -> { assertThat( @@ -196,8 +197,8 @@ public void resolutionFromImportedModulesIsDeterministic2() throws IOException { main = T.foo """); var projDir = tempFolder.newFolder().toPath(); - TestUtils.createProject("Proj", Set.of(xMod, yMod, zMod, mainMod), projDir); - TestUtils.testProjectRun( + ProjectUtils.createProject("Proj", Set.of(xMod, yMod, zMod, mainMod), projDir); + ProjectUtils.testProjectRun( projDir, res -> { assertThat( @@ -229,8 +230,8 @@ public void sameMethodInShadowedType() throws IOException { T.method """); var projDir = tempFolder.newFolder().toPath(); - TestUtils.createProject("Proj", Set.of(mod, mainMod), projDir); - TestUtils.testProjectRun( + ProjectUtils.createProject("Proj", Set.of(mod, mainMod), projDir); + ProjectUtils.testProjectRun( projDir, res -> { assertThat(res.isNumber(), is(true)); @@ -259,8 +260,8 @@ public void sameExtensionMethodInDifferentTypes() throws IOException { T.method """); var projDir = tempFolder.newFolder().toPath(); - TestUtils.createProject("Proj", Set.of(mod, mainMod), projDir); - TestUtils.testProjectRun( + ProjectUtils.createProject("Proj", Set.of(mod, mainMod), projDir); + ProjectUtils.testProjectRun( projDir, res -> { assertThat(res.isNumber(), is(true)); @@ -296,8 +297,8 @@ public void sameExtensionMethodInDifferentTypesInThreeModules() throws IOExcepti T.method """); var projDir = tempFolder.newFolder().toPath(); - TestUtils.createProject("Proj", Set.of(mod2, mod1, mainMod), projDir); - TestUtils.testProjectRun( + ProjectUtils.createProject("Proj", Set.of(mod2, mod1, mainMod), projDir); + ProjectUtils.testProjectRun( projDir, res -> { assertThat(res.isNumber(), is(true)); @@ -308,7 +309,7 @@ public void sameExtensionMethodInDifferentTypesInThreeModules() throws IOExcepti private void testProjectCompilationFailure(String mainSrc, Matcher errorMessageMatcher) throws IOException { var projDir = tempFolder.newFolder().toPath(); - TestUtils.createProject("Proj", mainSrc, projDir); + ProjectUtils.createProject("Proj", mainSrc, projDir); testProjectCompilationFailure(projDir, errorMessageMatcher); } @@ -316,7 +317,7 @@ private void testProjectCompilationFailure( Path mainProjDir, Matcher errorMessageMatcher) { var out = new ByteArrayOutputStream(); try (var ctx = - TestUtils.defaultContextBuilder() + ContextUtils.defaultContextBuilder() .option(RuntimeOptions.PROJECT_ROOT, mainProjDir.toAbsolutePath().toString()) .option(RuntimeOptions.STRICT_ERRORS, "true") .option(RuntimeOptions.DISABLE_IR_CACHES, "true") diff --git a/engine/runtime-integration-tests/src/test/java/org/enso/interpreter/test/FindExceptionMessageTest.java b/engine/runtime-integration-tests/src/test/java/org/enso/interpreter/test/FindExceptionMessageTest.java index c6f6d2b00f9f..ea181150396f 100644 --- a/engine/runtime-integration-tests/src/test/java/org/enso/interpreter/test/FindExceptionMessageTest.java +++ b/engine/runtime-integration-tests/src/test/java/org/enso/interpreter/test/FindExceptionMessageTest.java @@ -9,7 +9,7 @@ import org.enso.common.HostEnsoUtils; import org.enso.interpreter.instrument.job.VisualizationResult; -import org.enso.test.utils.TestUtils; +import org.enso.test.utils.ContextUtils; import org.graalvm.polyglot.Context; import org.graalvm.polyglot.PolyglotException; import org.graalvm.polyglot.Value; @@ -23,7 +23,7 @@ public class FindExceptionMessageTest { @BeforeClass public static void initCtx() { - ctx = TestUtils.createDefaultContext(); + ctx = ContextUtils.createDefaultContext(); } @AfterClass @@ -44,7 +44,7 @@ public void testThrowNPE() { """; try { - Value res = TestUtils.evalModule(ctx, src); + Value res = ContextUtils.evalModule(ctx, src); fail("No result expected: " + res); } catch (PolyglotException ex) { assertExceptionMessage("java.lang.NullPointerException", ex); @@ -64,7 +64,7 @@ public void testThrowNPEWithName() { """; try { - Value res = TestUtils.evalModule(ctx, src); + Value res = ContextUtils.evalModule(ctx, src); fail("No result expected: " + res); } catch (PolyglotException ex) { assertExceptionMessage("Hello World!", ex); @@ -85,7 +85,7 @@ public void errorThrowDeep() { d """; - var res = TestUtils.evalModule(ctx, src); + var res = ContextUtils.evalModule(ctx, src); assertTrue("Expecting error: " + res, res.isException()); assertEquals("Standard.Base.Error.Error", res.getMetaObject().getMetaQualifiedName()); @@ -115,7 +115,7 @@ public void panicThrowDeepRecoverError() { d """; - var res = TestUtils.evalModule(ctx, src); + var res = ContextUtils.evalModule(ctx, src); assertTrue("Expecting recovered error: " + res, res.isException()); assertEquals( "Panic was converted to error", @@ -159,7 +159,7 @@ public void panicThrowDeepMixingJava() { d """; - var res = TestUtils.evalModule(ctx, src); + var res = ContextUtils.evalModule(ctx, src); assertTrue("Expecting recovered error: " + res, res.isException()); assertEquals( "Panic was converted to error", @@ -198,7 +198,7 @@ public void testPanic() { """; try { - Value res = TestUtils.evalModule(ctx, src); + Value res = ContextUtils.evalModule(ctx, src); fail("No result expected: " + res); } catch (PolyglotException ex) { assertExceptionMessage("Illegal Argument: Jejda!", ex); @@ -209,7 +209,7 @@ private void assertExceptionMessage(String exp, PolyglotException ex) { var msg = HostEnsoUtils.findExceptionMessage(ex); assertEquals(exp, msg); - TestUtils.executeInContext( + ContextUtils.executeInContext( ctx, () -> { var guestException = extractHostException(ex); @@ -225,7 +225,7 @@ static Throwable extractHostException(PolyglotException ex) { } else { assertTrue("Has to be guest object: " + ex, ex.isGuestException()); var v = ex.getGuestObject(); - return (Throwable) TestUtils.unwrapValue(ctx, v); + return (Throwable) ContextUtils.unwrapValue(ctx, v); } } } diff --git a/engine/runtime-integration-tests/src/test/java/org/enso/interpreter/test/ForeignMethodInvokeTest.java b/engine/runtime-integration-tests/src/test/java/org/enso/interpreter/test/ForeignMethodInvokeTest.java index 576a3df4da55..fbcbed8b284b 100644 --- a/engine/runtime-integration-tests/src/test/java/org/enso/interpreter/test/ForeignMethodInvokeTest.java +++ b/engine/runtime-integration-tests/src/test/java/org/enso/interpreter/test/ForeignMethodInvokeTest.java @@ -8,7 +8,7 @@ import com.oracle.truffle.api.library.ExportLibrary; import com.oracle.truffle.api.library.ExportMessage; import java.util.concurrent.Executors; -import org.enso.test.utils.TestUtils; +import org.enso.test.utils.ContextUtils; import org.graalvm.polyglot.Context; import org.graalvm.polyglot.Value; import org.junit.AfterClass; @@ -21,7 +21,7 @@ public class ForeignMethodInvokeTest { @BeforeClass public static void prepareCtx() { - ctx = TestUtils.defaultContextBuilder("enso", "js").build(); + ctx = ContextUtils.defaultContextBuilder("enso", "js").build(); } @AfterClass diff --git a/engine/runtime-integration-tests/src/test/java/org/enso/interpreter/test/HashCodeTest.java b/engine/runtime-integration-tests/src/test/java/org/enso/interpreter/test/HashCodeTest.java index 796449c7833a..41b2e809c405 100644 --- a/engine/runtime-integration-tests/src/test/java/org/enso/interpreter/test/HashCodeTest.java +++ b/engine/runtime-integration-tests/src/test/java/org/enso/interpreter/test/HashCodeTest.java @@ -12,7 +12,8 @@ import org.enso.interpreter.node.expression.builtin.meta.HashCodeNode; import org.enso.interpreter.node.expression.builtin.meta.HashCodeNodeGen; import org.enso.interpreter.runtime.EnsoContext; -import org.enso.test.utils.TestUtils; +import org.enso.test.utils.ContextUtils; +import org.enso.test.utils.TestRootNode; import org.graalvm.polyglot.Context; import org.graalvm.polyglot.Value; import org.junit.AfterClass; @@ -30,18 +31,18 @@ public class HashCodeTest { private static HashCodeNode hashCodeNode; private static EqualsNode equalsNode; private static HostValueToEnsoNode hostValueToEnsoNode; - private static TestUtils.TestRootNode testRootNode; + private static TestRootNode testRootNode; @BeforeClass public static void initContextAndData() { - context = TestUtils.createDefaultContext(); - TestUtils.executeInContext( + context = ContextUtils.createDefaultContext(); + ContextUtils.executeInContext( context, () -> { hashCodeNode = HashCodeNode.build(); equalsNode = EqualsNode.create(); hostValueToEnsoNode = HostValueToEnsoNode.build(); - testRootNode = new TestUtils.TestRootNode(); + testRootNode = new TestRootNode(); testRootNode.insertChildren(hashCodeNode, equalsNode, hostValueToEnsoNode); return null; }); @@ -79,7 +80,7 @@ private static Object[] fetchAllUnwrappedValues() { values.addAll(valGenerator.warnings()); try { return values.stream() - .map(value -> TestUtils.unwrapValue(context, value)) + .map(value -> ContextUtils.unwrapValue(context, value)) .map(unwrappedValue -> hostValueToEnsoNode.execute(unwrappedValue)) .collect(Collectors.toList()) .toArray(new Object[] {}); @@ -90,7 +91,7 @@ private static Object[] fetchAllUnwrappedValues() { @Theory public void hashCodeContractTheory(Object firstValue, Object secondValue) { - TestUtils.executeInContext( + ContextUtils.executeInContext( context, () -> { long firstHash = hashCodeNode.execute(firstValue); @@ -124,7 +125,7 @@ public void hashCodeContractTheory(Object firstValue, Object secondValue) { @Theory public void hashCodeIsConsistent(Object value) { - TestUtils.executeInContext( + ContextUtils.executeInContext( context, () -> { long firstHash = hashCodeNode.execute(value); @@ -136,7 +137,7 @@ public void hashCodeIsConsistent(Object value) { @Theory public void hashCodeCachedNodeIsConsistentWithUncached(Object value) { - TestUtils.executeInContext( + ContextUtils.executeInContext( context, () -> { long uncachedRes = HashCodeNodeGen.getUncached().execute(value); diff --git a/engine/runtime-integration-tests/src/test/java/org/enso/interpreter/test/InsightForEnsoTest.java b/engine/runtime-integration-tests/src/test/java/org/enso/interpreter/test/InsightForEnsoTest.java index f4537d3e79b8..134e1d55404d 100644 --- a/engine/runtime-integration-tests/src/test/java/org/enso/interpreter/test/InsightForEnsoTest.java +++ b/engine/runtime-integration-tests/src/test/java/org/enso/interpreter/test/InsightForEnsoTest.java @@ -8,7 +8,7 @@ import java.io.ByteArrayOutputStream; import java.util.Map; import java.util.function.Function; -import org.enso.test.utils.TestUtils; +import org.enso.test.utils.ContextUtils; import org.graalvm.polyglot.Context; import org.graalvm.polyglot.Language; import org.graalvm.polyglot.Source; @@ -23,7 +23,7 @@ public class InsightForEnsoTest { @Before public void initContext() throws Exception { - this.ctx = TestUtils.defaultContextBuilder().out(out).build(); + this.ctx = ContextUtils.defaultContextBuilder().out(out).build(); var engine = ctx.getEngine(); Map langs = engine.getLanguages(); diff --git a/engine/runtime-integration-tests/src/test/java/org/enso/interpreter/test/IntegerTest.java b/engine/runtime-integration-tests/src/test/java/org/enso/interpreter/test/IntegerTest.java index 58f6afc3d0a4..88aa5d1552a9 100644 --- a/engine/runtime-integration-tests/src/test/java/org/enso/interpreter/test/IntegerTest.java +++ b/engine/runtime-integration-tests/src/test/java/org/enso/interpreter/test/IntegerTest.java @@ -9,7 +9,7 @@ import org.enso.interpreter.node.expression.builtin.number.integer.AddNode; import org.enso.interpreter.runtime.error.PanicException; import org.enso.interpreter.runtime.number.EnsoBigInteger; -import org.enso.test.utils.TestUtils; +import org.enso.test.utils.ContextUtils; import org.graalvm.polyglot.Context; import org.junit.AfterClass; import org.junit.BeforeClass; @@ -27,8 +27,8 @@ public class IntegerTest { @BeforeClass public static void setup() { - ctx = TestUtils.createDefaultContext(); - TestUtils.executeInContext( + ctx = ContextUtils.createDefaultContext(); + ContextUtils.executeInContext( ctx, () -> { absNode = AbsNode.build(); @@ -49,7 +49,7 @@ public static void teardown() { @Test public void testAbs() { - TestUtils.executeInContext( + ContextUtils.executeInContext( ctx, () -> { assertEquals(23L, absNode.execute(23L)); @@ -67,7 +67,7 @@ public void testAbs() { @Test public void testAdd() { - TestUtils.executeInContext( + ContextUtils.executeInContext( ctx, () -> { assertEquals(23L, addNode.execute(22L, 1L)); diff --git a/engine/runtime-integration-tests/src/test/java/org/enso/interpreter/test/JavaInteropTest.java b/engine/runtime-integration-tests/src/test/java/org/enso/interpreter/test/JavaInteropTest.java index 11b5725a7487..e4b000593d50 100644 --- a/engine/runtime-integration-tests/src/test/java/org/enso/interpreter/test/JavaInteropTest.java +++ b/engine/runtime-integration-tests/src/test/java/org/enso/interpreter/test/JavaInteropTest.java @@ -8,7 +8,7 @@ import java.io.ByteArrayOutputStream; import java.nio.charset.StandardCharsets; import java.util.List; -import org.enso.test.utils.TestUtils; +import org.enso.test.utils.ContextUtils; import org.graalvm.polyglot.Context; import org.graalvm.polyglot.PolyglotException; import org.graalvm.polyglot.Value; @@ -24,7 +24,7 @@ public class JavaInteropTest { @BeforeClass public static void prepareCtx() { - ctx = TestUtils.createDefaultContext(out); + ctx = ContextUtils.createDefaultContext(out); } @AfterClass @@ -42,7 +42,7 @@ private String[] getStdOutLines() { } private void checkPrint(String code, List expected) { - Value result = TestUtils.evalModule(ctx, code); + Value result = ContextUtils.evalModule(ctx, code); assertTrue("should return Nothing", result.isNull()); assertArrayEquals(expected.toArray(), getStdOutLines()); } @@ -54,7 +54,7 @@ public void testClassImport() { polyglot java import org.enso.example.TestClass main = TestClass.add 1 2 """; - var result = TestUtils.evalModule(ctx, code); + var result = ContextUtils.evalModule(ctx, code); assertEquals(3, result.asInt()); } @@ -68,7 +68,7 @@ public void testClassImportAndMethodCall() { instance = TestClass.new (x -> x * 2) instance.callFunctionAndIncrement 10 """; - var result = TestUtils.evalModule(ctx, code); + var result = ContextUtils.evalModule(ctx, code); assertEquals(21, result.asInt()); } @@ -82,7 +82,7 @@ public void testImportStaticInnerClass() { instance = StaticInnerClass.new "my_data" instance.add 1 2 """; - var result = TestUtils.evalModule(ctx, code); + var result = ContextUtils.evalModule(ctx, code); assertEquals(3, result.asInt()); } @@ -177,7 +177,7 @@ public void testImportOuterClassAndReferenceInner() { instance = TestClass.StaticInnerClass.new "my_data" instance.getData """; - var result = TestUtils.evalModule(ctx, code); + var result = ContextUtils.evalModule(ctx, code); assertEquals("my_data", result.asString()); } @@ -208,7 +208,7 @@ public void testImportNestedInnerClass() { inner_inner_value = StaticInnerInnerClass.new inner_inner_value.mul 3 5 """; - var res = TestUtils.evalModule(ctx, code); + var res = ContextUtils.evalModule(ctx, code); assertEquals(15, res.asInt()); } @@ -219,7 +219,7 @@ public void testImportNonExistingInnerClass() { polyglot java import org.enso.example.TestClass.StaticInnerClass.Non_Existing_Class """; try { - TestUtils.evalModule(ctx, code); + ContextUtils.evalModule(ctx, code); fail("Should throw exception"); } catch (Exception ignored) { } @@ -232,7 +232,7 @@ public void testImportNonExistingInnerNestedClass() { polyglot java import org.enso.example.TestClass.Non_Existing_Class.Another_Non_ExistingClass """; try { - TestUtils.evalModule(ctx, code); + ContextUtils.evalModule(ctx, code); fail("Should throw exception"); } catch (Exception ignored) { } @@ -248,7 +248,7 @@ public void testImportOuterClassAndAccessNestedInnerClass() { instance = TestClass.StaticInnerClass.StaticInnerInnerClass.new instance.mul 3 5 """; - var res = TestUtils.evalModule(ctx, code); + var res = ContextUtils.evalModule(ctx, code); assertEquals(15, res.asInt()); } @@ -276,7 +276,7 @@ public void testToStringBehavior() { [a, b, c, d, e] """; - var res = TestUtils.evalModule(ctx, code); + var res = ContextUtils.evalModule(ctx, code); assertTrue("It is an array", res.hasArrayElements()); assertEquals("Array with five elements", 5, res.getArraySize()); assertEquals(123, res.getArrayElement(0).asInt()); @@ -335,6 +335,6 @@ private Value evalInterfaceProxyFailures(String methodToEval) { b = Panic.catch No_Such_Method (Foo.callFoo Fooable_Unresolved.Value) (caught-> caught.payload.method_name) """; - return TestUtils.evalModule(ctx, code + "\nmain = " + methodToEval); + return ContextUtils.evalModule(ctx, code + "\nmain = " + methodToEval); } } diff --git a/engine/runtime-integration-tests/src/test/java/org/enso/interpreter/test/JsInteropTest.java b/engine/runtime-integration-tests/src/test/java/org/enso/interpreter/test/JsInteropTest.java index 4c98bb22c43e..a3edd76d6c99 100644 --- a/engine/runtime-integration-tests/src/test/java/org/enso/interpreter/test/JsInteropTest.java +++ b/engine/runtime-integration-tests/src/test/java/org/enso/interpreter/test/JsInteropTest.java @@ -3,7 +3,7 @@ import static org.junit.Assert.assertEquals; import java.io.ByteArrayOutputStream; -import org.enso.test.utils.TestUtils; +import org.enso.test.utils.ContextUtils; import org.graalvm.polyglot.Context; import org.graalvm.polyglot.Value; import org.junit.After; @@ -17,7 +17,7 @@ public class JsInteropTest { @Before public void initContext() { - ctx = TestUtils.createDefaultContext(out); + ctx = ContextUtils.createDefaultContext(out); out.reset(); } @@ -41,7 +41,7 @@ public void testDefaultJSPrint() { } json.get "inner" """; - Value res = TestUtils.evalModule(ctx, src); + Value res = ContextUtils.evalModule(ctx, src); assertEquals("{\"a\":1}", res.toString()); } } diff --git a/engine/runtime-integration-tests/src/test/java/org/enso/interpreter/test/LazyAtomFieldTest.java b/engine/runtime-integration-tests/src/test/java/org/enso/interpreter/test/LazyAtomFieldTest.java index c103c89495d7..79739868c891 100644 --- a/engine/runtime-integration-tests/src/test/java/org/enso/interpreter/test/LazyAtomFieldTest.java +++ b/engine/runtime-integration-tests/src/test/java/org/enso/interpreter/test/LazyAtomFieldTest.java @@ -8,7 +8,7 @@ import java.nio.charset.StandardCharsets; import java.util.stream.Collectors; import org.enso.common.MethodNames; -import org.enso.test.utils.TestUtils; +import org.enso.test.utils.ContextUtils; import org.graalvm.polyglot.Context; import org.graalvm.polyglot.Source; import org.graalvm.polyglot.Value; @@ -23,7 +23,7 @@ public class LazyAtomFieldTest { @BeforeClass public static void prepareCtx() { - ctx = TestUtils.createDefaultContext(out); + ctx = ContextUtils.createDefaultContext(out); } @Before diff --git a/engine/runtime-integration-tests/src/test/java/org/enso/interpreter/test/ListTest.java b/engine/runtime-integration-tests/src/test/java/org/enso/interpreter/test/ListTest.java index f44e0db965a0..fb8268cba9eb 100644 --- a/engine/runtime-integration-tests/src/test/java/org/enso/interpreter/test/ListTest.java +++ b/engine/runtime-integration-tests/src/test/java/org/enso/interpreter/test/ListTest.java @@ -8,7 +8,7 @@ import java.net.URI; import java.net.URISyntaxException; import java.util.ArrayList; -import org.enso.test.utils.TestUtils; +import org.enso.test.utils.ContextUtils; import org.graalvm.polyglot.Context; import org.graalvm.polyglot.Source; import org.graalvm.polyglot.Value; @@ -29,7 +29,7 @@ public class ListTest { @Before public void prepareCtx() throws Exception { - this.ctx = TestUtils.createDefaultContext(); + this.ctx = ContextUtils.createDefaultContext(); final String code = """ diff --git a/engine/runtime-integration-tests/src/test/java/org/enso/interpreter/test/MetaIsATest.java b/engine/runtime-integration-tests/src/test/java/org/enso/interpreter/test/MetaIsATest.java index 42c5677e2686..dd2814c14208 100644 --- a/engine/runtime-integration-tests/src/test/java/org/enso/interpreter/test/MetaIsATest.java +++ b/engine/runtime-integration-tests/src/test/java/org/enso/interpreter/test/MetaIsATest.java @@ -10,7 +10,7 @@ import java.util.List; import java.util.Map; import org.enso.interpreter.test.ValuesGenerator.Language; -import org.enso.test.utils.TestUtils; +import org.enso.test.utils.ContextUtils; import org.graalvm.polyglot.Context; import org.graalvm.polyglot.Source; import org.graalvm.polyglot.Value; @@ -26,7 +26,7 @@ public class MetaIsATest { @BeforeClass public static void prepareCtx() throws Exception { - ctx = TestUtils.createDefaultContext(); + ctx = ContextUtils.createDefaultContext(); final URI uri = new URI("memory://choose.enso"); final Source src = Source.newBuilder( diff --git a/engine/runtime-integration-tests/src/test/java/org/enso/interpreter/test/MetaObjectTest.java b/engine/runtime-integration-tests/src/test/java/org/enso/interpreter/test/MetaObjectTest.java index 502c483f75a6..95243782081b 100644 --- a/engine/runtime-integration-tests/src/test/java/org/enso/interpreter/test/MetaObjectTest.java +++ b/engine/runtime-integration-tests/src/test/java/org/enso/interpreter/test/MetaObjectTest.java @@ -18,7 +18,7 @@ import org.enso.common.MethodNames; import org.enso.interpreter.runtime.type.ConstantsGen; import org.enso.interpreter.test.ValuesGenerator.Language; -import org.enso.test.utils.TestUtils; +import org.enso.test.utils.ContextUtils; import org.graalvm.polyglot.Context; import org.graalvm.polyglot.Source; import org.graalvm.polyglot.Value; @@ -32,7 +32,7 @@ public class MetaObjectTest { @BeforeClass public static void prepareCtx() { - ctx = TestUtils.createDefaultContext(); + ctx = ContextUtils.createDefaultContext(); } @AfterClass @@ -234,7 +234,7 @@ public void nothingWithWarningIsNotMeta() { main = Warning.attach "foo" Nothing """; - var nothingWithWarn = TestUtils.evalModule(ctx, src); + var nothingWithWarn = ContextUtils.evalModule(ctx, src); assertThat(nothingWithWarn.isMetaObject(), is(false)); } @@ -244,7 +244,7 @@ public void nothingShouldBeNull() { import Standard.Base.Nothing.Nothing main = Nothing """; - var nothing = TestUtils.evalModule(ctx, src); + var nothing = ContextUtils.evalModule(ctx, src); assertThat(nothing.isNull(), is(true)); } diff --git a/engine/runtime-integration-tests/src/test/java/org/enso/interpreter/test/NonStrictModeTests.java b/engine/runtime-integration-tests/src/test/java/org/enso/interpreter/test/NonStrictModeTests.java index ba8f9831f5f4..9c211df5321d 100644 --- a/engine/runtime-integration-tests/src/test/java/org/enso/interpreter/test/NonStrictModeTests.java +++ b/engine/runtime-integration-tests/src/test/java/org/enso/interpreter/test/NonStrictModeTests.java @@ -5,7 +5,7 @@ import java.util.Map; import org.enso.polyglot.RuntimeOptions; -import org.enso.test.utils.TestUtils; +import org.enso.test.utils.ContextUtils; import org.graalvm.polyglot.Context; import org.graalvm.polyglot.Language; import org.graalvm.polyglot.Value; @@ -26,7 +26,7 @@ public static void initCtx() { protected static Context createNonStrictContext() { var context = - TestUtils.defaultContextBuilder() + ContextUtils.defaultContextBuilder() .logHandler(logHandler) .option(RuntimeOptions.STRICT_ERRORS, "false") .build(); @@ -59,7 +59,7 @@ public void testAmbiguousConversion() { main = 42 """; - Value res = TestUtils.evalModule(nonStrictCtx, src); + Value res = ContextUtils.evalModule(nonStrictCtx, src); assertEquals(42, res.asInt()); // Even if the conversion is unused and non-strict mode, we still get a diagnostic report: @@ -89,7 +89,7 @@ public void testAmbiguousConversionUsage() { main = (Foo.from (Bar.Mk_Bar 42)) . data """; - Value res = TestUtils.evalModule(nonStrictCtx, src); + Value res = ContextUtils.evalModule(nonStrictCtx, src); assertEquals(142, res.asInt()); logHandler.assertMessage( @@ -107,7 +107,7 @@ public void testBadImport() { main = 2+2 """; - Value res = TestUtils.evalModule(nonStrictCtx, src); + Value res = ContextUtils.evalModule(nonStrictCtx, src); assertEquals(4, res.asInt()); String line1 = diff --git a/engine/runtime-integration-tests/src/test/java/org/enso/interpreter/test/PolyglotErrorTest.java b/engine/runtime-integration-tests/src/test/java/org/enso/interpreter/test/PolyglotErrorTest.java index ef4bcd99cc09..b941f334ddbd 100644 --- a/engine/runtime-integration-tests/src/test/java/org/enso/interpreter/test/PolyglotErrorTest.java +++ b/engine/runtime-integration-tests/src/test/java/org/enso/interpreter/test/PolyglotErrorTest.java @@ -3,7 +3,7 @@ import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertTrue; -import org.enso.test.utils.TestUtils; +import org.enso.test.utils.ContextUtils; import org.graalvm.polyglot.Context; import org.graalvm.polyglot.Source; import org.graalvm.polyglot.Value; @@ -21,7 +21,7 @@ public static String bar(Object o) { @Before public void prepareCtx() throws Exception { - this.ctx = TestUtils.createDefaultContext(); + this.ctx = ContextUtils.createDefaultContext(); var code = """ diff --git a/engine/runtime-integration-tests/src/test/java/org/enso/interpreter/test/PolyglotFindExceptionMessageTest.java b/engine/runtime-integration-tests/src/test/java/org/enso/interpreter/test/PolyglotFindExceptionMessageTest.java index 98a0d6d5f3b3..22445fdf9f60 100644 --- a/engine/runtime-integration-tests/src/test/java/org/enso/interpreter/test/PolyglotFindExceptionMessageTest.java +++ b/engine/runtime-integration-tests/src/test/java/org/enso/interpreter/test/PolyglotFindExceptionMessageTest.java @@ -4,7 +4,7 @@ import static org.junit.Assert.fail; import org.enso.common.HostEnsoUtils; -import org.enso.test.utils.TestUtils; +import org.enso.test.utils.ContextUtils; import org.graalvm.polyglot.Context; import org.graalvm.polyglot.PolyglotException; import org.graalvm.polyglot.Value; @@ -17,7 +17,7 @@ public class PolyglotFindExceptionMessageTest { @BeforeClass public static void initCtx() { - ctx = TestUtils.createDefaultContext(); + ctx = ContextUtils.createDefaultContext(); } @AfterClass @@ -36,7 +36,7 @@ public void testJavaScriptException() { """; try { - Value res = TestUtils.evalModule(ctx, src); + Value res = ContextUtils.evalModule(ctx, src); fail("No result expected: " + res); } catch (PolyglotException ex) { assertExceptionMessage("Error: Wrong!", ex); diff --git a/engine/runtime-integration-tests/src/test/java/org/enso/interpreter/test/PrintTest.java b/engine/runtime-integration-tests/src/test/java/org/enso/interpreter/test/PrintTest.java index 79de322ef917..8cbe10de459e 100644 --- a/engine/runtime-integration-tests/src/test/java/org/enso/interpreter/test/PrintTest.java +++ b/engine/runtime-integration-tests/src/test/java/org/enso/interpreter/test/PrintTest.java @@ -7,7 +7,7 @@ import java.net.URISyntaxException; import java.nio.charset.StandardCharsets; import org.enso.common.MethodNames; -import org.enso.test.utils.TestUtils; +import org.enso.test.utils.ContextUtils; import org.graalvm.polyglot.Context; import org.graalvm.polyglot.Source; import org.graalvm.polyglot.Value; @@ -21,7 +21,7 @@ public class PrintTest { @Before public void prepareCtx() { - ctx = TestUtils.createDefaultContext(out); + ctx = ContextUtils.createDefaultContext(out); out.reset(); } diff --git a/engine/runtime-integration-tests/src/test/java/org/enso/interpreter/test/SharedEngineTest.java b/engine/runtime-integration-tests/src/test/java/org/enso/interpreter/test/SharedEngineTest.java index 3ba9de036d17..14c07c3c997a 100644 --- a/engine/runtime-integration-tests/src/test/java/org/enso/interpreter/test/SharedEngineTest.java +++ b/engine/runtime-integration-tests/src/test/java/org/enso/interpreter/test/SharedEngineTest.java @@ -5,7 +5,7 @@ import java.nio.file.Paths; import java.util.logging.Level; import org.enso.polyglot.RuntimeOptions; -import org.enso.test.utils.TestUtils; +import org.enso.test.utils.ContextUtils; import org.graalvm.polyglot.Context; import org.graalvm.polyglot.Engine; import org.graalvm.polyglot.Source; @@ -35,7 +35,7 @@ public static void initializeSharedEngine() { @Before public void initializeContext() { - this.ctx = TestUtils.defaultContextBuilder().engine(sharedEngine).build(); + this.ctx = ContextUtils.defaultContextBuilder().engine(sharedEngine).build(); } @AfterClass diff --git a/engine/runtime-integration-tests/src/test/java/org/enso/interpreter/test/SignaturePolyglotTest.java b/engine/runtime-integration-tests/src/test/java/org/enso/interpreter/test/SignaturePolyglotTest.java index b3e9dff6a289..ff015ee116fa 100644 --- a/engine/runtime-integration-tests/src/test/java/org/enso/interpreter/test/SignaturePolyglotTest.java +++ b/engine/runtime-integration-tests/src/test/java/org/enso/interpreter/test/SignaturePolyglotTest.java @@ -8,7 +8,7 @@ import java.net.URI; import java.time.format.DateTimeFormatter; import org.enso.common.MethodNames; -import org.enso.test.utils.TestUtils; +import org.enso.test.utils.ContextUtils; import org.graalvm.polyglot.Context; import org.graalvm.polyglot.PolyglotException; import org.graalvm.polyglot.Source; @@ -22,7 +22,7 @@ public class SignaturePolyglotTest { @BeforeClass public static void prepareCtx() { ctx = - TestUtils.defaultContextBuilder() + ContextUtils.defaultContextBuilder() .out(OutputStream.nullOutputStream()) .err(OutputStream.nullOutputStream()) .build(); diff --git a/engine/runtime-integration-tests/src/test/java/org/enso/interpreter/test/SignatureTest.java b/engine/runtime-integration-tests/src/test/java/org/enso/interpreter/test/SignatureTest.java index abe05add81e3..d0ca155a6a2c 100644 --- a/engine/runtime-integration-tests/src/test/java/org/enso/interpreter/test/SignatureTest.java +++ b/engine/runtime-integration-tests/src/test/java/org/enso/interpreter/test/SignatureTest.java @@ -11,7 +11,7 @@ import java.net.URISyntaxException; import java.util.ArrayList; import org.enso.common.MethodNames; -import org.enso.test.utils.TestUtils; +import org.enso.test.utils.ContextUtils; import org.graalvm.polyglot.Context; import org.graalvm.polyglot.PolyglotException; import org.graalvm.polyglot.Source; @@ -26,7 +26,7 @@ public class SignatureTest { @BeforeClass public static void prepareCtx() { ctx = - TestUtils.defaultContextBuilder() + ContextUtils.defaultContextBuilder() .out(OutputStream.nullOutputStream()) .err(OutputStream.nullOutputStream()) .build(); diff --git a/engine/runtime-integration-tests/src/test/java/org/enso/interpreter/test/TypeMembersTest.java b/engine/runtime-integration-tests/src/test/java/org/enso/interpreter/test/TypeMembersTest.java index a9e12bf90a2c..bca7d28d421a 100644 --- a/engine/runtime-integration-tests/src/test/java/org/enso/interpreter/test/TypeMembersTest.java +++ b/engine/runtime-integration-tests/src/test/java/org/enso/interpreter/test/TypeMembersTest.java @@ -8,7 +8,7 @@ import java.net.URI; import java.util.Set; -import org.enso.test.utils.TestUtils; +import org.enso.test.utils.ContextUtils; import org.graalvm.polyglot.Context; import org.graalvm.polyglot.PolyglotException; import org.graalvm.polyglot.Source; @@ -22,7 +22,7 @@ public class TypeMembersTest { @Before public void prepareCtx() { - ctx = TestUtils.createDefaultContext(); + ctx = ContextUtils.createDefaultContext(); } @After diff --git a/engine/runtime-integration-tests/src/test/java/org/enso/interpreter/test/VectorSortTest.java b/engine/runtime-integration-tests/src/test/java/org/enso/interpreter/test/VectorSortTest.java index 560317f164d8..94021804c92a 100644 --- a/engine/runtime-integration-tests/src/test/java/org/enso/interpreter/test/VectorSortTest.java +++ b/engine/runtime-integration-tests/src/test/java/org/enso/interpreter/test/VectorSortTest.java @@ -6,7 +6,7 @@ import java.util.ArrayList; import java.util.List; import org.enso.interpreter.test.ValuesGenerator.Language; -import org.enso.test.utils.TestUtils; +import org.enso.test.utils.ContextUtils; import org.graalvm.polyglot.Context; import org.graalvm.polyglot.Value; import org.junit.AfterClass; @@ -28,7 +28,7 @@ public class VectorSortTest { @BeforeClass public static void initCtxAndNodes() { - context = TestUtils.createDefaultContext(); + context = ContextUtils.createDefaultContext(); var code = """ from Standard.Base import all @@ -36,8 +36,8 @@ public static void initCtxAndNodes() { sort val1 val2 = [val1, val2].sort equals val1 val2 = val1 == val2 """; - sortFunc = TestUtils.getMethodFromModule(context, code, "sort"); - equalsFunc = TestUtils.getMethodFromModule(context, code, "equals"); + sortFunc = ContextUtils.getMethodFromModule(context, code, "sort"); + equalsFunc = ContextUtils.getMethodFromModule(context, code, "equals"); values = new ArrayList<>(); var valuesGenerator = ValuesGenerator.create(context, Language.ENSO, Language.JAVA); diff --git a/engine/runtime-integration-tests/src/test/java/org/enso/interpreter/test/VectorTest.java b/engine/runtime-integration-tests/src/test/java/org/enso/interpreter/test/VectorTest.java index 05ab7f905af3..6b28ba7ab31a 100644 --- a/engine/runtime-integration-tests/src/test/java/org/enso/interpreter/test/VectorTest.java +++ b/engine/runtime-integration-tests/src/test/java/org/enso/interpreter/test/VectorTest.java @@ -7,7 +7,7 @@ import java.util.BitSet; import java.util.List; import java.util.function.Consumer; -import org.enso.test.utils.TestUtils; +import org.enso.test.utils.ContextUtils; import org.graalvm.polyglot.Context; import org.graalvm.polyglot.Source; import org.graalvm.polyglot.Value; @@ -21,7 +21,7 @@ public class VectorTest { @BeforeClass public static void prepareCtx() { - ctx = TestUtils.createDefaultContext(); + ctx = ContextUtils.createDefaultContext(); } @AfterClass diff --git a/engine/runtime-integration-tests/src/test/java/org/enso/interpreter/test/WarningsTest.java b/engine/runtime-integration-tests/src/test/java/org/enso/interpreter/test/WarningsTest.java index 7900380da415..47156b88e99c 100644 --- a/engine/runtime-integration-tests/src/test/java/org/enso/interpreter/test/WarningsTest.java +++ b/engine/runtime-integration-tests/src/test/java/org/enso/interpreter/test/WarningsTest.java @@ -12,7 +12,7 @@ import org.enso.interpreter.runtime.error.Warning; import org.enso.interpreter.runtime.error.WarningsLibrary; import org.enso.interpreter.runtime.error.WithWarnings; -import org.enso.test.utils.TestUtils; +import org.enso.test.utils.ContextUtils; import org.graalvm.polyglot.Context; import org.graalvm.polyglot.PolyglotException; import org.graalvm.polyglot.Value; @@ -31,7 +31,7 @@ public class WarningsTest { @BeforeClass public static void initEnsoContext() { - ctx = TestUtils.createDefaultContext(); + ctx = ContextUtils.createDefaultContext(); generator = ValuesGenerator.create(ctx, ValuesGenerator.Language.ENSO); ensoContext = (EnsoContext) diff --git a/engine/runtime-integration-tests/src/test/java/org/enso/interpreter/test/asserts/AssertionsTest.java b/engine/runtime-integration-tests/src/test/java/org/enso/interpreter/test/asserts/AssertionsTest.java index 2a77e5af2c49..3ac6245d9eba 100644 --- a/engine/runtime-integration-tests/src/test/java/org/enso/interpreter/test/asserts/AssertionsTest.java +++ b/engine/runtime-integration-tests/src/test/java/org/enso/interpreter/test/asserts/AssertionsTest.java @@ -14,7 +14,7 @@ import org.enso.common.LanguageInfo; import org.enso.common.MethodNames; import org.enso.interpreter.runtime.EnsoContext; -import org.enso.test.utils.TestUtils; +import org.enso.test.utils.ContextUtils; import org.graalvm.polyglot.Context; import org.graalvm.polyglot.PolyglotException; import org.graalvm.polyglot.Value; @@ -32,7 +32,7 @@ public class AssertionsTest { @BeforeClass public static void setupCtx() { ctx = - TestUtils.defaultContextBuilder(LanguageInfo.ID) + ContextUtils.defaultContextBuilder(LanguageInfo.ID) .environment("ENSO_ENABLE_ASSERTIONS", "true") .out(out) .err(out) @@ -72,7 +72,7 @@ public void assertionsAreEnabled() { @Test public void simpleAssertionFailureWithMessage() { try { - TestUtils.evalModule( + ContextUtils.evalModule( ctx, """ from Standard.Base import False, Runtime @@ -87,7 +87,7 @@ public void simpleAssertionFailureWithMessage() { @Test public void assertionFailureDisplaysMessage() { try { - TestUtils.evalModule( + ContextUtils.evalModule( ctx, """ from Standard.Base import False, Runtime @@ -104,7 +104,7 @@ public void assertionFailureDisplaysMessage() { @Test public void assertionFailureDisplaysStackTrace() { try { - TestUtils.evalModule( + ContextUtils.evalModule( ctx, """ from Standard.Base import False, Runtime @@ -125,7 +125,7 @@ public void assertionFailureDisplaysStackTrace() { @Test public void assertionSuccessReturnsNothing() { Value res = - TestUtils.evalModule( + ContextUtils.evalModule( ctx, """ from Standard.Base import Runtime, True @@ -137,7 +137,7 @@ public void assertionSuccessReturnsNothing() { @Test public void assertChecksTypeOfReturnValue() { try { - TestUtils.evalModule( + ContextUtils.evalModule( ctx, """ from Standard.Base import Runtime @@ -152,7 +152,7 @@ public void assertChecksTypeOfReturnValue() { @Test public void actionInAssertIsComputedWhenAssertionsAreEnabled() { Value res = - TestUtils.evalModule( + ContextUtils.evalModule( ctx, """ from Standard.Base import Runtime diff --git a/engine/runtime-integration-tests/src/test/java/org/enso/interpreter/test/asserts/DisabledAssertionsTest.java b/engine/runtime-integration-tests/src/test/java/org/enso/interpreter/test/asserts/DisabledAssertionsTest.java index d61d40ac8e49..b795b179bea4 100644 --- a/engine/runtime-integration-tests/src/test/java/org/enso/interpreter/test/asserts/DisabledAssertionsTest.java +++ b/engine/runtime-integration-tests/src/test/java/org/enso/interpreter/test/asserts/DisabledAssertionsTest.java @@ -8,7 +8,7 @@ import org.enso.common.LanguageInfo; import org.enso.common.MethodNames.TopScope; import org.enso.interpreter.runtime.EnsoContext; -import org.enso.test.utils.TestUtils; +import org.enso.test.utils.ContextUtils; import org.graalvm.polyglot.Context; import org.graalvm.polyglot.Value; import org.junit.AfterClass; @@ -20,7 +20,8 @@ public class DisabledAssertionsTest { @BeforeClass public static void setupCtx() { - ctx = TestUtils.defaultContextBuilder().environment("ENSO_ENABLE_ASSERTIONS", "false").build(); + ctx = + ContextUtils.defaultContextBuilder().environment("ENSO_ENABLE_ASSERTIONS", "false").build(); } @AfterClass @@ -38,7 +39,7 @@ public void assertionsCanBeDisabledWithEnvVar() { @Test public void actionInAssertIsNotComputedWhenAssertionsAreDisabled() { Value res = - TestUtils.evalModule( + ContextUtils.evalModule( ctx, """ from Standard.Base import Runtime diff --git a/engine/runtime-integration-tests/src/test/java/org/enso/interpreter/test/asserts/SuccessfulAssertionExpressionTest.java b/engine/runtime-integration-tests/src/test/java/org/enso/interpreter/test/asserts/SuccessfulAssertionExpressionTest.java index e3c9916a68c6..f3114222f072 100644 --- a/engine/runtime-integration-tests/src/test/java/org/enso/interpreter/test/asserts/SuccessfulAssertionExpressionTest.java +++ b/engine/runtime-integration-tests/src/test/java/org/enso/interpreter/test/asserts/SuccessfulAssertionExpressionTest.java @@ -5,7 +5,7 @@ import java.io.ByteArrayOutputStream; import java.util.List; import org.enso.common.LanguageInfo; -import org.enso.test.utils.TestUtils; +import org.enso.test.utils.ContextUtils; import org.graalvm.polyglot.Context; import org.junit.After; import org.junit.AfterClass; @@ -26,7 +26,7 @@ public class SuccessfulAssertionExpressionTest { @BeforeClass public static void setupCtx() { ctx = - TestUtils.defaultContextBuilder(LanguageInfo.ID) + ContextUtils.defaultContextBuilder(LanguageInfo.ID) .environment("ENSO_ENABLE_ASSERTIONS", "true") .out(out) .err(out) @@ -69,7 +69,7 @@ public void assertTakesAnyExpression() { sb.append(imports).append("\n"); sb.append("main = Runtime.assert (").append(succExpr).append(")\n"); var code = sb.toString(); - var res = TestUtils.evalModule(ctx, code); + var res = ContextUtils.evalModule(ctx, code); assertTrue(res.isNull()); } } diff --git a/engine/runtime-integration-tests/src/test/java/org/enso/interpreter/test/instrument/AvoidIdInstrumentationTagTest.java b/engine/runtime-integration-tests/src/test/java/org/enso/interpreter/test/instrument/AvoidIdInstrumentationTagTest.java index 107b34358ee6..2d5253c4f1f5 100644 --- a/engine/runtime-integration-tests/src/test/java/org/enso/interpreter/test/instrument/AvoidIdInstrumentationTagTest.java +++ b/engine/runtime-integration-tests/src/test/java/org/enso/interpreter/test/instrument/AvoidIdInstrumentationTagTest.java @@ -14,7 +14,7 @@ import org.enso.interpreter.runtime.tag.AvoidIdInstrumentationTag; import org.enso.interpreter.runtime.tag.IdentifiedTag; import org.enso.interpreter.test.instruments.NodeCountingTestInstrument; -import org.enso.test.utils.TestUtils; +import org.enso.test.utils.ContextUtils; import org.graalvm.polyglot.Context; import org.graalvm.polyglot.Source; import org.junit.After; @@ -29,7 +29,7 @@ public class AvoidIdInstrumentationTagTest { @Before public void initContext() { - context = TestUtils.defaultContextBuilder().build(); + context = ContextUtils.defaultContextBuilder().build(); var engine = context.getEngine(); var langs = engine.getLanguages(); Assert.assertNotNull("Enso found: " + langs, langs.get("enso")); diff --git a/engine/runtime-integration-tests/src/test/java/org/enso/interpreter/test/instrument/FunctionPointerTest.java b/engine/runtime-integration-tests/src/test/java/org/enso/interpreter/test/instrument/FunctionPointerTest.java index a3bc9a55994e..7c8654a830d7 100644 --- a/engine/runtime-integration-tests/src/test/java/org/enso/interpreter/test/instrument/FunctionPointerTest.java +++ b/engine/runtime-integration-tests/src/test/java/org/enso/interpreter/test/instrument/FunctionPointerTest.java @@ -11,7 +11,7 @@ import org.enso.interpreter.runtime.data.atom.AtomConstructor; import org.enso.interpreter.service.ExecutionService.FunctionPointer; import org.enso.polyglot.RuntimeOptions; -import org.enso.test.utils.TestUtils; +import org.enso.test.utils.ContextUtils; import org.graalvm.polyglot.Context; import org.graalvm.polyglot.Language; import org.graalvm.polyglot.Source; @@ -62,7 +62,7 @@ public void moduleFunctionPointer() throws Exception { var res = module.invokeMember("eval_expression", "run"); assertTrue("fn: " + res, res.canExecute()); - var rawRes = TestUtils.unwrapValue(context, res); + var rawRes = ContextUtils.unwrapValue(context, res); assertTrue("function: " + rawRes, rawRes instanceof Function); var c = FunctionPointer.fromFunction((Function) rawRes); assertNotNull(c); @@ -85,7 +85,7 @@ public void typeStaticMethodPointer() throws Exception { var res = module.invokeMember("eval_expression", "X.run"); assertTrue("fn: " + res, res.canExecute()); - var rawRes = TestUtils.unwrapValue(context, res); + var rawRes = ContextUtils.unwrapValue(context, res); assertTrue("function: " + rawRes, rawRes instanceof Function); var c = FunctionPointer.fromFunction((Function) rawRes); assertNotNull(c); @@ -95,7 +95,7 @@ public void typeStaticMethodPointer() throws Exception { var apply = res.execute(1); assertTrue("fn: " + apply, apply.canExecute()); - var rawApply = TestUtils.unwrapValue(context, res); + var rawApply = ContextUtils.unwrapValue(context, res); assertTrue("function: " + rawApply, rawApply instanceof Function); var a = FunctionPointer.fromFunction((Function) rawApply); assertNotNull(a); @@ -118,7 +118,7 @@ public void typeInstanceMethodPointer() throws Exception { var res = module.invokeMember("eval_expression", "X.run"); assertTrue("fn: " + res, res.canExecute()); - var rawRes = TestUtils.unwrapValue(context, res); + var rawRes = ContextUtils.unwrapValue(context, res); assertTrue("function: " + rawRes, rawRes instanceof Function); var c = FunctionPointer.fromFunction((Function) rawRes); assertNotNull(c); @@ -128,7 +128,7 @@ public void typeInstanceMethodPointer() throws Exception { var apply = res.execute(1); assertTrue("fn: " + apply, apply.canExecute()); - var rawApply = TestUtils.unwrapValue(context, res); + var rawApply = ContextUtils.unwrapValue(context, res); assertTrue("function: " + rawApply, rawApply instanceof Function); var a = FunctionPointer.fromFunction((Function) rawApply); assertNotNull(a); @@ -151,7 +151,7 @@ public void typeConstructorPointer() throws Exception { var res = module.invokeMember("eval_expression", "X.Run"); assertTrue("fn: " + res, res.canInstantiate()); - var rawRes = TestUtils.unwrapValue(context, res); + var rawRes = ContextUtils.unwrapValue(context, res); assertTrue("function: " + rawRes.getClass(), rawRes instanceof AtomConstructor); var rawFn = ((AtomConstructor) rawRes).getConstructorFunction(); var c = FunctionPointer.fromFunction(rawFn); diff --git a/engine/runtime-integration-tests/src/test/java/org/enso/interpreter/test/privateaccess/PrivateAccessTest.java b/engine/runtime-integration-tests/src/test/java/org/enso/interpreter/test/privateaccess/PrivateAccessTest.java index 3708583f3d85..4aab967a48d3 100644 --- a/engine/runtime-integration-tests/src/test/java/org/enso/interpreter/test/privateaccess/PrivateAccessTest.java +++ b/engine/runtime-integration-tests/src/test/java/org/enso/interpreter/test/privateaccess/PrivateAccessTest.java @@ -13,7 +13,8 @@ import org.enso.interpreter.util.ScalaConversions; import org.enso.polyglot.PolyglotContext; import org.enso.polyglot.RuntimeOptions; -import org.enso.test.utils.TestUtils; +import org.enso.test.utils.ContextUtils; +import org.enso.test.utils.ProjectUtils; import org.graalvm.polyglot.PolyglotException; import org.junit.Rule; import org.junit.Test; @@ -32,8 +33,8 @@ public void privateConstructorCanBeCalledInUnknownProject() { obj = My_Type.Cons 42 obj.data """; - try (var ctx = TestUtils.createDefaultContext()) { - var res = TestUtils.evalModule(ctx, src); + try (var ctx = ContextUtils.createDefaultContext()) { + var res = ContextUtils.evalModule(ctx, src); assertThat(res.isNumber(), is(true)); assertThat(res.asInt(), is(42)); } @@ -48,8 +49,8 @@ public void privateFieldIsNotExposedToPolyglot() throws IOException { main = My_Type.Cons 42 """; var projDir = tempFolder.newFolder().toPath(); - TestUtils.createProject("My_Project", mainSrc, projDir); - TestUtils.testProjectRun( + ProjectUtils.createProject("My_Project", mainSrc, projDir); + ProjectUtils.testProjectRun( projDir, res -> { assertThat(res.hasMember("data"), is(false)); @@ -65,10 +66,10 @@ public void privateConstructorIsNotExposedToPolyglot() throws IOException { private Cons data """; var projDir = tempFolder.newFolder().toPath(); - TestUtils.createProject("My_Project", mainSrc, projDir); + ProjectUtils.createProject("My_Project", mainSrc, projDir); var mainSrcPath = projDir.resolve("src").resolve("Main.enso"); try (var ctx = - TestUtils.defaultContextBuilder() + ContextUtils.defaultContextBuilder() .option(RuntimeOptions.PROJECT_ROOT, projDir.toAbsolutePath().toString()) .build()) { var polyCtx = new PolyglotContext(ctx); @@ -89,10 +90,10 @@ public void typeWithPrivateConstructorExposesPublicMethodsToPolyglot() throws IO My_Type.Cons 42 """; var projDir = tempFolder.newFolder().toPath(); - TestUtils.createProject("My_Project", mainSrc, projDir); + ProjectUtils.createProject("My_Project", mainSrc, projDir); var mainSrcPath = projDir.resolve("src").resolve("Main.enso"); try (var ctx = - TestUtils.defaultContextBuilder() + ContextUtils.defaultContextBuilder() .option(RuntimeOptions.PROJECT_ROOT, projDir.toAbsolutePath().toString()) .build()) { var polyCtx = new PolyglotContext(ctx); @@ -124,8 +125,8 @@ public void canPatternMatchOnPrivateConstructorFromSameProject() throws IOExcept _ -> 0 """; var projDir = tempFolder.newFolder().toPath(); - TestUtils.createProject("My_Project", mainSrc, projDir); - TestUtils.testProjectRun( + ProjectUtils.createProject("My_Project", mainSrc, projDir); + ProjectUtils.testProjectRun( projDir, res -> { assertThat(res.isNumber(), is(true)); @@ -142,7 +143,7 @@ public void cannotPatternMatchOnPrivateConstructorFromDifferentProject() throws private Cons data create x = My_Type.Cons x """; - TestUtils.createProject("Lib", libSrc, tempFolder.newFolder("Lib").toPath()); + ProjectUtils.createProject("Lib", libSrc, tempFolder.newFolder("Lib").toPath()); var projSrc = """ from local.Lib import My_Type @@ -152,10 +153,10 @@ public void cannotPatternMatchOnPrivateConstructorFromDifferentProject() throws My_Type.Cons x -> x """; var projDir = tempFolder.newFolder().toPath(); - TestUtils.createProject("Proj", projSrc, projDir); + ProjectUtils.createProject("Proj", projSrc, projDir); var out = new ByteArrayOutputStream(); try (var ctx = - TestUtils.defaultContextBuilder() + ContextUtils.defaultContextBuilder() .option(RuntimeOptions.PROJECT_ROOT, projDir.toAbsolutePath().toString()) .option(RuntimeOptions.STRICT_ERRORS, "true") .option(RuntimeOptions.DISABLE_IR_CACHES, "true") diff --git a/engine/runtime-integration-tests/src/test/java/org/enso/interpreter/test/privateaccess/PrivateCheckDisabledTest.java b/engine/runtime-integration-tests/src/test/java/org/enso/interpreter/test/privateaccess/PrivateCheckDisabledTest.java index 867e9ffaf7de..c63ce8addca3 100644 --- a/engine/runtime-integration-tests/src/test/java/org/enso/interpreter/test/privateaccess/PrivateCheckDisabledTest.java +++ b/engine/runtime-integration-tests/src/test/java/org/enso/interpreter/test/privateaccess/PrivateCheckDisabledTest.java @@ -5,7 +5,8 @@ import java.io.IOException; import org.enso.polyglot.RuntimeOptions; -import org.enso.test.utils.TestUtils; +import org.enso.test.utils.ContextUtils; +import org.enso.test.utils.ProjectUtils; import org.junit.Rule; import org.junit.Test; import org.junit.rules.TemporaryFolder; @@ -20,7 +21,7 @@ public void privateCtorCanBeAccessedWhenPrivateCheckIsDisabled() throws IOExcept private Cons data """; var libDir = tempFolder.newFolder().toPath(); - TestUtils.createProject("Lib", libSrc, libDir); + ProjectUtils.createProject("Lib", libSrc, libDir); var mainSrc = """ from local.Lib import T @@ -29,10 +30,10 @@ public void privateCtorCanBeAccessedWhenPrivateCheckIsDisabled() throws IOExcept obj.data """; var mainDir = tempFolder.newFolder().toPath(); - TestUtils.createProject("Main", mainSrc, mainDir); + ProjectUtils.createProject("Main", mainSrc, mainDir); var ctxBuilder = - TestUtils.defaultContextBuilder().option(RuntimeOptions.DISABLE_PRIVATE_CHECK, "true"); - TestUtils.testProjectRun( + ContextUtils.defaultContextBuilder().option(RuntimeOptions.DISABLE_PRIVATE_CHECK, "true"); + ProjectUtils.testProjectRun( ctxBuilder, mainDir, res -> { diff --git a/lib/java/test-utils/src/main/java/org/enso/test/utils/TestUtils.java b/lib/java/test-utils/src/main/java/org/enso/test/utils/ContextUtils.java similarity index 51% rename from lib/java/test-utils/src/main/java/org/enso/test/utils/TestUtils.java rename to lib/java/test-utils/src/main/java/org/enso/test/utils/ContextUtils.java index 636f9482a1c0..63b2511ffc0a 100644 --- a/lib/java/test-utils/src/main/java/org/enso/test/utils/TestUtils.java +++ b/lib/java/test-utils/src/main/java/org/enso/test/utils/ContextUtils.java @@ -1,34 +1,20 @@ package org.enso.test.utils; -import com.oracle.truffle.api.frame.VirtualFrame; import com.oracle.truffle.api.interop.InteropLibrary; import com.oracle.truffle.api.interop.TruffleObject; import com.oracle.truffle.api.library.ExportLibrary; import com.oracle.truffle.api.library.ExportMessage; -import com.oracle.truffle.api.nodes.Node; -import com.oracle.truffle.api.nodes.RootNode; -import java.io.File; -import java.io.IOException; import java.io.OutputStream; -import java.nio.file.Files; -import java.nio.file.Path; import java.nio.file.Paths; import java.util.Map; -import java.util.Set; import java.util.concurrent.Callable; -import java.util.function.Consumer; -import java.util.function.Function; import java.util.logging.Level; import org.enso.common.LanguageInfo; import org.enso.common.MethodNames.Module; import org.enso.common.MethodNames.TopScope; -import org.enso.interpreter.EnsoLanguage; import org.enso.interpreter.runtime.EnsoContext; -import org.enso.pkg.QualifiedName; -import org.enso.polyglot.PolyglotContext; import org.enso.polyglot.RuntimeOptions; import org.graalvm.polyglot.Context; -import org.graalvm.polyglot.Context.Builder; import org.graalvm.polyglot.Language; import org.graalvm.polyglot.Source; import org.graalvm.polyglot.Value; @@ -36,10 +22,10 @@ import org.graalvm.polyglot.proxy.ProxyExecutable; /** - * A collection of classes and methods useful for testing, mostly Truffle-related stuff. + * A collection of classes and methods useful for testing {@link Context} related stuff. */ -public final class TestUtils { - private TestUtils() {} +public final class ContextUtils { + private ContextUtils() {} public static Context createDefaultContext() { var context = defaultContextBuilder().build(); @@ -175,134 +161,6 @@ public static Value getMethodFromModule(Context ctx, String moduleSrc, String me return module.invokeMember(Module.EVAL_EXPRESSION, methodName); } - /** - * Creates temporary project directory structure with a given main source content. No need to - * clean it up, as it is managed by JUnit TemporaryFolder rule. Note that we need to create a - * project, otherwise the private stuff won't work. - * - * @param projName Name of the project (as defined in package.yaml). - * @param mainSrc Main.enso source content - * @param projDir Root directory of the project. Will be populated with the project structure. - */ - public static void createProject(String projName, String mainSrc, Path projDir) - throws IOException { - var modules = Set.of(new SourceModule(QualifiedName.fromString("Main"), mainSrc)); - createProject(projName, modules, projDir); - } - - /** - * Creates a temporary project directory structure with all the given modules and their content. - * Creates also the package descriptor. The created project directory structure is eligible for - * running via {@code enso --run }. - * - * @param projName Name of the project - * @param modules Set of modules. Must contain `Main` module. - * @param projDir A directory in which the whole project structure will be created. - * Must exist and be a directory. - */ - public static void createProject( - String projName, Set modules, Path projDir) throws IOException { - if (!projDir.toFile().exists() || !projDir.toFile().isDirectory()) { - throw new IllegalArgumentException("Project directory " + projDir + " must already be created"); - } - var projYaml = - """ -name: %s -version: 0.0.1 -prefer-local-libraries: true - """.formatted(projName); - var yamlPath = projDir.resolve("package.yaml"); - Files.writeString(yamlPath, projYaml); - assert yamlPath.toFile().exists(); - var srcDir = Files.createDirectory(projDir.resolve("src")); - assert srcDir.toFile().exists(); - boolean mainModuleFound = false; - for (var module : modules) { - var relativePath = String.join(File.pathSeparator, module.name().pathAsJava()); - var modDirPath = srcDir.resolve(relativePath); - Files.createDirectories(modDirPath); - var modPath = modDirPath.resolve(module.name().item() + ".enso"); - Files.writeString(modPath, module.code()); - if (module.name().equals(QualifiedName.fromString("Main"))) { - mainModuleFound = true; - } - } - assert mainModuleFound; - } - - /** - * Tests running the project located in the given {@code projDir}. Is equal to running {@code enso - * --run }. - * - * @param ctxBuilder A context builder that might be initialized with some specific options. - * @param projDir Root directory of the project. - * @param resultConsumer Any action that is to be evaluated on the result of running the {@code - * main} method - */ - public static void testProjectRun( - Context.Builder ctxBuilder, Path projDir, Consumer resultConsumer) { - assert projDir.toFile().exists() && projDir.toFile().isDirectory(); - try (var ctx = - ctxBuilder - .option(RuntimeOptions.PROJECT_ROOT, projDir.toAbsolutePath().toString()) - .option(RuntimeOptions.STRICT_ERRORS, "true") - .option(RuntimeOptions.DISABLE_IR_CACHES, "true") - .build()) { - var polyCtx = new PolyglotContext(ctx); - var mainSrcPath = projDir.resolve("src").resolve("Main.enso"); - var mainMod = polyCtx.evalModule(mainSrcPath.toFile()); - var assocMainModType = mainMod.getAssociatedType(); - var mainMethod = mainMod.getMethod(assocMainModType, "main").get(); - var res = mainMethod.execute(); - resultConsumer.accept(res); - } - } - - /** - * Just a wrapper for {@link TestUtils#testProjectRun(Builder, Path, Consumer)}. - * - * @param projDir Root directory of the project. - * @param resultConsumer Any action that is to be evaluated on the result of running the {@code - * main} method - */ - public static void testProjectRun(Path projDir, Consumer resultConsumer) { - testProjectRun(defaultContextBuilder(), projDir, resultConsumer); - } - - /** - * An artificial RootNode. Used for tests of nodes that need to be adopted. Just create this root - * node inside a context, all the other nodes, and insert them via {@link - * #insertChildren(Node...)}. - */ - public static final class TestRootNode extends RootNode { - private final Function callback; - - public TestRootNode() { - this(null); - } - - public TestRootNode(Function callback) { - super(EnsoLanguage.get(null)); - this.callback = callback; - } - - public void insertChildren(Node... children) { - for (Node child : children) { - insert(child); - } - } - - /** In the tests, do not execute this root node, but execute directly the child nodes. */ - @Override - public Object execute(VirtualFrame frame) { - if (callback == null) { - throw new AssertionError("should not reach here"); - } else { - return callback.apply(frame); - } - } - } - @ExportLibrary(InteropLibrary.class) static final class Unwrapper implements TruffleObject { Object[] args; diff --git a/lib/java/test-utils/src/main/java/org/enso/test/utils/ProjectUtils.java b/lib/java/test-utils/src/main/java/org/enso/test/utils/ProjectUtils.java new file mode 100644 index 000000000000..2d3c84f22d05 --- /dev/null +++ b/lib/java/test-utils/src/main/java/org/enso/test/utils/ProjectUtils.java @@ -0,0 +1,116 @@ +package org.enso.test.utils; + +import java.io.File; +import java.io.IOException; +import java.nio.file.Files; +import java.nio.file.Path; +import java.util.Set; +import java.util.function.Consumer; +import org.enso.pkg.QualifiedName; +import org.enso.polyglot.PolyglotContext; +import org.enso.polyglot.RuntimeOptions; +import org.graalvm.polyglot.Context; +import org.graalvm.polyglot.Context.Builder; +import org.graalvm.polyglot.Value; + +/** + * Utility methods for creating and running Enso projects in tests. + */ +public class ProjectUtils { + private ProjectUtils() {} + + + /** + * Creates temporary project directory structure with a given main source content. No need to + * clean it up, as it is managed by JUnit TemporaryFolder rule. Note that we need to create a + * project, otherwise the private stuff won't work. + * + * @param projName Name of the project (as defined in package.yaml). + * @param mainSrc Main.enso source content + * @param projDir Root directory of the project. Will be populated with the project structure. + */ + public static void createProject(String projName, String mainSrc, Path projDir) + throws IOException { + var modules = Set.of(new SourceModule(QualifiedName.fromString("Main"), mainSrc)); + createProject(projName, modules, projDir); + } + + /** + * Creates a temporary project directory structure with all the given modules and their content. + * Creates also the package descriptor. The created project directory structure is eligible for + * running via {@code enso --run }. + * + * @param projName Name of the project + * @param modules Set of modules. Must contain `Main` module. + * @param projDir A directory in which the whole project structure will be created. + * Must exist and be a directory. + */ + public static void createProject( + String projName, Set modules, Path projDir) throws IOException { + if (!projDir.toFile().exists() || !projDir.toFile().isDirectory()) { + throw new IllegalArgumentException("Project directory " + projDir + " must already be created"); + } + var projYaml = + """ +name: %s +version: 0.0.1 +prefer-local-libraries: true + """.formatted(projName); + var yamlPath = projDir.resolve("package.yaml"); + Files.writeString(yamlPath, projYaml); + assert yamlPath.toFile().exists(); + var srcDir = Files.createDirectory(projDir.resolve("src")); + assert srcDir.toFile().exists(); + boolean mainModuleFound = false; + for (var module : modules) { + var relativePath = String.join(File.pathSeparator, module.name().pathAsJava()); + var modDirPath = srcDir.resolve(relativePath); + Files.createDirectories(modDirPath); + var modPath = modDirPath.resolve(module.name().item() + ".enso"); + Files.writeString(modPath, module.code()); + if (module.name().equals(QualifiedName.fromString("Main"))) { + mainModuleFound = true; + } + } + assert mainModuleFound; + } + + /** + * Tests running the project located in the given {@code projDir}. Is equal to running {@code enso + * --run }. + * + * @param ctxBuilder A context builder that might be initialized with some specific options. + * @param projDir Root directory of the project. + * @param resultConsumer Any action that is to be evaluated on the result of running the {@code + * main} method + */ + public static void testProjectRun( + Context.Builder ctxBuilder, Path projDir, Consumer resultConsumer) { + assert projDir.toFile().exists() && projDir.toFile().isDirectory(); + try (var ctx = + ctxBuilder + .option(RuntimeOptions.PROJECT_ROOT, projDir.toAbsolutePath().toString()) + .option(RuntimeOptions.STRICT_ERRORS, "true") + .option(RuntimeOptions.DISABLE_IR_CACHES, "true") + .build()) { + var polyCtx = new PolyglotContext(ctx); + var mainSrcPath = projDir.resolve("src").resolve("Main.enso"); + var mainMod = polyCtx.evalModule(mainSrcPath.toFile()); + var assocMainModType = mainMod.getAssociatedType(); + var mainMethod = mainMod.getMethod(assocMainModType, "main").get(); + var res = mainMethod.execute(); + resultConsumer.accept(res); + } + } + + /** + * Just a wrapper for {@link ContextUtils#testProjectRun(Builder, Path, Consumer)}. + * + * @param projDir Root directory of the project. + * @param resultConsumer Any action that is to be evaluated on the result of running the {@code + * main} method + */ + public static void testProjectRun(Path projDir, Consumer resultConsumer) { + testProjectRun(ContextUtils.defaultContextBuilder(), projDir, resultConsumer); + } +} diff --git a/lib/java/test-utils/src/main/java/org/enso/test/utils/TestRootNode.java b/lib/java/test-utils/src/main/java/org/enso/test/utils/TestRootNode.java new file mode 100644 index 000000000000..c97e1d7c641d --- /dev/null +++ b/lib/java/test-utils/src/main/java/org/enso/test/utils/TestRootNode.java @@ -0,0 +1,44 @@ +package org.enso.test.utils; + +import com.oracle.truffle.api.frame.VirtualFrame; +import com.oracle.truffle.api.nodes.Node; +import com.oracle.truffle.api.nodes.RootNode; +import java.util.function.Function; +import org.enso.interpreter.EnsoLanguage; + +/** + * An artificial RootNode. Used for tests of nodes that need to be adopted. Just create this root + * node inside a context, all the other nodes, and insert them via + * {@link #insertChildren(Node...)}. + */ +public final class TestRootNode extends RootNode { + + private final Function callback; + + public TestRootNode() { + this(null); + } + + public TestRootNode(Function callback) { + super(EnsoLanguage.get(null)); + this.callback = callback; + } + + public void insertChildren(Node... children) { + for (Node child : children) { + insert(child); + } + } + + /** + * In the tests, do not execute this root node, but execute directly the child nodes. + */ + @Override + public Object execute(VirtualFrame frame) { + if (callback == null) { + throw new AssertionError("should not reach here"); + } else { + return callback.apply(frame); + } + } +}