Search in sources :

Example 1 with ProxyNativeObject

use of org.graalvm.polyglot.proxy.ProxyNativeObject in project graal by oracle.

the class ProxySPITest method testProxyNativeObject.

@Test
public void testProxyNativeObject() throws Throwable {
    Context context = Context.create();
    ProxyNativeObject proxyOuter = new ProxyNativeObject() {

        public long asPointer() {
            return 42;
        }
    };
    eval(context, proxyOuter, (proxyInner) -> {
        assertEquals(true, Message.IS_POINTER, proxyInner);
        assertEquals(42L, Message.AS_POINTER, proxyInner);
        assertUnsupported(Message.createExecute(0), proxyInner);
        assertUnsupported(Message.UNBOX, proxyInner);
        assertUnsupported(Message.GET_SIZE, proxyInner);
        assertEmpty(Message.KEYS, proxyInner);
        assertUnsupported(Message.READ, proxyInner);
        assertUnsupported(Message.WRITE, proxyInner);
        assertUnsupported(Message.TO_NATIVE, proxyInner);
        assertUnsupported(Message.UNBOX, proxyInner);
        assertUnsupported(Message.createInvoke(0), proxyInner);
        assertUnsupported(Message.createExecute(0), proxyInner);
        assertUnsupported(Message.createNew(0), proxyInner);
        assertEquals(false, Message.IS_EXECUTABLE, proxyInner);
        assertEquals(false, Message.IS_INSTANTIABLE, proxyInner);
        assertEquals(false, Message.IS_NULL, proxyInner);
        assertEquals(false, Message.HAS_KEYS, proxyInner);
        assertEquals(false, Message.HAS_SIZE, proxyInner);
        assertEquals(false, Message.IS_BOXED, proxyInner);
        assertEquals(0, Message.KEY_INFO, proxyInner);
        return null;
    });
}
Also used : LanguageContext(com.oracle.truffle.api.test.polyglot.ContextAPITestLanguage.LanguageContext) Context(org.graalvm.polyglot.Context) ProxyNativeObject(org.graalvm.polyglot.proxy.ProxyNativeObject) Test(org.junit.Test)

Aggregations

LanguageContext (com.oracle.truffle.api.test.polyglot.ContextAPITestLanguage.LanguageContext)1 Context (org.graalvm.polyglot.Context)1 ProxyNativeObject (org.graalvm.polyglot.proxy.ProxyNativeObject)1 Test (org.junit.Test)1