Author: byron
Date: Wed Feb  4 20:30:19 2009
New Revision: 740865

URL: http://svn.apache.org/viewvc?rev=740865&view=rev
Log:
Fix MacroForwardDefineTestCase failure, fix number of arguments error message 
for block marcros, and block macros to MacroForwardDefineTestCase

Modified:
    velocity/engine/trunk/experimental/benchmark/Benchmark.java
    
velocity/engine/trunk/src/java/org/apache/velocity/runtime/directive/VelocimacroProxy.java
    velocity/engine/trunk/test/macroforwarddefine/compare/velocity.log.cmp
    velocity/engine/trunk/test/macroforwarddefine/macros.vm

Modified: velocity/engine/trunk/experimental/benchmark/Benchmark.java
URL: 
http://svn.apache.org/viewvc/velocity/engine/trunk/experimental/benchmark/Benchmark.java?rev=740865&r1=740864&r2=740865&view=diff
==============================================================================
--- velocity/engine/trunk/experimental/benchmark/Benchmark.java (original)
+++ velocity/engine/trunk/experimental/benchmark/Benchmark.java Wed Feb  4 
20:30:19 2009
@@ -33,8 +33,8 @@
 
 public class Benchmark
 {
-  int threadCnt = 2;
-  int runCnt = 500;
+  int threadCnt = 10;
+  int runCnt = 1000;
   
   public static final void main(String[] argv) throws Exception
   {
@@ -49,12 +49,13 @@
   
   public void go() throws Exception
   {
-    
-    Properties props = new Properties();
-    props.setProperty(RuntimeConstants.FILE_RESOURCE_LOADER_CACHE, "true");
-    props.setProperty(RuntimeConstants.RESOURCE_MANAGER_DEFAULTCACHE_SIZE, 
"20");
-    props.setProperty(RuntimeConstants.RUNTIME_REFERENCES_STRICT, "true");
-    VelocityEngine vengine = new VelocityEngine(props);
+    VelocityEngine vengine = new VelocityEngine();
+    vengine.setProperty(RuntimeConstants.FILE_RESOURCE_LOADER_CACHE, "true");
+    //vengine.setProperty(RuntimeConstants.VM_ARGUMENTS_PASSBYVALUE, "true");
+    vengine.setProperty(RuntimeConstants.VM_LIBRARY_AUTORELOAD, "false");
+    vengine.setProperty(RuntimeConstants.RESOURCE_MANAGER_DEFAULTCACHE_SIZE, 
"0");
+    vengine.setProperty(RuntimeConstants.RUNTIME_REFERENCES_STRICT, "true");
+    vengine.setProperty("file.resource.loader.modificationCheckInterval", "0");
     vengine.setProperty(RuntimeConstants.VM_LIBRARY, "vmlib1.vm,vmlib2.vm");
     log("Starting " + threadCnt + " threads which will run " + runCnt + " 
times");
     ArrayList list = new ArrayList(threadCnt);    

Modified: 
velocity/engine/trunk/src/java/org/apache/velocity/runtime/directive/VelocimacroProxy.java
URL: 
http://svn.apache.org/viewvc/velocity/engine/trunk/src/java/org/apache/velocity/runtime/directive/VelocimacroProxy.java?rev=740865&r1=740864&r2=740865&view=diff
==============================================================================
--- 
velocity/engine/trunk/src/java/org/apache/velocity/runtime/directive/VelocimacroProxy.java
 (original)
+++ 
velocity/engine/trunk/src/java/org/apache/velocity/runtime/directive/VelocimacroProxy.java
 Wed Feb  4 20:30:19 2009
@@ -259,13 +259,12 @@
     /**
      * Build an error message for not providing the correct number of arguments
      */
-    private String buildErrorMsg(Node node)
+    private String buildErrorMsg(Node node, int numArgsProvided)
     {
-      int i = node.jjtGetNumChildren() - 1; // the number of arguments this 
call provided
-      String msg = "VM #" + macroName + ": too "
-        + ((getNumArgs() > i) ? "few" : "many") + " arguments to macro. Wanted 
"
-        + getNumArgs() + " got " + i;      
-      return msg;
+        String msg = "VM #" + macroName + ": too "
+          + ((getNumArgs() > numArgsProvided) ? "few" : "many") + " arguments 
to macro. Wanted "
+          + getNumArgs() + " got " + numArgsProvided;      
+        return msg;
     }
     
     /**
@@ -290,12 +289,12 @@
                 /**
                  * indicate col/line assuming it starts at 0 - this will be 
corrected one call up
                  */
-                throw new TemplateInitException(buildErrorMsg(node), 
+                throw new TemplateInitException(buildErrorMsg(node, i), 
                     context.getCurrentTemplateName(), 0, 0);
             }
             else if (rsvc.getLog().isDebugEnabled())
             {
-                rsvc.getLog().debug(buildErrorMsg(node));
+                rsvc.getLog().debug(buildErrorMsg(node, i));
                 return;
             }
         }

Modified: velocity/engine/trunk/test/macroforwarddefine/compare/velocity.log.cmp
URL: 
http://svn.apache.org/viewvc/velocity/engine/trunk/test/macroforwarddefine/compare/velocity.log.cmp?rev=740865&r1=740864&r2=740865&view=diff
==============================================================================
--- velocity/engine/trunk/test/macroforwarddefine/compare/velocity.log.cmp 
(original)
+++ velocity/engine/trunk/test/macroforwarddefine/compare/velocity.log.cmp Wed 
Feb  4 20:30:19 2009
@@ -6,3 +6,5 @@
  [debug] VM #test2: too many arguments to macro. Wanted 1 got 2
  [debug] VM #test3: too many arguments to macro. Wanted 1 got 2
  [debug] VM #test4: too many arguments to macro. Wanted 1 got 2
+ [debug] VM #test1: too many arguments to macro. Wanted 1 got 2
+ [debug] VM #test1: too few arguments to macro. Wanted 1 got 0

Modified: velocity/engine/trunk/test/macroforwarddefine/macros.vm
URL: 
http://svn.apache.org/viewvc/velocity/engine/trunk/test/macroforwarddefine/macros.vm?rev=740865&r1=740864&r2=740865&view=diff
==============================================================================
--- velocity/engine/trunk/test/macroforwarddefine/macros.vm (original)
+++ velocity/engine/trunk/test/macroforwarddefine/macros.vm Wed Feb  4 20:30:19 
2009
@@ -35,3 +35,6 @@
 #test3("foo", "bar")
 #test4("foo", "bar")
 
+...@test1("foo", "bar")#end
+...@test1("foo")#end
+...@test1()#end


Reply via email to