Search in sources :

Example 1 with ProxyInstantiable

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

the class ProxySPITest method testProxyInstantiable.

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

        @Override
        public Object newInstance(Value... t) {
            return t[0].newInstance();
        }
    };
    eval(context, proxyOuter, (proxyInner) -> {
        assertEquals(true, Message.IS_INSTANTIABLE, proxyInner);
        assertEquals(false, Message.IS_EXECUTABLE, proxyInner);
        assertUnsupported(Message.createExecute(0), proxyInner, 42);
        assertUnsupported(Message.AS_POINTER, 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);
        assertEquals(false, Message.IS_BOXED, proxyInner);
        assertEquals(false, Message.IS_NULL, proxyInner);
        assertEquals(false, Message.HAS_KEYS, proxyInner);
        assertEquals(false, Message.HAS_SIZE, proxyInner);
        assertEquals(false, Message.IS_POINTER, 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) ProxyInstantiable(org.graalvm.polyglot.proxy.ProxyInstantiable) Value(org.graalvm.polyglot.Value) Test(org.junit.Test)

Aggregations

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