Changed For Loop Structure
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:
parent
dfded3e592
commit
2ae0988986
@ -207,10 +207,17 @@ public class ASTBuilder extends SimpleJavaBaseVisitor<ASTNode> {
|
|||||||
crement = (IStatementNode) visit(ctx.statementExpression(i));
|
crement = (IStatementNode) visit(ctx.statementExpression(i));
|
||||||
}
|
}
|
||||||
|
|
||||||
BlockNode forBlock = (BlockNode) visit(ctx.blockStatement());
|
BlockNode forBlock = new BlockNode();
|
||||||
|
|
||||||
|
BlockNode forStatements = (BlockNode) visit(ctx.blockStatement());
|
||||||
|
if(forStatements != null) {
|
||||||
|
forBlock.addStatement((IStatementNode) forStatements);
|
||||||
|
}
|
||||||
|
|
||||||
if(crement != null){
|
if(crement != null){
|
||||||
forBlock.addStatement((crement));
|
BlockNode forCrement = new BlockNode();
|
||||||
|
forCrement.addStatement((crement));
|
||||||
|
forBlock.addStatement(forCrement);
|
||||||
}
|
}
|
||||||
|
|
||||||
WhileNode While = new WhileNode(condition, forBlock);
|
WhileNode While = new WhileNode(condition, forBlock);
|
||||||
|
@ -200,6 +200,20 @@ class AstBuilderTest {
|
|||||||
//assertThat(actual).isEqualToComparingFieldByFieldRecursively(expected);
|
//assertThat(actual).isEqualToComparingFieldByFieldRecursively(expected);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//Noch nicht speziell Increment nur zum Development Testen per Debug
|
||||||
|
@Test
|
||||||
|
@DisplayName("Increment Test")
|
||||||
|
public void incrementTest(){
|
||||||
|
ClassNode classNode = Helper.generateEmptyClass("TestClass");
|
||||||
|
classNode.addMember(new FieldNode(new AccessModifierNode("public"), new BaseType(TypeEnum.INT), "a"));
|
||||||
|
|
||||||
|
ProgramNode expected = new ProgramNode();
|
||||||
|
expected.addClass(classNode);
|
||||||
|
|
||||||
|
ASTNode actual = Helper.generateAST("src/test/resources/input/javaCases/Increment.java");
|
||||||
|
assertThat(actual).isEqualToComparingFieldByFieldRecursively(expected);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
12
src/test/resources/input/javaCases/Increment.java
Normal file
12
src/test/resources/input/javaCases/Increment.java
Normal file
@ -0,0 +1,12 @@
|
|||||||
|
public class Increment {
|
||||||
|
|
||||||
|
public int test;
|
||||||
|
|
||||||
|
public void increment(int p) {
|
||||||
|
test = p++;
|
||||||
|
|
||||||
|
for(int i = 1; i<=10, i++) {
|
||||||
|
int a = 5;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user