blob: bba41ed560f32f5c03a947f11c81a5a202c6696c [file] [log] [blame]
// Copyright (c) 2024, 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;
import com.android.tools.r8.utils.StringUtils;
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 B344363462Test extends TestBase {
@Parameter() public TestParameters parameters;
@Parameters(name = "{0}")
public static TestParametersCollection data() {
return getTestParameters().withAllRuntimesAndApiLevels().build();
}
private static final String EXPECTED_OUTPUT = StringUtils.lines("-225");
private static final String UNEXPECTED_OUTPUT = StringUtils.lines("0");
@Test
public void testD8() throws Exception {
parameters.assumeDexRuntime();
testForD8(parameters.getBackend())
.addInnerClasses(getClass())
.setMinApi(parameters)
.run(parameters.getRuntime(), TestClass.class)
.assertSuccessWithOutput(EXPECTED_OUTPUT);
}
@Test
public void testD8Release() throws Exception {
parameters.assumeDexRuntime();
testForD8(parameters.getBackend())
.addInnerClasses(getClass())
.setMinApi(parameters)
.release()
.run(parameters.getRuntime(), TestClass.class)
.assertSuccessWithOutput(UNEXPECTED_OUTPUT);
}
@Test
public void testR8() throws Exception {
testForR8(parameters.getBackend())
.addInnerClasses(getClass())
.addKeepMainRule(TestClass.class)
.setMinApi(parameters)
.run(parameters.getRuntime(), TestClass.class)
.assertSuccessWithOutput(UNEXPECTED_OUTPUT);
}
static class TestClass {
int iFld1;
void t() {
int i5 = 61127, i7 = 42011;
long[] lArr = new long[10];
try {
iFld1 -= 225L;
lArr[i5] = i7;
iFld1 = i7;
} catch (ArrayIndexOutOfBoundsException err) {
}
System.out.println(iFld1);
}
public static void main(String[] strArr) {
TestClass test = new TestClass();
test.t();
}
}
}