You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@velocity.apache.org by wg...@apache.org on 2007/10/07 01:44:36 UTC

svn commit: r582559 - in /velocity/engine/trunk: src/java/org/apache/velocity/context/EvaluateContext.java src/test/org/apache/velocity/test/EvaluateTestCase.java test/evaluate/compare/evalvmcontext.cmp test/evaluate/evalvmcontext.vm

Author: wglass
Date: Sat Oct  6 16:44:35 2007
New Revision: 582559

URL: http://svn.apache.org/viewvc?rev=582559&view=rev
Log:
Make #evaluate get correct context within a #foreach.  Fixes VELOCITY-565.

Added:
    velocity/engine/trunk/test/evaluate/compare/evalvmcontext.cmp   (with props)
    velocity/engine/trunk/test/evaluate/evalvmcontext.vm   (with props)
Modified:
    velocity/engine/trunk/src/java/org/apache/velocity/context/EvaluateContext.java
    velocity/engine/trunk/src/test/org/apache/velocity/test/EvaluateTestCase.java

Modified: velocity/engine/trunk/src/java/org/apache/velocity/context/EvaluateContext.java
URL: http://svn.apache.org/viewvc/velocity/engine/trunk/src/java/org/apache/velocity/context/EvaluateContext.java?rev=582559&r1=582558&r2=582559&view=diff
==============================================================================
--- velocity/engine/trunk/src/java/org/apache/velocity/context/EvaluateContext.java (original)
+++ velocity/engine/trunk/src/java/org/apache/velocity/context/EvaluateContext.java Sat Oct  6 16:44:35 2007
@@ -63,7 +63,7 @@
      */
     public EvaluateContext( InternalContextAdapter  inner, RuntimeServices rsvc )
     {
-        innerContext = inner.getBaseContext();
+        innerContext = inner;
         initContext(rsvc);
     }
 

Modified: velocity/engine/trunk/src/test/org/apache/velocity/test/EvaluateTestCase.java
URL: http://svn.apache.org/viewvc/velocity/engine/trunk/src/test/org/apache/velocity/test/EvaluateTestCase.java?rev=582559&r1=582558&r2=582559&view=diff
==============================================================================
--- velocity/engine/trunk/src/test/org/apache/velocity/test/EvaluateTestCase.java (original)
+++ velocity/engine/trunk/src/test/org/apache/velocity/test/EvaluateTestCase.java Sat Oct  6 16:44:35 2007
@@ -106,6 +106,16 @@
     }
 
     /**
+     * Test in a macro context.
+     * @throws Exception
+     */
+    public void testEvaluateVMContext()
+    throws Exception
+    {
+        testFile("evalvmcontext");
+    }
+
+    /**
      * Test #stop (since it is attached to context).
      * @throws Exception
      */

Added: velocity/engine/trunk/test/evaluate/compare/evalvmcontext.cmp
URL: http://svn.apache.org/viewvc/velocity/engine/trunk/test/evaluate/compare/evalvmcontext.cmp?rev=582559&view=auto
==============================================================================
--- velocity/engine/trunk/test/evaluate/compare/evalvmcontext.cmp (added)
+++ velocity/engine/trunk/test/evaluate/compare/evalvmcontext.cmp Sat Oct  6 16:44:35 2007
@@ -0,0 +1,3 @@
+
+
+value is : val1;value is : val2;
\ No newline at end of file

Propchange: velocity/engine/trunk/test/evaluate/compare/evalvmcontext.cmp
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: velocity/engine/trunk/test/evaluate/compare/evalvmcontext.cmp
------------------------------------------------------------------------------
    svn:keywords = Id Author Date Revision

Added: velocity/engine/trunk/test/evaluate/evalvmcontext.vm
URL: http://svn.apache.org/viewvc/velocity/engine/trunk/test/evaluate/evalvmcontext.vm?rev=582559&view=auto
==============================================================================
--- velocity/engine/trunk/test/evaluate/evalvmcontext.vm (added)
+++ velocity/engine/trunk/test/evaluate/evalvmcontext.vm Sat Oct  6 16:44:35 2007
@@ -0,0 +1,7 @@
+## test of evaluate in a macro context whith local refs (foreach refs)
+
+#macro(testEval $expr)
+#foreach($value in ["val1", "val2"])value is : #evaluate( $expr );#end
+#end
+
+#testEval( "${value}" )

Propchange: velocity/engine/trunk/test/evaluate/evalvmcontext.vm
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: velocity/engine/trunk/test/evaluate/evalvmcontext.vm
------------------------------------------------------------------------------
    svn:keywords = Id Author Date Revision