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

1 import remedapy as R

2

3

4 class TestMap:

5 def test_data_first(self):

6 # R.map(data, callbackfn);

7

8 assert list(R.map([1, 2, 3], R.multiply(2))) == [2, 4, 6]

9 assert list(R.map([0, 0], R.add(1))) == [1, 1]

10 assert list(R.map([0, 0], lambda value, index: value + index)) == [0, 1]

11

12 def test_data_last(self):

13 # R.map(callbackfn)(data);

14

15 assert list(R.map(R.multiply(2))([1, 2, 3])) == [2, 4, 6]

16 assert list(R.map(R.add(1))([0, 0])) == [1, 1]

17

18 def add_index(value: int, index: int) -> int:

19 return value + index

20

21 assert list(R.map(add_index)([0, 0])) == [0, 1]

22

23 assert list(R.pipe([1, 2, 3], R.map(R.multiply(2)))) == [2, 4, 6]

24

25 assert list(R.pipe([0, 0], R.map(R.add(1)))) == [1, 1]

26 assert R.pipe([0, 0], R.map(add_index), list) == [0, 1]