Beispiel #1
0
 def test_filter(self):
     assert filter_(lambda v: Done(v % 2 == 0), range(3)).run() == (0, 2)
Beispiel #2
0
 def test_sequence(self):
     assert sequence([Done(v) for v in range(3)]).run() == (0, 1, 2)
Beispiel #3
0
 def test_stack_safety(self):
     with recursion_limit(100):
         sequence([Done(v) for v in range(500)]).run()
Beispiel #4
0
 def test_composition_law(self, f, g, value):
     h = compose(f, g)
     assert Done(value).map(g).map(f).run() == Done(value).map(h).run()
Beispiel #5
0
 def test_identity_law(self, value):
     assert Done(value).map(identity).run() == Done(value).run()
Beispiel #6
0
 def test_inequality(self, first, second):
     assume(first != second)
     assert Done(first) != Done(second)
Beispiel #7
0
 def test_equality(self, value):
     assert Done(value) == Done(value)
Beispiel #8
0
 def test_left_identity_law(self, value, f):
     assert Done(value).and_then(f).run() == f(value).run()