add test case for Map.removeAll { }

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

Branch: refs/heads/master
Commit: 6981cd1d196c1348398842e0b166db0907d6ceef
Parents: 28777a3
Author: oreissig <oreissig+git...@gmail.com>
Authored: Mon Feb 1 20:03:24 2016 +0100
Committer: paulk <pa...@asert.com.au>
Committed: Fri Feb 5 11:20:28 2016 +1000

----------------------------------------------------------------------
 src/test/groovy/MapTest.groovy | 20 ++++++++++++++++++++
 1 file changed, 20 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/groovy/blob/6981cd1d/src/test/groovy/MapTest.groovy
----------------------------------------------------------------------
diff --git a/src/test/groovy/MapTest.groovy b/src/test/groovy/MapTest.groovy
index e97a10f..545fa14 100644
--- a/src/test/groovy/MapTest.groovy
+++ b/src/test/groovy/MapTest.groovy
@@ -146,6 +146,26 @@ class MapTest extends GroovyTestCase {
         assert map1 == control
     }
 
+    void testRemoveAll() {
+        // given:
+        def map1 = [a:1, b:2]
+        def map2 = [c:3, d:4]
+
+        // when: 'two parameters = key,value'
+        map1.removeAll { k,v ->
+            k == 'a'
+        }
+        // then:
+        assert map1 == [b:2]
+
+        // when: 'one parameter = entry'
+        map2.removeAll { e ->
+            e.value == 3
+        }
+        // then:
+        assert map2 == [d:4]
+    }
+
     void testPlusCollectionMapEntry() {
         def map1 = [a:1, b:2]
         def map2 = [c:3, d:4]

Reply via email to