Skip to content

Commit eeb7ab4

Browse files
ebonnalpierrenodet
andcommitted
add test_running_map_example
Co-authored-by: pierrenodet <[email protected]>
1 parent 663a44c commit eeb7ab4

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

tests/test_readme.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,16 @@ def test_starmap_example(self) -> None:
8989

9090
assert list(zeros) == [0, 0, 0, 0, 0, 0, 0, 0, 0, 0]
9191

92+
def test_running_map_example(self) -> None:
93+
from streamable import running
94+
95+
cumulative_sum: Stream[int] = (
96+
integers
97+
.map(running(lambda cumsum, i: cumsum + i, initial=0))
98+
)
99+
100+
assert list(cumulative_sum) == [0, 1, 3, 6, 10, 15, 21, 28, 36, 45]
101+
92102
def test_foreach_example(self) -> None:
93103
state: List[int] = []
94104
appending_integers: Stream[int] = integers.foreach(state.append)

0 commit comments

Comments
 (0)