blob: d8d6fac306db49f88bc58acde271a07b6efc1e3c [file] [log] [blame]
Nicolas Geoffray7fb49da2014-10-06 09:12:41 +01001/*
2 * Copyright (C) 2014 The Android Open Source Project
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17public class Main {
18 public static void main(String[] args) {
19 assertEquals(4.2f, returnFloat());
20 float[] a = new float[1];
21 a[0] = 42.2f;
22 assertEquals(42.2f, returnFloat(a));
23
24 assertEquals(4.4, returnDouble());
25 double[] b = new double[1];
26 b[0] = 42.4;
27 assertEquals(42.4, returnDouble(b));
28
29 assertEquals(4.2f, invokeReturnFloat());
30 assertEquals(4.4, invokeReturnDouble());
31 assertEquals(4.2f, takeAFloat(4.2f));
32 assertEquals(3.1, takeADouble(3.1));
33 assertEquals(12.7, takeThreeDouble(3.1, 4.4, 5.2));
34 assertEquals(12.7f, takeThreeFloat(3.1f, 4.4f, 5.2f));
35 assertEquals(4.2f, invokeTakeAFloat(4.2f));
36 assertEquals(3.1, invokeTakeADouble(3.1));
37 assertEquals(12.7, invokeTakeThreeDouble(3.1, 4.4, 5.2));
38 assertEquals(12.7f, invokeTakeThreeFloat(3.1f, 4.4f, 5.2f));
39 }
40
41 public static float invokeReturnFloat() {
42 return returnFloat();
43 }
44
45 public static double invokeReturnDouble() {
46 return returnDouble();
47 }
48
49 public static float returnFloat() {
50 return 4.2f;
51 }
52
53 public static float returnFloat(float[] a) {
54 return a[0];
55 }
56
57 public static double returnDouble() {
58 return 4.4;
59 }
60
61 public static double returnDouble(double[] a) {
62 return a[0];
63 }
64
65 public static float takeAFloat(float a) {
66 return a;
67 }
68
69 public static double takeADouble(double a) {
70 return a;
71 }
72
73 public static double takeThreeDouble(double a, double b, double c) {
74 return a + b + c;
75 }
76
77 public static float takeThreeFloat(float a, float b, float c) {
78 return a + b + c;
79 }
80
81 public static float invokeTakeAFloat(float a) {
82 return takeAFloat(a);
83 }
84
85 public static double invokeTakeADouble(double a) {
86 return takeADouble(a);
87 }
88
89 public static double invokeTakeThreeDouble(double a, double b, double c) {
90 return takeThreeDouble(a, b, c);
91 }
92
93 public static float invokeTakeThreeFloat(float a, float b, float c) {
94 return takeThreeFloat(a, b, c);
95 }
96
97 public static void assertEquals(float expected, float actual) {
98 if (expected != actual) {
99 throw new AssertionError("Expected " + expected + " got " + actual);
100 }
101 }
102
103 public static void assertEquals(double expected, double actual) {
104 if (expected != actual) {
105 throw new AssertionError("Expected " + expected + " got " + actual);
106 }
107 }
108}