/** @since 0.16 */ @Test public void testWriteToObjectWithElement() throws Exception { String id = objectWithElement(); if (id == null) { return; } PolyglotEngine.Value apply = findGlobalSymbol(id); TruffleObject truffleObject = (TruffleObject) apply.execute().get(); assertIsObjectOfLanguage(truffleObject); @SuppressWarnings("unchecked") List<Object> object = JavaInterop.asJavaObject(List.class, truffleObject); Assert.assertEquals(42.0, ((Number) object.get(2)).doubleValue(), 0.1); object.set(2, 13.0); Assert.assertEquals(13.0, ((Number) object.get(2)).doubleValue(), 0.1); }
/** @since 0.16 */ @Test public void testReadFromObjectWithElement() throws Exception { String id = objectWithElement(); if (id == null) { return; } PolyglotEngine.Value apply = findGlobalSymbol(id); TruffleObject truffleObject = (TruffleObject) apply.execute().get(); assertIsObjectOfLanguage(truffleObject); List<?> object = JavaInterop.asJavaObject(List.class, truffleObject); Assert.assertEquals(42.0, ((Number) object.get(2)).doubleValue(), 0.1); }
/** @since 0.16 */ @Test public void testGetSize() throws Exception { String id = objectWithElement(); if (id == null) { return; } PolyglotEngine.Value apply = findGlobalSymbol(id); List<?> object = JavaInterop.asJavaObject(List.class, (TruffleObject) apply.execute().get()); Assert.assertEquals(4, object.size()); }
/** @since 0.16 */ @Test public void testHasSize() throws Exception { String id = objectWithElement(); if (id == null) { return; } PolyglotEngine.Value apply = findGlobalSymbol(id); MessageInterface object = JavaInterop.asJavaObject(MessageInterface.class, (TruffleObject) apply.execute().get()); Assert.assertEquals(true, object.hasSize()); }