blob: a4399841852e826e7037903c6022e21d28ea3dc5 [file] [log] [blame]
// 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;
import static org.junit.Assume.assumeTrue;
import com.android.tools.r8.TestBase;
import com.android.tools.r8.TestParameters;
import com.android.tools.r8.TestParametersCollection;
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 DefaultLambdaMethodWithPublicSuperClassTest extends TestBase {
private final TestParameters parameters;
private final String EXPECTED = "PublicNameBase::name";
@Parameters(name = "{0}")
public static TestParametersCollection data() {
return getTestParameters().withAllRuntimes().withAllApiLevelsAlsoForCf().build();
}
public DefaultLambdaMethodWithPublicSuperClassTest(TestParameters parameters) {
this.parameters = parameters;
}
@Test
public void testJvm() throws Exception {
assumeTrue(parameters.isCfRuntime());
testForJvm()
.addInnerClasses(getClass())
.run(parameters.getRuntime(), Main.class)
.assertSuccessWithOutputLines(EXPECTED);
}
@Test
public void testDesugar() throws Exception {
testForD8(parameters.getBackend())
.addInnerClasses(getClass())
.setMinApi(parameters.getApiLevel())
.run(parameters.getRuntime(), Main.class)
.assertSuccessWithOutputLines(EXPECTED);
}
interface Named {
default String name() {
return "interface";
}
class PublicNameBase {
public String name() {
return "PublicNameBase::name";
}
}
class PublicName extends PublicNameBase implements Named {}
}
public static class Main {
public static void main(String[] args) {
System.out.println(new Named.PublicName().name());
}
}
}