Package com.googlecode.aviator.lexer

Examples of com.googlecode.aviator.lexer.ExpressionLexer


    }


    @Test(expected = ExpressionSyntaxErrorException.class)
    public void testIllegalExpression6() {
        this.parser = new ExpressionParser(new ExpressionLexer("a!b"), codeGenerator);
        this.parser.parse();
    }
View Full Code Here


    }


    @Test(expected = ExpressionSyntaxErrorException.class)
    public void testParseBlankExpression2() {
        this.parser = new ExpressionParser(new ExpressionLexer("\t "), codeGenerator);
        this.parser.parse();
    }
View Full Code Here

    }


    @Test(expected = ExpressionSyntaxErrorException.class)
    public void testParseBlankExpression3() {
        this.parser = new ExpressionParser(new ExpressionLexer("  "), codeGenerator);
        this.parser.parse();
    }
View Full Code Here

    }


    @Test
    public void testSimpleExpression() {
        this.parser = new ExpressionParser(new ExpressionLexer("1+3"), codeGenerator);
        this.parser.parse();
        assertEquals("1 3 +", this.codeGenerator.getPostFixExpression());

        resetCodeGenerator();
        this.parser = new ExpressionParser(new ExpressionLexer("1+3-2"), codeGenerator);
        this.parser.parse();
        assertEquals("1 3 + 2 -", this.codeGenerator.getPostFixExpression());

        resetCodeGenerator();
        this.parser = new ExpressionParser(new ExpressionLexer("1+3-2/5"), codeGenerator);
        this.parser.parse();
        assertEquals("1 3 + 2 5 / -", this.codeGenerator.getPostFixExpression());

        resetCodeGenerator();
        this.parser = new ExpressionParser(new ExpressionLexer("6==3"), codeGenerator);
        this.parser.parse();
        assertEquals("6 3 ==", this.codeGenerator.getPostFixExpression());

        resetCodeGenerator();
        this.parser = new ExpressionParser(new ExpressionLexer("6>=3 && c==d.a"), codeGenerator);
        this.parser.parse();
        assertEquals("6 3 >= c d.a == &&", this.codeGenerator.getPostFixExpression());

        resetCodeGenerator();
        this.parser = new ExpressionParser(new ExpressionLexer("6>=3 && c==d.a || 0.3<4"), codeGenerator);
        this.parser.parse();
        assertEquals("6 3 >= c d.a == && 0.3 4 < ||", this.codeGenerator.getPostFixExpression());

        resetCodeGenerator();
        this.parser = new ExpressionParser(new ExpressionLexer("!true"), codeGenerator);
        this.parser.parse();
        assertEquals("true !", this.codeGenerator.getPostFixExpression());

        resetCodeGenerator();
        this.parser = new ExpressionParser(new ExpressionLexer("!a && 3==1"), codeGenerator);
        this.parser.parse();
        assertEquals("a ! 3 1 == &&", this.codeGenerator.getPostFixExpression());

        resetCodeGenerator();
        this.parser = new ExpressionParser(new ExpressionLexer("-a+2010"), codeGenerator);
        this.parser.parse();
        assertEquals("a - 2010 +", this.codeGenerator.getPostFixExpression());
    }
View Full Code Here

    }


    @Test
    public void testParseExpression_WithOneParen() {
        this.parser = new ExpressionParser(new ExpressionLexer("(3+1)/5"), codeGenerator);
        this.parser.parse();
        assertEquals("3 1 + 5 /", this.codeGenerator.getPostFixExpression());

        this.codeGenerator.reset();
        this.parser = new ExpressionParser(new ExpressionLexer("3-(5+2)"), codeGenerator);
        this.parser.parse();
        assertEquals("3 5 2 + -", this.codeGenerator.getPostFixExpression());

        resetCodeGenerator();
        this.parser = new ExpressionParser(new ExpressionLexer("6>=3 && (c==d.a || 0.3<4)"), codeGenerator);
        this.parser.parse();
        assertEquals("6 3 >= c d.a == 0.3 4 < || &&", this.codeGenerator.getPostFixExpression());

    }
View Full Code Here


    @Test
    public void testParseExpression_WithManyParens1() {
        this.parser =
                new ExpressionParser(new ExpressionLexer("6.3-((3+1)/5+3.14)*600%(2+3-(6+(4.3-9)))"), codeGenerator);
        this.parser.parse();
        assertEquals("6.3 3 1 + 5 / 3.14 + 600 * 2 3 + 6 4.3 9 - + - % -", this.codeGenerator.getPostFixExpression());
    }
View Full Code Here

    }


    @Test(expected = ExpressionSyntaxErrorException.class)
    public void testParseExpression_WithIllegalParen1() {
        this.parser = new ExpressionParser(new ExpressionLexer("3+4)"), codeGenerator);
        this.parser.parse();
    }
View Full Code Here

    }


    @Test(expected = ExpressionSyntaxErrorException.class)
    public void testParseExpression_WithIllegalParen2() {
        this.parser = new ExpressionParser(new ExpressionLexer("3+4)"), codeGenerator);
        this.parser.parse();
    }
View Full Code Here

    }


    @Test(expected = ExpressionSyntaxErrorException.class)
    public void testParseExpression_IllegalParens3() {
        this.parser = new ExpressionParser(new ExpressionLexer("(((((3+4)))"), codeGenerator);
        this.parser.parse();
    }
View Full Code Here

    }


    @Test(expected = ExpressionSyntaxErrorException.class)
    public void testParseExpression_IllegalParens4() {
        this.parser = new ExpressionParser(new ExpressionLexer("(((((3+4)))+3"), codeGenerator);
        this.parser.parse();
    }
View Full Code Here

TOP

Related Classes of com.googlecode.aviator.lexer.ExpressionLexer

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.