diff --git a/src/main/java/testfiles/ASTFeatures/AST_MultipleClasses.java b/src/main/java/testfiles/ASTFeatures/AST_MultipleClasses.java deleted file mode 100644 index 2cbacb1..0000000 --- a/src/main/java/testfiles/ASTFeatures/AST_MultipleClasses.java +++ /dev/null @@ -1,5 +0,0 @@ -package testfiles.ASTFeatures; - -public class AST_MultipleClasses { - -} \ No newline at end of file diff --git a/src/test/java/ScannerParserTests.java b/src/test/java/ScannerParserTests.java index 81fae52..5412585 100644 --- a/src/test/java/ScannerParserTests.java +++ b/src/test/java/ScannerParserTests.java @@ -1,8 +1,8 @@ import de.maishai.Compiler; import de.maishai.ast.records.Program; import org.junit.jupiter.api.Test; -import testfiles.ASTFeatures.*; -import testfiles.ASTMore.*; +import testResources.AST.ASTFeatures.*; +import testResources.AST.ASTMore.*; import java.util.List; @@ -12,56 +12,56 @@ public class ScannerParserTests { @Test public void testPublicClass() { - Program resultAst = Compiler.generateASTFromFile(List.of("src/main/resources/JavaTestfiles/PublicClass.java")); + Program resultAst = Compiler.generateASTFromFile(List.of("src/test/testFiles/JavaTestfilesMore/PublicClass.java")); assertEquals(AbstractSyntax_PublicClass.get(), resultAst); } @Test public void testClassWithField() { - Program resultAst = Compiler.generateASTFromFile(List.of("src/main/resources/JavaTestfiles/ClassWithField.java")); + Program resultAst = Compiler.generateASTFromFile(List.of("src/test/testFiles/JavaTestfilesMore/ClassWithField.java")); assertEquals(AbstractSyntax_ClassWithField.get(), resultAst); } @Test public void testClassWithConstructor() { - Program resultAst = Compiler.generateASTFromFile(List.of("src/main/resources/JavaTestfiles/ClassWithConstructor.java")); + Program resultAst = Compiler.generateASTFromFile(List.of("src/test/testFiles/JavaTestfilesMore/ClassWithConstructor.java")); assertEquals(AbstractSyntax_ClassWithConstructor.get(), resultAst); } @Test public void testClassWithMethod() { - Program resultAst = Compiler.generateASTFromFile(List.of("src/main/resources/JavaTestfiles/ClassWithMethod.java")); + Program resultAst = Compiler.generateASTFromFile(List.of("src/test/testFiles/JavaTestfilesMore/ClassWithMethod.java")); assertEquals(AbstractSyntax_ClassWithMethod.get(), resultAst); } @Test public void testClassWithConstructorWithCodeInComments() { - Program resultAst = Compiler.generateASTFromFile(List.of("src/main/resources/JavaTestfiles/ClassWithConstructorWithCodeInComments.java")); + Program resultAst = Compiler.generateASTFromFile(List.of("src/test/testFiles/JavaTestfilesMore/ClassWithConstructorWithCodeInComments.java")); assertEquals(AbstractSyntax_ClassWithConstructorWithCodeInComments.get(), resultAst); } @Test public void testClassWithConstructorWithParameters() { - Program resultAst = Compiler.generateASTFromFile(List.of("src/main/resources/JavaTestfiles/ClassWithConstructorWithParameters.java")); + Program resultAst = Compiler.generateASTFromFile(List.of("src/test/testFiles/JavaTestfilesMore/ClassWithConstructorWithParameters.java")); assertEquals(AbstractSyntax_ClassWithConstructorWithParameters.get(), resultAst); } // @Test // public void testClassWithMethodAndField() { -// Program resultAst = Compiler.generateASTFromFile(List.of("src/main/resources/JavaTestfiles/ClassWithMethodAndField.java")); +// Program resultAst = Compiler.generateASTFromFile(List.of("src/test/testFiles/JavaTestfilesMore/ClassWithMethodAndField.java")); // assertEquals(AbstractSyntax_ClassWithMethodAndField.get(), resultAst); // } //TODO: fix @Test public void testClassWithConstructorAndMethodCall() { - Program resultAst = Compiler.generateASTFromFile(List.of("src/main/resources/JavaTestfiles/ClassWithConstructorAndMethodCall.java")); + Program resultAst = Compiler.generateASTFromFile(List.of("src/test/testFiles/JavaTestfilesMore/ClassWithConstructorAndMethodCall.java")); assertEquals(AbstractSyntax_ClassWithConstructorAndMethodCall.get(), resultAst); } @Test public void testComplexClass() { - Program resultAst = Compiler.generateASTFromFile(List.of("src/main/resources/JavaTestfiles/ComplexClass.java")); + Program resultAst = Compiler.generateASTFromFile(List.of("src/test/testFiles/JavaTestfilesMore/ComplexClass.java")); assertEquals(AbstractSyntax_ComplexClass.get(), resultAst); } @@ -69,74 +69,74 @@ public class ScannerParserTests { @Test public void testClass() { - Program resultAst = Compiler.generateASTFromFile(List.of("src/main/resources/JavaTestfilesFeatures/Class.java")); + Program resultAst = Compiler.generateASTFromFile(List.of("src/test/testFiles/JavaTestfilesFeatures/Class.java")); assertEquals(AST_Class.get(), resultAst); } -// @Test -// public void testClassObjects() { -// Program resultAst = Compiler.generateASTFromFile(List.of("src/main/resources/JavaTestfilesFeatures/ClassObjects.java")); -// assertEquals(AST_ClassObjects.get(), resultAst); -// } - //TODO: fix + @Test + public void testClassObjects() { + Program resultAst = Compiler.generateASTFromFile(List.of("src/test/testFiles/JavaTestfilesFeatures/ClassObjects.java")); + assertEquals(AST_ClassObjects.get(), resultAst); + } + //TODO: nochmal drĂ¼berschauen, nachfragen wegen true/false bei FieldVarAccess @Test public void testComment() { - Program resultAst = Compiler.generateASTFromFile(List.of("src/main/resources/JavaTestfilesFeatures/Comment.java")); + Program resultAst = Compiler.generateASTFromFile(List.of("src/test/testFiles/JavaTestfilesFeatures/Comment.java")); assertEquals(AST_Comment.get(), resultAst); } @Test public void testConstructor() { - Program resultAst = Compiler.generateASTFromFile(List.of("src/main/resources/JavaTestfilesFeatures/Constructor.java")); + Program resultAst = Compiler.generateASTFromFile(List.of("src/test/testFiles/JavaTestfilesFeatures/Constructor.java")); assertEquals(AST_Constructor.get(), resultAst); } @Test public void testContinue() { - Program resultAst = Compiler.generateASTFromFile(List.of("src/main/resources/JavaTestfilesFeatures/Continue.java")); + Program resultAst = Compiler.generateASTFromFile(List.of("src/test/testFiles/JavaTestfilesFeatures/Continue.java")); assertEquals(AST_Continue.get(), resultAst); } @Test public void testField() { - Program resultAst = Compiler.generateASTFromFile(List.of("src/main/resources/JavaTestfilesFeatures/Field.java")); + Program resultAst = Compiler.generateASTFromFile(List.of("src/test/testFiles/JavaTestfilesFeatures/Field.java")); assertEquals(AST_Field.get(), resultAst); } @Test public void testFor() { - Program resultAst = Compiler.generateASTFromFile(List.of("src/main/resources/JavaTestfilesFeatures/For.java")); + Program resultAst = Compiler.generateASTFromFile(List.of("src/test/testFiles/JavaTestfilesFeatures/For.java")); assertEquals(AST_For.get(), resultAst); } @Test public void testIf() { - Program resultAst = Compiler.generateASTFromFile(List.of("src/main/resources/JavaTestfilesFeatures/If.java")); + Program resultAst = Compiler.generateASTFromFile(List.of("src/test/testFiles/JavaTestfilesFeatures/If.java")); assertEquals(AST_If.get(), resultAst); } // @Test // public void testIncrDecr() { -// Program resultAst = Compiler.generateASTFromFile(List.of("src/main/resources/JavaTestfilesFeatures/IncrDecr.java")); +// Program resultAst = Compiler.generateASTFromFile(List.of("src/test/testFiles/JavaTestfilesFeatures/IncrDecr.java")); // assertEquals(AST_IncrDecr.get(), resultAst); // } @Test public void testLogicExpr() { - Program resultAst = Compiler.generateASTFromFile(List.of("src/main/resources/JavaTestfilesFeatures/LogicExpr.java")); + Program resultAst = Compiler.generateASTFromFile(List.of("src/test/testFiles/JavaTestfilesFeatures/LogicExpr.java")); assertEquals(AST_LogicExpr.get(), resultAst); } @Test public void testMethod() { - Program resultAst = Compiler.generateASTFromFile(List.of("src/main/resources/JavaTestfilesFeatures/Method.java")); + Program resultAst = Compiler.generateASTFromFile(List.of("src/test/testFiles/JavaTestfilesFeatures/Method.java")); assertEquals(AST_Method.get(), resultAst); } @Test public void testMethodCall() { - Program resultAst = Compiler.generateASTFromFile(List.of("src/main/resources/JavaTestfilesFeatures/MethodCall.java")); + Program resultAst = Compiler.generateASTFromFile(List.of("src/test/testFiles/JavaTestfilesFeatures/MethodCall.java")); assertEquals(AST_MethodCall.get(), resultAst); } @@ -144,39 +144,39 @@ public class ScannerParserTests { @Test public void testOperators() { - Program resultAst = Compiler.generateASTFromFile(List.of("src/main/resources/JavaTestfilesFeatures/Operators.java")); + Program resultAst = Compiler.generateASTFromFile(List.of("src/test/testFiles/JavaTestfilesFeatures/Operators.java")); assertEquals(AST_Operators.get(), resultAst); } @Test public void testOverloaded() { - Program resultAst = Compiler.generateASTFromFile(List.of("src/main/resources/JavaTestfilesFeatures/Overloaded.java")); + Program resultAst = Compiler.generateASTFromFile(List.of("src/test/testFiles/JavaTestfilesFeatures/Overloaded.java")); assertEquals(AST_Overloaded.get(), resultAst); } -// @Test -// public void testPrint() { -// Program resultAst = Compiler.generateASTFromFile(List.of("src/main/resources/JavaTestfilesFeatures/Print.java")); -// assertEquals(AST_Print.get(), resultAst); -// } + @Test + public void testPrint() { + Program resultAst = Compiler.generateASTFromFile(List.of("src/test/testFiles/JavaTestfilesFeatures/Print.java")); + assertEquals(AST_Print.get(), resultAst); + } //TODO: fix // @Test // public void testReturn() { -// Program resultAst = Compiler.generateASTFromFile(List.of("src/main/resources/JavaTestfilesFeatures/Return.java")); +// Program resultAst = Compiler.generateASTFromFile(List.of("src/test/testFiles/JavaTestfilesFeatures/Return.java")); // assertEquals(AST_Return.get(), resultAst); // } //TODO: fix @Test public void testVariableDefWithDecl() { - Program resultAst = Compiler.generateASTFromFile(List.of("src/main/resources/JavaTestfilesFeatures/VariableDefWithDecl.java")); + Program resultAst = Compiler.generateASTFromFile(List.of("src/test/testFiles/JavaTestfilesFeatures/VariableDefWithDecl.java")); assertEquals(AST_VariableDefWithDecl.get(), resultAst); } @Test public void testWhile() { - Program resultAst = Compiler.generateASTFromFile(List.of("src/main/resources/JavaTestfilesFeatures/While.java")); + Program resultAst = Compiler.generateASTFromFile(List.of("src/test/testFiles/JavaTestfilesFeatures/While.java")); assertEquals(AST_While.get(), resultAst); } } diff --git a/src/test/java/TypingTests.java b/src/test/java/TypingTests.java index 867ced3..70eaadd 100644 --- a/src/test/java/TypingTests.java +++ b/src/test/java/TypingTests.java @@ -1,9 +1,16 @@ import de.maishai.Compiler; import de.maishai.typedast.typedclass.TypedProgram; import org.junit.jupiter.api.Test; -import testfiles.ASTFeatures.*; -import testfiles.ASTMore.*; -import testfiles.TypedASTMore.*; +import testResources.typedAST.TypedASTFeatures.*; +import testResources.AST.ASTFeatures.*; +import testResources.AST.ASTMore.AbstractSyntax_ClassWithConstructor; +import testResources.AST.ASTMore.AbstractSyntax_ClassWithField; +import testResources.AST.ASTMore.AbstractSyntax_ComplexClass; +import testResources.AST.ASTMore.AbstractSyntax_PublicClass; +import testResources.typedAST.TypedASTMore.TypedAbstractSyntax_ClassWithConstructor; +import testResources.typedAST.TypedASTMore.TypedAbstractSyntax_ClassWithField; +import testResources.typedAST.TypedASTMore.TypedAbstractSyntax_ComplexClass; +import testResources.typedAST.TypedASTMore.TypedAbstractSyntax_PublicClass; import static org.junit.jupiter.api.Assertions.assertEquals; @@ -27,9 +34,127 @@ public class TypingTests { assertEquals(TypedAbstractSyntax_ClassWithConstructor.get(), resultTypedAst); } +// @Test +// public void testComplexClass() { +// TypedProgram resultTypedAst = Compiler.generateTypedASTFromAst(AbstractSyntax_ComplexClass.get()); +// assertEquals(TypedAbstractSyntax_ComplexClass.get(), resultTypedAst); +// } + @Test - public void testComplexClass() { - TypedProgram resultTypedAst = Compiler.generateTypedASTFromAst(AbstractSyntax_ComplexClass.get()); - assertEquals(TypedAbstractSyntax_ComplexClass.get(), resultTypedAst); + public void testClass() { + TypedProgram resultTypedAst = Compiler.generateTypedASTFromAst(AST_Class.get()); + assertEquals(TypedAST_Class.get(), resultTypedAst); } + + @Test + public void testClassObjects() { + TypedProgram resultTypedAst = Compiler.generateTypedASTFromAst(AST_ClassObjects.get()); + assertEquals(TypedAST_ClassObjects.get(), resultTypedAst); + } + + @Test + public void testComment() { + TypedProgram resultTypedAst = Compiler.generateTypedASTFromAst(AST_Comment.get()); + assertEquals(TypedAST_Comment.get(), resultTypedAst); + } + + @Test + public void testConstructor() { + TypedProgram resultTypedAst = Compiler.generateTypedASTFromAst(AST_Constructor.get()); + assertEquals(TypedAST_Constructor.get(), resultTypedAst); + } +// +// @Test +// public void testContinue() { +// TypedProgram resultTypedAst = Compiler.generateTypedASTFromAst(AST_Continue.get()); +// assertEquals(TypedAST_Continue.get(), resultTypedAst); +// } +// +// @Test +// public void testField() { +// TypedProgram resultTypedAst = Compiler.generateTypedASTFromAst(AST_Field.get()); +// assertEquals(TypedAST_Field.get(), resultTypedAst); +// } +// +// @Test +// public void testFor() { +// TypedProgram resultTypedAst = Compiler.generateTypedASTFromAst(AST_For.get()); +// assertEquals(TypedAST_For.get(), resultTypedAst); +// } +// +// @Test +// public void testIf() { +// TypedProgram resultTypedAst = Compiler.generateTypedASTFromAst(testResources.AST.ASTFeatures.AST_If.get()); +// assertEquals(TypedAST_If.get(), resultTypedAst); +// } +// +// @Test +// public void testIncrDecr() { +// TypedProgram resultTypedAst = Compiler.generateTypedASTFromAst(AST_IncrDecr.get()); +// assertEquals(TypedAST_IncrDecr.get(), resultTypedAst); +// } + //TODO: fix +// +// @Test +// public void testLogicExpr() { +// TypedProgram resultTypedAst = Compiler.generateTypedASTFromAst(AST_LogicExpr.get()); +// assertEquals(TypedAST_LogicExpr.get(), resultTypedAst); +// } +// +// @Test +// public void testMethod() { +// TypedProgram resultTypedAst = Compiler.generateTypedASTFromAst(AST_Method.get()); +// assertEquals(TypedAST_Method.get(), resultTypedAst); +// } +// +// @Test +// public void testMethodCall() { +// TypedProgram resultTypedAst = Compiler.generateTypedASTFromAst(AST_MethodCall.get()); +// assertEquals(TypedAST_MethodCall.get(), resultTypedAst); +// } +// +// @Test +// public void testMultipleClasses() { +// TypedProgram resultTypedAst = Compiler.generateTypedASTFromAst(AST_MultipleClasses.get()); +// assertEquals(TypedAST_MultipleClasses.get(), resultTypedAst); +// } +// // TODO: Implement +// +// @Test +// public void testOperators() { +// TypedProgram resultTypedAst = Compiler.generateTypedASTFromAst(AST_Operators.get()); +// assertEquals(TypedAST_Operators.get(), resultTypedAst); +// } +// +// @Test +// public void testOverloaded() { +// TypedProgram resultTypedAst = Compiler.generateTypedASTFromAst(AST_Overloaded.get()); +// assertEquals(TypedAST_Overloaded.get(), resultTypedAst); +// } +// +// @Test +// public void testPrint() { +// TypedProgram resultTypedAst = Compiler.generateTypedASTFromAst(AST_Print.get()); +// assertEquals(TypedAST_Print.get(), resultTypedAst); +// } + //TODO: fix +// +// @Test +// public void testReturn() { +// TypedProgram resultTypedAst = Compiler.generateTypedASTFromAst(AST_Return.get()); +// assertEquals(TypedAST_Return.get(), resultTypedAst); +// } + //TODO: fix +// +// @Test +// public void testVariableDefWithDecl() { +// TypedProgram resultTypedAst = Compiler.generateTypedASTFromAst(AST_VariableDefWithDecl.get()); +// assertEquals(TypedAST_VariableDefWithDecl.get(), resultTypedAst); +// } +// +// @Test +// public void testWhile() { +// TypedProgram resultTypedAst = Compiler.generateTypedASTFromAst(AST_While.get()); +// assertEquals(TypedAST_While.get(), resultTypedAst); +// } } diff --git a/src/main/java/testfiles/ASTFeatures/AST_Class.java b/src/test/java/testResources/AST/ASTFeatures/AST_Class.java similarity index 96% rename from src/main/java/testfiles/ASTFeatures/AST_Class.java rename to src/test/java/testResources/AST/ASTFeatures/AST_Class.java index 0ea4beb..642a608 100644 --- a/src/main/java/testfiles/ASTFeatures/AST_Class.java +++ b/src/test/java/testResources/AST/ASTFeatures/AST_Class.java @@ -1,4 +1,4 @@ -package testfiles.ASTFeatures; +package testResources.AST.ASTFeatures; import de.maishai.ast.records.Block; import de.maishai.ast.records.Constructor; diff --git a/src/main/java/testfiles/ASTFeatures/AST_ClassObjects.java b/src/test/java/testResources/AST/ASTFeatures/AST_ClassObjects.java similarity index 87% rename from src/main/java/testfiles/ASTFeatures/AST_ClassObjects.java rename to src/test/java/testResources/AST/ASTFeatures/AST_ClassObjects.java index 9f22ec5..a26f052 100644 --- a/src/main/java/testfiles/ASTFeatures/AST_ClassObjects.java +++ b/src/test/java/testResources/AST/ASTFeatures/AST_ClassObjects.java @@ -1,4 +1,4 @@ -package testfiles.ASTFeatures; +package testResources.AST.ASTFeatures; import de.maishai.ast.records.*; import de.maishai.ast.records.Class; @@ -14,8 +14,8 @@ public class AST_ClassObjects { "ClassObjects", List.of( new Declaration( - "c", - Type.CHAR + "b", + Type.REFERENCE("ClassObjects") ) ), getMethods(), @@ -66,19 +66,29 @@ public class AST_ClassObjects { "d", Type.REFERENCE("ClassObjects") ), + new Assignment( + new FieldVarAccess( + false, + null, + "d"), + new New( + Type.REFERENCE("ClassObjects"), + List.of() + ) + ), new Assignment( new FieldVarAccess( false, null, "c"), new FieldVarAccess( - true, + false, new FieldVarAccess( true, new FieldVarAccess( true, new FieldVarAccess( - false, + true, null, "d"), "b"), @@ -93,7 +103,7 @@ public class AST_ClassObjects { new FieldVarAccess( true, new FieldVarAccess( - false, + true, null, "c"), "b"), diff --git a/src/main/java/testfiles/ASTFeatures/AST_Comment.java b/src/test/java/testResources/AST/ASTFeatures/AST_Comment.java similarity index 96% rename from src/main/java/testfiles/ASTFeatures/AST_Comment.java rename to src/test/java/testResources/AST/ASTFeatures/AST_Comment.java index d5e7e3b..6edcf40 100644 --- a/src/main/java/testfiles/ASTFeatures/AST_Comment.java +++ b/src/test/java/testResources/AST/ASTFeatures/AST_Comment.java @@ -1,4 +1,4 @@ -package testfiles.ASTFeatures; +package testResources.AST.ASTFeatures; import de.maishai.ast.records.Block; import de.maishai.ast.records.Class; diff --git a/src/main/java/testfiles/ASTFeatures/AST_Constructor.java b/src/test/java/testResources/AST/ASTFeatures/AST_Constructor.java similarity index 99% rename from src/main/java/testfiles/ASTFeatures/AST_Constructor.java rename to src/test/java/testResources/AST/ASTFeatures/AST_Constructor.java index d949c42..3c7e3c9 100644 --- a/src/main/java/testfiles/ASTFeatures/AST_Constructor.java +++ b/src/test/java/testResources/AST/ASTFeatures/AST_Constructor.java @@ -1,4 +1,4 @@ -package testfiles.ASTFeatures; +package testResources.AST.ASTFeatures; import de.maishai.ast.Operator; import de.maishai.ast.records.*; diff --git a/src/main/java/testfiles/ASTFeatures/AST_Continue.java b/src/test/java/testResources/AST/ASTFeatures/AST_Continue.java similarity index 99% rename from src/main/java/testfiles/ASTFeatures/AST_Continue.java rename to src/test/java/testResources/AST/ASTFeatures/AST_Continue.java index eefa238..38afc3a 100644 --- a/src/main/java/testfiles/ASTFeatures/AST_Continue.java +++ b/src/test/java/testResources/AST/ASTFeatures/AST_Continue.java @@ -1,4 +1,4 @@ -package testfiles.ASTFeatures; +package testResources.AST.ASTFeatures; import de.maishai.ast.Operator; import de.maishai.ast.records.*; diff --git a/src/main/java/testfiles/ASTFeatures/AST_Field.java b/src/test/java/testResources/AST/ASTFeatures/AST_Field.java similarity index 98% rename from src/main/java/testfiles/ASTFeatures/AST_Field.java rename to src/test/java/testResources/AST/ASTFeatures/AST_Field.java index 9235936..26cdda2 100644 --- a/src/main/java/testfiles/ASTFeatures/AST_Field.java +++ b/src/test/java/testResources/AST/ASTFeatures/AST_Field.java @@ -1,4 +1,4 @@ -package testfiles.ASTFeatures; +package testResources.AST.ASTFeatures; import de.maishai.ast.records.*; import de.maishai.ast.records.Class; diff --git a/src/main/java/testfiles/ASTFeatures/AST_For.java b/src/test/java/testResources/AST/ASTFeatures/AST_For.java similarity index 99% rename from src/main/java/testfiles/ASTFeatures/AST_For.java rename to src/test/java/testResources/AST/ASTFeatures/AST_For.java index 9efb2ce..2cb9768 100644 --- a/src/main/java/testfiles/ASTFeatures/AST_For.java +++ b/src/test/java/testResources/AST/ASTFeatures/AST_For.java @@ -1,4 +1,4 @@ -package testfiles.ASTFeatures; +package testResources.AST.ASTFeatures; import de.maishai.ast.Operator; import de.maishai.ast.records.*; diff --git a/src/main/java/testfiles/ASTFeatures/AST_If.java b/src/test/java/testResources/AST/ASTFeatures/AST_If.java similarity index 98% rename from src/main/java/testfiles/ASTFeatures/AST_If.java rename to src/test/java/testResources/AST/ASTFeatures/AST_If.java index be14121..664a695 100644 --- a/src/main/java/testfiles/ASTFeatures/AST_If.java +++ b/src/test/java/testResources/AST/ASTFeatures/AST_If.java @@ -1,4 +1,4 @@ -package testfiles.ASTFeatures; +package testResources.AST.ASTFeatures; import de.maishai.ast.records.*; import de.maishai.ast.records.Class; diff --git a/src/main/java/testfiles/ASTFeatures/AST_IncrDecr.java b/src/test/java/testResources/AST/ASTFeatures/AST_IncrDecr.java similarity index 99% rename from src/main/java/testfiles/ASTFeatures/AST_IncrDecr.java rename to src/test/java/testResources/AST/ASTFeatures/AST_IncrDecr.java index 5601dc7..0817dfe 100644 --- a/src/main/java/testfiles/ASTFeatures/AST_IncrDecr.java +++ b/src/test/java/testResources/AST/ASTFeatures/AST_IncrDecr.java @@ -1,4 +1,4 @@ -package testfiles.ASTFeatures; +package testResources.AST.ASTFeatures; import de.maishai.ast.Operator; import de.maishai.ast.records.*; diff --git a/src/main/java/testfiles/ASTFeatures/AST_LogicExpr.java b/src/test/java/testResources/AST/ASTFeatures/AST_LogicExpr.java similarity index 99% rename from src/main/java/testfiles/ASTFeatures/AST_LogicExpr.java rename to src/test/java/testResources/AST/ASTFeatures/AST_LogicExpr.java index d66c800..2e74610 100644 --- a/src/main/java/testfiles/ASTFeatures/AST_LogicExpr.java +++ b/src/test/java/testResources/AST/ASTFeatures/AST_LogicExpr.java @@ -1,4 +1,4 @@ -package testfiles.ASTFeatures; +package testResources.AST.ASTFeatures; import de.maishai.ast.Operator; import de.maishai.ast.records.*; diff --git a/src/main/java/testfiles/ASTFeatures/AST_Method.java b/src/test/java/testResources/AST/ASTFeatures/AST_Method.java similarity index 97% rename from src/main/java/testfiles/ASTFeatures/AST_Method.java rename to src/test/java/testResources/AST/ASTFeatures/AST_Method.java index e1627e1..3bbb6f1 100644 --- a/src/main/java/testfiles/ASTFeatures/AST_Method.java +++ b/src/test/java/testResources/AST/ASTFeatures/AST_Method.java @@ -1,4 +1,4 @@ -package testfiles.ASTFeatures; +package testResources.AST.ASTFeatures; import de.maishai.ast.records.*; import de.maishai.ast.records.Class; diff --git a/src/main/java/testfiles/ASTFeatures/AST_MethodCall.java b/src/test/java/testResources/AST/ASTFeatures/AST_MethodCall.java similarity index 99% rename from src/main/java/testfiles/ASTFeatures/AST_MethodCall.java rename to src/test/java/testResources/AST/ASTFeatures/AST_MethodCall.java index 44b83db..761e2e4 100644 --- a/src/main/java/testfiles/ASTFeatures/AST_MethodCall.java +++ b/src/test/java/testResources/AST/ASTFeatures/AST_MethodCall.java @@ -1,4 +1,4 @@ -package testfiles.ASTFeatures; +package testResources.AST.ASTFeatures; import de.maishai.ast.Operator; import de.maishai.ast.records.*; diff --git a/src/test/java/testResources/AST/ASTFeatures/AST_MultipleClasses.java b/src/test/java/testResources/AST/ASTFeatures/AST_MultipleClasses.java new file mode 100644 index 0000000..e0a06ee --- /dev/null +++ b/src/test/java/testResources/AST/ASTFeatures/AST_MultipleClasses.java @@ -0,0 +1,5 @@ +package testResources.AST.ASTFeatures; + +public class AST_MultipleClasses { + +} \ No newline at end of file diff --git a/src/main/java/testfiles/ASTFeatures/AST_Operators.java b/src/test/java/testResources/AST/ASTFeatures/AST_Operators.java similarity index 99% rename from src/main/java/testfiles/ASTFeatures/AST_Operators.java rename to src/test/java/testResources/AST/ASTFeatures/AST_Operators.java index 949c112..82c53da 100644 --- a/src/main/java/testfiles/ASTFeatures/AST_Operators.java +++ b/src/test/java/testResources/AST/ASTFeatures/AST_Operators.java @@ -1,4 +1,4 @@ -package testfiles.ASTFeatures; +package testResources.AST.ASTFeatures; import de.maishai.ast.Operator; import de.maishai.ast.records.*; diff --git a/src/main/java/testfiles/ASTFeatures/AST_Overloaded.java b/src/test/java/testResources/AST/ASTFeatures/AST_Overloaded.java similarity index 99% rename from src/main/java/testfiles/ASTFeatures/AST_Overloaded.java rename to src/test/java/testResources/AST/ASTFeatures/AST_Overloaded.java index 022de6a..cacbb80 100644 --- a/src/main/java/testfiles/ASTFeatures/AST_Overloaded.java +++ b/src/test/java/testResources/AST/ASTFeatures/AST_Overloaded.java @@ -1,4 +1,4 @@ -package testfiles.ASTFeatures; +package testResources.AST.ASTFeatures; import de.maishai.ast.Operator; import de.maishai.ast.records.*; diff --git a/src/main/java/testfiles/ASTFeatures/AST_Print.java b/src/test/java/testResources/AST/ASTFeatures/AST_Print.java similarity index 99% rename from src/main/java/testfiles/ASTFeatures/AST_Print.java rename to src/test/java/testResources/AST/ASTFeatures/AST_Print.java index c114029..a5658fa 100644 --- a/src/main/java/testfiles/ASTFeatures/AST_Print.java +++ b/src/test/java/testResources/AST/ASTFeatures/AST_Print.java @@ -1,4 +1,4 @@ -package testfiles.ASTFeatures; +package testResources.AST.ASTFeatures; import de.maishai.ast.Operator; import de.maishai.ast.records.*; diff --git a/src/main/java/testfiles/ASTFeatures/AST_Return.java b/src/test/java/testResources/AST/ASTFeatures/AST_Return.java similarity index 99% rename from src/main/java/testfiles/ASTFeatures/AST_Return.java rename to src/test/java/testResources/AST/ASTFeatures/AST_Return.java index 007ce6a..6300382 100644 --- a/src/main/java/testfiles/ASTFeatures/AST_Return.java +++ b/src/test/java/testResources/AST/ASTFeatures/AST_Return.java @@ -1,4 +1,4 @@ -package testfiles.ASTFeatures; +package testResources.AST.ASTFeatures; import de.maishai.ast.records.*; import de.maishai.ast.records.Class; diff --git a/src/main/java/testfiles/ASTFeatures/AST_VariableDefWithDecl.java b/src/test/java/testResources/AST/ASTFeatures/AST_VariableDefWithDecl.java similarity index 98% rename from src/main/java/testfiles/ASTFeatures/AST_VariableDefWithDecl.java rename to src/test/java/testResources/AST/ASTFeatures/AST_VariableDefWithDecl.java index f374d7c..546ec84 100644 --- a/src/main/java/testfiles/ASTFeatures/AST_VariableDefWithDecl.java +++ b/src/test/java/testResources/AST/ASTFeatures/AST_VariableDefWithDecl.java @@ -1,4 +1,4 @@ -package testfiles.ASTFeatures; +package testResources.AST.ASTFeatures; import de.maishai.ast.records.*; import de.maishai.ast.records.Class; diff --git a/src/main/java/testfiles/ASTFeatures/AST_While.java b/src/test/java/testResources/AST/ASTFeatures/AST_While.java similarity index 99% rename from src/main/java/testfiles/ASTFeatures/AST_While.java rename to src/test/java/testResources/AST/ASTFeatures/AST_While.java index b248828..fb42c84 100644 --- a/src/main/java/testfiles/ASTFeatures/AST_While.java +++ b/src/test/java/testResources/AST/ASTFeatures/AST_While.java @@ -1,4 +1,4 @@ -package testfiles.ASTFeatures; +package testResources.AST.ASTFeatures; import de.maishai.ast.Operator; import de.maishai.ast.records.*; diff --git a/src/main/java/testfiles/ASTMore/AbstractSyntax_ClassWithConstructor.java b/src/test/java/testResources/AST/ASTMore/AbstractSyntax_ClassWithConstructor.java similarity index 99% rename from src/main/java/testfiles/ASTMore/AbstractSyntax_ClassWithConstructor.java rename to src/test/java/testResources/AST/ASTMore/AbstractSyntax_ClassWithConstructor.java index f65281d..31b5c91 100644 --- a/src/main/java/testfiles/ASTMore/AbstractSyntax_ClassWithConstructor.java +++ b/src/test/java/testResources/AST/ASTMore/AbstractSyntax_ClassWithConstructor.java @@ -1,4 +1,4 @@ -package testfiles.ASTMore;//public class ClassWithConstructor { +package testResources.AST.ASTMore;//public class ClassWithConstructor { // int x; // public classWithConstructor() { // this.x = 10; diff --git a/src/main/java/testfiles/ASTMore/AbstractSyntax_ClassWithConstructorAndMethodCall.java b/src/test/java/testResources/AST/ASTMore/AbstractSyntax_ClassWithConstructorAndMethodCall.java similarity index 98% rename from src/main/java/testfiles/ASTMore/AbstractSyntax_ClassWithConstructorAndMethodCall.java rename to src/test/java/testResources/AST/ASTMore/AbstractSyntax_ClassWithConstructorAndMethodCall.java index dd3e013..c30cda0 100644 --- a/src/main/java/testfiles/ASTMore/AbstractSyntax_ClassWithConstructorAndMethodCall.java +++ b/src/test/java/testResources/AST/ASTMore/AbstractSyntax_ClassWithConstructorAndMethodCall.java @@ -1,4 +1,4 @@ -package testfiles.ASTMore;//public class ClassWithConstructorAndMethodCall { +package testResources.AST.ASTMore;//public class ClassWithConstructorAndMethodCall { // int x; // // public ClassWithConstructorAndMethodCall() { diff --git a/src/main/java/testfiles/ASTMore/AbstractSyntax_ClassWithConstructorWithCodeInComments.java b/src/test/java/testResources/AST/ASTMore/AbstractSyntax_ClassWithConstructorWithCodeInComments.java similarity index 98% rename from src/main/java/testfiles/ASTMore/AbstractSyntax_ClassWithConstructorWithCodeInComments.java rename to src/test/java/testResources/AST/ASTMore/AbstractSyntax_ClassWithConstructorWithCodeInComments.java index 6816a59..3c10ba4 100644 --- a/src/main/java/testfiles/ASTMore/AbstractSyntax_ClassWithConstructorWithCodeInComments.java +++ b/src/test/java/testResources/AST/ASTMore/AbstractSyntax_ClassWithConstructorWithCodeInComments.java @@ -1,4 +1,4 @@ -package testfiles.ASTMore;//public class ClassWithConstructorWithCodeInComments { +package testResources.AST.ASTMore;//public class ClassWithConstructorWithCodeInComments { // int x; // public ClassWithConstructorWithCodeInComments() { // this.x = 10; diff --git a/src/main/java/testfiles/ASTMore/AbstractSyntax_ClassWithConstructorWithParameters.java b/src/test/java/testResources/AST/ASTMore/AbstractSyntax_ClassWithConstructorWithParameters.java similarity index 99% rename from src/main/java/testfiles/ASTMore/AbstractSyntax_ClassWithConstructorWithParameters.java rename to src/test/java/testResources/AST/ASTMore/AbstractSyntax_ClassWithConstructorWithParameters.java index 332dda0..46ee1b6 100644 --- a/src/main/java/testfiles/ASTMore/AbstractSyntax_ClassWithConstructorWithParameters.java +++ b/src/test/java/testResources/AST/ASTMore/AbstractSyntax_ClassWithConstructorWithParameters.java @@ -1,4 +1,4 @@ -package testfiles.ASTMore;//public class ClassWithConstructorWithParameters { +package testResources.AST.ASTMore;//public class ClassWithConstructorWithParameters { // int x; // public ClassWithConstructorWithParameters(int startValue, int repetitions) { // this.x = startValue; diff --git a/src/main/java/testfiles/ASTMore/AbstractSyntax_ClassWithField.java b/src/test/java/testResources/AST/ASTMore/AbstractSyntax_ClassWithField.java similarity index 94% rename from src/main/java/testfiles/ASTMore/AbstractSyntax_ClassWithField.java rename to src/test/java/testResources/AST/ASTMore/AbstractSyntax_ClassWithField.java index 6c12c0d..c9a4bb4 100644 --- a/src/main/java/testfiles/ASTMore/AbstractSyntax_ClassWithField.java +++ b/src/test/java/testResources/AST/ASTMore/AbstractSyntax_ClassWithField.java @@ -1,4 +1,4 @@ -package testfiles.ASTMore;//public class ClassWithField { +package testResources.AST.ASTMore;//public class ClassWithField { // int x; //} diff --git a/src/main/java/testfiles/ASTMore/AbstractSyntax_ClassWithMethod.java b/src/test/java/testResources/AST/ASTMore/AbstractSyntax_ClassWithMethod.java similarity index 95% rename from src/main/java/testfiles/ASTMore/AbstractSyntax_ClassWithMethod.java rename to src/test/java/testResources/AST/ASTMore/AbstractSyntax_ClassWithMethod.java index dd1a6c2..aba8155 100644 --- a/src/main/java/testfiles/ASTMore/AbstractSyntax_ClassWithMethod.java +++ b/src/test/java/testResources/AST/ASTMore/AbstractSyntax_ClassWithMethod.java @@ -1,4 +1,4 @@ -package testfiles.ASTMore;//public class ClassWithMethod { +package testResources.AST.ASTMore;//public class ClassWithMethod { // public boolean method() { // return false; // } diff --git a/src/main/java/testfiles/ASTMore/AbstractSyntax_ClassWithMethodAndField.java b/src/test/java/testResources/AST/ASTMore/AbstractSyntax_ClassWithMethodAndField.java similarity index 97% rename from src/main/java/testfiles/ASTMore/AbstractSyntax_ClassWithMethodAndField.java rename to src/test/java/testResources/AST/ASTMore/AbstractSyntax_ClassWithMethodAndField.java index 4ed490b..f6aed4c 100644 --- a/src/main/java/testfiles/ASTMore/AbstractSyntax_ClassWithMethodAndField.java +++ b/src/test/java/testResources/AST/ASTMore/AbstractSyntax_ClassWithMethodAndField.java @@ -1,4 +1,4 @@ -package testfiles.ASTMore;//public class ClassWithMethodAndField { +package testResources.AST.ASTMore;//public class ClassWithMethodAndField { // char c; // // public ClassWithMethodAndField(char character) { diff --git a/src/main/java/testfiles/ASTMore/AbstractSyntax_ClassWithMultipleMethods.java b/src/test/java/testResources/AST/ASTMore/AbstractSyntax_ClassWithMultipleMethods.java similarity index 98% rename from src/main/java/testfiles/ASTMore/AbstractSyntax_ClassWithMultipleMethods.java rename to src/test/java/testResources/AST/ASTMore/AbstractSyntax_ClassWithMultipleMethods.java index cd1310a..dfa77a0 100644 --- a/src/main/java/testfiles/ASTMore/AbstractSyntax_ClassWithMultipleMethods.java +++ b/src/test/java/testResources/AST/ASTMore/AbstractSyntax_ClassWithMultipleMethods.java @@ -1,4 +1,4 @@ -package testfiles.ASTMore;//public class ClassWithMoreComplexMethodAndMain { +package testResources.AST.ASTMore;//public class ClassWithMoreComplexMethodAndMain { // ClassWithMoreComplexMethodAndMain instance; // // public boolean moreComplexMethod() { diff --git a/src/main/java/testfiles/ASTMore/AbstractSyntax_ComplexClass.java b/src/test/java/testResources/AST/ASTMore/AbstractSyntax_ComplexClass.java similarity index 99% rename from src/main/java/testfiles/ASTMore/AbstractSyntax_ComplexClass.java rename to src/test/java/testResources/AST/ASTMore/AbstractSyntax_ComplexClass.java index eea629d..7f1c631 100644 --- a/src/main/java/testfiles/ASTMore/AbstractSyntax_ComplexClass.java +++ b/src/test/java/testResources/AST/ASTMore/AbstractSyntax_ComplexClass.java @@ -1,4 +1,4 @@ -package testfiles.ASTMore;//public class ComplexClass { +package testResources.AST.ASTMore;//public class ComplexClass { // // int x; // int y; diff --git a/src/main/java/testfiles/ASTMore/AbstractSyntax_PublicClass.java b/src/test/java/testResources/AST/ASTMore/AbstractSyntax_PublicClass.java similarity index 94% rename from src/main/java/testfiles/ASTMore/AbstractSyntax_PublicClass.java rename to src/test/java/testResources/AST/ASTMore/AbstractSyntax_PublicClass.java index 915cfe0..e3fc937 100644 --- a/src/main/java/testfiles/ASTMore/AbstractSyntax_PublicClass.java +++ b/src/test/java/testResources/AST/ASTMore/AbstractSyntax_PublicClass.java @@ -1,4 +1,4 @@ -package testfiles.ASTMore;//public class PublicClass { +package testResources.AST.ASTMore;//public class PublicClass { //} import de.maishai.ast.records.Block; diff --git a/src/test/java/testResources/typedAST/TypedASTFeatures/TypedAST_Class.java b/src/test/java/testResources/typedAST/TypedASTFeatures/TypedAST_Class.java new file mode 100644 index 0000000..c9a7699 --- /dev/null +++ b/src/test/java/testResources/typedAST/TypedASTFeatures/TypedAST_Class.java @@ -0,0 +1,40 @@ +package testResources.typedAST.TypedASTFeatures; + +import de.maishai.typedast.Type; +import de.maishai.typedast.typedclass.TypedBlock; +import de.maishai.typedast.typedclass.TypedClass; +import de.maishai.typedast.typedclass.TypedConstructor; +import de.maishai.typedast.typedclass.TypedProgram; + +import java.util.List; + +public class TypedAST_Class { + public static TypedProgram get() { + return new TypedProgram( + List.of( + new TypedClass( + "Class", + List.of(), + List.of(), + List.of( + new TypedConstructor( + "Class", + List.of(), + new TypedBlock( + List.of(), + List.of(), + Type.VOID + ), + Type.VOID, + List.of() + ) + ), + null, + null, + Type.REFERENCE("Class") + ) + ), + null + ); + } +} \ No newline at end of file diff --git a/src/test/java/testResources/typedAST/TypedASTFeatures/TypedAST_ClassObjects.java b/src/test/java/testResources/typedAST/TypedASTFeatures/TypedAST_ClassObjects.java new file mode 100644 index 0000000..3943970 --- /dev/null +++ b/src/test/java/testResources/typedAST/TypedASTFeatures/TypedAST_ClassObjects.java @@ -0,0 +1,163 @@ +package testResources.typedAST.TypedASTFeatures; + +import de.maishai.typedast.Type; +import de.maishai.typedast.typedclass.*; + +import java.util.List; + +public class TypedAST_ClassObjects { + public static TypedProgram get() { + return new TypedProgram( + List.of( + new TypedClass( + "ClassObjects", + List.of( + new TypedDeclaration( + "b", + Type.REFERENCE("ClassObjects") + ) + ), + List.of( + new TypedMethod( + "objectsMethod", + Type.VOID, + List.of(), + List.of(new TypedLocalVariable( + "c", + Type.REFERENCE("ClassObjects") + ), + new TypedLocalVariable( + "d", + Type.REFERENCE("ClassObjects") + ) + ), + new TypedBlock( + List.of(), + List.of( + new TypedAssignment( + new TypedNew( + Type.REFERENCE("ClassObjects"), + List.of() + ), + new TypedFieldVarAccess( + true, + null, + "b", + Type.REFERENCE("ClassObjects")), + Type.VOID + ), + new TypedAssignment( + new TypedNew( + Type.REFERENCE("ClassObjects"), + List.of( + new TypedIntLiteral(2) + ) + ), + new TypedFieldVarAccess( + false, + null, + "c", + Type.REFERENCE("ClassObjects")), + Type.VOID + ), + new TypedAssignment( + new TypedNew( + Type.REFERENCE("ClassObjects"), + List.of() + ), + new TypedFieldVarAccess( + false, + null, + "d", + Type.REFERENCE("ClassObjects")), + Type.VOID + ), + new TypedAssignment( + new TypedFieldVarAccess( + false, + new TypedFieldVarAccess( + true, + new TypedFieldVarAccess( + true, + new TypedFieldVarAccess( + true, + null, + "d", + Type.REFERENCE("ClassObjects")), + "b", + Type.REFERENCE("ClassObjects")), + "b", + Type.REFERENCE("ClassObjects")), + "b", + Type.REFERENCE("ClassObjects")), + new TypedFieldVarAccess( + false, + null, + "c", + Type.REFERENCE("ClassObjects")), + Type.VOID + ), + new TypedMethodCall( + new TypedFieldVarAccess( + false, + new TypedFieldVarAccess( + true, + new TypedFieldVarAccess( + true, + new TypedFieldVarAccess( + true, + null, + "c", + Type.REFERENCE("ClassObjects")), + "b", + Type.REFERENCE("ClassObjects")), + "b", + Type.REFERENCE("ClassObjects")), + "objectsMethod", + Type.VOID), + List.of(), + Type.VOID + ) + ), + Type.VOID + ) + ) + ), + List.of( + new TypedConstructor( + "ClassObjects", + List.of(), + new TypedBlock( + List.of(), + List.of(), + Type.VOID + ), + Type.REFERENCE("ClassObjects"), + List.of() + ), + new TypedConstructor( + "ClassObjects", + List.of( + new TypedParameter( + "a", + Type.INT + ) + ), + new TypedBlock( + List.of(), + List.of(), + Type.VOID + ), + Type.REFERENCE("ClassObjects"), + List.of() + ) + ), + null, + null, + Type.REFERENCE("ClassObjects") + ) + ), + null + ); + } +} \ No newline at end of file diff --git a/src/test/java/testResources/typedAST/TypedASTFeatures/TypedAST_Comment.java b/src/test/java/testResources/typedAST/TypedASTFeatures/TypedAST_Comment.java new file mode 100644 index 0000000..d56d3a4 --- /dev/null +++ b/src/test/java/testResources/typedAST/TypedASTFeatures/TypedAST_Comment.java @@ -0,0 +1,44 @@ +package testResources.typedAST.TypedASTFeatures; + +import de.maishai.ast.records.Block; +import de.maishai.ast.records.Class; +import de.maishai.ast.records.Constructor; +import de.maishai.ast.records.Program; +import de.maishai.typedast.Type; +import de.maishai.typedast.typedclass.TypedBlock; +import de.maishai.typedast.typedclass.TypedClass; +import de.maishai.typedast.typedclass.TypedConstructor; +import de.maishai.typedast.typedclass.TypedProgram; + +import java.util.List; + +public class TypedAST_Comment { + public static TypedProgram get() { + return new TypedProgram( + List.of( + new TypedClass( + "Comment", + List.of(), + List.of(), + List.of( + new TypedConstructor( + "Comment", + List.of(), + new TypedBlock( + List.of(), + List.of(), + Type.VOID + ), + Type.VOID, + List.of() + ) + ), + null, + null, + Type.REFERENCE("Comment") + ) + ), + null + ); + } +} \ No newline at end of file diff --git a/src/test/java/testResources/typedAST/TypedASTFeatures/TypedAST_Constructor.java b/src/test/java/testResources/typedAST/TypedASTFeatures/TypedAST_Constructor.java new file mode 100644 index 0000000..8eb080d --- /dev/null +++ b/src/test/java/testResources/typedAST/TypedASTFeatures/TypedAST_Constructor.java @@ -0,0 +1,146 @@ +package testResources.typedAST.TypedASTFeatures; + +import de.maishai.ast.Operator; +import de.maishai.ast.records.Class; +import de.maishai.ast.records.*; +import de.maishai.typedast.Type; +import de.maishai.typedast.typedclass.*; + +import java.util.List; + +public class TypedAST_Constructor { + public static TypedProgram get() { + return new TypedProgram( + List.of( + new TypedClass( + "Constructor", + List.of(), + List.of(), + List.of( + new TypedConstructor( + "Constructor", + List.of(), + new TypedBlock( + List.of( + new TypedLocalVariable( + "i", + Type.INT + ) + ), + List.of( + new TypedAssignment( + new TypedIntLiteral( + 1, + Type.INT), + new TypedFieldVarAccess( + false, + null, + "i", + Type.INT + ), + Type.INT + ) + ), + Type.VOID + ), + Type.VOID, + List.of() + ), + new TypedConstructor( + "Constructor", + List.of( + new TypedParameter( + "x", + Type.INT + ) + ), + new TypedBlock( + List.of( + new TypedLocalVariable( + "i", + Type.INT + ) + ), + List.of( + new TypedAssignment( + new TypedFieldVarAccess( + false, + null, + "x", + Type.INT + ), + new TypedFieldVarAccess( + false, + null, + "i", + Type.INT + ), + Type.INT + ) + ), + Type.VOID + ), + Type.VOID, + List.of() + ), + new TypedConstructor( + "Constructor", + List.of( + new TypedParameter( + "x", + Type.INT + ), + new TypedParameter( + "y", + Type.INT + ) + ), + new TypedBlock( + List.of( + new TypedLocalVariable( + "i", + Type.INT + ) + ), + List.of( + new TypedAssignment( + new TypedBinary( + new TypedFieldVarAccess( + false, + null, + "x", + Type.INT + ), + Operator.ADD, + new TypedFieldVarAccess( + false, + null, + "y", + Type.INT + ), + Type.INT + ), + new TypedFieldVarAccess( + false, + null, + "i", + Type.INT + ), + Type.INT + ) + ), + Type.VOID + ), + Type.VOID, + List.of() + ) + ), + null, + null, + Type.REFERENCE("Constructor") + ) + ), + null + ); + } +} \ No newline at end of file diff --git a/src/test/java/testResources/typedAST/TypedASTFeatures/TypedAST_Continue.java b/src/test/java/testResources/typedAST/TypedASTFeatures/TypedAST_Continue.java new file mode 100644 index 0000000..a6cdcb8 --- /dev/null +++ b/src/test/java/testResources/typedAST/TypedASTFeatures/TypedAST_Continue.java @@ -0,0 +1,103 @@ +package testResources.typedAST.TypedASTFeatures; + +import de.maishai.ast.Operator; +import de.maishai.ast.records.Class; +import de.maishai.ast.records.*; +import de.maishai.typedast.Type; + +import java.util.List; + +public class TypedAST_Continue { + public static Program get() { + return new Program( + List.of( + new Class( + "Continue", + List.of(), + List.of( + new Method( + Type.VOID, + "continueLoop", + List.of(), + new Block( + List.of( + new Declaration( + "i", + Type.INT + ), + new For( + new Assignment( + new FieldVarAccess( + false, + null, + "i" + ), + new IntLiteral(0) + ), + new Binary( + new FieldVarAccess( + false, + null, + "i" + ), + Operator.LT, + new IntLiteral(5) + ), + new Assignment( + new FieldVarAccess( + false, + null, + "i" + ), + new Binary( + new FieldVarAccess( + false, + null, + "i" + ), + Operator.ADD, + new IntLiteral(1) + ) + + ), + new Block( + List.of( + new IfElse( + new Binary( + new FieldVarAccess( + false, + null, + "i" + ), + Operator.EQ, + new IntLiteral(3) + ), + new Block( + List.of( + new Continue() + ) + ), + null + ) + ) + ) + ) + ) + ) + ) + ), + List.of( + new Constructor( + "Continue", + List.of(), + new Block( + List.of( + ) + ) + ) + ) + ) + ) + ); + } +} \ No newline at end of file diff --git a/src/test/java/testResources/typedAST/TypedASTFeatures/TypedAST_Field.java b/src/test/java/testResources/typedAST/TypedASTFeatures/TypedAST_Field.java new file mode 100644 index 0000000..1bab774 --- /dev/null +++ b/src/test/java/testResources/typedAST/TypedASTFeatures/TypedAST_Field.java @@ -0,0 +1,66 @@ +package testResources.typedAST.TypedASTFeatures; + +import de.maishai.ast.records.Class; +import de.maishai.ast.records.*; +import de.maishai.typedast.Type; + +import java.util.List; + +public class TypedAST_Field { + public static Program get() { + return new Program( + List.of( + new Class( + "Field", + List.of( + new Declaration( + "x", + Type.INT + ), + new Declaration( + "c", + Type.CHAR + ) + ), + List.of( + new Method( + Type.VOID, + "fieldAccess", + List.of(), + new Block( + List.of( + new Assignment( + new FieldVarAccess( + true, + null, + "x" + ), + new IntLiteral(0) + ), + new Assignment( + new FieldVarAccess( + true, + null, + "c" + ), + new CharLiteral('a') + ) + ) + ) + ) + ), + List.of( + new Constructor( + "Field", + List.of(), + new Block( + List.of() + ) + ) + + ) + ) + ) + ); + } +} \ No newline at end of file diff --git a/src/test/java/testResources/typedAST/TypedASTFeatures/TypedAST_For.java b/src/test/java/testResources/typedAST/TypedASTFeatures/TypedAST_For.java new file mode 100644 index 0000000..bc22fb7 --- /dev/null +++ b/src/test/java/testResources/typedAST/TypedASTFeatures/TypedAST_For.java @@ -0,0 +1,127 @@ +package testResources.typedAST.TypedASTFeatures; + +import de.maishai.ast.Operator; +import de.maishai.ast.records.Class; +import de.maishai.ast.records.*; +import de.maishai.typedast.Type; + +import java.util.List; + +public class TypedAST_For { + public static Program get() { + return new Program( + List.of( + new Class( + "For", + List.of(), + List.of( + new Method( + Type.VOID, + "testFor", + List.of(), + new Block( + List.of( + new Declaration( + "i", + Type.INT + ), + new For( + new Assignment( + new FieldVarAccess( + false, + null, + "i" + ), + new IntLiteral(0) + ), + new Binary( + new FieldVarAccess( + false, + null, + "i" + ), + Operator.LT, + new IntLiteral(10) + ), + new Assignment( + new FieldVarAccess( + false, + null, + "i" + ), + new Binary( + new FieldVarAccess( + false, + null, + "i" + ), + Operator.ADD, + new IntLiteral(1) + ) + ), + new Block( + List.of() + ) + ), + new Declaration( + "j", + Type.INT + ), + new For( + new Assignment( + new FieldVarAccess( + false, + null, + "j" + ), + new IntLiteral(0) + ), + new Binary( + new FieldVarAccess( + false, + null, + "j" + ), + Operator.LT, + new IntLiteral(10) + ), + new Assignment( + new FieldVarAccess( + false, + null, + "j" + ), + new Binary( + new FieldVarAccess( + false, + null, + "j" + ), + Operator.ADD, + new IntLiteral(1) + ) + ), + new Block( + List.of() + ) + ) + ) + ) + ) + ), + List.of( + new Constructor( + "For", + List.of(), + new Block( + List.of( + ) + ) + + ) + ) + ) + ) + ); + } +} \ No newline at end of file diff --git a/src/test/java/testResources/typedAST/TypedASTFeatures/TypedAST_If.java b/src/test/java/testResources/typedAST/TypedASTFeatures/TypedAST_If.java new file mode 100644 index 0000000..1bc4729 --- /dev/null +++ b/src/test/java/testResources/typedAST/TypedASTFeatures/TypedAST_If.java @@ -0,0 +1,61 @@ +package testResources.typedAST.TypedASTFeatures; + +import de.maishai.ast.records.Class; +import de.maishai.ast.records.*; +import de.maishai.typedast.Type; + +import java.util.List; + +public class TypedAST_If { + public static Program get() { + return new Program( + List.of( + new Class( + "If", + List.of(), + List.of( + new Method( + Type.VOID, + "ifMethod", + List.of(), + new Block( + List.of( + new IfElse( + new BoolLiteral(false), + new Block( + List.of() + ), + new Block( + List.of( + new IfElse( + new BoolLiteral(true), + new Block( + List.of() + ), + new Block( + List.of() + ) + ) + ) + ) + + ) + ) + ) + ) + ), + List.of( + new Constructor( + "If", + List.of(), + new Block( + List.of( + ) + ) + ) + ) + ) + ) + ); + } +} \ No newline at end of file diff --git a/src/test/java/testResources/typedAST/TypedASTFeatures/TypedAST_IncrDecr.java b/src/test/java/testResources/typedAST/TypedASTFeatures/TypedAST_IncrDecr.java new file mode 100644 index 0000000..a403e5d --- /dev/null +++ b/src/test/java/testResources/typedAST/TypedASTFeatures/TypedAST_IncrDecr.java @@ -0,0 +1,86 @@ +package testResources.typedAST.TypedASTFeatures; + +import de.maishai.ast.Operator; +import de.maishai.ast.records.Class; +import de.maishai.ast.records.*; +import de.maishai.typedast.Type; + +import java.util.List; + +public class TypedAST_IncrDecr { + public static Program get() { + return new Program( + List.of( + new Class( + "IncrDecr", + List.of(), + List.of( + new Method( + Type.INT, + "increment", + List.of( + new Parameter( + "a", + Type.INT + ) + ), + new Block( + List.of( + new Return( + new Binary( + new FieldVarAccess( + false, + null, + "x" + ), + Operator.ADD, + new IntLiteral( + 1 + ) + ) + ) + ) + ) + ), + new Method( + Type.INT, + "decrement", + List.of( + new Parameter( + "a", + Type.INT + ) + ), + new Block( + List.of( + new Return( + new Binary( + new FieldVarAccess( + false, + null, + "a" + ), + Operator.SUB, + new IntLiteral( + 1 + ) + ) + ) + ) + ) + ) + ), + List.of( + new Constructor( + "IncrDecr", + List.of(), + new Block( + List.of() + ) + ) + ) + ) + ) + ); + } +} \ No newline at end of file diff --git a/src/test/java/testResources/typedAST/TypedASTFeatures/TypedAST_LogicExpr.java b/src/test/java/testResources/typedAST/TypedASTFeatures/TypedAST_LogicExpr.java new file mode 100644 index 0000000..a2526f6 --- /dev/null +++ b/src/test/java/testResources/typedAST/TypedASTFeatures/TypedAST_LogicExpr.java @@ -0,0 +1,332 @@ +package testResources.typedAST.TypedASTFeatures; + +import de.maishai.ast.Operator; +import de.maishai.ast.records.Class; +import de.maishai.ast.records.*; +import de.maishai.typedast.Type; + +import java.util.List; + +public class TypedAST_LogicExpr { + public static Program get() { + return new Program( + List.of( + new Class( + "LogicExpr", + List.of(), + List.of( + new Method( + Type.BOOL, + "test", + List.of(), + new Block( + List.of( + new Declaration( + "x", + Type.INT + ), + new Assignment( + new FieldVarAccess( + false, + null, + "x" + ), + new IntLiteral(10) + ), + new Declaration( + "y", + Type.INT + ), + new Assignment( + new FieldVarAccess( + false, + null, + "y" + ), + new IntLiteral(20) + ), + new Return( + new Binary( + new FieldVarAccess( + false, + null, + "x" + ), + Operator.LT, + new FieldVarAccess( + false, + null, + "y" + ) + ) + + ) + ) + ) + + ), + new Method( + Type.BOOL, + "test2", + List.of(), + new Block( + List.of( + new Declaration( + "x", + Type.INT + ), + new Assignment( + new FieldVarAccess( + false, + null, + "x" + ), + new IntLiteral(10) + ), + new Declaration( + "y", + Type.INT + ), + new Assignment( + new FieldVarAccess( + false, + null, + "y" + ), + new IntLiteral(20) + ), + new Return( + new Binary( + new FieldVarAccess( + false, + null, + "x" + ), + Operator.GT, + new FieldVarAccess( + false, + null, + "y" + ) + ) + + ) + ) + ) + + ), + new Method( + Type.BOOL, + "test3", + List.of(), + new Block( + List.of( + new Declaration( + "x", + Type.INT + ), + new Assignment( + new FieldVarAccess( + false, + null, + "x" + ), + new IntLiteral(10) + ), + new Declaration( + "y", + Type.INT + ), + new Assignment( + new FieldVarAccess( + false, + null, + "y" + ), + new IntLiteral(20) + ), + new Return( + new Binary( + new FieldVarAccess( + false, + null, + "x" + ), + Operator.EQ, + new FieldVarAccess( + false, + null, + "y" + ) + ) + + ) + ) + ) + + ), + new Method( + Type.BOOL, + "test4", + List.of(), + new Block( + List.of( + new Declaration( + "x", + Type.INT + ), + new Assignment( + new FieldVarAccess( + false, + null, + "x" + ), + new IntLiteral(10) + ), + new Declaration( + "y", + Type.INT + ), + new Assignment( + new FieldVarAccess( + false, + null, + "y" + ), + new IntLiteral(20) + ), + new Return( + new Binary( + new FieldVarAccess( + false, + null, + "x" + ), + Operator.NE, + new FieldVarAccess( + false, + null, + "y" + ) + ) + + ) + ) + ) + + ), + new Method( + Type.BOOL, + "test5", + List.of(), + new Block( + List.of( + new Declaration( + "x", + Type.INT + ), + new Assignment( + new FieldVarAccess( + false, + null, + "x" + ), + new IntLiteral(10) + ), + new Declaration( + "y", + Type.INT + ), + new Assignment( + new FieldVarAccess( + false, + null, + "y" + ), + new IntLiteral(20) + ), + new Return( + new Binary( + new FieldVarAccess( + false, + null, + "x" + ), + Operator.LE, + new FieldVarAccess( + false, + null, + "y" + ) + ) + + ) + ) + ) + + ), + new Method( + Type.BOOL, + "test6", + List.of(), + new Block( + List.of( + new Declaration( + "x", + Type.INT + ), + new Assignment( + new FieldVarAccess( + false, + null, + "x" + ), + new IntLiteral(10) + ), + new Declaration( + "y", + Type.INT + ), + new Assignment( + new FieldVarAccess( + false, + null, + "y" + ), + new IntLiteral(20) + ), + new Return( + new Binary( + new FieldVarAccess( + false, + null, + "x" + ), + Operator.GE, + new FieldVarAccess( + false, + null, + "y" + ) + ) + + ) + ) + ) + + ) + ), + List.of( + new Constructor( + "LogicExpr", + List.of(), + new Block( + List.of() + ) + ) + ) + ) + ) + ); + } +} \ No newline at end of file diff --git a/src/test/java/testResources/typedAST/TypedASTFeatures/TypedAST_Method.java b/src/test/java/testResources/typedAST/TypedASTFeatures/TypedAST_Method.java new file mode 100644 index 0000000..6a501fe --- /dev/null +++ b/src/test/java/testResources/typedAST/TypedASTFeatures/TypedAST_Method.java @@ -0,0 +1,39 @@ +package testResources.typedAST.TypedASTFeatures; + +import de.maishai.ast.records.Class; +import de.maishai.ast.records.*; +import de.maishai.typedast.Type; + +import java.util.List; + +public class TypedAST_Method { + public static Program get() { + return new Program( + List.of( + new Class( + "Method", + List.of(), + List.of( + new Method( + Type.VOID, + "method", + List.of(), + new Block( + List.of() + ) + ) + ), + List.of( + new Constructor( + "Method", + List.of(), + new Block( + List.of() + ) + ) + ) + ) + ) + ); + } +} \ No newline at end of file diff --git a/src/test/java/testResources/typedAST/TypedASTFeatures/TypedAST_MethodCall.java b/src/test/java/testResources/typedAST/TypedASTFeatures/TypedAST_MethodCall.java new file mode 100644 index 0000000..48891b5 --- /dev/null +++ b/src/test/java/testResources/typedAST/TypedASTFeatures/TypedAST_MethodCall.java @@ -0,0 +1,160 @@ +package testResources.typedAST.TypedASTFeatures; + +import de.maishai.ast.Operator; +import de.maishai.ast.records.Class; +import de.maishai.ast.records.*; +import de.maishai.typedast.Type; + +import java.util.List; + +public class TypedAST_MethodCall { + public static Program get() { + return new Program( + List.of( + new Class( + "MethodCall", + List.of(), + List.of( + new Method( + Type.INT, + "methodCall", + List.of(), + new Block( + List.of( + new Return( + new MethodCall( + new FieldVarAccess( + false, + null, + "method" + ), + List.of() + ) + ) + ) + ) + ), + new Method( + Type.INT, + "methodCall1", + List.of(), + new Block( + List.of( + new Return( + new MethodCall( + new FieldVarAccess( + false, + null, + "method1" + ), + List.of( + new IntLiteral(1) + ) + ) + ) + ) + ) + ), + new Method( + Type.INT, + "methodCall2", + List.of(), + new Block( + List.of( + new Return( + new MethodCall( + new FieldVarAccess( + false, + null, + "method2" + ), + List.of( + new IntLiteral(1), + new IntLiteral(2) + ) + ) + ) + ) + ) + ), + new Method( + Type.INT, + "method", + List.of(), + new Block( + List.of( + new Return( + new IntLiteral(0) + ) + ) + ) + ), + new Method( + Type.INT, + "method1", + List.of( + new Parameter( + "x", + Type.INT + ) + ), + new Block( + List.of( + new Return( + new FieldVarAccess( + false, + null, + "x" + ) + ) + ) + ) + ), + new Method( + Type.INT, + "method2", + List.of( + new Parameter( + "x", + Type.INT + ), + new Parameter( + "y", + Type.INT + ) + ), + new Block( + List.of( + new Return( + new Binary( + new FieldVarAccess( + false, + null, + "x" + ), + Operator.ADD, + new FieldVarAccess( + false, + null, + "y" + ) + ) + ) + ) + ) + ) + ), + List.of( + new Constructor( + "MethodCall", + List.of(), + new Block( + List.of() + ) + ) + ) + ) + ) + ); + } +} \ No newline at end of file diff --git a/src/test/java/testResources/typedAST/TypedASTFeatures/TypedAST_MultipleClasses.java b/src/test/java/testResources/typedAST/TypedASTFeatures/TypedAST_MultipleClasses.java new file mode 100644 index 0000000..2c6aa85 --- /dev/null +++ b/src/test/java/testResources/typedAST/TypedASTFeatures/TypedAST_MultipleClasses.java @@ -0,0 +1,5 @@ +package testResources.typedAST.TypedASTFeatures; + +public class TypedAST_MultipleClasses { + +} \ No newline at end of file diff --git a/src/test/java/testResources/typedAST/TypedASTFeatures/TypedAST_Operators.java b/src/test/java/testResources/typedAST/TypedASTFeatures/TypedAST_Operators.java new file mode 100644 index 0000000..1739a73 --- /dev/null +++ b/src/test/java/testResources/typedAST/TypedASTFeatures/TypedAST_Operators.java @@ -0,0 +1,198 @@ +package testResources.typedAST.TypedASTFeatures; + +import de.maishai.ast.Operator; +import de.maishai.ast.records.Class; +import de.maishai.ast.records.*; +import de.maishai.typedast.Type; + +import java.util.List; + + +public class TypedAST_Operators { + public static Program get() { + return new Program( + List.of( + new Class( + "Operators", + List.of(), + List.of( + new Method( + Type.INT, + "add", + List.of( + new Parameter( + "a", + Type.INT + ), + new Parameter( + "b", + Type.INT + ) + ), + new Block( + List.of( + new Return( + new Binary( + new FieldVarAccess( + false, + null, + "a" + ), + Operator.ADD, + new FieldVarAccess( + false, + null, + "b" + ) + ) + ) + ) + ) + ), + new Method( + Type.INT, + "sub", + List.of( + new Parameter( + "a", + Type.INT + ), + new Parameter( + "b", + Type.INT + ) + ), + new Block( + List.of( + new Return( + new Binary( + new FieldVarAccess( + false, + null, + "a" + ), + Operator.SUB, + new FieldVarAccess( + false, + null, + "b" + ) + ) + ) + ) + ) + ), + new Method( + Type.INT, + "mul", + List.of( + new Parameter( + "a", + Type.INT + ), + new Parameter( + "b", + Type.INT + ) + ), + new Block( + List.of( + new Return( + new Binary( + new FieldVarAccess( + false, + null, + "a" + ), + Operator.MUL, + new FieldVarAccess( + false, + null, + "b" + ) + ) + ) + ) + ) + ), + new Method( + Type.INT, + "div", + List.of( + new Parameter( + "a", + Type.INT + ), + new Parameter( + "b", + Type.INT + ) + ), + new Block( + List.of( + new Return( + new Binary( + new FieldVarAccess( + false, + null, + "a" + ), + Operator.DIV, + new FieldVarAccess( + false, + null, + "b" + ) + ) + ) + ) + ) + ), + new Method( + Type.INT, + "mod", + List.of( + new Parameter( + "a", + Type.INT + ), + new Parameter( + "b", + Type.INT + ) + ), + new Block( + List.of( + new Return( + new Binary( + new FieldVarAccess( + false, + null, + "a" + ), + Operator.MOD, + new FieldVarAccess( + false, + null, + "b" + ) + ) + ) + ) + ) + ) + ), + List.of( + new Constructor( + "Operators", + List.of(), + new Block( + List.of() + ) + ) + ) + ) + ) + ); + } +} \ No newline at end of file diff --git a/src/test/java/testResources/typedAST/TypedASTFeatures/TypedAST_Overloaded.java b/src/test/java/testResources/typedAST/TypedASTFeatures/TypedAST_Overloaded.java new file mode 100644 index 0000000..905f16a --- /dev/null +++ b/src/test/java/testResources/typedAST/TypedASTFeatures/TypedAST_Overloaded.java @@ -0,0 +1,98 @@ +package testResources.typedAST.TypedASTFeatures; + +import de.maishai.ast.Operator; +import de.maishai.ast.records.Class; +import de.maishai.ast.records.*; +import de.maishai.typedast.Type; + +import java.util.List; + +public class TypedAST_Overloaded { + public static Program get() { + return new Program( + List.of( + new Class( + "Overloaded", + List.of(), + List.of( + new Method( + Type.INT, + "overloadedMethod", + List.of(), + new Block( + List.of( + new Return( + new IntLiteral(0) + ) + ) + ) + ), + new Method( + Type.INT, + "overloadedMethod", + List.of( + new Parameter( + "x", + Type.INT + ) + ), + new Block( + List.of( + new Return( + new FieldVarAccess( + false, + null, + "x" + ) + ) + ) + ) + ), + new Method( + Type.INT, + "overloadedMethod", + List.of( + new Parameter( + "x", + Type.INT + ), + new Parameter( + "y", + Type.INT + ) + ), + new Block( + List.of( + new Return( + new Binary( + new FieldVarAccess( + false, + null, + "x" + ), + Operator.ADD, + new FieldVarAccess( + false, + null, + "y" + ) + ) + ) + ) + ) + ) + ), + List.of( + new Constructor( + "Overloaded", + List.of(), + new Block( + List.of() + ) + ) + ) + ) + ) + ); + } +} \ No newline at end of file diff --git a/src/test/java/testResources/typedAST/TypedASTFeatures/TypedAST_Print.java b/src/test/java/testResources/typedAST/TypedASTFeatures/TypedAST_Print.java new file mode 100644 index 0000000..b4c7ab4 --- /dev/null +++ b/src/test/java/testResources/typedAST/TypedASTFeatures/TypedAST_Print.java @@ -0,0 +1,86 @@ +package testResources.typedAST.TypedASTFeatures; + +import de.maishai.ast.Operator; +import de.maishai.ast.records.Class; +import de.maishai.ast.records.*; +import de.maishai.typedast.Type; + +import java.util.List; + +public class TypedAST_Print { + public static Program get() { + return new Program( + List.of( + new Class( + "Print", + List.of(), + List.of( + new Method( + Type.VOID, + "print", + List.of( + new Parameter( + "c", + Type.CHAR + ) + ), + new Block( + List.of( + new Print( + new FieldVarAccess( + false, + null, + "c" + ) + ) + ) + ) + ), + new Method( + Type.VOID, + "printMoreComplex", + List.of( + new Parameter( + "x", + Type.INT + ), + new Parameter( + "y", + Type.INT + ) + ), + new Block( + List.of( + new Print( + new Binary( + new FieldVarAccess( + false, + null, + "x" + ), + Operator.LT, + new FieldVarAccess( + false, + null, + "y" + ) + ) + ) + ) + ) + ) + ), + List.of( + new Constructor( + "Print", + List.of(), + new Block( + List.of() + ) + ) + ) + ) + ) + ); + } +} \ No newline at end of file diff --git a/src/test/java/testResources/typedAST/TypedASTFeatures/TypedAST_Return.java b/src/test/java/testResources/typedAST/TypedASTFeatures/TypedAST_Return.java new file mode 100644 index 0000000..c7b966a --- /dev/null +++ b/src/test/java/testResources/typedAST/TypedASTFeatures/TypedAST_Return.java @@ -0,0 +1,95 @@ +package testResources.typedAST.TypedASTFeatures; + +import de.maishai.ast.records.Class; +import de.maishai.ast.records.*; +import de.maishai.typedast.Type; + +import java.util.List; + +public class TypedAST_Return { + public static Program get() { + return new Program( + List.of( + new Class( + "Return", + List.of(), + List.of( + new Method( + Type.INT, + "returnInt", + List.of(), + new Block( + List.of( + new Return( + new IntLiteral(10) + ) + ) + ) + ), + new Method( + Type.VOID, + "returnVoid", + List.of(), + new Block( + List.of( + new Return( + null + ) + ) + ) + ), + new Method( + Type.BOOL, + "returnBoolean", + List.of(), + new Block( + List.of( + new Return( + new BoolLiteral(true) + ) + ) + ) + ), + new Method( + Type.CHAR, + "returnChar", + List.of(), + new Block( + List.of( + new Return( + new CharLiteral('a') + ) + ) + ) + ), + new Method( + Type.REFERENCE("AST_Return"), + "returnClass", + List.of(), + new Block( + List.of( + new Return( + new New( + Type.REFERENCE("AST_Return"), + List.of() + ) + ) + ) + ) + ) + ), + List.of( + new Constructor( + "Return", + List.of(), + new Block( + List.of() + ) + ) + ) + + ) + ) + ); + } +} \ No newline at end of file diff --git a/src/test/java/testResources/typedAST/TypedASTFeatures/TypedAST_VariableDefWithDecl.java b/src/test/java/testResources/typedAST/TypedASTFeatures/TypedAST_VariableDefWithDecl.java new file mode 100644 index 0000000..3c8ca54 --- /dev/null +++ b/src/test/java/testResources/typedAST/TypedASTFeatures/TypedAST_VariableDefWithDecl.java @@ -0,0 +1,55 @@ +package testResources.typedAST.TypedASTFeatures; + +import de.maishai.ast.records.Class; +import de.maishai.ast.records.*; +import de.maishai.typedast.Type; + +import java.util.List; + +public class TypedAST_VariableDefWithDecl { + public static Program get() { + return new Program( + List.of( + new Class( + "VariableDefWithDecl", + List.of(), + List.of(), + List.of( + new Constructor( + "VariableDefWithDecl", + List.of(), + new Block( + List.of( + new Declaration( + "a", + Type.INT + ), + new Assignment( + new FieldVarAccess( + false, + null, + "a" + ), + new IntLiteral(10) + ), + new Declaration( + "b", + Type.INT + ), + new Assignment( + new FieldVarAccess( + false, + null, + "b" + ), + new IntLiteral(20) + ) + ) + ) + ) + ) + ) + ) + ); + } +} \ No newline at end of file diff --git a/src/test/java/testResources/typedAST/TypedASTFeatures/TypedAST_While.java b/src/test/java/testResources/typedAST/TypedASTFeatures/TypedAST_While.java new file mode 100644 index 0000000..1ef1d74 --- /dev/null +++ b/src/test/java/testResources/typedAST/TypedASTFeatures/TypedAST_While.java @@ -0,0 +1,84 @@ +package testResources.typedAST.TypedASTFeatures; + +import de.maishai.ast.Operator; +import de.maishai.ast.records.Class; +import de.maishai.ast.records.*; +import de.maishai.typedast.Type; + +import java.util.List; + +public class TypedAST_While { + public static Program get() { + return new Program( + List.of( + new Class( + "While", + List.of(), + List.of( + new Method( + Type.VOID, + "whileLoop", + List.of(), + new Block( + List.of( + new Declaration( + "i", + Type.INT + ), + new Assignment( + new FieldVarAccess( + false, + null, + "i" + ), + new IntLiteral(0) + ), + new While( + new Binary( + new FieldVarAccess( + false, + null, + "i" + ), + Operator.LT, + new IntLiteral(5) + ), + new Block( + List.of( + new Assignment( + new FieldVarAccess( + false, + null, + "i" + ), + new Binary( + new FieldVarAccess( + false, + null, + "i" + ), + Operator.ADD, + new IntLiteral(1) + ) + ) + ) + ) + ) + ) + ) + ) + ), + List.of( + new Constructor( + "While", + List.of(), + new Block( + List.of() + ) + ) + ) + ) + ) + ); + } +} \ No newline at end of file diff --git a/src/main/java/testfiles/TypedASTMore/TypedAbstractSyntax_ClassWithConstructor.java b/src/test/java/testResources/typedAST/TypedASTMore/TypedAbstractSyntax_ClassWithConstructor.java similarity index 99% rename from src/main/java/testfiles/TypedASTMore/TypedAbstractSyntax_ClassWithConstructor.java rename to src/test/java/testResources/typedAST/TypedASTMore/TypedAbstractSyntax_ClassWithConstructor.java index bbe06f1..040111f 100644 --- a/src/main/java/testfiles/TypedASTMore/TypedAbstractSyntax_ClassWithConstructor.java +++ b/src/test/java/testResources/typedAST/TypedASTMore/TypedAbstractSyntax_ClassWithConstructor.java @@ -1,4 +1,4 @@ -package testfiles.TypedASTMore;//public class ClassWithConstructor { +package testResources.typedAST.TypedASTMore;//public class ClassWithConstructor { // int x; // public classWithConstructor() { // this.x = 10; diff --git a/src/main/java/testfiles/TypedASTMore/TypedAbstractSyntax_ClassWithConstructorAndMethodCall.java b/src/test/java/testResources/typedAST/TypedASTMore/TypedAbstractSyntax_ClassWithConstructorAndMethodCall.java similarity index 98% rename from src/main/java/testfiles/TypedASTMore/TypedAbstractSyntax_ClassWithConstructorAndMethodCall.java rename to src/test/java/testResources/typedAST/TypedASTMore/TypedAbstractSyntax_ClassWithConstructorAndMethodCall.java index 42ae47c..26e9017 100644 --- a/src/main/java/testfiles/TypedASTMore/TypedAbstractSyntax_ClassWithConstructorAndMethodCall.java +++ b/src/test/java/testResources/typedAST/TypedASTMore/TypedAbstractSyntax_ClassWithConstructorAndMethodCall.java @@ -1,4 +1,4 @@ -package testfiles.TypedASTMore;//public class ClassWithConstructorAndMethodCall { +package testResources.typedAST.TypedASTMore;//public class ClassWithConstructorAndMethodCall { // int x; // // public ClassWithConstructorAndMethodCall() { diff --git a/src/main/java/testfiles/TypedASTMore/TypedAbstractSyntax_ClassWithConstructorWithCodeInComments.java b/src/test/java/testResources/typedAST/TypedASTMore/TypedAbstractSyntax_ClassWithConstructorWithCodeInComments.java similarity index 97% rename from src/main/java/testfiles/TypedASTMore/TypedAbstractSyntax_ClassWithConstructorWithCodeInComments.java rename to src/test/java/testResources/typedAST/TypedASTMore/TypedAbstractSyntax_ClassWithConstructorWithCodeInComments.java index bdc72fd..db47095 100644 --- a/src/main/java/testfiles/TypedASTMore/TypedAbstractSyntax_ClassWithConstructorWithCodeInComments.java +++ b/src/test/java/testResources/typedAST/TypedASTMore/TypedAbstractSyntax_ClassWithConstructorWithCodeInComments.java @@ -1,4 +1,4 @@ -package testfiles.TypedASTMore;//public class ClassWithConstructorWithCodeInComments { +package testResources.typedAST.TypedASTMore;//public class ClassWithConstructorWithCodeInComments { // int x; // public ClassWithConstructorWithCodeInComments() { // this.x = 10; diff --git a/src/main/java/testfiles/TypedASTMore/TypedAbstractSyntax_ClassWithConstructorWithParameters.java b/src/test/java/testResources/typedAST/TypedASTMore/TypedAbstractSyntax_ClassWithConstructorWithParameters.java similarity index 98% rename from src/main/java/testfiles/TypedASTMore/TypedAbstractSyntax_ClassWithConstructorWithParameters.java rename to src/test/java/testResources/typedAST/TypedASTMore/TypedAbstractSyntax_ClassWithConstructorWithParameters.java index c756b33..84e8607 100644 --- a/src/main/java/testfiles/TypedASTMore/TypedAbstractSyntax_ClassWithConstructorWithParameters.java +++ b/src/test/java/testResources/typedAST/TypedASTMore/TypedAbstractSyntax_ClassWithConstructorWithParameters.java @@ -1,4 +1,4 @@ -package testfiles.TypedASTMore;//public class ClassWithConstructorWithParameters { +package testResources.typedAST.TypedASTMore;//public class ClassWithConstructorWithParameters { // int x; // public classWithConstructorWithParameters(int startValue, int repetitions) { // this.x = startValue; diff --git a/src/main/java/testfiles/TypedASTMore/TypedAbstractSyntax_ClassWithField.java b/src/test/java/testResources/typedAST/TypedASTMore/TypedAbstractSyntax_ClassWithField.java similarity index 95% rename from src/main/java/testfiles/TypedASTMore/TypedAbstractSyntax_ClassWithField.java rename to src/test/java/testResources/typedAST/TypedASTMore/TypedAbstractSyntax_ClassWithField.java index 226ac2e..7dabe49 100644 --- a/src/main/java/testfiles/TypedASTMore/TypedAbstractSyntax_ClassWithField.java +++ b/src/test/java/testResources/typedAST/TypedASTMore/TypedAbstractSyntax_ClassWithField.java @@ -1,4 +1,4 @@ -package testfiles.TypedASTMore;//public class ClassWithField { +package testResources.typedAST.TypedASTMore;//public class ClassWithField { // int x; //} diff --git a/src/main/java/testfiles/TypedASTMore/TypedAbstractSyntax_ClassWithMethod.java b/src/test/java/testResources/typedAST/TypedASTMore/TypedAbstractSyntax_ClassWithMethod.java similarity index 94% rename from src/main/java/testfiles/TypedASTMore/TypedAbstractSyntax_ClassWithMethod.java rename to src/test/java/testResources/typedAST/TypedASTMore/TypedAbstractSyntax_ClassWithMethod.java index ee39309..1364084 100644 --- a/src/main/java/testfiles/TypedASTMore/TypedAbstractSyntax_ClassWithMethod.java +++ b/src/test/java/testResources/typedAST/TypedASTMore/TypedAbstractSyntax_ClassWithMethod.java @@ -1,4 +1,4 @@ -package testfiles.TypedASTMore;//public class ClassWithMethod { +package testResources.typedAST.TypedASTMore;//public class ClassWithMethod { // public boolean method() { // return false; // } diff --git a/src/main/java/testfiles/TypedASTMore/TypedAbstractSyntax_ClassWithMethodAndField.java b/src/test/java/testResources/typedAST/TypedASTMore/TypedAbstractSyntax_ClassWithMethodAndField.java similarity index 96% rename from src/main/java/testfiles/TypedASTMore/TypedAbstractSyntax_ClassWithMethodAndField.java rename to src/test/java/testResources/typedAST/TypedASTMore/TypedAbstractSyntax_ClassWithMethodAndField.java index 02bfcdc..e6dd3e2 100644 --- a/src/main/java/testfiles/TypedASTMore/TypedAbstractSyntax_ClassWithMethodAndField.java +++ b/src/test/java/testResources/typedAST/TypedASTMore/TypedAbstractSyntax_ClassWithMethodAndField.java @@ -1,4 +1,4 @@ -package testfiles.TypedASTMore;//public class ClassWithMethodAndField { +package testResources.typedAST.TypedASTMore;//public class ClassWithMethodAndField { // char c; // // public ClassWithMethodAndField(char character) { diff --git a/src/main/java/testfiles/TypedASTMore/TypedAbstractSyntax_ClassWithMoreComplexMethodAndMain.java b/src/test/java/testResources/typedAST/TypedASTMore/TypedAbstractSyntax_ClassWithMoreComplexMethodAndMain.java similarity index 98% rename from src/main/java/testfiles/TypedASTMore/TypedAbstractSyntax_ClassWithMoreComplexMethodAndMain.java rename to src/test/java/testResources/typedAST/TypedASTMore/TypedAbstractSyntax_ClassWithMoreComplexMethodAndMain.java index 33ed656..08bbe3a 100644 --- a/src/main/java/testfiles/TypedASTMore/TypedAbstractSyntax_ClassWithMoreComplexMethodAndMain.java +++ b/src/test/java/testResources/typedAST/TypedASTMore/TypedAbstractSyntax_ClassWithMoreComplexMethodAndMain.java @@ -1,4 +1,4 @@ -package testfiles.TypedASTMore;//public class ClassWithMoreComplexMethodAndMain { +package testResources.typedAST.TypedASTMore;//public class ClassWithMoreComplexMethodAndMain { // ClassWithMoreComplexMethodAndMain instance; // // public boolean moreComplexMethod() { diff --git a/src/main/java/testfiles/TypedASTMore/TypedAbstractSyntax_ComplexClass.java b/src/test/java/testResources/typedAST/TypedASTMore/TypedAbstractSyntax_ComplexClass.java similarity index 99% rename from src/main/java/testfiles/TypedASTMore/TypedAbstractSyntax_ComplexClass.java rename to src/test/java/testResources/typedAST/TypedASTMore/TypedAbstractSyntax_ComplexClass.java index 3006d55..3d3129e 100644 --- a/src/main/java/testfiles/TypedASTMore/TypedAbstractSyntax_ComplexClass.java +++ b/src/test/java/testResources/typedAST/TypedASTMore/TypedAbstractSyntax_ComplexClass.java @@ -1,4 +1,4 @@ -package testfiles.TypedASTMore;//public class ComplexClass { +package testResources.typedAST.TypedASTMore;//public class ComplexClass { // // int x; // int y; diff --git a/src/main/java/testfiles/TypedASTMore/TypedAbstractSyntax_PublicClass.java b/src/test/java/testResources/typedAST/TypedASTMore/TypedAbstractSyntax_PublicClass.java similarity index 94% rename from src/main/java/testfiles/TypedASTMore/TypedAbstractSyntax_PublicClass.java rename to src/test/java/testResources/typedAST/TypedASTMore/TypedAbstractSyntax_PublicClass.java index b291026..33c3ad3 100644 --- a/src/main/java/testfiles/TypedASTMore/TypedAbstractSyntax_PublicClass.java +++ b/src/test/java/testResources/typedAST/TypedASTMore/TypedAbstractSyntax_PublicClass.java @@ -1,4 +1,4 @@ -package testfiles.TypedASTMore;//public class PublicClass { +package testResources.typedAST.TypedASTMore;//public class PublicClass { //} import de.maishai.typedast.Type; diff --git a/src/main/resources/JavaTestfilesFeatures/Class.java b/src/test/testFiles/JavaTestfilesFeatures/Class.java similarity index 100% rename from src/main/resources/JavaTestfilesFeatures/Class.java rename to src/test/testFiles/JavaTestfilesFeatures/Class.java diff --git a/src/main/resources/JavaTestfilesFeatures/ClassObjects.java b/src/test/testFiles/JavaTestfilesFeatures/ClassObjects.java similarity index 100% rename from src/main/resources/JavaTestfilesFeatures/ClassObjects.java rename to src/test/testFiles/JavaTestfilesFeatures/ClassObjects.java diff --git a/src/main/resources/JavaTestfilesFeatures/Comment.java b/src/test/testFiles/JavaTestfilesFeatures/Comment.java similarity index 100% rename from src/main/resources/JavaTestfilesFeatures/Comment.java rename to src/test/testFiles/JavaTestfilesFeatures/Comment.java diff --git a/src/main/resources/JavaTestfilesFeatures/Constructor.java b/src/test/testFiles/JavaTestfilesFeatures/Constructor.java similarity index 100% rename from src/main/resources/JavaTestfilesFeatures/Constructor.java rename to src/test/testFiles/JavaTestfilesFeatures/Constructor.java diff --git a/src/main/resources/JavaTestfilesFeatures/Continue.java b/src/test/testFiles/JavaTestfilesFeatures/Continue.java similarity index 100% rename from src/main/resources/JavaTestfilesFeatures/Continue.java rename to src/test/testFiles/JavaTestfilesFeatures/Continue.java diff --git a/src/main/resources/JavaTestfilesFeatures/Field.java b/src/test/testFiles/JavaTestfilesFeatures/Field.java similarity index 100% rename from src/main/resources/JavaTestfilesFeatures/Field.java rename to src/test/testFiles/JavaTestfilesFeatures/Field.java diff --git a/src/main/resources/JavaTestfilesFeatures/For.java b/src/test/testFiles/JavaTestfilesFeatures/For.java similarity index 100% rename from src/main/resources/JavaTestfilesFeatures/For.java rename to src/test/testFiles/JavaTestfilesFeatures/For.java diff --git a/src/main/resources/JavaTestfilesFeatures/If.java b/src/test/testFiles/JavaTestfilesFeatures/If.java similarity index 100% rename from src/main/resources/JavaTestfilesFeatures/If.java rename to src/test/testFiles/JavaTestfilesFeatures/If.java diff --git a/src/main/resources/JavaTestfilesFeatures/IncrDecr.java b/src/test/testFiles/JavaTestfilesFeatures/IncrDecr.java similarity index 100% rename from src/main/resources/JavaTestfilesFeatures/IncrDecr.java rename to src/test/testFiles/JavaTestfilesFeatures/IncrDecr.java diff --git a/src/main/resources/JavaTestfilesFeatures/LogicExpr.java b/src/test/testFiles/JavaTestfilesFeatures/LogicExpr.java similarity index 100% rename from src/main/resources/JavaTestfilesFeatures/LogicExpr.java rename to src/test/testFiles/JavaTestfilesFeatures/LogicExpr.java diff --git a/src/main/resources/JavaTestfilesFeatures/Method.java b/src/test/testFiles/JavaTestfilesFeatures/Method.java similarity index 100% rename from src/main/resources/JavaTestfilesFeatures/Method.java rename to src/test/testFiles/JavaTestfilesFeatures/Method.java diff --git a/src/main/resources/JavaTestfilesFeatures/MethodCall.java b/src/test/testFiles/JavaTestfilesFeatures/MethodCall.java similarity index 100% rename from src/main/resources/JavaTestfilesFeatures/MethodCall.java rename to src/test/testFiles/JavaTestfilesFeatures/MethodCall.java diff --git a/src/main/resources/JavaTestfilesFeatures/MultipleClasses.java b/src/test/testFiles/JavaTestfilesFeatures/MultipleClasses.java similarity index 100% rename from src/main/resources/JavaTestfilesFeatures/MultipleClasses.java rename to src/test/testFiles/JavaTestfilesFeatures/MultipleClasses.java diff --git a/src/main/resources/JavaTestfilesFeatures/Operators.java b/src/test/testFiles/JavaTestfilesFeatures/Operators.java similarity index 100% rename from src/main/resources/JavaTestfilesFeatures/Operators.java rename to src/test/testFiles/JavaTestfilesFeatures/Operators.java diff --git a/src/main/resources/JavaTestfilesFeatures/Overloaded.java b/src/test/testFiles/JavaTestfilesFeatures/Overloaded.java similarity index 100% rename from src/main/resources/JavaTestfilesFeatures/Overloaded.java rename to src/test/testFiles/JavaTestfilesFeatures/Overloaded.java diff --git a/src/main/resources/JavaTestfilesFeatures/Print.java b/src/test/testFiles/JavaTestfilesFeatures/Print.java similarity index 100% rename from src/main/resources/JavaTestfilesFeatures/Print.java rename to src/test/testFiles/JavaTestfilesFeatures/Print.java diff --git a/src/main/resources/JavaTestfilesFeatures/Return.java b/src/test/testFiles/JavaTestfilesFeatures/Return.java similarity index 100% rename from src/main/resources/JavaTestfilesFeatures/Return.java rename to src/test/testFiles/JavaTestfilesFeatures/Return.java diff --git a/src/main/resources/JavaTestfilesFeatures/VariableDefWithDecl.java b/src/test/testFiles/JavaTestfilesFeatures/VariableDefWithDecl.java similarity index 100% rename from src/main/resources/JavaTestfilesFeatures/VariableDefWithDecl.java rename to src/test/testFiles/JavaTestfilesFeatures/VariableDefWithDecl.java diff --git a/src/main/resources/JavaTestfilesFeatures/While.java b/src/test/testFiles/JavaTestfilesFeatures/While.java similarity index 100% rename from src/main/resources/JavaTestfilesFeatures/While.java rename to src/test/testFiles/JavaTestfilesFeatures/While.java diff --git a/src/main/resources/JavaTestfilesMore/ClassCanBeBytecoded.java b/src/test/testFiles/JavaTestfilesMore/ClassCanBeBytecoded.java similarity index 100% rename from src/main/resources/JavaTestfilesMore/ClassCanBeBytecoded.java rename to src/test/testFiles/JavaTestfilesMore/ClassCanBeBytecoded.java diff --git a/src/main/resources/JavaTestfilesMore/ClassCanBeTyped.java b/src/test/testFiles/JavaTestfilesMore/ClassCanBeTyped.java similarity index 99% rename from src/main/resources/JavaTestfilesMore/ClassCanBeTyped.java rename to src/test/testFiles/JavaTestfilesMore/ClassCanBeTyped.java index 7f6b0cf..338cadb 100644 --- a/src/main/resources/JavaTestfilesMore/ClassCanBeTyped.java +++ b/src/test/testFiles/JavaTestfilesMore/ClassCanBeTyped.java @@ -1,4 +1,3 @@ - public class ClassCanBeTyped{ public int c; public ClassCanBeTyped d; diff --git a/src/main/resources/JavaTestfilesMore/ClassWithConstructor.java b/src/test/testFiles/JavaTestfilesMore/ClassWithConstructor.java similarity index 100% rename from src/main/resources/JavaTestfilesMore/ClassWithConstructor.java rename to src/test/testFiles/JavaTestfilesMore/ClassWithConstructor.java diff --git a/src/main/resources/JavaTestfilesMore/ClassWithConstructorAndMethodCall.java b/src/test/testFiles/JavaTestfilesMore/ClassWithConstructorAndMethodCall.java similarity index 100% rename from src/main/resources/JavaTestfilesMore/ClassWithConstructorAndMethodCall.java rename to src/test/testFiles/JavaTestfilesMore/ClassWithConstructorAndMethodCall.java diff --git a/src/main/resources/JavaTestfilesMore/ClassWithConstructorWithCodeInComments.java b/src/test/testFiles/JavaTestfilesMore/ClassWithConstructorWithCodeInComments.java similarity index 100% rename from src/main/resources/JavaTestfilesMore/ClassWithConstructorWithCodeInComments.java rename to src/test/testFiles/JavaTestfilesMore/ClassWithConstructorWithCodeInComments.java diff --git a/src/main/resources/JavaTestfilesMore/ClassWithConstructorWithParameters.java b/src/test/testFiles/JavaTestfilesMore/ClassWithConstructorWithParameters.java similarity index 100% rename from src/main/resources/JavaTestfilesMore/ClassWithConstructorWithParameters.java rename to src/test/testFiles/JavaTestfilesMore/ClassWithConstructorWithParameters.java diff --git a/src/main/resources/JavaTestfilesMore/ClassWithField.java b/src/test/testFiles/JavaTestfilesMore/ClassWithField.java similarity index 100% rename from src/main/resources/JavaTestfilesMore/ClassWithField.java rename to src/test/testFiles/JavaTestfilesMore/ClassWithField.java diff --git a/src/main/resources/JavaTestfilesMore/ClassWithMethod.java b/src/test/testFiles/JavaTestfilesMore/ClassWithMethod.java similarity index 100% rename from src/main/resources/JavaTestfilesMore/ClassWithMethod.java rename to src/test/testFiles/JavaTestfilesMore/ClassWithMethod.java diff --git a/src/main/resources/JavaTestfilesMore/ClassWithMethodAndField.java b/src/test/testFiles/JavaTestfilesMore/ClassWithMethodAndField.java similarity index 100% rename from src/main/resources/JavaTestfilesMore/ClassWithMethodAndField.java rename to src/test/testFiles/JavaTestfilesMore/ClassWithMethodAndField.java diff --git a/src/main/resources/JavaTestfilesMore/ClassWithMoreComplexMethodAndMain.java b/src/test/testFiles/JavaTestfilesMore/ClassWithMoreComplexMethodAndMain.java similarity index 100% rename from src/main/resources/JavaTestfilesMore/ClassWithMoreComplexMethodAndMain.java rename to src/test/testFiles/JavaTestfilesMore/ClassWithMoreComplexMethodAndMain.java diff --git a/src/main/resources/JavaTestfilesMore/ComplexClass.java b/src/test/testFiles/JavaTestfilesMore/ComplexClass.java similarity index 100% rename from src/main/resources/JavaTestfilesMore/ComplexClass.java rename to src/test/testFiles/JavaTestfilesMore/ComplexClass.java diff --git a/src/main/resources/JavaTestfilesMore/PublicClass.java b/src/test/testFiles/JavaTestfilesMore/PublicClass.java similarity index 100% rename from src/main/resources/JavaTestfilesMore/PublicClass.java rename to src/test/testFiles/JavaTestfilesMore/PublicClass.java