[pypy-commit] pypy list-strategies: Added tests for RangeListStrategy

l.diekmann noreply at buildbot.pypy.org
Fri Sep 23 13:12:09 CEST 2011


Author: Lukas Diekmann <lukas.diekmann at uni-duesseldorf.de>
Branch: list-strategies
Changeset: r47453:75956a940aea
Date: 2011-03-08 15:06 +0100
http://bitbucket.org/pypy/pypy/changeset/75956a940aea/

Log:	Added tests for RangeListStrategy

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
@@ -309,7 +309,7 @@
         if is_W_IntObject(w_item):
             self.switch_to_integer_strategy(w_list)
         else:
-            w_list.switch_to_object_strategy(w_list)
+            w_list.switch_to_object_strategy()
         w_list.append(w_item)
 
     def inplace_mul(self, w_list, times):
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
@@ -1,4 +1,4 @@
-from pypy.objspace.std.listobject import W_ListObject, EmptyListStrategy, ObjectListStrategy, IntegerListStrategy, StringListStrategy
+from pypy.objspace.std.listobject import W_ListObject, EmptyListStrategy, ObjectListStrategy, IntegerListStrategy, StringListStrategy, RangeListStrategy, make_range_list
 from pypy.objspace.std.test.test_listobject import TestW_ListObject
 
 class TestW_ListStrategies(TestW_ListObject):
@@ -145,3 +145,15 @@
         l.extend(W_ListObject(self.space, [self.space.wrap(4), self.space.wrap(5), self.space.wrap(6)]))
         assert isinstance(l.strategy, IntegerListStrategy)
 
+    def test_rangelist(self):
+        l = make_range_list(self.space, 1,3,7)
+        assert isinstance(l.strategy, RangeListStrategy)
+        v = l.pop(6)
+        assert self.space.eq_w(v, self.space.wrap(19))
+        assert isinstance(l.strategy, IntegerListStrategy)
+
+        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)
+


More information about the pypy-commit mailing list