[pypy-svn] rev 1067 - in pypy/trunk/src/pypy/objspace/std: . test
arigo at codespeak.net
arigo at codespeak.net
Mon Jun 30 16:44:32 CEST 2003
Author: arigo
Date: Mon Jun 30 16:44:31 2003
New Revision: 1067
Modified:
pypy/trunk/src/pypy/objspace/std/multimethod.py
pypy/trunk/src/pypy/objspace/std/test/test_multimethod.py
Log:
Fixed the genuine problem reported by the disabled test in test_multimethod.
Re-enabled the test.
Modified: pypy/trunk/src/pypy/objspace/std/multimethod.py
==============================================================================
--- pypy/trunk/src/pypy/objspace/std/multimethod.py (original)
+++ pypy/trunk/src/pypy/objspace/std/multimethod.py Mon Jun 30 16:44:31 2003
@@ -140,7 +140,8 @@
parenttypes += list(t.__bases__)
if parenttypes:
def delegate_to_parent_classes(space, a, parenttypes=parenttypes):
- return [(t, a) for t in parenttypes]
+ return [(t, a) for t in parenttypes
+ if issubclass(a.dispatchclass, t)]
# hard-wire it at priority 0
by_priority[0] = [((t,), delegate_to_parent_classes)
for t in arg1types]
@@ -265,6 +266,7 @@
for argi in range(arity-1, -1, -1):
curtypes = types[argi] # growing tuple of types we can delegate to
+ assert len(curtypes) == 1
curobjs = {curtypes[0]: args[argi]} # maps them to actual objects
args = args[:argi] # initial segments of arguments before this one
types = types[:argi] # same with types (no deleg tried on them yet)
Modified: pypy/trunk/src/pypy/objspace/std/test/test_multimethod.py
==============================================================================
--- pypy/trunk/src/pypy/objspace/std/test/test_multimethod.py (original)
+++ pypy/trunk/src/pypy/objspace/std/test/test_multimethod.py Mon Jun 30 16:44:31 2003
@@ -76,8 +76,7 @@
if type(x) in cache:
Stub = cache[type(x)]
else:
- class Stub(type(x)):
- pass
+ Stub = type(type(x))('%s_stub' % type(x).__name__, (type(x),), {})
Stub.dispatchclass = Stub
cache[type(x)] = Stub
return Stub(x)
@@ -129,7 +128,7 @@
self.assertRaises(OperationError, space.add, X(0), w("spam"))
self.assertRaises(OperationError, space.add, Y(666), w("egg"))
- def _test_delegate_x_to_str_sometimes(self):
+ def test_delegate_x_to_str_sometimes(self):
space = self.space
r = space.add(X(42), w("spam"))
self.assertEquals(repr(r), "('add_string_string', '!42', 'spam')")
More information about the Pypy-commit
mailing list