Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def test_filter_m(self):
assert writer.filter_m(lambda v: writer.value(v % 2 == 0),
range(3)) == writer.value((0, 2))
def test_map_m(self):
assert writer.map_m(writer.value, range(3)) == writer.value((0, 1, 2))
def test_composition_law(self, f, g, value):
h = compose(f, g)
assert writer.value(value).map(h) == writer.value(value).map(g).map(f)
def test_inequality(self, first, second, monoid):
assume(first != second)
assert writer.value(first, monoid) != writer.value(second, monoid)
def test_right_identity_law(self, value, monoid):
assert (
writer.value(value,
monoid).and_then(writer.value
) == writer.value(value, monoid)
)
def test_identity_law(self, value):
assert writer.value(value).map(identity) == writer.value(value)
def test_sequence(self):
assert writer.sequence([writer.value(v)
for v in range(3)]) == writer.value((0, 1, 2))
def test_stack_safety():
for _ in range(500):
yield writer.value(1)
return None