wrote more comments

This commit is contained in:
JonathanFleischmann 2024-07-04 00:06:48 +02:00
parent 04a84806b1
commit c0f3d8c940
9 changed files with 116 additions and 6 deletions

View File

@ -3,7 +3,9 @@ import org.junit.jupiter.api.Test;
import static HelpClasses.TestFileTester.run;
/**
* This class runs all the E2E test classes.
*/
class AllE2ETests {
// @Test

View File

@ -7,6 +7,9 @@ import java.util.List;
import static HelpClasses.TestFileTester.run;
import static org.junit.jupiter.api.Assertions.assertThrows;
/**
* This class runs all negative tests plus some additional tests that did not fit into any of the categories.
*/
class AllNegativeTests {
@Test
@ -34,6 +37,7 @@ class AllNegativeTests {
run(WrongType.class);
}
// A value is assigned to a field outside a method
@Test
void AssignmentOutsideMethod() {
assertThrows(Exception.class, () -> {
@ -42,6 +46,7 @@ class AllNegativeTests {
});
}
// A field is called in the main method
@Test
void CallingFieldInMainMethod() {
assertThrows(Exception.class, () -> {

View File

@ -1,8 +1,6 @@
package NegativeTests;
import de.maishai.Compiler;
import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import java.util.List;

View File

@ -1,8 +1,6 @@
package NegativeTests;
import de.maishai.Compiler;
import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import java.util.List;

View File

@ -16,6 +16,7 @@ import static org.junit.jupiter.api.Assertions.assertThrows;
*/
public class MissingComponents {
// Missing a brace in a class.
@Test
public void MissingComponentsBraceInClass() {
assertThrows(Exception.class, () -> {
@ -24,6 +25,7 @@ public class MissingComponents {
});
}
// Missing a brace in a constructor.
@Test
public void MissingComponentsBraceInConstructor() {
assertThrows(Exception.class, () -> {
@ -32,6 +34,7 @@ public class MissingComponents {
});
}
// Missing a brace in a do-while loop.
@Test
public void MissingComponentsBraceInDoWhile() {
assertThrows(Exception.class, () -> {
@ -40,6 +43,7 @@ public class MissingComponents {
});
}
// Missing a brace in for loop.
@Test
public void MissingComponentsBraceInFor() {
assertThrows(Exception.class, () -> {
@ -48,6 +52,7 @@ public class MissingComponents {
});
}
// Missing a brace in an if block.
@Test
public void MissingComponentsBraceInIf() {
assertThrows(Exception.class, () -> {
@ -56,6 +61,7 @@ public class MissingComponents {
});
}
// Missing a brace in a method.
@Test
public void MissingComponentsBraceInMethod() {
assertThrows(Exception.class, () -> {
@ -64,6 +70,7 @@ public class MissingComponents {
});
}
// Missing a brace in a while loop.
@Test
public void MissingComponentsBraceInWhile() {
assertThrows(Exception.class, () -> {
@ -72,6 +79,7 @@ public class MissingComponents {
});
}
// Missing the identifier of the class declaration.
@Test
public void MissingComponentsIdentifierInClass() {
assertThrows(Exception.class, () -> {
@ -80,6 +88,7 @@ public class MissingComponents {
});
}
// Missing the identifier of the constructor.
@Test
public void MissingComponentsIdentifierInConstructor() {
assertThrows(Exception.class, () -> {
@ -88,6 +97,7 @@ public class MissingComponents {
});
}
// Missing the identifier of a field.
@Test
public void MissingComponentsIdentifierInField() {
assertThrows(Exception.class, () -> {
@ -96,6 +106,7 @@ public class MissingComponents {
});
}
// Missing the identifier of a field call.
@Test
public void MissingComponentsIdentifierInFieldCall() {
assertThrows(Exception.class, () -> {
@ -104,6 +115,7 @@ public class MissingComponents {
});
}
// Missing the identifier of a method.
@Test
public void MissingComponentsIdentifierInMethod() {
assertThrows(Exception.class, () -> {
@ -112,6 +124,7 @@ public class MissingComponents {
});
}
// Missing the identifier of a method call.
@Test
public void MissingComponentsIdentifierInMethodCall() {
assertThrows(Exception.class, () -> {
@ -120,6 +133,7 @@ public class MissingComponents {
});
}
// Missing the identifier of a variable.
@Test
public void MissingComponentsIdentifierInVariable() {
assertThrows(Exception.class, () -> {
@ -128,6 +142,7 @@ public class MissingComponents {
});
}
// Missing the keyword 'public' in class declaration.
@Test
public void MissingComponentsPublicInClass() {
assertThrows(Exception.class, () -> {
@ -136,6 +151,7 @@ public class MissingComponents {
});
}
// Missing the keyword 'public' in method declaration.
@Test
public void MissingComponentsPublicInMethod() {
assertThrows(Exception.class, () -> {
@ -144,6 +160,7 @@ public class MissingComponents {
});
}
// Missing the round bracket in constructor declaration.
@Test
public void MissingComponentsRoundBracketsInConstructor() {
assertThrows(Exception.class, () -> {
@ -152,6 +169,7 @@ public class MissingComponents {
});
}
// Missing the round bracket in do-while loop.
@Test
public void MissingComponentsRoundBracketsInDoWhile() {
assertThrows(Exception.class, () -> {
@ -160,6 +178,7 @@ public class MissingComponents {
});
}
// Missing the round bracket in else-if block.
@Test
public void MissingComponentsRoundBracketsInElseIf() {
assertThrows(Exception.class, () -> {
@ -168,6 +187,7 @@ public class MissingComponents {
});
}
// Missing the round bracket in for loop.
@Test
public void MissingComponentsRoundBracketsInFor() {
assertThrows(Exception.class, () -> {
@ -176,6 +196,7 @@ public class MissingComponents {
});
}
// Missing the round bracket in if block.
@Test
public void MissingComponentsRoundBracketsInIf() {
assertThrows(Exception.class, () -> {
@ -184,6 +205,7 @@ public class MissingComponents {
});
}
// Missing the round bracket in method declaration.
@Test
public void MissingComponentsRoundBracketsInMethod() {
assertThrows(Exception.class, () -> {
@ -192,6 +214,7 @@ public class MissingComponents {
});
}
// Missing the round bracket in method call.
@Test
public void MissingComponentsRoundBracketsInMethodCall() {
assertThrows(Exception.class, () -> {
@ -200,6 +223,7 @@ public class MissingComponents {
});
}
// Missing the round bracket in new object.
@Test
public void MissingComponentsRoundBracketsInNewObject() {
assertThrows(Exception.class, () -> {
@ -208,6 +232,7 @@ public class MissingComponents {
});
}
// Missing the round bracket in while loop.
@Test
public void MissingComponentsRoundBracketsInWhile() {
assertThrows(Exception.class, () -> {
@ -216,6 +241,7 @@ public class MissingComponents {
});
}
// Missing the semicolon in an assignment.
@Test
public void MissingComponentsSemicolonInAssignment() {
assertThrows(Exception.class, () -> {
@ -224,6 +250,7 @@ public class MissingComponents {
});
}
// Missing the semicolon in a do-while loop.
@Test
public void MissingComponentsSemicolonInDoWhile() {
assertThrows(Exception.class, () -> {
@ -232,6 +259,7 @@ public class MissingComponents {
});
}
// Missing the semicolon in a field.
@Test
public void MissingComponentsSemicolonInField() {
assertThrows(Exception.class, () -> {
@ -240,6 +268,7 @@ public class MissingComponents {
});
}
// Missing the semicolon in a method call.
@Test
public void MissingComponentsSemicolonInMethodCall() {
assertThrows(Exception.class, () -> {
@ -248,6 +277,7 @@ public class MissingComponents {
});
}
// Missing the semicolon in a return statement.
@Test
public void MissingComponentsSemicolonInReturn() {
assertThrows(Exception.class, () -> {
@ -256,6 +286,7 @@ public class MissingComponents {
});
}
// Missing the type of field.
@Test
public void MissingComponentsTypeInField() {
assertThrows(Exception.class, () -> {
@ -264,6 +295,7 @@ public class MissingComponents {
});
}
// Missing the type of method.
@Test
public void MissingComponentsTypeInMethodSignature() {
assertThrows(Exception.class, () -> {
@ -272,6 +304,7 @@ public class MissingComponents {
});
}
// Missing the type of parameter.
@Test
public void MissingComponentsTypeInParameter() {
assertThrows(Exception.class, () -> {
@ -280,6 +313,7 @@ public class MissingComponents {
});
}
// Missing the keyword 'class' in class declaration
@Test
public void MissingComponentsClassInClass() {
assertThrows(Exception.class, () -> {
@ -288,6 +322,7 @@ public class MissingComponents {
});
}
// Missing the class declaration of an object.
@Test
public void MissingComponentsClassOfObject() {
assertThrows(Exception.class, () -> {
@ -296,6 +331,7 @@ public class MissingComponents {
});
}
// Missing the return statement in a method.
@Test
public void MissingComponentsReturn() {
assertThrows(Exception.class, () -> {

View File

@ -9,20 +9,27 @@ import java.util.List;
import static org.junit.jupiter.api.Assertions.assertThrows;
/**
* Tests for using the same name for different things.
* see src/test/testFiles/Negative/UsingSameName for the test files.
*/
public class UsingSameName {
// Using the same name for a parameter and a variable
@Test
public void UsingSameNameForParameterAndVariable() {
assertThrows(Exception.class, () -> Compiler.generateByteCodeArrayFromFiles(List.of(
"src/test/testFiles/Negative/UsingSameName/ForParameterAndVariable.java")));
}
// Using the same name for two parameters
@Test
public void UsingSameNameForTwoParameters() {
assertThrows(Exception.class, () -> Compiler.generateByteCodeArrayFromFiles(List.of(
"src/test/testFiles/Negative/UsingSameName/ForTwoParameters.java")));
}
// Using the same name for two variables
@Test
public void UsingSameNameForTwoVariables() {
assertThrows(Exception.class, () -> Compiler.generateByteCodeArrayFromFiles(List.of(

View File

@ -9,32 +9,41 @@ import java.util.List;
import static org.junit.jupiter.api.Assertions.assertThrows;
/**
* Tests for wrong type.
* see src/test/testFiles/Negative/WrongType for the test files.
*/
public class WrongType {
// Assigning a boolean to a char
@Test
public void WrongTypeCheckTypeDifferencesBetweenBoolAndChar() {
assertThrows(Exception.class, () -> Compiler.generateByteCodeArrayFromFiles(List.of(
"src/test/testFiles/Negative/WrongType/CheckTypeDifferences/BetweenBoolAndChar.java")));
}
// Assigning a class to an int
@Test
public void WrongTypeCheckTypeDifferencesBetweenClassAndInt() {
assertThrows(Exception.class, () -> Compiler.generateByteCodeArrayFromFiles(List.of(
"src/test/testFiles/Negative/WrongType/CheckTypeDifferences/BetweenClassAndInt.java")));
}
// Assigning a boolean to an int
@Test
public void WrongTypeCheckTypeDifferencesBetweenIntAndBool() {
assertThrows(Exception.class, () -> Compiler.generateByteCodeArrayFromFiles(List.of(
"src/test/testFiles/Negative/WrongType/CheckTypeDifferences/BetweenIntAndBool.java")));
}
// Assigning a char to an int
@Test
public void WrongTypeCheckTypeDifferencesBetweenIntAndChar() {
assertThrows(Exception.class, () -> Compiler.generateByteCodeArrayFromFiles(List.of(
"src/test/testFiles/Negative/WrongType/CheckTypeDifferences/BetweenIntAndChar.java")));
}
// Assigning a class to another class
@Test
public void WrongTypeCheckTypeDifferencesBetweenTwoClasses() {
assertThrows(Exception.class, () -> Compiler.generateByteCodeArrayFromFiles(List.of(
@ -42,258 +51,301 @@ public class WrongType {
"src/test/testFiles/Negative/WrongType/CheckTypeDifferences/BetweenTwoClassesClassTwo.java")));
}
// a field of an object has a different type than the variable it is assigned to
@Test
public void WrongTypeInAssigmentInAttributeOfObjectGet() {
assertThrows(Exception.class, () -> Compiler.generateByteCodeArrayFromFiles(List.of(
"src/test/testFiles/Negative/WrongType/InAssignment/InAttributeOfObjectGet.java")));
}
// a variable has a different type than the field of an object it is assigned to
@Test
public void WrongTypeInAssigmentInAttributeOfObjectSet() {
assertThrows(Exception.class, () -> Compiler.generateByteCodeArrayFromFiles(List.of(
"src/test/testFiles/Negative/WrongType/InAssignment/InAttributeOfObjectSet.java")));
}
// a field has a different type than the field it is assigned to
@Test
public void WrongTypeInAssigmentInFieldToField() {
assertThrows(Exception.class, () -> Compiler.generateByteCodeArrayFromFiles(List.of(
"src/test/testFiles/Negative/WrongType/InAssignment/InFieldToField.java")));
}
// a variable has a different type than the field it is assigned to
@Test
public void WrongTypeInAssigmentInFieldToVariable() {
assertThrows(Exception.class, () -> Compiler.generateByteCodeArrayFromFiles(List.of(
"src/test/testFiles/Negative/WrongType/InAssignment/InFieldToVariable.java")));
}
// a method call has a different type than the variable it is assigned to
@Test
public void WrongTypeInAssigmentInMethodCall() {
assertThrows(Exception.class, () -> Compiler.generateByteCodeArrayFromFiles(List.of(
"src/test/testFiles/Negative/WrongType/InAssignment/InMethodCall.java")));
}
// a method of an object has a different type than the variable it is assigned to
@Test
public void WrongTypeInAssigmentInMethodOfObjectGet() {
assertThrows(Exception.class, () -> Compiler.generateByteCodeArrayFromFiles(List.of(
"src/test/testFiles/Negative/WrongType/InAssignment/InMethodOfObjectGet.java")));
}
// a parameter has a different type than the variable it is assigned to
@Test
public void WrongTypeInAssigmentInParameter() {
assertThrows(Exception.class, () -> Compiler.generateByteCodeArrayFromFiles(List.of(
"src/test/testFiles/Negative/WrongType/InAssignment/InParameter.java")));
}
// two chars are connected with a and operator
@Test
public void WrongTypeUsingWithOperatorsAndOnChar() {
assertThrows(Exception.class, () -> Compiler.generateByteCodeArrayFromFiles(List.of(
"src/test/testFiles/Negative/WrongType/UsingWithOperators/And/OnChar.java")));
}
// two integers are connected with a and operator
@Test
public void WrongTypeUsingWithOperatorsAndOnInt() {
assertThrows(Exception.class, () -> Compiler.generateByteCodeArrayFromFiles(List.of(
"src/test/testFiles/Negative/WrongType/UsingWithOperators/And/OnInt.java")));
}
// two objects are connected with a and operator
@Test
public void WrongTypeUsingWithOperatorsAndOnObject() {
assertThrows(Exception.class, () -> Compiler.generateByteCodeArrayFromFiles(List.of(
"src/test/testFiles/Negative/WrongType/UsingWithOperators/And/OnObject.java")));
}
// a boolean is divided by a boolean
@Test
public void WrongTypeUsingWithOperatorsDivOnBoolean() {
assertThrows(Exception.class, () -> Compiler.generateByteCodeArrayFromFiles(List.of(
"src/test/testFiles/Negative/WrongType/UsingWithOperators/Div/OnBoolean.java")));
}
// a char is divided by a char
@Test
public void WrongTypeUsingWithOperatorsDivOnChar() {
assertThrows(Exception.class, () -> Compiler.generateByteCodeArrayFromFiles(List.of(
"src/test/testFiles/Negative/WrongType/UsingWithOperators/Div/OnChar.java")));
}
// an object is divided by an object
@Test
public void WrongTypeUsingWithOperatorsDivOnObject() {
assertThrows(Exception.class, () -> Compiler.generateByteCodeArrayFromFiles(List.of(
"src/test/testFiles/Negative/WrongType/UsingWithOperators/Div/OnObject.java")));
}
// a boolean is subtracted by a boolean
@Test
public void WrongTypeUsingWithOperatorsMinOnBoolean() {
assertThrows(Exception.class, () -> Compiler.generateByteCodeArrayFromFiles(List.of(
"src/test/testFiles/Negative/WrongType/UsingWithOperators/Min/OnBoolean.java")));
}
// a char is subtracted by a char
@Test
public void WrongTypeUsingWithOperatorsMinOnChar() {
assertThrows(Exception.class, () -> Compiler.generateByteCodeArrayFromFiles(List.of(
"src/test/testFiles/Negative/WrongType/UsingWithOperators/Min/OnChar.java")));
}
// an object is subtracted by an object
@Test
public void WrongTypeUsingWithOperatorsMinOnObject() {
assertThrows(Exception.class, () -> Compiler.generateByteCodeArrayFromFiles(List.of(
"src/test/testFiles/Negative/WrongType/UsingWithOperators/Min/OnObject.java")));
}
// a boolean is modulated by a boolean
@Test
public void WrongTypeUsingWithOperatorsModOnBoolean() {
assertThrows(Exception.class, () -> Compiler.generateByteCodeArrayFromFiles(List.of(
"src/test/testFiles/Negative/WrongType/UsingWithOperators/Mod/OnBoolean.java")));
}
// a char is modulated by a char
@Test
public void WrongTypeUsingWithOperatorsModOnChar() {
assertThrows(Exception.class, () -> Compiler.generateByteCodeArrayFromFiles(List.of(
"src/test/testFiles/Negative/WrongType/UsingWithOperators/Mod/OnChar.java")));
}
// an object is modulated by an object
@Test
public void WrongTypeUsingWithOperatorsModOnObject() {
assertThrows(Exception.class, () -> Compiler.generateByteCodeArrayFromFiles(List.of(
"src/test/testFiles/Negative/WrongType/UsingWithOperators/Mod/OnObject.java")));
}
// a boolean is multiplied by a boolean
@Test
public void WrongTypeUsingWithOperatorsMulOnBoolean() {
assertThrows(Exception.class, () -> Compiler.generateByteCodeArrayFromFiles(List.of(
"src/test/testFiles/Negative/WrongType/UsingWithOperators/Mul/OnBoolean.java")));
}
// a char is multiplied by a char
@Test
public void WrongTypeUsingWithOperatorsMulOnChar() {
assertThrows(Exception.class, () -> Compiler.generateByteCodeArrayFromFiles(List.of(
"src/test/testFiles/Negative/WrongType/UsingWithOperators/Mul/OnChar.java")));
}
// an object is multiplied by an object
@Test
public void WrongTypeUsingWithOperatorsMulOnObject() {
assertThrows(Exception.class, () -> Compiler.generateByteCodeArrayFromFiles(List.of(
"src/test/testFiles/Negative/WrongType/UsingWithOperators/Mul/OnObject.java")));
}
// a char is negated
@Test
public void WrongTypeUsingWithOperatorsNotOnChar() {
assertThrows(Exception.class, () -> Compiler.generateByteCodeArrayFromFiles(List.of(
"src/test/testFiles/Negative/WrongType/UsingWithOperators/Not/OnChar.java")));
}
// an int is negated
@Test
public void WrongTypeUsingWithOperatorsNotOnInt() {
assertThrows(Exception.class, () -> Compiler.generateByteCodeArrayFromFiles(List.of(
"src/test/testFiles/Negative/WrongType/UsingWithOperators/Not/OnInt.java")));
}
// an object is negated
@Test
public void WrongTypeUsingWithOperatorsNotOnObject() {
assertThrows(Exception.class, () -> Compiler.generateByteCodeArrayFromFiles(List.of(
"src/test/testFiles/Negative/WrongType/UsingWithOperators/Not/OnObject.java")));
}
// two chars are connected with a or operator
@Test
public void WrongTypeUsingWithOperatorsOrOnChar() {
assertThrows(Exception.class, () -> Compiler.generateByteCodeArrayFromFiles(List.of(
"src/test/testFiles/Negative/WrongType/UsingWithOperators/Or/OnChar.java")));
}
// two integers are connected with a or operator
@Test
public void WrongTypeUsingWithOperatorsOrOnInt() {
assertThrows(Exception.class, () -> Compiler.generateByteCodeArrayFromFiles(List.of(
"src/test/testFiles/Negative/WrongType/UsingWithOperators/Or/OnInt.java")));
}
// two objects are connected with a or operator
@Test
public void WrongTypeUsingWithOperatorsOrOnObject() {
assertThrows(Exception.class, () -> Compiler.generateByteCodeArrayFromFiles(List.of(
"src/test/testFiles/Negative/WrongType/UsingWithOperators/Or/OnObject.java")));
}
// a boolean is added to a boolean
@Test
public void WrongTypeUsingWithOperatorsPlusOnBoolean() {
assertThrows(Exception.class, () -> Compiler.generateByteCodeArrayFromFiles(List.of(
"src/test/testFiles/Negative/WrongType/UsingWithOperators/Plus/OnBoolean.java")));
}
// a char is added to a char
@Test
public void WrongTypeUsingWithOperatorsPlusOnChar() {
assertThrows(Exception.class, () -> Compiler.generateByteCodeArrayFromFiles(List.of(
"src/test/testFiles/Negative/WrongType/UsingWithOperators/Plus/OnChar.java")));
}
// an object is added to an object
@Test
public void WrongTypeUsingWithOperatorsPlusOnObject() {
assertThrows(Exception.class, () -> Compiler.generateByteCodeArrayFromFiles(List.of(
"src/test/testFiles/Negative/WrongType/UsingWithOperators/Plus/OnObject.java")));
}
// the result of a and statement is assigned to a variable which is not boolean
@Test
public void WrongTypeUsingWithOperatorsOperatorReturnValuesAnd() {
assertThrows(Exception.class, () -> Compiler.generateByteCodeArrayFromFiles(List.of(
"src/test/testFiles/Negative/WrongType/UsingWithOperators/OperatorReturnValues/And.java")));
}
// the result of a div statement is assigned to a variable which is not int
@Test
public void WrongTypeUsingWithOperatorsOperatorReturnValuesDiv() {
assertThrows(Exception.class, () -> Compiler.generateByteCodeArrayFromFiles(List.of(
"src/test/testFiles/Negative/WrongType/UsingWithOperators/OperatorReturnValues/Div.java")));
}
// the result of a min statement is assigned to a variable which is not int
@Test
public void WrongTypeUsingWithOperatorsOperatorReturnValuesMin() {
assertThrows(Exception.class, () -> Compiler.generateByteCodeArrayFromFiles(List.of(
"src/test/testFiles/Negative/WrongType/UsingWithOperators/OperatorReturnValues/Min.java")));
}
// the result of a mod statement is assigned to a variable which is not int
@Test
public void WrongTypeUsingWithOperatorsOperatorReturnValuesMod() {
assertThrows(Exception.class, () -> Compiler.generateByteCodeArrayFromFiles(List.of(
"src/test/testFiles/Negative/WrongType/UsingWithOperators/OperatorReturnValues/Mod.java")));
}
// the result of a mul statement is assigned to a variable which is not int
@Test
public void WrongTypeUsingWithOperatorsOperatorReturnValuesMul() {
assertThrows(Exception.class, () -> Compiler.generateByteCodeArrayFromFiles(List.of(
"src/test/testFiles/Negative/WrongType/UsingWithOperators/OperatorReturnValues/Mul.java")));
}
// the result of a not statement is assigned to a variable which is not boolean
@Test
public void WrongTypeUsingWithOperatorsOperatorReturnValuesNot() {
assertThrows(Exception.class, () -> Compiler.generateByteCodeArrayFromFiles(List.of(
"src/test/testFiles/Negative/WrongType/UsingWithOperators/OperatorReturnValues/Not.java")));
}
// the result of a or statement is assigned to a variable which is not boolean
@Test
public void WrongTypeUsingWithOperatorsOperatorReturnValuesOr() {
assertThrows(Exception.class, () -> Compiler.generateByteCodeArrayFromFiles(List.of(
"src/test/testFiles/Negative/WrongType/UsingWithOperators/OperatorReturnValues/Or.java")));
}
// the result of a plus statement is assigned to a variable which is not int
@Test
public void WrongTypeUsingWithOperatorsOperatorReturnValuesPlus() {
assertThrows(Exception.class, () -> Compiler.generateByteCodeArrayFromFiles(List.of(
"src/test/testFiles/Negative/WrongType/UsingWithOperators/OperatorReturnValues/Plus.java")));
}
// a parameter type of method is different from the value it is passed
@Test
public void WrongTypeUsingWithOperatorsInMethodCallParameters() {
assertThrows(Exception.class, () -> Compiler.generateByteCodeArrayFromFiles(List.of(
"src/test/testFiles/Negative/WrongType/InMethodCallParameters.java")));
}
// a parameter type of method of an object is different from the value it is passed
@Test
public void WrongTypeUsingWithOperatorsInMethodOfObjectCallParameters() {
assertThrows(Exception.class, () -> Compiler.generateByteCodeArrayFromFiles(List.of(
"src/test/testFiles/Negative/WrongType/InMethodOfObjectCallParameters.java")));
}
// return statement has a different type than the method
@Test
public void WrongTypeUsingWithOperatorsInReturnStatement() {
assertThrows(Exception.class, () -> Compiler.generateByteCodeArrayFromFiles(List.of(
"src/test/testFiles/Negative/WrongType/InReturnStatement.java")));
}
// return statement has a type, but the method is void
@Test
public void WrongTypeUsingWithOperatorsInReturnStatementWithVoidMethod() {
assertThrows(Exception.class, () -> Compiler.generateByteCodeArrayFromFiles(List.of(

View File

@ -10,6 +10,12 @@ import java.util.List;
import static org.junit.jupiter.api.Assertions.assertEquals;
/**
* This class contains all tests for the Scanner and Parser which compare the generated AST with the expected AST.
* The tests are divided into two categories:
* - Feature Tests: These tests should test the conversion of code into an AST with every possible feature.
* - More Tests: These tests are just some tests on top, no real structure, left from the beginning, don't care about the names.
*/
class ScannerParserTests {
// Feature Tests, which should test converting code into AST with every possible Feature

View File

@ -9,7 +9,13 @@ import MoreTestResources.AST.*;
import MoreTestResources.TypedAST.*;
import static org.junit.jupiter.api.Assertions.assertEquals;
/**
* This class contains all tests for the Typing Phase.
* It tests the conversion of the AST into the TypedAST.
* The tests are divided into Feature Tests and More Tests.
* The Feature Tests test the conversion of the AST into the TypedAST with every possible Feature.
* The More Tests are just some additional Tests, which are not structured in any way.
*/
class TypingTests {
// Feature Tests, which should test converting code into AST with every possible Feature