Skip to content

Commit

Permalink
Fixed the unit test failures
Browse files Browse the repository at this point in the history
  • Loading branch information
subyssurendran666 committed Dec 30, 2024
1 parent 37763f9 commit 7703e6a
Show file tree
Hide file tree
Showing 2 changed files with 48 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,13 @@ public void testAddRecordSwitchPattern() throws Exception {
SingleVariableDeclaration patternVariable = ast.newSingleVariableDeclaration();
patternVariable.setType(ast.newSimpleType(ast.newSimpleName("Rectangle")));
patternVariable.setName(ast.newSimpleName("r1"));
tPattern.setPatternVariable(patternVariable);

if (this.apiLevel < AST.JLS22) {
tPattern.setPatternVariable(patternVariable);
} else {
tPattern.setPatternVariable((VariableDeclaration) patternVariable);
}

caseStatement.expressions().add(tPattern);
ListRewrite listRewrite= rewrite.getListRewrite(switchExpression, SwitchExpression.STATEMENTS_PROPERTY);
listRewrite.insertAt(caseStatement, 0, null);
Expand Down Expand Up @@ -179,7 +185,13 @@ public void testModifyRecordSwitchPattern() throws Exception {
SingleVariableDeclaration variableDeclaration = ast.newSingleVariableDeclaration();
variableDeclaration.setType(ast.newSimpleType(ast.newSimpleName("ColoredPoint")));
variableDeclaration.setName(ast.newSimpleName("clr1"));
typePattern.setPatternVariable(variableDeclaration);

if (this.apiLevel < AST.JLS22) {
typePattern.setPatternVariable(variableDeclaration);
} else {
typePattern.setPatternVariable((VariableDeclaration) variableDeclaration);
}

ListRewrite listRewrite= rewrite.getListRewrite(recordPatternR, RecordPattern.PATTERNS_PROPERTY);
listRewrite.insertAt(typePattern, 0, null);
}
Expand Down Expand Up @@ -317,7 +329,12 @@ public void testAddRecordInstanceOfPattern() throws Exception {
SingleVariableDeclaration patternVariable = ast.newSingleVariableDeclaration();
patternVariable.setType(ast.newSimpleType(ast.newSimpleName("Integer")));
patternVariable.setName(ast.newSimpleName("i"));
typePattern.setPatternVariable(patternVariable);
if (this.apiLevel < AST.JLS22) {
typePattern.setPatternVariable(patternVariable);
} else {
typePattern.setPatternVariable((VariableDeclaration) patternVariable);
}

guardedPattern.setPattern(typePattern);
InfixExpression infixExpression = ast.newInfixExpression();
infixExpression.setOperator(InfixExpression.Operator.GREATER);
Expand Down Expand Up @@ -400,7 +417,13 @@ public void testModifyGuardedPattern() throws Exception {
SingleVariableDeclaration patternVariable = ast.newSingleVariableDeclaration();
patternVariable.setType(ast.newSimpleType(ast.newSimpleName("Integer")));
patternVariable.setName(ast.newSimpleName("i"));
typePattern.setPatternVariable(patternVariable);

if (this.apiLevel < AST.JLS22) {
typePattern.setPatternVariable(patternVariable);
} else {
typePattern.setPatternVariable((VariableDeclaration) patternVariable);
}

guardedPattern.setPattern(typePattern);
InfixExpression infixExpression = ast.newInfixExpression();
infixExpression.setOperator(InfixExpression.Operator.GREATER);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,13 @@ public void testAddTypePattern() throws Exception {
SingleVariableDeclaration patternVariable = ast.newSingleVariableDeclaration();
patternVariable.setType(ast.newSimpleType(ast.newSimpleName("String")));
patternVariable.setName(ast.newSimpleName("s"));
typePattern.setPatternVariable(patternVariable);

if (this.apiLevel < AST.JLS22) {
typePattern.setPatternVariable(patternVariable);
} else {
typePattern.setPatternVariable((VariableDeclaration) patternVariable);
}

caseStatement.expressions().add(typePattern);

ListRewrite listRewrite= rewrite.getListRewrite(switchStatement, SwitchExpression.STATEMENTS_PROPERTY);
Expand Down Expand Up @@ -286,7 +292,13 @@ public void testAddGuardedPattern() throws Exception {
SingleVariableDeclaration patternVariable = ast.newSingleVariableDeclaration();
patternVariable.setType(ast.newSimpleType(ast.newSimpleName("Integer")));
patternVariable.setName(ast.newSimpleName("i"));
typePattern.setPatternVariable(patternVariable);

if (this.apiLevel < AST.JLS22) {
typePattern.setPatternVariable(patternVariable);
} else {
typePattern.setPatternVariable((VariableDeclaration) patternVariable);
}

guardedPattern.setPattern(typePattern);
InfixExpression infixExpression = ast.newInfixExpression();
infixExpression.setOperator(InfixExpression.Operator.GREATER);
Expand Down Expand Up @@ -369,7 +381,13 @@ public void testModifyGuardedPattern() throws Exception {
SingleVariableDeclaration patternVariable = ast.newSingleVariableDeclaration();
patternVariable.setType(ast.newSimpleType(ast.newSimpleName("Integer")));
patternVariable.setName(ast.newSimpleName("i"));
typePattern.setPatternVariable(patternVariable);

if (this.apiLevel < AST.JLS22) {
typePattern.setPatternVariable(patternVariable);
} else {
typePattern.setPatternVariable((VariableDeclaration) patternVariable);
}

guardedPattern.setPattern(typePattern);
InfixExpression infixExpression = ast.newInfixExpression();
infixExpression.setOperator(InfixExpression.Operator.GREATER);
Expand Down

0 comments on commit 7703e6a

Please sign in to comment.