[pypy-svn] r47925 - in pypy/dist/pypy/lang/smalltalk: . test

akuhn at codespeak.net akuhn at codespeak.net
Thu Oct 25 15:41:54 CEST 2007


Author: akuhn
Date: Thu Oct 25 15:41:52 2007
New Revision: 47925

Modified:
   pypy/dist/pypy/lang/smalltalk/model.py
   pypy/dist/pypy/lang/smalltalk/test/test_miniimage.py
Log:
(akuhn, tverwaes, arigo)
added test to test for class of #doesNotUnderstand: in mini.image (which is, for some strange reason, an Array)


Modified: pypy/dist/pypy/lang/smalltalk/model.py
==============================================================================
--- pypy/dist/pypy/lang/smalltalk/model.py	(original)
+++ pypy/dist/pypy/lang/smalltalk/model.py	Thu Oct 25 15:41:52 2007
@@ -134,7 +134,7 @@
         values = w_methoddict[constants.METHODDICT_VALUES_INDEX]._vars
         for var in names:
             if isinstance(var, W_BytesObject):
-                if str(var) == repr(methodname):
+                if str(var) == str(methodname):
                     return values[names.index(var)]
         raise MethodNotFound
 
@@ -155,7 +155,7 @@
                     else:
                         in_class = new_class
                 except IndexError:
-                    return self.lookup("doesNotUnderstand")
+                    return self.lookup("doesNotUnderstand:")
 
 class W_BytesObject(W_AbstractObjectWithClassReference):
     def __init__(self, w_class, size):
@@ -172,7 +172,11 @@
         return len(self.bytes)    
 
     def __str__(self):
-        return repr("".join(self.bytes))
+        return "".join(self.bytes)
+
+    def __repr__(self):
+        return "<W_BytesObject %r>" % ("".join(self.bytes),)
+
 
     def invariant(self):
         if not W_AbstractObjectWithClassReference.invariant(self):

Modified: pypy/dist/pypy/lang/smalltalk/test/test_miniimage.py
==============================================================================
--- pypy/dist/pypy/lang/smalltalk/test/test_miniimage.py	(original)
+++ pypy/dist/pypy/lang/smalltalk/test/test_miniimage.py	Thu Oct 25 15:41:52 2007
@@ -105,7 +105,7 @@
     image = get_image()
     w = image.special(constants.SO_SCHEDULERASSOCIATIONPOINTER)
     w0 = w.fetch(0)
-    assert str(w0) == "'Processor'" 
+    assert str(w0) == "Processor" 
     w0 = w.fetch(1)
     assert str(w0) == "a ProcessorScheduler" 
    
@@ -138,8 +138,16 @@
     SO_COMPILEDMETHOD_CLASS = 16
     SO_LOW_SPACE_SEMAPHORE = 17
     SO_SEMAPHORE_CLASS = 18
-    SO_CHARACTER_CLASS = 19
-    SO_DOES_NOT_UNDERSTAND = 20
+    SO_CHARACTER_CLASS = 19"""
+    
+def test_special_classes0():
+    image = get_image()
+    w = image.special(constants.SO_DOES_NOT_UNDERSTAND)
+    assert str(w) == "doesNotUnderstand:"
+    assert str(w.getclass()) == "Array class" # for some strange reason not a symbol
+    
+    
+    """SO_DOES_NOT_UNDERSTAND = 20
     SO_CANNOT_RETURN = 21
     # no clue what 22 is doing
     SO_SPECIAL_SELECTORS_ARRAY = 23



More information about the Pypy-commit mailing list