Skip to content

Commit

Permalink
Tape.head goes at the end! (#130)
Browse files Browse the repository at this point in the history
Signed-off-by: Michel Hidalgo <[email protected]>
  • Loading branch information
mhidalgo-bdai authored Nov 20, 2024
1 parent 02ca14e commit 420f251
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
2 changes: 1 addition & 1 deletion bdai_ros2_wrappers/bdai_ros2_wrappers/utilities.py
Original file line number Diff line number Diff line change
Expand Up @@ -232,7 +232,7 @@ def head(self) -> Optional[T]:
return None
if len(self._content) == 0:
return None
return self._content[0]
return self._content[-1]

@overload
def content(
Expand Down
9 changes: 9 additions & 0 deletions bdai_ros2_wrappers/test/test_utilities.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,15 @@
from bdai_ros2_wrappers.utilities import Tape, either_or, ensure, namespace_with


def test_tape_head() -> None:
tape: Tape[int] = Tape()
assert tape.head is None
expected_sequence = list(range(10))
for i in expected_sequence:
tape.write(i)
assert tape.head == i


def test_tape_content_iteration() -> None:
tape: Tape[int] = Tape()
expected_sequence = list(range(10))
Expand Down

0 comments on commit 420f251

Please sign in to comment.