def test_lens_and(): my_lens = b.BothLens() & b.GetitemLens(1) assert my_lens.set([(0, 1), (2, 3)], 4) == [(0, 4), (2, 4)]
def test_ZoomLens_get(): l = b.GetitemLens(0) & b.ZoomLens() data = [lens([1, 2, 3])[1]] assert l.get(data) == 2
def test_ZoomLens_set(): l = b.GetitemLens(0) & b.ZoomLens() data = [lens([1, 2, 3])[1]] assert l.set(data, 7) == [[1, 7, 3]]
def test_ItemsLens_modify_empty(): my_lens = b.ItemsLens() & b.GetitemLens(0) assert my_lens.modify({}, lambda a: a + 1) == {}
def test_ItemsLens_modify(): data = {0: 'zero', 1: 'one'} my_lens = b.ItemsLens() & b.GetitemLens(0) assert my_lens.modify(data, lambda a: a + 1) == { 1: 'zero', 2: 'one'}
def test_GetitemLens_set(): assert b.GetitemLens(0).set([1, 2, 3], 4) == [4, 2, 3]
def test_GetitemLens_get(): assert b.GetitemLens(0).get([1, 2, 3]) == 1
def test_lens_add_lens_nontrivial_LensLike(): assert lens([1, 2]).add_lens(baselens.GetitemLens(1)).set(3) == [1, 3]