mirror of
https://github.com/JonathanFleischmann/CompilerULTIMATE.git
synced 2024-12-27 09:28:03 +00:00
fixed wrong changes from testsuites
This commit is contained in:
parent
d9cf560331
commit
2087f6b37c
@ -105,7 +105,6 @@ public class StatementGenerator extends DecafBaseVisitor<List<Statement>> {
|
||||
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());
|
||||
|
52
src/test/java/AllNegativeTests.java
Normal file
52
src/test/java/AllNegativeTests.java
Normal file
@ -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"));
|
||||
});
|
||||
}
|
||||
}
|
@ -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<String> failedTests = new ArrayList<>();
|
||||
|
||||
// Finde alle Methoden, die mit @Test annotiert sind
|
||||
List<Method> 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<Method> 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.");
|
||||
}
|
||||
}
|
||||
}
|
53
src/test/java/HelpFiles/TestFileTester.java
Normal file
53
src/test/java/HelpFiles/TestFileTester.java
Normal file
@ -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<String> failedTests = new ArrayList<>();
|
||||
|
||||
// Finde alle Methoden, die mit @Test annotiert sind
|
||||
List<Method> 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<Method> 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.");
|
||||
}
|
||||
}
|
||||
}
|
@ -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"));
|
||||
}
|
||||
}
|
41
src/test/java/NegativeTests/CallVariableOutsideScope.java
Normal file
41
src/test/java/NegativeTests/CallVariableOutsideScope.java
Normal file
@ -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")));
|
||||
}
|
||||
}
|
@ -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")));
|
||||
}
|
||||
}
|
291
src/test/java/NegativeTests/MissingComponents.java
Normal file
291
src/test/java/NegativeTests/MissingComponents.java
Normal file
@ -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"));
|
||||
});
|
||||
}
|
||||
}
|
28
src/test/java/NegativeTests/UsingSameName.java
Normal file
28
src/test/java/NegativeTests/UsingSameName.java
Normal file
@ -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")));
|
||||
}
|
||||
}
|
294
src/test/java/NegativeTests/WrongType.java
Normal file
294
src/test/java/NegativeTests/WrongType.java
Normal file
@ -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")));
|
||||
}
|
||||
}
|
@ -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);
|
||||
}
|
||||
|
@ -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);
|
||||
}
|
||||
|
4
src/test/testFiles/Negative/AssignmentOutsideMethod.java
Normal file
4
src/test/testFiles/Negative/AssignmentOutsideMethod.java
Normal file
@ -0,0 +1,4 @@
|
||||
public class AssignmentOutsideMethod {
|
||||
int a;
|
||||
a = 5;
|
||||
}
|
@ -0,0 +1,10 @@
|
||||
public class OfElse {
|
||||
public void test(boolean b) {
|
||||
if (b) {
|
||||
b = false;
|
||||
} else {
|
||||
int a = 5;
|
||||
}
|
||||
a = 5;
|
||||
}
|
||||
}
|
@ -0,0 +1,8 @@
|
||||
public class OfFor {
|
||||
public void method() {
|
||||
for (int i = 0; i < 10; i+=1) {
|
||||
int a = 5;
|
||||
}
|
||||
a = 3;
|
||||
}
|
||||
}
|
@ -0,0 +1,8 @@
|
||||
public class OfIf {
|
||||
public void test() {
|
||||
if (true) {
|
||||
int a = 5;
|
||||
}
|
||||
a = 5;
|
||||
}
|
||||
}
|
@ -0,0 +1,10 @@
|
||||
public class OfIfElse {
|
||||
public void test(boolean b) {
|
||||
if (b) {
|
||||
b = false;
|
||||
} else if(!b) {
|
||||
int a = 5;
|
||||
}
|
||||
a = 6;
|
||||
}
|
||||
}
|
@ -0,0 +1,9 @@
|
||||
public class OfMethod {
|
||||
public void method1() {
|
||||
int a = 5;
|
||||
}
|
||||
|
||||
public void method2() {
|
||||
a = 3;
|
||||
}
|
||||
}
|
@ -0,0 +1,8 @@
|
||||
public class OfWhile {
|
||||
public void method() {
|
||||
while (a < 10) {
|
||||
int a = 0;
|
||||
}
|
||||
a = 5;
|
||||
}
|
||||
}
|
@ -0,0 +1,6 @@
|
||||
public class InMainMethod {
|
||||
int a;
|
||||
public static void main(String[] args) {
|
||||
this.a = 5;
|
||||
}
|
||||
}
|
@ -0,0 +1,3 @@
|
||||
public class AccessModifier {
|
||||
private int x;
|
||||
}
|
@ -0,0 +1,7 @@
|
||||
public class IMinusMinus {
|
||||
public IMinusMinus() {
|
||||
int a;
|
||||
a = 5;
|
||||
a--;
|
||||
}
|
||||
}
|
@ -0,0 +1,7 @@
|
||||
public class IPlusPlus {
|
||||
public IPlusPlus() {
|
||||
int a;
|
||||
a = 5;
|
||||
a++;
|
||||
}
|
||||
}
|
@ -0,0 +1,5 @@
|
||||
public class UsingSystemOut {
|
||||
public UsingSystemOut() {
|
||||
System.out.println('b');
|
||||
}
|
||||
}
|
@ -0,0 +1,3 @@
|
||||
public class InClass
|
||||
|
||||
}
|
@ -0,0 +1,4 @@
|
||||
public class InConstructor {
|
||||
public InConstructor()
|
||||
}
|
||||
}
|
@ -0,0 +1,6 @@
|
||||
public class InDoWhile {
|
||||
public InDoWhile() {
|
||||
do
|
||||
} while (true);
|
||||
}
|
||||
}
|
@ -0,0 +1,6 @@
|
||||
public class InFor {
|
||||
public InFor() {
|
||||
for (int i = 0; i < 10; i++)
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,6 @@
|
||||
public class InIf {
|
||||
public InWhile() {
|
||||
if (true)
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,4 @@
|
||||
public class InMethod {
|
||||
public int get()
|
||||
}
|
||||
}
|
@ -0,0 +1,6 @@
|
||||
public class InWhile {
|
||||
public InWhile() {
|
||||
while (true)
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,2 @@
|
||||
public ClassMissingInClass {
|
||||
}
|
@ -0,0 +1,3 @@
|
||||
public class ClassOfObject {
|
||||
NotExistingClass a;
|
||||
}
|
@ -0,0 +1,2 @@
|
||||
public class {
|
||||
}
|
@ -0,0 +1,5 @@
|
||||
public class InConstructor {
|
||||
public () {
|
||||
|
||||
}
|
||||
}
|
@ -0,0 +1,3 @@
|
||||
public class InField {
|
||||
int;
|
||||
}
|
@ -0,0 +1,6 @@
|
||||
public class InField {
|
||||
int i;
|
||||
public InField() {
|
||||
this. = 5;
|
||||
}
|
||||
}
|
@ -0,0 +1,5 @@
|
||||
public class InConstructor {
|
||||
public int () {
|
||||
|
||||
}
|
||||
}
|
@ -0,0 +1,5 @@
|
||||
public class InMethodCall {
|
||||
public int get() {
|
||||
();
|
||||
}
|
||||
}
|
@ -0,0 +1,5 @@
|
||||
public class InConstructor {
|
||||
public InConstructor() {
|
||||
int;
|
||||
}
|
||||
}
|
@ -0,0 +1,2 @@
|
||||
class InClass {
|
||||
}
|
@ -0,0 +1,5 @@
|
||||
public class InMethod {
|
||||
int getFive() {
|
||||
return 5;
|
||||
}
|
||||
}
|
@ -0,0 +1,4 @@
|
||||
public class InConstructor {
|
||||
public InConstructor {
|
||||
}
|
||||
}
|
@ -0,0 +1,7 @@
|
||||
public class InDoWhile {
|
||||
public void get() {
|
||||
do {
|
||||
|
||||
} while true;
|
||||
}
|
||||
}
|
@ -0,0 +1,9 @@
|
||||
public class InElseIf {
|
||||
public void get() {
|
||||
if (true) {
|
||||
|
||||
} else if true {
|
||||
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,6 @@
|
||||
public class InDoWhile {
|
||||
public void get() {
|
||||
for int i = 0; i < 5; i++ {
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,7 @@
|
||||
public class InIf {
|
||||
public void get() {
|
||||
if true {
|
||||
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,5 @@
|
||||
public class InMethod {
|
||||
public int getFive {
|
||||
return 5;
|
||||
}
|
||||
}
|
@ -0,0 +1,5 @@
|
||||
public class PublicMissingInMethod {
|
||||
public void getFive() {
|
||||
getFive;
|
||||
}
|
||||
}
|
@ -0,0 +1,5 @@
|
||||
public class InIf {
|
||||
public void get() {
|
||||
Object o = new Object;
|
||||
}
|
||||
}
|
@ -0,0 +1,6 @@
|
||||
public class InDoWhile {
|
||||
public void get() {
|
||||
while true {
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,6 @@
|
||||
public class InAssignment {
|
||||
int a;
|
||||
int getFive() {
|
||||
this.a = 5
|
||||
}
|
||||
}
|
@ -0,0 +1,8 @@
|
||||
public class InDoWhile {
|
||||
int getFive() {
|
||||
int i = 0;
|
||||
do {
|
||||
i = i + 1;
|
||||
} while (i < 5)
|
||||
}
|
||||
}
|
@ -0,0 +1,3 @@
|
||||
public class InField {
|
||||
int a
|
||||
}
|
@ -0,0 +1,11 @@
|
||||
public class InMethodCall {
|
||||
int a;
|
||||
|
||||
public InMethodCall() {
|
||||
setFive()
|
||||
}
|
||||
|
||||
int setFive() {
|
||||
this.a = 5;
|
||||
}
|
||||
}
|
@ -0,0 +1,5 @@
|
||||
public class InReturn {
|
||||
int getFive() {
|
||||
return 5
|
||||
}
|
||||
}
|
@ -0,0 +1,3 @@
|
||||
public class InField {
|
||||
public a;
|
||||
}
|
@ -0,0 +1,5 @@
|
||||
public class InMethodSignature {
|
||||
public getFive() {
|
||||
return 5;
|
||||
}
|
||||
}
|
@ -0,0 +1,5 @@
|
||||
public class InParameter {
|
||||
public int getInt(i) {
|
||||
return i;
|
||||
}
|
||||
}
|
Binary file not shown.
@ -1,2 +0,0 @@
|
||||
class PublicMissingInClass {
|
||||
}
|
@ -0,0 +1,5 @@
|
||||
public class ForParameterAndVariable {
|
||||
public void method(int a) {
|
||||
int a = 5;
|
||||
}
|
||||
}
|
@ -0,0 +1,4 @@
|
||||
public class ForTwoParameters {
|
||||
public void method(int a, boolean a) {
|
||||
}
|
||||
}
|
@ -0,0 +1,8 @@
|
||||
public class ForTwoVariables {
|
||||
public int getA() {
|
||||
int a;
|
||||
int a;
|
||||
a = 5;
|
||||
return a;
|
||||
}
|
||||
}
|
@ -0,0 +1,7 @@
|
||||
public class BetweenBoolAndChar {
|
||||
public BetweenBoolAndChar() {
|
||||
boolean a = true;
|
||||
char b = 'a';
|
||||
a = b;
|
||||
}
|
||||
}
|
@ -0,0 +1,7 @@
|
||||
public class BetweenClassAndInt {
|
||||
public BetweenClassAndInt() {
|
||||
BetweenClassAndInt a = new BetweenClassAndInt();
|
||||
int b = 5;
|
||||
a = b;
|
||||
}
|
||||
}
|
@ -0,0 +1,7 @@
|
||||
public class BetweenIntAndBool {
|
||||
public BetweenIntAndBool() {
|
||||
int a = 5;
|
||||
boolean b = true;
|
||||
a = b;
|
||||
}
|
||||
}
|
@ -0,0 +1,7 @@
|
||||
public class BetweenIntAndChar {
|
||||
public BetweenIntAndChar() {
|
||||
int a = 5;
|
||||
char b = 'a';
|
||||
a = b;
|
||||
}
|
||||
}
|
@ -0,0 +1,7 @@
|
||||
public class BetweenTwoClasses {
|
||||
public BetweenTwoClasses() {
|
||||
BetweenTwoClasses a = new BetweenTwoClasses();
|
||||
BetweenTwoClassesClassTwo b = new BetweenTwoClassesClassTwo();
|
||||
a = b;
|
||||
}
|
||||
}
|
@ -0,0 +1,2 @@
|
||||
public class BetweenTwoClassesClassTwo {
|
||||
}
|
@ -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;
|
||||
}
|
||||
}
|
@ -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;
|
||||
}
|
||||
}
|
@ -0,0 +1,9 @@
|
||||
public class InFieldToField {
|
||||
int a;
|
||||
char b;
|
||||
public InFieldToField() {
|
||||
this.a = 5;
|
||||
this.b = 'a';
|
||||
this.a = this.b;
|
||||
}
|
||||
}
|
@ -0,0 +1,8 @@
|
||||
public class InAssignmentOfFieldToVariable {
|
||||
int a;
|
||||
public InAssignmentOfFieldToVariable() {
|
||||
char b;
|
||||
b = 'a';
|
||||
this.a = b;
|
||||
}
|
||||
}
|
@ -0,0 +1,11 @@
|
||||
public class InMethodCall {
|
||||
|
||||
public InMethodCall() {
|
||||
char c;
|
||||
c = getFive();
|
||||
}
|
||||
|
||||
public int getFive() {
|
||||
return 5;
|
||||
}
|
||||
}
|
@ -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();
|
||||
}
|
||||
}
|
@ -0,0 +1,5 @@
|
||||
public class InParameter {
|
||||
public void test(boolean b) {
|
||||
char c = b;
|
||||
}
|
||||
}
|
@ -0,0 +1,9 @@
|
||||
public class InMethodCallParameters {
|
||||
public void callThisMethod(boolean a) {
|
||||
a = false;
|
||||
}
|
||||
|
||||
public void method() {
|
||||
callThisMethod(5);
|
||||
}
|
||||
}
|
@ -0,0 +1,10 @@
|
||||
public class InMethodOfObjectCallParameters {
|
||||
public void callThisMethod(boolean a) {
|
||||
a = false;
|
||||
}
|
||||
|
||||
public void method() {
|
||||
InMethodOfObjectCallParameters obj = new InMethodOfObjectCallParameters();
|
||||
obj.callThisMethod(5);
|
||||
}
|
||||
}
|
@ -0,0 +1,5 @@
|
||||
public class InReturnStatement {
|
||||
public int getA() {
|
||||
return '5';
|
||||
}
|
||||
}
|
@ -0,0 +1,6 @@
|
||||
public class OnChar {
|
||||
public void method() {
|
||||
boolean b;
|
||||
b = 'a' && 'b';
|
||||
}
|
||||
}
|
@ -0,0 +1,6 @@
|
||||
public class OnInt {
|
||||
public OnInt() {
|
||||
boolean a;
|
||||
a = 5 && 6;
|
||||
}
|
||||
}
|
@ -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;
|
||||
}
|
||||
}
|
@ -0,0 +1,10 @@
|
||||
public class OnBoolean {
|
||||
public OnBoolean() {
|
||||
int a;
|
||||
boolean b;
|
||||
b = true;
|
||||
boolean c;
|
||||
c = false;
|
||||
a = b / c;
|
||||
}
|
||||
}
|
@ -0,0 +1,10 @@
|
||||
public class OnChar {
|
||||
public void method() {
|
||||
int c;
|
||||
char a;
|
||||
char b;
|
||||
a = 'a';
|
||||
b = 'b';
|
||||
c = a / b;
|
||||
}
|
||||
}
|
@ -0,0 +1,10 @@
|
||||
public class OnObject {
|
||||
public OnObject() {
|
||||
int b;
|
||||
OnObject a;
|
||||
a = new OnObject();
|
||||
OnObject c;
|
||||
c = new OnObject();
|
||||
b = a / c;
|
||||
}
|
||||
}
|
@ -0,0 +1,8 @@
|
||||
public class OnBoolean {
|
||||
public void method() {
|
||||
int c;
|
||||
boolean a = true;
|
||||
boolean b = false;
|
||||
c = a - b;
|
||||
}
|
||||
}
|
@ -0,0 +1,10 @@
|
||||
public class OnChar {
|
||||
public OnChar() {
|
||||
int c;
|
||||
char a;
|
||||
char b;
|
||||
a = 'a';
|
||||
b = 'b';
|
||||
c = a - b;
|
||||
}
|
||||
}
|
@ -0,0 +1,10 @@
|
||||
public class OnObject {
|
||||
public OnObject() {
|
||||
int b;
|
||||
OnObject a;
|
||||
a = new OnObject();
|
||||
OnObject c;
|
||||
c = new OnObject();
|
||||
b = a - c;
|
||||
}
|
||||
}
|
@ -0,0 +1,6 @@
|
||||
public class OnBoolean {
|
||||
public void method() {
|
||||
int a;
|
||||
a = true % false;
|
||||
}
|
||||
}
|
@ -0,0 +1,6 @@
|
||||
public class OnChar {
|
||||
public void method() {
|
||||
int a;
|
||||
a = 'a' % 5;
|
||||
}
|
||||
}
|
@ -0,0 +1,10 @@
|
||||
public class OnObject {
|
||||
public OnObject() {
|
||||
int b;
|
||||
OnObject a;
|
||||
a = new OnObject();
|
||||
OnObject c;
|
||||
c = new OnObject();
|
||||
b = a % c;
|
||||
}
|
||||
}
|
@ -0,0 +1,8 @@
|
||||
public class OnBoolean {
|
||||
public void method() {
|
||||
int c;
|
||||
boolean a = true;
|
||||
boolean b = false;
|
||||
c = a * b;
|
||||
}
|
||||
}
|
@ -0,0 +1,10 @@
|
||||
public class OnChar {
|
||||
public OnChar() {
|
||||
int c;
|
||||
char a;
|
||||
char b;
|
||||
a = 'a';
|
||||
b = 'b';
|
||||
c = a * b;
|
||||
}
|
||||
}
|
@ -0,0 +1,10 @@
|
||||
public class OnObject {
|
||||
public OnObject() {
|
||||
int b;
|
||||
OnObject a;
|
||||
a = new OnObject();
|
||||
OnObject c;
|
||||
c = new OnObject();
|
||||
b = a * c;
|
||||
}
|
||||
}
|
@ -0,0 +1,8 @@
|
||||
public class OnChar {
|
||||
public OnChar() {
|
||||
boolean c;
|
||||
char a;
|
||||
a = 'a';
|
||||
b = !a;
|
||||
}
|
||||
}
|
@ -0,0 +1,8 @@
|
||||
public class OnInt {
|
||||
public OnInt() {
|
||||
int a;
|
||||
boolean b;
|
||||
a = 1;
|
||||
b = !a;
|
||||
}
|
||||
}
|
@ -0,0 +1,8 @@
|
||||
public class OnObject {
|
||||
public OnObject() {
|
||||
boolean b;
|
||||
OnObject a;
|
||||
a = new OnObject();
|
||||
b = !a;
|
||||
}
|
||||
}
|
@ -0,0 +1,10 @@
|
||||
public class And {
|
||||
public And() {
|
||||
boolean a;
|
||||
boolean b;
|
||||
int c;
|
||||
a = true;
|
||||
b = false;
|
||||
c = a && b;
|
||||
}
|
||||
}
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user