Ejemplo n.º 1
0
    def test_rangelist(self):
        l = make_range_list(self.space, 1, 3, 7)
        assert isinstance(l.strategy, RangeListStrategy)
        v = l.pop(5)
        assert self.space.eq_w(v, self.space.wrap(16))
        assert isinstance(l.strategy, IntegerListStrategy)

        l = make_range_list(self.space, 1, 3, 7)
        assert isinstance(l.strategy, RangeListStrategy)
        v = l.pop(0)
        assert self.space.eq_w(v, self.space.wrap(1))
        assert isinstance(l.strategy, RangeListStrategy)
        v = l.pop(l.length() - 1)
        assert self.space.eq_w(v, self.space.wrap(19))
        assert isinstance(l.strategy, RangeListStrategy)
        v = l.pop_end()
        assert self.space.eq_w(v, self.space.wrap(16))
        assert isinstance(l.strategy, RangeListStrategy)

        l = make_range_list(self.space, 1, 3, 7)
        assert isinstance(l.strategy, RangeListStrategy)
        l.append(self.space.wrap("string"))
        assert isinstance(l.strategy, ObjectListStrategy)

        l = make_range_list(self.space, 1, 1, 5)
        assert isinstance(l.strategy, RangeListStrategy)
        l.append(self.space.wrap(19))
        assert isinstance(l.strategy, IntegerListStrategy)
Ejemplo n.º 2
0
    def test_rangelist(self):
        l = make_range_list(self.space, 1,3,7)
        assert isinstance(l.strategy, RangeListStrategy)
        v = l.pop(5)
        assert self.space.eq_w(v, self.space.wrap(16))
        assert isinstance(l.strategy, IntegerListStrategy)

        l = make_range_list(self.space, 1,3,7)
        assert isinstance(l.strategy, RangeListStrategy)
        v = l.pop(0)
        assert self.space.eq_w(v, self.space.wrap(1))
        assert isinstance(l.strategy, RangeListStrategy)
        v = l.pop(l.length() - 1)
        assert self.space.eq_w(v, self.space.wrap(19))
        assert isinstance(l.strategy, RangeListStrategy)
        v = l.pop_end()
        assert self.space.eq_w(v, self.space.wrap(16))
        assert isinstance(l.strategy, RangeListStrategy)

        l = make_range_list(self.space, 1,3,7)
        assert isinstance(l.strategy, RangeListStrategy)
        l.append(self.space.wrap("string"))
        assert isinstance(l.strategy, ObjectListStrategy)

        l = make_range_list(self.space, 1,1,5)
        assert isinstance(l.strategy, RangeListStrategy)
        l.append(self.space.wrap(19))
        assert isinstance(l.strategy, IntegerListStrategy)
Ejemplo n.º 3
0
    def test_range_reverse_ovf(self):
        l = make_range_list(self.space, 0, -sys.maxint - 1, 1)
        assert isinstance(l.strategy, RangeListStrategy)
        l.reverse()
        assert isinstance(l.strategy, IntegerListStrategy)

        l = make_range_list(self.space, 0, -sys.maxint - 1, 1)
        l.sort(False)
        assert isinstance(l.strategy, IntegerListStrategy)
Ejemplo n.º 4
0
    def test_range_reverse_ovf(self):
        l = make_range_list(self.space, 0, -sys.maxint - 1, 1)
        assert isinstance(l.strategy, RangeListStrategy)
        l.reverse()
        assert isinstance(l.strategy, IntegerListStrategy)

        l = make_range_list(self.space, 0, -sys.maxint - 1, 1)
        l.sort(False)
        assert isinstance(l.strategy, IntegerListStrategy)
Ejemplo n.º 5
0
    def test_empty_range(self):
        l = make_range_list(self.space, 0, 0, 0)
        assert isinstance(l.strategy, EmptyListStrategy)

        l = make_range_list(self.space, 1, 1, 10)
        for i in l.getitems():
            assert isinstance(l.strategy, RangeListStrategy)
            l.pop(l.length() - 1)

        assert isinstance(l.strategy, RangeListStrategy)
Ejemplo n.º 6
0
    def test_empty_range(self):
        l = make_range_list(self.space, 0, 0, 0)
        assert isinstance(l.strategy, EmptyListStrategy)

        l = make_range_list(self.space, 1, 1, 10)
        for i in l.getitems():
            assert isinstance(l.strategy, RangeListStrategy)
            l.pop(l.length()-1)

        assert isinstance(l.strategy, RangeListStrategy)
Ejemplo n.º 7
0
    def test_empty_extend_with_any(self):
        space = self.space
        w = space.wrap
        wb = space.wrapbytes

        empty = W_ListObject(space, [])
        assert isinstance(empty.strategy, EmptyListStrategy)
        empty.extend(W_ListObject(space, [w(1), w(2), w(3)]))
        assert isinstance(empty.strategy, IntegerListStrategy)

        empty = W_ListObject(space, [])
        assert isinstance(empty.strategy, EmptyListStrategy)
        empty.extend(W_ListObject(space, [wb("a"), wb("b"), wb("c")]))
        assert isinstance(empty.strategy, BytesListStrategy)

        empty = W_ListObject(space, [])
        assert isinstance(empty.strategy, EmptyListStrategy)
        empty.extend(W_ListObject(space, [w(u"a"), w(u"b"), w(u"c")]))
        assert isinstance(empty.strategy, UnicodeListStrategy)

        empty = W_ListObject(space, [])
        assert isinstance(empty.strategy, EmptyListStrategy)
        r = make_range_list(space, 1,3,7)
        empty.extend(r)
        assert isinstance(empty.strategy, RangeListStrategy)
        print empty.getitem(6)
        assert space.is_true(space.eq(empty.getitem(1), w(4)))

        empty = W_ListObject(space, [])
        assert isinstance(empty.strategy, EmptyListStrategy)
        r = make_range_list(space, 0, 1, 10)
        empty.extend(r)
        assert isinstance(empty.strategy, SimpleRangeListStrategy)
        assert space.is_true(space.eq(empty.getitem(1), w(1)))

        empty = W_ListObject(space, [])
        assert isinstance(empty.strategy, EmptyListStrategy)
        empty.extend(W_ListObject(space, [w(1), w(2), w(3)]))
        assert isinstance(empty.strategy, IntegerListStrategy)

        empty = W_ListObject(space, [])
        assert isinstance(empty.strategy, EmptyListStrategy)
        empty.extend(W_ListObject(space, [w(1.1), w(2.2), w(3.3)]))
        assert isinstance(empty.strategy, FloatListStrategy)

        empty = W_ListObject(space, [])
        assert isinstance(empty.strategy, EmptyListStrategy)
        empty.extend(W_ListObject(space, []))
        assert isinstance(empty.strategy, EmptyListStrategy)
Ejemplo n.º 8
0
    def test_empty_extend_with_any(self):
        empty = W_ListObject(self.space, [])
        assert isinstance(empty.strategy, EmptyListStrategy)
        empty.extend(W_ListObject(self.space, [self.space.wrap(1), self.space.wrap(2), self.space.wrap(3)]))
        assert isinstance(empty.strategy, IntegerListStrategy)

        empty = W_ListObject(self.space, [])
        assert isinstance(empty.strategy, EmptyListStrategy)
        empty.extend(W_ListObject(self.space, [self.space.wrap("a"), self.space.wrap("b"), self.space.wrap("c")]))
        assert isinstance(empty.strategy, StringListStrategy)

        empty = W_ListObject(self.space, [])
        assert isinstance(empty.strategy, EmptyListStrategy)
        r = make_range_list(self.space, 1,3,7)
        empty.extend(r)
        assert isinstance(empty.strategy, RangeListStrategy)
        print empty.getitem(6)
        assert self.space.is_true(self.space.eq(empty.getitem(1), self.space.wrap(4)))

        empty = W_ListObject(self.space, [])
        assert isinstance(empty.strategy, EmptyListStrategy)
        empty.extend(W_ListObject(self.space, [self.space.wrap(1), self.space.wrap(2), self.space.wrap(3)]))
        assert isinstance(empty.strategy, IntegerListStrategy)

        empty = W_ListObject(self.space, [])
        assert isinstance(empty.strategy, EmptyListStrategy)
        empty.extend(W_ListObject(self.space, []))
        assert isinstance(empty.strategy, EmptyListStrategy)
Ejemplo n.º 9
0
 def test_setslice_int_range(self):
     space = self.space
     w = space.wrap
     l = W_ListObject(space, [w(1), w(2), w(3)])
     assert isinstance(l.strategy, IntegerListStrategy)
     l.setslice(0, 1, 2, make_range_list(space, 5, 1, 4))
     assert isinstance(l.strategy, IntegerListStrategy)
Ejemplo n.º 10
0
 def test_weird_rangelist_bug(self):
     l = make_range_list(self.space, 1, 1, 3)
     from pypy.objspace.std.listobject import getslice__List_ANY_ANY
     # should not raise
     assert getslice__List_ANY_ANY(
         self.space, l, self.space.wrap(15), self.space.wrap(
             2222)).strategy == self.space.fromcache(EmptyListStrategy)
Ejemplo n.º 11
0
 def test_setslice_int_range(self):
     space = self.space
     w = space.wrap
     l = W_ListObject(space, [w(1), w(2), w(3)])
     assert isinstance(l.strategy, IntegerListStrategy)
     l.setslice(0, 1, 2, make_range_list(space, 5, 1, 4))
     assert isinstance(l.strategy, IntegerListStrategy)
Ejemplo n.º 12
0
    def test_keep_range(self):
        # simple list
        l = make_range_list(self.space, 1,1,5)
        assert isinstance(l.strategy, RangeListStrategy)
        x = l.pop(0)
        assert self.space.eq_w(x, self.space.wrap(1))
        assert isinstance(l.strategy, RangeListStrategy)
        l.pop(l.length()-1)
        assert isinstance(l.strategy, RangeListStrategy)
        l.append(self.space.wrap(5))
        assert isinstance(l.strategy, RangeListStrategy)

        # complex list
        l = make_range_list(self.space, 1,3,5)
        assert isinstance(l.strategy, RangeListStrategy)
        l.append(self.space.wrap(16))
        assert isinstance(l.strategy, RangeListStrategy)
Ejemplo n.º 13
0
 def test_getitems(self):
     w = self.space.wrap
     from pypy.objspace.std.listobject import make_range_list
     r = make_range_list(self.space, 1, 1, 7)
     l = [w(1), w(2), w(3), w(4), w(5), w(6), w(7)]
     l2 = r.getitems()
     for i in range(7):
         assert self.space.eq_w(l[i], l2[i])
Ejemplo n.º 14
0
 def test_weird_rangelist_bug(self):
     space = self.space
     l = make_range_list(space, 1, 1, 3)
     # should not raise
     w_slice = space.newslice(space.wrap(15), space.wrap(2222),
                              space.wrap(1))
     assert l.descr_getitem(
         space, w_slice).strategy == space.fromcache(EmptyListStrategy)
Ejemplo n.º 15
0
    def test_keep_range(self):
        # simple list
        l = make_range_list(self.space, 1, 1, 5)
        assert isinstance(l.strategy, RangeListStrategy)
        x = l.pop(0)
        assert self.space.eq_w(x, self.space.wrap(1))
        assert isinstance(l.strategy, RangeListStrategy)
        l.pop(l.length() - 1)
        assert isinstance(l.strategy, RangeListStrategy)
        l.append(self.space.wrap(5))
        assert isinstance(l.strategy, RangeListStrategy)

        # complex list
        l = make_range_list(self.space, 1, 3, 5)
        assert isinstance(l.strategy, RangeListStrategy)
        l.append(self.space.wrap(16))
        assert isinstance(l.strategy, RangeListStrategy)
Ejemplo n.º 16
0
 def test_getitems(self):
     w = self.space.wrap
     from pypy.objspace.std.listobject import make_range_list
     r = make_range_list(self.space, 1,1,7)
     l = [w(1),w(2),w(3),w(4),w(5),w(6),w(7)]
     l2 = r.getitems()
     for i in range(7):
         assert self.space.eq_w(l[i], l2[i])
Ejemplo n.º 17
0
 def test_add_of_range_and_int(self):
     l1 = make_range_list(self.space, 0, 1, 100)
     l2 = W_ListObject(
         self.space,
         [self.space.wrap(1),
          self.space.wrap(2),
          self.space.wrap(3)])
     l3 = self.space.add(l2, l1)
     assert l3.strategy is l2.strategy
Ejemplo n.º 18
0
    def test_getitems_fixedsize(self):
        w = self.space.wrap
        from pypy.objspace.std.listobject import make_range_list
        rangelist = make_range_list(self.space, 1, 1, 7)
        emptylist = W_ListObject(self.space, [])
        intlist = W_ListObject(
            self.space,
            [w(1), w(2), w(3), w(4), w(5),
             w(6), w(7)])
        strlist = W_ListObject(
            self.space,
            [w('1'), w('2'),
             w('3'), w('4'),
             w('5'), w('6'),
             w('7')])
        floatlist = W_ListObject(
            self.space,
            [w(1.0), w(2.0),
             w(3.0), w(4.0),
             w(5.0), w(6.0),
             w(7.0)])
        objlist = W_ListObject(
            self.space,
            [w(1), w('2'), w(3.0),
             w(4), w(5), w(6), w(7)])

        emptylist_copy = emptylist.getitems_fixedsize()
        assert emptylist_copy == []

        rangelist_copy = rangelist.getitems_fixedsize()
        intlist_copy = intlist.getitems_fixedsize()
        strlist_copy = strlist.getitems_fixedsize()
        floatlist_copy = floatlist.getitems_fixedsize()
        objlist_copy = objlist.getitems_fixedsize()
        for i in range(7):
            assert self.space.eq_w(rangelist_copy[i], rangelist.getitem(i))
            assert self.space.eq_w(intlist_copy[i], intlist.getitem(i))
            assert self.space.eq_w(strlist_copy[i], strlist.getitem(i))
            assert self.space.eq_w(floatlist_copy[i], floatlist.getitem(i))
            assert self.space.eq_w(objlist_copy[i], objlist.getitem(i))

        emptylist_copy = emptylist.getitems_unroll()
        assert emptylist_copy == []

        rangelist_copy = rangelist.getitems_unroll()
        intlist_copy = intlist.getitems_unroll()
        strlist_copy = strlist.getitems_unroll()
        floatlist_copy = floatlist.getitems_unroll()
        objlist_copy = objlist.getitems_unroll()
        for i in range(7):
            assert self.space.eq_w(rangelist_copy[i], rangelist.getitem(i))
            assert self.space.eq_w(intlist_copy[i], intlist.getitem(i))
            assert self.space.eq_w(strlist_copy[i], strlist.getitem(i))
            assert self.space.eq_w(floatlist_copy[i], floatlist.getitem(i))
            assert self.space.eq_w(objlist_copy[i], objlist.getitem(i))
Ejemplo n.º 19
0
    def test_empty_extend_with_any(self):
        empty = W_ListObject(self.space, [])
        assert isinstance(empty.strategy, EmptyListStrategy)
        empty.extend(
            W_ListObject(
                self.space,
                [self.space.wrap(1),
                 self.space.wrap(2),
                 self.space.wrap(3)]))
        assert isinstance(empty.strategy, IntegerListStrategy)

        empty = W_ListObject(self.space, [])
        assert isinstance(empty.strategy, EmptyListStrategy)
        empty.extend(
            W_ListObject(self.space, [
                self.space.wrap("a"),
                self.space.wrap("b"),
                self.space.wrap("c")
            ]))
        assert isinstance(empty.strategy, StringListStrategy)

        empty = W_ListObject(self.space, [])
        assert isinstance(empty.strategy, EmptyListStrategy)
        r = make_range_list(self.space, 1, 3, 7)
        empty.extend(r)
        assert isinstance(empty.strategy, RangeListStrategy)
        print empty.getitem(6)
        assert self.space.is_true(
            self.space.eq(empty.getitem(1), self.space.wrap(4)))

        empty = W_ListObject(self.space, [])
        assert isinstance(empty.strategy, EmptyListStrategy)
        empty.extend(
            W_ListObject(
                self.space,
                [self.space.wrap(1),
                 self.space.wrap(2),
                 self.space.wrap(3)]))
        assert isinstance(empty.strategy, IntegerListStrategy)

        empty = W_ListObject(self.space, [])
        assert isinstance(empty.strategy, EmptyListStrategy)
        empty.extend(
            W_ListObject(self.space, [
                self.space.wrap(1.1),
                self.space.wrap(2.2),
                self.space.wrap(3.3)
            ]))
        assert isinstance(empty.strategy, FloatListStrategy)

        empty = W_ListObject(self.space, [])
        assert isinstance(empty.strategy, EmptyListStrategy)
        empty.extend(W_ListObject(self.space, []))
        assert isinstance(empty.strategy, EmptyListStrategy)
Ejemplo n.º 20
0
 def test_range_setslice(self):
     l = make_range_list(self.space, 1, 3, 5)
     assert isinstance(l.strategy, RangeListStrategy)
     l.setslice(
         0, 1, 3,
         W_ListObject(
             self.space,
             [self.space.wrap(1),
              self.space.wrap(2),
              self.space.wrap(3)]))
     assert isinstance(l.strategy, IntegerListStrategy)
Ejemplo n.º 21
0
    def test_mul(self):
        l1 = W_ListObject(self.space, [self.space.wrap(1), self.space.wrap(2), self.space.wrap(3)])
        l2 = l1.mul(2)
        l3 = W_ListObject(self.space, [self.space.wrap(1), self.space.wrap(2), self.space.wrap(3), self.space.wrap(1), self.space.wrap(2), self.space.wrap(3)])
        assert self.space.eq_w(l2, l3)

        l4 = make_range_list(self.space, 1, 1, 3)
        assert self.space.eq_w(l4, l1)

        l5 = l4.mul(2)
        assert self.space.eq_w(l5, l3)
Ejemplo n.º 22
0
    def test_mul(self):
        l1 = W_ListObject(self.space, [self.space.wrap(1), self.space.wrap(2), self.space.wrap(3)])
        l2 = l1.mul(2)
        l3 = W_ListObject(self.space, [self.space.wrap(1), self.space.wrap(2), self.space.wrap(3), self.space.wrap(1), self.space.wrap(2), self.space.wrap(3)])
        assert self.space.eq_w(l2, l3)

        l4 = make_range_list(self.space, 1, 1, 3)
        assert self.space.eq_w(l4, l1)

        l5 = l4.mul(2)
        assert self.space.eq_w(l5, l3)
Ejemplo n.º 23
0
 def test_add_to_rangelist(self):
     l1 = make_range_list(self.space, 1, 1, 3)
     l2 = W_ListObject(self.space, [self.space.wrap(4), self.space.wrap(5)])
     l3 = l1.descr_add(self.space, l2)
     assert self.space.eq_w(
         l3,
         W_ListObject(self.space, [
             self.space.wrap(1),
             self.space.wrap(2),
             self.space.wrap(3),
             self.space.wrap(4),
             self.space.wrap(5)
         ]))
Ejemplo n.º 24
0
 def test_add_to_rangelist(self):
     l1 = make_range_list(self.space, 1, 1, 3)
     l2 = W_ListObject(self.space, [self.space.wrap(4), self.space.wrap(5)])
     from pypy.objspace.std.listobject import add__List_List
     l3 = add__List_List(self.space, l1, l2)
     assert self.space.eq_w(
         l3,
         W_ListObject(self.space, [
             self.space.wrap(1),
             self.space.wrap(2),
             self.space.wrap(3),
             self.space.wrap(4),
             self.space.wrap(5)
         ]))
Ejemplo n.º 25
0
    def test_getitems_fixedsize(self):
        w = self.space.wrap
        from pypy.objspace.std.listobject import make_range_list

        rangelist = make_range_list(self.space, 1, 1, 7)
        emptylist = W_ListObject(self.space, [])
        intlist = W_ListObject(self.space, [w(1), w(2), w(3), w(4), w(5), w(6), w(7)])
        strlist = W_ListObject(self.space, [w("1"), w("2"), w("3"), w("4"), w("5"), w("6"), w("7")])
        floatlist = W_ListObject(self.space, [w(1.0), w(2.0), w(3.0), w(4.0), w(5.0), w(6.0), w(7.0)])
        objlist = W_ListObject(self.space, [w(1), w("2"), w(3.0), w(4), w(5), w(6), w(7)])

        emptylist_copy = emptylist.getitems_fixedsize()
        assert emptylist_copy == []

        rangelist_copy = rangelist.getitems_fixedsize()
        intlist_copy = intlist.getitems_fixedsize()
        strlist_copy = strlist.getitems_fixedsize()
        floatlist_copy = floatlist.getitems_fixedsize()
        objlist_copy = objlist.getitems_fixedsize()
        for i in range(7):
            assert self.space.eq_w(rangelist_copy[i], rangelist.getitem(i))
            assert self.space.eq_w(intlist_copy[i], intlist.getitem(i))
            assert self.space.eq_w(strlist_copy[i], strlist.getitem(i))
            assert self.space.eq_w(floatlist_copy[i], floatlist.getitem(i))
            assert self.space.eq_w(objlist_copy[i], objlist.getitem(i))

        emptylist_copy = emptylist.getitems_unroll()
        assert emptylist_copy == []

        rangelist_copy = rangelist.getitems_unroll()
        intlist_copy = intlist.getitems_unroll()
        strlist_copy = strlist.getitems_unroll()
        floatlist_copy = floatlist.getitems_unroll()
        objlist_copy = objlist.getitems_unroll()
        for i in range(7):
            assert self.space.eq_w(rangelist_copy[i], rangelist.getitem(i))
            assert self.space.eq_w(intlist_copy[i], intlist.getitem(i))
            assert self.space.eq_w(strlist_copy[i], strlist.getitem(i))
            assert self.space.eq_w(floatlist_copy[i], floatlist.getitem(i))
            assert self.space.eq_w(objlist_copy[i], objlist.getitem(i))
Ejemplo n.º 26
0
    def test_simplerangelist(self):
        l = make_range_list(self.space, 0, 1, 10)
        assert isinstance(l.strategy, SimpleRangeListStrategy)
        v = l.pop(5)
        assert self.space.eq_w(v, self.space.wrap(5))
        assert isinstance(l.strategy, IntegerListStrategy)

        l = make_range_list(self.space, 0, 1, 10)
        assert isinstance(l.strategy, SimpleRangeListStrategy)
        v = l.pop(0)
        assert self.space.eq_w(v, self.space.wrap(0))
        assert isinstance(l.strategy, IntegerListStrategy)

        l = make_range_list(self.space, 0, 1, 10)
        assert isinstance(l.strategy, SimpleRangeListStrategy)
        v = l.pop_end()
        assert self.space.eq_w(v, self.space.wrap(9))
        assert isinstance(l.strategy, SimpleRangeListStrategy)
        v = l.pop_end()
        assert self.space.eq_w(v, self.space.wrap(8))
        assert isinstance(l.strategy, SimpleRangeListStrategy)

        l = make_range_list(self.space, 0, 1, 5)
        assert isinstance(l.strategy, SimpleRangeListStrategy)
        l.append(self.space.wrap("string"))
        assert isinstance(l.strategy, ObjectListStrategy)

        l = make_range_list(self.space, 0,1,5)
        assert isinstance(l.strategy, SimpleRangeListStrategy)
        l.append(self.space.wrap(19))
        assert isinstance(l.strategy, IntegerListStrategy)

        l = make_range_list(self.space, 0,1,5)
        assert isinstance(l.strategy, SimpleRangeListStrategy)
        assert l.find(self.space.wrap(0)) == 0
        assert l.find(self.space.wrap(4)) == 4

        try:
            l.find(self.space.wrap(5))
        except ValueError:
            pass
        else:
            assert False, "Did not raise ValueError"

        try:
            l.find(self.space.wrap(0), 5, 6)
        except ValueError:
            pass
        else:
            assert False, "Did not raise ValueError"

        assert l.length() == 5

        l = make_range_list(self.space, 0, 1, 1)
        assert self.space.eq_w(l.pop(0), self.space.wrap(0))

        l = make_range_list(self.space, 0, 1, 10)
        l.sort(False)
        assert isinstance(l.strategy, SimpleRangeListStrategy)

        assert self.space.eq_w(l.getitem(5), self.space.wrap(5))

        l = make_range_list(self.space, 0, 1, 1)
        assert self.space.eq_w(l.pop_end(), self.space.wrap(0))
        assert isinstance(l.strategy, EmptyListStrategy)
Ejemplo n.º 27
0
def range_withspecialized_implementation(space, start, step, length):
    assert space.config.objspace.std.withrangelist
    from pypy.objspace.std.listobject import make_range_list
    return make_range_list(space, start, step, length)
Ejemplo n.º 28
0
 def test_weird_rangelist_bug(self):
     l = make_range_list(self.space, 1, 1, 3)
     from pypy.objspace.std.listobject import getslice__List_ANY_ANY
     # should not raise
     assert getslice__List_ANY_ANY(self.space, l, self.space.wrap(15), self.space.wrap(2222)).strategy == self.space.fromcache(EmptyListStrategy)
Ejemplo n.º 29
0
 def test_add_to_rangelist(self):
     l1 = make_range_list(self.space, 1, 1, 3)
     l2 = W_ListObject(self.space, [self.space.wrap(4), self.space.wrap(5)])
     from pypy.objspace.std.listobject import add__List_List
     l3 = add__List_List(self.space, l1, l2)
     assert self.space.eq_w(l3, W_ListObject(self.space, [self.space.wrap(1), self.space.wrap(2), self.space.wrap(3), self.space.wrap(4), self.space.wrap(5)]))
Ejemplo n.º 30
0
 def test_range_setslice(self):
     l = make_range_list(self.space, 1, 3, 5)
     assert isinstance(l.strategy, RangeListStrategy)
     l.setslice(0, 1, 3, W_ListObject(self.space, [self.space.wrap(1), self.space.wrap(2), self.space.wrap(3)]))
     assert isinstance(l.strategy, IntegerListStrategy)
Ejemplo n.º 31
0
 def test_range_getslice_ovf(self):
     l = make_range_list(self.space, -sys.maxint, sys.maxint // 10, 21)
     assert isinstance(l.strategy, RangeListStrategy)
     l2 = l.getslice(0, 21, 11, 2)
     assert isinstance(l2.strategy, IntegerListStrategy)
Ejemplo n.º 32
0
    def test_simplerangelist(self):
        l = make_range_list(self.space, 0, 1, 10)
        assert isinstance(l.strategy, SimpleRangeListStrategy)
        v = l.pop(5)
        assert self.space.eq_w(v, self.space.wrap(5))
        assert isinstance(l.strategy, IntegerListStrategy)

        l = make_range_list(self.space, 0, 1, 10)
        assert isinstance(l.strategy, SimpleRangeListStrategy)
        v = l.pop(0)
        assert self.space.eq_w(v, self.space.wrap(0))
        assert isinstance(l.strategy, IntegerListStrategy)

        l = make_range_list(self.space, 0, 1, 10)
        assert isinstance(l.strategy, SimpleRangeListStrategy)
        v = l.pop_end()
        assert self.space.eq_w(v, self.space.wrap(9))
        assert isinstance(l.strategy, SimpleRangeListStrategy)
        v = l.pop_end()
        assert self.space.eq_w(v, self.space.wrap(8))
        assert isinstance(l.strategy, SimpleRangeListStrategy)

        l = make_range_list(self.space, 0, 1, 5)
        assert isinstance(l.strategy, SimpleRangeListStrategy)
        l.append(self.space.wrap("string"))
        assert isinstance(l.strategy, ObjectListStrategy)

        l = make_range_list(self.space, 0,1,5)
        assert isinstance(l.strategy, SimpleRangeListStrategy)
        l.append(self.space.wrap(19))
        assert isinstance(l.strategy, IntegerListStrategy)

        l = make_range_list(self.space, 0,1,5)
        assert isinstance(l.strategy, SimpleRangeListStrategy)
        assert l.find(self.space.wrap(0)) == 0
        assert l.find(self.space.wrap(4)) == 4

        try:
            l.find(self.space.wrap(5))
        except ValueError:
            pass
        else:
            assert False, "Did not raise ValueError"

        try:
            l.find(self.space.wrap(0), 5, 6)
        except ValueError:
            pass
        else:
            assert False, "Did not raise ValueError"

        assert l.length() == 5

        l = make_range_list(self.space, 0, 1, 1)
        assert self.space.eq_w(l.pop(0), self.space.wrap(0))

        l = make_range_list(self.space, 0, 1, 10)
        l.sort(False)
        assert isinstance(l.strategy, SimpleRangeListStrategy)

        assert self.space.eq_w(l.getitem(5), self.space.wrap(5))

        l = make_range_list(self.space, 0, 1, 1)
        assert self.space.eq_w(l.pop_end(), self.space.wrap(0))
        assert isinstance(l.strategy, EmptyListStrategy)
Ejemplo n.º 33
0
 def test_weird_rangelist_bug(self):
     space = self.space
     l = make_range_list(space, 1, 1, 3)
     # should not raise
     w_slice = space.newslice(space.wrap(15), space.wrap(2222), space.wrap(1))
     assert l.descr_getitem(space, w_slice).strategy == space.fromcache(EmptyListStrategy)
Ejemplo n.º 34
0
 def test_range_getslice_ovf(self):
     l = make_range_list(self.space, -sys.maxint, sys.maxint // 10, 21)
     assert isinstance(l.strategy, RangeListStrategy)
     l2 = l.getslice(0, 21, 11, 2)
     assert isinstance(l2.strategy, IntegerListStrategy)
Ejemplo n.º 35
0
 def test_add_of_range_and_int(self):
     l1 = make_range_list(self.space, 0, 1, 100)
     l2 = W_ListObject(self.space, [self.space.wrap(1), self.space.wrap(2), self.space.wrap(3)])
     l3 = self.space.add(l2, l1)
     assert l3.strategy is l2.strategy
Ejemplo n.º 36
0
 def test_weird_rangelist_bug(self):
     l = make_range_list(self.space, 1, 1, 3)
     # should not raise
     assert l.descr_getslice(self.space, self.space.wrap(15), self.space.wrap(2222)).strategy == self.space.fromcache(EmptyListStrategy)
Ejemplo n.º 37
0
 def test_add_to_rangelist(self):
     l1 = make_range_list(self.space, 1, 1, 3)
     l2 = W_ListObject(self.space, [self.space.wrap(4), self.space.wrap(5)])
     l3 = l1.descr_add(self.space, l2)
     assert self.space.eq_w(l3, W_ListObject(self.space, [self.space.wrap(1), self.space.wrap(2), self.space.wrap(3), self.space.wrap(4), self.space.wrap(5)]))
Ejemplo n.º 38
0
 def test_weird_rangelist_bug(self):
     l = make_range_list(self.space, 1, 1, 3)
     # should not raise
     assert l.descr_getslice(
         self.space, self.space.wrap(15), self.space.wrap(
             2222)).strategy == self.space.fromcache(EmptyListStrategy)