示例#1
0
 public void testCantSimplifyCast() {
   Number number = new Number(2);
   Cast cast = new Cast(number);
   cast.type = IntegerType.instance;
   ExpressionVisitor visitor = new ExpressionVisitor(new SymbolTable());
   assertEquals(cast, visitor.visit(cast));
 }
示例#2
0
 public void testLongToInt() {
   IdExpression expression = new IdExpression("l");
   expression.type = LongType.instance;
   Cast cast = new Cast(expression);
   cast.type = IntegerType.instance;
   ExpressionVisitor visitor = new ExpressionVisitor(new SymbolTable());
   assertEquals(cast, visitor.visit(cast));
 }
示例#3
0
 public void testDowncast() {
   SymbolTableForTests table = new SymbolTableForTests();
   table.addClasses("A", "B");
   table.getClass("B").superName = "A";
   Expression expression = new IdExpression("a");
   expression.type = new IdType("A");
   ExpressionVisitor visitor = new ExpressionVisitor(table);
   Cast cast = new Cast(expression);
   cast.type = new IdType("B");
   assertEquals(visitor.visit(cast), cast);
 }