Mercurial > hg > truffle
comparison graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/micro/BigShortParams01.java @ 5061:e808627bd16f
Renamed projects.
author | Thomas Wuerthinger <thomas.wuerthinger@oracle.com> |
---|---|
date | Thu, 08 Mar 2012 19:24:17 +0100 |
parents | graal/com.oracle.max.graal.jtt/src/com/oracle/graal/jtt/micro/BigShortParams01.java@4ed4295ce15f |
children | 390448a6b535 |
comparison
equal
deleted
inserted
replaced
5060:4ed4295ce15f | 5061:e808627bd16f |
---|---|
1 /* | |
2 * Copyright (c) 2009, 2012, 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.graal.jtt.micro; | |
24 | |
25 import org.junit.*; | |
26 | |
27 /* | |
28 */ | |
29 public class BigShortParams01 { | |
30 | |
31 public static int test(int num) { | |
32 int sum = 0; | |
33 if (num == 0) { | |
34 sum += testA((short) 0, (short) 1, (short) 2, (short) 3, (short) 4, (short) 5, (short) 6, (short) 7, (short) 8, (short) 9); | |
35 sum += testA((short) 1, (short) 1, (short) 2, (short) 3, (short) 4, (short) 5, (short) 6, (short) 7, (short) 8, (short) 9); | |
36 sum += testA((short) 2, (short) 1, (short) 2, (short) 3, (short) 4, (short) 5, (short) 6, (short) 7, (short) 8, (short) 9); | |
37 sum += testA((short) 3, (short) 1, (short) 2, (short) 3, (short) 4, (short) 5, (short) 6, (short) 7, (short) 8, (short) 9); | |
38 sum += testA((short) 4, (short) 1, (short) 2, (short) 3, (short) 4, (short) 5, (short) 6, (short) 7, (short) 8, (short) 9); | |
39 sum += testA((short) 5, (short) 1, (short) 2, (short) 3, (short) 4, (short) 5, (short) 6, (short) 7, (short) 8, (short) 9); | |
40 sum += testA((short) 6, (short) 1, (short) 2, (short) 3, (short) 4, (short) 5, (short) 6, (short) 7, (short) 8, (short) 9); | |
41 sum += testA((short) 7, (short) 1, (short) 2, (short) 3, (short) 4, (short) 5, (short) 6, (short) 7, (short) 8, (short) 9); | |
42 sum += testA((short) 8, (short) 1, (short) 2, (short) 3, (short) 4, (short) 5, (short) 6, (short) 7, (short) 8, (short) 9); | |
43 } else if (num == 1) { | |
44 sum += testB(0, (short) 1, (short) 2, (short) 3, (short) 4, (short) 5, (short) 6, (short) 7, (short) 8, (short) 9); | |
45 sum += testB(1, (short) 1, (short) 2, (short) 3, (short) 4, (short) 5, (short) 6, (short) 7, (short) 8, (short) 9); | |
46 sum += testB(2, (short) 1, (short) 2, (short) 3, (short) 4, (short) 5, (short) 6, (short) 7, (short) 8, (short) 9); | |
47 sum += testB(3, (short) 1, (short) 2, (short) 3, (short) 4, (short) 5, (short) 6, (short) 7, (short) 8, (short) 9); | |
48 sum += testB(4, (short) 1, (short) 2, (short) 3, (short) 4, (short) 5, (short) 6, (short) 7, (short) 8, (short) 9); | |
49 sum += testB(5, (short) 1, (short) 2, (short) 3, (short) 4, (short) 5, (short) 6, (short) 7, (short) 8, (short) 9); | |
50 sum += testB(6, (short) 1, (short) 2, (short) 3, (short) 4, (short) 5, (short) 6, (short) 7, (short) 8, (short) 9); | |
51 sum += testB(7, (short) 1, (short) 2, (short) 3, (short) 4, (short) 5, (short) 6, (short) 7, (short) 8, (short) 9); | |
52 sum += testB(8, (short) 1, (short) 2, (short) 3, (short) 4, (short) 5, (short) 6, (short) 7, (short) 8, (short) 9); | |
53 } else if (num == 2) { | |
54 for (int i = 0; i < 9; i++) { | |
55 sum += testA(i, (short) 1, (short) 2, (short) 3, (short) 4, (short) 5, (short) 6, (short) 7, (short) 8, (short) 9); | |
56 } | |
57 } else if (num == 3) { | |
58 for (int i = 0; i < 9; i++) { | |
59 sum += testB(i, (short) 1, (short) 2, (short) 3, (short) 4, (short) 5, (short) 6, (short) 7, (short) 8, (short) 9); | |
60 } | |
61 } | |
62 return sum; | |
63 } | |
64 | |
65 private static int testA(int choice, short p0, short p1, short p2, short p3, short p4, short p5, short p6, short p7, short p8) { | |
66 switch (choice) { | |
67 case 0: | |
68 return p0; | |
69 case 1: | |
70 return p1; | |
71 case 2: | |
72 return p2; | |
73 case 3: | |
74 return p3; | |
75 case 4: | |
76 return p4; | |
77 case 5: | |
78 return p5; | |
79 case 6: | |
80 return p6; | |
81 case 7: | |
82 return p7; | |
83 case 8: | |
84 return p8; | |
85 } | |
86 return 42; | |
87 } | |
88 | |
89 private static long testB(int choice, long p0, long p1, long p2, long p3, long p4, long p5, long p6, long p7, long p8) { | |
90 switch (choice) { | |
91 case 0: | |
92 return p0; | |
93 case 1: | |
94 return p1; | |
95 case 2: | |
96 return p2; | |
97 case 3: | |
98 return p3; | |
99 case 4: | |
100 return p4; | |
101 case 5: | |
102 return p5; | |
103 case 6: | |
104 return p6; | |
105 case 7: | |
106 return p7; | |
107 case 8: | |
108 return p8; | |
109 } | |
110 return 42; | |
111 } | |
112 | |
113 @Test | |
114 public void run0() throws Throwable { | |
115 Assert.assertEquals(45, test(0)); | |
116 } | |
117 | |
118 @Test | |
119 public void run1() throws Throwable { | |
120 Assert.assertEquals(45, test(1)); | |
121 } | |
122 | |
123 @Test | |
124 public void run2() throws Throwable { | |
125 Assert.assertEquals(45, test(2)); | |
126 } | |
127 | |
128 @Test | |
129 public void run3() throws Throwable { | |
130 Assert.assertEquals(45, test(3)); | |
131 } | |
132 | |
133 @Test | |
134 public void run4() throws Throwable { | |
135 Assert.assertEquals(0, test(4)); | |
136 } | |
137 | |
138 } |