Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add test for negative instanceof variable outside if scope #9993

Merged
Merged
Show file tree
Hide file tree
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 @@ -379,4 +379,12 @@ public void testInstanceOfPatternMatchingAsReturn() {
Bar bar = new Bar();
assertTrue(bar.isSquare());
}

public void testNegativeInstanceOfPatternOutsideIfScope() {
Object bar = new Bar();
if (!(bar instanceof Bar b)) {
throw new RuntimeException();
}
assertTrue(b.isSquare());
}
}
16 changes: 16 additions & 0 deletions user/test/com/google/gwt/dev/jjs/test/Java17Test.java
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,10 @@ public void testInstanceOfPatternMatching() {
assertFalse(isGwtSourceLevel17());
}

public void testInstanceOfPatternMatchingWithSideEffectExpression() {
assertFalse(isGwtSourceLevel17());
}

public void testInstanceOfPatternMatchingWithAnd() {
assertFalse(isGwtSourceLevel17());
}
Expand All @@ -78,6 +82,14 @@ public void testMultipleInstanceOfPatternMatchingWithSameVariableName() {
assertFalse(isGwtSourceLevel17());
}

public void testMultipleInstanceOfPatternMatchingWithSameVariableNameWithDifferentTypes() {
assertFalse(isGwtSourceLevel17());
}

public void testInstanceOfPatternMatchingIsFalse() {
assertFalse(isGwtSourceLevel17());
}

public void testInstanceOfPatternMatchingInLambda() {
assertFalse(isGwtSourceLevel17());
}
Expand All @@ -86,6 +98,10 @@ public void testInstanceOfPatternMatchingAsReturn() {
assertFalse(isGwtSourceLevel17());
}

public void testNegativeInstanceOfPatternOutsideIfScope() {
assertFalse(isGwtSourceLevel17());
}

private boolean isGwtSourceLevel17() {
return JUnitShell.getCompilerOptions().getSourceLevel().compareTo(SourceLevel.JAVA17) >= 0;
}
Expand Down