mirror of
https://github.com/Textualize/textual.git
synced 2025-10-17 02:38:12 +03:00
eof
This commit is contained in:
28
tests/test_loop.py
Normal file
28
tests/test_loop.py
Normal file
@@ -0,0 +1,28 @@
|
||||
from textual._loop import loop_first, loop_last, loop_first_last
|
||||
|
||||
|
||||
def test_loop_first():
|
||||
assert list(loop_first([])) == []
|
||||
iterable = loop_first(["apples", "oranges", "pears", "lemons"])
|
||||
assert next(iterable) == (True, "apples")
|
||||
assert next(iterable) == (False, "oranges")
|
||||
assert next(iterable) == (False, "pears")
|
||||
assert next(iterable) == (False, "lemons")
|
||||
|
||||
|
||||
def test_loop_last():
|
||||
assert list(loop_last([])) == []
|
||||
iterable = loop_last(["apples", "oranges", "pears", "lemons"])
|
||||
assert next(iterable) == (False, "apples")
|
||||
assert next(iterable) == (False, "oranges")
|
||||
assert next(iterable) == (False, "pears")
|
||||
assert next(iterable) == (True, "lemons")
|
||||
|
||||
|
||||
def test_loop_first_last():
|
||||
assert list(loop_first_last([])) == []
|
||||
iterable = loop_first_last(["apples", "oranges", "pears", "lemons"])
|
||||
assert next(iterable) == (True, False, "apples")
|
||||
assert next(iterable) == (False, False, "oranges")
|
||||
assert next(iterable) == (False, False, "pears")
|
||||
assert next(iterable) == (False, True, "lemons")
|
||||
Reference in New Issue
Block a user