Skip to content

Commit

Permalink
add a new test for for-loop scenario.
Browse files Browse the repository at this point in the history
  • Loading branch information
gayanper committed Feb 15, 2024
1 parent 67deec6 commit 7315a92
Showing 1 changed file with 33 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -983,6 +983,7 @@ public void testBugGH1095_2() throws Exception {
"implementMe[METHOD_DECLARATION]{public void implementMe(), LBaseInterface;, ()V, implementMe, null, " + (R_DEFAULT + R_RESOLVED + R_INTERESTING + R_CASE + R_ABSTRACT_METHOD + R_UNQUALIFIED + R_NON_RESTRICTED) + "}",
requestor.getResults());
}

public void testGH1561_CompletionInIfConditionInsideASwitchStatement() throws JavaModelException {
this.workingCopies = new ICompilationUnit[1];
this.workingCopies[0] = getWorkingCopy("/Completion/src/SwitchIf.java",
Expand Down Expand Up @@ -1093,4 +1094,36 @@ private void foo(Type input) {
+ (R_DEFAULT + R_RESOLVED + R_INTERESTING + R_CASE + R_UNQUALIFIED + R_NON_RESTRICTED) + "}",
requestor.getResults());
}

public void testGH1561_CompletionInForInsideASwitchStatement() throws JavaModelException {
this.workingCopies = new ICompilationUnit[1];
this.workingCopies[0] = getWorkingCopy("/Completion/src/SwitchIf.java",
"""
public class SwitchIf {
final String name = "test";
enum Type { A }
private void foo(Type input) {
switch (input) {
case A:
for (int i = 0; nam)
break;
}
}
private boolean nameContains(String name) {
return false;
}
}
""");
CompletionTestsRequestor2 requestor = new CompletionTestsRequestor2(true, true, true, false);
String str = this.workingCopies[0].getSource();
String completeBehind = "for (int i = 0; nam";
int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
this.workingCopies[0].codeComplete(cursorLocation, requestor, this.wcOwner);
assertResults("name[FIELD_REF]{name, LSwitchIf;, Ljava.lang.String;, null, null, name, null, [156, 159], "
+ (R_DEFAULT + R_RESOLVED + R_INTERESTING + R_CASE + R_UNQUALIFIED + R_NON_RESTRICTED) + "}\n"
+ "nameContains[METHOD_REF]{nameContains(), LSwitchIf;, (Ljava.lang.String;)Z, null, null, nameContains, (name), [156, 159], "
+ (R_DEFAULT + R_RESOLVED + R_INTERESTING + R_CASE + R_UNQUALIFIED + R_NON_RESTRICTED
+ R_EXACT_EXPECTED_TYPE)
+ "}", requestor.getResults());
}
}

0 comments on commit 7315a92

Please sign in to comment.