[pypy-svn] pypy collections-module: Test and fix.
arigo
commits-noreply at bitbucket.org
Tue Feb 15 20:55:24 CET 2011
Author: Armin Rigo <arigo at tunes.org>
Branch: collections-module
Changeset: r41998:e5b990219303
Date: 2011-02-15 20:39 +0100
http://bitbucket.org/pypy/pypy/changeset/e5b990219303/
Log: Test and fix.
diff --git a/pypy/module/_collections/test/test_deque.py b/pypy/module/_collections/test/test_deque.py
--- a/pypy/module/_collections/test/test_deque.py
+++ b/pypy/module/_collections/test/test_deque.py
@@ -170,6 +170,16 @@
d = deque(xrange(1000, 1200))
d.reverse()
assert list(d) == list(reversed(range(1000, 1200)))
+ #
+ n = 100
+ data = map(str, range(n))
+ for i in range(n):
+ d = deque(data[:i])
+ r = d.reverse()
+ assert list(d) == list(reversed(data[:i]))
+ assert r is None
+ d.reverse()
+ assert list(d) == data[:i]
def test_rotate(self):
from _collections import deque
diff --git a/pypy/module/_collections/interp_deque.py b/pypy/module/_collections/interp_deque.py
--- a/pypy/module/_collections/interp_deque.py
+++ b/pypy/module/_collections/interp_deque.py
@@ -283,7 +283,7 @@
lb = self.leftblock
ri = self.rightindex
rb = self.rightblock
- while lb is not rb or li < ri:
+ for i in range(self.len >> 1):
lb.data[li], rb.data[ri] = rb.data[ri], lb.data[li]
li += 1
if li >= BLOCKLEN:
More information about the Pypy-commit
mailing list