Ejemplo n.º 1
0
def test_int_list_equality():
    ls = [1, 2, 3]
    x = IntList(ls)
    y = IntList(ls)

    assert ls != x
    assert x != ls
    assert not (x == ls)
    assert x == x
    assert x == y
Ejemplo n.º 2
0
def test_basic_equality():
    x = IntList([1, 2, 3])
    assert x == x
    t = x != x
    assert not t
    assert x != "foo"

    s = x == "foo"
    assert not s
Ejemplo n.º 3
0
 def children(self):
     if self.__children is None:
         self.__children = [IntList() for _ in hrange(len(self))]
         for i, p in enumerate(self.parentage):
             if i > 0:
                 self.__children[p].append(i)
         # Replace empty children lists with a tuple to reduce
         # memory usage.
         for i, c in enumerate(self.__children):
             if not c:
                 self.__children[i] = ()
     return self.__children
Ejemplo n.º 4
0
def test_extend_by_too_large():
    x = IntList()
    ls = [1, 10**6]
    x.extend(ls)
    assert list(x) == ls
Ejemplo n.º 5
0
def test_error_on_invalid_value():
    with pytest.raises(ValueError):
        IntList([-1])
Ejemplo n.º 6
0
def test_distinct_int_lists_are_not_equal(x, y):
    assume(x != y)
    assert IntList(x) != IntList(y)
Ejemplo n.º 7
0
def test_intlist_is_equal_to_itself(ls):
    assert IntList(ls) == IntList(ls)
Ejemplo n.º 8
0
def test_int_list_can_contain_arbitrary_size():
    n = 2**65
    assert list(IntList([n])) == [n]
Ejemplo n.º 9
0
def test_int_list_cannot_contain_negative():
    with pytest.raises(ValueError):
        IntList([-1])
Ejemplo n.º 10
0
 def __init__(self, owner):
     self.owner = owner
     self.endpoints = IntList()
     self.__blocks = {}
     self.__count = 0
     self.__sparse = True
Ejemplo n.º 11
0
 def __init__(self):
     self.labels = [DRAW_BYTES_LABEL]
     self.__index_of_labels = {DRAW_BYTES_LABEL: 0}
     self.trail = IntList()
Ejemplo n.º 12
0
 def __copy__(self):
     result = IntegerNormalizer()
     result.__values = IntList(self.__values)
     return result
Ejemplo n.º 13
0
 def __init__(self):
     # We store canonical values as a sorted list of integers
     # with each value being treated as equivalent to the largest
     # integer in the list that is below it.
     self.__values = IntList([0])
Ejemplo n.º 14
0
 def starting_lists(self, ls):
     self.model = list(ls)
     self.target = IntList(ls)