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/28 10:48:29 UTC

svn commit: r1873244 - in /velocity/engine/trunk/velocity-engine-core/src: main/java/org/apache/velocity/runtime/ main/java/org/apache/velocity/runtime/directive/ main/java/org/apache/velocity/runtime/parser/node/ main/resources/org/apache/velocity/run...

Author: cbrisson
Date: Tue Jan 28 10:48:29 2020
New Revision: 1873244

URL: http://svn.apache.org/viewvc?rev=1873244&view=rev
Log:
[engine] Review VELOCITY-926 fix:

deprecate velocimacro.arguments.preserve_literals in favor of the new velocimacro.enable_bc_mode flag,
which mimics 1.7 velocimacro behavior:

- preserve arguments literals:

    #macro(m $arg) $arg #end
    m($null)

will displays $arg w/o bc mode and $null with bc mode

- use global defaults for missing arguments:

    #macro(m $foo) $foo #end
    #set($foo='foo')
    #m()

will display $foo w/o bc mode and 'foo' with bc mode

The following use cases have been left aside from backward compatibility:

- preserving local macro scope values

    #macro(test) #set($foo = 'foo') $some_tool.change_foo_value_in_global_context_to_bar() $foo #end
    #test()

will always display 'bar', while 1.7 displayed 'foo'

- setting a null argument to null, while argument name exists in context, 

    #macro(setnull $foo) #set($foo = $null) #end
    #set($foo='foo')
    #setnull($null)
    $foo

Will always display 'foo' (w or w/o bc mode), while 1.7 did display $foo



Added:
    velocity/engine/trunk/velocity-engine-core/src/test/java/org/apache/velocity/test/VelocimacroBCModeTestCase.java
      - copied, changed from r1873243, velocity/engine/trunk/velocity-engine-core/src/test/java/org/apache/velocity/test/PreserveArgumentsLiteralsTestCase.java
    velocity/engine/trunk/velocity-engine-core/src/test/resources/bc_mode/
    velocity/engine/trunk/velocity-engine-core/src/test/resources/bc_mode/compare/
    velocity/engine/trunk/velocity-engine-core/src/test/resources/bc_mode/compare/test_bc_mode.bc_mode_disabled
    velocity/engine/trunk/velocity-engine-core/src/test/resources/bc_mode/compare/test_bc_mode.bc_mode_enabled
    velocity/engine/trunk/velocity-engine-core/src/test/resources/bc_mode/test_bc_mode.vtl
Removed:
    velocity/engine/trunk/velocity-engine-core/src/test/java/org/apache/velocity/test/PreserveArgumentsLiteralsTestCase.java
Modified:
    velocity/engine/trunk/velocity-engine-core/src/main/java/org/apache/velocity/runtime/DeprecatedRuntimeConstants.java
    velocity/engine/trunk/velocity-engine-core/src/main/java/org/apache/velocity/runtime/RuntimeConstants.java
    velocity/engine/trunk/velocity-engine-core/src/main/java/org/apache/velocity/runtime/directive/VelocimacroProxy.java
    velocity/engine/trunk/velocity-engine-core/src/main/java/org/apache/velocity/runtime/parser/node/ASTReference.java
    velocity/engine/trunk/velocity-engine-core/src/main/resources/org/apache/velocity/runtime/defaults/velocity.properties
    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/DeprecatedRuntimeConstants.java
URL: http://svn.apache.org/viewvc/velocity/engine/trunk/velocity-engine-core/src/main/java/org/apache/velocity/runtime/DeprecatedRuntimeConstants.java?rev=1873244&r1=1873243&r2=1873244&view=diff
==============================================================================
--- velocity/engine/trunk/velocity-engine-core/src/main/java/org/apache/velocity/runtime/DeprecatedRuntimeConstants.java (original)
+++ velocity/engine/trunk/velocity-engine-core/src/main/java/org/apache/velocity/runtime/DeprecatedRuntimeConstants.java Tue Jan 28 10:48:29 2020
@@ -274,4 +274,12 @@ public interface DeprecatedRuntimeConsta
      */
     String OLD_SPACE_GOBBLING = "space.gobbling";
 
+    /**
+     * When displaying null or invalid non-quiet references, use the argument literal reference
+     * instead of the one in the macro block. Defaults to false.
+     * @since 2.1
+     * @Deprecated since 2.2, see {@link RuntimeConstants#VM_ENABLE_BC_MODE}
+     **/
+    String OLD_VM_ENABLE_BC_MODE = "velocimacro.arguments.preserve_literals";
+
 }

Modified: velocity/engine/trunk/velocity-engine-core/src/main/java/org/apache/velocity/runtime/RuntimeConstants.java
URL: http://svn.apache.org/viewvc/velocity/engine/trunk/velocity-engine-core/src/main/java/org/apache/velocity/runtime/RuntimeConstants.java?rev=1873244&r1=1873243&r2=1873244&view=diff
==============================================================================
--- velocity/engine/trunk/velocity-engine-core/src/main/java/org/apache/velocity/runtime/RuntimeConstants.java (original)
+++ velocity/engine/trunk/velocity-engine-core/src/main/java/org/apache/velocity/runtime/RuntimeConstants.java Tue Jan 28 10:48:29 2020
@@ -331,11 +331,21 @@ public interface RuntimeConstants extend
     String VM_ARGUMENTS_STRICT = "velocimacro.arguments.strict";
 
     /**
-     * When displaying null or invalid non-quiet references, use the argument literal reference
-     * instead of the one in the macro block. Defaults to false.
-     * @since 2.1
-     **/
-    String VM_PRESERVE_ARGUMENTS_LITERALS = "velocimacro.arguments.preserve_literals";
+     * This flag enable the 1.7 backward compatible mode for velocimacros (defaults to false):
+     * <ul>
+     *     <li>
+     *         preserve argument literals: when displaying null or invalid non-quiet references,
+     *         use the argument literal reference instead of the one in the macro block. Defaults to false.
+     *     </li>
+     *     <li>
+     *         use global values for missing arguments: when calling a macro with fewer arguments than declared,
+     *         if those arguments don't have an explicit default value in the macro definition, default values will
+     *         be looked for in the global context
+     *     </li>
+     * </ul>
+     * @since 2.2
+     */
+    String VM_ENABLE_BC_MODE = "velocimacro.enable_bc_mode";
 
     /**
      * Specify the maximum depth for macro calls

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=1873244&r1=1873243&r2=1873244&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 Tue Jan 28 10:48:29 2020
@@ -56,7 +56,7 @@ public class VelocimacroProxy extends Di
     private boolean strictArguments;
     private int maxCallDepth;
     private String bodyReference;
-    private boolean preserveArgumentsLiterals;
+    private boolean enableBCmode;
 
     private static final Object NULL_VALUE_MARKER = new Object();
 
@@ -99,7 +99,7 @@ public class VelocimacroProxy extends Di
 
         // for performance reasons we precache these strings - they are needed in
         // "render literal if null" functionality
-        if (preserveArgumentsLiterals)
+        if (enableBCmode)
         {
             literalArgArray = new String[macroArgs.size()];
             for (int i = 0; i < macroArgs.size(); i++)
@@ -160,7 +160,7 @@ public class VelocimacroProxy extends Di
         // get name of the reference that refers to AST block passed to block macro call
         bodyReference = rsvc.getString(RuntimeConstants.VM_BODY_REFERENCE, "bodyContent");
 
-        preserveArgumentsLiterals = rsvc.getBoolean(RuntimeConstants.VM_PRESERVE_ARGUMENTS_LITERALS, false);
+        enableBCmode = rsvc.getBoolean(RuntimeConstants.VM_ENABLE_BC_MODE, false);
     }
 
     /**
@@ -247,9 +247,10 @@ public class VelocimacroProxy extends Di
             {
                 MacroArg macroArg = macroArgs.get(i);
                 current = context.get(macroArg.name);
-                if (current == values[(i-1) * 2 + 1])
+                Object given = values[(i-1) * 2 + 1];
+                Object old = values[(i-1) * 2];
+                if (current == given || current == null && given == NULL_VALUE_MARKER)
                 {
-                    Object old = values[(i-1) * 2];
                     if (old == null)
                     {
                         context.remove(macroArg.name);
@@ -264,11 +265,11 @@ public class VelocimacroProxy extends Di
                     }
                 }
 
-                if (preserveArgumentsLiterals)
+                if (enableBCmode)
                 {
                     /* allow for nested calls */
                     Deque<String> literalsStack = (Deque<String>)context.get(literalArgArray[i]);
-                    if (literalsStack != null) /* may be null if argument was missing in macro call */
+                    if (literalsStack != null) /* shouldn't be null */
                     {
                         literalsStack.removeFirst();
                         if (literalsStack.size() == 0)
@@ -354,6 +355,8 @@ public class VelocimacroProxy extends Di
     	// Changed two dimensional array to single dimensional to optimize memory lookups
         Object[] values = new Object[macroArgs.size() * 2];
 
+        boolean warnedMissingArguments = false;
+
         // Move arguments into the macro's context. Start at one to skip macro name
         for (int i = 1; i < macroArgs.size(); i++)
         {
@@ -394,18 +397,26 @@ public class VelocimacroProxy extends Di
             }
             else
             {
-                // Backward compatibility logging, Mainly for MacroForwardDefinedTestCase
-                log.debug("VM #{}: too few arguments to macro. Wanted {} got {}",
-                          macroArgs.get(0).name, macroArgs.size() - 1, callArgNum);
-                break;
+                if (!warnedMissingArguments)
+                {
+                    // Backward compatibility logging, Mainly for MacroForwardDefinedTestCase
+                    log.debug("VM #{}: too few arguments to macro. Wanted {} got {}",
+                        macroArgs.get(0).name, macroArgs.size() - 1, callArgNum);
+                    warnedMissingArguments = true;
+                }
+                if (enableBCmode)
+                {
+                    // use the global context value as default
+                    newVal = oldVal;
+                }
             }
 
             values[(i-1) * 2 + 1] = newVal;
 
-            /* when preserveArgumentsLiterals is true, we still store the actual reference passed to the macro
+            /* when enableBCmode is true, we still store the actual reference passed to the macro
                even if the value is not null, because *if* the argument is set to null *during* the macro rendering
                we still expect the passed argument literal to be displayed to be fully backward compatible. */
-            if (preserveArgumentsLiterals && /* newVal == null && */ argNode != null)
+            if (enableBCmode && /* newVal == null && */ argNode != null)
             {
                 /* allow nested macro calls for B.C. */
                 Deque<String> literalsStack = (Deque<String>)context.get(literalArgArray[i]);
@@ -415,7 +426,7 @@ public class VelocimacroProxy extends Di
                     context.put(literalArgArray[i], literalsStack);
                 }
                 /* Reflects the strange 1.7 behavor... */
-                if (argNode instanceof ASTReference || argNode instanceof ASTStringLiteral)
+                if (argNode != null && (argNode instanceof ASTReference || argNode instanceof ASTStringLiteral))
                 {
                     literalsStack.addFirst(argNode.literal());
                 }

Modified: velocity/engine/trunk/velocity-engine-core/src/main/java/org/apache/velocity/runtime/parser/node/ASTReference.java
URL: http://svn.apache.org/viewvc/velocity/engine/trunk/velocity-engine-core/src/main/java/org/apache/velocity/runtime/parser/node/ASTReference.java?rev=1873244&r1=1873243&r2=1873244&view=diff
==============================================================================
--- velocity/engine/trunk/velocity-engine-core/src/main/java/org/apache/velocity/runtime/parser/node/ASTReference.java (original)
+++ velocity/engine/trunk/velocity-engine-core/src/main/java/org/apache/velocity/runtime/parser/node/ASTReference.java Tue Jan 28 10:48:29 2020
@@ -157,7 +157,7 @@ public class ASTReference extends Simple
 
         strictEscape = rsvc.getBoolean(RuntimeConstants.RUNTIME_REFERENCES_STRICT_ESCAPE, false);
         strictRef = rsvc.getBoolean(RuntimeConstants.RUNTIME_REFERENCES_STRICT, false);
-        lookupAlternateLiteral = rsvc.getBoolean(RuntimeConstants.VM_PRESERVE_ARGUMENTS_LITERALS, false);
+        lookupAlternateLiteral = rsvc.getBoolean(RuntimeConstants.VM_ENABLE_BC_MODE, false);
 
         /*
          *  the only thing we can do in init() is getRoot()

Modified: velocity/engine/trunk/velocity-engine-core/src/main/resources/org/apache/velocity/runtime/defaults/velocity.properties
URL: http://svn.apache.org/viewvc/velocity/engine/trunk/velocity-engine-core/src/main/resources/org/apache/velocity/runtime/defaults/velocity.properties?rev=1873244&r1=1873243&r2=1873244&view=diff
==============================================================================
--- velocity/engine/trunk/velocity-engine-core/src/main/resources/org/apache/velocity/runtime/defaults/velocity.properties (original)
+++ velocity/engine/trunk/velocity-engine-core/src/main/resources/org/apache/velocity/runtime/defaults/velocity.properties Tue Jan 28 10:48:29 2020
@@ -118,14 +118,16 @@ velocimacro.arguments.strict = false
 velocimacro.body_reference = bodyContent
 
 # ----------------------------------------------------------------------------
-# VELOCIMACRO PRESERVE ARGUMENTS LITERALS
+# VELOCIMACRO ENABLE BC MODE
 # ----------------------------------------------------------------------------
-# if true, when a macro has to render a null or invalid argument reference
+# Backward compatibility for 1.7 macros behavior.
+# If true, when a macro has to render a null or invalid argument reference
 # which is not quiet, it will print the provided literal reference instead
-# of the one found in the body of the macro
+# of the one found in the body of the macro ; and if a macro argument is
+# without an explicit default value is missing from the macro call, its value
+# will be looked up in the global context
 # ----------------------------------------------------------------------------
-velocimacro.arguments.preserve_literals = false
-
+velocimacro.enable_bc_mode = false
 
 # ----------------------------------------------------------------------------
 # STRICT REFERENCE MODE

Copied: velocity/engine/trunk/velocity-engine-core/src/test/java/org/apache/velocity/test/VelocimacroBCModeTestCase.java (from r1873243, velocity/engine/trunk/velocity-engine-core/src/test/java/org/apache/velocity/test/PreserveArgumentsLiteralsTestCase.java)
URL: http://svn.apache.org/viewvc/velocity/engine/trunk/velocity-engine-core/src/test/java/org/apache/velocity/test/VelocimacroBCModeTestCase.java?p2=velocity/engine/trunk/velocity-engine-core/src/test/java/org/apache/velocity/test/VelocimacroBCModeTestCase.java&p1=velocity/engine/trunk/velocity-engine-core/src/test/java/org/apache/velocity/test/PreserveArgumentsLiteralsTestCase.java&r1=1873243&r2=1873244&rev=1873244&view=diff
==============================================================================
--- velocity/engine/trunk/velocity-engine-core/src/test/java/org/apache/velocity/test/PreserveArgumentsLiteralsTestCase.java (original)
+++ velocity/engine/trunk/velocity-engine-core/src/test/java/org/apache/velocity/test/VelocimacroBCModeTestCase.java Tue Jan 28 10:48:29 2020
@@ -19,27 +19,81 @@ package org.apache.velocity.test;
  * under the License.
  */
 
+import org.apache.velocity.Template;
+import org.apache.velocity.VelocityContext;
 import org.apache.velocity.app.VelocityEngine;
 import org.apache.velocity.runtime.RuntimeConstants;
 
+import java.io.BufferedWriter;
+import java.io.FileOutputStream;
+import java.io.OutputStreamWriter;
+import java.io.Writer;
+
 /**
  * This class tests the mode where velocimacros do preserve arguments literals
  */
 
-public class PreserveArgumentsLiteralsTestCase extends BaseTestCase
+public class VelocimacroBCModeTestCase extends BaseTestCase
 {
-    public PreserveArgumentsLiteralsTestCase(final String name)
+    private static final String BASE_DIR = TEST_COMPARE_DIR + "/bc_mode";
+    private static final String CMP_DIR = BASE_DIR + "/compare";
+    private static final String RESULTS_DIR = TEST_RESULT_DIR + "/bc_mode";
+
+    public VelocimacroBCModeTestCase(final String name)
     {
         super(name);
     }
 
     protected void setUpEngine(VelocityEngine engine)
     {
-        engine.setProperty(RuntimeConstants.VM_PRESERVE_ARGUMENTS_LITERALS, true);
+        boolean bcMode = !getName().contains("NoPreserve");
+        engine.setProperty(RuntimeConstants.VM_ENABLE_BC_MODE, bcMode);
+        engine.setProperty("file.resource.loader.path", TEST_COMPARE_DIR + "/bc_mode");
     }
 
     public void testPreserveLiterals()
     {
         assertEvalEquals("$bar","#macro(m $foo)$foo#end#m($bar)");
     }
+
+    public void testGlobalDefaults()
+    {
+        assertEvalEquals("foo","#macro(m $foo)$foo#end#set($foo='foo')#m()");
+    }
+
+    public void testVariousCasesPreserve() throws Exception
+    {
+        doTestVariousCases("bc_mode_enabled");
+    }
+
+    public void testVariousCasesNoPreserve() throws Exception
+    {
+        doTestVariousCases("bc_mode_disabled");
+    }
+
+    private void doTestVariousCases(String compare_ext) throws Exception
+    {
+        assureResultsDirectoryExists(RESULTS_DIR);
+        String basefilename = "test_bc_mode";
+        Template template = engine.getTemplate( getFileName(null, basefilename, "vtl") );
+        context = new VelocityContext();
+        FileOutputStream fos;
+        Writer fwriter;
+
+        fos = new FileOutputStream (getFileName(RESULTS_DIR, basefilename, RESULT_FILE_EXT));
+
+        fwriter = new BufferedWriter( new OutputStreamWriter(fos) );
+
+        template.merge(context, fwriter);
+        fwriter.flush();
+        fwriter.close();
+
+        if (!isMatch(RESULTS_DIR, CMP_DIR, basefilename, RESULT_FILE_EXT, compare_ext))
+        {
+            String result = getFileContents(RESULTS_DIR, basefilename, RESULT_FILE_EXT);
+            String compare = getFileContents(CMP_DIR, basefilename, compare_ext);
+
+            assertEquals(compare, result);
+        }
+    }
 }

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=1873244&r1=1873243&r2=1873244&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 Tue Jan 28 10:48:29 2020
@@ -35,6 +35,7 @@ public class Velocity904TestCase extends
     @Override
     protected void setUpEngine(VelocityEngine engine)
     {
+        // that will also test the deprecation of velocimacro.arguments.preserve_literals towards velocimacro.enable_bc_mode
         engine.setProperty("velocimacro.arguments.preserve_literals", getName().contains("NoPreserve") ? "false" : "true");
     }
 

Added: velocity/engine/trunk/velocity-engine-core/src/test/resources/bc_mode/compare/test_bc_mode.bc_mode_disabled
URL: http://svn.apache.org/viewvc/velocity/engine/trunk/velocity-engine-core/src/test/resources/bc_mode/compare/test_bc_mode.bc_mode_disabled?rev=1873244&view=auto
==============================================================================
--- velocity/engine/trunk/velocity-engine-core/src/test/resources/bc_mode/compare/test_bc_mode.bc_mode_disabled (added)
+++ velocity/engine/trunk/velocity-engine-core/src/test/resources/bc_mode/compare/test_bc_mode.bc_mode_disabled Tue Jan 28 10:48:29 2020
@@ -0,0 +1,40 @@
+
+
+
+
+A) Null Values
+1. missing argument
+foo=$foo => disp miss [foo=$foo] => foo=$foo
+foo=$foo => setn miss [foo=$foo] => foo=$foo
+foo=$foo => setv miss [foo=inn] => foo=inn
+2. null argument
+foo=$foo => disp null [foo=$foo] => foo=$foo
+foo=$foo => setn null [foo=$foo] => foo=$foo
+foo=$foo => setv null [foo=inn] => foo=inn
+3. non-colliding argument
+foo=$foo => disp ncol [foo=$foo] => foo=$foo
+foo=$foo => setn ncol [foo=$foo] => foo=$foo
+foo=$foo => setv ncol [foo=inn] => foo=inn
+4. colliding argument
+foo=$foo => disp coll [foo=$foo] => foo=$foo
+foo=$foo => setn coll [foo=$foo] => foo=$foo
+foo=$foo => setv coll [foo=inn] => foo=inn
+
+B) Non-null Values
+1. missing argument
+foo=foo => disp miss [foo=$foo] => foo=foo
+foo=foo => setn miss [foo=$foo] => foo=foo
+foo=foo => setv miss [foo=inn] => foo=inn
+2. null argument
+foo=foo => disp null [foo=$foo] => foo=foo
+foo=foo => setn null [foo=$foo] => foo=foo
+foo=foo => setv null [foo=inn] => foo=inn
+3. non-colliding argument
+foo=foo => disp ncol [foo=bar] => foo=foo
+foo=foo => setn ncol [foo=$foo] => foo=$foo
+foo=foo => setv ncol [foo=bar] => foo=foo
+4. colliding argument
+foo=foo => disp coll [foo=foo] => foo=foo
+foo=foo => setn coll [foo=$foo] => foo=$foo
+foo=foo => setv coll [foo=foo] => foo=foo
+

Added: velocity/engine/trunk/velocity-engine-core/src/test/resources/bc_mode/compare/test_bc_mode.bc_mode_enabled
URL: http://svn.apache.org/viewvc/velocity/engine/trunk/velocity-engine-core/src/test/resources/bc_mode/compare/test_bc_mode.bc_mode_enabled?rev=1873244&view=auto
==============================================================================
--- velocity/engine/trunk/velocity-engine-core/src/test/resources/bc_mode/compare/test_bc_mode.bc_mode_enabled (added)
+++ velocity/engine/trunk/velocity-engine-core/src/test/resources/bc_mode/compare/test_bc_mode.bc_mode_enabled Tue Jan 28 10:48:29 2020
@@ -0,0 +1,40 @@
+
+
+
+
+A) Null Values
+1. missing argument
+foo=$foo => disp miss [foo=$foo] => foo=$foo
+foo=$foo => setn miss [foo=$foo] => foo=$foo
+foo=$foo => setv miss [foo=inn] => foo=inn
+2. null argument
+foo=$foo => disp null [foo=$null] => foo=$foo
+foo=$foo => setn null [foo=$foo] => foo=$foo
+foo=$foo => setv null [foo=inn] => foo=inn
+3. non-colliding argument
+foo=$foo => disp ncol [foo=$bar] => foo=$foo
+foo=$foo => setn ncol [foo=$foo] => foo=$foo
+foo=$foo => setv ncol [foo=inn] => foo=inn
+4. colliding argument
+foo=$foo => disp coll [foo=$foo] => foo=$foo
+foo=$foo => setn coll [foo=$foo] => foo=$foo
+foo=$foo => setv coll [foo=inn] => foo=inn
+
+B) Non-null Values
+1. missing argument
+foo=foo => disp miss [foo=foo] => foo=foo
+foo=foo => setn miss [foo=$foo] => foo=$foo
+foo=foo => setv miss [foo=foo] => foo=foo
+2. null argument
+foo=foo => disp null [foo=$null] => foo=foo
+foo=foo => setn null [foo=$foo] => foo=foo
+foo=foo => setv null [foo=inn] => foo=inn
+3. non-colliding argument
+foo=foo => disp ncol [foo=bar] => foo=foo
+foo=foo => setn ncol [foo=$foo] => foo=$foo
+foo=foo => setv ncol [foo=bar] => foo=foo
+4. colliding argument
+foo=foo => disp coll [foo=foo] => foo=foo
+foo=foo => setn coll [foo=$foo] => foo=$foo
+foo=foo => setv coll [foo=foo] => foo=foo
+

Added: velocity/engine/trunk/velocity-engine-core/src/test/resources/bc_mode/test_bc_mode.vtl
URL: http://svn.apache.org/viewvc/velocity/engine/trunk/velocity-engine-core/src/test/resources/bc_mode/test_bc_mode.vtl?rev=1873244&view=auto
==============================================================================
--- velocity/engine/trunk/velocity-engine-core/src/test/resources/bc_mode/test_bc_mode.vtl (added)
+++ velocity/engine/trunk/velocity-engine-core/src/test/resources/bc_mode/test_bc_mode.vtl Tue Jan 28 10:48:29 2020
@@ -0,0 +1,39 @@
+#macro(store)#set($foo_ = $foo)#set($bar_ = $bar)#end##
+#macro(reset)#set($foo = $foo_)#set($bar = $bar_)#end##
+#macro(state)foo=$foo#end##
+
+#macro(disp $foo)[foo=$foo]#end
+#macro(setn $foo)#set($foo=$null)#disp($foo)#end
+#macro(setv $foo)#if(!$foo)#set($foo='inn')#end#disp($foo)#end
+#macro(sub)#set($foo='sub')#end
+
+#macro(test)
+1. missing argument
+#store#state => disp miss #disp() => #state#reset
+#store#state => setn miss #setn() => #state#reset
+#store#state => setv miss #setv() => #state#reset
+2. null argument
+#store#state => disp null #disp($null) => #state#reset
+#store#state => setn null #setn($null) => #state#reset
+#store#state => setv null #setv($null) => #state#reset
+3. non-colliding argument
+#store#state => disp ncol #disp($bar) => #state#reset
+#store#state => setn ncol #setn($bar) => #state#reset
+#store#state => setv ncol #setv($bar) => #state#reset
+4. colliding argument
+#store#state => disp coll #disp($foo) => #state#reset
+#store#state => setn coll #setn($foo) => #state#reset
+#store#state => setv coll #setv($foo) => #state#reset
+#end
+
+
+A) Null Values
+#set($foo = $null)
+#set($bar = $null)
+#test()
+
+B) Non-null Values
+#set($foo = 'foo')
+#set($bar = 'bar')
+#test()
+