1/* 2 * Copyright (c) 2007, 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 */ 23package org.graalvm.compiler.jtt.micro; 24 25import org.junit.Test; 26 27import org.graalvm.compiler.jtt.JTTTest; 28 29/* 30 */ 31public class BigIntParams01 extends JTTTest { 32 33 public static int test(int num) { 34 int sum = 0; 35 if (num == 0) { 36 sum += testA(0, 1, 2, 3, 4, 5, 6, 7, 8, 9); 37 sum += testA(1, 1, 2, 3, 4, 5, 6, 7, 8, 9); 38 sum += testA(2, 1, 2, 3, 4, 5, 6, 7, 8, 9); 39 sum += testA(3, 1, 2, 3, 4, 5, 6, 7, 8, 9); 40 sum += testA(4, 1, 2, 3, 4, 5, 6, 7, 8, 9); 41 sum += testA(5, 1, 2, 3, 4, 5, 6, 7, 8, 9); 42 sum += testA(6, 1, 2, 3, 4, 5, 6, 7, 8, 9); 43 sum += testA(7, 1, 2, 3, 4, 5, 6, 7, 8, 9); 44 sum += testA(8, 1, 2, 3, 4, 5, 6, 7, 8, 9); 45 } else if (num == 1) { 46 sum += testB(0, 1, 2, 3, 4, 5, 6, 7, 8, 9); 47 sum += testB(1, 1, 2, 3, 4, 5, 6, 7, 8, 9); 48 sum += testB(2, 1, 2, 3, 4, 5, 6, 7, 8, 9); 49 sum += testB(3, 1, 2, 3, 4, 5, 6, 7, 8, 9); 50 sum += testB(4, 1, 2, 3, 4, 5, 6, 7, 8, 9); 51 sum += testB(5, 1, 2, 3, 4, 5, 6, 7, 8, 9); 52 sum += testB(6, 1, 2, 3, 4, 5, 6, 7, 8, 9); 53 sum += testB(7, 1, 2, 3, 4, 5, 6, 7, 8, 9); 54 sum += testB(8, 1, 2, 3, 4, 5, 6, 7, 8, 9); 55 } else if (num == 2) { 56 for (int i = 0; i < 9; i++) { 57 sum += testA(i, 1, 2, 3, 4, 5, 6, 7, 8, 9); 58 } 59 } else if (num == 3) { 60 for (int i = 0; i < 9; i++) { 61 sum += testB(i, 1, 2, 3, 4, 5, 6, 7, 8, 9); 62 } 63 } 64 return sum; 65 } 66 67 private static int testA(int choice, int p0, int p1, int p2, int p3, int p4, int p5, int p6, int p7, int p8) { 68 switch (choice) { 69 case 0: 70 return p0; 71 case 1: 72 return p1; 73 case 2: 74 return p2; 75 case 3: 76 return p3; 77 case 4: 78 return p4; 79 case 5: 80 return p5; 81 case 6: 82 return p6; 83 case 7: 84 return p7; 85 case 8: 86 return p8; 87 } 88 return 42; 89 } 90 91 private static long testB(int choice, long p0, long p1, long p2, long p3, long p4, long p5, long p6, long p7, long p8) { 92 switch (choice) { 93 case 0: 94 return p0; 95 case 1: 96 return p1; 97 case 2: 98 return p2; 99 case 3: 100 return p3; 101 case 4: 102 return p4; 103 case 5: 104 return p5; 105 case 6: 106 return p6; 107 case 7: 108 return p7; 109 case 8: 110 return p8; 111 } 112 return 42; 113 } 114 115 @Test 116 public void run0() throws Throwable { 117 runTest("test", 0); 118 } 119 120 @Test 121 public void run1() throws Throwable { 122 runTest("test", 1); 123 } 124 125 @Test 126 public void run2() throws Throwable { 127 runTest("test", 2); 128 } 129 130 @Test 131 public void run3() throws Throwable { 132 runTest("test", 3); 133 } 134 135 @Test 136 public void run4() throws Throwable { 137 runTest("test", 4); 138 } 139 140} 141