| // Copyright (c) 2021, the R8 project authors. Please see the AUTHORS file |
| // for details. All rights reserved. Use of this source code is governed by a |
| // BSD-style license that can be found in the LICENSE file. |
| |
| package com.android.tools.r8.desugar.desugaredlibrary; |
| |
| import static com.android.tools.r8.desugar.desugaredlibrary.test.CompilationSpecification.DEFAULT_SPECIFICATIONS; |
| import static com.android.tools.r8.desugar.desugaredlibrary.test.LibraryDesugaringSpecification.getJdk8Jdk11; |
| |
| import com.android.tools.r8.TestParameters; |
| import com.android.tools.r8.desugar.desugaredlibrary.test.CompilationSpecification; |
| import com.android.tools.r8.desugar.desugaredlibrary.test.LibraryDesugaringSpecification; |
| import java.time.DayOfWeek; |
| import java.util.List; |
| import org.junit.Test; |
| import org.junit.runner.RunWith; |
| import org.junit.runners.Parameterized; |
| import org.junit.runners.Parameterized.Parameters; |
| |
| @RunWith(Parameterized.class) |
| public class DesugaredLibraryCloneTest extends DesugaredLibraryTestBase { |
| |
| private static final String EXPECTED = "Just another manic MONDAY"; |
| |
| private final TestParameters parameters; |
| private final CompilationSpecification compilationSpecification; |
| private final LibraryDesugaringSpecification libraryDesugaringSpecification; |
| |
| @Parameters(name = "{0}, spec: {1}, {2}") |
| public static List<Object[]> data() { |
| return buildParameters( |
| getTestParameters().withAllRuntimes().withAllApiLevelsAlsoForCf().build(), |
| getJdk8Jdk11(), |
| DEFAULT_SPECIFICATIONS); |
| } |
| |
| public DesugaredLibraryCloneTest( |
| TestParameters parameters, |
| LibraryDesugaringSpecification libraryDesugaringSpecification, |
| CompilationSpecification compilationSpecification) { |
| this.parameters = parameters; |
| this.compilationSpecification = compilationSpecification; |
| this.libraryDesugaringSpecification = libraryDesugaringSpecification; |
| } |
| |
| @Test |
| public void testClone() throws Throwable { |
| testForDesugaredLibrary(parameters, libraryDesugaringSpecification, compilationSpecification) |
| .addInnerClasses(getClass()) |
| .addKeepMainRule(Main.class) |
| .run(parameters.getRuntime(), Main.class) |
| .assertSuccessWithOutputLines(EXPECTED); |
| } |
| |
| public static class Main { |
| |
| public static void main(String[] args) { |
| DayOfWeek[] dayOfWeeks = new DayOfWeek[args.length + 1]; |
| if (args.length == 0) { |
| dayOfWeeks[0] = DayOfWeek.MONDAY; |
| } |
| print(dayOfWeeks.clone()); |
| } |
| |
| public static void print(DayOfWeek[] arr) { |
| if (arr.length > 0) { |
| System.out.println("Just another manic " + arr[0]); |
| } |
| } |
| } |
| } |