velocity-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From cbris...@apache.org
Subject svn commit: r1872211 - in /velocity/engine/trunk/velocity-engine-core/src: main/java/org/apache/velocity/runtime/directive/VelocimacroProxy.java test/java/org/apache/velocity/test/issues/Velocity904TestCase.java
Date Wed, 01 Jan 2020 21:27:25 GMT
Author: cbrisson
Date: Wed Jan  1 21:27:25 2020
New Revision: 1872211

URL: http://svn.apache.org/viewvc?rev=1872211&view=rev
Log:
[engine] Fix another VELOCITY-904 regression

Modified:
    velocity/engine/trunk/velocity-engine-core/src/main/java/org/apache/velocity/runtime/directive/VelocimacroProxy.java
    velocity/engine/trunk/velocity-engine-core/src/test/java/org/apache/velocity/test/issues/Velocity904TestCase.java

Modified: velocity/engine/trunk/velocity-engine-core/src/main/java/org/apache/velocity/runtime/directive/VelocimacroProxy.java
URL: http://svn.apache.org/viewvc/velocity/engine/trunk/velocity-engine-core/src/main/java/org/apache/velocity/runtime/directive/VelocimacroProxy.java?rev=1872211&r1=1872210&r2=1872211&view=diff
==============================================================================
--- velocity/engine/trunk/velocity-engine-core/src/main/java/org/apache/velocity/runtime/directive/VelocimacroProxy.java
(original)
+++ velocity/engine/trunk/velocity-engine-core/src/main/java/org/apache/velocity/runtime/directive/VelocimacroProxy.java
Wed Jan  1 21:27:25 2020
@@ -418,7 +418,7 @@ public class VelocimacroProxy extends Di
                     context.put(literalArgArray[i], literalsStack);
                 }
                 /* Reflects the strange 1.7 behavor... */
-                if (argNode instanceof ASTReference || argNode instanceof ASTStringLiteral
|| argNode instanceof ASTObjectArray || argNode instanceof ASTMap)
+                if (argNode instanceof ASTReference || argNode instanceof ASTStringLiteral)
                 {
                     literalsStack.addFirst(argNode.literal());
                 }

Modified: velocity/engine/trunk/velocity-engine-core/src/test/java/org/apache/velocity/test/issues/Velocity904TestCase.java
URL: http://svn.apache.org/viewvc/velocity/engine/trunk/velocity-engine-core/src/test/java/org/apache/velocity/test/issues/Velocity904TestCase.java?rev=1872211&r1=1872210&r2=1872211&view=diff
==============================================================================
--- velocity/engine/trunk/velocity-engine-core/src/test/java/org/apache/velocity/test/issues/Velocity904TestCase.java
(original)
+++ velocity/engine/trunk/velocity-engine-core/src/test/java/org/apache/velocity/test/issues/Velocity904TestCase.java
Wed Jan  1 21:27:25 2020
@@ -93,4 +93,23 @@ public class Velocity904TestCase extends
         assertEvalEquals("$input", "#macro(mymacro $input)#set($input = $null)$input#end#mymacro(true)");
         assertEvalEquals("$input", "#macro(mymacro $input)#set($input = $null)$input#end#mymacro(4.5)");
     }
+
+    public void testConstantNoPreserve()
+    {
+        assertEvalEquals("true", "#macro(mymacro $input)$input#end#mymacro(true)");
+        assertEvalEquals("1.5", "#macro(mymacro $input)$input#end#mymacro(1.5)");
+        assertEvalEquals("foo", "#macro(mymacro $input)$input#end#mymacro('foo')");
+        assertEvalEquals("{}", "#macro(mymacro $input)$input#end#mymacro({})");
+        assertEvalEquals("[]", "#macro(mymacro $input)$input#end#mymacro([])");
+    }
+
+    public void testConstantPreserve()
+    {
+        assertEvalEquals("true", "#macro(mymacro $input)$input#end#mymacro(true)");
+        assertEvalEquals("1.5", "#macro(mymacro $input)$input#end#mymacro(1.5)");
+        assertEvalEquals("foo", "#macro(mymacro $input)$input#end#mymacro('foo')");
+        assertEvalEquals("{}", "#macro(mymacro $input)$input#end#mymacro({})");
+        assertEvalEquals("[]", "#macro(mymacro $input)$input#end#mymacro([])");
+    }
+
 }



Mime
View raw message