Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
PojavLauncherTeam
GitHub Repository: PojavLauncherTeam/mobile
Path: blob/master/test/jdk/java/lang/String/concat/ImplicitStringConcatBoundaries.java
41153 views
1
/*
2
* Copyright (c) 2015, 2016, 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
/**
25
* @test
26
* @summary Test the boundary values for concatenation arguments.
27
*
28
* @compile ImplicitStringConcatBoundaries.java
29
* @run main/othervm -Xverify:all ImplicitStringConcatBoundaries
30
*
31
* @compile -XDstringConcat=inline ImplicitStringConcatBoundaries.java
32
* @run main/othervm -Xverify:all ImplicitStringConcatBoundaries
33
*
34
* @compile -XDstringConcat=indy ImplicitStringConcatBoundaries.java
35
* @run main/othervm -Xverify:all ImplicitStringConcatBoundaries
36
*
37
* @compile -XDstringConcat=indyWithConstants ImplicitStringConcatBoundaries.java
38
* @run main/othervm -Xverify:all ImplicitStringConcatBoundaries
39
*/
40
41
public class ImplicitStringConcatBoundaries {
42
43
public static final boolean BOOL_TRUE_1 = true;
44
public static boolean BOOL_TRUE_2 = true;
45
public static final boolean BOOL_FALSE_1 = false;
46
public static boolean BOOL_FALSE_2 = false;
47
48
public static final byte BYTE_MIN_1 = Byte.MIN_VALUE;
49
public static byte BYTE_MIN_2 = Byte.MIN_VALUE;
50
public static final byte BYTE_MAX_1 = Byte.MAX_VALUE;
51
public static byte BYTE_MAX_2 = Byte.MAX_VALUE;
52
53
public static final short SHORT_MIN_1 = Short.MIN_VALUE;
54
public static short SHORT_MIN_2 = Short.MIN_VALUE;
55
public static final short SHORT_MAX_1 = Short.MAX_VALUE;
56
public static short SHORT_MAX_2 = Short.MAX_VALUE;
57
58
public static final char CHAR_MIN_1 = Character.MIN_VALUE;
59
public static char CHAR_MIN_2 = Character.MIN_VALUE;
60
public static final char CHAR_MAX_1 = Character.MAX_VALUE;
61
public static char CHAR_MAX_2 = Character.MAX_VALUE;
62
63
public static final int INT_MIN_1 = Integer.MIN_VALUE;
64
public static int INT_MIN_2 = Integer.MIN_VALUE;
65
public static final int INT_MAX_1 = Integer.MAX_VALUE;
66
public static int INT_MAX_2 = Integer.MAX_VALUE;
67
68
public static final float FLOAT_MIN_EXP_1 = Float.MIN_EXPONENT;
69
public static float FLOAT_MIN_EXP_2 = Float.MIN_EXPONENT;
70
public static final float FLOAT_MIN_NORM_1 = Float.MIN_NORMAL;
71
public static float FLOAT_MIN_NORM_2 = Float.MIN_NORMAL;
72
public static final float FLOAT_MIN_1 = Float.MIN_VALUE;
73
public static float FLOAT_MIN_2 = Float.MIN_VALUE;
74
public static final float FLOAT_MAX_1 = Float.MAX_VALUE;
75
public static float FLOAT_MAX_2 = Float.MAX_VALUE;
76
77
public static final long LONG_MIN_1 = Long.MIN_VALUE;
78
public static long LONG_MIN_2 = Long.MIN_VALUE;
79
public static final long LONG_MAX_1 = Long.MAX_VALUE;
80
public static long LONG_MAX_2 = Long.MAX_VALUE;
81
82
public static final double DOUBLE_MIN_EXP_1 = Double.MIN_EXPONENT;
83
public static double DOUBLE_MIN_EXP_2 = Double.MIN_EXPONENT;
84
public static final double DOUBLE_MIN_NORM_1 = Double.MIN_NORMAL;
85
public static double DOUBLE_MIN_NORM_2 = Double.MIN_NORMAL;
86
public static final double DOUBLE_MIN_1 = Double.MIN_VALUE;
87
public static double DOUBLE_MIN_2 = Double.MIN_VALUE;
88
public static final double DOUBLE_MAX_1 = Double.MAX_VALUE;
89
public static double DOUBLE_MAX_2 = Double.MAX_VALUE;
90
91
public static void main(String[] args) throws Exception {
92
test("foofalse", "foo" + BOOL_FALSE_1);
93
test("foofalse", "foo" + BOOL_FALSE_2);
94
test("footrue", "foo" + BOOL_TRUE_1);
95
test("footrue", "foo" + BOOL_TRUE_2);
96
97
test("foo127", "foo" + BYTE_MAX_1);
98
test("foo127", "foo" + BYTE_MAX_2);
99
test("foo-128", "foo" + BYTE_MIN_1);
100
test("foo-128", "foo" + BYTE_MIN_2);
101
102
test("foo32767", "foo" + SHORT_MAX_1);
103
test("foo32767", "foo" + SHORT_MAX_2);
104
test("foo-32768", "foo" + SHORT_MIN_1);
105
test("foo-32768", "foo" + SHORT_MIN_2);
106
107
test("foo\u0000", "foo" + CHAR_MIN_1);
108
test("foo\u0000", "foo" + CHAR_MIN_2);
109
test("foo\uFFFF", "foo" + CHAR_MAX_1);
110
test("foo\uFFFF", "foo" + CHAR_MAX_2);
111
112
test("foo2147483647", "foo" + INT_MAX_1);
113
test("foo2147483647", "foo" + INT_MAX_2);
114
test("foo-2147483648", "foo" + INT_MIN_1);
115
test("foo-2147483648", "foo" + INT_MIN_2);
116
117
test("foo1.17549435E-38", "foo" + FLOAT_MIN_NORM_1);
118
test("foo1.17549435E-38", "foo" + FLOAT_MIN_NORM_2);
119
test("foo-126.0", "foo" + FLOAT_MIN_EXP_1);
120
test("foo-126.0", "foo" + FLOAT_MIN_EXP_2);
121
test("foo1.4E-45", "foo" + FLOAT_MIN_1);
122
test("foo1.4E-45", "foo" + FLOAT_MIN_2);
123
test("foo3.4028235E38", "foo" + FLOAT_MAX_1);
124
test("foo3.4028235E38", "foo" + FLOAT_MAX_2);
125
126
test("foo-9223372036854775808", "foo" + LONG_MIN_1);
127
test("foo-9223372036854775808", "foo" + LONG_MIN_2);
128
test("foo9223372036854775807", "foo" + LONG_MAX_1);
129
test("foo9223372036854775807", "foo" + LONG_MAX_2);
130
131
test("foo2.2250738585072014E-308", "foo" + DOUBLE_MIN_NORM_1);
132
test("foo2.2250738585072014E-308", "foo" + DOUBLE_MIN_NORM_2);
133
test("foo-1022.0", "foo" + DOUBLE_MIN_EXP_1);
134
test("foo-1022.0", "foo" + DOUBLE_MIN_EXP_2);
135
test("foo4.9E-324", "foo" + DOUBLE_MIN_1);
136
test("foo4.9E-324", "foo" + DOUBLE_MIN_2);
137
test("foo1.7976931348623157E308", "foo" + DOUBLE_MAX_1);
138
test("foo1.7976931348623157E308", "foo" + DOUBLE_MAX_2);
139
}
140
141
public static void test(String expected, String actual) {
142
if (!expected.equals(actual)) {
143
StringBuilder sb = new StringBuilder();
144
sb.append("Expected = ");
145
sb.append(expected);
146
sb.append(", actual = ");
147
sb.append(actual);
148
throw new IllegalStateException(sb.toString());
149
}
150
}
151
}
152
153