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);
}
}
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));
}
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));
}
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));
}
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));
}
Aggregations