Package org.auraframework.impl.expression

Examples of org.auraframework.impl.expression.LiteralImpl


     * Number literals include integers, decimals, and exponents.
     */
    public void testLiteralNumbers() throws Exception {
        Expression e = buildExpression("5");
        assertEquals("Unexpected expression type", ExpressionType.LITERAL, e.getExpressionType());
        LiteralImpl l = (LiteralImpl) e;
        assertEquals("Unexpected number literal value", 5.0, l.getValue());

        e = buildExpression("5.345");
        assertEquals("Unexpected expression type", ExpressionType.LITERAL, e.getExpressionType());
        l = (LiteralImpl) e;
        assertEquals("Unexpected number literal value", 5.345, l.getValue());

        e = buildExpression("911.");
        assertEquals("Unexpected expression type", ExpressionType.LITERAL, e.getExpressionType());
        l = (LiteralImpl) e;
        assertEquals("Unexpected number literal value", 911., l.getValue());

        e = buildExpression(".119");
        assertEquals("Unexpected expression type", ExpressionType.LITERAL, e.getExpressionType());
        l = (LiteralImpl) e;
        assertEquals("Unexpected number literal value", .119, l.getValue());

        e = buildExpression("1e10");
        assertEquals("Unexpected expression type", ExpressionType.LITERAL, e.getExpressionType());
        l = (LiteralImpl) e;
        assertEquals("Unexpected number literal value", 1e10, l.getValue());

        e = buildExpression("2.e20");
        assertEquals("Unexpected expression type", ExpressionType.LITERAL, e.getExpressionType());
        l = (LiteralImpl) e;
        assertEquals("Unexpected number literal value", 2.e20, l.getValue());

        e = buildExpression("0e0");
        assertEquals("Unexpected expression type", ExpressionType.LITERAL, e.getExpressionType());
        l = (LiteralImpl) e;
        assertEquals("Unexpected number literal value", 0e0, l.getValue());

        e = buildExpression("1e01");
        assertEquals("Unexpected expression type", ExpressionType.LITERAL, e.getExpressionType());
        l = (LiteralImpl) e;
        assertEquals("Unexpected number literal value", 1e01, l.getValue());

        e = buildExpression(".3e3");
        assertEquals("Unexpected expression type", ExpressionType.LITERAL, e.getExpressionType());
        l = (LiteralImpl) e;
        assertEquals("Unexpected number literal value", .3e3, l.getValue());
    }
View Full Code Here


     * String literals require single quotes and may be empty.
     */
    public void testLiteralStrings() throws Exception {
        Expression e = buildExpression("'ahfdh'");
        assertEquals("Unexpected expression type", ExpressionType.LITERAL, e.getExpressionType());
        LiteralImpl l = (LiteralImpl) e;
        assertEquals("ahfdh", l.getValue());

        verifyInvalidExpressionException("\"ahfdh\"", "unexpected token: '\"' at column 1 of expression: \"ahfdh\"");

        e = buildExpression("''");
        assertEquals("Unexpected expression type", ExpressionType.LITERAL, e.getExpressionType());
        l = (LiteralImpl) e;
        assertEquals("", l.getValue());
    }
View Full Code Here

     * Boolean literals are case insensitive.
     */
    public void testLiteralBools() throws Exception {
        Expression e = buildExpression("true");
        assertEquals("Unexpected expression type", ExpressionType.LITERAL, e.getExpressionType());
        LiteralImpl l = (LiteralImpl) e;
        assertTrue("Case sensitivity of Boolean literlas failed", l.getValue());

        e = buildExpression("TRUE");
        assertEquals("Unexpected expression type", ExpressionType.LITERAL, e.getExpressionType());
        l = (LiteralImpl) e;
        assertTrue("Case sensitivity of Boolean literlas failed", l.getValue());

        e = buildExpression("false");
        assertEquals("Unexpected expression type", ExpressionType.LITERAL, e.getExpressionType());
        l = (LiteralImpl) e;
        assertFalse("Case sensitivity of Boolean literlas failed", l.getValue());

        e = buildExpression("FALSE");
        assertEquals("Unexpected expression type", ExpressionType.LITERAL, e.getExpressionType());
        l = (LiteralImpl) e;
        assertFalse("Case sensitivity of Boolean literlas failed", l.getValue());
    }
View Full Code Here

     * Escape sequences in strings are parsed correctly.
     */
    public void testEscapedString() throws Exception {
        Expression e = buildExpression("\t'over there! '\r\n\n");
        assertEquals("Unexpected expression type", ExpressionType.LITERAL, e.getExpressionType());
        LiteralImpl l = (LiteralImpl) e;
        assertEquals("Escape sequences not parsed correctly", "over there! ", l.getValue());

        e = buildExpression(" '\\'stuff me,\\' the unfilled teddy bear said to the child.'");
        assertEquals("Unexpected expression type", ExpressionType.LITERAL, e.getExpressionType());
        l = (LiteralImpl) e;
        assertEquals("Escape sequences not parsed correctly", "'stuff me,' the unfilled teddy bear said to the child.",
                l.getValue());

        e = buildExpression("'the child blinked and replied,\\n \\t\\'I\\'d be delighted.\\''");
        assertEquals("Unexpected expression type", ExpressionType.LITERAL, e.getExpressionType());
        l = (LiteralImpl) e;
        assertEquals("Escape sequences not parsed correctly", "the child blinked and replied,\n \t'I'd be delighted.'",
                l.getValue());

        e = buildExpression("'top\\\\\\\"2\\\"\\b\\f\\r\\n\\tbottom'");
        assertEquals("Unexpected expression type", ExpressionType.LITERAL, e.getExpressionType());
        l = (LiteralImpl) e;
        assertEquals("Escape sequences not parsed correctly", "top\\\"2\"\b\f\r\n\tbottom", l.getValue());
    }
View Full Code Here

     * Unicode escapes in strings are parsed correctly.
     */
    public void testUnicodeEscapesInString() throws Exception {
        Expression e = buildExpression("'\\u0032'");
        assertEquals(ExpressionType.LITERAL, e.getExpressionType());
        LiteralImpl l = (LiteralImpl) e;
        assertEquals("2", l.getValue());

        e = buildExpression("'good\\u0032go'");
        assertEquals(ExpressionType.LITERAL, e.getExpressionType());
        l = (LiteralImpl) e;
        assertEquals("good2go", l.getValue());

        e = buildExpression("'Ocean\\'s \\u0031\\u0031'");
        assertEquals(ExpressionType.LITERAL, e.getExpressionType());
        l = (LiteralImpl) e;
        assertEquals("Ocean's 11", l.getValue());

        e = buildExpression("'\\u0031\\u0032\\u0020Monkeys\\u0020\\u0099'");
        assertEquals(ExpressionType.LITERAL, e.getExpressionType());
        l = (LiteralImpl) e;
        assertEquals("12 Monkeys \u0099", l.getValue());
    }
View Full Code Here

TOP

Related Classes of org.auraframework.impl.expression.LiteralImpl

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.