blob: 82c0d55a079a79de2733b74e4d061471cd57f55f [file] [log] [blame]
// Copyright (c) 2022, 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.lightir;
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;
@RunWith(Parameterized.class)
public class LIRRoundtripTest extends TestBase {
static class TestClass {
public static void main(String[] args) {
System.out.println("Hello, world!");
}
}
@Parameterized.Parameters(name = "{0}")
public static TestParametersCollection data() {
return getTestParameters().withDefaultRuntimes().build();
}
private final TestParameters parameters;
public LIRRoundtripTest(TestParameters parameters) {
this.parameters = parameters;
}
@Test
public void testReference() throws Exception {
assumeTrue(parameters.isCfRuntime());
testForJvm()
.addProgramClasses(TestClass.class)
.run(parameters.getRuntime(), TestClass.class)
.assertSuccessWithOutputLines("Hello, world!");
}
@Test
public void testRoundtrip() throws Exception {
testForD8(parameters.getBackend())
.release()
.addProgramClasses(TestClass.class)
.addOptionsModification(
o -> {
o.testing.forceIRForCfToCfDesugar = true;
o.testing.roundtripThroughLIR = true;
})
.run(parameters.getRuntime(), TestClass.class)
.assertSuccessWithOutputLines("Hello, world!");
}
}