comparison graal/com.oracle.truffle.api.dsl.test/src/com/oracle/truffle/api/dsl/test/UnsupportedSpecializationTest.java @ 13812:f270f09616da

Truffle-DSL: implemented specific structured exception for unsupported specializations. (GRAAL-682)
author Christian Humer <christian.humer@gmail.com>
date Wed, 29 Jan 2014 21:26:26 +0100
parents
children 28479abd1a69
comparison
equal deleted inserted replaced
13811:641f22b1c6b8 13812:f270f09616da
1 /*
2 * Copyright (c) 2012, 2013, 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.dsl.test;
24
25 import org.junit.*;
26
27 import com.oracle.truffle.api.dsl.*;
28 import com.oracle.truffle.api.dsl.test.TypeSystemTest.TestRootNode;
29 import com.oracle.truffle.api.dsl.test.TypeSystemTest.ValueNode;
30 import com.oracle.truffle.api.dsl.test.UnsupportedSpecializationTestFactory.Undefined1Factory;
31
32 public class UnsupportedSpecializationTest {
33
34 @Test
35 public void testUndefined1() {
36 TestRootNode<Undefined1> root = TestHelper.createRoot(Undefined1Factory.getInstance());
37 try {
38 TestHelper.executeWith(root, "");
39 Assert.fail();
40 } catch (UnsupportedSpecializationException e) {
41 Assert.assertNotNull(e.getSuppliedValues());
42 Assert.assertEquals(1, e.getSuppliedValues().length);
43 Assert.assertEquals("", e.getSuppliedValues()[0]);
44 Assert.assertEquals(root.getNode(), e.getNode());
45 }
46 }
47
48 @NodeChild("a")
49 abstract static class Undefined1 extends ValueNode {
50
51 @Specialization
52 public int doInteger(@SuppressWarnings("unused") int a) {
53 throw new AssertionError();
54 }
55 }
56
57 // TODO more tests required
58 }