annotate 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
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
13812
f270f09616da Truffle-DSL: implemented specific structured exception for unsupported specializations. (GRAAL-682)
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
1 /*
f270f09616da Truffle-DSL: implemented specific structured exception for unsupported specializations. (GRAAL-682)
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
2 * Copyright (c) 2012, 2013, Oracle and/or its affiliates. All rights reserved.
f270f09616da Truffle-DSL: implemented specific structured exception for unsupported specializations. (GRAAL-682)
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
f270f09616da Truffle-DSL: implemented specific structured exception for unsupported specializations. (GRAAL-682)
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
4 *
f270f09616da Truffle-DSL: implemented specific structured exception for unsupported specializations. (GRAAL-682)
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
5 * This code is free software; you can redistribute it and/or modify it
f270f09616da Truffle-DSL: implemented specific structured exception for unsupported specializations. (GRAAL-682)
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
6 * under the terms of the GNU General Public License version 2 only, as
f270f09616da Truffle-DSL: implemented specific structured exception for unsupported specializations. (GRAAL-682)
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
7 * published by the Free Software Foundation.
f270f09616da Truffle-DSL: implemented specific structured exception for unsupported specializations. (GRAAL-682)
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
8 *
f270f09616da Truffle-DSL: implemented specific structured exception for unsupported specializations. (GRAAL-682)
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
9 * This code is distributed in the hope that it will be useful, but WITHOUT
f270f09616da Truffle-DSL: implemented specific structured exception for unsupported specializations. (GRAAL-682)
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
f270f09616da Truffle-DSL: implemented specific structured exception for unsupported specializations. (GRAAL-682)
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
f270f09616da Truffle-DSL: implemented specific structured exception for unsupported specializations. (GRAAL-682)
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
12 * version 2 for more details (a copy is included in the LICENSE file that
f270f09616da Truffle-DSL: implemented specific structured exception for unsupported specializations. (GRAAL-682)
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
13 * accompanied this code).
f270f09616da Truffle-DSL: implemented specific structured exception for unsupported specializations. (GRAAL-682)
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
14 *
f270f09616da Truffle-DSL: implemented specific structured exception for unsupported specializations. (GRAAL-682)
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
15 * You should have received a copy of the GNU General Public License version
f270f09616da Truffle-DSL: implemented specific structured exception for unsupported specializations. (GRAAL-682)
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
16 * 2 along with this work; if not, write to the Free Software Foundation,
f270f09616da Truffle-DSL: implemented specific structured exception for unsupported specializations. (GRAAL-682)
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
f270f09616da Truffle-DSL: implemented specific structured exception for unsupported specializations. (GRAAL-682)
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
18 *
f270f09616da Truffle-DSL: implemented specific structured exception for unsupported specializations. (GRAAL-682)
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
f270f09616da Truffle-DSL: implemented specific structured exception for unsupported specializations. (GRAAL-682)
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
20 * or visit www.oracle.com if you need additional information or have any
f270f09616da Truffle-DSL: implemented specific structured exception for unsupported specializations. (GRAAL-682)
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
21 * questions.
f270f09616da Truffle-DSL: implemented specific structured exception for unsupported specializations. (GRAAL-682)
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
22 */
f270f09616da Truffle-DSL: implemented specific structured exception for unsupported specializations. (GRAAL-682)
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
23 package com.oracle.truffle.api.dsl.test;
f270f09616da Truffle-DSL: implemented specific structured exception for unsupported specializations. (GRAAL-682)
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
24
f270f09616da Truffle-DSL: implemented specific structured exception for unsupported specializations. (GRAAL-682)
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
25 import org.junit.*;
f270f09616da Truffle-DSL: implemented specific structured exception for unsupported specializations. (GRAAL-682)
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
26
f270f09616da Truffle-DSL: implemented specific structured exception for unsupported specializations. (GRAAL-682)
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
27 import com.oracle.truffle.api.dsl.*;
f270f09616da Truffle-DSL: implemented specific structured exception for unsupported specializations. (GRAAL-682)
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
28 import com.oracle.truffle.api.dsl.test.TypeSystemTest.TestRootNode;
f270f09616da Truffle-DSL: implemented specific structured exception for unsupported specializations. (GRAAL-682)
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
29 import com.oracle.truffle.api.dsl.test.TypeSystemTest.ValueNode;
f270f09616da Truffle-DSL: implemented specific structured exception for unsupported specializations. (GRAAL-682)
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
30 import com.oracle.truffle.api.dsl.test.UnsupportedSpecializationTestFactory.Undefined1Factory;
f270f09616da Truffle-DSL: implemented specific structured exception for unsupported specializations. (GRAAL-682)
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
31
f270f09616da Truffle-DSL: implemented specific structured exception for unsupported specializations. (GRAAL-682)
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
32 public class UnsupportedSpecializationTest {
f270f09616da Truffle-DSL: implemented specific structured exception for unsupported specializations. (GRAAL-682)
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
33
f270f09616da Truffle-DSL: implemented specific structured exception for unsupported specializations. (GRAAL-682)
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
34 @Test
f270f09616da Truffle-DSL: implemented specific structured exception for unsupported specializations. (GRAAL-682)
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
35 public void testUndefined1() {
f270f09616da Truffle-DSL: implemented specific structured exception for unsupported specializations. (GRAAL-682)
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
36 TestRootNode<Undefined1> root = TestHelper.createRoot(Undefined1Factory.getInstance());
f270f09616da Truffle-DSL: implemented specific structured exception for unsupported specializations. (GRAAL-682)
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
37 try {
f270f09616da Truffle-DSL: implemented specific structured exception for unsupported specializations. (GRAAL-682)
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
38 TestHelper.executeWith(root, "");
f270f09616da Truffle-DSL: implemented specific structured exception for unsupported specializations. (GRAAL-682)
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
39 Assert.fail();
f270f09616da Truffle-DSL: implemented specific structured exception for unsupported specializations. (GRAAL-682)
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
40 } catch (UnsupportedSpecializationException e) {
f270f09616da Truffle-DSL: implemented specific structured exception for unsupported specializations. (GRAAL-682)
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
41 Assert.assertNotNull(e.getSuppliedValues());
f270f09616da Truffle-DSL: implemented specific structured exception for unsupported specializations. (GRAAL-682)
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
42 Assert.assertEquals(1, e.getSuppliedValues().length);
f270f09616da Truffle-DSL: implemented specific structured exception for unsupported specializations. (GRAAL-682)
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
43 Assert.assertEquals("", e.getSuppliedValues()[0]);
f270f09616da Truffle-DSL: implemented specific structured exception for unsupported specializations. (GRAAL-682)
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
44 Assert.assertEquals(root.getNode(), e.getNode());
f270f09616da Truffle-DSL: implemented specific structured exception for unsupported specializations. (GRAAL-682)
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
45 }
f270f09616da Truffle-DSL: implemented specific structured exception for unsupported specializations. (GRAAL-682)
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
46 }
f270f09616da Truffle-DSL: implemented specific structured exception for unsupported specializations. (GRAAL-682)
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
47
f270f09616da Truffle-DSL: implemented specific structured exception for unsupported specializations. (GRAAL-682)
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
48 @NodeChild("a")
f270f09616da Truffle-DSL: implemented specific structured exception for unsupported specializations. (GRAAL-682)
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
49 abstract static class Undefined1 extends ValueNode {
f270f09616da Truffle-DSL: implemented specific structured exception for unsupported specializations. (GRAAL-682)
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
50
f270f09616da Truffle-DSL: implemented specific structured exception for unsupported specializations. (GRAAL-682)
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
51 @Specialization
f270f09616da Truffle-DSL: implemented specific structured exception for unsupported specializations. (GRAAL-682)
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
52 public int doInteger(@SuppressWarnings("unused") int a) {
f270f09616da Truffle-DSL: implemented specific structured exception for unsupported specializations. (GRAAL-682)
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
53 throw new AssertionError();
f270f09616da Truffle-DSL: implemented specific structured exception for unsupported specializations. (GRAAL-682)
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
54 }
f270f09616da Truffle-DSL: implemented specific structured exception for unsupported specializations. (GRAAL-682)
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
55 }
f270f09616da Truffle-DSL: implemented specific structured exception for unsupported specializations. (GRAAL-682)
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
56
f270f09616da Truffle-DSL: implemented specific structured exception for unsupported specializations. (GRAAL-682)
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
57 // TODO more tests required
f270f09616da Truffle-DSL: implemented specific structured exception for unsupported specializations. (GRAAL-682)
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
58 }