blob: 216673a1e950d9450693d5d95f986f562f9b1579 [file] [log] [blame]
clementberaacb01472019-10-04 10:56:16 +02001// Copyright (c) 2019, the R8 project authors. Please see the AUTHORS file
2// for details. All rights reserved. Use of this source code is governed by a
3// BSD-style license that can be found in the LICENSE file.
4
Clément Bérab7d332a2024-06-04 08:50:51 +02005package nesthostexample;
clementberaacb01472019-10-04 10:56:16 +02006
Clément Bérab7d332a2024-06-04 08:50:51 +02007import static nesthostexample.BasicNestHostWithInnerClassConstructors.getExpectedResult;
clementberaacb01472019-10-04 10:56:16 +02008
Christoffer Quist Adamsene1575c32021-02-18 10:23:19 +01009import com.android.tools.r8.Jdk9TestUtils;
clementberaacb01472019-10-04 10:56:16 +020010import com.android.tools.r8.TestBase;
11import com.android.tools.r8.TestParameters;
12import com.android.tools.r8.TestParametersCollection;
13import com.android.tools.r8.TestRuntime.CfVm;
clementberaacb01472019-10-04 10:56:16 +020014import org.junit.Test;
15import org.junit.runner.RunWith;
16import org.junit.runners.Parameterized;
17import org.junit.runners.Parameterized.Parameters;
18
19@RunWith(Parameterized.class)
20public class NestConstructorRemovedArgTest extends TestBase {
21
Clément Bérab7d332a2024-06-04 08:50:51 +020022 private static final Class<?> MAIN_CLASS = BasicNestHostWithInnerClassConstructors.class;
23
clementberaacb01472019-10-04 10:56:16 +020024 public NestConstructorRemovedArgTest(TestParameters parameters) {
25 this.parameters = parameters;
26 }
27
28 private final TestParameters parameters;
29
30 @Parameters(name = "{0}")
31 public static TestParametersCollection data() {
32 return getTestParameters()
33 .withCfRuntimesStartingFromIncluding(CfVm.JDK11)
Clément Bérab7d332a2024-06-04 08:50:51 +020034 .withDexRuntimes()
Christoffer Quist Adamsenf9c73ea2021-01-21 16:33:16 +010035 .withApiLevelsStartingAtIncluding(apiLevelWithInvokeCustomSupport())
Clément Béra9bd9b292021-03-22 08:58:38 +000036 .enableApiLevelsForCf()
clementberaacb01472019-10-04 10:56:16 +020037 .build();
38 }
39
40 @Test
41 public void testRemoveArgConstructorNestsR8() throws Exception {
Christoffer Quist Adamsend4d93602023-02-21 15:28:42 +010042 parameters.assumeR8TestParameters();
clementberaacb01472019-10-04 10:56:16 +020043 testForR8(parameters.getBackend())
Clément Bérab7d332a2024-06-04 08:50:51 +020044 .addKeepMainRule(MAIN_CLASS)
Morten Krogh-Jespersen977b51d2022-08-08 15:39:28 +020045 .addDontObfuscate()
Christoffer Quist Adamsend4d93602023-02-21 15:28:42 +010046 .setMinApi(parameters)
Christoffer Quist Adamsene1575c32021-02-18 10:23:19 +010047 .addOptionsModification(options -> options.enableClassInlining = false)
Clément Bérab7d332a2024-06-04 08:50:51 +020048 .addProgramClassesAndInnerClasses(MAIN_CLASS)
Christoffer Quist Adamsene1575c32021-02-18 10:23:19 +010049 .applyIf(parameters.isCfRuntime(), Jdk9TestUtils.addJdk9LibraryFiles(temp))
clementberaacb01472019-10-04 10:56:16 +020050 .compile()
Clément Bérab7d332a2024-06-04 08:50:51 +020051 .run(parameters.getRuntime(), MAIN_CLASS)
52 .assertSuccessWithOutputLines(getExpectedResult());
clementberaacb01472019-10-04 10:56:16 +020053 }
54
55 @Test
56 public void testRemoveArgConstructorNestsR8NoTreeShaking() throws Exception {
Christoffer Quist Adamsend4d93602023-02-21 15:28:42 +010057 parameters.assumeR8TestParameters();
clementberaacb01472019-10-04 10:56:16 +020058 testForR8(parameters.getBackend())
Christoffer Adamsen77119022024-08-09 09:30:29 +020059 .addDontShrink()
Clément Bérab7d332a2024-06-04 08:50:51 +020060 .addKeepMainRule(MAIN_CLASS)
Morten Krogh-Jespersen977b51d2022-08-08 15:39:28 +020061 .addDontObfuscate()
Christoffer Quist Adamsend4d93602023-02-21 15:28:42 +010062 .setMinApi(parameters)
Christoffer Quist Adamsene1575c32021-02-18 10:23:19 +010063 .addOptionsModification(options -> options.enableClassInlining = false)
Clément Bérab7d332a2024-06-04 08:50:51 +020064 .addProgramClassesAndInnerClasses(MAIN_CLASS)
Christoffer Quist Adamsene1575c32021-02-18 10:23:19 +010065 .applyIf(parameters.isCfRuntime(), Jdk9TestUtils.addJdk9LibraryFiles(temp))
clementberaacb01472019-10-04 10:56:16 +020066 .compile()
Clément Bérab7d332a2024-06-04 08:50:51 +020067 .run(parameters.getRuntime(), MAIN_CLASS)
68 .assertSuccessWithOutputLines(getExpectedResult());
clementberaacb01472019-10-04 10:56:16 +020069 }
70}