blob: ad374733b30eadfb946102dde01f6810c6016098 [file]
// Copyright (c) 2017, 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.debuginfo;
import static org.junit.Assert.assertEquals;
import com.android.tools.r8.TestParameters;
import com.android.tools.r8.TestParametersCollection;
import com.android.tools.r8.utils.AndroidApp;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.runners.Parameterized;
import org.junit.runners.Parameterized.Parameter;
import org.junit.runners.Parameterized.Parameters;
@RunWith(Parameterized.class)
public class ArgumentLocalsInLoopTestRunner extends DebugInfoTestBase {
@Parameter(0)
public TestParameters parameters;
@Parameters(name = "{0}")
public static TestParametersCollection data() {
return getTestParameters().withDexRuntimes().build();
}
@Test
public void testArgumentLocalsInLoop() throws Exception {
Class clazz = ArgumentLocalsInLoopTest.class;
AndroidApp d8App = compileWithD8(clazz);
String expected = "0";
assertEquals(expected, runOnJava(clazz));
assertEquals(expected, runOnArt(d8App, clazz.getCanonicalName(), parameters.getDexVm()));
checkFoo(inspectMethod(d8App, clazz, "int", "foo", "int"), clazz);
}
private void checkFoo(DebugInfoInspector info, Class clazz) {
String[] locals = {"this", clazz.getCanonicalName(), "x", "int"};
info.checkStartLine(10);
info.checkLineHasExactLocals(10, locals);
info.checkLineHasExactLocals(11, locals);
info.checkNoLine(12);
info.checkLineHasExactLocals(13, locals);
info.checkNoLine(14);
info.checkNoLine(15);
}
}