Mercurial > hg > truffle
comparison truffle/com.oracle.truffle.api.test/src/com/oracle/truffle/api/vm/EngineSingleThreadedTest.java @ 22424:fec62e298245
Rename package truffle.api.test to truffle.api to enable package-protected API access for testing.
author | Christian Humer <christian.humer@oracle.com> |
---|---|
date | Wed, 02 Dec 2015 15:16:27 +0100 |
parents | truffle/com.oracle.truffle.api.test/src/com/oracle/truffle/api/test/vm/EngineSingleThreadedTest.java@906a5f6e07cc |
children | b39b603e2a1e |
comparison
equal
deleted
inserted
replaced
22423:70a10a9f28ad | 22424:fec62e298245 |
---|---|
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.vm; | |
24 | |
25 import com.oracle.truffle.api.source.Source; | |
26 import com.oracle.truffle.api.vm.PolyglotEngine; | |
27 import java.io.File; | |
28 import java.io.IOException; | |
29 import java.io.StringReader; | |
30 import org.junit.Before; | |
31 import org.junit.Test; | |
32 | |
33 public class EngineSingleThreadedTest { | |
34 PolyglotEngine tvm; | |
35 | |
36 @Before | |
37 public void initInDifferentThread() throws InterruptedException { | |
38 final PolyglotEngine.Builder b = PolyglotEngine.newBuilder(); | |
39 Thread t = new Thread("Initializer") { | |
40 @Override | |
41 public void run() { | |
42 tvm = b.build(); | |
43 } | |
44 }; | |
45 t.start(); | |
46 t.join(); | |
47 } | |
48 | |
49 @Test(expected = IllegalStateException.class) | |
50 public void evalURI() throws IOException { | |
51 tvm.eval(Source.fromURL(new File(".").toURI().toURL(), "wrong.test")); | |
52 } | |
53 | |
54 @Test(expected = IllegalStateException.class) | |
55 public void evalString() throws IOException { | |
56 tvm.eval(Source.fromText("1 + 1", "wrong.test").withMimeType("text/javascript")); | |
57 } | |
58 | |
59 @Test(expected = IllegalStateException.class) | |
60 public void evalReader() throws IOException { | |
61 try (StringReader sr = new StringReader("1 + 1")) { | |
62 tvm.eval(Source.fromReader(sr, "wrong.test").withMimeType("text/javascript")); | |
63 } | |
64 } | |
65 | |
66 @Test(expected = IllegalStateException.class) | |
67 public void evalSource() throws IOException { | |
68 tvm.eval(Source.fromText("", "Empty")); | |
69 } | |
70 | |
71 @Test(expected = IllegalStateException.class) | |
72 public void findGlobalSymbol() { | |
73 tvm.findGlobalSymbol("doesNotExists"); | |
74 } | |
75 } |