groovy-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jwagenleit...@apache.org
Subject groovy git commit: Added test cases for Collection .intersect() and .disjoint() (closes #402)
Date Sun, 28 Aug 2016 18:46:39 GMT
Repository: groovy
Updated Branches:
  refs/heads/master 3d3aa4ff0 -> 86eff312d


Added test cases for Collection .intersect() and .disjoint() (closes #402)


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

Branch: refs/heads/master
Commit: 86eff312de87015d9a7d7e8ff46288dd5b511ded
Parents: 3d3aa4f
Author: Youri Ackx <youri@ackx.net>
Authored: Sun Aug 28 13:30:00 2016 +0200
Committer: John Wagenleitner <jwagenleitner@apache.org>
Committed: Sun Aug 28 11:31:20 2016 -0700

----------------------------------------------------------------------
 src/test/groovy/GroovyMethodsTest.groovy | 15 +++++++++++++--
 1 file changed, 13 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/groovy/blob/86eff312/src/test/groovy/GroovyMethodsTest.groovy
----------------------------------------------------------------------
diff --git a/src/test/groovy/GroovyMethodsTest.groovy b/src/test/groovy/GroovyMethodsTest.groovy
index cbffeb5..cd05a95 100644
--- a/src/test/groovy/GroovyMethodsTest.groovy
+++ b/src/test/groovy/GroovyMethodsTest.groovy
@@ -1558,6 +1558,7 @@ class GroovyMethodsTest extends GroovyTestCase {
         assert [] == [].intersect([4, 5, 6, 7, 8])
         assert [] == [1, 2, 3, 4, 5].intersect([])
         assert [4, 5] == [1, 2, 3, 4, 5].intersect([4, 5, 6, 7, 8])
+        assert [[0, 1]] == [[0, 0], [0, 1]].intersect([[0, 1], [1, 1]])
     }
 
     void testIntersectForIterables() {
@@ -1573,12 +1574,17 @@ class GroovyMethodsTest extends GroovyTestCase {
         assert [4, 5] == iterableA.intersect(iterableB)
     }
 
-    // GROOVY-7602
     void testIntersectForMaps() {
+        // GROOVY-7602
         def list1 = [[language: 'Java'], [language: 'Groovy'], [language: 'Scala']]
         def list2 = [[language: 'Groovy'], [language: 'JRuby'], [language: 'Java']]
         def intersection = list1.intersect(list2)
         assert intersection == [[language: 'Groovy'], [language: 'Java']]
+
+        def locs1 = [[loc: [0, 1]], [loc: [1, 1]]]
+        def locs2 = [[loc: [2, 1]], [loc: [1, 1]]]
+        def locInter = [[loc: [1, 1]]]
+        assert [[loc: [1, 1]]] == locs1.intersect(locs2)
     }
 
     // GROOVY-7602
@@ -1590,11 +1596,15 @@ class GroovyMethodsTest extends GroovyTestCase {
         assert c1.intersect(c2)
     }
 
-    // GROOVY-7530
     void testDisjointForMaps() {
+        // GROOVY-7530
         def list1 = [[language: 'Java'], [language: 'Groovy'], [language: 'Scala']]
         def list2 = [[language: 'Groovy'], [language: 'JRuby'], [language: 'Java']]
         assert !list1.disjoint(list2)
+
+        def locs1 = [[loc: [0, 1]], [loc: [1, 1]]]
+        def locs2 = [[loc: [2, 1]], [loc: [1, 1]]]
+        assert !locs1.disjoint(locs2)
     }
 
     class Foo {
@@ -1628,6 +1638,7 @@ class GroovyMethodsTest extends GroovyTestCase {
         assert [1, 2, 3, 4, 5].disjoint([])
         assert ![1, 2, 3, 4, 5].disjoint([4, 5, 6, 7, 8])
         assert [1, 2, 3].disjoint([4, 5, 6, 7, 8])
+        assert ![[0, 0], [0, 1]].disjoint([[0, 1], [1, 1]])
     }
 
     void testDisjointForIterables() {


Mime
View raw message