Search in sources :

Example 66 with InteropLibrary

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

the class InteropDateTimeTest method testValidCombination.

private void testValidCombination(Object o, boolean hasDate, boolean hasTime, boolean hasTimeZone) throws InteropException {
    InteropLibrary library = createLibrary(InteropLibrary.class, o);
    assertEquals(hasDate, library.isDate(o));
    assertEquals(hasTime, library.isTime(o));
    assertEquals(hasTimeZone, library.isTimeZone(o));
    if (hasDate) {
        library.asDate(o);
    } else {
        assertFails(() -> library.asDate(o), UnsupportedMessageException.class);
    }
    if (hasTime) {
        library.asTime(o);
    } else {
        assertFails(() -> library.asTime(o), UnsupportedMessageException.class);
    }
    if (hasTimeZone) {
        library.asTimeZone(o);
    } else {
        assertFails(() -> library.asTimeZone(o), UnsupportedMessageException.class);
    }
}
Also used : InteropLibrary(com.oracle.truffle.api.interop.InteropLibrary)

Example 67 with InteropLibrary

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

the class InteropLibraryBaseTest method assertNoBuffer.

protected final void assertNoBuffer(Object value) {
    InteropLibrary lib = createLibrary(InteropLibrary.class, value);
    assertFalse(lib.hasBufferElements(value));
    assertUnsupported(() -> lib.isBufferWritable(value));
    assertUnsupported(() -> lib.getBufferSize(value));
    assertUnsupported(() -> lib.readBufferByte(value, 0));
    assertUnsupported(() -> lib.writeBufferByte(value, 0, (byte) 0));
    assertUnsupported(() -> lib.readBufferShort(value, LITTLE_ENDIAN, 0));
    assertUnsupported(() -> lib.writeBufferShort(value, LITTLE_ENDIAN, 0, (short) 0));
    assertUnsupported(() -> lib.readBufferInt(value, LITTLE_ENDIAN, 0));
    assertUnsupported(() -> lib.writeBufferInt(value, LITTLE_ENDIAN, 0, 0));
    assertUnsupported(() -> lib.readBufferLong(value, LITTLE_ENDIAN, 0));
    assertUnsupported(() -> lib.writeBufferLong(value, LITTLE_ENDIAN, 0, 0));
    assertUnsupported(() -> lib.readBufferFloat(value, LITTLE_ENDIAN, 0));
    assertUnsupported(() -> lib.writeBufferFloat(value, LITTLE_ENDIAN, 0, 0));
    assertUnsupported(() -> lib.readBufferDouble(value, LITTLE_ENDIAN, 0));
    assertUnsupported(() -> lib.writeBufferDouble(value, LITTLE_ENDIAN, 0, 0));
}
Also used : InteropLibrary(com.oracle.truffle.api.interop.InteropLibrary)

Example 68 with InteropLibrary

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

the class InteropLibraryBaseTest method assertNoMetaObject.

protected final void assertNoMetaObject(Object value) {
    InteropLibrary lib = createLibrary(InteropLibrary.class, value);
    assertFalse(lib.isMetaObject(value));
    assertUnsupported(() -> lib.getMetaQualifiedName(value));
    assertUnsupported(() -> lib.getMetaSimpleName(value));
}
Also used : InteropLibrary(com.oracle.truffle.api.interop.InteropLibrary)

Example 69 with InteropLibrary

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

the class InteropLibraryBaseTest method assertNoString.

protected final void assertNoString(Object value) {
    InteropLibrary lib = createLibrary(InteropLibrary.class, value);
    assertFalse(lib.isString(value));
    assertUnsupported(() -> lib.asString(value));
}
Also used : InteropLibrary(com.oracle.truffle.api.interop.InteropLibrary)

Example 70 with InteropLibrary

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

the class InteropLibraryBaseTest method assertNoDuration.

protected final void assertNoDuration(Object value) {
    InteropLibrary lib = createLibrary(InteropLibrary.class, value);
    assertFalse(lib.isDuration(value));
    assertUnsupported(() -> lib.asDuration(value));
}
Also used : InteropLibrary(com.oracle.truffle.api.interop.InteropLibrary)

Aggregations

InteropLibrary (com.oracle.truffle.api.interop.InteropLibrary)158 Test (org.junit.Test)76 TruffleObject (com.oracle.truffle.api.interop.TruffleObject)60 UnsupportedMessageException (com.oracle.truffle.api.interop.UnsupportedMessageException)51 UnknownIdentifierException (com.oracle.truffle.api.interop.UnknownIdentifierException)18 UnsupportedTypeException (com.oracle.truffle.api.interop.UnsupportedTypeException)18 ArityException (com.oracle.truffle.api.interop.ArityException)16 TruffleBoundary (com.oracle.truffle.api.CompilerDirectives.TruffleBoundary)15 WasmInstance (org.graalvm.wasm.WasmInstance)15 WebAssembly (org.graalvm.wasm.api.WebAssembly)15 VirtualFrame (com.oracle.truffle.api.frame.VirtualFrame)12 RootNode (com.oracle.truffle.api.nodes.RootNode)12 InteropException (com.oracle.truffle.api.interop.InteropException)11 InvalidArrayIndexException (com.oracle.truffle.api.interop.InvalidArrayIndexException)11 Dictionary (org.graalvm.wasm.api.Dictionary)8 SourceSection (com.oracle.truffle.api.source.SourceSection)6 CallTarget (com.oracle.truffle.api.CallTarget)5 Node (com.oracle.truffle.api.nodes.Node)5 ProxyObject (org.graalvm.polyglot.proxy.ProxyObject)5 WasmJsApiException (org.graalvm.wasm.exception.WasmJsApiException)5