Mercurial > hg > graal-jvmci-8
annotate graal/com.oracle.truffle.sl.test/src/com/oracle/truffle/sl/test/TernaryTest.java @ 7848:698cd036a1ca
Added a ternary operator to simple language to test short circuit specialization.
author | Christian Humer <christian.humer@gmail.com> |
---|---|
date | Tue, 19 Feb 2013 17:27:02 +0100 |
parents | |
children | b2161263e9f2 |
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[] { |
698cd036a1ca
Added a ternary operator to simple language to test short circuit specialization.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
31 "function main { " + |
698cd036a1ca
Added a ternary operator to simple language to test short circuit specialization.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
32 " print #(1 < 2) ? 1 : 2;" + |
698cd036a1ca
Added a ternary operator to simple language to test short circuit specialization.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
33 " print #(2 < 1) ? 100000000000000 : 1; ", |
698cd036a1ca
Added a ternary operator to simple language to test short circuit specialization.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
34 " print #(1 < 2) ? 100000000000000 : 1; ", |
698cd036a1ca
Added a ternary operator to simple language to test short circuit specialization.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
35 " print #(2 < 1) ? \"wrong\" : \"true\";", |
698cd036a1ca
Added a ternary operator to simple language to test short circuit specialization.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
36 " print #(2 < 1) ? \"wrong\" : 1;", |
698cd036a1ca
Added a ternary operator to simple language to test short circuit specialization.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
37 "} ", |
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() { |
698cd036a1ca
Added a ternary operator to simple language to test short circuit specialization.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
50 executeSL(INPUT, OUTPUT, true); |
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 } |