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)
Beispiel #2
0
 def test_extend_other_with_empty(self):
     space = self.space
     w = space.wrap
     l = W_ListObject(space, [w(1), w(2), w(3)])
     assert isinstance(l.strategy, IntegerListStrategy)
     l.extend(W_ListObject(space, []))
     assert isinstance(l.strategy, IntegerListStrategy)
Beispiel #3
0
 def test_extend_other_with_empty(self):
     space = self.space
     w = space.wrap
     l = W_ListObject(space, [w(1), w(2), w(3)])
     assert isinstance(l.strategy, IntegerListStrategy)
     l.extend(W_ListObject(space, []))
     assert isinstance(l.strategy, IntegerListStrategy)
Beispiel #4
0
 def test_int_or_float_extend_mixed_6(self):
     space = self.space
     w_l1 = W_ListObject(space, [space.wrap(-2.5)])
     w_l2 = W_ListObject(space, [space.wrap(3.4), space.wrap(-2)])
     assert isinstance(w_l1.strategy, FloatListStrategy)
     assert isinstance(w_l2.strategy, IntOrFloatListStrategy)
     w_l1.extend(w_l2)
     assert isinstance(w_l1.strategy, IntOrFloatListStrategy)
     assert space.unwrap(w_l1) == [-2.5, 3.4, -2]
Beispiel #5
0
 def test_int_or_float_extend(self):
     space = self.space
     w_l1 = W_ListObject(space, [space.wrap(0), space.wrap(1.2)])
     w_l2 = W_ListObject(space, [space.wrap(3), space.wrap(4.5)])
     assert isinstance(w_l1.strategy, IntOrFloatListStrategy)
     assert isinstance(w_l2.strategy, IntOrFloatListStrategy)
     w_l1.extend(w_l2)
     assert isinstance(w_l1.strategy, IntOrFloatListStrategy)
     assert space.unwrap(w_l1) == [0, 1.2, 3, 4.5]
Beispiel #6
0
 def test_int_or_float_extend_mixed_1(self):
     space = self.space
     w_l1 = W_ListObject(space, [space.wrap(0), space.wrap(1.2)])
     w_l2 = W_ListObject(space, [space.wrap(3)])
     assert isinstance(w_l1.strategy, IntOrFloatListStrategy)
     assert isinstance(w_l2.strategy, IntegerListStrategy)
     w_l1.extend(w_l2)
     assert isinstance(w_l1.strategy, IntOrFloatListStrategy)
     assert [(type(x), x) for x in space.unwrap(w_l1)] == [
         (int, 0), (float, 1.2), (int, 3)]
Beispiel #7
0
 def test_int_or_float_extend_mixed_5_overflow(self):
     if sys.maxint == 2147483647:
         py.test.skip("only on 64-bit")
     space = self.space
     ovf1 = 2 ** 35
     w_l1 = W_ListObject(space, [space.wrap(-2.5)])
     w_l2 = W_ListObject(space, [space.wrap(ovf1)])
     assert isinstance(w_l1.strategy, FloatListStrategy)
     assert isinstance(w_l2.strategy, IntegerListStrategy)
     w_l1.extend(w_l2)
     assert isinstance(w_l1.strategy, ObjectListStrategy)
     assert space.unwrap(w_l1) == [-2.5, ovf1]
Beispiel #8
0
    def test_extend(self):
        l = W_ListObject(self.space, [])
        assert isinstance(l.strategy, EmptyListStrategy)
        l.extend(
            W_ListObject(
                self.space,
                [self.space.wrap(1),
                 self.space.wrap(2),
                 self.space.wrap(3)]))
        assert isinstance(l.strategy, IntegerListStrategy)

        l = W_ListObject(
            self.space,
            [self.space.wrap(1),
             self.space.wrap(2),
             self.space.wrap(3)])
        assert isinstance(l.strategy, IntegerListStrategy)
        l.extend(
            W_ListObject(self.space, [
                self.space.wrap('a'),
                self.space.wrap('b'),
                self.space.wrap('c')
            ]))
        assert isinstance(l.strategy, ObjectListStrategy)

        l = W_ListObject(
            self.space,
            [self.space.wrap(1),
             self.space.wrap(2),
             self.space.wrap(3)])
        assert isinstance(l.strategy, IntegerListStrategy)
        l.extend(
            W_ListObject(
                self.space,
                [self.space.wrap(4),
                 self.space.wrap(5),
                 self.space.wrap(6)]))
        assert isinstance(l.strategy, IntegerListStrategy)

        l = W_ListObject(
            self.space,
            [self.space.wrap(1.1),
             self.space.wrap(2.2),
             self.space.wrap(3.3)])
        assert isinstance(l.strategy, FloatListStrategy)
        l.extend(
            W_ListObject(
                self.space,
                [self.space.wrap(4),
                 self.space.wrap(5),
                 self.space.wrap(6)]))
        assert isinstance(l.strategy, ObjectListStrategy)
Beispiel #9
0
    def test_extend(self):
        l = W_ListObject(self.space, [])
        assert isinstance(l.strategy, EmptyListStrategy)
        l.extend(W_ListObject(self.space, [self.space.wrap(1), self.space.wrap(2), self.space.wrap(3)]))
        assert isinstance(l.strategy, IntegerListStrategy)

        l = W_ListObject(self.space, [self.space.wrap(1), self.space.wrap(2), self.space.wrap(3)])
        assert isinstance(l.strategy, IntegerListStrategy)
        l.extend(W_ListObject(self.space, [self.space.wrap('a'), self.space.wrap('b'), self.space.wrap('c')]))
        assert isinstance(l.strategy, ObjectListStrategy)

        l = W_ListObject(self.space, [self.space.wrap(1), self.space.wrap(2), self.space.wrap(3)])
        assert isinstance(l.strategy, IntegerListStrategy)
        l.extend(W_ListObject(self.space, [self.space.wrap(4), self.space.wrap(5), self.space.wrap(6)]))
        assert isinstance(l.strategy, IntegerListStrategy)

        l = W_ListObject(self.space, [self.space.wrap(1.1), self.space.wrap(2.2), self.space.wrap(3.3)])
        assert isinstance(l.strategy, FloatListStrategy)
        l.extend(W_ListObject(self.space, [self.space.wrap(4), self.space.wrap(5), self.space.wrap(6)]))
        assert isinstance(l.strategy, ObjectListStrategy)
Beispiel #10
0
    def test_extend(self):
        space = self.space
        w = space.wrap

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

        l = W_ListObject(space, [w(1), w(2), w(3)])
        assert isinstance(l.strategy, IntegerListStrategy)
        l.extend(W_ListObject(space, [w('a'), w('b'), w('c')]))
        assert isinstance(l.strategy, ObjectListStrategy)

        l = W_ListObject(space, [w(1), w(2), w(3)])
        assert isinstance(l.strategy, IntegerListStrategy)
        l.extend(W_ListObject(space, [w(4), w(5), w(6)]))
        assert isinstance(l.strategy, IntegerListStrategy)

        l = W_ListObject(space, [w(1.1), w(2.2), w(3.3)])
        assert isinstance(l.strategy, FloatListStrategy)
        l.extend(W_ListObject(space, [w(4), w(5), w(6)]))
        assert isinstance(l.strategy, ObjectListStrategy)
Beispiel #11
0
    def test_extend(self):
        space = self.space
        w = space.wrap

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

        l = W_ListObject(space, [w(1), w(2), w(3)])
        assert isinstance(l.strategy, IntegerListStrategy)
        l.extend(W_ListObject(space, [w('a'), w('b'), w('c')]))
        assert isinstance(l.strategy, ObjectListStrategy)

        l = W_ListObject(space, [w(1), w(2), w(3)])
        assert isinstance(l.strategy, IntegerListStrategy)
        l.extend(W_ListObject(space, [w(4), w(5), w(6)]))
        assert isinstance(l.strategy, IntegerListStrategy)

        l = W_ListObject(space, [w(1.1), w(2.2), w(3.3)])
        assert isinstance(l.strategy, FloatListStrategy)
        l.extend(W_ListObject(space, [w("abc"), w("def"), w("ghi")]))
        assert isinstance(l.strategy, ObjectListStrategy)
Beispiel #12
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)
Beispiel #13
0
    def test_empty_extend_with_any(self):
        space = self.space
        w = space.wrap

        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("a"), w("b"), w("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)
Beispiel #14
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)