예제 #1
0
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!'
예제 #2
0
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)
예제 #3
0
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!'
예제 #4
0
def test_Lens_view():
    my_lens = b.Lens(lambda a: a[:-1], lambda s, a: a + '!')
    state = 'hello!'
    assert my_lens.view(state) == 'hello'
예제 #5
0
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!"
예제 #6
0
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!"
예제 #7
0
def test_Lens_view():
    my_lens = b.Lens(lambda a: a[:-1], lambda s, a: a + "!")
    state = "hello!"
    assert my_lens.view(state) == "hello"