Mercurial > hg > graal-compiler
comparison graal/com.oracle.truffle.api.test/src/com/oracle/truffle/api/test/vm/TruffleVMSingleThreadedTest.java @ 21468:99942eac9c6d
Introducing TruffleVM - a central place to invoke code in any registered TruffleLanguage.
author | Jaroslav Tulach <jaroslav.tulach@oracle.com> |
---|---|
date | Fri, 22 May 2015 13:41:10 +0200 |
parents | |
children | 3286fb5fea4a b1530a6cce8c |
comparison
equal
deleted
inserted
replaced
21467:d4db9d812c8d | 21468:99942eac9c6d |
---|---|
1 /* | |
2 * Copyright (c) 2012, 2015, Oracle and/or its affiliates. All rights reserved. | |
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. | |
4 * | |
5 * This code is free software; you can redistribute it and/or modify it | |
6 * under the terms of the GNU General Public License version 2 only, as | |
7 * published by the Free Software Foundation. | |
8 * | |
9 * This code is distributed in the hope that it will be useful, but WITHOUT | |
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or | |
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License | |
12 * version 2 for more details (a copy is included in the LICENSE file that | |
13 * accompanied this code). | |
14 * | |
15 * You should have received a copy of the GNU General Public License version | |
16 * 2 along with this work; if not, write to the Free Software Foundation, | |
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. | |
18 * | |
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA | |
20 * or visit www.oracle.com if you need additional information or have any | |
21 * questions. | |
22 */ | |
23 package com.oracle.truffle.api.test.vm; | |
24 | |
25 import com.oracle.truffle.api.vm.TruffleVM; | |
26 import java.io.IOException; | |
27 import java.io.StringReader; | |
28 import java.net.URI; | |
29 import java.net.URISyntaxException; | |
30 import org.junit.Before; | |
31 import org.junit.Test; | |
32 | |
33 public class TruffleVMSingleThreadedTest { | |
34 TruffleVM tvm; | |
35 | |
36 @Before | |
37 public void initInDifferentThread() throws InterruptedException { | |
38 Thread t = new Thread("Initializer") { | |
39 @Override | |
40 public void run() { | |
41 tvm = TruffleVM.create(); | |
42 } | |
43 }; | |
44 t.start(); | |
45 t.join(); | |
46 } | |
47 | |
48 @Test(expected = IllegalStateException.class) | |
49 public void evalURI() throws IOException, URISyntaxException { | |
50 tvm.eval(new URI("http://unknown.js")); | |
51 } | |
52 | |
53 @Test(expected = IllegalStateException.class) | |
54 public void evalString() throws IOException { | |
55 tvm.eval("text/javascript", "1 + 1"); | |
56 } | |
57 | |
58 @Test(expected = IllegalStateException.class) | |
59 public void evalReader() throws IOException { | |
60 try (StringReader sr = new StringReader("1 + 1")) { | |
61 tvm.eval("text/javascript", sr); | |
62 } | |
63 } | |
64 | |
65 @Test(expected = IllegalStateException.class) | |
66 public void findGlobalSymbol() { | |
67 tvm.findGlobalSymbol("doesNotExists"); | |
68 } | |
69 } |