commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jstrac...@apache.org
Subject cvs commit: jakarta-commons-sandbox/jexl/src/test/org/apache/commons/jexl JexlTest.java
Date Thu, 10 Oct 2002 15:44:23 GMT
jstrachan    2002/10/10 08:44:23

  Modified:    jexl/src/test/org/apache/commons/jexl JexlTest.java
  Log:
  Fixed a glaring bug I'd introduced into the unit test case by a bad cut and paste :-).
  
  the tests now demonstrate 3 main bugs in Jexl
  
  * .size() doesn't work in an expression
  * x.foo(-3) doesn't work - the '-' confuses the parser
  * we need support for variable name resolution, inside expressions
  
  Revision  Changes    Path
  1.21      +13 -38    jakarta-commons-sandbox/jexl/src/test/org/apache/commons/jexl/JexlTest.java
  
  Index: JexlTest.java
  ===================================================================
  RCS file: /home/cvs/jakarta-commons-sandbox/jexl/src/test/org/apache/commons/jexl/JexlTest.java,v
  retrieving revision 1.20
  retrieving revision 1.21
  diff -u -r1.20 -r1.21
  --- JexlTest.java	10 Oct 2002 14:19:16 -0000	1.20
  +++ JexlTest.java	10 Oct 2002 15:44:23 -0000	1.21
  @@ -671,38 +671,13 @@
           assertTrue("o not instanceof Boolean", o instanceof Boolean);
           assertEquals("o incorrect", Boolean.TRUE, o);
   
  -        /*
  -         * also support the functional syntax extension
  -         */
  -        e = ExpressionFactory.createExpression("empty(foo)");
  -        o = e.evaluate(jc);
  -
  -        assertTrue("o not instanceof Boolean", o instanceof Boolean);
  -        assertEquals("o incorrect", Boolean.TRUE, o);
  -
  -        e = ExpressionFactory.createExpression("bar == null");
  -        o = e.evaluate(jc);
  -
  -        assertTrue("o not instanceof Boolean", o instanceof Boolean);
  -        assertEquals("o incorrect", Boolean.FALSE, o );
  -
  -        e = ExpressionFactory.createExpression("bar != null");
  -        o = e.evaluate(jc);
  -
  -        assertTrue("o not instanceof Boolean", o instanceof Boolean);
  -        assertEquals("o incorrect", Boolean.TRUE, o );
  -
  -        e = ExpressionFactory.createExpression("foo != null");
  -        o = e.evaluate(jc);
  -
  -        assertTrue("o not instanceof Boolean", o instanceof Boolean);
  -        assertEquals("o incorrect", Boolean.FALSE, o);
  -
  -        e = ExpressionFactory.createExpression("foo == null");
  -        o = e.evaluate(jc);
  -
  -        assertTrue("o not instanceof Boolean", o instanceof Boolean);
  -        assertEquals("o incorrect", Boolean.TRUE, o);
  +        assertExpression(jc, "empty foo", Boolean.TRUE);
  +        assertExpression(jc, "bar == null", Boolean.FALSE);
  +        assertExpression(jc, "foo == null", Boolean.TRUE);
  +        assertExpression(jc, "bar != null", Boolean.TRUE);
  +        assertExpression(jc, "foo != null", Boolean.FALSE);
  +        assertExpression(jc, "empty(bar)", Boolean.FALSE);
  +        assertExpression(jc, "empty(foo)", Boolean.TRUE);
       }
   
       /**
  @@ -818,9 +793,9 @@
   
           assertEquals("o incorrect", new Integer(5), o);
           
  -        assertExpression(jc, "foo.square(-2)", new Integer(4));
           assertExpression(jc, "foo.square(2)", new Integer(4));
  -    }
  +        assertExpression(jc, "foo.square(-2)", new Integer(4));
  +   }
   
       public void testArrayProperty()
           throws Exception
  @@ -873,8 +848,8 @@
   
           jc.getVars().put("foo", "abcdef");
   
  -        assertExpression(jc, "foo.substring(2,3)", "cd");
  -        assertExpression(jc, "foo.charAt(2)", new Character('b'));
  +        assertExpression(jc, "foo.substring(2,4)", "cd");
  +        assertExpression(jc, "foo.charAt(2)", new Character('c'));
        
           try {
               assertExpression(jc, "foo.charAt(-2)", null);
  @@ -1008,7 +983,7 @@
        */
       protected void assertExpression(JexlContext jc, String expression, Object expected)
throws Exception 
       {
  -        Expression e = ExpressionFactory.createExpression("array.length");
  +        Expression e = ExpressionFactory.createExpression(expression);
           Object actual = e.evaluate(jc);
           assertEquals(expression, expected, actual);
       }
  
  
  

--
To unsubscribe, e-mail:   <mailto:commons-dev-unsubscribe@jakarta.apache.org>
For additional commands, e-mail: <mailto:commons-dev-help@jakarta.apache.org>


Mime
View raw message