예제 #1
0
파일: test_lens.py 프로젝트: suned/pfun
def test_list_root():
    l = [-1]
    assert lens()[0](1)(l) == [1]
    assert l == [-1]
예제 #2
0
파일: test_lens.py 프로젝트: suned/pfun
def test_pfun_list_attribute():
    x = VanillaClass(List([0]))
    assert lens().attribute[0](1)(x).attribute == List([1])
    assert x.attribute == List([0])
예제 #3
0
파일: test_lens.py 프로젝트: suned/pfun
def test_pfun_nested_list():
    l = List([List([-1])])
    assert lens()[0][0](1)(l) == List([List([1])])
    assert l == List([List([-1])])
예제 #4
0
파일: test_lens.py 프로젝트: suned/pfun
def test_pfun_dict_root():
    d = Dict({})
    assert lens()['key']('value')(d) == Dict({'key': 'value'})
    assert d == Dict({})
예제 #5
0
파일: test_lens.py 프로젝트: suned/pfun
def test_vanilla_class_root():
    x = VanillaClass('a')
    assert lens().attribute('b')(x).attribute == 'b'
    assert x.attribute == 'a'
예제 #6
0
파일: test_lens.py 프로젝트: suned/pfun
def test_tuple_index_error():
    t = ()
    with pytest.raises(IndexError):
        lens()[0](1)(t)
예제 #7
0
파일: test_lens.py 프로젝트: suned/pfun
def test_dict_root():
    d = {}
    assert lens()['key']('value')(d) == {'key': 'value'}
    assert d == {}
예제 #8
0
파일: test_lens.py 프로젝트: suned/pfun
def test_dict_immutable_attribute():
    x = ImmutableClass({})
    assert lens().attribute['key']('value')(x) == ImmutableClass(
        {'key': 'value'})
    assert x == ImmutableClass({})
예제 #9
0
파일: test_lens.py 프로젝트: suned/pfun
def test_pfun_dict_attribute():
    x = VanillaClass(Dict({}))
    assert lens().attribute['key']('value')(x).attribute == Dict(
        {'key': 'value'})
    assert x.attribute == Dict({})
예제 #10
0
파일: test_lens.py 프로젝트: suned/pfun
def test_tuple_immutable_attribute():
    x = ImmutableClass((0, ))
    assert lens().attribute[0](1)(x).attribute == (1, )
    assert x == ImmutableClass((0, ))
예제 #11
0
파일: test_lens.py 프로젝트: suned/pfun
def test_dict_attribute():
    x = VanillaClass({})
    assert lens().attribute['key']('value')(x).attribute == {'key': 'value'}
    assert x.attribute == {}
예제 #12
0
파일: test_lens.py 프로젝트: suned/pfun
def test_tuple_attribute():
    x = VanillaClass((0, ))
    assert lens().attribute[0](1)(x).attribute == (1, )
    assert x.attribute == (0, )
예제 #13
0
파일: test_lens.py 프로젝트: suned/pfun
def test_list_immutable_attribute():
    x = ImmutableClass([0])
    assert lens().attribute[0](1)(x) == ImmutableClass([1])
    assert x == ImmutableClass([0])
예제 #14
0
파일: test_lens.py 프로젝트: suned/pfun
def test_list_attribute():
    x = VanillaClass([0])
    assert lens().attribute[0](1)(x).attribute == [1]
    assert x.attribute == [0]
예제 #15
0
파일: test_lens.py 프로젝트: suned/pfun
def test_nested_list():
    l = [[0]]
    assert lens()[0][0](1)(l) == [[1]]
    assert l == [[0]]
예제 #16
0
파일: test_lens.py 프로젝트: suned/pfun
def test_nested_vanilla():
    x = VanillaClass(VanillaClass('a'))
    assert lens().attribute.attribute('b')(x).attribute.attribute == 'b'
    assert x.attribute.attribute == 'a'
예제 #17
0
파일: test_lens.py 프로젝트: suned/pfun
def test_tuple_root():
    t = (-1, )
    assert lens()[0](1)(t) == (1, )
    assert t == (-1, )
예제 #18
0
파일: test_lens.py 프로젝트: suned/pfun
def test_nested_immutable():
    x = ImmutableClass(ImmutableClass('a'))
    assert lens().attribute.attribute('b')(x) == ImmutableClass(
        ImmutableClass('b'))
    assert x == ImmutableClass(ImmutableClass('a'))
예제 #19
0
파일: test_lens.py 프로젝트: suned/pfun
def test_nested_tuple():
    t = ((-1, ), )
    assert lens()[0][0](1)(t) == ((1, ), )
    assert t == ((-1, ), )
예제 #20
0
파일: test_lens.py 프로젝트: suned/pfun
def test_nested_named_tuple():
    x = NamedTupleClass(NamedTupleClass('a'))
    assert lens().attribute.attribute('b')(x) == NamedTupleClass(
        NamedTupleClass('b'))
    assert x == NamedTupleClass(NamedTupleClass('a'))
예제 #21
0
파일: test_lens.py 프로젝트: suned/pfun
def test_nested_dict():
    d = {'key': {}}
    assert lens()['key']['key']('value')(d) == {'key': {'key': 'value'}}
    assert d == {'key': {}}
예제 #22
0
파일: test_lens.py 프로젝트: suned/pfun
def test_pfun_list_root():
    l = List([-1])
    assert lens()[0](1)(l) == List([1])
    assert l == List([-1])
예제 #23
0
파일: test_lens.py 프로젝트: suned/pfun
def test_nested_pfun_dict():
    d = Dict({'key': Dict({})})
    assert lens()['key']['key']('value')(d) == Dict(
        {'key': Dict({'key': 'value'})})
    assert d == Dict({'key': Dict({})})
예제 #24
0
파일: test_lens.py 프로젝트: suned/pfun
def test_pfun_list_index_error():
    l = List([])
    with pytest.raises(IndexError):
        lens()[0]('')(l)
예제 #25
0
파일: test_lens.py 프로젝트: suned/pfun
def test_immutable_class_root():
    x = ImmutableClass('a')
    assert lens().attribute('b')(x) == ImmutableClass('b')
    assert x == ImmutableClass('a')
예제 #26
0
파일: test_lens.py 프로젝트: suned/pfun
def test_named_tuple_root():
    x = NamedTupleClass('a')
    assert lens().attribute('b')(x) == NamedTupleClass('b')
    assert x == NamedTupleClass('a')