| // 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 com.android.tools.r8.TestParameters; | 
 | import com.android.tools.r8.utils.BooleanUtils; | 
 | 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 final TestParameters parameters; | 
 |   private final boolean shrinkDesugaredLibrary; | 
 |   private final String EXPECTED = "Just another manic MONDAY"; | 
 |  | 
 |   @Parameters(name = "{1}, shrinkDesugaredLibrary: {0}") | 
 |   public static List<Object[]> data() { | 
 |     return buildParameters( | 
 |         getTestParameters().withDexRuntimes().withAllApiLevels().build(), BooleanUtils.values()); | 
 |   } | 
 |  | 
 |   public DesugaredLibraryCloneTest(TestParameters parameters, boolean shrinkDesugaredLibrary) { | 
 |     this.parameters = parameters; | 
 |     this.shrinkDesugaredLibrary = shrinkDesugaredLibrary; | 
 |   } | 
 |  | 
 |   @Test | 
 |   public void testD8() throws Exception { | 
 |     KeepRuleConsumer keepRuleConsumer = createKeepRuleConsumer(parameters); | 
 |     testForD8() | 
 |         .addInnerClasses(getClass()) | 
 |         .setMinApi(parameters.getApiLevel()) | 
 |         .enableCoreLibraryDesugaring(parameters.getApiLevel(), keepRuleConsumer) | 
 |         .compile() | 
 |         .addDesugaredCoreLibraryRunClassPath( | 
 |             this::buildDesugaredLibrary, | 
 |             parameters.getApiLevel(), | 
 |             keepRuleConsumer.get(), | 
 |             shrinkDesugaredLibrary) | 
 |         .run(parameters.getRuntime(), Main.class) | 
 |         .assertSuccessWithOutputLines(EXPECTED); | 
 |   } | 
 |  | 
 |   @Test | 
 |   public void testR8() throws Exception { | 
 |     KeepRuleConsumer keepRuleConsumer = createKeepRuleConsumer(parameters); | 
 |     testForR8(parameters.getBackend()) | 
 |         .addInnerClasses(getClass()) | 
 |         .addKeepMainRule(Main.class) | 
 |         .setMinApi(parameters.getApiLevel()) | 
 |         .enableCoreLibraryDesugaring(parameters.getApiLevel(), keepRuleConsumer) | 
 |         .compile() | 
 |         .addDesugaredCoreLibraryRunClassPath( | 
 |             this::buildDesugaredLibrary, | 
 |             parameters.getApiLevel(), | 
 |             keepRuleConsumer.get(), | 
 |             shrinkDesugaredLibrary) | 
 |         .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]); | 
 |       } | 
 |     } | 
 |   } | 
 | } |