clementbera | acb0147 | 2019-10-04 10:56:16 +0200 | [diff] [blame] | 1 | // 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éra | b7d332a | 2024-06-04 08:50:51 +0200 | [diff] [blame] | 5 | package nesthostexample; |
clementbera | acb0147 | 2019-10-04 10:56:16 +0200 | [diff] [blame] | 6 | |
Clément Béra | b7d332a | 2024-06-04 08:50:51 +0200 | [diff] [blame] | 7 | import static nesthostexample.BasicNestHostWithInnerClassConstructors.getExpectedResult; |
clementbera | acb0147 | 2019-10-04 10:56:16 +0200 | [diff] [blame] | 8 | |
Christoffer Quist Adamsen | e1575c3 | 2021-02-18 10:23:19 +0100 | [diff] [blame] | 9 | import com.android.tools.r8.Jdk9TestUtils; |
clementbera | acb0147 | 2019-10-04 10:56:16 +0200 | [diff] [blame] | 10 | import com.android.tools.r8.TestBase; |
| 11 | import com.android.tools.r8.TestParameters; |
| 12 | import com.android.tools.r8.TestParametersCollection; |
| 13 | import com.android.tools.r8.TestRuntime.CfVm; |
clementbera | acb0147 | 2019-10-04 10:56:16 +0200 | [diff] [blame] | 14 | import org.junit.Test; |
| 15 | import org.junit.runner.RunWith; |
| 16 | import org.junit.runners.Parameterized; |
| 17 | import org.junit.runners.Parameterized.Parameters; |
| 18 | |
| 19 | @RunWith(Parameterized.class) |
| 20 | public class NestConstructorRemovedArgTest extends TestBase { |
| 21 | |
Clément Béra | b7d332a | 2024-06-04 08:50:51 +0200 | [diff] [blame] | 22 | private static final Class<?> MAIN_CLASS = BasicNestHostWithInnerClassConstructors.class; |
| 23 | |
clementbera | acb0147 | 2019-10-04 10:56:16 +0200 | [diff] [blame] | 24 | 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éra | b7d332a | 2024-06-04 08:50:51 +0200 | [diff] [blame] | 34 | .withDexRuntimes() |
Christoffer Quist Adamsen | f9c73ea | 2021-01-21 16:33:16 +0100 | [diff] [blame] | 35 | .withApiLevelsStartingAtIncluding(apiLevelWithInvokeCustomSupport()) |
Clément Béra | 9bd9b29 | 2021-03-22 08:58:38 +0000 | [diff] [blame] | 36 | .enableApiLevelsForCf() |
clementbera | acb0147 | 2019-10-04 10:56:16 +0200 | [diff] [blame] | 37 | .build(); |
| 38 | } |
| 39 | |
| 40 | @Test |
| 41 | public void testRemoveArgConstructorNestsR8() throws Exception { |
Christoffer Quist Adamsen | d4d9360 | 2023-02-21 15:28:42 +0100 | [diff] [blame] | 42 | parameters.assumeR8TestParameters(); |
clementbera | acb0147 | 2019-10-04 10:56:16 +0200 | [diff] [blame] | 43 | testForR8(parameters.getBackend()) |
Clément Béra | b7d332a | 2024-06-04 08:50:51 +0200 | [diff] [blame] | 44 | .addKeepMainRule(MAIN_CLASS) |
Morten Krogh-Jespersen | 977b51d | 2022-08-08 15:39:28 +0200 | [diff] [blame] | 45 | .addDontObfuscate() |
Christoffer Quist Adamsen | d4d9360 | 2023-02-21 15:28:42 +0100 | [diff] [blame] | 46 | .setMinApi(parameters) |
Christoffer Quist Adamsen | e1575c3 | 2021-02-18 10:23:19 +0100 | [diff] [blame] | 47 | .addOptionsModification(options -> options.enableClassInlining = false) |
Clément Béra | b7d332a | 2024-06-04 08:50:51 +0200 | [diff] [blame] | 48 | .addProgramClassesAndInnerClasses(MAIN_CLASS) |
Christoffer Quist Adamsen | e1575c3 | 2021-02-18 10:23:19 +0100 | [diff] [blame] | 49 | .applyIf(parameters.isCfRuntime(), Jdk9TestUtils.addJdk9LibraryFiles(temp)) |
clementbera | acb0147 | 2019-10-04 10:56:16 +0200 | [diff] [blame] | 50 | .compile() |
Clément Béra | b7d332a | 2024-06-04 08:50:51 +0200 | [diff] [blame] | 51 | .run(parameters.getRuntime(), MAIN_CLASS) |
| 52 | .assertSuccessWithOutputLines(getExpectedResult()); |
clementbera | acb0147 | 2019-10-04 10:56:16 +0200 | [diff] [blame] | 53 | } |
| 54 | |
| 55 | @Test |
| 56 | public void testRemoveArgConstructorNestsR8NoTreeShaking() throws Exception { |
Christoffer Quist Adamsen | d4d9360 | 2023-02-21 15:28:42 +0100 | [diff] [blame] | 57 | parameters.assumeR8TestParameters(); |
clementbera | acb0147 | 2019-10-04 10:56:16 +0200 | [diff] [blame] | 58 | testForR8(parameters.getBackend()) |
Christoffer Adamsen | 7711902 | 2024-08-09 09:30:29 +0200 | [diff] [blame] | 59 | .addDontShrink() |
Clément Béra | b7d332a | 2024-06-04 08:50:51 +0200 | [diff] [blame] | 60 | .addKeepMainRule(MAIN_CLASS) |
Morten Krogh-Jespersen | 977b51d | 2022-08-08 15:39:28 +0200 | [diff] [blame] | 61 | .addDontObfuscate() |
Christoffer Quist Adamsen | d4d9360 | 2023-02-21 15:28:42 +0100 | [diff] [blame] | 62 | .setMinApi(parameters) |
Christoffer Quist Adamsen | e1575c3 | 2021-02-18 10:23:19 +0100 | [diff] [blame] | 63 | .addOptionsModification(options -> options.enableClassInlining = false) |
Clément Béra | b7d332a | 2024-06-04 08:50:51 +0200 | [diff] [blame] | 64 | .addProgramClassesAndInnerClasses(MAIN_CLASS) |
Christoffer Quist Adamsen | e1575c3 | 2021-02-18 10:23:19 +0100 | [diff] [blame] | 65 | .applyIf(parameters.isCfRuntime(), Jdk9TestUtils.addJdk9LibraryFiles(temp)) |
clementbera | acb0147 | 2019-10-04 10:56:16 +0200 | [diff] [blame] | 66 | .compile() |
Clément Béra | b7d332a | 2024-06-04 08:50:51 +0200 | [diff] [blame] | 67 | .run(parameters.getRuntime(), MAIN_CLASS) |
| 68 | .assertSuccessWithOutputLines(getExpectedResult()); |
clementbera | acb0147 | 2019-10-04 10:56:16 +0200 | [diff] [blame] | 69 | } |
| 70 | } |