Mercurial > hg > truffle
diff truffle/com.oracle.truffle.api.test/src/com/oracle/truffle/api/test/vm/ExceptionDuringParsingTest.java @ 22081:ff531952a91c
Making sure IOException from TruffleLanguage.parse method is correctly propagated to TruffleVM.eval caller.
author | Jaroslav Tulach <jaroslav.tulach@oracle.com> |
---|---|
date | Fri, 14 Aug 2015 13:57:12 +0200 |
parents | truffle/com.oracle.truffle.api.test/src/com/oracle/truffle/api/test/vm/AccessorTest.java@78c3d3d8d86e |
children | cf19259edf87 |
line wrap: on
line diff
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/truffle/com.oracle.truffle.api.test/src/com/oracle/truffle/api/test/vm/ExceptionDuringParsingTest.java Fri Aug 14 13:57:12 2015 +0200 @@ -0,0 +1,48 @@ +/* + * Copyright (c) 2015, 2015, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ +package com.oracle.truffle.api.test.vm; + +import com.oracle.truffle.api.impl.Accessor; +import static com.oracle.truffle.api.test.vm.ImplicitExplicitExportTest.L1; +import com.oracle.truffle.api.vm.TruffleVM; +import java.io.IOException; +import static org.junit.Assert.*; +import org.junit.Test; + +public class ExceptionDuringParsingTest { + public static Accessor API; + + @Test + public void canGetAccessToOwnLanguageInstance() throws Exception { + TruffleVM vm = TruffleVM.newVM().build(); + TruffleVM.Language language = vm.getLanguages().get(L1); + assertNotNull("L1 language is defined", language); + + try { + vm.eval(L1, "parse=No, no, no!"); + fail("Exception thrown"); + } catch (IOException ex) { + assertEquals(ex.getMessage(), "No, no, no!"); + } + } +}