Skip to content
Merged

Add a[] #5688

Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -325,6 +325,65 @@ void f(Helper helper) {
.doTest();
}

@Test
public void binaryExpression_b498209711() {
compilationHelper
.addInputLines(
"Test.java",
"""
import static org.junit.Assert.assertThrows;

class Test {
void f(Helper helper, int width) {
assertThrows(IllegalStateException.class, () -> helper.consume(width + 1));
}
}
""")
// TODO(b/498209711): This should be .expectUnchanged()
.addOutputLines(
"Test.java",
"""
import static org.junit.Assert.assertThrows;

class Test {
void f(Helper helper, int width) {
int i = width + 1;
assertThrows(IllegalStateException.class, () -> helper.consume(i));
}
}
""")
.doTest();
}

@Test
public void complexExpression_isHoisted() {
compilationHelper
.addInputLines(
"Test.java",
"""
import static org.junit.Assert.assertThrows;

class Test {
void f(Helper helper, int width) {
assertThrows(IllegalStateException.class, () -> helper.consume(width + Helper.onlyUnchecked()));
}
}
""")
.addOutputLines(
"Test.java",
"""
import static org.junit.Assert.assertThrows;

class Test {
void f(Helper helper, int width) {
int i = width + Helper.onlyUnchecked();
assertThrows(IllegalStateException.class, () -> helper.consume(i));
}
}
""")
.doTest();
}

@Test
public void uncheckedException_argOnlyThrowsUnchecked_hoist() {
compilationHelper
Expand Down
Loading