Mercurial > hg > graal-jvmci-8
annotate graal/com.oracle.truffle.sl.test/src/com/oracle/truffle/sl/test/TernaryTest.java @ 13166:107fee7fa3bb
replace code handling abstract (non-array) types in type profiles with assertions now that it should never occur
author | Doug Simon <doug.simon@oracle.com> |
---|---|
date | Tue, 26 Nov 2013 00:09:17 +0100 |
parents | 71991b7a0f14 |
children |
rev | line source |
---|---|
7848
698cd036a1ca
Added a ternary operator to simple language to test short circuit specialization.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
1 /* |
698cd036a1ca
Added a ternary operator to simple language to test short circuit specialization.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
2 * Copyright (c) 2012, 2012, Oracle and/or its affiliates. All rights reserved. |
698cd036a1ca
Added a ternary operator to simple language to test short circuit specialization.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
698cd036a1ca
Added a ternary operator to simple language to test short circuit specialization.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
4 * |
698cd036a1ca
Added a ternary operator to simple language to test short circuit specialization.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
5 * This code is free software; you can redistribute it and/or modify it |
698cd036a1ca
Added a ternary operator to simple language to test short circuit specialization.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
6 * under the terms of the GNU General Public License version 2 only, as |
698cd036a1ca
Added a ternary operator to simple language to test short circuit specialization.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
7 * published by the Free Software Foundation. |
698cd036a1ca
Added a ternary operator to simple language to test short circuit specialization.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
8 * |
698cd036a1ca
Added a ternary operator to simple language to test short circuit specialization.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
9 * This code is distributed in the hope that it will be useful, but WITHOUT |
698cd036a1ca
Added a ternary operator to simple language to test short circuit specialization.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
698cd036a1ca
Added a ternary operator to simple language to test short circuit specialization.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
698cd036a1ca
Added a ternary operator to simple language to test short circuit specialization.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
12 * version 2 for more details (a copy is included in the LICENSE file that |
698cd036a1ca
Added a ternary operator to simple language to test short circuit specialization.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
13 * accompanied this code). |
698cd036a1ca
Added a ternary operator to simple language to test short circuit specialization.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
14 * |
698cd036a1ca
Added a ternary operator to simple language to test short circuit specialization.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
15 * You should have received a copy of the GNU General Public License version |
698cd036a1ca
Added a ternary operator to simple language to test short circuit specialization.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
16 * 2 along with this work; if not, write to the Free Software Foundation, |
698cd036a1ca
Added a ternary operator to simple language to test short circuit specialization.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
698cd036a1ca
Added a ternary operator to simple language to test short circuit specialization.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
18 * |
698cd036a1ca
Added a ternary operator to simple language to test short circuit specialization.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
698cd036a1ca
Added a ternary operator to simple language to test short circuit specialization.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
20 * or visit www.oracle.com if you need additional information or have any |
698cd036a1ca
Added a ternary operator to simple language to test short circuit specialization.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
21 * questions. |
698cd036a1ca
Added a ternary operator to simple language to test short circuit specialization.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
22 */ |
698cd036a1ca
Added a ternary operator to simple language to test short circuit specialization.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
23 package com.oracle.truffle.sl.test; |
698cd036a1ca
Added a ternary operator to simple language to test short circuit specialization.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
24 |
698cd036a1ca
Added a ternary operator to simple language to test short circuit specialization.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
25 import org.junit.*; |
698cd036a1ca
Added a ternary operator to simple language to test short circuit specialization.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
26 |
698cd036a1ca
Added a ternary operator to simple language to test short circuit specialization.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
27 // @formatter:off |
698cd036a1ca
Added a ternary operator to simple language to test short circuit specialization.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
28 public class TernaryTest extends AbstractTest { |
698cd036a1ca
Added a ternary operator to simple language to test short circuit specialization.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
29 |
698cd036a1ca
Added a ternary operator to simple language to test short circuit specialization.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
30 private static String[] INPUT = new String[] { |
9258
07f8d136a05e
Truffle API changes for the Frame API. Introduction of Assumptions class.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
8463
diff
changeset
|
31 "function main { " + |
12752
71991b7a0f14
SL: Enhanced SimpleLanguage with support for if statements, function calls, function caching + inlining and builtins.
Christian Humer <christian.humer@gmail.com>
parents:
9258
diff
changeset
|
32 " print(#(1 < 2) ? 1 : 2);" + |
71991b7a0f14
SL: Enhanced SimpleLanguage with support for if statements, function calls, function caching + inlining and builtins.
Christian Humer <christian.humer@gmail.com>
parents:
9258
diff
changeset
|
33 " print(#(2 < 1) ? 100000000000000 : 1); ", |
71991b7a0f14
SL: Enhanced SimpleLanguage with support for if statements, function calls, function caching + inlining and builtins.
Christian Humer <christian.humer@gmail.com>
parents:
9258
diff
changeset
|
34 " print(#(1 < 2) ? 100000000000000 : 1); ", |
71991b7a0f14
SL: Enhanced SimpleLanguage with support for if statements, function calls, function caching + inlining and builtins.
Christian Humer <christian.humer@gmail.com>
parents:
9258
diff
changeset
|
35 " print(#(2 < 1) ? \"wrong\" : \"true\");", |
71991b7a0f14
SL: Enhanced SimpleLanguage with support for if statements, function calls, function caching + inlining and builtins.
Christian Humer <christian.humer@gmail.com>
parents:
9258
diff
changeset
|
36 " print(#(2 < 1) ? \"wrong\" : 1);", |
9258
07f8d136a05e
Truffle API changes for the Frame API. Introduction of Assumptions class.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
8463
diff
changeset
|
37 "} ", |
7848
698cd036a1ca
Added a ternary operator to simple language to test short circuit specialization.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
38 }; |
698cd036a1ca
Added a ternary operator to simple language to test short circuit specialization.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
39 |
698cd036a1ca
Added a ternary operator to simple language to test short circuit specialization.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
40 private static String[] OUTPUT = new String[] { |
698cd036a1ca
Added a ternary operator to simple language to test short circuit specialization.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
41 "1", |
698cd036a1ca
Added a ternary operator to simple language to test short circuit specialization.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
42 "1", |
698cd036a1ca
Added a ternary operator to simple language to test short circuit specialization.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
43 "100000000000000", |
698cd036a1ca
Added a ternary operator to simple language to test short circuit specialization.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
44 "true", |
698cd036a1ca
Added a ternary operator to simple language to test short circuit specialization.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
45 "1", |
698cd036a1ca
Added a ternary operator to simple language to test short circuit specialization.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
46 }; |
698cd036a1ca
Added a ternary operator to simple language to test short circuit specialization.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
47 |
698cd036a1ca
Added a ternary operator to simple language to test short circuit specialization.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
48 @Test |
698cd036a1ca
Added a ternary operator to simple language to test short circuit specialization.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
49 public void test() { |
8463
b2161263e9f2
Cleanup unit tests : they should not print to stdout/stderr
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
7848
diff
changeset
|
50 executeSL(INPUT, OUTPUT, false); |
7848
698cd036a1ca
Added a ternary operator to simple language to test short circuit specialization.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
51 } |
698cd036a1ca
Added a ternary operator to simple language to test short circuit specialization.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
52 } |