001/*
002 * Copyright (c) 2009, 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.optimize;
024
025import org.junit.*;
026
027import com.oracle.graal.jtt.*;
028
029/*
030 */
031public class Fold_Math01 extends JTTTest {
032
033    public static double test(int arg) {
034        switch (arg) {
035            case 0:
036                return abs();
037            case 1:
038                return sin();
039            case 2:
040                return cos();
041            case 3:
042                return tan();
043            case 4:
044                return atan2();
045            case 5:
046                return sqrt();
047            case 6:
048                return log();
049            case 7:
050                return log10();
051            case 8:
052                return pow();
053            case 9:
054                return exp();
055            case 10:
056                return min();
057            case 11:
058                return max();
059        }
060        return 42;
061    }
062
063    private static double abs() {
064        return Math.abs(-10.0d);
065    }
066
067    private static double sin() {
068        return Math.sin(0.15d);
069    }
070
071    private static double cos() {
072        return Math.cos(0.15d);
073    }
074
075    private static double tan() {
076        return Math.tan(0.15d);
077    }
078
079    private static double atan2() {
080        return Math.atan2(0.15d, 3.1d);
081    }
082
083    private static double sqrt() {
084        return Math.sqrt(144d);
085    }
086
087    private static double log() {
088        return Math.log(3.15d);
089    }
090
091    private static double log10() {
092        return Math.log10(0.15d);
093    }
094
095    private static double pow() {
096        return Math.pow(2.15d, 6.1d);
097    }
098
099    private static double exp() {
100        return Math.log(3.15d);
101    }
102
103    private static int min() {
104        return Math.min(2, -1);
105    }
106
107    private static int max() {
108        return Math.max(2, -1);
109    }
110
111    @Test
112    public void run0() throws Throwable {
113        runTest("test", 0);
114    }
115
116    @Test
117    public void run1() throws Throwable {
118        runTest("test", 1);
119    }
120
121    @Test
122    public void run2() throws Throwable {
123        runTest("test", 2);
124    }
125
126    @Test
127    public void run3() throws Throwable {
128        runTest("test", 3);
129    }
130
131    @Test
132    public void run4() throws Throwable {
133        runTest("test", 4);
134    }
135
136    @Test
137    public void run5() throws Throwable {
138        runTest("test", 5);
139    }
140
141    @Test
142    public void run6() throws Throwable {
143        runTest("test", 6);
144    }
145
146    @Test
147    public void run7() throws Throwable {
148        runTest("test", 7);
149    }
150
151    @Test
152    public void run8() throws Throwable {
153        runTest("test", 8);
154    }
155
156    @Test
157    public void run9() throws Throwable {
158        runTest("test", 9);
159    }
160
161    @Test
162    public void run10() throws Throwable {
163        runTest("test", 10);
164    }
165
166    @Test
167    public void run11() throws Throwable {
168        runTest("test", 11);
169    }
170
171    @Test
172    public void run12() throws Throwable {
173        runTest("test", 12);
174    }
175
176}