You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@velocity.apache.org by cb...@apache.org on 2020/01/23 16:51:09 UTC
svn commit: r1873069 - in /velocity/engine/trunk/velocity-engine-core/src:
main/java/org/apache/velocity/runtime/directive/VelocimacroProxy.java
test/java/org/apache/velocity/test/issues/Velocity926TestCase.java
Author: cbrisson
Date: Thu Jan 23 16:51:09 2020
New Revision: 1873069
URL: http://svn.apache.org/viewvc?rev=1873069&view=rev
Log:
[engine] Fix VELOCITY-926
Added:
velocity/engine/trunk/velocity-engine-core/src/test/java/org/apache/velocity/test/issues/Velocity926TestCase.java
- copied, changed from r1872422, velocity/engine/trunk/velocity-engine-core/src/test/java/org/apache/velocity/test/issues/Velocity924TestCase.java
Modified:
velocity/engine/trunk/velocity-engine-core/src/main/java/org/apache/velocity/runtime/directive/VelocimacroProxy.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=1873069&r1=1873068&r2=1873069&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 Thu Jan 23 16:51:09 2020
@@ -26,8 +26,6 @@ import org.apache.velocity.runtime.Rende
import org.apache.velocity.runtime.RuntimeConstants;
import org.apache.velocity.runtime.RuntimeServices;
import org.apache.velocity.runtime.directive.Macro.MacroArg;
-import org.apache.velocity.runtime.parser.node.ASTMap;
-import org.apache.velocity.runtime.parser.node.ASTObjectArray;
import org.apache.velocity.runtime.parser.node.ASTReference;
import org.apache.velocity.runtime.parser.node.ASTStringLiteral;
import org.apache.velocity.runtime.parser.node.Node;
@@ -402,7 +400,6 @@ public class VelocimacroProxy extends Di
break;
}
- context.put(macroArg.name, newVal);
values[(i-1) * 2 + 1] = newVal;
/* when preserveArgumentsLiterals is true, we still store the actual reference passed to the macro
@@ -429,6 +426,14 @@ public class VelocimacroProxy extends Di
}
}
+ // Now really put the values in the context
+ for (int i = 1; i < macroArgs.size(); i++)
+ {
+ MacroArg macroArg = macroArgs.get(i);
+ Object value = values[(i-1) * 2 + 1];
+ context.put(macroArg.name, value);
+ }
+
// return the array of replaced and new values
return values;
}
Copied: velocity/engine/trunk/velocity-engine-core/src/test/java/org/apache/velocity/test/issues/Velocity926TestCase.java (from r1872422, velocity/engine/trunk/velocity-engine-core/src/test/java/org/apache/velocity/test/issues/Velocity924TestCase.java)
URL: http://svn.apache.org/viewvc/velocity/engine/trunk/velocity-engine-core/src/test/java/org/apache/velocity/test/issues/Velocity926TestCase.java?p2=velocity/engine/trunk/velocity-engine-core/src/test/java/org/apache/velocity/test/issues/Velocity926TestCase.java&p1=velocity/engine/trunk/velocity-engine-core/src/test/java/org/apache/velocity/test/issues/Velocity924TestCase.java&r1=1872422&r2=1873069&rev=1873069&view=diff
==============================================================================
--- velocity/engine/trunk/velocity-engine-core/src/test/java/org/apache/velocity/test/issues/Velocity924TestCase.java (original)
+++ velocity/engine/trunk/velocity-engine-core/src/test/java/org/apache/velocity/test/issues/Velocity926TestCase.java Thu Jan 23 16:51:09 2020
@@ -23,42 +23,17 @@ import org.apache.velocity.VelocityConte
import org.apache.velocity.test.BaseTestCase;
/**
- * This class tests VELOCITY-855.
+ * This class tests VELOCITY-926.
*/
-public class Velocity924TestCase extends BaseTestCase
+public class Velocity926TestCase extends BaseTestCase
{
- public Velocity924TestCase(String name)
+ public Velocity926TestCase(String name)
{
super(name);
}
- public static class Foo
+ public void testNamesCollision()
{
- public String getName() { return "foo"; }
- }
-
- protected void setUpContext(VelocityContext context)
- {
- context.put("var", new Foo());
- }
-
- public void testVelocity924Getter()
- {
- assertEvalEquals("org.apache.velocity.test.issues.Velocity924TestCase$Foo foo", "$var.class.name $var.name");
- }
-
- public void testVelocity924Method()
- {
- assertEvalEquals("org.apache.velocity.test.issues.Velocity924TestCase$Foo foo", "$var.class.getName() $var.getName()");assertEvalEquals("org.apache.velocity.test.issues.Velocity924TestCase$Foo foo", "$var.class.name $var.name");
- }
-
- public void testVelocity924Getter2()
- {
- assertEvalEquals("foo org.apache.velocity.test.issues.Velocity924TestCase$Foo", "$var.name $var.class.name");
- }
-
- public void testVelocity924Method2()
- {
- assertEvalEquals("foo org.apache.velocity.test.issues.Velocity924TestCase$Foo", "$var.getName() $var.class.getName()");assertEvalEquals("org.apache.velocity.test.issues.Velocity924TestCase$Foo foo", "$var.class.name $var.name");
+ assertEvalEquals("bar foo", "#set($foo='foo')#set($bar='bar')#macro(test, $foo, $bar)$foo $bar#end#test($bar, $foo)");
}
}