velocity-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From wgl...@apache.org
Subject svn commit: r674729 - in /velocity/engine/trunk: src/java/org/apache/velocity/runtime/parser/node/ src/test/org/apache/velocity/test/issues/ test/issues/velocity-537/compare/ test/issues/velocity-537/templates/
Date Tue, 08 Jul 2008 06:12:47 GMT
Author: wglass
Date: Mon Jul  7 23:12:47 2008
New Revision: 674729

URL: http://svn.apache.org/viewvc?rev=674729&view=rev
Log:
Do not erroneously display *# inside of macros with multiline comments.  Fix thanks to Marnix
van Bochove.  VELOCITY-537, VELOCITY-580.

Added:
    velocity/engine/trunk/test/issues/velocity-537/compare/velocity537b.vm.cmp   (with props)
    velocity/engine/trunk/test/issues/velocity-537/templates/velocity537b.vm   (with props)
Modified:
    velocity/engine/trunk/src/java/org/apache/velocity/runtime/parser/node/NodeUtils.java
    velocity/engine/trunk/src/test/org/apache/velocity/test/issues/Velocity537TestCase.java

Modified: velocity/engine/trunk/src/java/org/apache/velocity/runtime/parser/node/NodeUtils.java
URL: http://svn.apache.org/viewvc/velocity/engine/trunk/src/java/org/apache/velocity/runtime/parser/node/NodeUtils.java?rev=674729&r1=674728&r2=674729&view=diff
==============================================================================
--- velocity/engine/trunk/src/java/org/apache/velocity/runtime/parser/node/NodeUtils.java
(original)
+++ velocity/engine/trunk/src/java/org/apache/velocity/runtime/parser/node/NodeUtils.java
Mon Jul  7 23:12:47 2008
@@ -21,6 +21,7 @@
 
 import org.apache.velocity.context.Context;
 import org.apache.velocity.exception.MethodInvocationException;
+import org.apache.velocity.runtime.parser.ParserConstants;
 import org.apache.velocity.runtime.parser.Token;
 
 /**
@@ -148,9 +149,20 @@
      */
     public static String tokenLiteral( Token t )
     {
-        return specialText( t ) + t.image;
-    }
+      String result;
 
+      // Look at kind of token and return "" when it's a multiline comment
+      if (t.kind == ParserConstants.MULTI_LINE_COMMENT) 
+      {
+        result = "";
+      } 
+      else 
+      {
+        result = specialText( t ) + t.image;
+      }
+      return result;
+    } 
+    
     /**
      * Utility method to interpolate context variables
      * into string literals. So that the following will

Modified: velocity/engine/trunk/src/test/org/apache/velocity/test/issues/Velocity537TestCase.java
URL: http://svn.apache.org/viewvc/velocity/engine/trunk/src/test/org/apache/velocity/test/issues/Velocity537TestCase.java?rev=674729&r1=674728&r2=674729&view=diff
==============================================================================
--- velocity/engine/trunk/src/test/org/apache/velocity/test/issues/Velocity537TestCase.java
(original)
+++ velocity/engine/trunk/src/test/org/apache/velocity/test/issues/Velocity537TestCase.java
Mon Jul  7 23:12:47 2008
@@ -22,6 +22,7 @@
 import org.apache.velocity.Template;
 import org.apache.velocity.VelocityContext;
 import org.apache.velocity.app.Velocity;
+import org.apache.velocity.app.VelocityEngine;
 import org.apache.velocity.runtime.RuntimeSingleton;
 import org.apache.velocity.runtime.log.NullLogChute;
 import org.apache.velocity.test.BaseTestCase;
@@ -66,16 +67,18 @@
         return new TestSuite(Velocity537TestCase.class);
     }
 
+    private VelocityEngine velocityEngine;
     public void setUp() throws Exception
     {
 
         assureResultsDirectoryExists(RESULTS_DIR);
 
-        Velocity.addProperty(Velocity.FILE_RESOURCE_LOADER_PATH, TEMPLATE_DIR);
+        velocityEngine = new VelocityEngine();
+        velocityEngine.addProperty(Velocity.FILE_RESOURCE_LOADER_PATH, TEMPLATE_DIR);
 
-        Velocity.setProperty(Velocity.RUNTIME_LOG_LOGSYSTEM_CLASS, NullLogChute.class.getName());
+        velocityEngine.setProperty(Velocity.RUNTIME_LOG_LOGSYSTEM_CLASS, NullLogChute.class.getName());
 
-        Velocity.init();
+        velocityEngine.init();
     }
 
     public void testVelocity537() throws Exception
@@ -83,9 +86,14 @@
         executeTest("velocity537.vm");
     }
 
+    public void testVelocity537Again() throws Exception
+    {
+        executeTest("velocity537b.vm");
+    }
+
     protected Template executeTest(final String templateName) throws Exception
     {
-        Template template = RuntimeSingleton.getTemplate(templateName);
+        Template template = velocityEngine.getTemplate(templateName);
 
         FileOutputStream fos = new FileOutputStream(getFileName(RESULTS_DIR, templateName,
RESULT_FILE_EXT));
 

Added: velocity/engine/trunk/test/issues/velocity-537/compare/velocity537b.vm.cmp
URL: http://svn.apache.org/viewvc/velocity/engine/trunk/test/issues/velocity-537/compare/velocity537b.vm.cmp?rev=674729&view=auto
==============================================================================
--- velocity/engine/trunk/test/issues/velocity-537/compare/velocity537b.vm.cmp (added)
+++ velocity/engine/trunk/test/issues/velocity-537/compare/velocity537b.vm.cmp Mon Jul  7
23:12:47 2008
@@ -0,0 +1 @@
+b
\ No newline at end of file

Propchange: velocity/engine/trunk/test/issues/velocity-537/compare/velocity537b.vm.cmp
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: velocity/engine/trunk/test/issues/velocity-537/compare/velocity537b.vm.cmp
------------------------------------------------------------------------------
    svn:keywords = Id Author Date Revision

Added: velocity/engine/trunk/test/issues/velocity-537/templates/velocity537b.vm
URL: http://svn.apache.org/viewvc/velocity/engine/trunk/test/issues/velocity-537/templates/velocity537b.vm?rev=674729&view=auto
==============================================================================
--- velocity/engine/trunk/test/issues/velocity-537/templates/velocity537b.vm (added)
+++ velocity/engine/trunk/test/issues/velocity-537/templates/velocity537b.vm Mon Jul  7 23:12:47
2008
@@ -0,0 +1,3 @@
+#macro( test )#*
+a*#b#end
+#test()
\ No newline at end of file

Propchange: velocity/engine/trunk/test/issues/velocity-537/templates/velocity537b.vm
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: velocity/engine/trunk/test/issues/velocity-537/templates/velocity537b.vm
------------------------------------------------------------------------------
    svn:keywords = Id Author Date Revision



Mime
View raw message