Search in sources :

Example 21 with TruffleObject

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

the class NullArrayNFITest method testNullArray.

@Test
public void testNullArray(@Inject(NullArrayNode.class) CallTarget target) {
    Object ret = target.call(new NullObject());
    Assert.assertThat("return value", ret, is(instanceOf(TruffleObject.class)));
    TruffleObject obj = (TruffleObject) ret;
    Assert.assertTrue("isBoxed", isBoxed(obj));
    Assert.assertEquals("return value", "null", unbox(obj));
}
Also used : TruffleObject(com.oracle.truffle.api.interop.TruffleObject) NullObject(com.oracle.truffle.nfi.test.interop.NullObject) NullObject(com.oracle.truffle.nfi.test.interop.NullObject) TruffleObject(com.oracle.truffle.api.interop.TruffleObject) Test(org.junit.Test)

Example 22 with TruffleObject

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

the class NullNFITest method testNullCallbackArg.

@Test
public void testNullCallbackArg(@Inject(TestNullCallbackArgNode.class) CallTarget callTarget) {
    TruffleObject nullCallback = new TestCallback(1, (args) -> {
        Assert.assertThat("callback argument", args[0], is(instanceOf(TruffleObject.class)));
        Assert.assertTrue("isNull", isNull((TruffleObject) args[0]));
        return null;
    });
    callTarget.call(nullCallback);
}
Also used : TestCallback(com.oracle.truffle.nfi.test.interop.TestCallback) TruffleObject(com.oracle.truffle.api.interop.TruffleObject) Test(org.junit.Test)

Example 23 with TruffleObject

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

the class NullNFITest method testNullRet.

@Test
public void testNullRet(@Inject(TestNullRetNode.class) CallTarget callTarget) {
    Object ret = callTarget.call();
    Assert.assertThat("return value", ret, is(instanceOf(TruffleObject.class)));
    TruffleObject obj = (TruffleObject) ret;
    Assert.assertTrue("isNull", isNull(obj));
}
Also used : TruffleObject(com.oracle.truffle.api.interop.TruffleObject) NullObject(com.oracle.truffle.nfi.test.interop.NullObject) TruffleObject(com.oracle.truffle.api.interop.TruffleObject) Test(org.junit.Test)

Example 24 with TruffleObject

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

the class NullNFITest method testNullArg.

@Test
public void testNullArg(@Inject(TestNullArgNode.class) CallTarget callTarget) {
    String expected = getExpected();
    Object ret = callTarget.call(new NullObject());
    Assert.assertThat("return value", ret, is(instanceOf(TruffleObject.class)));
    TruffleObject obj = (TruffleObject) ret;
    Assert.assertTrue("isBoxed", isBoxed(obj));
    Assert.assertEquals("return value", expected, unbox(obj));
}
Also used : TruffleObject(com.oracle.truffle.api.interop.TruffleObject) NullObject(com.oracle.truffle.nfi.test.interop.NullObject) NullObject(com.oracle.truffle.nfi.test.interop.NullObject) TruffleObject(com.oracle.truffle.api.interop.TruffleObject) Test(org.junit.Test)

Example 25 with TruffleObject

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

the class NullNFITest method testNullCallbackRet.

@Test
public void testNullCallbackRet(@Inject(TestNullCallbackRetNode.class) CallTarget callTarget) {
    String expected = getExpected();
    TruffleObject nullCallback = new TestCallback(0, (args) -> {
        return new NullObject();
    });
    Object ret = callTarget.call(nullCallback);
    Assert.assertThat("return value", ret, is(instanceOf(TruffleObject.class)));
    TruffleObject obj = (TruffleObject) ret;
    Assert.assertTrue("isBoxed", isBoxed(obj));
    Assert.assertEquals("return value", expected, unbox(obj));
}
Also used : NullObject(com.oracle.truffle.nfi.test.interop.NullObject) TruffleObject(com.oracle.truffle.api.interop.TruffleObject) NullObject(com.oracle.truffle.nfi.test.interop.NullObject) TestCallback(com.oracle.truffle.nfi.test.interop.TestCallback) 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