added wrong type in if clause
Some checks are pending
Gitea Actions Demo / Explore-Gitea-Actions (push) Waiting to run
Some checks are pending
Gitea Actions Demo / Explore-Gitea-Actions (push) Waiting to run
This commit is contained in:
parent
7b41c45cd5
commit
5bf9a4fc73
@ -175,7 +175,7 @@ public class SemanticAnalyzer implements SemanticVisitor {
|
||||
|
||||
@Override
|
||||
public TypeCheckResult analyze(IfStatementNode toCheck) {
|
||||
return null;
|
||||
return new TypeCheckResult(true, null);
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -275,7 +275,7 @@ public class SemanticAnalyzer implements SemanticVisitor {
|
||||
|
||||
@Override
|
||||
public TypeCheckResult analyze(IfElseStatementNode toCheck) {
|
||||
return null;
|
||||
return new TypeCheckResult(true, null);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -49,6 +49,7 @@ public class EndToTAST {
|
||||
|
||||
ASTNode tast = SemanticAnalyzer.generateTast(abstractSyntaxTree);
|
||||
|
||||
|
||||
assertEquals(SemanticAnalyzer.errors.size(), 0);
|
||||
assertNotNull(tast);
|
||||
|
||||
@ -254,4 +255,28 @@ public class EndToTAST {
|
||||
|
||||
}
|
||||
|
||||
@Test
|
||||
public void wrongTypeInIfClause(){
|
||||
|
||||
CharStream codeCharStream = null;
|
||||
try {
|
||||
codeCharStream = CharStreams.fromPath(Paths.get("src/test/resources/semantic/endToTAST/WrongIfClause.java"));
|
||||
} catch (IOException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
SimpleJavaLexer lexer = new SimpleJavaLexer(codeCharStream);
|
||||
CommonTokenStream tokenStream = new CommonTokenStream(lexer);
|
||||
|
||||
SimpleJavaParser parser = new SimpleJavaParser(tokenStream);
|
||||
ParseTree parseTree = parser.program();
|
||||
|
||||
ASTBuilder astBuilder = new ASTBuilder();
|
||||
ProgramNode abstractSyntaxTree = (ProgramNode) astBuilder.visit(parseTree);
|
||||
|
||||
ASTNode tast = SemanticAnalyzer.generateTast(abstractSyntaxTree);
|
||||
|
||||
assertFalse(SemanticAnalyzer.errors.isEmpty());
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -2,10 +2,17 @@ public class Example {
|
||||
|
||||
public int a;
|
||||
|
||||
public static int testMethod(int b){
|
||||
public static int testMethod(int b, boolean bo){
|
||||
a = b;
|
||||
if(bo){
|
||||
|
||||
}
|
||||
return a;
|
||||
|
||||
}
|
||||
|
||||
public static void testMethod(int b){
|
||||
|
||||
}
|
||||
|
||||
}
|
7
src/test/resources/semantic/endToTAST/WrongIfClause.java
Normal file
7
src/test/resources/semantic/endToTAST/WrongIfClause.java
Normal file
@ -0,0 +1,7 @@
|
||||
public class Example {
|
||||
|
||||
public static void testMethod(int x){
|
||||
|
||||
}
|
||||
|
||||
}
|
Loading…
Reference in New Issue
Block a user