[2/2] groovy git commit: Fixes issue GROOVY-8537

2018-04-11 Thread paulk
Fixes issue GROOVY-8537

Ensures no combination is returned if any of the input iterables to
GroovyCollections.combinations() is empty.


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

Branch: refs/heads/GROOVY_2_6_X
Commit: c1eda75ba1b47227be59b31a45f8d35ff9e70322
Parents: 83391ce
Author: Venkatesh-Prasad Ranganath 
Authored: Sun Apr 8 12:45:18 2018 -0500
Committer: Paul King 
Committed: Wed Apr 11 16:39:25 2018 +1000

--
 src/main/groovy/groovy/util/GroovyCollections.java | 3 +++
 src/test/groovy/util/GroovyCollectionsTest.groovy  | 7 ++-
 2 files changed, 9 insertions(+), 1 deletion(-)
--


http://git-wip-us.apache.org/repos/asf/groovy/blob/c1eda75b/src/main/groovy/groovy/util/GroovyCollections.java
--
diff --git a/src/main/groovy/groovy/util/GroovyCollections.java 
b/src/main/groovy/groovy/util/GroovyCollections.java
index dff062d..3f637ef 100644
--- a/src/main/groovy/groovy/util/GroovyCollections.java
+++ b/src/main/groovy/groovy/util/GroovyCollections.java
@@ -118,6 +118,9 @@ public class GroovyCollections {
 }
 collectedCombos = newCombos;
 }
+
+if (collectedCombos.isEmpty()) 
+break;
 }
 return collectedCombos;
 }

http://git-wip-us.apache.org/repos/asf/groovy/blob/c1eda75b/src/test/groovy/util/GroovyCollectionsTest.groovy
--
diff --git a/src/test/groovy/util/GroovyCollectionsTest.groovy 
b/src/test/groovy/util/GroovyCollectionsTest.groovy
index d605e20..1678f5b 100644
--- a/src/test/groovy/util/GroovyCollectionsTest.groovy
+++ b/src/test/groovy/util/GroovyCollectionsTest.groovy
@@ -50,6 +50,11 @@ public class GroovyCollectionsTest extends GroovyTestCase {
 // collection versions should match Collection
 assert GroovyCollections.combinations(input) as Set == expected
 assert combinations(input) as Set == expected
+
+// an empty iterable should result in no combination
+assert combinations([[]] + input).isEmpty()
+assert combinations(input + [[]]).isEmpty()
+assert combinations(input + [[]] + input).isEmpty()
 }
 
 void testTranspose() {
@@ -114,4 +119,4 @@ public class GroovyCollectionsTest extends GroovyTestCase {
 void testHashCodeCollisionInMinus() {
 assert ([[1:2],[2:3]]-[["b":"a"]]) == [[1:2],[2:3]]
 }
-}
\ No newline at end of file
+}



[2/2] groovy git commit: Fixes issue GROOVY-8537

2018-04-11 Thread paulk
Fixes issue GROOVY-8537

Ensures no combination is returned if any of the input iterables to
GroovyCollections.combinations() is empty.


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

Branch: refs/heads/GROOVY_2_5_X
Commit: 3f1f925982925b9e7870d78718f018e2dd504cb3
Parents: 79374d3
Author: Venkatesh-Prasad Ranganath 
Authored: Sun Apr 8 12:45:18 2018 -0500
Committer: Paul King 
Committed: Wed Apr 11 16:40:00 2018 +1000

--
 src/main/groovy/groovy/util/GroovyCollections.java | 3 +++
 src/test/groovy/util/GroovyCollectionsTest.groovy  | 7 ++-
 2 files changed, 9 insertions(+), 1 deletion(-)
--


http://git-wip-us.apache.org/repos/asf/groovy/blob/3f1f9259/src/main/groovy/groovy/util/GroovyCollections.java
--
diff --git a/src/main/groovy/groovy/util/GroovyCollections.java 
b/src/main/groovy/groovy/util/GroovyCollections.java
index dff062d..3f637ef 100644
--- a/src/main/groovy/groovy/util/GroovyCollections.java
+++ b/src/main/groovy/groovy/util/GroovyCollections.java
@@ -118,6 +118,9 @@ public class GroovyCollections {
 }
 collectedCombos = newCombos;
 }
+
+if (collectedCombos.isEmpty()) 
+break;
 }
 return collectedCombos;
 }

http://git-wip-us.apache.org/repos/asf/groovy/blob/3f1f9259/src/test/groovy/util/GroovyCollectionsTest.groovy
--
diff --git a/src/test/groovy/util/GroovyCollectionsTest.groovy 
b/src/test/groovy/util/GroovyCollectionsTest.groovy
index d605e20..1678f5b 100644
--- a/src/test/groovy/util/GroovyCollectionsTest.groovy
+++ b/src/test/groovy/util/GroovyCollectionsTest.groovy
@@ -50,6 +50,11 @@ public class GroovyCollectionsTest extends GroovyTestCase {
 // collection versions should match Collection
 assert GroovyCollections.combinations(input) as Set == expected
 assert combinations(input) as Set == expected
+
+// an empty iterable should result in no combination
+assert combinations([[]] + input).isEmpty()
+assert combinations(input + [[]]).isEmpty()
+assert combinations(input + [[]] + input).isEmpty()
 }
 
 void testTranspose() {
@@ -114,4 +119,4 @@ public class GroovyCollectionsTest extends GroovyTestCase {
 void testHashCodeCollisionInMinus() {
 assert ([[1:2],[2:3]]-[["b":"a"]]) == [[1:2],[2:3]]
 }
-}
\ No newline at end of file
+}