Skip to content

Commit

Permalink
feat(#139): eager iterators
Browse files Browse the repository at this point in the history
Fixes #139
  • Loading branch information
MartinBernstorff committed Mar 9, 2024
1 parent eeddb34 commit 5b863ba
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 0 deletions.
7 changes: 7 additions & 0 deletions iterpy/test_arr.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,13 @@
from collections.abc import Sequence


def test_inexhaustable():
test_input = [1, 2, 3]
test_iterator = Arr(test_input)
assert test_iterator.to_list() == test_input
assert test_iterator.to_list() == test_input


def test_chaining():
iterator = Arr([1, 2])
result: list[int] = iterator.filter(lambda x: x % 2 == 0).map(lambda x: x * 2).to_list()
Expand Down
7 changes: 7 additions & 0 deletions iterpy/test_iter.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,13 @@ def test_chaining():
assert result == [4]


def test_exhaustable():
test_input = [1, 2, 3]
test_iterator = Iter(test_input)
assert test_iterator.to_list() == test_input
assert test_iterator.to_list() == []


def test_map():
iterator = Iter([1, 2])
result: list[int] = iterator.map(lambda x: x * 2).to_list()
Expand Down

0 comments on commit 5b863ba

Please sign in to comment.