jstrachan    02/05/17 00:53:47

  Modified:    jexl/src/test/org/apache/commons/jexl JexlTest.java
  Log:
  Added some more unit tests to test the use of calculations; it seems multiplication 
isn't working yet.
  
  Revision  Changes    Path
  1.2       +37 -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.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- JexlTest.java     26 Apr 2002 04:45:28 -0000      1.1
  +++ JexlTest.java     17 May 2002 07:53:47 -0000      1.2
  @@ -71,7 +71,7 @@
    *  Simple testcases
    *
    *  @author <a href="mailto:[EMAIL PROTECTED]";>Geir Magnusson Jr.</a>
  - *  @version $Id: JexlTest.java,v 1.1 2002/04/26 04:45:28 geirm Exp $
  + *  @version $Id: JexlTest.java,v 1.2 2002/05/17 07:53:47 jstrachan Exp $
    */
   public class JexlTest extends TestCase
   {
  @@ -423,6 +423,42 @@
       }
   
   
  +
  +    /**
  +      *  test some simple mathematical calculations
  +      */
  +    public void testCalculations()
  +         throws Exception
  +    {
  +        Expression e = ExpressionFactory.createExpression("foo + 2");
  +        JexlContext jc = JexlHelper.createContext();
  +
  +        jc.getVars().put("foo", new Integer(2) );
  +        Object o = e.evaluate(jc);
  +
  +        assertTrue("o not instanceof Integer", o instanceof Integer);
  +        assertEquals("o incorrect", o, new Integer(4));
  +        
  +        e = ExpressionFactory.createExpression("3 + 3");
  +        o = e.evaluate(jc);
  +        
  +        assertEquals("o incorrect", new Integer(6), o );
  +        
  +        e = ExpressionFactory.createExpression("3 + 3 + foo");
  +        o = e.evaluate(jc);
  +        
  +        assertEquals("o incorrect", new Integer(8), o );
  +        
  +        e = ExpressionFactory.createExpression("3 * 3");
  +        o = e.evaluate(jc);
  +        
  +        assertEquals("o incorrect", new Integer(9), o );
  +        
  +        e = ExpressionFactory.createExpression("3 * 3 + foo");
  +        o = e.evaluate(jc);
  +        
  +        assertEquals("o incorrect", new Integer(11), o );
  +    }
   
       public class Foo
       {
  
  
  

--
To unsubscribe, e-mail:   <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>

Reply via email to