[pypy-commit] pypy list-strategies: Added tests for adding lists (especially range lists)

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


Author: Lukas Diekmann <lukas.diekmann at uni-duesseldorf.de>
Branch: list-strategies
Changeset: r47505:a5c9d09d47ae
Date: 2011-04-26 11:11 +0200
http://bitbucket.org/pypy/pypy/changeset/a5c9d09d47ae/

Log:	Added tests for adding lists (especially range lists)

diff --git a/pypy/objspace/std/test/test_listobject.py b/pypy/objspace/std/test/test_listobject.py
--- a/pypy/objspace/std/test/test_listobject.py
+++ b/pypy/objspace/std/test/test_listobject.py
@@ -566,6 +566,16 @@
         l1 += bar
         assert l1 == ('radd', bar, [1,2,3])
 
+    def test_add_lists(self):
+        l1 = [1,2,3]
+        l2 = [4,5,6]
+        l3 = l1 + l2
+        assert l3 == [1,2,3,4,5,6]
+
+        l4 = range(3)
+        l5 = l4 + l2
+        assert l5 == [0,1,2,4,5,6]
+
     def test_imul(self):
         l = l0 = [4,3]
         l *= 2
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
@@ -330,3 +330,11 @@
         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)
+
+
+    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)]))


More information about the pypy-commit mailing list