You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@velocity.apache.org by nb...@apache.org on 2008/08/20 00:16:40 UTC

svn commit: r687184 - in /velocity/engine/trunk/src: java/org/apache/velocity/runtime/parser/node/ASTAndNode.java test/org/apache/velocity/test/IfNullTestCase.java

Author: nbubna
Date: Tue Aug 19 15:16:39 2008
New Revision: 687184

URL: http://svn.apache.org/viewvc?rev=687184&view=rev
Log:
more #if null tests and remove unnecessary error

Modified:
    velocity/engine/trunk/src/java/org/apache/velocity/runtime/parser/node/ASTAndNode.java
    velocity/engine/trunk/src/test/org/apache/velocity/test/IfNullTestCase.java

Modified: velocity/engine/trunk/src/java/org/apache/velocity/runtime/parser/node/ASTAndNode.java
URL: http://svn.apache.org/viewvc/velocity/engine/trunk/src/java/org/apache/velocity/runtime/parser/node/ASTAndNode.java?rev=687184&r1=687183&r2=687184&view=diff
==============================================================================
--- velocity/engine/trunk/src/java/org/apache/velocity/runtime/parser/node/ASTAndNode.java (original)
+++ velocity/engine/trunk/src/java/org/apache/velocity/runtime/parser/node/ASTAndNode.java Tue Aug 19 15:16:39 2008
@@ -90,15 +90,10 @@
         Node right = jjtGetChild(1);
 
         /*
-         *  if either is null, lets log and bail
+         * null == false
          */
-
         if (left == null || right == null)
         {
-            log.error((left == null ? "Left" : "Right") + " side of '&&' operation is null."
-                           + " Operation not possible. "
-                           + context.getCurrentTemplateName() + " [line " + getLine()
-                           + ", column " + getColumn() + "]");
             return false;
         }
 

Modified: velocity/engine/trunk/src/test/org/apache/velocity/test/IfNullTestCase.java
URL: http://svn.apache.org/viewvc/velocity/engine/trunk/src/test/org/apache/velocity/test/IfNullTestCase.java?rev=687184&r1=687183&r2=687184&view=diff
==============================================================================
--- velocity/engine/trunk/src/test/org/apache/velocity/test/IfNullTestCase.java (original)
+++ velocity/engine/trunk/src/test/org/apache/velocity/test/IfNullTestCase.java Tue Aug 19 15:16:39 2008
@@ -73,6 +73,22 @@
         assertEvalEquals("foo", "#if( !$nullToString )foo#{else}bar#end");
     }
 
+    public void testIfAnd()
+    {
+        assertEvalEquals("bar", "#if( $null && $nullToString )foo#{else}bar#end");
+        assertEvalEquals("bar", "#if( $nullToString && $null )foo#{else}bar#end");
+        assertEvalEquals("bar", "#if( $null && $notnull )foo#{else}bar#end");
+        assertEvalEquals("bar", "#if( $notnull && $nullToString )foo#{else}bar#end");
+    }
+
+    public void testIfOr()
+    {
+        assertEvalEquals("bar", "#if( $null || $nullToString )foo#{else}bar#end");
+        assertEvalEquals("bar", "#if( $nullToString || $null )foo#{else}bar#end");
+        assertEvalEquals("foo", "#if( $null || $notnull )foo#{else}bar#end");
+        assertEvalEquals("foo", "#if( $notnull || $nullToString )foo#{else}bar#end");
+    }
+
     public static class NullToString
     {
         public String toString()