Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
PojavLauncherTeam
GitHub Repository: PojavLauncherTeam/mobile
Path: blob/master/test/jdk/java/lang/String/concat/ImplicitStringConcatArgCount.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 multiple number of arguments to concatenate.
27
*
28
* @compile ImplicitStringConcatArgCount.java
29
* @run main/othervm -Xverify:all ImplicitStringConcatArgCount
30
*
31
* @compile -XDallowStringFolding=false -XDstringConcat=inline ImplicitStringConcatArgCount.java
32
* @run main/othervm -Xverify:all ImplicitStringConcatArgCount
33
*
34
* @compile -XDallowStringFolding=false -XDstringConcat=indy ImplicitStringConcatArgCount.java
35
* @run main/othervm -Xverify:all ImplicitStringConcatArgCount
36
*
37
* @compile -XDallowStringFolding=false -XDstringConcat=indyWithConstants ImplicitStringConcatArgCount.java
38
* @run main/othervm -Xverify:all ImplicitStringConcatArgCount
39
*/
40
public class ImplicitStringConcatArgCount {
41
static final String s = "f";
42
static final String s1 = "o";
43
static String s2 = "o";
44
static int i = 7;
45
46
public static void main(String[] args) throws Exception {
47
test("fo", s + s1);
48
test("foo", s + s1 + s2);
49
test("foo7", s + s1 + s2 + i);
50
test("foo77", s + s1 + s2 + i + i);
51
test("foo777", s + s1 + s2 + i + i + i);
52
test("foo7777", s + s1 + s2 + i + i + i + i);
53
test("foo77777", s + s1 + s2 + i + i + i + i + i);
54
test("foo777777", s + s1 + s2 + i + i + i + i + i + i);
55
test("foo7777777", s + s1 + s2 + i + i + i + i + i + i + i);
56
test("foo77777777", s + s1 + s2 + i + i + i + i + i + i + i + i);
57
}
58
59
public static void test(String expected, String actual) {
60
if (!expected.equals(actual)) {
61
StringBuilder sb = new StringBuilder();
62
sb.append("Expected = ");
63
sb.append(expected);
64
sb.append(", actual = ");
65
sb.append(actual);
66
throw new IllegalStateException(sb.toString());
67
}
68
}
69
}
70
71