commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From d...@apache.org
Subject cvs commit: jakarta-commons/jexl/src/test/org/apache/commons/jexl JexlTest.java
Date Fri, 20 Aug 2004 12:05:04 GMT
dion        2004/08/20 05:05:04

  Modified:    jexl/src/test/org/apache/commons/jexl JexlTest.java
  Log:
  More coverage for EQ and NE
  
  Revision  Changes    Path
  1.55      +33 -1     jakarta-commons/jexl/src/test/org/apache/commons/jexl/JexlTest.java
  
  Index: JexlTest.java
  ===================================================================
  RCS file: /home/cvs/jakarta-commons/jexl/src/test/org/apache/commons/jexl/JexlTest.java,v
  retrieving revision 1.54
  retrieving revision 1.55
  diff -u -r1.54 -r1.55
  --- JexlTest.java	20 Aug 2004 08:22:20 -0000	1.54
  +++ JexlTest.java	20 Aug 2004 12:05:03 -0000	1.55
  @@ -19,6 +19,7 @@
   import java.util.BitSet;
   import java.util.HashMap;
   import java.util.HashSet;
  +import java.util.LinkedList;
   import java.util.List;
   import java.util.Map;
   import java.util.Collections;
  @@ -380,12 +381,43 @@
       {
           JexlContext jc = JexlHelper.createContext();
           jc.getVars().put("foo", new Integer(2) );
  +        jc.getVars().put("aFloat", new Float(1));
  +        jc.getVars().put("aDouble", new Double(2));
  +        jc.getVars().put("aChar", new Character('A'));
  +        jc.getVars().put("aBool", Boolean.TRUE);
  +        StringBuffer buffer = new StringBuffer("abc");
  +        List list = new ArrayList();
  +        List list2 = new LinkedList();
  +        jc.getVars().put("aBuffer", buffer);
  +        jc.getVars().put("aList", list);
  +        jc.getVars().put("bList", list2);
           
           assertExpression(jc, "foo == 2", Boolean.TRUE);
           assertExpression(jc, "2 == 3", Boolean.FALSE);
           assertExpression(jc, "3 == foo", Boolean.FALSE);
           assertExpression(jc, "3 != foo", Boolean.TRUE);
           assertExpression(jc, "foo != 2", Boolean.FALSE);
  +        // test float and double equality
  +        assertExpression(jc, "aFloat eq aDouble", Boolean.FALSE);
  +        assertExpression(jc, "aFloat ne aDouble", Boolean.TRUE);
  +        assertExpression(jc, "aFloat == aDouble", Boolean.FALSE);
  +        assertExpression(jc, "aFloat != aDouble", Boolean.TRUE);
  +        // test number and character equality
  +        assertExpression(jc, "foo == aChar", Boolean.FALSE);
  +        assertExpression(jc, "foo != aChar", Boolean.TRUE);
  +        // test string and boolean
  +        assertExpression(jc, "aBool == 'true'", Boolean.TRUE);
  +        assertExpression(jc, "aBool == 'false'", Boolean.FALSE);
  +        assertExpression(jc, "aBool != 'false'", Boolean.TRUE);
  +        // test null and boolean
  +        assertExpression(jc, "aBool == notThere", Boolean.FALSE);
  +        assertExpression(jc, "aBool != notThere", Boolean.TRUE);
  +        // anything and string as a string comparison
  +        assertExpression(jc, "aBuffer == 'abc'", Boolean.TRUE);
  +        assertExpression(jc, "aBuffer != 'abc'", Boolean.FALSE);
  +        // arbitrary equals
  +        assertExpression(jc, "aList == bList", Boolean.TRUE);
  +        assertExpression(jc, "aList != bList", Boolean.FALSE);
       }
   
       /**
  
  
  

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


Mime
View raw message