/** @since 0.16 */ @Test public void testIsNotNull() throws Exception { String id = objectWithValueProperty(); if (id == null) { return; } PolyglotEngine.Value apply = findGlobalSymbol(id); MessageInterface object = JavaInterop.asJavaObject(MessageInterface.class, (TruffleObject) apply.execute().get()); Assert.assertEquals(false, object.isNull()); }
/** @since 0.16 */ @Test public void testReadFromObjectWithValueProperty() throws Exception { String id = objectWithValueProperty(); if (id == null) { return; } PolyglotEngine.Value apply = findGlobalSymbol(id); TruffleObject truffleObject = (TruffleObject) apply.execute().get(); assertIsObjectOfLanguage(truffleObject); ObjectWithValueInterface object = JavaInterop.asJavaObject(ObjectWithValueInterface.class, truffleObject); Assert.assertEquals(42.0, object.value(), 0.1); }
/** @since 0.16 */ @Test public void testWriteToObjectWithValueProperty() throws Exception { String id = objectWithValueProperty(); if (id == null) { return; } PolyglotEngine.Value apply = findGlobalSymbol(id); TruffleObject truffleObject = (TruffleObject) apply.execute().get(); assertIsObjectOfLanguage(truffleObject); ObjectWithValueInterface object = JavaInterop.asJavaObject(ObjectWithValueInterface.class, truffleObject); Assert.assertEquals(42.0, object.value(), 0.1); object.value(13.0); Assert.assertEquals(13.0, object.value(), 0.1); }