-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
added LambdaFormalParametersExpressionTest
- Loading branch information
nbauma109
committed
May 21, 2023
1 parent
c885595
commit 7b94e52
Showing
1 changed file
with
51 additions
and
0 deletions.
There are no files selected for viewing
51 changes: 51 additions & 0 deletions
51
...java/org/jd/core/v1/model/javasyntax/expression/LambdaFormalParametersExpressionTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
package org.jd.core.v1.model.javasyntax.expression; | ||
|
||
import org.jd.core.v1.model.javasyntax.declaration.BaseFormalParameter; | ||
import org.jd.core.v1.model.javasyntax.declaration.FormalParameter; | ||
import org.jd.core.v1.model.javasyntax.statement.BaseStatement; | ||
import org.jd.core.v1.model.javasyntax.statement.ReturnExpressionStatement; | ||
import org.jd.core.v1.model.javasyntax.type.ObjectType; | ||
import org.jd.core.v1.model.javasyntax.type.Type; | ||
import org.jd.core.v1.service.converter.classfiletojavasyntax.visitor.TestVisitor; | ||
import org.junit.Test; | ||
|
||
import static org.junit.Assert.assertEquals; | ||
import static org.junit.Assert.assertNotEquals; | ||
|
||
public class LambdaFormalParametersExpressionTest { | ||
|
||
@Test | ||
public void testLambdaFormalParametersExpression() { | ||
// Arrange | ||
Type type = ObjectType.TYPE_OBJECT; | ||
Expression returnExpression = new IntegerConstantExpression(1); | ||
BaseStatement statement = new ReturnExpressionStatement(returnExpression); | ||
BaseFormalParameter baseFormalParameter = new FormalParameter(ObjectType.TYPE_INTEGER, "x"); | ||
int lineNumber = 10; | ||
|
||
// Act | ||
LambdaFormalParametersExpression lambdaFormalParametersExpression = new LambdaFormalParametersExpression(lineNumber, type, baseFormalParameter, statement); | ||
|
||
// Assert | ||
assertEquals(lineNumber, lambdaFormalParametersExpression.getLineNumber()); | ||
assertEquals(type, lambdaFormalParametersExpression.getType()); | ||
assertEquals(baseFormalParameter, lambdaFormalParametersExpression.getFormalParameters()); | ||
assertEquals(statement, lambdaFormalParametersExpression.getStatements()); | ||
|
||
// Act & Assert | ||
LambdaFormalParametersExpression copy = (LambdaFormalParametersExpression) lambdaFormalParametersExpression.copyTo(lineNumber + 1); | ||
assertEquals(lambdaFormalParametersExpression.getType(), copy.getType()); | ||
assertEquals(lambdaFormalParametersExpression.getFormalParameters(), copy.getFormalParameters()); | ||
assertEquals(lambdaFormalParametersExpression.getStatements(), copy.getStatements()); | ||
assertNotEquals(lambdaFormalParametersExpression.getLineNumber(), copy.getLineNumber()); | ||
|
||
// Test accept method | ||
TestVisitor visitor = new TestVisitor(); | ||
lambdaFormalParametersExpression.accept(visitor); | ||
assertEquals(1, visitor.getLambdaFormalParametersExpressionCount()); | ||
|
||
// Test toString method | ||
String expectedToString = "LambdaFormalParametersExpression{" + baseFormalParameter + " -> " + statement + "}"; | ||
assertEquals(expectedToString, lambdaFormalParametersExpression.toString()); | ||
} | ||
} |