commons-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Ben Walding <default0...@walding.com>
Subject [jexl] "size" is a magic reserved word?
Date Mon, 07 Apr 2003 12:31:37 GMT
Is there any good reason why the following test case (that I made up) 
should fail

    /**
      *  test a simple size() expression
      */
    public void testSize() throws Exception
    {
        /*
         *  tests a simple size expression
         */

        Expression e = ExpressionFactory.createExpression("foo.size()");
        JexlContext jc = JexlHelper.createContext();

        jc.getVars().put("foo", new ArrayList());

        Object o = e.evaluate(jc);

        assertTrue("o instanceof Integer", o instanceof Integer);
        assertEquals("o", new Integer(0), (Integer) o);
    }




Exception thrown:

org.apache.commons.jexl.parser.ParseException: Encountered ". size" at 
line 1, column 4.
Was expecting one of:
    "||" ...
    "or" ...
    "&&" ...
    "and" ...
    "|" ...
    "^" ...
    "&" ...
    "==" ...
    "eq" ...
    "!=" ...
    "ne" ...
    "<" ...
    "lt" ...
    ">" ...
    "gt" ...
    "<=" ...
    "le" ...
    ">=" ...
    "ge" ...
    "+" ...
    "-" ...
    "*" ...
    "/" ...
    "div" ...
    "%" ...
    "mod" ...
    ";" ...
    "[" ...
    "." <IDENTIFIER> ...
    "." <INTEGER_LITERAL> ...
    "=" ...
   
    at 
org.apache.commons.jexl.parser.Parser.generateParseException(Parser.java:3193)
    at 
org.apache.commons.jexl.parser.Parser.jj_consume_token(Parser.java:3077)
    at 
org.apache.commons.jexl.parser.Parser.ExpressionExpression(Parser.java:1519)
    at org.apache.commons.jexl.parser.Parser.Statement(Parser.java:1492)
    at org.apache.commons.jexl.parser.Parser.JexlScript(Parser.java:58)
    at org.apache.commons.jexl.parser.Parser.parse(Parser.java:18)
    at 
org.apache.commons.jexl.ExpressionFactory.createNewExpression(ExpressionFactory.java:123)
    at 
org.apache.commons.jexl.ExpressionFactory.createExpression(ExpressionFactory.java:87)
    at org.apache.commons.jexl.JexlSizeTest.testMethod(JexlSizeTest.java:28)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at 
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
    at 
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
    at java.lang.reflect.Method.invoke(Method.java:324)
    at junit.framework.TestCase.runTest(TestCase.java:154)
    at junit.framework.TestCase.runBare(TestCase.java:127)
    at junit.framework.TestResult$1.protect(TestResult.java:106)
    at junit.framework.TestResult.runProtected(TestResult.java:124)
    at junit.framework.TestResult.run(TestResult.java:109)
    at junit.framework.TestCase.run(TestCase.java:118)
    at junit.framework.TestSuite.runTest(TestSuite.java:208)
    at junit.framework.TestSuite.run(TestSuite.java:203)
    at 
org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:392)
    at 
org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:276)
    at 
org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:167)




Cheers,

Ben


Mime
View raw message