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