-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathtest.py
28 lines (22 loc) · 788 Bytes
/
test.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
import unittest
from pipeto import *
from random import randint
def inc(x): return x + 1
def double(x): return x * 2
def neg(x): return 0 - x
class TestPipeto(unittest.TestCase):
def setUp(self):
self.true = self.assertTrue
def test_pipe(self):
for i in range(1, 100):
arg = randint(1, 1000000)
self.true(pipe(arg) | inc | done == inc(arg))
self.true(pipe(arg) | double | done == double(arg))
self.true(pipe(arg) | double | inc | neg | done == neg(inc(double(arg))))
def test_compose(self):
fn = compose(inc) | double | neg
for i in range(1, 100):
arg = randint(1, 1000000)
self.true(neg(double(inc(arg))) == fn(arg))
if __name__ == '__main__':
unittest.main()