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