-
Notifications
You must be signed in to change notification settings - Fork 7
/
test_recursive.py
67 lines (54 loc) · 1.5 KB
/
test_recursive.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
import pytest
from lambdas import ONE, TWO, THREE, FOUR, FIVE, SIX
from lambdas import FAC, FIB, DIV, MOD, MIN, MAX
from lambdas import decode_number
@pytest.mark.parametrize('given, expected', [
(THREE, 6),
(FOUR, 24),
])
def test_fac(given, expected):
assert decode_number(FAC(given)) == expected
@pytest.mark.parametrize('given, expected', [
(ONE, 1),
(TWO, 1),
(THREE, 2),
(FOUR, 3),
(FIVE, 5),
(SIX, 8),
])
def test_fib(given, expected):
assert decode_number(FIB(given)) == expected
@pytest.mark.parametrize('left, right, expected', [
(ONE, ONE, 1),
(TWO, ONE, 2),
(FOUR, TWO, 2),
(SIX, TWO, 3),
(FIVE, TWO, 2),
])
def test_div(left, right, expected):
assert decode_number(DIV(left)(right)) == expected
@pytest.mark.parametrize('left, right, expected', [
(ONE, ONE, 0),
(THREE, TWO, 1),
(FIVE, TWO, 1),
])
def test_mod(left, right, expected):
assert decode_number(MOD(left)(right)) == expected
@pytest.mark.parametrize('left, right, expected', [
(ONE, ONE, 1),
(TWO, ONE, 1),
(ONE, TWO, 1),
(THREE, FIVE, 3),
(FIVE, THREE, 3),
])
def test_min(left, right, expected):
assert decode_number(MIN(left)(right)) == expected
@pytest.mark.parametrize('left, right, expected', [
(ONE, ONE, 1),
(TWO, ONE, 2),
(ONE, TWO, 2),
(THREE, FIVE, 5),
(FIVE, THREE, 5),
])
def test_max(left, right, expected):
assert decode_number(MAX(left)(right)) == expected