Пример #1
0
  private Expression operationWithConstantValue(
      BinaryExpression binExp,
      java.lang.Class expectedClass,
      Expression constantExp,
      boolean constantOnLeft,
      boolean operationWithSideEffect) {
    Expression exp;
    if (operationWithSideEffect) {
      MethodAccess call = new MethodAccess();
      call.expression = new This();
      exp = call;
    } else {
      exp = new IdExpression();
    }
    exp.type = constantExp.type;
    if (constantOnLeft) {
      binExp.right = exp;
      binExp.left = constantExp;
    } else {
      binExp.left = exp;
      binExp.right = constantExp;
    }
    if (null == expectedClass) expectedClass = MethodAccess.class;

    return expressionSimplificationTester(binExp, expectedClass, constantExp.type, 0, false);
  }
Пример #2
0
  public final void testEvenExpressionNegationSimplification() {
    MethodAccess callExp = new MethodAccess();
    callExp.expression = new This();
    callExp.type = BooleanType.instance;
    Not not1 = new Not(callExp);
    not1.type = BooleanType.instance;
    Not not2 = new Not(not1);
    not2.type = BooleanType.instance;

    expressionSimplificationTester(not2, MethodAccess.class, BooleanType.instance, 0, false);
  }
Пример #3
0
  public final void testOddExpressionNegationSimplification() {
    MethodAccess callExp = new MethodAccess();
    callExp.expression = new This();
    callExp.type = BooleanType.instance;
    Not not1 = new Not(callExp);
    not1.type = BooleanType.instance;
    Not not2 = new Not(not1);
    not2.type = BooleanType.instance;
    Not not3 = new Not(not2);
    not3.type = BooleanType.instance;

    Expression resultExp =
        expressionSimplificationTester(not3, Not.class, BooleanType.instance, 0, false);

    assertEquals(((Not) resultExp).expression.getClass(), MethodAccess.class);
  }