Skip to content

Commit

Permalink
added LambdaExpressionStatementTest
Browse files Browse the repository at this point in the history
  • Loading branch information
nbauma109 committed May 21, 2023
1 parent 00c33c8 commit 187095d
Showing 1 changed file with 38 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
package org.jd.core.v1.model.javasyntax.statement;

import org.jd.core.v1.model.javasyntax.expression.Expression;
import org.jd.core.v1.model.javasyntax.expression.IntegerConstantExpression;
import org.jd.core.v1.service.converter.classfiletojavasyntax.visitor.TestVisitor;
import org.junit.Test;

import static org.junit.Assert.*;

public class LambdaExpressionStatementTest {

@Test
public void testLambdaExpressionStatement() {
// Test constructor
Expression expression = new IntegerConstantExpression(1, 10);
LambdaExpressionStatement lambdaExpressionStatement = new LambdaExpressionStatement(expression);

assertTrue(lambdaExpressionStatement.getExpression() instanceof IntegerConstantExpression);

// Test setExpression method
Expression newExpression = new IntegerConstantExpression(1, 20);
lambdaExpressionStatement.setExpression(newExpression);

assertEquals(newExpression, lambdaExpressionStatement.getExpression());

// Test the accept method with a simple visitor
TestVisitor visitor = new TestVisitor();
lambdaExpressionStatement.accept(visitor);
assertEquals(1, visitor.getLambdaExpressionStatementCount());

// Test toString method
assertEquals("LambdaExpressionStatement{IntegerConstantExpression{type=PrimitiveType{primitive=maybe_byte}, value=20}}",
lambdaExpressionStatement.toString());

// Test isLambdaExpressionStatement method
assertTrue(lambdaExpressionStatement.isLambdaExpressionStatement());
}
}

0 comments on commit 187095d

Please sign in to comment.