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)); }
public void testConcatCantOptimize() { IdExpression id = new IdExpression("a"); id.type = new IdType("A"); Text text = new Text("a"); text.type = TextType.instance; Plus plus = new Plus(text, id); plus.type = TextType.instance; ExpressionVisitor expressionVisitor = new ExpressionVisitor(new SymbolTable()); Expression expression = expressionVisitor.visit(plus); assertTrue(expression instanceof Concat); Concat concat = (Concat) expression; assertEquals(text, concat.left); assertEquals(id, concat.right); }
private void multiplyWithOne(boolean oneOnLeft) { Times t = new Times(); t.type = IntegerType.instance; IdExpression id = new IdExpression("mult"); id.type = IntegerType.instance; if (oneOnLeft) { t.left = new Number(1); t.right = id; } else { t.right = new Number(1); t.left = id; } IdExpression idExp = (IdExpression) expressionSimplificationTester(t, IdExpression.class, IntegerType.instance, 0, false); assertEquals(idExp.id, id.id); }