Skip to content

Commit

Permalink
Fixed bug #7, overlap with empty range incorrectly returns True
Browse files Browse the repository at this point in the history
  • Loading branch information
runfalk committed May 17, 2017
1 parent 1df9980 commit ed9a79c
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 2 deletions.
8 changes: 8 additions & 0 deletions doc/changelog.rst
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,14 @@ first `0.1` release does not properly adhere to this. Unless explicitly stated,
changes are made by `Andreas Runfalk <https://github.com/runfalk>`_.


Version 1.0.0
-------------
Released on <unreleased>

- Fixed overlap with empty range incorrectly returns ``True``
(`bug #7 <https://github.com/runfalk/spans/issues/7>`_)


Version 0.5.0
-------------
Released on 16th April, 2017
Expand Down
4 changes: 2 additions & 2 deletions spans/types.py
Original file line number Diff line number Diff line change
Expand Up @@ -377,7 +377,7 @@ def overlap(self, other):
This is the same as the ``&&`` operator for two ranges in PostgreSQL.
:param other: Range to test against.
:return: ``True`` if ranges intersect, otherwise ``False``.
:return: ``True`` if ranges overlap, otherwise ``False``.
:raises TypeError: If `other` is of another type than this range.
.. seealso::
Expand All @@ -387,7 +387,7 @@ def overlap(self, other):

# Special case for empty ranges
if not self or not other:
return True
return False

if self < other:
a, b = self, other
Expand Down
4 changes: 4 additions & 0 deletions tests/test_range.py
Original file line number Diff line number Diff line change
Expand Up @@ -439,3 +439,7 @@ def test_intersection(a, b, intersection):
def test_pickling():
span = intrange(1, 10)
assert span == pickle.loads(pickle.dumps(span))


def test_bug7_overlap_empty():
assert not intrange(1, 10).overlap(intrange.empty())

0 comments on commit ed9a79c

Please sign in to comment.