You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@commons.apache.org by di...@apache.org on 2006/02/27 01:37:54 UTC
svn commit: r381209 -
/jakarta/commons/proper/jexl/trunk/src/test/org/apache/commons/jexl/IfTest.java
Author: dion
Date: Sun Feb 26 16:37:52 2006
New Revision: 381209
URL: http://svn.apache.org/viewcvs?rev=381209&view=rev
Log:
Comments on tests
Modified:
jakarta/commons/proper/jexl/trunk/src/test/org/apache/commons/jexl/IfTest.java
Modified: jakarta/commons/proper/jexl/trunk/src/test/org/apache/commons/jexl/IfTest.java
URL: http://svn.apache.org/viewcvs/jakarta/commons/proper/jexl/trunk/src/test/org/apache/commons/jexl/IfTest.java?rev=381209&r1=381208&r2=381209&view=diff
==============================================================================
--- jakarta/commons/proper/jexl/trunk/src/test/org/apache/commons/jexl/IfTest.java (original)
+++ jakarta/commons/proper/jexl/trunk/src/test/org/apache/commons/jexl/IfTest.java Sun Feb 26 16:37:52 2006
@@ -28,7 +28,11 @@
public IfTest(String testName) {
super(testName);
}
-
+
+ /**
+ * Make sure if true executes the true statement
+ * @throws Exception on any error
+ */
public void testSimpleIfTrue() throws Exception
{
Expression e = ExpressionFactory.createExpression("if (true) 1");
@@ -40,6 +44,10 @@
assertEquals("Result is not 1", Integer.valueOf(1), o);
}
+ /**
+ * Make sure if false doesn't execute the true statement
+ * @throws Exception on any error
+ */
public void testSimpleIfFalse() throws Exception
{
Expression e = ExpressionFactory.createExpression("if (false) 1");
@@ -49,6 +57,10 @@
assertNull("Return value is not empty", o);
}
+ /**
+ * Make sure if false executes the false statement
+ * @throws Exception on any error
+ */
public void testSimpleElse() throws Exception
{
Expression e = ExpressionFactory.createExpression("if (false) 1; else 2;");
@@ -58,5 +70,31 @@
assertNotNull("Return value is empty", o);
assertTrue("Result is not an integer", o instanceof Integer);
assertEquals("Result is not 2", Integer.valueOf(2), o);
+ }
+
+ /**
+ * Test the if statement handles blocks correctly
+ * @throws Exception on any error
+ */
+ public void testBlockIfTrue() throws Exception
+ {
+ Expression e = ExpressionFactory.createExpression("if (true) { 'hello'; }");
+ JexlContext jc = JexlHelper.createContext();
+
+ Object o = e.evaluate(jc);
+ assertNull("Return value is not empty", o);
+ }
+
+ /**
+ * Test the if statement handles blocks in the else statement correctly
+ * @throws Exception on any error
+ */
+ public void testBlockElse() throws Exception
+ {
+ Expression e = ExpressionFactory.createExpression("if (false) {1;} else {2;}");
+ JexlContext jc = JexlHelper.createContext();
+
+ Object o = e.evaluate(jc);
+ assertNull("Return value is not empty", o);
}
}
---------------------------------------------------------------------
To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-dev-help@jakarta.apache.org