Search in sources :

Example 1 with TestObject

use of com.oracle.truffle.tck.impl.TestObject in project graal by oracle.

the class TruffleTCK method testWriteValueToForeign.

/**
 * @since 0.16
 */
@Test
public void testWriteValueToForeign() throws Exception {
    String id = writeValueToForeign();
    if (id == null) {
        return;
    }
    PolyglotEngine.Value apply = findGlobalSymbol(id);
    TestObject obj = new TestObject(-1.5);
    apply.execute(JavaInterop.asTruffleObject(obj));
    Assert.assertEquals(42.0, obj.value, 0.1);
}
Also used : TestObject(com.oracle.truffle.tck.impl.TestObject) Test(org.junit.Test)

Example 2 with TestObject

use of com.oracle.truffle.tck.impl.TestObject in project graal by oracle.

the class TruffleTCK method testReadValueFromForeign.

/**
 * @since 0.16
 */
@Test
public void testReadValueFromForeign() throws Exception {
    String id = readValueFromForeign();
    if (id == null) {
        return;
    }
    PolyglotEngine.Value apply = findGlobalSymbol(id);
    Assert.assertEquals(42.0, ((Number) apply.execute(JavaInterop.asTruffleObject(new TestObject(42.0))).get()).doubleValue(), 0.1);
}
Also used : TestObject(com.oracle.truffle.tck.impl.TestObject) Test(org.junit.Test)

Example 3 with TestObject

use of com.oracle.truffle.tck.impl.TestObject in project graal by oracle.

the class TruffleTCK method testCallMethod.

/**
 * @since 0.16
 */
@Test
public void testCallMethod() throws Exception {
    String id = callMethod();
    if (id == null) {
        return;
    }
    PolyglotEngine.Value apply = findGlobalSymbol(id);
    TestObject obj = new TestObject(0);
    apply.execute(JavaInterop.asTruffleObject(obj));
    Assert.assertEquals(obj.arg1, 41.0, 0.1);
    Assert.assertEquals(obj.arg2, 42.0, 0.1);
}
Also used : TestObject(com.oracle.truffle.tck.impl.TestObject) Test(org.junit.Test)

Aggregations

TestObject (com.oracle.truffle.tck.impl.TestObject)3 Test (org.junit.Test)3