Mercurial > hg > truffle
comparison truffle/com.oracle.truffle.api.test/src/com/oracle/truffle/api/test/vm/ExceptionDuringParsingTest.java @ 22183:1421041175a7
Adding dispose() and TruffleLanguage.disposeContext to allow user request and languages explicitly free the resources
author | Jaroslav Tulach <jaroslav.tulach@oracle.com> |
---|---|
date | Mon, 21 Sep 2015 14:05:33 +0200 |
parents | dc83cc1f94f2 |
children | 6380c7de0159 |
comparison
equal
deleted
inserted
replaced
22167:0480c4873a4a | 22183:1421041175a7 |
---|---|
27 import static com.oracle.truffle.api.test.vm.ImplicitExplicitExportTest.L1; | 27 import static com.oracle.truffle.api.test.vm.ImplicitExplicitExportTest.L1; |
28 import com.oracle.truffle.api.vm.TruffleVM; | 28 import com.oracle.truffle.api.vm.TruffleVM; |
29 import java.io.IOException; | 29 import java.io.IOException; |
30 import static org.junit.Assert.assertEquals; | 30 import static org.junit.Assert.assertEquals; |
31 import static org.junit.Assert.assertNotNull; | 31 import static org.junit.Assert.assertNotNull; |
32 import static org.junit.Assert.assertTrue; | |
32 import static org.junit.Assert.fail; | 33 import static org.junit.Assert.fail; |
33 import org.junit.Test; | 34 import org.junit.Test; |
34 | 35 |
35 public class ExceptionDuringParsingTest { | 36 public class ExceptionDuringParsingTest { |
36 public static Accessor API; | 37 public static Accessor API; |
39 public void canGetAccessToOwnLanguageInstance() throws Exception { | 40 public void canGetAccessToOwnLanguageInstance() throws Exception { |
40 TruffleVM vm = TruffleVM.newVM().build(); | 41 TruffleVM vm = TruffleVM.newVM().build(); |
41 TruffleVM.Language language = vm.getLanguages().get(L1); | 42 TruffleVM.Language language = vm.getLanguages().get(L1); |
42 assertNotNull("L1 language is defined", language); | 43 assertNotNull("L1 language is defined", language); |
43 | 44 |
45 final Source src = Source.fromText("parse=No, no, no!", "Fail on parsing").withMimeType(L1); | |
44 try { | 46 try { |
45 vm.eval(Source.fromText("parse=No, no, no!", "Fail on parsing").withMimeType(L1)); | 47 vm.eval(src); |
46 fail("Exception thrown"); | 48 fail("Exception thrown"); |
47 } catch (IOException ex) { | 49 } catch (IOException ex) { |
48 assertEquals(ex.getMessage(), "No, no, no!"); | 50 assertEquals(ex.getMessage(), "No, no, no!"); |
49 } | 51 } |
52 | |
53 vm.dispose(); | |
54 | |
55 try { | |
56 vm.eval(src); | |
57 fail("Should throw an exception"); | |
58 } catch (IllegalStateException ex) { | |
59 assertTrue(ex.getMessage(), ex.getMessage().contains("disposed")); | |
60 } | |
61 try { | |
62 vm.findGlobalSymbol("nothing"); | |
63 fail("Should throw an exception"); | |
64 } catch (IllegalStateException ex) { | |
65 assertTrue(ex.getMessage(), ex.getMessage().contains("disposed")); | |
66 } | |
67 try { | |
68 vm.dispose(); | |
69 fail("Should throw an exception"); | |
70 } catch (IllegalStateException ex) { | |
71 assertTrue(ex.getMessage(), ex.getMessage().contains("disposed")); | |
72 } | |
50 } | 73 } |
51 } | 74 } |