diff --git a/README.md b/README.md index 7ae61eb..16ff106 100644 --- a/README.md +++ b/README.md @@ -12,12 +12,20 @@ - Julian Kraus: Grammatik entwickeln, Generator, Syntactic Sugar auflösen - Ahmad Juha: Typcheck - Simon Wittmann: Codegen und Tool für ASM -- Jonathan Fleischmann: Tests +- Jonathan Fleischmann: + - Schreiben von Tests, die die einzelnen Features abdecken + - Umwandlung der Testfiles in AST und TypedAST + - Implementierung der Tests, die mithilfe der umgewandelten Testfiles die korrekte Umwandlung + von java-File zu AST und AST zu TypedAST prüfen + - Schreiben von Testfiles, die die einzelnen Features abdecken und gut über Reflections testbar sind + - Implementierung eines Tools, durch das die Testfiles mithilfe von Reflections + einfacher nach gewissen Kriterien überprüfbar sind + - Implementierung von Tests, die die korrekte Umwandlung der Testfiles von java-File in class-File + durch den Compiler mithilfe des Tools prüfen + - Hinzufügen von Testfiles, die bei der Umwandlung fehlschlagen sollen + - Implementierung von Tests, die prüfen, ob der Compiler bei den fehlerhaften Testfiles tatsächlich fehlschlägt -## Fehlende Tests für Features (positive Tests) - -- Main-Methode -- Klammern von Expressions + [//]: # (TODO: - Dokumentation der Tests) ## Besonderheiten unserer Implementierung diff --git a/src/main/java/de/maishai/StatementGenerator.java b/src/main/java/de/maishai/StatementGenerator.java index fa98767..268642c 100644 --- a/src/main/java/de/maishai/StatementGenerator.java +++ b/src/main/java/de/maishai/StatementGenerator.java @@ -105,7 +105,6 @@ public class StatementGenerator extends DecafBaseVisitor> { Expression recipient = null; if (fieldIdContext.recipient() != null) { recipient = ExpressionGenerator.generateRecursiveOwnerChain(fieldIdContext.recipient(), null, isField); - } if (recipient == null) { return new FieldVarAccess(isField, null, fieldIdContext.id().IDENTIFIER().getText()); diff --git a/src/test/java/AllNegativeTests.java b/src/test/java/AllNegativeTests.java new file mode 100644 index 0000000..090cd8a --- /dev/null +++ b/src/test/java/AllNegativeTests.java @@ -0,0 +1,52 @@ +import NegativeTests.*; +import de.maishai.Compiler; +import org.junit.jupiter.api.Test; + +import java.util.List; + +import static HelpFiles.TestFileTester.run; +import static org.junit.jupiter.api.Assertions.assertThrows; + +class AllNegativeTests { + + @Test + void runCallVariableOutsideScopeTests() { + run(CallVariableOutsideScope.class); + } + + @Test + void runForbiddenParticularitiesInImplementationTests() { + run(ForbiddenParticularitiesInImplementation.class); + } + + @Test + void runMissingComponentsTests() { + run(MissingComponents.class); + } + + @Test + void runUsingSameNameTests() { + run(UsingSameName.class); + } + + @Test + void runWrongTypeTests() { + run(WrongType.class); + } + + @Test + void AssignmentOutsideMethod() { + assertThrows(Exception.class, () -> { + Compiler.generateByteCodeFilesFromFiles(List.of( + "src/test/testFiles/Negative/AssignmentOutsideMethod.java")); + }); + } + + @Test + void CallingFieldInMainMethod() { + assertThrows(Exception.class, () -> { + Compiler.generateByteCodeFilesFromFiles(List.of( + "src/test/testFiles/Negative/CallingFieldInMainMethod.java")); + }); + } +} diff --git a/src/test/java/CodegeneratorTests.java b/src/test/java/CodegeneratorTests.java index fcdc9fb..a2efa27 100644 --- a/src/test/java/CodegeneratorTests.java +++ b/src/test/java/CodegeneratorTests.java @@ -1,25 +1,19 @@ -import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Test; -import org.junit.platform.commons.support.HierarchyTraversalMode; -import org.junit.platform.commons.support.ReflectionSupport; import testResources.CodeGen.Features.*; -import java.lang.reflect.Method; -import java.util.ArrayList; -import java.util.List; -import java.util.Optional; +import static HelpFiles.TestFileTester.run; -public class CodegeneratorTests { +class CodegeneratorTests { // @Test -// public void testPublicClass() { +// void testPublicClass() { // byte[] resultBytecode = Compiler.generateByteCodeArrayFromTypedAst(); // assertEquals(AbstractSyntax_PublicClass.get(), resultBytecode); // } // @Test -// public void testMethodCall() { +// void testMethodCall() { // assertDoesNotThrow(() -> { // BytecodeTestUtil testUtility = new BytecodeTestUtil("src/test/testFiles/ASTandTypedASTFeatures/MethodCall.java", "MethodCall"); // @@ -30,163 +24,125 @@ public class CodegeneratorTests { // } @Test - public void runByteCodeBreakTests() { - runByteCodeTests(ByteCode_Break.class); + void runByteCodeBreakTests() { + run(ByteCode_Break.class); } @Test - public void runByteCodeClassTests() { - runByteCodeTests(ByteCode_Class.class); + void runByteCodeClassTests() { + run(ByteCode_Class.class); } @Test - public void runByteCodeClassObjectsTests() { - runByteCodeTests(ByteCode_ClassObjects.class); + void runByteCodeClassObjectsTests() { + run(ByteCode_ClassObjects.class); } @Test - public void runByteCodeCommentTests() { - runByteCodeTests(ByteCode_Comment.class); + void runByteCodeCommentTests() { + run(ByteCode_Comment.class); } @Test - public void runByteCodeCompAssignTests() { - runByteCodeTests(ByteCode_CompAssign.class); + void runByteCodeCompAssignTests() { + run(ByteCode_CompAssign.class); } @Test - public void runByteCodeComplexCallsTests() { - runByteCodeTests(ByteCode_ComplexCalls.class); + void runByteCodeComplexCallsTests() { + run(ByteCode_ComplexCalls.class); } @Test - public void runByteCodeConstructorTests() { - runByteCodeTests(ByteCode_Constructor.class); + void runByteCodeConstructorTests() { + run(ByteCode_Constructor.class); } @Test - public void runByteCodeContinueTests() { - runByteCodeTests(ByteCode_Continue.class); + void runByteCodeContinueTests() { + run(ByteCode_Continue.class); } @Test - public void runByteCodeDataTypesTests() { - runByteCodeTests(ByteCode_DataTypes.class); + void runByteCodeDataTypesTests() { + run(ByteCode_DataTypes.class); } @Test - public void runByteCodeFieldTests() { - runByteCodeTests(ByteCode_Field.class); + void runByteCodeFieldTests() { + run(ByteCode_Field.class); } @Test - public void runByteCodeForTests() { - runByteCodeTests(ByteCode_For.class); + void runByteCodeForTests() { + run(ByteCode_For.class); } @Test - public void runByteCodeIfTests() { - runByteCodeTests(ByteCode_If.class); + void runByteCodeIfTests() { + run(ByteCode_If.class); } @Test - public void runByteCodeLogicExprTests() { - runByteCodeTests(ByteCode_LogicExpr.class); + void runByteCodeLogicExprTests() { + run(ByteCode_LogicExpr.class); } @Test - public void runByteCodeMainTests() { - runByteCodeTests(ByteCode_Main.class); + void runByteCodeMainTests() { + run(ByteCode_Main.class); } @Test - public void runByteCodeMethodTests() { - runByteCodeTests(ByteCode_Method.class); + void runByteCodeMethodTests() { + run(ByteCode_Method.class); } @Test - public void runByteCodeMethodCallTests() { - runByteCodeTests(ByteCode_MethodCall.class); + void runByteCodeMethodCallTests() { + run(ByteCode_MethodCall.class); } @Test - public void runByteCodeMultipleClassesTests() { - runByteCodeTests(ByteCode_MultipleClasses.class); + void runByteCodeMultipleClassesTests() { + run(ByteCode_MultipleClasses.class); } @Test - public void runByteCodeOperatorsTests() { - runByteCodeTests(ByteCode_Operators.class); + void runByteCodeOperatorsTests() { + run(ByteCode_Operators.class); } @Test - public void runByteCodeOverloadedTests() { - runByteCodeTests(ByteCode_Overloaded.class); + void runByteCodeOverloadedTests() { + run(ByteCode_Overloaded.class); } @Test - public void runByteCodePrintTests() { - runByteCodeTests(ByteCode_Print.class); + void runByteCodePrintTests() { + run(ByteCode_Print.class); } @Test - public void runByteCodeReturnTests() { - runByteCodeTests(ByteCode_Return.class); + void runByteCodeReturnTests() { + run(ByteCode_Return.class); } @Test - public void runByteCodeUnaryTests() { - runByteCodeTests(ByteCode_Unary.class); + void runByteCodeUnaryTests() { + run(ByteCode_Unary.class); } @Test - public void runByteCodeVariableDefWithDeclTests() { - runByteCodeTests(ByteCode_VariableDefWithDecl.class); + void runByteCodeVariableDefWithDeclTests() { + run(ByteCode_VariableDefWithDecl.class); } @Test - public void runByteCodeWhileTests() { - runByteCodeTests(ByteCode_While.class); + void runByteCodeWhileTests() { + run(ByteCode_While.class); } - private void runByteCodeTests(Class testClass) { - List failedTests = new ArrayList<>(); - // Finde alle Methoden, die mit @Test annotiert sind - List testMethods = ReflectionSupport.findMethods( - testClass, - method -> method.isAnnotationPresent(Test.class), - HierarchyTraversalMode.TOP_DOWN - ); - - for (Method testMethod : testMethods) { - try { - // Erstelle eine Instanz der Testklasse - Object testInstance = ReflectionSupport.newInstance(testClass); - - // Führe die Setup-Methode aus (falls vorhanden) - Optional setUpMethodOptional = ReflectionSupport.findMethod(testClass, "setUp"); - if (setUpMethodOptional.isPresent()) { - setUpMethodOptional.get().invoke(testInstance); - } - - // Führe die Testmethode aus - testMethod.invoke(testInstance); - } catch (Exception e) { - if (e.getCause() != null) { - failedTests.add(testMethod.getName() + ": " + e.getCause().getMessage()); - } else { - failedTests.add(testMethod.getName() + ": " + e.getMessage()); - } - } - } - - if (!failedTests.isEmpty()) { - failedTests.forEach(System.err::println); - Assertions.fail("Ein oder mehrere Tests sind fehlgeschlagen."); - } else { - System.out.println("Alle Tests sind erfolgreich."); - } - } } \ No newline at end of file diff --git a/src/test/java/HelpFiles/TestFileTester.java b/src/test/java/HelpFiles/TestFileTester.java new file mode 100644 index 0000000..dd23ec2 --- /dev/null +++ b/src/test/java/HelpFiles/TestFileTester.java @@ -0,0 +1,53 @@ +package HelpFiles; + +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; +import org.junit.platform.commons.support.HierarchyTraversalMode; +import org.junit.platform.commons.support.ReflectionSupport; + +import java.lang.reflect.Method; +import java.util.ArrayList; +import java.util.List; +import java.util.Optional; + +public class TestFileTester { + public static void run(Class testClass) { + List failedTests = new ArrayList<>(); + + // Finde alle Methoden, die mit @Test annotiert sind + List testMethods = ReflectionSupport.findMethods( + testClass, + method -> method.isAnnotationPresent(Test.class), + HierarchyTraversalMode.TOP_DOWN + ); + + for (Method testMethod : testMethods) { + try { + // Erstelle eine Instanz der Testklasse + Object testInstance = ReflectionSupport.newInstance(testClass); + + // Führe die Setup-Methode aus (falls vorhanden) + Optional setUpMethodOptional = ReflectionSupport.findMethod(testClass, "setUp"); + if (setUpMethodOptional.isPresent()) { + setUpMethodOptional.get().invoke(testInstance); + } + + // Führe die Testmethode aus + testMethod.invoke(testInstance); + } catch (Exception e) { + if (e.getCause() != null) { + failedTests.add(testMethod.getName() + ": " + e.getCause().getMessage()); + } else { + failedTests.add(testMethod.getName() + ": " + e.getMessage()); + } + } + } + + if (!failedTests.isEmpty()) { + failedTests.forEach(System.err::println); + Assertions.fail("Ein oder mehrere Tests sind fehlgeschlagen."); + } else { + System.out.println("Alle Tests sind erfolgreich."); + } + } +} diff --git a/src/test/java/NegativeTests.java b/src/test/java/NegativeTests.java deleted file mode 100644 index f384b72..0000000 --- a/src/test/java/NegativeTests.java +++ /dev/null @@ -1,23 +0,0 @@ -import de.maishai.Compiler; -import org.junit.jupiter.api.Assertions; -import org.junit.jupiter.api.Test; - -import java.util.List; - -public class NegativeTests { - - @Test - public void AddressingFieldWithoutThis() { - try { - Compiler.generateByteCodeFilesFromFiles(List.of("src/test/testFiles/Negative/AddressingFieldWithoutThis.java")); - Assertions.fail(); - } catch (Exception e) { - Assertions.assertTrue(true); - } - } - - @Test - public void PublicMissingInClass() { - Compiler.generateByteCodeFilesFromFiles(List.of("src/test/testFiles/Negative/PublicMissingInClass.java")); - } -} diff --git a/src/test/java/NegativeTests/CallVariableOutsideScope.java b/src/test/java/NegativeTests/CallVariableOutsideScope.java new file mode 100644 index 0000000..87a37d5 --- /dev/null +++ b/src/test/java/NegativeTests/CallVariableOutsideScope.java @@ -0,0 +1,41 @@ +package NegativeTests; + +import de.maishai.Compiler; +import org.junit.jupiter.api.Test; + +import java.util.List; + +import static org.junit.jupiter.api.Assertions.assertThrows; + +public class CallVariableOutsideScope { + + @Test + public void CallVariableOutsideScopeOfElse() { + assertThrows(Exception.class, () -> Compiler.generateByteCodeFilesFromFiles(List.of("src/test/testFiles/Negative/CallVariableOutsideScope/OfElse.java"))); + } + + @Test + public void CallVariableOutsideScopeOfFor() { + assertThrows(Exception.class, () -> Compiler.generateByteCodeFilesFromFiles(List.of("src/test/testFiles/Negative/CallVariableOutsideScope/OfFor.java"))); + } + + @Test + public void CallVariableOutsideScopeOfIf() { + assertThrows(Exception.class, () -> Compiler.generateByteCodeFilesFromFiles(List.of("src/test/testFiles/Negative/CallVariableOutsideScope/OfIf.java"))); + } + + @Test + public void CallVariableOutsideScopeOfIfElse() { + assertThrows(Exception.class, () -> Compiler.generateByteCodeFilesFromFiles(List.of("src/test/testFiles/Negative/CallVariableOutsideScope/OfIfElse.java"))); + } + + @Test + public void CallVariableOutsideScopeOfMethod() { + assertThrows(Exception.class, () -> Compiler.generateByteCodeFilesFromFiles(List.of("src/test/testFiles/Negative/CallVariableOutsideScope/OfMethod.java"))); + } + + @Test + public void CallVariableOutsideScopeOfWhile() { + assertThrows(Exception.class, () -> Compiler.generateByteCodeFilesFromFiles(List.of("src/test/testFiles/Negative/CallVariableOutsideScope/OfWhile.java"))); + } +} diff --git a/src/test/java/NegativeTests/ForbiddenParticularitiesInImplementation.java b/src/test/java/NegativeTests/ForbiddenParticularitiesInImplementation.java new file mode 100644 index 0000000..65e25db --- /dev/null +++ b/src/test/java/NegativeTests/ForbiddenParticularitiesInImplementation.java @@ -0,0 +1,45 @@ +package NegativeTests; + +import de.maishai.Compiler; +import org.junit.jupiter.api.Test; + +import java.util.List; + +import static org.junit.jupiter.api.Assertions.assertThrows; + +public class ForbiddenParticularitiesInImplementation { + @Test + public void ForbiddenParticularitiesInImplementationAccessModifier() { + assertThrows(Exception.class, () -> Compiler.generateByteCodeFilesFromFiles(List.of( + "src/test/testFiles/Negative/ForbiddenParticularitiesInImplementation/" + + "AccessModifier.java"))); + } + + @Test + public void ForbiddenParticularitiesInImplementationAddressingFieldWithoutThis() { + assertThrows(Exception.class, () -> Compiler.generateByteCodeFilesFromFiles(List.of( + "src/test/testFiles/Negative/ForbiddenParticularitiesInImplementation/" + + "AddressingFieldWithoutThis.java"))); + } + +// @Test +// public void ForbiddenParticularitiesInImplementationIMinusMinus() { +// assertThrows(Exception.class, () -> Compiler.generateByteCodeFilesFromFiles(List.of( +// "src/test/testFiles/Negative/ForbiddenParticularitiesInImplementation/" + +// "IMinusMinus.java"))); +// } +// +// @Test +// public void ForbiddenParticularitiesInImplementationIPlusPlus() { +// assertThrows(Exception.class, () -> Compiler.generateByteCodeFilesFromFiles(List.of( +// "src/test/testFiles/Negative/ForbiddenParticularitiesInImplementation/" + +// "IPlusPlus.java"))); +// } + + @Test + public void ForbiddenParticularitiesInImplementationUsingSystemOut() { + assertThrows(Exception.class, () -> Compiler.generateByteCodeFilesFromFiles(List.of( + "src/test/testFiles/Negative/ForbiddenParticularitiesInImplementation/" + + "UsingSystemOut.java"))); + } +} diff --git a/src/test/java/NegativeTests/MissingComponents.java b/src/test/java/NegativeTests/MissingComponents.java new file mode 100644 index 0000000..4e771ab --- /dev/null +++ b/src/test/java/NegativeTests/MissingComponents.java @@ -0,0 +1,291 @@ +package NegativeTests; + +import de.maishai.Compiler; +import org.junit.jupiter.api.Test; + +import java.util.List; + +import static org.junit.jupiter.api.Assertions.assertThrows; + +public class MissingComponents { + +// @Test +// public void MissingComponentsBraceInClass() { +// assertThrows(Exception.class, () -> { +// Compiler.generateByteCodeFilesFromFiles(List.of( +// "src/test/testFiles/Negative/MissingComponents/Brace/InClass.java")); +// }); +// } +// +// @Test +// public void MissingComponentsBraceInConstructor() { +// assertThrows(Exception.class, () -> { +// Compiler.generateByteCodeFilesFromFiles(List.of( +// "src/test/testFiles/Negative/MissingComponents/Brace/InConstructor.java")); +// }); +// } +// +// @Test +// public void MissingComponentsBraceInDoWhile() { +// assertThrows(Exception.class, () -> { +// Compiler.generateByteCodeFilesFromFiles(List.of( +// "src/test/testFiles/Negative/MissingComponents/Brace/InDoWhile.java")); +// }); +// } +// +// @Test +// public void MissingComponentsBraceInFor() { +// assertThrows(Exception.class, () -> { +// Compiler.generateByteCodeFilesFromFiles(List.of( +// "src/test/testFiles/Negative/MissingComponents/Brace/InFor.java")); +// }); +// } +// +// @Test +// public void MissingComponentsBraceInIf() { +// assertThrows(Exception.class, () -> { +// Compiler.generateByteCodeFilesFromFiles(List.of( +// "src/test/testFiles/Negative/MissingComponents/Brace/InIf.java")); +// }); +// } +// +// @Test +// public void MissingComponentsBraceInMethod() { +// assertThrows(Exception.class, () -> { +// Compiler.generateByteCodeFilesFromFiles(List.of( +// "src/test/testFiles/Negative/MissingComponents/Brace/InMethod.java")); +// }); +// } +// +// @Test +// public void MissingComponentsBraceInWhile() { +// assertThrows(Exception.class, () -> { +// Compiler.generateByteCodeFilesFromFiles(List.of( +// "src/test/testFiles/Negative/MissingComponents/Brace/InWhile.java")); +// }); +// } +// +// @Test +// public void MissingComponentsIdentifierInClass() { +// assertThrows(Exception.class, () -> { +// Compiler.generateByteCodeFilesFromFiles(List.of( +// "src/test/testFiles/Negative/MissingComponents/Identifier/InClass.java")); +// }); +// } +// +// @Test +// public void MissingComponentsIdentifierInConstructor() { +// assertThrows(Exception.class, () -> { +// Compiler.generateByteCodeFilesFromFiles(List.of( +// "src/test/testFiles/Negative/MissingComponents/Identifier/InConstructor.java")); +// }); +// } +// +// @Test +// public void MissingComponentsIdentifierInField() { +// assertThrows(Exception.class, () -> { +// Compiler.generateByteCodeFilesFromFiles(List.of( +// "src/test/testFiles/Negative/MissingComponents/Identifier/InField.java")); +// }); +// } +// +// @Test +// public void MissingComponentsIdentifierInFieldCall() { +// assertThrows(Exception.class, () -> { +// Compiler.generateByteCodeFilesFromFiles(List.of( +// "src/test/testFiles/Negative/MissingComponents/Identifier/InFieldCall.java")); +// }); +// } +// +// @Test +// public void MissingComponentsIdentifierInMethod() { +// assertThrows(Exception.class, () -> { +// Compiler.generateByteCodeFilesFromFiles(List.of( +// "src/test/testFiles/Negative/MissingComponents/Identifier/InMethod.java")); +// }); +// } +// +// @Test +// public void MissingComponentsIdentifierInMethodCall() { +// assertThrows(Exception.class, () -> { +// Compiler.generateByteCodeFilesFromFiles(List.of( +// "src/test/testFiles/Negative/MissingComponents/Identifier/InMethodCall.java")); +// }); +// } +// +// @Test +// public void MissingComponentsIdentifierInVariable() { +// assertThrows(Exception.class, () -> { +// Compiler.generateByteCodeFilesFromFiles(List.of( +// "src/test/testFiles/Negative/MissingComponents/Identifier/InVariable.java")); +// }); +// } +// +// @Test +// public void MissingComponentsPublicInClass() { +// assertThrows(Exception.class, () -> { +// Compiler.generateByteCodeFilesFromFiles(List.of( +// "src/test/testFiles/Negative/MissingComponents/Public/InClass.java")); +// }); +// } +// +// @Test +// public void MissingComponentsPublicInMethod() { +// assertThrows(Exception.class, () -> { +// Compiler.generateByteCodeFilesFromFiles(List.of( +// "src/test/testFiles/Negative/MissingComponents/Public/InMethod.java")); +// }); +// } +// +// @Test +// public void MissingComponentsRoundBracketsInConstructor() { +// assertThrows(Exception.class, () -> { +// Compiler.generateByteCodeFilesFromFiles(List.of( +// "src/test/testFiles/Negative/MissingComponents/RoundBrackets/InConstructor.java")); +// }); +// } +// +// @Test +// public void MissingComponentsRoundBracketsInDoWhile() { +// assertThrows(Exception.class, () -> { +// Compiler.generateByteCodeFilesFromFiles(List.of( +// "src/test/testFiles/Negative/MissingComponents/RoundBrackets/InDoWhile.java")); +// }); +// } +// +// @Test +// public void MissingComponentsRoundBracketsInElseIf() { +// assertThrows(Exception.class, () -> { +// Compiler.generateByteCodeFilesFromFiles(List.of( +// "src/test/testFiles/Negative/MissingComponents/RoundBrackets/InElseIf.java")); +// }); +// } +// +// @Test +// public void MissingComponentsRoundBracketsInFor() { +// assertThrows(Exception.class, () -> { +// Compiler.generateByteCodeFilesFromFiles(List.of( +// "src/test/testFiles/Negative/MissingComponents/RoundBrackets/InFor.java")); +// }); +// } +// +// @Test +// public void MissingComponentsRoundBracketsInIf() { +// assertThrows(Exception.class, () -> { +// Compiler.generateByteCodeFilesFromFiles(List.of( +// "src/test/testFiles/Negative/MissingComponents/RoundBrackets/InIf.java")); +// }); +// } +// +// @Test +// public void MissingComponentsRoundBracketsInMethod() { +// assertThrows(Exception.class, () -> { +// Compiler.generateByteCodeFilesFromFiles(List.of( +// "src/test/testFiles/Negative/MissingComponents/RoundBrackets/InMethod.java")); +// }); +// } +// +// @Test +// public void MissingComponentsRoundBracketsInMethodCall() { +// assertThrows(Exception.class, () -> { +// Compiler.generateByteCodeFilesFromFiles(List.of( +// "src/test/testFiles/Negative/MissingComponents/RoundBrackets/InMethodCall.java")); +// }); +// } +// +// @Test +// public void MissingComponentsRoundBracketsInNewObject() { +// assertThrows(Exception.class, () -> { +// Compiler.generateByteCodeFilesFromFiles(List.of( +// "src/test/testFiles/Negative/MissingComponents/RoundBrackets/InNewObject.java")); +// }); +// } +// +// @Test +// public void MissingComponentsRoundBracketsInWhile() { +// assertThrows(Exception.class, () -> { +// Compiler.generateByteCodeFilesFromFiles(List.of( +// "src/test/testFiles/Negative/MissingComponents/RoundBrackets/InWhile.java")); +// }); +// } +// +// @Test +// public void MissingComponentsSemicolonInAssignment() { +// assertThrows(Exception.class, () -> { +// Compiler.generateByteCodeFilesFromFiles(List.of( +// "src/test/testFiles/Negative/MissingComponents/Semicolon/InAssignment.java")); +// }); +// } +// +// @Test +// public void MissingComponentsSemicolonInDoWhile() { +// assertThrows(Exception.class, () -> { +// Compiler.generateByteCodeFilesFromFiles(List.of( +// "src/test/testFiles/Negative/MissingComponents/Semicolon/InDoWhile.java")); +// }); +// } +// +// @Test +// public void MissingComponentsSemicolonInField() { +// assertThrows(Exception.class, () -> { +// Compiler.generateByteCodeFilesFromFiles(List.of( +// "src/test/testFiles/Negative/MissingComponents/Semicolon/InField.java")); +// }); +// } +// +// @Test +// public void MissingComponentsSemicolonInMethodCall() { +// assertThrows(Exception.class, () -> { +// Compiler.generateByteCodeFilesFromFiles(List.of( +// "src/test/testFiles/Negative/MissingComponents/Semicolon/InMethodCall.java")); +// }); +// } +// +// @Test +// public void MissingComponentsSemicolonInReturn() { +// assertThrows(Exception.class, () -> { +// Compiler.generateByteCodeFilesFromFiles(List.of( +// "src/test/testFiles/Negative/MissingComponents/Semicolon/InReturn.java")); +// }); +// } +// +// @Test +// public void MissingComponentsTypeInField() { +// assertThrows(Exception.class, () -> { +// Compiler.generateByteCodeFilesFromFiles(List.of( +// "src/test/testFiles/Negative/MissingComponents/Type/InField.java")); +// }); +// } +// +// @Test +// public void MissingComponentsTypeInMethodSignature() { +// assertThrows(Exception.class, () -> { +// Compiler.generateByteCodeFilesFromFiles(List.of( +// "src/test/testFiles/Negative/MissingComponents/Type/InMethodSignature.java")); +// }); +// } +// +// @Test +// public void MissingComponentsTypeInParameter() { +// assertThrows(Exception.class, () -> { +// Compiler.generateByteCodeFilesFromFiles(List.of( +// "src/test/testFiles/Negative/MissingComponents/Type/InParameter.java")); +// }); +// } +// +// @Test +// public void MissingComponentsClassInClass() { +// assertThrows(Exception.class, () -> { +// Compiler.generateByteCodeFilesFromFiles(List.of( +// "src/test/testFiles/Negative/MissingComponents/ClassInClass.java")); +// }); +// } + + @Test + public void MissingComponentsClassOfObject() { + assertThrows(Exception.class, () -> { + Compiler.generateByteCodeFilesFromFiles(List.of( + "src/test/testFiles/Negative/MissingComponents/ClassOfObject.java")); + }); + } +} diff --git a/src/test/java/NegativeTests/UsingSameName.java b/src/test/java/NegativeTests/UsingSameName.java new file mode 100644 index 0000000..06fcc5f --- /dev/null +++ b/src/test/java/NegativeTests/UsingSameName.java @@ -0,0 +1,28 @@ +package NegativeTests; + +import de.maishai.Compiler; +import org.junit.jupiter.api.Test; + +import java.util.List; + +import static org.junit.jupiter.api.Assertions.assertThrows; + +public class UsingSameName { + @Test + public void UsingSameNameForParameterAndVariable() { + assertThrows(Exception.class, () -> Compiler.generateByteCodeFilesFromFiles(List.of( + "src/test/testFiles/Negative/UsingSameName/ForParameterAndVariable.java"))); + } + + @Test + public void UsingSameNameForTwoParameters() { + assertThrows(Exception.class, () -> Compiler.generateByteCodeFilesFromFiles(List.of( + "src/test/testFiles/Negative/UsingSameName/ForTwoParameters.java"))); + } + + @Test + public void UsingSameNameForTwoVariables() { + assertThrows(Exception.class, () -> Compiler.generateByteCodeFilesFromFiles(List.of( + "src/test/testFiles/Negative/UsingSameName/ForTwoVariables.java"))); + } +} diff --git a/src/test/java/NegativeTests/WrongType.java b/src/test/java/NegativeTests/WrongType.java new file mode 100644 index 0000000..c9d34bb --- /dev/null +++ b/src/test/java/NegativeTests/WrongType.java @@ -0,0 +1,294 @@ +package NegativeTests; + +import de.maishai.Compiler; +import org.junit.jupiter.api.Test; + +import java.util.List; + +import static org.junit.jupiter.api.Assertions.assertThrows; + +public class WrongType { + + @Test + public void WrongTypeCheckTypeDifferencesBetweenBoolAndChar() { + assertThrows(Exception.class, () -> Compiler.generateByteCodeFilesFromFiles(List.of( + "src/test/testFiles/Negative/WrongType/CheckTypeDifferences/BetweenBoolAndChar.java"))); + } + + @Test + public void WrongTypeCheckTypeDifferencesBetweenClassAndInt() { + assertThrows(Exception.class, () -> Compiler.generateByteCodeFilesFromFiles(List.of( + "src/test/testFiles/Negative/WrongType/CheckTypeDifferences/BetweenClassAndInt.java"))); + } + + @Test + public void WrongTypeCheckTypeDifferencesBetweenIntAndBool() { + assertThrows(Exception.class, () -> Compiler.generateByteCodeFilesFromFiles(List.of( + "src/test/testFiles/Negative/WrongType/CheckTypeDifferences/BetweenIntAndBool.java"))); + } + + @Test + public void WrongTypeCheckTypeDifferencesBetweenIntAndChar() { + assertThrows(Exception.class, () -> Compiler.generateByteCodeFilesFromFiles(List.of( + "src/test/testFiles/Negative/WrongType/CheckTypeDifferences/BetweenIntAndChar.java"))); + } + + @Test + public void WrongTypeCheckTypeDifferencesBetweenTwoClasses() { + assertThrows(Exception.class, () -> Compiler.generateByteCodeFilesFromFiles(List.of( + "src/test/testFiles/Negative/WrongType/CheckTypeDifferences/BetweenTwoClasses.java", + "src/test/testFiles/Negative/WrongType/CheckTypeDifferences/BetweenTwoClassesClassTwo.java"))); + } + + @Test + public void WrongTypeInAssigmentInAttributeOfObjectGet() { + assertThrows(Exception.class, () -> Compiler.generateByteCodeFilesFromFiles(List.of( + "src/test/testFiles/Negative/WrongType/InAssignment/InAttributeOfObjectGet.java"))); + } + + @Test + public void WrongTypeInAssigmentInAttributeOfObjectSet() { + assertThrows(Exception.class, () -> Compiler.generateByteCodeFilesFromFiles(List.of( + "src/test/testFiles/Negative/WrongType/InAssignment/InAttributeOfObjectSet.java"))); + } + + @Test + public void WrongTypeInAssigmentInFieldToField() { + assertThrows(Exception.class, () -> Compiler.generateByteCodeFilesFromFiles(List.of( + "src/test/testFiles/Negative/WrongType/InAssignment/InFieldToField.java"))); + } + + @Test + public void WrongTypeInAssigmentInFieldToVariable() { + assertThrows(Exception.class, () -> Compiler.generateByteCodeFilesFromFiles(List.of( + "src/test/testFiles/Negative/WrongType/InAssignment/InFieldToVariable.java"))); + } + + @Test + public void WrongTypeInAssigmentInMethodCall() { + assertThrows(Exception.class, () -> Compiler.generateByteCodeFilesFromFiles(List.of( + "src/test/testFiles/Negative/WrongType/InAssignment/InMethodCall.java"))); + } + + @Test + public void WrongTypeInAssigmentInMethodOfObjectGet() { + assertThrows(Exception.class, () -> Compiler.generateByteCodeFilesFromFiles(List.of( + "src/test/testFiles/Negative/WrongType/InAssignment/InMethodOfObjectGet.java"))); + } + + @Test + public void WrongTypeInAssigmentInParameter() { + assertThrows(Exception.class, () -> Compiler.generateByteCodeFilesFromFiles(List.of( + "src/test/testFiles/Negative/WrongType/InAssignment/InParameter.java"))); + } + + @Test + public void WrongTypeUsingWithOperatorsAndOnChar() { + assertThrows(Exception.class, () -> Compiler.generateByteCodeFilesFromFiles(List.of( + "src/test/testFiles/Negative/WrongType/UsingWithOperators/And/OnChar.java"))); + } + + @Test + public void WrongTypeUsingWithOperatorsAndOnInt() { + assertThrows(Exception.class, () -> Compiler.generateByteCodeFilesFromFiles(List.of( + "src/test/testFiles/Negative/WrongType/UsingWithOperators/And/OnInt.java"))); + } + + @Test + public void WrongTypeUsingWithOperatorsAndOnObject() { + assertThrows(Exception.class, () -> Compiler.generateByteCodeFilesFromFiles(List.of( + "src/test/testFiles/Negative/WrongType/UsingWithOperators/And/OnObject.java"))); + } + + @Test + public void WrongTypeUsingWithOperatorsDivOnBoolean() { + assertThrows(Exception.class, () -> Compiler.generateByteCodeFilesFromFiles(List.of( + "src/test/testFiles/Negative/WrongType/UsingWithOperators/Div/OnBoolean.java"))); + } + + @Test + public void WrongTypeUsingWithOperatorsDivOnChar() { + assertThrows(Exception.class, () -> Compiler.generateByteCodeFilesFromFiles(List.of( + "src/test/testFiles/Negative/WrongType/UsingWithOperators/Div/OnChar.java"))); + } + + @Test + public void WrongTypeUsingWithOperatorsDivOnObject() { + assertThrows(Exception.class, () -> Compiler.generateByteCodeFilesFromFiles(List.of( + "src/test/testFiles/Negative/WrongType/UsingWithOperators/Div/OnObject.java"))); + } + + @Test + public void WrongTypeUsingWithOperatorsMinOnBoolean() { + assertThrows(Exception.class, () -> Compiler.generateByteCodeFilesFromFiles(List.of( + "src/test/testFiles/Negative/WrongType/UsingWithOperators/Min/OnBoolean.java"))); + } + + @Test + public void WrongTypeUsingWithOperatorsMinOnChar() { + assertThrows(Exception.class, () -> Compiler.generateByteCodeFilesFromFiles(List.of( + "src/test/testFiles/Negative/WrongType/UsingWithOperators/Min/OnChar.java"))); + } + + @Test + public void WrongTypeUsingWithOperatorsMinOnObject() { + assertThrows(Exception.class, () -> Compiler.generateByteCodeFilesFromFiles(List.of( + "src/test/testFiles/Negative/WrongType/UsingWithOperators/Min/OnObject.java"))); + } + + @Test + public void WrongTypeUsingWithOperatorsModOnBoolean() { + assertThrows(Exception.class, () -> Compiler.generateByteCodeFilesFromFiles(List.of( + "src/test/testFiles/Negative/WrongType/UsingWithOperators/Mod/OnBoolean.java"))); + } + + @Test + public void WrongTypeUsingWithOperatorsModOnChar() { + assertThrows(Exception.class, () -> Compiler.generateByteCodeFilesFromFiles(List.of( + "src/test/testFiles/Negative/WrongType/UsingWithOperators/Mod/OnChar.java"))); + } + + @Test + public void WrongTypeUsingWithOperatorsModOnObject() { + assertThrows(Exception.class, () -> Compiler.generateByteCodeFilesFromFiles(List.of( + "src/test/testFiles/Negative/WrongType/UsingWithOperators/Mod/OnObject.java"))); + } + + @Test + public void WrongTypeUsingWithOperatorsMulOnBoolean() { + assertThrows(Exception.class, () -> Compiler.generateByteCodeFilesFromFiles(List.of( + "src/test/testFiles/Negative/WrongType/UsingWithOperators/Mul/OnBoolean.java"))); + } + + @Test + public void WrongTypeUsingWithOperatorsMulOnChar() { + assertThrows(Exception.class, () -> Compiler.generateByteCodeFilesFromFiles(List.of( + "src/test/testFiles/Negative/WrongType/UsingWithOperators/Mul/OnChar.java"))); + } + + @Test + public void WrongTypeUsingWithOperatorsMulOnObject() { + assertThrows(Exception.class, () -> Compiler.generateByteCodeFilesFromFiles(List.of( + "src/test/testFiles/Negative/WrongType/UsingWithOperators/Mul/OnObject.java"))); + } + + @Test + public void WrongTypeUsingWithOperatorsNotOnChar() { + assertThrows(Exception.class, () -> Compiler.generateByteCodeFilesFromFiles(List.of( + "src/test/testFiles/Negative/WrongType/UsingWithOperators/Not/OnChar.java"))); + } + + @Test + public void WrongTypeUsingWithOperatorsNotOnInt() { + assertThrows(Exception.class, () -> Compiler.generateByteCodeFilesFromFiles(List.of( + "src/test/testFiles/Negative/WrongType/UsingWithOperators/Not/OnInt.java"))); + } + + @Test + public void WrongTypeUsingWithOperatorsNotOnObject() { + assertThrows(Exception.class, () -> Compiler.generateByteCodeFilesFromFiles(List.of( + "src/test/testFiles/Negative/WrongType/UsingWithOperators/Not/OnObject.java"))); + } + + @Test + public void WrongTypeUsingWithOperatorsOrOnChar() { + assertThrows(Exception.class, () -> Compiler.generateByteCodeFilesFromFiles(List.of( + "src/test/testFiles/Negative/WrongType/UsingWithOperators/Or/OnChar.java"))); + } + + @Test + public void WrongTypeUsingWithOperatorsOrOnInt() { + assertThrows(Exception.class, () -> Compiler.generateByteCodeFilesFromFiles(List.of( + "src/test/testFiles/Negative/WrongType/UsingWithOperators/Or/OnInt.java"))); + } + + @Test + public void WrongTypeUsingWithOperatorsOrOnObject() { + assertThrows(Exception.class, () -> Compiler.generateByteCodeFilesFromFiles(List.of( + "src/test/testFiles/Negative/WrongType/UsingWithOperators/Or/OnObject.java"))); + } + + @Test + public void WrongTypeUsingWithOperatorsPlusOnBoolean() { + assertThrows(Exception.class, () -> Compiler.generateByteCodeFilesFromFiles(List.of( + "src/test/testFiles/Negative/WrongType/UsingWithOperators/Plus/OnBoolean.java"))); + } + + @Test + public void WrongTypeUsingWithOperatorsPlusOnChar() { + assertThrows(Exception.class, () -> Compiler.generateByteCodeFilesFromFiles(List.of( + "src/test/testFiles/Negative/WrongType/UsingWithOperators/Plus/OnChar.java"))); + } + + @Test + public void WrongTypeUsingWithOperatorsPlusOnObject() { + assertThrows(Exception.class, () -> Compiler.generateByteCodeFilesFromFiles(List.of( + "src/test/testFiles/Negative/WrongType/UsingWithOperators/Plus/OnObject.java"))); + } + + @Test + public void WrongTypeUsingWithOperatorsOperatorReturnValuesAnd() { + assertThrows(Exception.class, () -> Compiler.generateByteCodeFilesFromFiles(List.of( + "src/test/testFiles/Negative/WrongType/UsingWithOperators/OperatorReturnValues/And.java"))); + } + + @Test + public void WrongTypeUsingWithOperatorsOperatorReturnValuesDiv() { + assertThrows(Exception.class, () -> Compiler.generateByteCodeFilesFromFiles(List.of( + "src/test/testFiles/Negative/WrongType/UsingWithOperators/OperatorReturnValues/Div.java"))); + } + + @Test + public void WrongTypeUsingWithOperatorsOperatorReturnValuesMin() { + assertThrows(Exception.class, () -> Compiler.generateByteCodeFilesFromFiles(List.of( + "src/test/testFiles/Negative/WrongType/UsingWithOperators/OperatorReturnValues/Min.java"))); + } + + @Test + public void WrongTypeUsingWithOperatorsOperatorReturnValuesMod() { + assertThrows(Exception.class, () -> Compiler.generateByteCodeFilesFromFiles(List.of( + "src/test/testFiles/Negative/WrongType/UsingWithOperators/OperatorReturnValues/Mod.java"))); + } + + @Test + public void WrongTypeUsingWithOperatorsOperatorReturnValuesMul() { + assertThrows(Exception.class, () -> Compiler.generateByteCodeFilesFromFiles(List.of( + "src/test/testFiles/Negative/WrongType/UsingWithOperators/OperatorReturnValues/Mul.java"))); + } + + @Test + public void WrongTypeUsingWithOperatorsOperatorReturnValuesNot() { + assertThrows(Exception.class, () -> Compiler.generateByteCodeFilesFromFiles(List.of( + "src/test/testFiles/Negative/WrongType/UsingWithOperators/OperatorReturnValues/Not.java"))); + } + + @Test + public void WrongTypeUsingWithOperatorsOperatorReturnValuesOr() { + assertThrows(Exception.class, () -> Compiler.generateByteCodeFilesFromFiles(List.of( + "src/test/testFiles/Negative/WrongType/UsingWithOperators/OperatorReturnValues/Or.java"))); + } + + @Test + public void WrongTypeUsingWithOperatorsOperatorReturnValuesPlus() { + assertThrows(Exception.class, () -> Compiler.generateByteCodeFilesFromFiles(List.of( + "src/test/testFiles/Negative/WrongType/UsingWithOperators/OperatorReturnValues/Plus.java"))); + } + + @Test + public void WrongTypeUsingWithOperatorsInMethodCallParameters() { + assertThrows(Exception.class, () -> Compiler.generateByteCodeFilesFromFiles(List.of( + "src/test/testFiles/Negative/WrongType/InMethodCallParameters.java"))); + } + + @Test + public void WrongTypeUsingWithOperatorsInMethodOfObjectCallParameters() { + assertThrows(Exception.class, () -> Compiler.generateByteCodeFilesFromFiles(List.of( + "src/test/testFiles/Negative/WrongType/InMethodOfObjectCallParameters.java"))); + } + + @Test + public void WrongTypeUsingWithOperatorsInReturnStatement() { + assertThrows(Exception.class, () -> Compiler.generateByteCodeFilesFromFiles(List.of( + "src/test/testFiles/Negative/WrongType/InReturnStatement.java"))); + } +} diff --git a/src/test/java/ScannerParserTests.java b/src/test/java/ScannerParserTests.java index 03e6145..9ad383f 100644 --- a/src/test/java/ScannerParserTests.java +++ b/src/test/java/ScannerParserTests.java @@ -7,59 +7,59 @@ import java.util.List; import static org.junit.jupiter.api.Assertions.assertEquals; -public class ScannerParserTests { +class ScannerParserTests { // // @Test -// public void testPublicClass() { +// void testPublicClass() { // Program resultAst = Compiler.generateASTFromFile(List.of("src/test/testFiles/JavaTestfilesMore/PublicClass.java")); // assertEquals(AbstractSyntax_PublicClass.get(), resultAst); // } // // @Test -// public void testClassWithField() { +// void testClassWithField() { // Program resultAst = Compiler.generateASTFromFile(List.of("src/test/testFiles/JavaTestfilesMore/ClassWithField.java")); // assertEquals(AbstractSyntax_ClassWithField.get(), resultAst); // } // // @Test -// public void testClassWithConstructor() { +// void testClassWithConstructor() { // Program resultAst = Compiler.generateASTFromFile(List.of("src/test/testFiles/JavaTestfilesMore/ClassWithConstructor.java")); // assertEquals(AbstractSyntax_ClassWithConstructor.get(), resultAst); // } // // @Test -// public void testClassWithMethod() { +// void testClassWithMethod() { // Program resultAst = Compiler.generateASTFromFile(List.of("src/test/testFiles/JavaTestfilesMore/ClassWithMethod.java")); // assertEquals(AbstractSyntax_ClassWithMethod.get(), resultAst); // } // // @Test -// public void testClassWithConstructorWithCodeInComments() { +// void testClassWithConstructorWithCodeInComments() { // Program resultAst = Compiler.generateASTFromFile(List.of("src/test/testFiles/JavaTestfilesMore/ClassWithConstructorWithCodeInComments.java")); // assertEquals(AbstractSyntax_ClassWithConstructorWithCodeInComments.get(), resultAst); // } // // @Test -// public void testClassWithConstructorWithParameters() { +// void testClassWithConstructorWithParameters() { // Program resultAst = Compiler.generateASTFromFile(List.of("src/test/testFiles/JavaTestfilesMore/ClassWithConstructorWithParameters.java")); // assertEquals(AbstractSyntax_ClassWithConstructorWithParameters.get(), resultAst); // } // //// @Test -//// public void testClassWithMethodAndField() { +//// void testClassWithMethodAndField() { //// Program resultAst = Compiler.generateASTFromFile(List.of("src/test/testFiles/JavaTestfilesMore/ClassWithMethodAndField.java")); //// assertEquals(AbstractSyntax_ClassWithMethodAndField.get(), resultAst); //// } // //TODO: fix // // @Test -// public void testClassWithConstructorAndMethodCall() { +// void testClassWithConstructorAndMethodCall() { // Program resultAst = Compiler.generateASTFromFile(List.of("src/test/testFiles/JavaTestfilesMore/ClassWithConstructorAndMethodCall.java")); // assertEquals(AbstractSyntax_ClassWithConstructorAndMethodCall.get(), resultAst); // } // // @Test -// public void testComplexClass() { +// void testComplexClass() { // Program resultAst = Compiler.generateASTFromFile(List.of("src/test/testFiles/JavaTestfilesMore/ComplexClass.java")); // assertEquals(AbstractSyntax_ComplexClass.get(), resultAst); // } @@ -74,104 +74,103 @@ public class ScannerParserTests { // Feature Tests @Test - public void testBreak() { + void testBreak() { Program resultAst = Compiler.generateASTFromFiles(List.of("src/test/testFiles/ASTandTypedASTFeatures/Break.java")); assertEquals(AST_Break.get(), resultAst); } @Test - public void testClass() { + void testClass() { Program resultAst = Compiler.generateASTFromFiles(List.of("src/test/testFiles/ASTandTypedASTFeatures/Class.java")); assertEquals(AST_Class.get(), resultAst); } @Test - public void testClassObjects() { + void testClassObjects() { Program resultAst = Compiler.generateASTFromFiles(List.of("src/test/testFiles/ASTandTypedASTFeatures/ClassObjects.java")); assertEquals(AST_ClassObjects.get(), resultAst); } - //TODO: nochmal drüberschauen, nachfragen wegen true/false bei FieldVarAccess @Test - public void testComment() { + void testComment() { Program resultAst = Compiler.generateASTFromFiles(List.of("src/test/testFiles/ASTandTypedASTFeatures/Comment.java")); assertEquals(AST_Comment.get(), resultAst); } @Test - public void testCompAssign() { + void testCompAssign() { Program resultAst = Compiler.generateASTFromFiles(List.of("src/test/testFiles/ASTandTypedASTFeatures/CompAssign.java")); assertEquals(AST_CompAssign.get(), resultAst); } @Test - public void testComplexCalls() { + void testComplexCalls() { Program resultAst = Compiler.generateASTFromFiles(List.of("src/test/testFiles/ASTandTypedASTFeatures/ComplexCalls.java")); assertEquals(AST_ComplexCalls.get(), resultAst); } @Test - public void testConstructor() { + void testConstructor() { Program resultAst = Compiler.generateASTFromFiles(List.of("src/test/testFiles/ASTandTypedASTFeatures/Constructor.java")); assertEquals(AST_Constructor.get(), resultAst); } @Test - public void testContinue() { + void testContinue() { Program resultAst = Compiler.generateASTFromFiles(List.of("src/test/testFiles/ASTandTypedASTFeatures/Continue.java")); assertEquals(AST_Continue.get(), resultAst); } @Test - public void testDataTypes() { + void testDataTypes() { Program resultAst = Compiler.generateASTFromFiles(List.of("src/test/testFiles/ASTandTypedASTFeatures/DataTypes.java")); assertEquals(AST_DataTypes.get(), resultAst); } @Test - public void testField() { + void testField() { Program resultAst = Compiler.generateASTFromFiles(List.of("src/test/testFiles/ASTandTypedASTFeatures/Field.java")); assertEquals(AST_Field.get(), resultAst); } @Test - public void testFor() { + void testFor() { Program resultAst = Compiler.generateASTFromFiles(List.of("src/test/testFiles/ASTandTypedASTFeatures/For.java")); assertEquals(AST_For.get(), resultAst); } @Test - public void testIf() { + void testIf() { Program resultAst = Compiler.generateASTFromFiles(List.of("src/test/testFiles/ASTandTypedASTFeatures/If.java")); assertEquals(AST_If.get(), resultAst); } @Test - public void testLogicExpr() { + void testLogicExpr() { Program resultAst = Compiler.generateASTFromFiles(List.of("src/test/testFiles/ASTandTypedASTFeatures/LogicExpr.java")); assertEquals(AST_LogicExpr.get(), resultAst); } @Test - public void testMain() { + void testMain() { Program resultAst = Compiler.generateASTFromFiles(List.of("src/test/testFiles/ASTandTypedASTFeatures/Main.java")); assertEquals(AST_Main.get(), resultAst); } @Test - public void testMethod() { + void testMethod() { Program resultAst = Compiler.generateASTFromFiles(List.of("src/test/testFiles/ASTandTypedASTFeatures/Method.java")); assertEquals(AST_Method.get(), resultAst); } @Test - public void testMethodCall() { + void testMethodCall() { Program resultAst = Compiler.generateASTFromFiles(List.of("src/test/testFiles/ASTandTypedASTFeatures/MethodCall.java")); assertEquals(AST_MethodCall.get(), resultAst); } @Test - public void testMultipleClasses() { + void testMultipleClasses() { Program resultAst = Compiler.generateASTFromFiles( List.of("src/test/testFiles/ASTandTypedASTFeatures/MultipleClasses1.java", "src/test/testFiles/ASTandTypedASTFeatures/MultipleClasses2.java")); @@ -179,43 +178,43 @@ public class ScannerParserTests { } @Test - public void testOperators() { + void testOperators() { Program resultAst = Compiler.generateASTFromFiles(List.of("src/test/testFiles/ASTandTypedASTFeatures/Operators.java")); assertEquals(AST_Operators.get(), resultAst); } @Test - public void testOverloaded() { + void testOverloaded() { Program resultAst = Compiler.generateASTFromFiles(List.of("src/test/testFiles/ASTandTypedASTFeatures/Overloaded.java")); assertEquals(AST_Overloaded.get(), resultAst); } @Test - public void testPrint() { + void testPrint() { Program resultAst = Compiler.generateASTFromFiles(List.of("src/test/testFiles/ASTandTypedASTFeatures/Print.java")); assertEquals(AST_Print.get(), resultAst); } @Test - public void testReturn() { + void testReturn() { Program resultAst = Compiler.generateASTFromFiles(List.of("src/test/testFiles/ASTandTypedASTFeatures/Return.java")); assertEquals(AST_Return.get(), resultAst); } @Test - public void testUnary() { + void testUnary() { Program resultAst = Compiler.generateASTFromFiles(List.of("src/test/testFiles/ASTandTypedASTFeatures/Unary.java")); assertEquals(AST_Unary.get(), resultAst); } @Test - public void testVariableDefWithDecl() { + void testVariableDefWithDecl() { Program resultAst = Compiler.generateASTFromFiles(List.of("src/test/testFiles/ASTandTypedASTFeatures/VariableDefWithDecl.java")); assertEquals(AST_VariableDefWithDecl.get(), resultAst); } @Test - public void testWhile() { + void testWhile() { Program resultAst = Compiler.generateASTFromFiles(List.of("src/test/testFiles/ASTandTypedASTFeatures/While.java")); assertEquals(AST_While.get(), resultAst); } diff --git a/src/test/java/TypingTests.java b/src/test/java/TypingTests.java index 31d23bd..0fb34f2 100644 --- a/src/test/java/TypingTests.java +++ b/src/test/java/TypingTests.java @@ -6,28 +6,28 @@ import testResources.AST.ASTFeatures.*; import static org.junit.jupiter.api.Assertions.assertEquals; -public class TypingTests { +class TypingTests { // // @Test -// public void testPublicClass() { +// void testPublicClass() { // TypedProgram resultTypedAst = Compiler.generateTypedASTFromAst(AbstractSyntax_PublicClass.get()); // assertEquals(TypedAbstractSyntax_PublicClass.get(), resultTypedAst); // } // // @Test -// public void testClassWithField() { +// void testClassWithField() { // TypedProgram resultTypedAst = Compiler.generateTypedASTFromAst(AbstractSyntax_ClassWithField.get()); // assertEquals(TypedAbstractSyntax_ClassWithField.get(), resultTypedAst); // } // // @Test -// public void testClassWithConstructor() { +// void testClassWithConstructor() { // TypedProgram resultTypedAst = Compiler.generateTypedASTFromAst(AbstractSyntax_ClassWithConstructor.get()); // assertEquals(TypedAbstractSyntax_ClassWithConstructor.get(), resultTypedAst); // } // //// @Test -//// public void testComplexClass() { +//// void testComplexClass() { //// TypedProgram resultTypedAst = Compiler.generateTypedASTFromAst(AbstractSyntax_ComplexClass.get()); //// assertEquals(TypedAbstractSyntax_ComplexClass.get(), resultTypedAst); //// } @@ -37,146 +37,145 @@ public class TypingTests { // Feature Tests @Test - public void testBreak() { + void testBreak() { TypedProgram resultTypedAst = Compiler.generateTypedASTFromAst(AST_Break.get()); assertEquals(TypedAST_Break.get(), resultTypedAst); } @Test - public void testClass() { + void testClass() { TypedProgram resultTypedAst = Compiler.generateTypedASTFromAst(AST_Class.get()); assertEquals(TypedAST_Class.get(), resultTypedAst); } @Test - public void testClassObjects() { + void testClassObjects() { TypedProgram resultTypedAst = Compiler.generateTypedASTFromAst(AST_ClassObjects.get()); assertEquals(TypedAST_ClassObjects.get(), resultTypedAst); } @Test - public void testComment() { + void testComment() { TypedProgram resultTypedAst = Compiler.generateTypedASTFromAst(AST_Comment.get()); assertEquals(TypedAST_Comment.get(), resultTypedAst); } @Test - public void testCompAssign() { + void testCompAssign() { TypedProgram resultTypedAst = Compiler.generateTypedASTFromAst(AST_CompAssign.get()); assertEquals(TypedAST_CompAssign.get(), resultTypedAst); } @Test - public void testComplexCalls() { + void testComplexCalls() { TypedProgram resultTypedAst = Compiler.generateTypedASTFromAst(AST_ComplexCalls.get()); assertEquals(TypedAST_ComplexCalls.get(), resultTypedAst); } @Test - public void testConstructor() { + void testConstructor() { TypedProgram resultTypedAst = Compiler.generateTypedASTFromAst(AST_Constructor.get()); assertEquals(TypedAST_Constructor.get(), resultTypedAst); } - // TODO: Konstruktor hat doch immer den Typ der Klasse?, Parameter werden als TypedLocalVariable aufgeführt, notwendig? @Test - public void testContinue() { + void testContinue() { TypedProgram resultTypedAst = Compiler.generateTypedASTFromAst(AST_Continue.get()); assertEquals(TypedAST_Continue.get(), resultTypedAst); } @Test - public void testDataTypes() { + void testDataTypes() { TypedProgram resultTypedAst = Compiler.generateTypedASTFromAst(AST_DataTypes.get()); assertEquals(TypedAST_DataTypes.get(), resultTypedAst); } @Test - public void testField() { + void testField() { TypedProgram resultTypedAst = Compiler.generateTypedASTFromAst(AST_Field.get()); assertEquals(TypedAST_Field.get(), resultTypedAst); } @Test - public void testFor() { + void testFor() { TypedProgram resultTypedAst = Compiler.generateTypedASTFromAst(AST_For.get()); assertEquals(TypedAST_For.get(), resultTypedAst); } @Test - public void testIf() { + void testIf() { TypedProgram resultTypedAst = Compiler.generateTypedASTFromAst(testResources.AST.ASTFeatures.AST_If.get()); assertEquals(TypedAST_If.get(), resultTypedAst); } @Test - public void testLogicExpr() { + void testLogicExpr() { TypedProgram resultTypedAst = Compiler.generateTypedASTFromAst(AST_LogicExpr.get()); assertEquals(TypedAST_LogicExpr.get(), resultTypedAst); } @Test - public void testMain() { + void testMain() { TypedProgram resultTypedAst = Compiler.generateTypedASTFromAst(AST_Main.get()); assertEquals(TypedAST_Main.get(), resultTypedAst); } @Test - public void testMethod() { + void testMethod() { TypedProgram resultTypedAst = Compiler.generateTypedASTFromAst(AST_Method.get()); assertEquals(TypedAST_Method.get(), resultTypedAst); } @Test - public void testMethodCall() { + void testMethodCall() { TypedProgram resultTypedAst = Compiler.generateTypedASTFromAst(AST_MethodCall.get()); assertEquals(TypedAST_MethodCall.get(), resultTypedAst); } @Test - public void testMultipleClasses() { + void testMultipleClasses() { TypedProgram resultTypedAst = Compiler.generateTypedASTFromAst(AST_MultipleClasses.get()); assertEquals(TypedAST_MultipleClasses.get(), resultTypedAst); } @Test - public void testOperators() { + void testOperators() { TypedProgram resultTypedAst = Compiler.generateTypedASTFromAst(AST_Operators.get()); assertEquals(TypedAST_Operators.get(), resultTypedAst); } @Test - public void testOverloaded() { + void testOverloaded() { TypedProgram resultTypedAst = Compiler.generateTypedASTFromAst(AST_Overloaded.get()); assertEquals(TypedAST_Overloaded.get(), resultTypedAst); } @Test - public void testPrint() { + void testPrint() { TypedProgram resultTypedAst = Compiler.generateTypedASTFromAst(AST_Print.get()); assertEquals(TypedAST_Print.get(), resultTypedAst); } @Test - public void testReturn() { + void testReturn() { TypedProgram resultTypedAst = Compiler.generateTypedASTFromAst(AST_Return.get()); assertEquals(TypedAST_Return.get(), resultTypedAst); } @Test - public void testUnary() { + void testUnary() { TypedProgram resultTypedAst = Compiler.generateTypedASTFromAst(AST_Unary.get()); assertEquals(TypedAST_Unary.get(), resultTypedAst); } @Test - public void testVariableDefWithDecl() { + void testVariableDefWithDecl() { TypedProgram resultTypedAst = Compiler.generateTypedASTFromAst(AST_VariableDefWithDecl.get()); assertEquals(TypedAST_VariableDefWithDecl.get(), resultTypedAst); } @Test - public void testWhile() { + void testWhile() { TypedProgram resultTypedAst = Compiler.generateTypedASTFromAst(AST_While.get()); assertEquals(TypedAST_While.get(), resultTypedAst); } diff --git a/src/test/testFiles/Negative/AssignmentOutsideMethod.java b/src/test/testFiles/Negative/AssignmentOutsideMethod.java new file mode 100644 index 0000000..791d709 --- /dev/null +++ b/src/test/testFiles/Negative/AssignmentOutsideMethod.java @@ -0,0 +1,4 @@ +public class AssignmentOutsideMethod { + int a; + a = 5; +} \ No newline at end of file diff --git a/src/test/testFiles/Negative/CallVariableOutsideScope/OfElse.java b/src/test/testFiles/Negative/CallVariableOutsideScope/OfElse.java new file mode 100644 index 0000000..0b529d8 --- /dev/null +++ b/src/test/testFiles/Negative/CallVariableOutsideScope/OfElse.java @@ -0,0 +1,10 @@ +public class OfElse { + public void test(boolean b) { + if (b) { + b = false; + } else { + int a = 5; + } + a = 5; + } +} \ No newline at end of file diff --git a/src/test/testFiles/Negative/CallVariableOutsideScope/OfFor.java b/src/test/testFiles/Negative/CallVariableOutsideScope/OfFor.java new file mode 100644 index 0000000..266b8b7 --- /dev/null +++ b/src/test/testFiles/Negative/CallVariableOutsideScope/OfFor.java @@ -0,0 +1,8 @@ +public class OfFor { + public void method() { + for (int i = 0; i < 10; i+=1) { + int a = 5; + } + a = 3; + } +} \ No newline at end of file diff --git a/src/test/testFiles/Negative/CallVariableOutsideScope/OfIf.java b/src/test/testFiles/Negative/CallVariableOutsideScope/OfIf.java new file mode 100644 index 0000000..655a7bb --- /dev/null +++ b/src/test/testFiles/Negative/CallVariableOutsideScope/OfIf.java @@ -0,0 +1,8 @@ +public class OfIf { + public void test() { + if (true) { + int a = 5; + } + a = 5; + } +} \ No newline at end of file diff --git a/src/test/testFiles/Negative/CallVariableOutsideScope/OfIfElse.java b/src/test/testFiles/Negative/CallVariableOutsideScope/OfIfElse.java new file mode 100644 index 0000000..fefec50 --- /dev/null +++ b/src/test/testFiles/Negative/CallVariableOutsideScope/OfIfElse.java @@ -0,0 +1,10 @@ +public class OfIfElse { + public void test(boolean b) { + if (b) { + b = false; + } else if(!b) { + int a = 5; + } + a = 6; + } +} \ No newline at end of file diff --git a/src/test/testFiles/Negative/CallVariableOutsideScope/OfMethod.java b/src/test/testFiles/Negative/CallVariableOutsideScope/OfMethod.java new file mode 100644 index 0000000..f782ff4 --- /dev/null +++ b/src/test/testFiles/Negative/CallVariableOutsideScope/OfMethod.java @@ -0,0 +1,9 @@ +public class OfMethod { + public void method1() { + int a = 5; + } + + public void method2() { + a = 3; + } +} \ No newline at end of file diff --git a/src/test/testFiles/Negative/CallVariableOutsideScope/OfWhile.java b/src/test/testFiles/Negative/CallVariableOutsideScope/OfWhile.java new file mode 100644 index 0000000..d39bc38 --- /dev/null +++ b/src/test/testFiles/Negative/CallVariableOutsideScope/OfWhile.java @@ -0,0 +1,8 @@ +public class OfWhile { + public void method() { + while (a < 10) { + int a = 0; + } + a = 5; + } +} \ No newline at end of file diff --git a/src/test/testFiles/Negative/CallingFieldInMainMethod.java b/src/test/testFiles/Negative/CallingFieldInMainMethod.java new file mode 100644 index 0000000..26376b3 --- /dev/null +++ b/src/test/testFiles/Negative/CallingFieldInMainMethod.java @@ -0,0 +1,6 @@ +public class InMainMethod { + int a; + public static void main(String[] args) { + this.a = 5; + } +} \ No newline at end of file diff --git a/src/test/testFiles/Negative/ForbiddenParticularitiesInImplementation/AccessModifier.java b/src/test/testFiles/Negative/ForbiddenParticularitiesInImplementation/AccessModifier.java new file mode 100644 index 0000000..3fa0824 --- /dev/null +++ b/src/test/testFiles/Negative/ForbiddenParticularitiesInImplementation/AccessModifier.java @@ -0,0 +1,3 @@ +public class AccessModifier { + private int x; +} \ No newline at end of file diff --git a/src/test/testFiles/Negative/AddressingFieldWithoutThis.java b/src/test/testFiles/Negative/ForbiddenParticularitiesInImplementation/AddressingFieldWithoutThis.java similarity index 100% rename from src/test/testFiles/Negative/AddressingFieldWithoutThis.java rename to src/test/testFiles/Negative/ForbiddenParticularitiesInImplementation/AddressingFieldWithoutThis.java diff --git a/src/test/testFiles/Negative/ForbiddenParticularitiesInImplementation/IMinusMinus.java b/src/test/testFiles/Negative/ForbiddenParticularitiesInImplementation/IMinusMinus.java new file mode 100644 index 0000000..eee197b --- /dev/null +++ b/src/test/testFiles/Negative/ForbiddenParticularitiesInImplementation/IMinusMinus.java @@ -0,0 +1,7 @@ +public class IMinusMinus { + public IMinusMinus() { + int a; + a = 5; + a--; + } +} \ No newline at end of file diff --git a/src/test/testFiles/Negative/ForbiddenParticularitiesInImplementation/IPlusPlus.java b/src/test/testFiles/Negative/ForbiddenParticularitiesInImplementation/IPlusPlus.java new file mode 100644 index 0000000..57eabee --- /dev/null +++ b/src/test/testFiles/Negative/ForbiddenParticularitiesInImplementation/IPlusPlus.java @@ -0,0 +1,7 @@ +public class IPlusPlus { + public IPlusPlus() { + int a; + a = 5; + a++; + } +} \ No newline at end of file diff --git a/src/test/testFiles/Negative/ForbiddenParticularitiesInImplementation/UsingSystemOut.java b/src/test/testFiles/Negative/ForbiddenParticularitiesInImplementation/UsingSystemOut.java new file mode 100644 index 0000000..1b83c48 --- /dev/null +++ b/src/test/testFiles/Negative/ForbiddenParticularitiesInImplementation/UsingSystemOut.java @@ -0,0 +1,5 @@ +public class UsingSystemOut { + public UsingSystemOut() { + System.out.println('b'); + } +} \ No newline at end of file diff --git a/src/test/testFiles/Negative/MissingComponents/Brace/InClass.java b/src/test/testFiles/Negative/MissingComponents/Brace/InClass.java new file mode 100644 index 0000000..34dcf97 --- /dev/null +++ b/src/test/testFiles/Negative/MissingComponents/Brace/InClass.java @@ -0,0 +1,3 @@ +public class InClass + +} \ No newline at end of file diff --git a/src/test/testFiles/Negative/MissingComponents/Brace/InConstructor.java b/src/test/testFiles/Negative/MissingComponents/Brace/InConstructor.java new file mode 100644 index 0000000..abe19c2 --- /dev/null +++ b/src/test/testFiles/Negative/MissingComponents/Brace/InConstructor.java @@ -0,0 +1,4 @@ +public class InConstructor { + public InConstructor() + } +} \ No newline at end of file diff --git a/src/test/testFiles/Negative/MissingComponents/Brace/InDoWhile.java b/src/test/testFiles/Negative/MissingComponents/Brace/InDoWhile.java new file mode 100644 index 0000000..df93c36 --- /dev/null +++ b/src/test/testFiles/Negative/MissingComponents/Brace/InDoWhile.java @@ -0,0 +1,6 @@ +public class InDoWhile { + public InDoWhile() { + do + } while (true); + } +} \ No newline at end of file diff --git a/src/test/testFiles/Negative/MissingComponents/Brace/InFor.java b/src/test/testFiles/Negative/MissingComponents/Brace/InFor.java new file mode 100644 index 0000000..c8c5570 --- /dev/null +++ b/src/test/testFiles/Negative/MissingComponents/Brace/InFor.java @@ -0,0 +1,6 @@ +public class InFor { + public InFor() { + for (int i = 0; i < 10; i++) + } + } +} \ No newline at end of file diff --git a/src/test/testFiles/Negative/MissingComponents/Brace/InIf.java b/src/test/testFiles/Negative/MissingComponents/Brace/InIf.java new file mode 100644 index 0000000..c0c2e8e --- /dev/null +++ b/src/test/testFiles/Negative/MissingComponents/Brace/InIf.java @@ -0,0 +1,6 @@ +public class InIf { + public InWhile() { + if (true) + } + } +} \ No newline at end of file diff --git a/src/test/testFiles/Negative/MissingComponents/Brace/InMethod.java b/src/test/testFiles/Negative/MissingComponents/Brace/InMethod.java new file mode 100644 index 0000000..034df57 --- /dev/null +++ b/src/test/testFiles/Negative/MissingComponents/Brace/InMethod.java @@ -0,0 +1,4 @@ +public class InMethod { + public int get() + } +} \ No newline at end of file diff --git a/src/test/testFiles/Negative/MissingComponents/Brace/InWhile.java b/src/test/testFiles/Negative/MissingComponents/Brace/InWhile.java new file mode 100644 index 0000000..7b5f1ec --- /dev/null +++ b/src/test/testFiles/Negative/MissingComponents/Brace/InWhile.java @@ -0,0 +1,6 @@ +public class InWhile { + public InWhile() { + while (true) + } + } +} \ No newline at end of file diff --git a/src/test/testFiles/Negative/MissingComponents/ClassInClass.java b/src/test/testFiles/Negative/MissingComponents/ClassInClass.java new file mode 100644 index 0000000..57c02ab --- /dev/null +++ b/src/test/testFiles/Negative/MissingComponents/ClassInClass.java @@ -0,0 +1,2 @@ +public ClassMissingInClass { +} \ No newline at end of file diff --git a/src/test/testFiles/Negative/MissingComponents/ClassOfObject.java b/src/test/testFiles/Negative/MissingComponents/ClassOfObject.java new file mode 100644 index 0000000..e23e935 --- /dev/null +++ b/src/test/testFiles/Negative/MissingComponents/ClassOfObject.java @@ -0,0 +1,3 @@ +public class ClassOfObject { + NotExistingClass a; +} \ No newline at end of file diff --git a/src/test/testFiles/Negative/MissingComponents/Identifier/InClass.java b/src/test/testFiles/Negative/MissingComponents/Identifier/InClass.java new file mode 100644 index 0000000..6339dca --- /dev/null +++ b/src/test/testFiles/Negative/MissingComponents/Identifier/InClass.java @@ -0,0 +1,2 @@ +public class { +} \ No newline at end of file diff --git a/src/test/testFiles/Negative/MissingComponents/Identifier/InConstructor.java b/src/test/testFiles/Negative/MissingComponents/Identifier/InConstructor.java new file mode 100644 index 0000000..6c2cba4 --- /dev/null +++ b/src/test/testFiles/Negative/MissingComponents/Identifier/InConstructor.java @@ -0,0 +1,5 @@ +public class InConstructor { + public () { + + } +} \ No newline at end of file diff --git a/src/test/testFiles/Negative/MissingComponents/Identifier/InField.java b/src/test/testFiles/Negative/MissingComponents/Identifier/InField.java new file mode 100644 index 0000000..505620b --- /dev/null +++ b/src/test/testFiles/Negative/MissingComponents/Identifier/InField.java @@ -0,0 +1,3 @@ +public class InField { + int; +} \ No newline at end of file diff --git a/src/test/testFiles/Negative/MissingComponents/Identifier/InFieldCall.java b/src/test/testFiles/Negative/MissingComponents/Identifier/InFieldCall.java new file mode 100644 index 0000000..409e377 --- /dev/null +++ b/src/test/testFiles/Negative/MissingComponents/Identifier/InFieldCall.java @@ -0,0 +1,6 @@ +public class InField { + int i; + public InField() { + this. = 5; + } +} \ No newline at end of file diff --git a/src/test/testFiles/Negative/MissingComponents/Identifier/InMethod.java b/src/test/testFiles/Negative/MissingComponents/Identifier/InMethod.java new file mode 100644 index 0000000..8c3c97b --- /dev/null +++ b/src/test/testFiles/Negative/MissingComponents/Identifier/InMethod.java @@ -0,0 +1,5 @@ +public class InConstructor { + public int () { + + } +} \ No newline at end of file diff --git a/src/test/testFiles/Negative/MissingComponents/Identifier/InMethodCall.java b/src/test/testFiles/Negative/MissingComponents/Identifier/InMethodCall.java new file mode 100644 index 0000000..b3aa84f --- /dev/null +++ b/src/test/testFiles/Negative/MissingComponents/Identifier/InMethodCall.java @@ -0,0 +1,5 @@ +public class InMethodCall { + public int get() { + (); + } +} \ No newline at end of file diff --git a/src/test/testFiles/Negative/MissingComponents/Identifier/InVariable.java b/src/test/testFiles/Negative/MissingComponents/Identifier/InVariable.java new file mode 100644 index 0000000..8b7197a --- /dev/null +++ b/src/test/testFiles/Negative/MissingComponents/Identifier/InVariable.java @@ -0,0 +1,5 @@ +public class InConstructor { + public InConstructor() { + int; + } +} \ No newline at end of file diff --git a/src/test/testFiles/Negative/MissingComponents/Public/InClass.java b/src/test/testFiles/Negative/MissingComponents/Public/InClass.java new file mode 100644 index 0000000..9cea2b0 --- /dev/null +++ b/src/test/testFiles/Negative/MissingComponents/Public/InClass.java @@ -0,0 +1,2 @@ +class InClass { +} \ No newline at end of file diff --git a/src/test/testFiles/Negative/MissingComponents/Public/InMethod.java b/src/test/testFiles/Negative/MissingComponents/Public/InMethod.java new file mode 100644 index 0000000..d1d7bc5 --- /dev/null +++ b/src/test/testFiles/Negative/MissingComponents/Public/InMethod.java @@ -0,0 +1,5 @@ +public class InMethod { + int getFive() { + return 5; + } +} \ No newline at end of file diff --git a/src/test/testFiles/Negative/MissingComponents/RoundBracket/InConstructor.java b/src/test/testFiles/Negative/MissingComponents/RoundBracket/InConstructor.java new file mode 100644 index 0000000..5ef6a6c --- /dev/null +++ b/src/test/testFiles/Negative/MissingComponents/RoundBracket/InConstructor.java @@ -0,0 +1,4 @@ +public class InConstructor { + public InConstructor { + } +} \ No newline at end of file diff --git a/src/test/testFiles/Negative/MissingComponents/RoundBracket/InDoWhile.java b/src/test/testFiles/Negative/MissingComponents/RoundBracket/InDoWhile.java new file mode 100644 index 0000000..58509ed --- /dev/null +++ b/src/test/testFiles/Negative/MissingComponents/RoundBracket/InDoWhile.java @@ -0,0 +1,7 @@ +public class InDoWhile { + public void get() { + do { + + } while true; + } +} \ No newline at end of file diff --git a/src/test/testFiles/Negative/MissingComponents/RoundBracket/InElseIf.java b/src/test/testFiles/Negative/MissingComponents/RoundBracket/InElseIf.java new file mode 100644 index 0000000..7aa23ab --- /dev/null +++ b/src/test/testFiles/Negative/MissingComponents/RoundBracket/InElseIf.java @@ -0,0 +1,9 @@ +public class InElseIf { + public void get() { + if (true) { + + } else if true { + + } + } +} \ No newline at end of file diff --git a/src/test/testFiles/Negative/MissingComponents/RoundBracket/InFor.java b/src/test/testFiles/Negative/MissingComponents/RoundBracket/InFor.java new file mode 100644 index 0000000..182e2fc --- /dev/null +++ b/src/test/testFiles/Negative/MissingComponents/RoundBracket/InFor.java @@ -0,0 +1,6 @@ +public class InDoWhile { + public void get() { + for int i = 0; i < 5; i++ { + } + } +} \ No newline at end of file diff --git a/src/test/testFiles/Negative/MissingComponents/RoundBracket/InIf.java b/src/test/testFiles/Negative/MissingComponents/RoundBracket/InIf.java new file mode 100644 index 0000000..7d68153 --- /dev/null +++ b/src/test/testFiles/Negative/MissingComponents/RoundBracket/InIf.java @@ -0,0 +1,7 @@ +public class InIf { + public void get() { + if true { + + } + } +} \ No newline at end of file diff --git a/src/test/testFiles/Negative/MissingComponents/RoundBracket/InMethod.java b/src/test/testFiles/Negative/MissingComponents/RoundBracket/InMethod.java new file mode 100644 index 0000000..79a807e --- /dev/null +++ b/src/test/testFiles/Negative/MissingComponents/RoundBracket/InMethod.java @@ -0,0 +1,5 @@ +public class InMethod { + public int getFive { + return 5; + } +} \ No newline at end of file diff --git a/src/test/testFiles/Negative/MissingComponents/RoundBracket/InMethodCall.java b/src/test/testFiles/Negative/MissingComponents/RoundBracket/InMethodCall.java new file mode 100644 index 0000000..2f06dec --- /dev/null +++ b/src/test/testFiles/Negative/MissingComponents/RoundBracket/InMethodCall.java @@ -0,0 +1,5 @@ +public class PublicMissingInMethod { + public void getFive() { + getFive; + } +} \ No newline at end of file diff --git a/src/test/testFiles/Negative/MissingComponents/RoundBracket/InNewObject.java b/src/test/testFiles/Negative/MissingComponents/RoundBracket/InNewObject.java new file mode 100644 index 0000000..4635a88 --- /dev/null +++ b/src/test/testFiles/Negative/MissingComponents/RoundBracket/InNewObject.java @@ -0,0 +1,5 @@ +public class InIf { + public void get() { + Object o = new Object; + } +} \ No newline at end of file diff --git a/src/test/testFiles/Negative/MissingComponents/RoundBracket/InWhile.java b/src/test/testFiles/Negative/MissingComponents/RoundBracket/InWhile.java new file mode 100644 index 0000000..9c6b163 --- /dev/null +++ b/src/test/testFiles/Negative/MissingComponents/RoundBracket/InWhile.java @@ -0,0 +1,6 @@ +public class InDoWhile { + public void get() { + while true { + } + } +} \ No newline at end of file diff --git a/src/test/testFiles/Negative/MissingComponents/Semicolon/InAssignment.java b/src/test/testFiles/Negative/MissingComponents/Semicolon/InAssignment.java new file mode 100644 index 0000000..bd7867f --- /dev/null +++ b/src/test/testFiles/Negative/MissingComponents/Semicolon/InAssignment.java @@ -0,0 +1,6 @@ +public class InAssignment { + int a; + int getFive() { + this.a = 5 + } +} \ No newline at end of file diff --git a/src/test/testFiles/Negative/MissingComponents/Semicolon/InDoWhile.java b/src/test/testFiles/Negative/MissingComponents/Semicolon/InDoWhile.java new file mode 100644 index 0000000..79e7d44 --- /dev/null +++ b/src/test/testFiles/Negative/MissingComponents/Semicolon/InDoWhile.java @@ -0,0 +1,8 @@ +public class InDoWhile { + int getFive() { + int i = 0; + do { + i = i + 1; + } while (i < 5) + } +} \ No newline at end of file diff --git a/src/test/testFiles/Negative/MissingComponents/Semicolon/InField.java b/src/test/testFiles/Negative/MissingComponents/Semicolon/InField.java new file mode 100644 index 0000000..b787245 --- /dev/null +++ b/src/test/testFiles/Negative/MissingComponents/Semicolon/InField.java @@ -0,0 +1,3 @@ +public class InField { + int a +} \ No newline at end of file diff --git a/src/test/testFiles/Negative/MissingComponents/Semicolon/InMethodCall.java b/src/test/testFiles/Negative/MissingComponents/Semicolon/InMethodCall.java new file mode 100644 index 0000000..a11478f --- /dev/null +++ b/src/test/testFiles/Negative/MissingComponents/Semicolon/InMethodCall.java @@ -0,0 +1,11 @@ +public class InMethodCall { + int a; + + public InMethodCall() { + setFive() + } + + int setFive() { + this.a = 5; + } +} \ No newline at end of file diff --git a/src/test/testFiles/Negative/MissingComponents/Semicolon/InReturn.java b/src/test/testFiles/Negative/MissingComponents/Semicolon/InReturn.java new file mode 100644 index 0000000..bb63027 --- /dev/null +++ b/src/test/testFiles/Negative/MissingComponents/Semicolon/InReturn.java @@ -0,0 +1,5 @@ +public class InReturn { + int getFive() { + return 5 + } +} \ No newline at end of file diff --git a/src/test/testFiles/Negative/MissingComponents/Type/InField.java b/src/test/testFiles/Negative/MissingComponents/Type/InField.java new file mode 100644 index 0000000..55a2189 --- /dev/null +++ b/src/test/testFiles/Negative/MissingComponents/Type/InField.java @@ -0,0 +1,3 @@ +public class InField { + public a; +} \ No newline at end of file diff --git a/src/test/testFiles/Negative/MissingComponents/Type/InMethodSignature.java b/src/test/testFiles/Negative/MissingComponents/Type/InMethodSignature.java new file mode 100644 index 0000000..44e1b5a --- /dev/null +++ b/src/test/testFiles/Negative/MissingComponents/Type/InMethodSignature.java @@ -0,0 +1,5 @@ +public class InMethodSignature { + public getFive() { + return 5; + } +} \ No newline at end of file diff --git a/src/test/testFiles/Negative/MissingComponents/Type/InParameter.java b/src/test/testFiles/Negative/MissingComponents/Type/InParameter.java new file mode 100644 index 0000000..ba5b92c --- /dev/null +++ b/src/test/testFiles/Negative/MissingComponents/Type/InParameter.java @@ -0,0 +1,5 @@ +public class InParameter { + public int getInt(i) { + return i; + } +} \ No newline at end of file diff --git a/src/test/testFiles/Negative/PublicMissingInClass.class b/src/test/testFiles/Negative/PublicMissingInClass.class deleted file mode 100644 index 635c6f1..0000000 Binary files a/src/test/testFiles/Negative/PublicMissingInClass.class and /dev/null differ diff --git a/src/test/testFiles/Negative/PublicMissingInClass.java b/src/test/testFiles/Negative/PublicMissingInClass.java deleted file mode 100644 index ebc6b33..0000000 --- a/src/test/testFiles/Negative/PublicMissingInClass.java +++ /dev/null @@ -1,2 +0,0 @@ -class PublicMissingInClass { -} \ No newline at end of file diff --git a/src/test/testFiles/Negative/UsingSameName/ForParameterAndVariable.java b/src/test/testFiles/Negative/UsingSameName/ForParameterAndVariable.java new file mode 100644 index 0000000..bd68e5a --- /dev/null +++ b/src/test/testFiles/Negative/UsingSameName/ForParameterAndVariable.java @@ -0,0 +1,5 @@ +public class ForParameterAndVariable { + public void method(int a) { + int a = 5; + } +} \ No newline at end of file diff --git a/src/test/testFiles/Negative/UsingSameName/ForTwoParameters.java b/src/test/testFiles/Negative/UsingSameName/ForTwoParameters.java new file mode 100644 index 0000000..87deba1 --- /dev/null +++ b/src/test/testFiles/Negative/UsingSameName/ForTwoParameters.java @@ -0,0 +1,4 @@ +public class ForTwoParameters { + public void method(int a, boolean a) { + } +} \ No newline at end of file diff --git a/src/test/testFiles/Negative/UsingSameName/ForTwoVariables.java b/src/test/testFiles/Negative/UsingSameName/ForTwoVariables.java new file mode 100644 index 0000000..d73b285 --- /dev/null +++ b/src/test/testFiles/Negative/UsingSameName/ForTwoVariables.java @@ -0,0 +1,8 @@ +public class ForTwoVariables { + public int getA() { + int a; + int a; + a = 5; + return a; + } +} \ No newline at end of file diff --git a/src/test/testFiles/Negative/WrongType/CheckTypeDifferences/BetweenBoolAndChar.java b/src/test/testFiles/Negative/WrongType/CheckTypeDifferences/BetweenBoolAndChar.java new file mode 100644 index 0000000..d7077fc --- /dev/null +++ b/src/test/testFiles/Negative/WrongType/CheckTypeDifferences/BetweenBoolAndChar.java @@ -0,0 +1,7 @@ +public class BetweenBoolAndChar { + public BetweenBoolAndChar() { + boolean a = true; + char b = 'a'; + a = b; + } +} \ No newline at end of file diff --git a/src/test/testFiles/Negative/WrongType/CheckTypeDifferences/BetweenClassAndInt.java b/src/test/testFiles/Negative/WrongType/CheckTypeDifferences/BetweenClassAndInt.java new file mode 100644 index 0000000..1d83d07 --- /dev/null +++ b/src/test/testFiles/Negative/WrongType/CheckTypeDifferences/BetweenClassAndInt.java @@ -0,0 +1,7 @@ +public class BetweenClassAndInt { + public BetweenClassAndInt() { + BetweenClassAndInt a = new BetweenClassAndInt(); + int b = 5; + a = b; + } +} \ No newline at end of file diff --git a/src/test/testFiles/Negative/WrongType/CheckTypeDifferences/BetweenIntAndBool.java b/src/test/testFiles/Negative/WrongType/CheckTypeDifferences/BetweenIntAndBool.java new file mode 100644 index 0000000..32e1287 --- /dev/null +++ b/src/test/testFiles/Negative/WrongType/CheckTypeDifferences/BetweenIntAndBool.java @@ -0,0 +1,7 @@ +public class BetweenIntAndBool { + public BetweenIntAndBool() { + int a = 5; + boolean b = true; + a = b; + } +} \ No newline at end of file diff --git a/src/test/testFiles/Negative/WrongType/CheckTypeDifferences/BetweenIntAndChar.java b/src/test/testFiles/Negative/WrongType/CheckTypeDifferences/BetweenIntAndChar.java new file mode 100644 index 0000000..175a535 --- /dev/null +++ b/src/test/testFiles/Negative/WrongType/CheckTypeDifferences/BetweenIntAndChar.java @@ -0,0 +1,7 @@ +public class BetweenIntAndChar { + public BetweenIntAndChar() { + int a = 5; + char b = 'a'; + a = b; + } +} \ No newline at end of file diff --git a/src/test/testFiles/Negative/WrongType/CheckTypeDifferences/BetweenTwoClasses.java b/src/test/testFiles/Negative/WrongType/CheckTypeDifferences/BetweenTwoClasses.java new file mode 100644 index 0000000..2fd1b91 --- /dev/null +++ b/src/test/testFiles/Negative/WrongType/CheckTypeDifferences/BetweenTwoClasses.java @@ -0,0 +1,7 @@ +public class BetweenTwoClasses { + public BetweenTwoClasses() { + BetweenTwoClasses a = new BetweenTwoClasses(); + BetweenTwoClassesClassTwo b = new BetweenTwoClassesClassTwo(); + a = b; + } +} \ No newline at end of file diff --git a/src/test/testFiles/Negative/WrongType/CheckTypeDifferences/BetweenTwoClassesClassTwo.java b/src/test/testFiles/Negative/WrongType/CheckTypeDifferences/BetweenTwoClassesClassTwo.java new file mode 100644 index 0000000..4de4c8f --- /dev/null +++ b/src/test/testFiles/Negative/WrongType/CheckTypeDifferences/BetweenTwoClassesClassTwo.java @@ -0,0 +1,2 @@ +public class BetweenTwoClassesClassTwo { +} \ No newline at end of file diff --git a/src/test/testFiles/Negative/WrongType/InAssignment/InAttributeOfObjectGet.java b/src/test/testFiles/Negative/WrongType/InAssignment/InAttributeOfObjectGet.java new file mode 100644 index 0000000..a719c24 --- /dev/null +++ b/src/test/testFiles/Negative/WrongType/InAssignment/InAttributeOfObjectGet.java @@ -0,0 +1,13 @@ +public class InAttributeOfObjectGet { + int a; + char b; + public InAttributeOfObjectGet() { + this.a = 4; + this.b = 'a'; + } + + public void assignAttributeOfObjectToField() { + InAttributeOfObjectGet c = new InAttributeOfObjectGet(); + this.a = c.b; + } +} \ No newline at end of file diff --git a/src/test/testFiles/Negative/WrongType/InAssignment/InAttributeOfObjectSet.java b/src/test/testFiles/Negative/WrongType/InAssignment/InAttributeOfObjectSet.java new file mode 100644 index 0000000..81986de --- /dev/null +++ b/src/test/testFiles/Negative/WrongType/InAssignment/InAttributeOfObjectSet.java @@ -0,0 +1,13 @@ +public class InAttributeOfObjectSet { + int a; + char b; + public InAttributeOfObjectSet() { + this.a = 4; + this.b = 'a'; + } + + public void assignFieldToAttributeOfObject() { + InAttributeOfObjectSet c = new InAttributeOfObjectSet(); + c.b = this.a; + } +} \ No newline at end of file diff --git a/src/test/testFiles/Negative/WrongType/InAssignment/InFieldToField.java b/src/test/testFiles/Negative/WrongType/InAssignment/InFieldToField.java new file mode 100644 index 0000000..da570bd --- /dev/null +++ b/src/test/testFiles/Negative/WrongType/InAssignment/InFieldToField.java @@ -0,0 +1,9 @@ +public class InFieldToField { + int a; + char b; + public InFieldToField() { + this.a = 5; + this.b = 'a'; + this.a = this.b; + } +} \ No newline at end of file diff --git a/src/test/testFiles/Negative/WrongType/InAssignment/InFieldToVariable.java b/src/test/testFiles/Negative/WrongType/InAssignment/InFieldToVariable.java new file mode 100644 index 0000000..7bffa0c --- /dev/null +++ b/src/test/testFiles/Negative/WrongType/InAssignment/InFieldToVariable.java @@ -0,0 +1,8 @@ +public class InAssignmentOfFieldToVariable { + int a; + public InAssignmentOfFieldToVariable() { + char b; + b = 'a'; + this.a = b; + } +} \ No newline at end of file diff --git a/src/test/testFiles/Negative/WrongType/InAssignment/InMethodCall.java b/src/test/testFiles/Negative/WrongType/InAssignment/InMethodCall.java new file mode 100644 index 0000000..122bce0 --- /dev/null +++ b/src/test/testFiles/Negative/WrongType/InAssignment/InMethodCall.java @@ -0,0 +1,11 @@ +public class InMethodCall { + + public InMethodCall() { + char c; + c = getFive(); + } + + public int getFive() { + return 5; + } +} \ No newline at end of file diff --git a/src/test/testFiles/Negative/WrongType/InAssignment/InMethodOfObjectGet.java b/src/test/testFiles/Negative/WrongType/InAssignment/InMethodOfObjectGet.java new file mode 100644 index 0000000..f62924c --- /dev/null +++ b/src/test/testFiles/Negative/WrongType/InAssignment/InMethodOfObjectGet.java @@ -0,0 +1,16 @@ +public class InMethodOfObjectGet { + int a; + public InMethodOfObjectGet() { + this.a = 4; + } + + public int getA() { + return a; + } + + public void assignFieldToMethodCallOnObject() { + InMethodOfObjectGet b = new InMethodOfObjectGet(); + char c; + c = b.getA(); + } +} \ No newline at end of file diff --git a/src/test/testFiles/Negative/WrongType/InAssignment/InParameter.java b/src/test/testFiles/Negative/WrongType/InAssignment/InParameter.java new file mode 100644 index 0000000..72bd1cf --- /dev/null +++ b/src/test/testFiles/Negative/WrongType/InAssignment/InParameter.java @@ -0,0 +1,5 @@ +public class InParameter { + public void test(boolean b) { + char c = b; + } +} \ No newline at end of file diff --git a/src/test/testFiles/Negative/WrongType/InMethodCallParameters.java b/src/test/testFiles/Negative/WrongType/InMethodCallParameters.java new file mode 100644 index 0000000..18f7dc4 --- /dev/null +++ b/src/test/testFiles/Negative/WrongType/InMethodCallParameters.java @@ -0,0 +1,9 @@ +public class InMethodCallParameters { + public void callThisMethod(boolean a) { + a = false; + } + + public void method() { + callThisMethod(5); + } +} \ No newline at end of file diff --git a/src/test/testFiles/Negative/WrongType/InMethodOfObjectCallParameters.java b/src/test/testFiles/Negative/WrongType/InMethodOfObjectCallParameters.java new file mode 100644 index 0000000..83b55d4 --- /dev/null +++ b/src/test/testFiles/Negative/WrongType/InMethodOfObjectCallParameters.java @@ -0,0 +1,10 @@ +public class InMethodOfObjectCallParameters { + public void callThisMethod(boolean a) { + a = false; + } + + public void method() { + InMethodOfObjectCallParameters obj = new InMethodOfObjectCallParameters(); + obj.callThisMethod(5); + } +} \ No newline at end of file diff --git a/src/test/testFiles/Negative/WrongType/InReturnStatement.java b/src/test/testFiles/Negative/WrongType/InReturnStatement.java new file mode 100644 index 0000000..f233421 --- /dev/null +++ b/src/test/testFiles/Negative/WrongType/InReturnStatement.java @@ -0,0 +1,5 @@ +public class InReturnStatement { + public int getA() { + return '5'; + } +} \ No newline at end of file diff --git a/src/test/testFiles/Negative/WrongType/UsingWithOperators/And/OnChar.java b/src/test/testFiles/Negative/WrongType/UsingWithOperators/And/OnChar.java new file mode 100644 index 0000000..d2ef413 --- /dev/null +++ b/src/test/testFiles/Negative/WrongType/UsingWithOperators/And/OnChar.java @@ -0,0 +1,6 @@ +public class OnChar { + public void method() { + boolean b; + b = 'a' && 'b'; + } +} \ No newline at end of file diff --git a/src/test/testFiles/Negative/WrongType/UsingWithOperators/And/OnInt.java b/src/test/testFiles/Negative/WrongType/UsingWithOperators/And/OnInt.java new file mode 100644 index 0000000..9376428 --- /dev/null +++ b/src/test/testFiles/Negative/WrongType/UsingWithOperators/And/OnInt.java @@ -0,0 +1,6 @@ +public class OnInt { + public OnInt() { + boolean a; + a = 5 && 6; + } +} \ No newline at end of file diff --git a/src/test/testFiles/Negative/WrongType/UsingWithOperators/And/OnObject.java b/src/test/testFiles/Negative/WrongType/UsingWithOperators/And/OnObject.java new file mode 100644 index 0000000..f15b968 --- /dev/null +++ b/src/test/testFiles/Negative/WrongType/UsingWithOperators/And/OnObject.java @@ -0,0 +1,10 @@ +public class OnObject { + public void test() { + boolean a; + OnObject b; + b = new OnObject(); + OnObject c; + c = new OnObject(); + a = b && c; + } +} \ No newline at end of file diff --git a/src/test/testFiles/Negative/WrongType/UsingWithOperators/Div/OnBoolean.java b/src/test/testFiles/Negative/WrongType/UsingWithOperators/Div/OnBoolean.java new file mode 100644 index 0000000..d52ed7a --- /dev/null +++ b/src/test/testFiles/Negative/WrongType/UsingWithOperators/Div/OnBoolean.java @@ -0,0 +1,10 @@ +public class OnBoolean { + public OnBoolean() { + int a; + boolean b; + b = true; + boolean c; + c = false; + a = b / c; + } +} \ No newline at end of file diff --git a/src/test/testFiles/Negative/WrongType/UsingWithOperators/Div/OnChar.java b/src/test/testFiles/Negative/WrongType/UsingWithOperators/Div/OnChar.java new file mode 100644 index 0000000..35fa71b --- /dev/null +++ b/src/test/testFiles/Negative/WrongType/UsingWithOperators/Div/OnChar.java @@ -0,0 +1,10 @@ +public class OnChar { + public void method() { + int c; + char a; + char b; + a = 'a'; + b = 'b'; + c = a / b; + } +} \ No newline at end of file diff --git a/src/test/testFiles/Negative/WrongType/UsingWithOperators/Div/OnObject.java b/src/test/testFiles/Negative/WrongType/UsingWithOperators/Div/OnObject.java new file mode 100644 index 0000000..7bcb2a2 --- /dev/null +++ b/src/test/testFiles/Negative/WrongType/UsingWithOperators/Div/OnObject.java @@ -0,0 +1,10 @@ +public class OnObject { + public OnObject() { + int b; + OnObject a; + a = new OnObject(); + OnObject c; + c = new OnObject(); + b = a / c; + } +} \ No newline at end of file diff --git a/src/test/testFiles/Negative/WrongType/UsingWithOperators/Min/OnBoolean.java b/src/test/testFiles/Negative/WrongType/UsingWithOperators/Min/OnBoolean.java new file mode 100644 index 0000000..d8f2ed2 --- /dev/null +++ b/src/test/testFiles/Negative/WrongType/UsingWithOperators/Min/OnBoolean.java @@ -0,0 +1,8 @@ +public class OnBoolean { + public void method() { + int c; + boolean a = true; + boolean b = false; + c = a - b; + } +} \ No newline at end of file diff --git a/src/test/testFiles/Negative/WrongType/UsingWithOperators/Min/OnChar.java b/src/test/testFiles/Negative/WrongType/UsingWithOperators/Min/OnChar.java new file mode 100644 index 0000000..79d58bf --- /dev/null +++ b/src/test/testFiles/Negative/WrongType/UsingWithOperators/Min/OnChar.java @@ -0,0 +1,10 @@ +public class OnChar { + public OnChar() { + int c; + char a; + char b; + a = 'a'; + b = 'b'; + c = a - b; + } +} \ No newline at end of file diff --git a/src/test/testFiles/Negative/WrongType/UsingWithOperators/Min/OnObject.java b/src/test/testFiles/Negative/WrongType/UsingWithOperators/Min/OnObject.java new file mode 100644 index 0000000..8d10530 --- /dev/null +++ b/src/test/testFiles/Negative/WrongType/UsingWithOperators/Min/OnObject.java @@ -0,0 +1,10 @@ +public class OnObject { + public OnObject() { + int b; + OnObject a; + a = new OnObject(); + OnObject c; + c = new OnObject(); + b = a - c; + } +} \ No newline at end of file diff --git a/src/test/testFiles/Negative/WrongType/UsingWithOperators/Mod/OnBoolean.java b/src/test/testFiles/Negative/WrongType/UsingWithOperators/Mod/OnBoolean.java new file mode 100644 index 0000000..2626d6a --- /dev/null +++ b/src/test/testFiles/Negative/WrongType/UsingWithOperators/Mod/OnBoolean.java @@ -0,0 +1,6 @@ +public class OnBoolean { + public void method() { + int a; + a = true % false; + } +} \ No newline at end of file diff --git a/src/test/testFiles/Negative/WrongType/UsingWithOperators/Mod/OnChar.java b/src/test/testFiles/Negative/WrongType/UsingWithOperators/Mod/OnChar.java new file mode 100644 index 0000000..99fb823 --- /dev/null +++ b/src/test/testFiles/Negative/WrongType/UsingWithOperators/Mod/OnChar.java @@ -0,0 +1,6 @@ +public class OnChar { + public void method() { + int a; + a = 'a' % 5; + } +} \ No newline at end of file diff --git a/src/test/testFiles/Negative/WrongType/UsingWithOperators/Mod/OnObject.java b/src/test/testFiles/Negative/WrongType/UsingWithOperators/Mod/OnObject.java new file mode 100644 index 0000000..d948634 --- /dev/null +++ b/src/test/testFiles/Negative/WrongType/UsingWithOperators/Mod/OnObject.java @@ -0,0 +1,10 @@ +public class OnObject { + public OnObject() { + int b; + OnObject a; + a = new OnObject(); + OnObject c; + c = new OnObject(); + b = a % c; + } +} \ No newline at end of file diff --git a/src/test/testFiles/Negative/WrongType/UsingWithOperators/Mul/OnBoolean.java b/src/test/testFiles/Negative/WrongType/UsingWithOperators/Mul/OnBoolean.java new file mode 100644 index 0000000..5651d1c --- /dev/null +++ b/src/test/testFiles/Negative/WrongType/UsingWithOperators/Mul/OnBoolean.java @@ -0,0 +1,8 @@ +public class OnBoolean { + public void method() { + int c; + boolean a = true; + boolean b = false; + c = a * b; + } +} \ No newline at end of file diff --git a/src/test/testFiles/Negative/WrongType/UsingWithOperators/Mul/OnChar.java b/src/test/testFiles/Negative/WrongType/UsingWithOperators/Mul/OnChar.java new file mode 100644 index 0000000..c481531 --- /dev/null +++ b/src/test/testFiles/Negative/WrongType/UsingWithOperators/Mul/OnChar.java @@ -0,0 +1,10 @@ +public class OnChar { + public OnChar() { + int c; + char a; + char b; + a = 'a'; + b = 'b'; + c = a * b; + } +} \ No newline at end of file diff --git a/src/test/testFiles/Negative/WrongType/UsingWithOperators/Mul/OnObject.java b/src/test/testFiles/Negative/WrongType/UsingWithOperators/Mul/OnObject.java new file mode 100644 index 0000000..92afb5e --- /dev/null +++ b/src/test/testFiles/Negative/WrongType/UsingWithOperators/Mul/OnObject.java @@ -0,0 +1,10 @@ +public class OnObject { + public OnObject() { + int b; + OnObject a; + a = new OnObject(); + OnObject c; + c = new OnObject(); + b = a * c; + } +} \ No newline at end of file diff --git a/src/test/testFiles/Negative/WrongType/UsingWithOperators/Not/OnChar.java b/src/test/testFiles/Negative/WrongType/UsingWithOperators/Not/OnChar.java new file mode 100644 index 0000000..531a4c7 --- /dev/null +++ b/src/test/testFiles/Negative/WrongType/UsingWithOperators/Not/OnChar.java @@ -0,0 +1,8 @@ +public class OnChar { + public OnChar() { + boolean c; + char a; + a = 'a'; + b = !a; + } +} \ No newline at end of file diff --git a/src/test/testFiles/Negative/WrongType/UsingWithOperators/Not/OnInt.java b/src/test/testFiles/Negative/WrongType/UsingWithOperators/Not/OnInt.java new file mode 100644 index 0000000..82f4a7e --- /dev/null +++ b/src/test/testFiles/Negative/WrongType/UsingWithOperators/Not/OnInt.java @@ -0,0 +1,8 @@ +public class OnInt { + public OnInt() { + int a; + boolean b; + a = 1; + b = !a; + } +} \ No newline at end of file diff --git a/src/test/testFiles/Negative/WrongType/UsingWithOperators/Not/OnObject.java b/src/test/testFiles/Negative/WrongType/UsingWithOperators/Not/OnObject.java new file mode 100644 index 0000000..59ea92f --- /dev/null +++ b/src/test/testFiles/Negative/WrongType/UsingWithOperators/Not/OnObject.java @@ -0,0 +1,8 @@ +public class OnObject { + public OnObject() { + boolean b; + OnObject a; + a = new OnObject(); + b = !a; + } +} \ No newline at end of file diff --git a/src/test/testFiles/Negative/WrongType/UsingWithOperators/OperatorReturnValues/And.java b/src/test/testFiles/Negative/WrongType/UsingWithOperators/OperatorReturnValues/And.java new file mode 100644 index 0000000..a8173f1 --- /dev/null +++ b/src/test/testFiles/Negative/WrongType/UsingWithOperators/OperatorReturnValues/And.java @@ -0,0 +1,10 @@ +public class And { + public And() { + boolean a; + boolean b; + int c; + a = true; + b = false; + c = a && b; + } +} \ No newline at end of file diff --git a/src/test/testFiles/Negative/WrongType/UsingWithOperators/OperatorReturnValues/Div.java b/src/test/testFiles/Negative/WrongType/UsingWithOperators/OperatorReturnValues/Div.java new file mode 100644 index 0000000..30fb062 --- /dev/null +++ b/src/test/testFiles/Negative/WrongType/UsingWithOperators/OperatorReturnValues/Div.java @@ -0,0 +1,10 @@ +public class Div { + public Div() { + int a; + int b; + char c; + a = 5; + b = 2; + c = a / b; + } +} \ No newline at end of file diff --git a/src/test/testFiles/Negative/WrongType/UsingWithOperators/OperatorReturnValues/Min.java b/src/test/testFiles/Negative/WrongType/UsingWithOperators/OperatorReturnValues/Min.java new file mode 100644 index 0000000..04628a3 --- /dev/null +++ b/src/test/testFiles/Negative/WrongType/UsingWithOperators/OperatorReturnValues/Min.java @@ -0,0 +1,10 @@ +public class Min { + public Min() { + int a; + int b; + Min c; + a = 1; + b = 2; + c = a - b; + } +} \ No newline at end of file diff --git a/src/test/testFiles/Negative/WrongType/UsingWithOperators/OperatorReturnValues/Mod.java b/src/test/testFiles/Negative/WrongType/UsingWithOperators/OperatorReturnValues/Mod.java new file mode 100644 index 0000000..06ba344 --- /dev/null +++ b/src/test/testFiles/Negative/WrongType/UsingWithOperators/OperatorReturnValues/Mod.java @@ -0,0 +1,10 @@ +public class Mod { + public Mod() { + int a; + int b; + boolean c; + a = 5; + b = 2; + c = a % b; + } +} \ No newline at end of file diff --git a/src/test/testFiles/Negative/WrongType/UsingWithOperators/OperatorReturnValues/Mul.java b/src/test/testFiles/Negative/WrongType/UsingWithOperators/OperatorReturnValues/Mul.java new file mode 100644 index 0000000..b08479f --- /dev/null +++ b/src/test/testFiles/Negative/WrongType/UsingWithOperators/OperatorReturnValues/Mul.java @@ -0,0 +1,10 @@ +public class Mul { + public Mul() { + int a; + int b; + char c; + a = 1; + b = 2; + c = a * b; + } +} \ No newline at end of file diff --git a/src/test/testFiles/Negative/WrongType/UsingWithOperators/OperatorReturnValues/Not.java b/src/test/testFiles/Negative/WrongType/UsingWithOperators/OperatorReturnValues/Not.java new file mode 100644 index 0000000..d348c15 --- /dev/null +++ b/src/test/testFiles/Negative/WrongType/UsingWithOperators/OperatorReturnValues/Not.java @@ -0,0 +1,8 @@ +public class Not { + public Not() { + boolean c; + char a; + b = true; + a = !b; + } +} \ No newline at end of file diff --git a/src/test/testFiles/Negative/WrongType/UsingWithOperators/OperatorReturnValues/Or.java b/src/test/testFiles/Negative/WrongType/UsingWithOperators/OperatorReturnValues/Or.java new file mode 100644 index 0000000..be4e8df --- /dev/null +++ b/src/test/testFiles/Negative/WrongType/UsingWithOperators/OperatorReturnValues/Or.java @@ -0,0 +1,10 @@ +public class Or { + public Or() { + boolean a; + boolean b; + int c; + a = true; + b = false; + c = a || b; + } +} \ No newline at end of file diff --git a/src/test/testFiles/Negative/WrongType/UsingWithOperators/OperatorReturnValues/Plus.java b/src/test/testFiles/Negative/WrongType/UsingWithOperators/OperatorReturnValues/Plus.java new file mode 100644 index 0000000..92c503e --- /dev/null +++ b/src/test/testFiles/Negative/WrongType/UsingWithOperators/OperatorReturnValues/Plus.java @@ -0,0 +1,10 @@ +public class Plus { + public Plus() { + int a; + int b; + char c; + a = 1; + b = 2; + c = a + b; + } +} \ No newline at end of file diff --git a/src/test/testFiles/Negative/WrongType/UsingWithOperators/Or/OnChar.java b/src/test/testFiles/Negative/WrongType/UsingWithOperators/Or/OnChar.java new file mode 100644 index 0000000..33a18bf --- /dev/null +++ b/src/test/testFiles/Negative/WrongType/UsingWithOperators/Or/OnChar.java @@ -0,0 +1,10 @@ +public class OnChar { + public OnChar() { + boolean c; + char a; + char b; + a = 'a'; + b = 'b'; + c = a || b; + } +} \ No newline at end of file diff --git a/src/test/testFiles/Negative/WrongType/UsingWithOperators/Or/OnInt.java b/src/test/testFiles/Negative/WrongType/UsingWithOperators/Or/OnInt.java new file mode 100644 index 0000000..28f633e --- /dev/null +++ b/src/test/testFiles/Negative/WrongType/UsingWithOperators/Or/OnInt.java @@ -0,0 +1,10 @@ +public class OnInt { + public OnInt() { + int a; + int b; + boolean c; + a = 1; + b = 2; + c = a || b; + } +} \ No newline at end of file diff --git a/src/test/testFiles/Negative/WrongType/UsingWithOperators/Or/OnObject.java b/src/test/testFiles/Negative/WrongType/UsingWithOperators/Or/OnObject.java new file mode 100644 index 0000000..2d95e52 --- /dev/null +++ b/src/test/testFiles/Negative/WrongType/UsingWithOperators/Or/OnObject.java @@ -0,0 +1,10 @@ +public class OnObject { + public OnObject() { + boolean b; + OnObject a; + a = new OnObject(); + OnObject c; + c = new OnObject(); + b = a || c; + } +} \ No newline at end of file diff --git a/src/test/testFiles/Negative/WrongType/UsingWithOperators/Plus/OnBoolean.java b/src/test/testFiles/Negative/WrongType/UsingWithOperators/Plus/OnBoolean.java new file mode 100644 index 0000000..718b59e --- /dev/null +++ b/src/test/testFiles/Negative/WrongType/UsingWithOperators/Plus/OnBoolean.java @@ -0,0 +1,8 @@ +public class OnBoolean { + public void method() { + int c; + boolean a = true; + boolean b = false; + c = a + b; + } +} \ No newline at end of file diff --git a/src/test/testFiles/Negative/WrongType/UsingWithOperators/Plus/OnChar.java b/src/test/testFiles/Negative/WrongType/UsingWithOperators/Plus/OnChar.java new file mode 100644 index 0000000..8c15203 --- /dev/null +++ b/src/test/testFiles/Negative/WrongType/UsingWithOperators/Plus/OnChar.java @@ -0,0 +1,10 @@ +public class OnChar { + public OnChar() { + char a; + char b; + int c; + a = 'a'; + b = 'b'; + c = a + b; + } +} \ No newline at end of file diff --git a/src/test/testFiles/Negative/WrongType/UsingWithOperators/Plus/OnObject.java b/src/test/testFiles/Negative/WrongType/UsingWithOperators/Plus/OnObject.java new file mode 100644 index 0000000..7de8617 --- /dev/null +++ b/src/test/testFiles/Negative/WrongType/UsingWithOperators/Plus/OnObject.java @@ -0,0 +1,10 @@ +public class OnObject { + public OnObject() { + int b; + OnObject a; + a = new OnObject(); + OnObject c; + c = new OnObject(); + b = a + c; + } +} \ No newline at end of file