use of com.oracle.truffle.api.nodes.Node in project graal by oracle.
the class JavaInteropTest method notUnboxable.
@Test
public void notUnboxable() {
Node unboxNode = Message.UNBOX.createNode();
assertThrowsExceptionWithCause(() -> ForeignAccess.sendUnbox(unboxNode, JavaInterop.asTruffleObject(null)), UnsupportedMessageException.class);
assertThrowsExceptionWithCause(() -> ForeignAccess.sendUnbox(unboxNode, JavaInterop.asTruffleObject(new Object())), UnsupportedMessageException.class);
assertThrowsExceptionWithCause(() -> ForeignAccess.sendUnbox(unboxNode, JavaInterop.asTruffleObject(Object.class)), UnsupportedMessageException.class);
}
use of com.oracle.truffle.api.nodes.Node in project graal by oracle.
the class JavaInteropTest method message.
static Object message(final Message m, TruffleObject receiver, Object... arr) {
Node n = m.createNode();
CallTarget callTarget = Truffle.getRuntime().createCallTarget(new TemporaryRoot(n, receiver));
return callTarget.call(arr);
}
use of com.oracle.truffle.api.nodes.Node in project graal by oracle.
the class OverloadedTest method testOverloadingTruffleObjectArg.
@Test
public void testOverloadingTruffleObjectArg() throws InteropException {
Node n = Message.createInvoke(1).createNode();
ForeignAccess.sendInvoke(n, obj, "x", new UnboxableToInt(21));
assertEquals(42, data.x);
ForeignAccess.sendInvoke(n, obj, "x", JavaInterop.asTruffleObject(10));
assertEquals(20, data.x);
}
use of com.oracle.truffle.api.nodes.Node in project graal by oracle.
the class OverloadedTest method testWidening.
@Test
public void testWidening() throws InteropException {
Node n = Message.createInvoke(1).createNode();
Num num = new Num();
TruffleObject numobj = JavaInterop.asTruffleObject(num);
ForeignAccess.sendInvoke(n, numobj, "d", (byte) 42);
assertEquals("int", num.parameter);
ForeignAccess.sendInvoke(n, numobj, "d", (short) 42);
assertEquals("int", num.parameter);
ForeignAccess.sendInvoke(n, numobj, "d", 42);
assertEquals("int", num.parameter);
ForeignAccess.sendInvoke(n, numobj, "d", 42.1f);
assertEquals("double", num.parameter);
ForeignAccess.sendInvoke(n, numobj, "d", 42.1d);
assertEquals("double", num.parameter);
ForeignAccess.sendInvoke(n, numobj, "d", 0x8000_0000L);
assertEquals("double", num.parameter);
ForeignAccess.sendInvoke(n, numobj, "d", 42L);
assertEquals("int", num.parameter);
ForeignAccess.sendInvoke(n, numobj, "f", 42L);
assertEquals("int", num.parameter);
}
use of com.oracle.truffle.api.nodes.Node in project graal by oracle.
the class SLInstrumentTest method checkBlock.
private static void checkBlock(Scope ls) {
assertEquals("block", ls.getName());
// Test that ls.getNode() does not return the current root node, it ought to be a block node
Node node = ls.getNode();
assertNotNull(node);
assertFalse(node.getClass().getName(), node instanceof RootNode);
}
Aggregations