Skip to content
This repository has been archived by the owner on May 31, 2020. It is now read-only.

Commit

Permalink
add implementation for set.intersection_update()
Browse files Browse the repository at this point in the history
  • Loading branch information
stummjr committed Nov 20, 2016
1 parent a911d02 commit fb8a580
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 2 deletions.
6 changes: 4 additions & 2 deletions python/common/org/python/types/Set.java
Expand Up @@ -392,10 +392,12 @@ public org.python.Object intersection(org.python.Object other) {
}

@org.python.Method(
__doc__ = ""
__doc__ = "Update a set with the intersection of itself and another.",
args = {"other"}
)
public org.python.Object intersection_update(org.python.Object other) {
throw new org.python.exceptions.NotImplementedError("intersection_update() has not been implemented.");
this.value.retainAll(((Set) other).value);
return org.python.types.NoneType.NONE;
}

@org.python.Method(
Expand Down
8 changes: 8 additions & 0 deletions tests/datatypes/test_set.py
Expand Up @@ -139,6 +139,14 @@ def test_difference_update(self):
print(x)
""")

def test_intersection_update(self):
self.assertCodeExecution("""
x = {1, 2, 3}
y = {3, 4, 5}
x.intersection_update(y)
print(x)
""")


class UnarySetOperationTests(UnaryOperationTestCase, TranspileTestCase):
data_type = 'set'
Expand Down

0 comments on commit fb8a580

Please sign in to comment.