Mercurial > hg > truffle
diff truffle/com.oracle.truffle.api.test/src/com/oracle/truffle/api/test/vm/GlobalSymbolTest.java @ 22196:364e3f024643
Java objects passed into globalSymbol should be converted into something that Truffle languages can understand - e.g. TruffleObject instances.
author | Jaroslav Tulach <jaroslav.tulach@oracle.com> |
---|---|
date | Fri, 25 Sep 2015 14:06:44 +0200 |
parents | dcb70d90c11d |
children | 0d36601f233e |
line wrap: on
line diff
--- a/truffle/com.oracle.truffle.api.test/src/com/oracle/truffle/api/test/vm/GlobalSymbolTest.java Thu Sep 24 15:50:38 2015 +0200 +++ b/truffle/com.oracle.truffle.api.test/src/com/oracle/truffle/api/test/vm/GlobalSymbolTest.java Fri Sep 25 14:06:44 2015 +0200 @@ -22,13 +22,17 @@ */ package com.oracle.truffle.api.test.vm; +import com.oracle.truffle.api.interop.TruffleObject; import com.oracle.truffle.api.source.Source; import static com.oracle.truffle.api.test.vm.ImplicitExplicitExportTest.L3; import com.oracle.truffle.api.vm.PolyglotEngine; import java.io.IOException; +import java.util.List; import java.util.concurrent.Executors; import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertNotNull; +import static org.junit.Assert.assertTrue; import org.junit.Test; public class GlobalSymbolTest { @@ -50,4 +54,18 @@ assertNotNull("Symbol found", ret); assertEquals("42", ret.get()); } + + @Test + public void passingArray() throws IOException { + PolyglotEngine vm = PolyglotEngine.buildNew().globalSymbol("arguments", new Object[]{"one", "two", "three"}).build(); + PolyglotEngine.Value value = vm.findGlobalSymbol("arguments"); + assertFalse("Not instance of array", value.get() instanceof Object[]); + assertTrue("Instance of TruffleObject", value.get() instanceof TruffleObject); + List<?> args = value.as(List.class); + assertNotNull("Can be converted to List", args); + assertEquals("Three items", 3, args.size()); + assertEquals("one", args.get(0)); + assertEquals("two", args.get(1)); + assertEquals("three", args.get(2)); + } }