Skip to content

Commit

Permalink
Fix bug with passage range
Browse files Browse the repository at this point in the history
  • Loading branch information
rcdilorenzo committed Apr 16, 2019
1 parent f8d11ef commit 035bc05
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 1 deletion.
2 changes: 1 addition & 1 deletion ecce/passage.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ def _to_string(sequential):
return f'{sequential[0]}-{sequential[-1]}'

def _reduce_verse(acc, number):
if len(acc) == 0 or len(acc[0]) == 0 or acc[0][-1] != (number - 1):
if len(acc) == 0 or len(acc[0]) == 0 or acc[-1][-1] != (number - 1):
return acc + [[number]]
else:
return acc[0:-1] + [acc[-1] + [number]]
Expand Down
16 changes: 16 additions & 0 deletions tests/test_passage.py
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,21 @@ def duplicates():
], None)
]

def discontiguous_verses():
assert passage.init([
reference.init('Genesis', 1, 5),
reference.init('Genesis', 1, 4),
reference.init('Genesis', 1, 2),
reference.init('Genesis', 1, 1)
]) == [
passage.Data('Genesis 1:1-2,4-5', [
reference.init('Genesis', 1, 1),
reference.init('Genesis', 1, 2),
reference.init('Genesis', 1, 4),
reference.init('Genesis', 1, 5)
], None)
]

def describe_text():
def single_verse():
assert passage.text([
Expand All @@ -111,3 +126,4 @@ def multiple_verses():
reference.init('Genesis', 1, 3)
], '2 The earth was without form and void, and darkness was over the face of the deep. And the Spirit of God was hovering over the face of the waters.\n3 And God said, "Let there be light," and there was light.')
]

0 comments on commit 035bc05

Please sign in to comment.