Skip to content

Commit

Permalink
Adjust test expectations for various JDK levels
Browse files Browse the repository at this point in the history
  • Loading branch information
srikanth-sankaran committed Nov 13, 2023
1 parent 91912aa commit fb9cdea
Showing 1 changed file with 60 additions and 37 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,24 @@ public void test001() {
options);
}
public void test002() {
String expectedDiagnostics = this.complianceLevel < ClassFileConstants.JDK20 ?
"----------\n" +
"1. ERROR in X.java (at line 3)\n" +
" if (obj instanceof (String s)) {\n" +
" ^\n" +
"Syntax error on token \"(\", delete this token\n" +
"----------\n" +
"2. ERROR in X.java (at line 3)\n" +
" if (obj instanceof (String s)) {\n" +
" ^\n" +
"Syntax error on token \")\", delete this token\n" +
"----------\n" :
"----------\n" +
"1. ERROR in X.java (at line 3)\n" +
" if (obj instanceof (String s)) {\n" +
" ^^^^^^^^^^\n" +
"Syntax error on token \"instanceof\", ReferenceType expected after this token\n" +
"----------\n";
runNegativeTest(
new String[] {
"X.java",
Expand All @@ -106,19 +124,49 @@ public void test002() {
" }\n" +
"}\n",
},
"----------\n" +
"1. ERROR in X.java (at line 3)\n" +
" if (obj instanceof (String s)) {\n" +
" ^\n" +
"Syntax error on token \"(\", delete this token\n" +
"----------\n" +
"2. ERROR in X.java (at line 3)\n" +
" if (obj instanceof (String s)) {\n" +
" ^\n" +
"Syntax error on token \")\", delete this token\n" +
"----------\n");
expectedDiagnostics);
}
public void test003() {

String expectedDiagnostics = this.complianceLevel < ClassFileConstants.JDK20 ?
"----------\n" +
"1. ERROR in X.java (at line 3)\n" +
" if (obj instanceof ((String s))) {\n" +
" ^^^^^^^^^^\n" +
"Syntax error, insert \"Type\" to complete InstanceofClassic\n" +
"----------\n" +
"2. ERROR in X.java (at line 3)\n" +
" if (obj instanceof ((String s))) {\n" +
" ^^^^^^^^^^\n" +
"Syntax error, insert \") Statement\" to complete BlockStatements\n" +
"----------\n" +
"3. ERROR in X.java (at line 3)\n" +
" if (obj instanceof ((String s))) {\n" +
" ^^^^^^\n" +
"Syntax error on token \"String\", ( expected after this token\n" +
"----------\n" +
"4. ERROR in X.java (at line 3)\n" +
" if (obj instanceof ((String s))) {\n" +
" ^\n" +
"Syntax error, insert \"AssignmentOperator Expression\" to complete Assignment\n" +
"----------\n" +
"5. ERROR in X.java (at line 3)\n" +
" if (obj instanceof ((String s))) {\n" +
" ^\n" +
"Syntax error, insert \";\" to complete Statement\n" +
"----------\n" :
"----------\n" +
"1. ERROR in X.java (at line 3)\n" +
" if (obj instanceof ((String s))) {\n" +
" ^\n" +
"Syntax error on token \"(\", invalid ReferenceType\n" +
"----------\n" +
"2. ERROR in X.java (at line 3)\n" +
" if (obj instanceof ((String s))) {\n" +
" ^\n" +
"Syntax error on token \")\", delete this token\n" +
"----------\n";

runNegativeTest(
new String[] {
"X.java",
Expand All @@ -133,32 +181,7 @@ public void test003() {
" }\n" +
"}\n",
},
"----------\n" +
"1. ERROR in X.java (at line 3)\n" +
" if (obj instanceof ((String s))) {\n" +
" ^^^^^^^^^^\n" +
"Syntax error, insert \"Type\" to complete InstanceofClassic\n" +
"----------\n" +
"2. ERROR in X.java (at line 3)\n" +
" if (obj instanceof ((String s))) {\n" +
" ^^^^^^^^^^\n" +
"Syntax error, insert \") Statement\" to complete BlockStatements\n" +
"----------\n" +
"3. ERROR in X.java (at line 3)\n" +
" if (obj instanceof ((String s))) {\n" +
" ^^^^^^\n" +
"Syntax error on token \"String\", ( expected after this token\n" +
"----------\n" +
"4. ERROR in X.java (at line 3)\n" +
" if (obj instanceof ((String s))) {\n" +
" ^\n" +
"Syntax error, insert \"AssignmentOperator Expression\" to complete Assignment\n" +
"----------\n" +
"5. ERROR in X.java (at line 3)\n" +
" if (obj instanceof ((String s))) {\n" +
" ^\n" +
"Syntax error, insert \";\" to complete Statement\n" +
"----------\n");
expectedDiagnostics);
}
public void test007() {
runNegativeTest(
Expand Down

0 comments on commit fb9cdea

Please sign in to comment.