Compare commits

...

2 Commits

Author SHA1 Message Date
Bruder John
97e0c228d6 Merge branch 'Endabgabe' of https://gitea.hb.dhbw-stuttgart.de/i22005/NichtHaskell2.0 into Endabgabe
Some checks are pending
Gitea Actions Demo / Explore-Gitea-Actions (push) Waiting to run
2024-07-03 20:37:35 +02:00
Bruder John
d4be77ceb2 Changed Some Tests 2024-07-03 20:36:57 +02:00
5 changed files with 54 additions and 22 deletions

View File

@ -26,10 +26,7 @@ import java.util.regex.Matcher;
import java.util.regex.Pattern; import java.util.regex.Pattern;
import org.junit.jupiter.api.Test; import org.junit.jupiter.api.Test;
import semantic.exceptions.AlreadyDeclaredException; import semantic.exceptions.*;
import semantic.exceptions.MultipleReturnTypes;
import semantic.exceptions.NotDeclaredException;
import semantic.exceptions.TypeMismatchException;
import semantic.exceptions.NotDeclaredException; import semantic.exceptions.NotDeclaredException;
import static org.junit.jupiter.api.Assertions.*; import static org.junit.jupiter.api.Assertions.*;
@ -236,6 +233,46 @@ public class EndToTypedAstTest {
assertFalse(SemanticAnalyzer.errors.isEmpty()); assertFalse(SemanticAnalyzer.errors.isEmpty());
assertTrue(SemanticAnalyzer.errors.stream().anyMatch(c -> c instanceof MultipleReturnTypes)); assertTrue(SemanticAnalyzer.errors.stream().anyMatch(c -> c instanceof MultipleReturnTypes));
} }
@Test
public void BothTypesMustBeSameGreaterSmallerEqual(){
ASTNode tast = SemanticHelper.generateTypedASTFrom("src/test/resources/input/johnsTests/BothTypesMustBeSame.java");
SemanticAnalyzer.generateTast(tast);
assertFalse(SemanticAnalyzer.errors.isEmpty());
assertEquals(3, SemanticAnalyzer.errors.size());
assertTrue(SemanticAnalyzer.errors.stream().anyMatch(c -> c instanceof TypeMismatchException));
}
@Test
public void NoSuchType(){
ASTNode tast = SemanticHelper.generateTypedASTFrom("src/test/resources/input/johnsTests/ClassNotDeclared.java");
SemanticAnalyzer.generateTast(tast);
assertFalse(SemanticAnalyzer.errors.isEmpty());
assertEquals(1, SemanticAnalyzer.errors.size());
assertTrue(SemanticAnalyzer.errors.stream().anyMatch(c -> c instanceof NotDeclaredException));
}
@Test
public void FieldIsNotVisible(){
ASTNode tast = SemanticHelper.generateTypedASTFrom("src/test/resources/input/johnsTests/FieldIsNotVisible.java");
SemanticAnalyzer.generateTast(tast);
assertFalse(SemanticAnalyzer.errors.isEmpty());
assertEquals(1, SemanticAnalyzer.errors.size());
assertTrue(SemanticAnalyzer.errors.stream().anyMatch(c -> c instanceof NotVisibleException));
}
// ------------------ Helpers ------------------ // ------------------ Helpers ------------------
/** /**

View File

@ -5,5 +5,18 @@ public class AllFeaturesClassExample {
while (a > bool) { while (a > bool) {
a--; a--;
} }
if (a == bool) {
} else {
}
if (a < bool) {
} else {
}
} }
} }

View File

@ -4,9 +4,4 @@ public class Test {
public House1 h; public House1 h;
}
public class House {
} }

View File

@ -1,13 +0,0 @@
// @expected: TypeMismatchException
public class Test{
public void test(boolean b){
if(b == 2){
} else {
}
}
}