Mercurial > hg > graal-compiler
annotate graal/com.oracle.truffle.api.dsl.test/src/com/oracle/truffle/api/dsl/test/BadLongOverflowSpecializationTest.java @ 20171:9ca538e3e46e
DSL: add tests for comparing against a byte and a short in guards.
author | Chris Seaton <chris.seaton@oracle.com> |
---|---|
date | Mon, 06 Apr 2015 13:43:39 +0100 |
parents | eecda5abf627 |
children |
rev | line source |
---|---|
18221
2c68474cc893
Truffle: add a test to track an ImplicitCast bug
Benoit Daloze <benoit.daloze@jku.at>
parents:
diff
changeset
|
1 /* |
2c68474cc893
Truffle: add a test to track an ImplicitCast bug
Benoit Daloze <benoit.daloze@jku.at>
parents:
diff
changeset
|
2 * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved. |
2c68474cc893
Truffle: add a test to track an ImplicitCast bug
Benoit Daloze <benoit.daloze@jku.at>
parents:
diff
changeset
|
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
2c68474cc893
Truffle: add a test to track an ImplicitCast bug
Benoit Daloze <benoit.daloze@jku.at>
parents:
diff
changeset
|
4 * |
2c68474cc893
Truffle: add a test to track an ImplicitCast bug
Benoit Daloze <benoit.daloze@jku.at>
parents:
diff
changeset
|
5 * This code is free software; you can redistribute it and/or modify it |
2c68474cc893
Truffle: add a test to track an ImplicitCast bug
Benoit Daloze <benoit.daloze@jku.at>
parents:
diff
changeset
|
6 * under the terms of the GNU General Public License version 2 only, as |
2c68474cc893
Truffle: add a test to track an ImplicitCast bug
Benoit Daloze <benoit.daloze@jku.at>
parents:
diff
changeset
|
7 * published by the Free Software Foundation. |
2c68474cc893
Truffle: add a test to track an ImplicitCast bug
Benoit Daloze <benoit.daloze@jku.at>
parents:
diff
changeset
|
8 * |
2c68474cc893
Truffle: add a test to track an ImplicitCast bug
Benoit Daloze <benoit.daloze@jku.at>
parents:
diff
changeset
|
9 * This code is distributed in the hope that it will be useful, but WITHOUT |
2c68474cc893
Truffle: add a test to track an ImplicitCast bug
Benoit Daloze <benoit.daloze@jku.at>
parents:
diff
changeset
|
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
2c68474cc893
Truffle: add a test to track an ImplicitCast bug
Benoit Daloze <benoit.daloze@jku.at>
parents:
diff
changeset
|
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
2c68474cc893
Truffle: add a test to track an ImplicitCast bug
Benoit Daloze <benoit.daloze@jku.at>
parents:
diff
changeset
|
12 * version 2 for more details (a copy is included in the LICENSE file that |
2c68474cc893
Truffle: add a test to track an ImplicitCast bug
Benoit Daloze <benoit.daloze@jku.at>
parents:
diff
changeset
|
13 * accompanied this code). |
2c68474cc893
Truffle: add a test to track an ImplicitCast bug
Benoit Daloze <benoit.daloze@jku.at>
parents:
diff
changeset
|
14 * |
2c68474cc893
Truffle: add a test to track an ImplicitCast bug
Benoit Daloze <benoit.daloze@jku.at>
parents:
diff
changeset
|
15 * You should have received a copy of the GNU General Public License version |
2c68474cc893
Truffle: add a test to track an ImplicitCast bug
Benoit Daloze <benoit.daloze@jku.at>
parents:
diff
changeset
|
16 * 2 along with this work; if not, write to the Free Software Foundation, |
2c68474cc893
Truffle: add a test to track an ImplicitCast bug
Benoit Daloze <benoit.daloze@jku.at>
parents:
diff
changeset
|
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
2c68474cc893
Truffle: add a test to track an ImplicitCast bug
Benoit Daloze <benoit.daloze@jku.at>
parents:
diff
changeset
|
18 * |
2c68474cc893
Truffle: add a test to track an ImplicitCast bug
Benoit Daloze <benoit.daloze@jku.at>
parents:
diff
changeset
|
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
2c68474cc893
Truffle: add a test to track an ImplicitCast bug
Benoit Daloze <benoit.daloze@jku.at>
parents:
diff
changeset
|
20 * or visit www.oracle.com if you need additional information or have any |
2c68474cc893
Truffle: add a test to track an ImplicitCast bug
Benoit Daloze <benoit.daloze@jku.at>
parents:
diff
changeset
|
21 * questions. |
2c68474cc893
Truffle: add a test to track an ImplicitCast bug
Benoit Daloze <benoit.daloze@jku.at>
parents:
diff
changeset
|
22 */ |
2c68474cc893
Truffle: add a test to track an ImplicitCast bug
Benoit Daloze <benoit.daloze@jku.at>
parents:
diff
changeset
|
23 package com.oracle.truffle.api.dsl.test; |
2c68474cc893
Truffle: add a test to track an ImplicitCast bug
Benoit Daloze <benoit.daloze@jku.at>
parents:
diff
changeset
|
24 |
2c68474cc893
Truffle: add a test to track an ImplicitCast bug
Benoit Daloze <benoit.daloze@jku.at>
parents:
diff
changeset
|
25 import static com.oracle.truffle.api.dsl.test.TestHelper.*; |
2c68474cc893
Truffle: add a test to track an ImplicitCast bug
Benoit Daloze <benoit.daloze@jku.at>
parents:
diff
changeset
|
26 import static org.junit.Assert.*; |
2c68474cc893
Truffle: add a test to track an ImplicitCast bug
Benoit Daloze <benoit.daloze@jku.at>
parents:
diff
changeset
|
27 |
2c68474cc893
Truffle: add a test to track an ImplicitCast bug
Benoit Daloze <benoit.daloze@jku.at>
parents:
diff
changeset
|
28 import org.junit.*; |
2c68474cc893
Truffle: add a test to track an ImplicitCast bug
Benoit Daloze <benoit.daloze@jku.at>
parents:
diff
changeset
|
29 |
2c68474cc893
Truffle: add a test to track an ImplicitCast bug
Benoit Daloze <benoit.daloze@jku.at>
parents:
diff
changeset
|
30 import com.oracle.truffle.api.dsl.*; |
18786
eecda5abf627
Truffle-DSL: simplify bad overflow test. The issue is fixed by the new generated node layout. (GRAAL-885 #resolve)
Christian Humer <christian.humer@gmail.com>
parents:
18221
diff
changeset
|
31 import com.oracle.truffle.api.dsl.test.BadLongOverflowSpecializationTestFactory.ImplicitCastExclusionFactory; |
18221
2c68474cc893
Truffle: add a test to track an ImplicitCast bug
Benoit Daloze <benoit.daloze@jku.at>
parents:
diff
changeset
|
32 import com.oracle.truffle.api.dsl.test.TypeSystemTest.TestRootNode; |
2c68474cc893
Truffle: add a test to track an ImplicitCast bug
Benoit Daloze <benoit.daloze@jku.at>
parents:
diff
changeset
|
33 import com.oracle.truffle.api.dsl.test.TypeSystemTest.ValueNode; |
2c68474cc893
Truffle: add a test to track an ImplicitCast bug
Benoit Daloze <benoit.daloze@jku.at>
parents:
diff
changeset
|
34 |
2c68474cc893
Truffle: add a test to track an ImplicitCast bug
Benoit Daloze <benoit.daloze@jku.at>
parents:
diff
changeset
|
35 public class BadLongOverflowSpecializationTest { |
2c68474cc893
Truffle: add a test to track an ImplicitCast bug
Benoit Daloze <benoit.daloze@jku.at>
parents:
diff
changeset
|
36 |
18786
eecda5abf627
Truffle-DSL: simplify bad overflow test. The issue is fixed by the new generated node layout. (GRAAL-885 #resolve)
Christian Humer <christian.humer@gmail.com>
parents:
18221
diff
changeset
|
37 /* Regression test for */ |
18221
2c68474cc893
Truffle: add a test to track an ImplicitCast bug
Benoit Daloze <benoit.daloze@jku.at>
parents:
diff
changeset
|
38 |
18786
eecda5abf627
Truffle-DSL: simplify bad overflow test. The issue is fixed by the new generated node layout. (GRAAL-885 #resolve)
Christian Humer <christian.humer@gmail.com>
parents:
18221
diff
changeset
|
39 @NodeChild |
eecda5abf627
Truffle-DSL: simplify bad overflow test. The issue is fixed by the new generated node layout. (GRAAL-885 #resolve)
Christian Humer <christian.humer@gmail.com>
parents:
18221
diff
changeset
|
40 @SuppressWarnings("unused") |
eecda5abf627
Truffle-DSL: simplify bad overflow test. The issue is fixed by the new generated node layout. (GRAAL-885 #resolve)
Christian Humer <christian.humer@gmail.com>
parents:
18221
diff
changeset
|
41 abstract static class ImplicitCastExclusion extends ValueNode { |
eecda5abf627
Truffle-DSL: simplify bad overflow test. The issue is fixed by the new generated node layout. (GRAAL-885 #resolve)
Christian Humer <christian.humer@gmail.com>
parents:
18221
diff
changeset
|
42 |
eecda5abf627
Truffle-DSL: simplify bad overflow test. The issue is fixed by the new generated node layout. (GRAAL-885 #resolve)
Christian Humer <christian.humer@gmail.com>
parents:
18221
diff
changeset
|
43 @Specialization(rewriteOn = RuntimeException.class) |
eecda5abf627
Truffle-DSL: simplify bad overflow test. The issue is fixed by the new generated node layout. (GRAAL-885 #resolve)
Christian Humer <christian.humer@gmail.com>
parents:
18221
diff
changeset
|
44 String f1(long a) { |
eecda5abf627
Truffle-DSL: simplify bad overflow test. The issue is fixed by the new generated node layout. (GRAAL-885 #resolve)
Christian Humer <christian.humer@gmail.com>
parents:
18221
diff
changeset
|
45 return "triggered1"; |
18221
2c68474cc893
Truffle: add a test to track an ImplicitCast bug
Benoit Daloze <benoit.daloze@jku.at>
parents:
diff
changeset
|
46 } |
2c68474cc893
Truffle: add a test to track an ImplicitCast bug
Benoit Daloze <benoit.daloze@jku.at>
parents:
diff
changeset
|
47 |
2c68474cc893
Truffle: add a test to track an ImplicitCast bug
Benoit Daloze <benoit.daloze@jku.at>
parents:
diff
changeset
|
48 @Specialization |
18786
eecda5abf627
Truffle-DSL: simplify bad overflow test. The issue is fixed by the new generated node layout. (GRAAL-885 #resolve)
Christian Humer <christian.humer@gmail.com>
parents:
18221
diff
changeset
|
49 String f2(long a) { |
eecda5abf627
Truffle-DSL: simplify bad overflow test. The issue is fixed by the new generated node layout. (GRAAL-885 #resolve)
Christian Humer <christian.humer@gmail.com>
parents:
18221
diff
changeset
|
50 return "triggered2"; |
18221
2c68474cc893
Truffle: add a test to track an ImplicitCast bug
Benoit Daloze <benoit.daloze@jku.at>
parents:
diff
changeset
|
51 } |
2c68474cc893
Truffle: add a test to track an ImplicitCast bug
Benoit Daloze <benoit.daloze@jku.at>
parents:
diff
changeset
|
52 } |
2c68474cc893
Truffle: add a test to track an ImplicitCast bug
Benoit Daloze <benoit.daloze@jku.at>
parents:
diff
changeset
|
53 |
2c68474cc893
Truffle: add a test to track an ImplicitCast bug
Benoit Daloze <benoit.daloze@jku.at>
parents:
diff
changeset
|
54 @Test |
2c68474cc893
Truffle: add a test to track an ImplicitCast bug
Benoit Daloze <benoit.daloze@jku.at>
parents:
diff
changeset
|
55 public void testAdd() { |
18786
eecda5abf627
Truffle-DSL: simplify bad overflow test. The issue is fixed by the new generated node layout. (GRAAL-885 #resolve)
Christian Humer <christian.humer@gmail.com>
parents:
18221
diff
changeset
|
56 TestRootNode<ImplicitCastExclusion> node = createRoot(ImplicitCastExclusionFactory.getInstance()); |
eecda5abf627
Truffle-DSL: simplify bad overflow test. The issue is fixed by the new generated node layout. (GRAAL-885 #resolve)
Christian Humer <christian.humer@gmail.com>
parents:
18221
diff
changeset
|
57 assertEquals("triggered1", executeWith(node, -1)); |
eecda5abf627
Truffle-DSL: simplify bad overflow test. The issue is fixed by the new generated node layout. (GRAAL-885 #resolve)
Christian Humer <christian.humer@gmail.com>
parents:
18221
diff
changeset
|
58 assertEquals("triggered1", executeWith(node, 5000L)); |
18221
2c68474cc893
Truffle: add a test to track an ImplicitCast bug
Benoit Daloze <benoit.daloze@jku.at>
parents:
diff
changeset
|
59 } |
2c68474cc893
Truffle: add a test to track an ImplicitCast bug
Benoit Daloze <benoit.daloze@jku.at>
parents:
diff
changeset
|
60 } |