[pypy-commit] pypy SpecialisedTuples: (antocuni, mwp) make sure that tuple in test_getitem does not delegate
mwp
noreply at buildbot.pypy.org
Thu Nov 10 10:47:34 CET 2011
Author: Mark Pearse <mark.pearse at skynet.be>
Branch: SpecialisedTuples
Changeset: r49089:b5c82fd6acf8
Date: 2011-11-05 16:59 +0100
http://bitbucket.org/pypy/pypy/changeset/b5c82fd6acf8/
Log: (antocuni, mwp) make sure that tuple in test_getitem does not
delegate
diff --git a/pypy/objspace/std/specialisedtupleobject.py b/pypy/objspace/std/specialisedtupleobject.py
--- a/pypy/objspace/std/specialisedtupleobject.py
+++ b/pypy/objspace/std/specialisedtupleobject.py
@@ -112,7 +112,6 @@
raise OperationError(space.w_IndexError,
space.wrap("tuple index out of range"))
'''
-
def getitem__SpecialisedTuple_Slice(space, w_tuple, w_slice):
length = w_tuple.length()
start, stop, step, slicelength = w_slice.indices4(space, length)
diff --git a/pypy/objspace/std/test/test_specialisedtupleobject.py b/pypy/objspace/std/test/test_specialisedtupleobject.py
--- a/pypy/objspace/std/test/test_specialisedtupleobject.py
+++ b/pypy/objspace/std/test/test_specialisedtupleobject.py
@@ -3,7 +3,7 @@
from pypy.objspace.std.specialisedtupleobject import W_SpecialisedTupleObject,W_SpecialisedTupleObjectIntInt
from pypy.interpreter.error import OperationError
from pypy.conftest import gettestobjspace
-from pypy.objspace.std.test.test_tupleobject import AppTestW_TupleObject
+#from pypy.objspace.std.test.test_tupleobject import AppTestW_TupleObject
from pypy.interpreter import gateway
@@ -41,7 +41,7 @@
assert len(list_w) == 1
assert self.space.eq_w(list_w[0], self.space.wrap(5))
-class AppTestW_SpecialisedTupleObject(AppTestW_TupleObject):
+class AppTestW_SpecialisedTupleObject(object):
def setup_class(cls):
cls.space = gettestobjspace(**{"objspace.std.withspecialisedtuple": True})
@@ -99,6 +99,13 @@
c = (2,4)
assert hash(a) != hash(c)
+ def test_getitem(self):
+ t = self.forbid_delegation((5,3))
+ assert (t)[0] == 5
+ assert (t)[1] == 3
+ assert (t)[-1] == 3
+ assert (t)[-2] == 5
+ raises(IndexError, "t[2]")
More information about the pypy-commit
mailing list