Merge remote-tracking branch 'origin/NewParser' into NewParser
Some checks are pending
Gitea Actions Demo / Explore-Gitea-Actions (push) Waiting to run
Some checks are pending
Gitea Actions Demo / Explore-Gitea-Actions (push) Waiting to run
This commit is contained in:
commit
ca77307f0c
@ -5,6 +5,8 @@ import ast.ASTNode;
|
|||||||
import ast.ClassNode;
|
import ast.ClassNode;
|
||||||
import ast.ProgramNode;
|
import ast.ProgramNode;
|
||||||
import ast.expressions.IExpressionNode;
|
import ast.expressions.IExpressionNode;
|
||||||
|
import ast.expressions.binaryexpressions.EnumNonCalculationOperator;
|
||||||
|
import ast.expressions.binaryexpressions.NonCalculationNode;
|
||||||
import ast.expressions.unaryexpressions.MemberAccessNode;
|
import ast.expressions.unaryexpressions.MemberAccessNode;
|
||||||
import ast.expressions.unaryexpressions.UnaryNode;
|
import ast.expressions.unaryexpressions.UnaryNode;
|
||||||
import ast.members.ConstructorNode;
|
import ast.members.ConstructorNode;
|
||||||
@ -14,8 +16,11 @@ import ast.members.MethodNode;
|
|||||||
import ast.parameters.ParameterNode;
|
import ast.parameters.ParameterNode;
|
||||||
import ast.statementexpressions.AssignNode;
|
import ast.statementexpressions.AssignNode;
|
||||||
import ast.statementexpressions.AssignableNode;
|
import ast.statementexpressions.AssignableNode;
|
||||||
|
import ast.statementexpressions.crementexpressions.CrementType;
|
||||||
|
import ast.statementexpressions.crementexpressions.IncrementNode;
|
||||||
import ast.statementexpressions.NewDeclarationNode;
|
import ast.statementexpressions.NewDeclarationNode;
|
||||||
import ast.statementexpressions.methodcallstatementnexpressions.MethodCallNode;
|
import ast.statementexpressions.methodcallstatementnexpressions.MethodCallNode;
|
||||||
|
import ast.statements.*;
|
||||||
import ast.statementexpressions.methodcallstatementnexpressions.TargetNode;
|
import ast.statementexpressions.methodcallstatementnexpressions.TargetNode;
|
||||||
import ast.statements.BlockNode;
|
import ast.statements.BlockNode;
|
||||||
import ast.statements.LocalVariableDeclarationNode;
|
import ast.statements.LocalVariableDeclarationNode;
|
||||||
@ -407,21 +412,37 @@ class AstBuilderTest {
|
|||||||
@Test
|
@Test
|
||||||
@DisplayName("For Test")
|
@DisplayName("For Test")
|
||||||
public void forTest(){
|
public void forTest(){
|
||||||
|
LocalVariableDeclarationNode forDeclaration = new LocalVariableDeclarationNode(new BaseType(TypeEnum.INT), "i", "=", new UnaryNode(new ValueNode(EnumValueNode.INT_VALUE, "0")));
|
||||||
|
|
||||||
//assertThat(actual).isEqualToComparingFieldByFieldRecursively(expected);
|
NonCalculationNode condition = new NonCalculationNode(new UnaryNode("i"), "<", new UnaryNode(new ValueNode(EnumValueNode.INT_VALUE, "10")));
|
||||||
}
|
AssignableNode assignable = new AssignableNode("i");
|
||||||
|
IncrementNode increment = new IncrementNode(CrementType.SUFFIX, assignable);
|
||||||
|
|
||||||
//Noch nicht speziell Increment nur zum Development Testen per Debug
|
LocalVariableDeclarationNode declaration = new LocalVariableDeclarationNode(new BaseType(TypeEnum.INT), "a", null, null);
|
||||||
@Test
|
|
||||||
@DisplayName("Increment Test")
|
BlockNode whileBlock = new BlockNode();
|
||||||
public void incrementTest(){
|
whileBlock.addStatement(declaration);
|
||||||
ClassNode classNode = Helper.generateEmptyClass("TestClass");
|
whileBlock.addStatement(increment);
|
||||||
classNode.addMember(new FieldNode(new AccessModifierNode("public"), new BaseType(TypeEnum.INT), "a"));
|
|
||||||
|
WhileNode whileStatement = new WhileNode(condition, whileBlock);
|
||||||
|
|
||||||
|
BlockNode forStatement = new BlockNode();
|
||||||
|
forStatement.addStatement(forDeclaration);
|
||||||
|
forStatement.addStatement(whileStatement);
|
||||||
|
|
||||||
|
BlockNode blockCon = new BlockNode();
|
||||||
|
blockCon.addStatement(forStatement);
|
||||||
|
blockCon.addStatement(new ReturnNode(null));
|
||||||
|
ConstructorNode constructor = new ConstructorNode("public", "TestClass", blockCon);
|
||||||
|
|
||||||
|
ClassNode class1 = new ClassNode("public", "TestClass");
|
||||||
|
class1.addMember(constructor);
|
||||||
|
|
||||||
ProgramNode expected = new ProgramNode();
|
ProgramNode expected = new ProgramNode();
|
||||||
expected.addClass(classNode);
|
expected.addClass(class1);
|
||||||
|
|
||||||
|
ASTNode actual = Helper.generateAST("src/test/resources/input/javaCases/For.java");
|
||||||
|
|
||||||
ASTNode actual = Helper.generateAST("src/test/resources/input/javaCases/Increment.java");
|
|
||||||
assertThat(actual).isEqualToComparingFieldByFieldRecursively(expected);
|
assertThat(actual).isEqualToComparingFieldByFieldRecursively(expected);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -436,4 +457,5 @@ class AstBuilderTest {
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
Loading…
Reference in New Issue
Block a user