def test_Lens_over(): my_lens = b.Lens(lambda a: a[:-1], lambda s, a: a + '!') state = 'hello!' assert my_lens.over(state, lambda a: a.replace('lo', 'p')) == 'help!'
def test_Lens_meaningful_repr(): getter = lambda s: s setter = lambda s, f: f l = b.Lens(getter, setter) assert repr(getter) in repr(l) assert repr(setter) in repr(l)
def test_Lens_set(): my_lens = b.Lens(lambda a: a[:-1], lambda s, a: a + '!') state = 'hello!' assert my_lens.set(state, 'bye') == 'bye!'
def test_Lens_view(): my_lens = b.Lens(lambda a: a[:-1], lambda s, a: a + '!') state = 'hello!' assert my_lens.view(state) == 'hello'
def test_Lens_over(): my_lens = b.Lens(lambda a: a[:-1], lambda s, a: a + "!") state = "hello!" assert my_lens.over(state, lambda a: a.replace("lo", "p")) == "help!"
def test_Lens_set(): my_lens = b.Lens(lambda a: a[:-1], lambda s, a: a + "!") state = "hello!" assert my_lens.set(state, "bye") == "bye!"
def test_Lens_view(): my_lens = b.Lens(lambda a: a[:-1], lambda s, a: a + "!") state = "hello!" assert my_lens.view(state) == "hello"