-
Notifications
You must be signed in to change notification settings - Fork 323
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Avoid exposing EnsoMultiValue getters (#11642)
Another step in the #11482 work. Avoid accessing internals of `EnsoMultiValue`. Use `TypeOfNode` methods (as provided by #11618) instead.
- Loading branch information
1 parent
e5a65a2
commit 1cc3848
Showing
5 changed files
with
95 additions
and
6 deletions.
There are no files selected for viewing
82 changes: 82 additions & 0 deletions
82
.../src/test/java/org/enso/interpreter/node/expression/builtin/meta/TypeOfNodeValueTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,82 @@ | ||
package org.enso.interpreter.node.expression.builtin.meta; | ||
|
||
import static org.junit.Assert.assertEquals; | ||
|
||
import com.oracle.truffle.api.RootCallTarget; | ||
import org.enso.interpreter.runtime.callable.UnresolvedConstructor; | ||
import org.enso.interpreter.runtime.callable.UnresolvedSymbol; | ||
import org.enso.interpreter.runtime.data.Type; | ||
import org.enso.interpreter.runtime.library.dispatch.TypeOfNode; | ||
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; | ||
|
||
public class TypeOfNodeValueTest { | ||
private static RootCallTarget testTypesCall; | ||
private static Context ctx; | ||
|
||
private static Context ctx() { | ||
if (ctx == null) { | ||
ctx = ContextUtils.defaultContextBuilder().build(); | ||
ContextUtils.executeInContext( | ||
ctx, | ||
() -> { | ||
var node = TypeOfNode.create(); | ||
var root = | ||
new TestRootNode( | ||
(frame) -> { | ||
var arg = frame.getArguments()[0]; | ||
var t = node.findTypeOrError(arg); | ||
var all = node.findAllTypesOrNull(arg); | ||
return new Object[] {t, all}; | ||
}); | ||
root.insertChildren(node); | ||
testTypesCall = root.getCallTarget(); | ||
return null; | ||
}); | ||
} | ||
return ctx; | ||
} | ||
|
||
@AfterClass | ||
public static void disposeCtx() throws Exception { | ||
if (ctx != null) { | ||
ctx.close(); | ||
ctx = null; | ||
} | ||
} | ||
|
||
@Test | ||
public void typeOfUnresolvedConstructor() { | ||
ContextUtils.executeInContext( | ||
ctx(), | ||
() -> { | ||
var cnstr = UnresolvedConstructor.build(null, "Unknown_Name"); | ||
var arr = (Object[]) testTypesCall.call(cnstr); | ||
var type = (Type) arr[0]; | ||
var allTypes = (Type[]) arr[1]; | ||
assertEquals("Function", type.getName()); | ||
assertEquals("One array", 1, allTypes.length); | ||
assertEquals("Also function type", type, allTypes[0]); | ||
return null; | ||
}); | ||
} | ||
|
||
@Test | ||
public void typeOfUnresolvedSymbol() { | ||
ContextUtils.executeInContext( | ||
ctx(), | ||
() -> { | ||
var cnstr = UnresolvedSymbol.build("Unknown_Name", null); | ||
var arr = (Object[]) testTypesCall.call(cnstr); | ||
var type = (Type) arr[0]; | ||
var allTypes = (Type[]) arr[1]; | ||
assertEquals("Function", type.getName()); | ||
assertEquals("One array", 1, allTypes.length); | ||
assertEquals("Also function type", type, allTypes[0]); | ||
return null; | ||
}); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters