blob: 3810a92d4ba3d69456602ece4ad309b4dbdf7416 [file] [log] [blame]
// Copyright (c) 2019, 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.examples.newarray;
import static org.junit.Assume.assumeTrue;
import com.android.tools.r8.CompilationMode;
import com.android.tools.r8.TestBase;
import com.android.tools.r8.TestParameters;
import com.android.tools.r8.TestRuntime;
import com.android.tools.r8.utils.BooleanUtils;
import java.util.List;
import org.junit.BeforeClass;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.runners.Parameterized;
@RunWith(Parameterized.class)
public class NewArrayTestRunner extends TestBase {
static final Class<?> CLASS = NewArray.class;
private final TestParameters parameters;
private final CompilationMode mode;
private final boolean newCfFrontend;
private static String referenceOut;
@Parameterized.Parameters(name = "{0}, {1}, new-cf:{2}")
public static List<Object[]> data() {
return buildParameters(
getTestParameters().withAllRuntimes().withAllApiLevels().build(),
CompilationMode.values(),
BooleanUtils.values());
}
public NewArrayTestRunner(
TestParameters parameters, CompilationMode mode, boolean newCfFrontend) {
this.parameters = parameters;
this.mode = mode;
this.newCfFrontend = newCfFrontend;
}
@BeforeClass
public static void runReference() throws Exception {
referenceOut =
testForJvm(getStaticTemp())
.addProgramClassesAndInnerClasses(CLASS)
.run(TestRuntime.getDefaultJavaRuntime(), CLASS)
.assertSuccess()
.getStdOut();
}
@Test
public void testD8() throws Exception {
assumeTrue(parameters.isDexRuntime());
testForD8()
.addProgramClassesAndInnerClasses(CLASS)
.setMinApi(parameters.getApiLevel())
.addOptionsModification(options -> options.enableCfFrontend = newCfFrontend)
.setMode(mode)
.run(parameters.getRuntime(), CLASS)
.assertSuccessWithOutput(referenceOut);
}
@Test
public void testR8() throws Exception {
testForR8(parameters.getBackend())
.addProgramClassesAndInnerClasses(CLASS)
.addKeepMainRule(CLASS)
.setMinApi(parameters.getApiLevel())
.addOptionsModification(options -> options.enableCfFrontend = newCfFrontend)
.setMode(mode)
.run(parameters.getRuntime(), CLASS)
.assertSuccessWithOutput(referenceOut);
}
}