Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
PojavLauncherTeam
GitHub Repository: PojavLauncherTeam/mobile
Path: blob/master/test/hotspot/jtreg/vmTestbase/jit/CondExpr/CondExpr.java
40948 views
1
/*
2
* Copyright (c) 2008, 2020, 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
// test the conditional expressions
24
25
26
/*
27
* @test
28
*
29
* @summary converted from VM Testbase jit/CondExpr.
30
* VM Testbase keywords: [jit, quick]
31
*
32
* @library /vmTestbase
33
* /test/lib
34
* @run main/othervm jit.CondExpr.CondExpr
35
*/
36
37
package jit.CondExpr;
38
39
import nsk.share.TestFailure;
40
41
public class CondExpr {
42
43
public static void trace (String s, int res) {
44
System.out.println("test result for " + s + " is " + res);
45
}
46
47
public static int test_int1(int arg) { return (arg==10) ? 1 : 2; }
48
49
public static int test_int(int arg) { return test_int1(arg) + test_int1(arg+1); }
50
51
public static long test_long1(long arg) { return (arg==10) ? 1l : 2l; }
52
53
public static int test_long(long arg) { return (int)(test_long1(arg) + test_long1(arg+1)); }
54
55
public static float test_float1(float arg) { return (arg==10.0f) ? 1.0f : 2.0f; }
56
57
public static int test_float(float arg) { return (int)(test_float1(arg) + test_float1(arg+1)); }
58
59
public static double test_double1(double arg) { return (arg==10.0) ? 1.0 : 2.0; }
60
61
public static int test_double(double arg) { return (int)(test_double1(arg) + test_double1(arg+1)); }
62
63
64
public static int nested_test_int1(int arg) {
65
return (arg>1) ? ((arg==10) ? 1 : 2) : ((arg==-10) ? 3: 4);
66
}
67
68
69
70
public static int nested_test_int (int arg) {
71
return (nested_test_int1 (arg) + nested_test_int1 (arg+1) + nested_test_int1 (-arg) + nested_test_int1 (-arg-1)); }
72
73
public static void main(String s[]) {
74
System.out.println ("Testing conditional expressions (srm 10/22)");
75
boolean correct = true;
76
int res = 0;
77
res = test_int(10); trace("test_int", res);
78
correct = correct & ( res == 3);
79
res = test_long(10l); trace("test_long", res);
80
correct = correct & ( res == 3);
81
res = test_float(10.0f); trace("test_float", res);
82
correct = correct & ( res == 3);
83
res = test_double(10.0); trace("test_double", res);
84
correct = correct & ( res == 3);
85
86
res = nested_test_int(10); trace("nested_test_int", res);
87
correct = correct & ( res == 10);
88
89
if (correct) System.out.println("Correct!");
90
else throw new TestFailure("ERRROR in conditional expressions");
91
}
92
}
93
94