Mercurial > hg > truffle
comparison truffle/com.oracle.truffle.api.test/src/com/oracle/truffle/api/test/vm/ExceptionDuringParsingTest.java @ 22184:6380c7de0159
Verify disposeContext is really called
author | Jaroslav Tulach <jaroslav.tulach@oracle.com> |
---|---|
date | Tue, 22 Sep 2015 12:11:21 +0200 |
parents | 1421041175a7 |
children | b50f3bc4ed37 |
comparison
equal
deleted
inserted
replaced
22183:1421041175a7 | 22184:6380c7de0159 |
---|---|
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.impl.Accessor; | 25 import com.oracle.truffle.api.impl.Accessor; |
26 import com.oracle.truffle.api.source.Source; | 26 import com.oracle.truffle.api.source.Source; |
27 import com.oracle.truffle.api.test.vm.ImplicitExplicitExportTest.Ctx; | |
27 import static com.oracle.truffle.api.test.vm.ImplicitExplicitExportTest.L1; | 28 import static com.oracle.truffle.api.test.vm.ImplicitExplicitExportTest.L1; |
28 import com.oracle.truffle.api.vm.TruffleVM; | 29 import com.oracle.truffle.api.vm.TruffleVM; |
29 import java.io.IOException; | 30 import java.io.IOException; |
30 import static org.junit.Assert.assertEquals; | 31 import static org.junit.Assert.assertEquals; |
31 import static org.junit.Assert.assertNotNull; | 32 import static org.junit.Assert.assertNotNull; |
36 public class ExceptionDuringParsingTest { | 37 public class ExceptionDuringParsingTest { |
37 public static Accessor API; | 38 public static Accessor API; |
38 | 39 |
39 @Test | 40 @Test |
40 public void canGetAccessToOwnLanguageInstance() throws Exception { | 41 public void canGetAccessToOwnLanguageInstance() throws Exception { |
42 Ctx.disposed.clear(); | |
43 | |
41 TruffleVM vm = TruffleVM.newVM().build(); | 44 TruffleVM vm = TruffleVM.newVM().build(); |
42 TruffleVM.Language language = vm.getLanguages().get(L1); | 45 TruffleVM.Language language = vm.getLanguages().get(L1); |
43 assertNotNull("L1 language is defined", language); | 46 assertNotNull("L1 language is defined", language); |
44 | 47 |
45 final Source src = Source.fromText("parse=No, no, no!", "Fail on parsing").withMimeType(L1); | 48 final Source src = Source.fromText("parse=No, no, no!", "Fail on parsing").withMimeType(L1); |
48 fail("Exception thrown"); | 51 fail("Exception thrown"); |
49 } catch (IOException ex) { | 52 } catch (IOException ex) { |
50 assertEquals(ex.getMessage(), "No, no, no!"); | 53 assertEquals(ex.getMessage(), "No, no, no!"); |
51 } | 54 } |
52 | 55 |
56 assertEquals("No dispose yet", 0, Ctx.disposed.size()); | |
57 | |
53 vm.dispose(); | 58 vm.dispose(); |
59 | |
60 assertEquals("One context disposed", 1, Ctx.disposed.size()); | |
54 | 61 |
55 try { | 62 try { |
56 vm.eval(src); | 63 vm.eval(src); |
57 fail("Should throw an exception"); | 64 fail("Should throw an exception"); |
58 } catch (IllegalStateException ex) { | 65 } catch (IllegalStateException ex) { |