Author: nbubna
Date: Tue May 18 22:21:41 2010
New Revision: 945927
URL: http://svn.apache.org/viewvc?rev=945927&view=rev
Log:
VELOCITY-763 fix $foreach.last
Added:
velocity/engine/trunk/src/test/org/apache/velocity/test/issues/Velocity762TestCase.java
(with props)
Modified:
velocity/engine/trunk/src/java/org/apache/velocity/runtime/directive/Foreach.java
Modified:
velocity/engine/trunk/src/java/org/apache/velocity/runtime/directive/Foreach.java
URL:
http://svn.apache.org/viewvc/velocity/engine/trunk/src/java/org/apache/velocity/runtime/directive/Foreach.java?rev=945927&r1=945926&r2=945927&view=diff
==============================================================================
---
velocity/engine/trunk/src/java/org/apache/velocity/runtime/directive/Foreach.java
(original)
+++
velocity/engine/trunk/src/java/org/apache/velocity/runtime/directive/Foreach.java
Tue May 18 22:21:41 2010
@@ -388,6 +388,12 @@ public class Foreach extends Directive
while (!maxNbrLoopsExceeded && i.hasNext())
{
+ // TODO: JDK 1.5+ -> Integer.valueOf()
+ put(context, counterName , new Integer(counter));
+ Object value = i.next();
+ put(context, hasNextName, Boolean.valueOf(i.hasNext()));
+ put(context, elementKey, value);
+
if (isScopeProvided())
{
// update the scope control
@@ -395,12 +401,6 @@ public class Foreach extends Directive
foreach.hasNext = i.hasNext();
}
- // TODO: JDK 1.5+ -> Integer.valueOf()
- put(context, counterName , new Integer(counter));
- Object value = i.next();
- put(context, hasNextName, Boolean.valueOf(i.hasNext()));
- put(context, elementKey, value);
-
try
{
/*
Added:
velocity/engine/trunk/src/test/org/apache/velocity/test/issues/Velocity762TestCase.java
URL:
http://svn.apache.org/viewvc/velocity/engine/trunk/src/test/org/apache/velocity/test/issues/Velocity762TestCase.java?rev=945927&view=auto
==============================================================================
---
velocity/engine/trunk/src/test/org/apache/velocity/test/issues/Velocity762TestCase.java
(added)
+++
velocity/engine/trunk/src/test/org/apache/velocity/test/issues/Velocity762TestCase.java
Tue May 18 22:21:41 2010
@@ -0,0 +1,40 @@
+package org.apache.velocity.test.issues;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+import org.apache.velocity.test.BaseTestCase;
+
+/**
+ * This class tests VELOCITY-762.
+ */
+public class Velocity762TestCase extends BaseTestCase
+{
+ public Velocity762TestCase(String name)
+ {
+ super(name);
+ }
+
+ public void testForeachIsLast()
+ {
+ String template = "#foreach( $i in [1..3] )$foreach.last #end";
+ assertEvalEquals("false false true ", template);
+ }
+
+}
Propchange:
velocity/engine/trunk/src/test/org/apache/velocity/test/issues/Velocity762TestCase.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange:
velocity/engine/trunk/src/test/org/apache/velocity/test/issues/Velocity762TestCase.java
------------------------------------------------------------------------------
svn:executable = *
Propchange:
velocity/engine/trunk/src/test/org/apache/velocity/test/issues/Velocity762TestCase.java
------------------------------------------------------------------------------
svn:keywords = Revision
Propchange:
velocity/engine/trunk/src/test/org/apache/velocity/test/issues/Velocity762TestCase.java
------------------------------------------------------------------------------
svn:mime-type = text/plain