Compare commits

..

No commits in common. "97e0c228d65a1e96e8222860e8c39060f3df3a6f" and "ca539add988e459fa6b832a4fbd00177f517ea21" have entirely different histories.

5 changed files with 22 additions and 54 deletions

View File

@ -26,7 +26,10 @@ import java.util.regex.Matcher;
import java.util.regex.Pattern;
import org.junit.jupiter.api.Test;
import semantic.exceptions.*;
import semantic.exceptions.AlreadyDeclaredException;
import semantic.exceptions.MultipleReturnTypes;
import semantic.exceptions.NotDeclaredException;
import semantic.exceptions.TypeMismatchException;
import semantic.exceptions.NotDeclaredException;
import static org.junit.jupiter.api.Assertions.*;
@ -233,46 +236,6 @@ public class EndToTypedAstTest {
assertFalse(SemanticAnalyzer.errors.isEmpty());
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 ------------------
/**

View File

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

View File

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