Author: rahul
Date: Mon Feb 27 14:53:08 2006
New Revision: 381474

URL: http://svn.apache.org/viewcvs?rev=381474&view=rev
Log:
More block tests that:
1) Ensure value is the last *executed* statement
2) Flesh out the relationship between an expression and a block (will post on 
this in a bit)

Modified:
    
jakarta/commons/proper/jexl/trunk/src/test/org/apache/commons/jexl/BlockTest.java

Modified: 
jakarta/commons/proper/jexl/trunk/src/test/org/apache/commons/jexl/BlockTest.java
URL: 
http://svn.apache.org/viewcvs/jakarta/commons/proper/jexl/trunk/src/test/org/apache/commons/jexl/BlockTest.java?rev=381474&r1=381473&r2=381474&view=diff
==============================================================================
--- 
jakarta/commons/proper/jexl/trunk/src/test/org/apache/commons/jexl/BlockTest.java
 (original)
+++ 
jakarta/commons/proper/jexl/trunk/src/test/org/apache/commons/jexl/BlockTest.java
 Mon Feb 27 14:53:08 2006
@@ -53,4 +53,48 @@
         Object o = e.evaluate(jc);
         assertNull("Result is wrong", o);
     }
+
+    public void testBlockLastExecuted01() throws Exception {
+        Expression e = ExpressionFactory
+                .createExpression("if (true) { x = 1; } else { x = 2; }");
+        JexlContext jc = JexlHelper.createContext();
+        Object o = e.evaluate(jc);
+        assertEquals("Block result is wrong", new Integer(1), o);
+    }
+
+    public void testBlockLastExecuted02() throws Exception {
+        Expression e = ExpressionFactory
+                .createExpression("if (false) { x = 1; } else { x = 2; }");
+        JexlContext jc = JexlHelper.createContext();
+        Object o = e.evaluate(jc);
+        assertEquals("Block result is wrong", new Integer(2), o);
+    }
+
+    public void testNestedBlock() throws Exception {
+        Expression e = ExpressionFactory
+                .createExpression("if (true) { x = 'hello'; y = 'world';"
+                    + " if (true) { x; } y; }");
+        JexlContext jc = JexlHelper.createContext();
+        Object o = e.evaluate(jc);
+        assertEquals("Block result is wrong", "world", o);
+    }
+
+    /* Need to flesh out block <-> expression relationship?
+    public void testBlockPlusStatements() throws Exception {
+        Expression e = ExpressionFactory
+                .createExpression("if (true) { x = 1; } y = 2; ");
+        JexlContext jc = JexlHelper.createContext();
+        Object o = e.evaluate(jc);
+        assertEquals("Block result is wrong", new Integer(2), o);
+    }
+
+    public void testMultipleBlocks() throws Exception {
+        Expression e = ExpressionFactory
+                .createExpression("if (true) { x = 1; } if (true) { y = 2;}");
+        JexlContext jc = JexlHelper.createContext();
+        Object o = e.evaluate(jc);
+        assertEquals("Block result is wrong", new Integer(2), o);
+    }
+    */
+
 }



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

Reply via email to