Author: Lukas Diekmann <[email protected]>
Branch: list-strategies
Changeset: r47435:750c8eed3a9d
Date: 2011-02-23 17:15 +0100
http://bitbucket.org/pypy/pypy/changeset/750c8eed3a9d/

Log:    Added tests for strategy changes in setslice and fixed
        is_correct_type error

diff --git a/pypy/objspace/std/listobject.py b/pypy/objspace/std/listobject.py
--- a/pypy/objspace/std/listobject.py
+++ b/pypy/objspace/std/listobject.py
@@ -290,7 +290,7 @@
         assert slicelength >= 0
         items = self.cast_from_void_star(w_list.storage)
 
-        if not self.is_correct_type(W_ListObject(sequence_w)):
+        if not self.list_is_correct_type(W_ListObject(sequence_w)):
             w_list.strategy = ObjectListStrategy()
             w_list.strategy.init_from_list_w(w_list, items)
             w_list.setslice(start, step, slicelength, sequence_w)
diff --git a/pypy/objspace/std/test/test_liststrategies.py 
b/pypy/objspace/std/test/test_liststrategies.py
--- a/pypy/objspace/std/test/test_liststrategies.py
+++ b/pypy/objspace/std/test/test_liststrategies.py
@@ -98,6 +98,16 @@
         l.setslice(0, 1, 2, [self.space.wrap(1), self.space.wrap(2), 
self.space.wrap(3)])
         assert isinstance(l.strategy, IntegerListStrategy)
 
+        l = W_ListObject([self.space.wrap(1), self.space.wrap(2), 
self.space.wrap(3)])
+        assert isinstance(l.strategy, IntegerListStrategy)
+        l.setslice(0, 1, 2, [self.space.wrap(4), self.space.wrap(5), 
self.space.wrap(6)])
+        assert isinstance(l.strategy, IntegerListStrategy)
+
+        l = W_ListObject([self.space.wrap(1), self.space.wrap(2), 
self.space.wrap(3)])
+        assert isinstance(l.strategy, IntegerListStrategy)
+        l.setslice(0, 1, 2, [self.space.wrap('a'), self.space.wrap('b'), 
self.space.wrap('c')])
+        assert isinstance(l.strategy, ObjectListStrategy)
+
     def test_extend(self):
         l = W_ListObject([])
         assert isinstance(l.strategy, EmptyListStrategy)
_______________________________________________
pypy-commit mailing list
[email protected]
http://mail.python.org/mailman/listinfo/pypy-commit

Reply via email to