001/*
002 * Copyright (c) 2007, 2012, Oracle and/or its affiliates. All rights reserved.
003 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
004 *
005 * This code is free software; you can redistribute it and/or modify it
006 * under the terms of the GNU General Public License version 2 only, as
007 * published by the Free Software Foundation.
008 *
009 * This code is distributed in the hope that it will be useful, but WITHOUT
010 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
011 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
012 * version 2 for more details (a copy is included in the LICENSE file that
013 * accompanied this code).
014 *
015 * You should have received a copy of the GNU General Public License version
016 * 2 along with this work; if not, write to the Free Software Foundation,
017 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
018 *
019 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
020 * or visit www.oracle.com if you need additional information or have any
021 * questions.
022 */
023package com.oracle.graal.jtt.micro;
024
025import org.junit.*;
026
027import com.oracle.graal.jtt.*;
028
029/*
030 */
031public class BigFloatParams01 extends JTTTest {
032
033    public static double test(int num) {
034        double sum = 0;
035        if (num == 0) {
036            sum += testA(0, 1, 2, 3, 4, 5, 6, 7, 8, 9);
037            sum += testA(1, 1, 2, 3, 4, 5, 6, 7, 8, 9);
038            sum += testA(2, 1, 2, 3, 4, 5, 6, 7, 8, 9);
039            sum += testA(3, 1, 2, 3, 4, 5, 6, 7, 8, 9);
040            sum += testA(4, 1, 2, 3, 4, 5, 6, 7, 8, 9);
041            sum += testA(5, 1, 2, 3, 4, 5, 6, 7, 8, 9);
042            sum += testA(6, 1, 2, 3, 4, 5, 6, 7, 8, 9);
043            sum += testA(7, 1, 2, 3, 4, 5, 6, 7, 8, 9);
044            sum += testA(8, 1, 2, 3, 4, 5, 6, 7, 8, 9);
045        } else if (num == 1) {
046            sum += testB(0, 1, 2, 3, 4, 5, 6, 7, 8, 9);
047            sum += testB(1, 1, 2, 3, 4, 5, 6, 7, 8, 9);
048            sum += testB(2, 1, 2, 3, 4, 5, 6, 7, 8, 9);
049            sum += testB(3, 1, 2, 3, 4, 5, 6, 7, 8, 9);
050            sum += testB(4, 1, 2, 3, 4, 5, 6, 7, 8, 9);
051            sum += testB(5, 1, 2, 3, 4, 5, 6, 7, 8, 9);
052            sum += testB(6, 1, 2, 3, 4, 5, 6, 7, 8, 9);
053            sum += testB(7, 1, 2, 3, 4, 5, 6, 7, 8, 9);
054            sum += testB(8, 1, 2, 3, 4, 5, 6, 7, 8, 9);
055        } else if (num == 2) {
056            for (int i = 0; i < 9; i++) {
057                sum += testA(i, 1, 2, 3, 4, 5, 6, 7, 8, 9);
058            }
059        } else if (num == 3) {
060            for (int i = 0; i < 9; i++) {
061                sum += testB(i, 1, 2, 3, 4, 5, 6, 7, 8, 9);
062            }
063        }
064        return sum;
065    }
066
067    private static float testA(int choice, float p0, float p1, float p2, float p3, float p4, float p5, float p6, float p7, float p8) {
068        switch (choice) {
069            case 0:
070                return p0;
071            case 1:
072                return p1;
073            case 2:
074                return p2;
075            case 3:
076                return p3;
077            case 4:
078                return p4;
079            case 5:
080                return p5;
081            case 6:
082                return p6;
083            case 7:
084                return p7;
085            case 8:
086                return p8;
087        }
088        return 42;
089    }
090
091    private static double testB(int choice, double p0, double p1, double p2, double p3, double p4, double p5, double p6, double p7, double p8) {
092        switch (choice) {
093            case 0:
094                return p0;
095            case 1:
096                return p1;
097            case 2:
098                return p2;
099            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}