Skip to content

Commit

Permalink
Add a few tests
Browse files Browse the repository at this point in the history
  • Loading branch information
bfontaine committed Oct 7, 2024
1 parent 1779767 commit 08da7b1
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 3 deletions.
7 changes: 7 additions & 0 deletions tests/test_fns.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,13 @@ def test_odd():
assert not c.is_odd(-2)


def test_comp_no_fn():
fn = c.comp()
assert fn() is None
assert fn(42) is None
assert fn("Hello, world!") is None


def test_comp():
def twice(n):
return n * 2
Expand Down
17 changes: 14 additions & 3 deletions tests/test_seqs.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import re
from collections import OrderedDict, Counter, deque, defaultdict
from typing import Iterable, Any
from typing import Iterable, Any, cast

import pytest

Expand Down Expand Up @@ -145,6 +145,7 @@ def test_rest():

def test_drop():
assert c.drop(10, infinite_range_fn()) is not None
assert list(c.drop(10, cast(Iterable, None))) == []
assert list(c.drop(0, [])) == []
assert list(c.drop(1000, [])) == []
assert list(c.drop(1000, [1, 2, 3, 4])) == []
Expand Down Expand Up @@ -445,11 +446,21 @@ def add_el():
els.append(42)

c.dorun(c.take(3, c.repeatedly(add_el)))
assert els == [42, 42, 42]
assert els == [42] * 3

els = []
c.dorun(c.repeatedly(add_el, 2))
assert els == [42, 42]
assert els == [42] * 2


def test_repeatedly_nf():
els = []

def add_el():
els.append(42)

c.dorun(c.repeatedly(3, add_el))
assert els == [42] * 3


def test_iterate():
Expand Down

0 comments on commit 08da7b1

Please sign in to comment.