import static org.junit.jupiter.api.Assertions.assertEquals; import static org.junit.jupiter.api.Assertions.assertThrows; import org.antlr.v4.runtime.tree.ParseTree; import org.junit.jupiter.api.Test; import de.hsrm.compiler.Klang.ContextAnalysis; public class OrTest { @Test void onlyForBool() { ParseTree tree = Helper.prepareParser("function foo(): bool { return 1 || 2; } foo();"); var funcs = Helper.getFuncs(tree); var structs = Helper.getStructs(tree); var enums = Helper.getEnums(tree); ContextAnalysis ctxAnal = new ContextAnalysis(funcs, structs, enums); Exception e = assertThrows(RuntimeException.class, () -> ctxAnal.visit(tree)); assertEquals("Error in line 1:30 || is only defined for bool.", e.getMessage()); } }