Search in sources :

Example 66 with TruffleObject

use of com.oracle.truffle.api.interop.TruffleObject in project graal by oracle.

the class AsCollectionsTest method testInvokeArrayOfMap.

@Test
public void testInvokeArrayOfMap() throws InteropException {
    TruffleObject validator = com.oracle.truffle.api.interop.java.JavaInterop.asTruffleObject(new Validator());
    MapBasedTO mapTO = new MapBasedTO(Collections.singletonMap("foo", "bar"));
    TruffleObject listOfMapTO = new ListBasedTO(Arrays.asList(mapTO));
    assertEquals(Boolean.TRUE, ForeignAccess.sendInvoke(Message.createInvoke(1).createNode(), validator, "validateArrayOfMap", listOfMapTO, listOfMapTO));
}
Also used : TruffleObject(com.oracle.truffle.api.interop.TruffleObject) Test(org.junit.Test)

Example 67 with TruffleObject

use of com.oracle.truffle.api.interop.TruffleObject in project graal by oracle.

the class CallbackConvertTest method callWithNegativeNumberTest.

@Test(expected = IllegalArgumentException.class)
public void callWithNegativeNumberTest() {
    TruffleObject truffle = JavaInterop.asTruffleObject(this);
    CallWithInt callback = JavaInterop.asJavaObject(CallWithInt.class, truffle);
    callback.callback(-32);
    assertEquals("The call will not get here", 0, ch);
}
Also used : TruffleObject(com.oracle.truffle.api.interop.TruffleObject) Test(org.junit.Test)

Example 68 with TruffleObject

use of com.oracle.truffle.api.interop.TruffleObject in project graal by oracle.

the class CallbackConvertTest method callWithHugeIntTest.

@Test(expected = IllegalArgumentException.class)
public void callWithHugeIntTest() {
    TruffleObject truffle = JavaInterop.asTruffleObject(this);
    CallWithInt callback = JavaInterop.asJavaObject(CallWithInt.class, truffle);
    callback.callback(Integer.MAX_VALUE / 2);
    fail("Should thrown an exception as the int value is too big for char: " + ch);
}
Also used : TruffleObject(com.oracle.truffle.api.interop.TruffleObject) Test(org.junit.Test)

Example 69 with TruffleObject

use of com.oracle.truffle.api.interop.TruffleObject in project graal by oracle.

the class CallbackConvertTest method callWithIntTest.

@Test
public void callWithIntTest() {
    TruffleObject truffle = JavaInterop.asTruffleObject(this);
    CallWithInt callback = JavaInterop.asJavaObject(CallWithInt.class, truffle);
    callback.callback(32);
    assertEquals(' ', ch);
}
Also used : TruffleObject(com.oracle.truffle.api.interop.TruffleObject) Test(org.junit.Test)

Example 70 with TruffleObject

use of com.oracle.truffle.api.interop.TruffleObject in project graal by oracle.

the class CallbackConvertTest method callWithCharTest.

@Test
public void callWithCharTest() {
    TruffleObject truffle = JavaInterop.asTruffleObject(this);
    CallWithChar callback = JavaInterop.asJavaObject(CallWithChar.class, truffle);
    callback.callback('A');
    assertEquals('A', ch);
}
Also used : TruffleObject(com.oracle.truffle.api.interop.TruffleObject) Test(org.junit.Test)

Aggregations

TruffleObject (com.oracle.truffle.api.interop.TruffleObject)201 Test (org.junit.Test)135 ValueHostInteropTest (com.oracle.truffle.api.test.polyglot.ValueHostInteropTest)34 InteropException (com.oracle.truffle.api.interop.InteropException)18 UnsupportedMessageException (com.oracle.truffle.api.interop.UnsupportedMessageException)17 Specialization (com.oracle.truffle.api.dsl.Specialization)16 UnknownIdentifierException (com.oracle.truffle.api.interop.UnknownIdentifierException)14 LLVMTruffleObject (com.oracle.truffle.llvm.runtime.LLVMTruffleObject)12 ArrayTruffleObject (com.oracle.truffle.api.test.polyglot.ValueHostInteropTest.ArrayTruffleObject)10 Node (com.oracle.truffle.api.nodes.Node)9 UnsupportedTypeException (com.oracle.truffle.api.interop.UnsupportedTypeException)8 CallTarget (com.oracle.truffle.api.CallTarget)7 StackPointer (com.oracle.truffle.llvm.runtime.memory.LLVMStack.StackPointer)7 TestCallback (com.oracle.truffle.nfi.test.interop.TestCallback)7 LinkedHashMap (java.util.LinkedHashMap)7 Source (com.oracle.truffle.api.source.Source)6 Method (java.lang.reflect.Method)6 HashMap (java.util.HashMap)6 Map (java.util.Map)6 TruffleBoundary (com.oracle.truffle.api.CompilerDirectives.TruffleBoundary)5