velocity-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From by...@apache.org
Subject svn commit: r742851 - in /velocity/engine/trunk/src: java/org/apache/velocity/runtime/parser/node/ASTReference.java test/org/apache/velocity/test/IndexTestCase.java test/org/apache/velocity/test/StrictReferenceTestCase.java
Date Tue, 10 Feb 2009 04:59:03 GMT
Author: byron
Date: Tue Feb 10 04:59:02 2009
New Revision: 742851

URL: http://svn.apache.org/viewvc?rev=742851&view=rev
Log:
VELOCITY-688 Change so that 0 syntax causes the exception if the reference is null instead
of $

Modified:
    velocity/engine/trunk/src/java/org/apache/velocity/runtime/parser/node/ASTReference.java
    velocity/engine/trunk/src/test/org/apache/velocity/test/IndexTestCase.java
    velocity/engine/trunk/src/test/org/apache/velocity/test/StrictReferenceTestCase.java

Modified: velocity/engine/trunk/src/java/org/apache/velocity/runtime/parser/node/ASTReference.java
URL: http://svn.apache.org/viewvc/velocity/engine/trunk/src/java/org/apache/velocity/runtime/parser/node/ASTReference.java?rev=742851&r1=742850&r2=742851&view=diff
==============================================================================
--- velocity/engine/trunk/src/java/org/apache/velocity/runtime/parser/node/ASTReference.java
(original)
+++ velocity/engine/trunk/src/java/org/apache/velocity/runtime/parser/node/ASTReference.java
Tue Feb 10 04:59:02 2009
@@ -424,10 +424,8 @@
         {          
             if (strictRef)
             {
-                if (referenceType != QUIET_REFERENCE)
+                if (referenceType == QUIET_REFERENCE)
                 {
-                  log.error("Prepend the reference with '$!' e.g., $!" + literal().substring(1)
-                      + " if you want Velocity to ignore the reference when it evaluates
to null");
                   if (value == null)
                   {
                     throw new VelocityException("Reference " + literal() 

Modified: velocity/engine/trunk/src/test/org/apache/velocity/test/IndexTestCase.java
URL: http://svn.apache.org/viewvc/velocity/engine/trunk/src/test/org/apache/velocity/test/IndexTestCase.java?rev=742851&r1=742850&r2=742851&view=diff
==============================================================================
--- velocity/engine/trunk/src/test/org/apache/velocity/test/IndexTestCase.java (original)
+++ velocity/engine/trunk/src/test/org/apache/velocity/test/IndexTestCase.java Tue Feb 10
04:59:02 2009
@@ -29,7 +29,6 @@
     public IndexTestCase(String name)
     {
         super(name);
-        //DEBUG = true;
     }
 
     public void setUp() throws Exception
@@ -92,7 +91,7 @@
         assertEvalEquals("GOT NULL", "#set($i=$NULL)$boo[$i]");
         
         assertEvalEquals("321", "$a[-1]$a[ -2]$a[-3 ]");
-        assertEvalEquals("67xx", "#set($hash={1:11, 5:67, 23:2})$hash[5]$!hash[6]#if(!$hash[1000])xx#end");
+        assertEvalEquals("67xx", "#set($hash={1:11, 5:67, 23:2})$hash[5]$hash[6]#if(!$hash[1000])xx#end");
         
         // Some cases that should be evaluated as text
         assertEvalEquals("[]", "[]");

Modified: velocity/engine/trunk/src/test/org/apache/velocity/test/StrictReferenceTestCase.java
URL: http://svn.apache.org/viewvc/velocity/engine/trunk/src/test/org/apache/velocity/test/StrictReferenceTestCase.java?rev=742851&r1=742850&r2=742851&view=diff
==============================================================================
--- velocity/engine/trunk/src/test/org/apache/velocity/test/StrictReferenceTestCase.java (original)
+++ velocity/engine/trunk/src/test/org/apache/velocity/test/StrictReferenceTestCase.java Tue
Feb 10 04:59:02 2009
@@ -76,7 +76,7 @@
     public void testAllowNullValues()
         throws Exception
     {
-        evaluate("$!bar");
+        evaluate("$bar");
         assertEvalEquals("true", "#if($bar == $NULL)true#end");
         assertEvalEquals("true", "#set($foobar = $NULL)#if($foobar == $NULL)true#end");
         assertEvalEquals("13", "#set($list = [1, $NULL, 3])#foreach($item in $list)#if($item
!= $NULL)$item#end#end");
@@ -119,7 +119,7 @@
 
         // Mainly want to make sure no exceptions are thrown here
         assertEvalEquals("propiness", "$fargo.prop");
-        assertEvalEquals("", "$!fargo.nullVal");
+        assertEvalEquals("", "$fargo.nullVal");
         assertEvalEquals("propiness", "$fargo.next.prop");
 
         assertMethodEx("$fargo.foobar");
@@ -152,8 +152,8 @@
         assertVelocityEx("#set($fargo.prop = $NULL)$fargo.prop.next");
 
         // make sure no exceptions are thrown here
-        evaluate("$!fargo.next.next");
-        evaluate("$!fargo.next.nullVal");
+        evaluate("$fargo.next.next");
+        evaluate("$fargo.next.nullVal");
         evaluate("#foreach($item in $fargo.nullVal)#end");
     }
 
@@ -181,14 +181,14 @@
         fargo.next = new Fargo();
         context.put("fargo", fargo);      
       
-        assertVelocityEx("#set($foo = $NULL)$foo");
-        assertEvalEquals("", "#set($foo = $NULL)$!foo");
-        assertVelocityEx("$fargo.nullVal");
-        assertEvalEquals("", "$!fargo.nullVal");
-        assertVelocityEx("$fargo.next.next");
-        assertEvalEquals("", "$!fargo.next.next");
-        assertVelocityEx("$fargo.next.nullVal");
-        assertEvalEquals("", "$!fargo.next.nullVal");
+        assertVelocityEx("#set($foo = $NULL)$!foo");
+        assertEvalEquals("", "#set($foo = $NULL)$foo");
+        assertVelocityEx("$!fargo.nullVal");
+        assertEvalEquals("", "$fargo.nullVal");
+        assertVelocityEx("$!fargo.next.next");
+        assertEvalEquals("", "$fargo.next.next");
+        assertVelocityEx("$!fargo.next.nullVal");
+        assertEvalEquals("", "$fargo.next.nullVal");
     }
     
     /**



Mime
View raw message