Repository: groovy
Updated Branches:
  refs/heads/GROOVY_2_4_X ec1f3e3f0 -> 6778128eb


GROOVY-7699: collate() on an empty list is an empty list. (closes #205)


Project: http://git-wip-us.apache.org/repos/asf/groovy/repo
Commit: http://git-wip-us.apache.org/repos/asf/groovy/commit/6778128e
Tree: http://git-wip-us.apache.org/repos/asf/groovy/tree/6778128e
Diff: http://git-wip-us.apache.org/repos/asf/groovy/diff/6778128e

Branch: refs/heads/GROOVY_2_4_X
Commit: 6778128eb12c1a4672cc64add04080cdec9ced85
Parents: ec1f3e3
Author: Rahul Somasunderam <rahul....@gmail.com>
Authored: Sat Dec 5 16:58:31 2015 -0800
Committer: paulk <pa...@asert.com.au>
Committed: Fri Jul 29 20:50:53 2016 +1000

----------------------------------------------------------------------
 .../groovy/runtime/DefaultGroovyMethods.java    | 48 ++++++++++----------
 src/test/groovy/CollateTest.groovy              |  4 +-
 2 files changed, 26 insertions(+), 26 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/groovy/blob/6778128e/src/main/org/codehaus/groovy/runtime/DefaultGroovyMethods.java
----------------------------------------------------------------------
diff --git a/src/main/org/codehaus/groovy/runtime/DefaultGroovyMethods.java 
b/src/main/org/codehaus/groovy/runtime/DefaultGroovyMethods.java
index 38bf5f1..53b406d 100644
--- a/src/main/org/codehaus/groovy/runtime/DefaultGroovyMethods.java
+++ b/src/main/org/codehaus/groovy/runtime/DefaultGroovyMethods.java
@@ -3051,7 +3051,7 @@ public class DefaultGroovyMethods extends 
DefaultGroovyMethodsSupport {
     public static <T> List<List<T>> collate(Iterable<T> self, int size, int 
step, boolean keepRemainder) {
         List<T> selfList = asList(self);
         List<List<T>> answer = new ArrayList<List<T>>();
-        if (size <= 0 || selfList.isEmpty()) {
+        if (size <= 0) {
             answer.add(selfList);
         } else {
             for (int pos = 0; pos < selfList.size() && pos > -1; pos += step) {
@@ -6223,7 +6223,7 @@ public class DefaultGroovyMethods extends 
DefaultGroovyMethodsSupport {
      * @see #min(Iterable)
      * @since 1.0
      */
-    @Deprecated 
+    @Deprecated
     public static <T> T min(Collection<T> self) {
         return GroovyCollections.min(self);
     }
@@ -11257,7 +11257,7 @@ public class DefaultGroovyMethods extends 
DefaultGroovyMethodsSupport {
     /**
      * Create a Collection composed of the intersection of both collections.  
Any
      * elements that exist in both collections are added to the resultant 
collection.
-     * For collection of custom objects; objects should implement 
java.lang.Comparable  
+     * For collection of custom objects; objects should implement 
java.lang.Comparable
      * <pre class="groovyTestCase">assert [4,5] == 
[1,2,3,4,5].intersect([4,5,6,7,8])</pre>
      *
      * @param left  a Collection
@@ -11293,7 +11293,7 @@ public class DefaultGroovyMethods extends 
DefaultGroovyMethodsSupport {
     /**
      * Create a Collection composed of the intersection of both iterables.  Any
      * elements that exist in both iterables are added to the resultant 
collection.
-     * For collection of custom objects; objects should implement 
java.lang.Comparable  
+     * For collection of custom objects; objects should implement 
java.lang.Comparable
      * <pre class="groovyTestCase">assert [4,5] == 
[1,2,3,4,5].intersect([4,5,6,7,8])</pre>
      *
      * @param left  an Iterable
@@ -14364,7 +14364,7 @@ public class DefaultGroovyMethods extends 
DefaultGroovyMethodsSupport {
                 closure.call(i);
             }
         } else
-            throw new GroovyRuntimeException("The argument (" + to + 
+            throw new GroovyRuntimeException("The argument (" + to +
                     ") to upto() cannot be less than the value (" + self + ") 
it's called on.");
     }
 
@@ -14384,7 +14384,7 @@ public class DefaultGroovyMethods extends 
DefaultGroovyMethodsSupport {
                 closure.call(i);
             }
         } else
-            throw new GroovyRuntimeException("The argument (" + to + 
+            throw new GroovyRuntimeException("The argument (" + to +
                     ") to upto() cannot be less than the value (" + self + ") 
it's called on.");
     }
 
@@ -14404,7 +14404,7 @@ public class DefaultGroovyMethods extends 
DefaultGroovyMethodsSupport {
                 closure.call(i);
             }
         } else
-            throw new GroovyRuntimeException("The argument (" + to + 
+            throw new GroovyRuntimeException("The argument (" + to +
                     ") to upto() cannot be less than the value (" + self + ") 
it's called on.");
     }
 
@@ -14424,7 +14424,7 @@ public class DefaultGroovyMethods extends 
DefaultGroovyMethodsSupport {
                 closure.call(i);
             }
         } else
-            throw new GroovyRuntimeException("The argument (" + to + 
+            throw new GroovyRuntimeException("The argument (" + to +
                     ") to upto() cannot be less than the value (" + self + ") 
it's called on.");
     }
 
@@ -14444,7 +14444,7 @@ public class DefaultGroovyMethods extends 
DefaultGroovyMethodsSupport {
                 closure.call(i);
             }
         } else
-            throw new GroovyRuntimeException("The argument (" + to + 
+            throw new GroovyRuntimeException("The argument (" + to +
                     ") to upto() cannot be less than the value (" + self + ") 
it's called on.");
     }
 
@@ -14464,7 +14464,7 @@ public class DefaultGroovyMethods extends 
DefaultGroovyMethodsSupport {
                 closure.call(i);
             }
         } else
-            throw new GroovyRuntimeException("The argument (" + to + 
+            throw new GroovyRuntimeException("The argument (" + to +
                     ") to upto() cannot be less than the value (" + self + ") 
it's called on.");
     }
 
@@ -14484,7 +14484,7 @@ public class DefaultGroovyMethods extends 
DefaultGroovyMethodsSupport {
                 closure.call(i);
             }
         } else
-            throw new GroovyRuntimeException("The argument (" + to + 
+            throw new GroovyRuntimeException("The argument (" + to +
                     ") to upto() cannot be less than the value (" + self + ") 
it's called on.");
     }
 
@@ -14562,7 +14562,7 @@ public class DefaultGroovyMethods extends 
DefaultGroovyMethodsSupport {
                     closure.call(i);
                 }
             } else
-                throw new GroovyRuntimeException("The argument (" + to + 
+                throw new GroovyRuntimeException("The argument (" + to +
                         ") to upto() cannot be less than the value (" + self + 
") it's called on.");
         } else if (to instanceof BigInteger) {
             BigDecimal to1 = new BigDecimal((BigInteger) to);
@@ -14571,7 +14571,7 @@ public class DefaultGroovyMethods extends 
DefaultGroovyMethodsSupport {
                     closure.call(i);
                 }
             } else
-                throw new GroovyRuntimeException("The argument (" + to + 
+                throw new GroovyRuntimeException("The argument (" + to +
                         ") to upto() cannot be less than the value (" + self + 
") it's called on.");
         } else {
             BigDecimal to1 = new BigDecimal(to.toString());
@@ -14580,7 +14580,7 @@ public class DefaultGroovyMethods extends 
DefaultGroovyMethodsSupport {
                     closure.call(i);
                 }
             } else
-                throw new GroovyRuntimeException("The argument (" + to + 
+                throw new GroovyRuntimeException("The argument (" + to +
                         ") to upto() cannot be less than the value (" + self + 
") it's called on.");
         }
     }
@@ -14602,7 +14602,7 @@ public class DefaultGroovyMethods extends 
DefaultGroovyMethodsSupport {
                 closure.call(i);
             }
         } else
-            throw new GroovyRuntimeException("The argument (" + to + 
+            throw new GroovyRuntimeException("The argument (" + to +
                     ") to downto() cannot be greater than the value (" + self 
+ ") it's called on.");
     }
 
@@ -14622,7 +14622,7 @@ public class DefaultGroovyMethods extends 
DefaultGroovyMethodsSupport {
                 closure.call(i);
             }
         } else
-            throw new GroovyRuntimeException("The argument (" + to + 
+            throw new GroovyRuntimeException("The argument (" + to +
                     ") to downto() cannot be greater than the value (" + self 
+ ") it's called on.");
     }
 
@@ -14642,7 +14642,7 @@ public class DefaultGroovyMethods extends 
DefaultGroovyMethodsSupport {
                 closure.call(i);
             }
         } else
-            throw new GroovyRuntimeException("The argument (" + to + 
+            throw new GroovyRuntimeException("The argument (" + to +
                     ") to downto() cannot be greater than the value (" + self 
+ ") it's called on.");
     }
 
@@ -14662,7 +14662,7 @@ public class DefaultGroovyMethods extends 
DefaultGroovyMethodsSupport {
                 closure.call(i);
             }
         } else
-            throw new GroovyRuntimeException("The argument (" + to + 
+            throw new GroovyRuntimeException("The argument (" + to +
                     ") to downto() cannot be greater than the value (" + self 
+ ") it's called on.");    }
 
     /**
@@ -14681,7 +14681,7 @@ public class DefaultGroovyMethods extends 
DefaultGroovyMethodsSupport {
                 closure.call(i);
             }
         } else
-            throw new GroovyRuntimeException("The argument (" + to + 
+            throw new GroovyRuntimeException("The argument (" + to +
                     ") to downto() cannot be greater than the value (" + self 
+ ") it's called on.");    }
 
     /**
@@ -14700,7 +14700,7 @@ public class DefaultGroovyMethods extends 
DefaultGroovyMethodsSupport {
                 closure.call(i);
             }
         } else
-            throw new GroovyRuntimeException("The argument (" + to + 
+            throw new GroovyRuntimeException("The argument (" + to +
                     ") to downto() cannot be greater than the value (" + self 
+ ") it's called on.");    }
 
     /**
@@ -14719,7 +14719,7 @@ public class DefaultGroovyMethods extends 
DefaultGroovyMethodsSupport {
                 closure.call(i);
             }
         } else
-            throw new GroovyRuntimeException("The argument (" + to + 
+            throw new GroovyRuntimeException("The argument (" + to +
                     ") to downto() cannot be greater than the value (" + self 
+ ") it's called on.");    }
 
     /**
@@ -14794,7 +14794,7 @@ public class DefaultGroovyMethods extends 
DefaultGroovyMethodsSupport {
                     closure.call(i);
                 }
             } else
-                throw new GroovyRuntimeException("The argument (" + to + 
+                throw new GroovyRuntimeException("The argument (" + to +
                         ") to downto() cannot be greater than the value (" + 
self + ") it's called on.");        } else if (to instanceof BigInteger) {
             BigDecimal to1 = new BigDecimal((BigInteger) to);
             if (self.compareTo(to1) >= 0) {
@@ -14802,7 +14802,7 @@ public class DefaultGroovyMethods extends 
DefaultGroovyMethodsSupport {
                     closure.call(i);
                 }
             } else
-                throw new GroovyRuntimeException("The argument (" + to + 
+                throw new GroovyRuntimeException("The argument (" + to +
                         ") to downto() cannot be greater than the value (" + 
self + ") it's called on.");        } else {
             BigDecimal to1 = new BigDecimal(to.toString());
             if (self.compareTo(to1) >= 0) {
@@ -14810,7 +14810,7 @@ public class DefaultGroovyMethods extends 
DefaultGroovyMethodsSupport {
                     closure.call(i);
                 }
             } else
-                throw new GroovyRuntimeException("The argument (" + to + 
+                throw new GroovyRuntimeException("The argument (" + to +
                         ") to downto() cannot be greater than the value (" + 
self + ") it's called on.");        }
     }
 

http://git-wip-us.apache.org/repos/asf/groovy/blob/6778128e/src/test/groovy/CollateTest.groovy
----------------------------------------------------------------------
diff --git a/src/test/groovy/CollateTest.groovy 
b/src/test/groovy/CollateTest.groovy
index 580fb6c..e08172a 100644
--- a/src/test/groovy/CollateTest.groovy
+++ b/src/test/groovy/CollateTest.groovy
@@ -75,7 +75,7 @@ class CollateTest extends GroovyTestCase {
   }
 
   void testEmpty() {
-    assert [].collate( 3 ) == [[]]
+    assert [].collate( 3 ) == []
   }
 
   void testZero() {
@@ -115,4 +115,4 @@ class CollateTest extends GroovyTestCase {
     def list = [ 'tim', 20, 'dave', 14, 'steve', 23 ]
     assert list.collate( 2 ).transpose() == [ [ 'tim', 'dave', 'steve' ], [ 
20, 14, 23 ] ]
   }
-}
\ No newline at end of file
+}

Reply via email to