Coverage for src / tests / test_tap.py: 100%

15 statements  

« prev     ^ index     » next       coverage.py v7.13.2, created at 2026-02-02 10:52 +0100

1import remedapy as R 

2from tests.util import Spy 

3 

4 

5class TestTap: 

6 def test_data_first(self): 

7 # R.tap(value, fn); 

8 spy = Spy() 

9 assert R.tap('foo', spy) == 'foo' 

10 assert spy.calls == [('foo',)] 

11 

12 def test_data_last(self): 

13 # R.tap(fn)(value); 

14 spy = Spy() 

15 

16 def bigger_than_zero(n: int) -> bool: 

17 return n > 0 

18 

19 def times_two(n: int) -> int: 

20 return n * 2 

21 

22 assert R.pipe( 

23 [-5, -1, 2, 3], 

24 R.filter(bigger_than_zero), 

25 list, 

26 R.tap(spy), 

27 R.map(times_two), 

28 list, 

29 ) == [4, 6] 

30 assert spy.calls == [([2, 3],)]