You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@commons.apache.org by ge...@apache.org on 2003/02/09 21:20:08 UTC
cvs commit: jakarta-commons/jexl/src/test/org/apache/commons/jexl JexlTest.java
geirm 2003/02/09 12:20:08
Modified: jexl/src/test/org/apache/commons/jexl JexlTest.java
Log:
added % and /
Revision Changes Path
1.26 +43 -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.25
retrieving revision 1.26
diff -u -r1.25 -r1.26
--- JexlTest.java 16 Dec 2002 10:42:26 -0000 1.25
+++ JexlTest.java 9 Feb 2003 20:20:08 -0000 1.26
@@ -510,6 +510,35 @@
e = ExpressionFactory.createExpression("3 * 3.0");
o = e.evaluate(jc);
assertEquals("o incorrect", new Double(9), o );
+
+ /*
+ * test / and %
+ */
+
+ e = ExpressionFactory.createExpression("6 / 3");
+ o = e.evaluate(jc);
+ assertEquals("o incorrect", new Double(6/3), o);
+
+ e = ExpressionFactory.createExpression("6.4 / 3");
+ o = e.evaluate(jc);
+ assertEquals("o incorrect", new Double(6.4 / 3), o);
+
+ e = ExpressionFactory.createExpression("0 / 3");
+ o = e.evaluate(jc);
+ assertEquals("o incorrect", new Double(0 / 3), o);
+
+ e = ExpressionFactory.createExpression("3 / 0");
+ o = e.evaluate(jc);
+ assertEquals("o incorrect", new Double(0), o);
+
+ e = ExpressionFactory.createExpression("4 % 3");
+ o = e.evaluate(jc);
+ assertEquals("o incorrect", new Long(1), o);
+
+ e = ExpressionFactory.createExpression("4.8 % 3");
+ o = e.evaluate(jc);
+ assertEquals("o incorrect", new Double(4.8 % 3), o);
+
}
/**
@@ -1036,4 +1065,17 @@
Object actual = e.evaluate(jc);
assertEquals(expression, expected, actual);
}
+
+
+ /**
+ * Helps in debugging the testcases when working with it
+ *
+ */
+ public static void main(String[] args)
+ throws Exception
+ {
+ JexlTest jt = new JexlTest("foo");
+ jt.testCalculations();
+ }
+
}
---------------------------------------------------------------------
To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-dev-help@jakarta.apache.org