示例#1
0
  private void lessThanTester(int left, int right) {
    LessThan lessThan = new LessThan();
    lessThan.left = new Number(left);
    lessThan.left.type = IntegerType.instance;
    lessThan.right = new Number(right);
    lessThan.right.type = IntegerType.instance;

    expressionSimplificationTester(
        lessThan, left < right ? True.class : False.class, BooleanType.instance, 0, false);
  }
示例#2
0
  /** Simple test that constructs and AST from the ANTLR generated files */
  @Test
  public void lessThan() throws RecognitionException {

    String queryString = "select * where a < 5";

    ANTLRStringStream in = new ANTLRStringStream(queryString);
    QueryFilterLexer lexer = new QueryFilterLexer(in);
    TokenRewriteStream tokens = new TokenRewriteStream(lexer);
    QueryFilterParser parser = new QueryFilterParser(tokens);

    Query query = parser.ql().query;

    Operand root = query.getRootOperand();

    LessThan equal = (LessThan) root;

    assertEquals("a", equal.getProperty().getValue());

    assertEquals(5, ((LongLiteral) equal.getLiteral()).getValue().intValue());

    // TODO Todd fix this.

    queryString = "select * where a lt 5";

    in = new ANTLRStringStream(queryString);
    lexer = new QueryFilterLexer(in);
    tokens = new TokenRewriteStream(lexer);
    parser = new QueryFilterParser(tokens);

    query = parser.ql().query;

    root = query.getRootOperand();

    equal = (LessThan) root;

    assertEquals("a", equal.getProperty().getValue());

    assertEquals(5, ((LongLiteral) equal.getLiteral()).getValue().intValue());
  }
 @Override
 public Boolean visit(LessThan<T> pLessThan, MemoryLocation pVarName) {
   return pLessThan.getOperand1().accept(this, pVarName)
       || pLessThan.getOperand2().accept(this, pVarName);
 }