LogicalExpressionPlan plan = new LogicalExpressionPlan() ;
ConstantExpression constant1 = new ConstantExpression(plan, 10) ;
ConstantExpression constant2 = new ConstantExpression(plan, 20D) ;
ConstantExpression constant3 = new ConstantExpression(plan, 123f) ;
DivideExpression div1 = new DivideExpression(plan, constant1, constant2) ;
CastExpression cast1 = new CastExpression(plan, constant3, createFS(DataType.DOUBLE));
NotEqualExpression notequal1 = new NotEqualExpression(plan, div1, cast1) ;
CompilationMessageCollector collector = new CompilationMessageCollector() ;
TypeCheckingExpVisitor expTypeChecker = new TypeCheckingExpVisitor(plan, collector, null);
expTypeChecker.visit();
printMessageCollector(collector) ;
//printTypeGraph(plan) ;
if (collector.hasError()) {
throw new Exception("Error during type checking") ;
}
// Induction check
assertEquals(DataType.DOUBLE, div1.getType()) ;
assertEquals(DataType.BOOLEAN, notequal1.getType()) ;
// Cast insertion check
assertEquals(DataType.DOUBLE, div1.getLhs().getType()) ;
assertEquals(DataType.DOUBLE, notequal1.getRhs().getType()) ;
}