You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@groovy.apache.org by jw...@apache.org on 2016/08/28 18:45:52 UTC
groovy git commit: Added test cases for Collection .intersect() and
.disjoint() (closes #402)
Repository: groovy
Updated Branches:
refs/heads/GROOVY_2_4_X daccd0b1c -> 0e50a796e
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/0e50a796
Tree: http://git-wip-us.apache.org/repos/asf/groovy/tree/0e50a796
Diff: http://git-wip-us.apache.org/repos/asf/groovy/diff/0e50a796
Branch: refs/heads/GROOVY_2_4_X
Commit: 0e50a796eb7d8c0c465124288ef020756d6bbf0f
Parents: daccd0b
Author: Youri Ackx <yo...@ackx.net>
Authored: Sun Aug 28 13:30:00 2016 +0200
Committer: John Wagenleitner <jw...@apache.org>
Committed: Sun Aug 28 11:32:24 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/0e50a796/src/test/groovy/GroovyMethodsTest.groovy
----------------------------------------------------------------------
diff --git a/src/test/groovy/GroovyMethodsTest.groovy b/src/test/groovy/GroovyMethodsTest.groovy
index dce0b56..5d198f4 100644
--- a/src/test/groovy/GroovyMethodsTest.groovy
+++ b/src/test/groovy/GroovyMethodsTest.groovy
@@ -1540,6 +1540,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() {
@@ -1555,12 +1556,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
@@ -1572,11 +1578,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 {
@@ -1610,6 +1620,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() {