You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@commons.apache.org by js...@apache.org on 2002/08/09 13:46:49 UTC

cvs commit: jakarta-commons-sandbox/jexl/src/test/org/apache/commons/jexl JexlTest.java

jstrachan    2002/08/09 04:46:49

  Modified:    jexl/src/test/org/apache/commons/jexl JexlTest.java
  Log:
  added a bunch of test cases for the ! not operator. Mostly they seem to work fine, except the codebase doesn't seem to correctly detect boolean bean properties. so foo.simple should map to foo.isSimple()
  
  Revision  Changes    Path
  1.15      +55 -1     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.14
  retrieving revision 1.15
  diff -u -r1.14 -r1.15
  --- JexlTest.java	8 Jul 2002 13:47:51 -0000	1.14
  +++ JexlTest.java	9 Aug 2002 11:46:49 -0000	1.15
  @@ -540,6 +540,55 @@
       }
   
       /**
  +      *  test some simple conditions
  +      */
  +    public void testNotConditions()
  +         throws Exception
  +    {
  +        Expression e = ExpressionFactory.createExpression("!x");
  +        JexlContext jc = JexlHelper.createContext();
  +
  +        Foo foo = new Foo();
  +        jc.getVars().put("x", Boolean.TRUE );
  +        jc.getVars().put("foo", foo );
  +        jc.getVars().put("bar", "true" );
  +        Object o = e.evaluate(jc);
  +
  +        assertTrue("o not instanceof Boolean", o instanceof Boolean);
  +        assertEquals("o incorrect", Boolean.FALSE, o);
  +
  +        e = ExpressionFactory.createExpression("x");
  +        o = e.evaluate(jc);
  +
  +        assertEquals("o incorrect", Boolean.TRUE, o );
  +
  +        e = ExpressionFactory.createExpression("!bar");
  +        o = e.evaluate(jc);
  +
  +        assertEquals("o incorrect", Boolean.FALSE, o );
  +
  +        e = ExpressionFactory.createExpression("!foo.isSimple()");
  +        o = e.evaluate(jc);
  +
  +        assertEquals("o incorrect", Boolean.FALSE, o );
  +        
  +        e = ExpressionFactory.createExpression("foo.isSimple()");
  +        o = e.evaluate(jc);
  +
  +        assertEquals("o incorrect", Boolean.TRUE, o );
  +        
  +        e = ExpressionFactory.createExpression("!foo.simple");
  +        o = e.evaluate(jc);
  +
  +        assertEquals("o incorrect", Boolean.FALSE, o );
  +        
  +        e = ExpressionFactory.createExpression("foo.simple");
  +        o = e.evaluate(jc);
  +
  +        assertEquals("o incorrect", Boolean.TRUE, o );
  +    }
  +
  +    /**
         *  test some null conditions
         */
       public void testNull()
  @@ -844,6 +893,11 @@
           public String[][] getArray2()
           {
               return GET_METHOD_ARRAY2;
  +        }
  +        
  +        public boolean isSimple() 
  +        {
  +            return true;
           }
       }
   
  
  
  

--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>