Mercurial > hg > truffle
comparison truffle/com.oracle.truffle.api.test/src/com/oracle/truffle/api/test/vm/GlobalSymbolTest.java @ 22121:d045a505c2b3
Asynchronous TruffleVM can be created by providing own Executor when configuring the TruffleVM.Builder
author | Jaroslav Tulach <jaroslav.tulach@oracle.com> |
---|---|
date | Wed, 02 Sep 2015 10:44:54 +0200 |
parents | cf19259edf87 |
children | dc83cc1f94f2 ffadd23c63c8 |
comparison
equal
deleted
inserted
replaced
22120:fe5df1f36fec | 22121:d045a505c2b3 |
---|---|
21 * questions. | 21 * questions. |
22 */ | 22 */ |
23 package com.oracle.truffle.api.test.vm; | 23 package com.oracle.truffle.api.test.vm; |
24 | 24 |
25 import com.oracle.truffle.api.source.Source; | 25 import com.oracle.truffle.api.source.Source; |
26 import static org.junit.Assert.*; | |
27 | |
28 import java.io.*; | |
29 | |
30 import org.junit.*; | |
31 | |
32 import static com.oracle.truffle.api.test.vm.ImplicitExplicitExportTest.L3; | 26 import static com.oracle.truffle.api.test.vm.ImplicitExplicitExportTest.L3; |
33 import com.oracle.truffle.api.vm.*; | 27 import com.oracle.truffle.api.vm.*; |
28 import java.io.*; | |
29 import java.util.concurrent.Executors; | |
30 import org.junit.*; | |
31 import static org.junit.Assert.*; | |
34 | 32 |
35 public class GlobalSymbolTest { | 33 public class GlobalSymbolTest { |
36 @Test | 34 @Test |
37 public void globalSymbolFoundByLanguage() throws IOException { | 35 public void globalSymbolFoundByLanguage() throws IOException { |
38 TruffleVM vm = TruffleVM.newVM().globalSymbol("ahoj", "42").build(); | 36 TruffleVM vm = TruffleVM.newVM().globalSymbol("ahoj", "42").executor(Executors.newSingleThreadExecutor()).build(); |
39 // @formatter:off | 37 // @formatter:off |
40 Object ret = vm.eval( | 38 Object ret = vm.eval( |
41 Source.fromText("return=ahoj", "Return").withMimeType(L3) | 39 Source.fromText("return=ahoj", "Return").withMimeType(L3) |
42 ); | 40 ).get(); |
43 // @formatter:on | 41 // @formatter:on |
44 assertEquals("42", ret); | 42 assertEquals("42", ret); |
45 } | 43 } |
46 | 44 |
47 @Test | 45 @Test |
48 public void globalSymbolFoundByVMUser() throws IOException { | 46 public void globalSymbolFoundByVMUser() throws IOException { |
49 TruffleVM vm = TruffleVM.newVM().globalSymbol("ahoj", "42").build(); | 47 TruffleVM vm = TruffleVM.newVM().globalSymbol("ahoj", "42").build(); |
50 TruffleVM.Symbol ret = vm.findGlobalSymbol("ahoj"); | 48 TruffleVM.Symbol ret = vm.findGlobalSymbol("ahoj"); |
51 assertNotNull("Symbol found", ret); | 49 assertNotNull("Symbol found", ret); |
52 assertEquals("42", ret.invoke(null)); | 50 assertEquals("42", ret.get()); |
53 } | 51 } |
54 } | 52 } |