[pypy-commit] pypy SpecialisedTuples: (antocuni, mwp) make sure that tuple in test_len does not delegate
mwp
noreply at buildbot.pypy.org
Thu Nov 10 10:47:32 CET 2011
Author: Mark Pearse <mark.pearse at skynet.be>
Branch: SpecialisedTuples
Changeset: r49088:ca02c6a45190
Date: 2011-11-05 16:44 +0100
http://bitbucket.org/pypy/pypy/changeset/ca02c6a45190/
Log: (antocuni, mwp) make sure that tuple in test_len 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
@@ -93,14 +93,6 @@
if index == 1:
return self.space.wrap(self.intval1)
raise IndexError
-'''
- def setitem(self, index, w_item):
- assert isinstance(w_item, W_IntObject)
- if index == 0:
- self.intval = w_item.intval
- return
- raise IndexError
-'''
registerimplementation(W_SpecialisedTupleObject)
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
@@ -4,7 +4,7 @@
from pypy.interpreter.error import OperationError
from pypy.conftest import gettestobjspace
from pypy.objspace.std.test.test_tupleobject import AppTestW_TupleObject
-
+from pypy.interpreter import gateway
class TestW_SpecialisedTupleObject():
@@ -45,17 +45,27 @@
def setup_class(cls):
cls.space = gettestobjspace(**{"objspace.std.withspecialisedtuple": True})
+ def forbid_delegation(space, w_tuple):
+ def delegation_forbidden():
+ raise NotImplementedError
+ w_tuple.tolist = delegation_forbidden
+ return w_tuple
+ cls.w_forbid_delegation = cls.space.wrap(gateway.interp2app(forbid_delegation))
+
+
def w_isspecialised(self, obj):
import __pypy__
return "SpecialisedTuple" in __pypy__.internal_repr(obj)
+
def test_specialisedtuple(self):
assert self.isspecialised((42,43))
def test_len(self):
- assert len((42,43)) == 2
+ t = self.forbid_delegation((42,43))
+ assert len(t) == 2
def test_notspecialisedtuple(self):
assert not self.isspecialised((42,43,44))
More information about the pypy-commit
mailing list