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

akuhn at codespeak.net akuhn at codespeak.net
Thu Oct 25 02:36:17 CEST 2007


Author: akuhn
Date: Thu Oct 25 02:36:17 2007
New Revision: 47882

Modified:
   pypy/dist/pypy/lang/smalltalk/squeakimage.py
   pypy/dist/pypy/lang/smalltalk/test/test_miniimage.py
Log:
very strange, for example range(4)[:0] returns [] instead of [0,1,2,3]! Hence what we have to write list[:-odd] as list[:len(list)-odd] instead :( found this bug when testing the name of True class :)

Modified: pypy/dist/pypy/lang/smalltalk/squeakimage.py
==============================================================================
--- pypy/dist/pypy/lang/smalltalk/squeakimage.py	(original)
+++ pypy/dist/pypy/lang/smalltalk/squeakimage.py	Thu Oct 25 02:36:17 2007
@@ -306,14 +306,16 @@
         w_wordsobject.hash = self.chunk.hash12 # XXX check this
 
     def fillin_bytesobject(self, w_bytesobject):
-        bytes = []
+        bbytes = []
         for each in self.chunk.data:
-            bytes.append(chr((each >> 24) & 0xff))
-            bytes.append(chr((each >> 16) & 0xff)) 
-            bytes.append(chr((each >> 8) & 0xff)) 
-            bytes.append(chr((each >> 0) & 0xff))
+            bbytes.append(chr((each >> 24) & 0xff))
+            bbytes.append(chr((each >> 16) & 0xff)) 
+            bbytes.append(chr((each >> 8) & 0xff)) 
+            bbytes.append(chr((each >> 0) & 0xff))
         w_bytesobject.m_class = mirrorcache.get_or_build(self.g_class.w_object)
-        w_bytesobject.bytes = bytes[:-(self.format & 3)] # omit odd bytes
+        #strange, for example range(4)[:0] returns [] instead of [0,1,2,3]!
+        #hence what we have to write list[:-odd] as list[:len(list)-odd] instead :(
+        w_bytesobject.bytes = bbytes[:len(bbytes)-(self.format & 3)] # omit odd bytes
         w_bytesobject.hash = self.chunk.hash12 # XXX check this
  
     def fillin_compiledmethod(self, w_compiledmethod):
@@ -339,7 +341,9 @@
             bbytes.append(chr((each >> 16) & 0xff)) 
             bbytes.append(chr((each >> 8) & 0xff)) 
             bbytes.append(chr((each >> 0) & 0xff))
-        bbytes = bbytes[(literalsize + 1)*4:-(self.format & 3)] # omit literals & odd bytes
+        #strange, for example range(4)[:0] returns [] instead of [0,1,2,3]!
+        #hence what we have to write list[:-odd] as list[:len(list)-odd] instead :(
+        bbytes = bbytes[(literalsize + 1)*4:len(bbytes)-(self.format & 3)] # omit literals & odd bytes
         # XXX assert mirrorcache.get_or_build(self.g_class.w_object) is
         #            ct.m_CompiledMethod
         w_compiledmethod.__init__(

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 02:36:17 2007
@@ -89,9 +89,81 @@
 def test_str_w_object():
     w_float_class = get_float_class()
     assert str(w_float_class) == "Float class"
-    assert str(w_float_class.getclass()) == "a Metaclass" # yes, with article here.
+    assert str(w_float_class.getclass()) == "a Metaclass" #yes, with article
     assert str(w_float_class.getclass().getclass()) == "Metaclass class"
 
+def test_nil_true_false():
+    image = get_image()
+    w = image.special(sqc.SO_NIL)
+    assert str(w) == "a UndefinedObject" #yes, with article
+    w = image.special(sqc.SO_FALSE)
+    assert str(w) == "a False" #yes, with article
+    w = image.special(sqc.SO_TRUE)
+    assert str(w) == "a True" #yes, with article
+    
+def test_scheduler():
+    image = get_image()
+    w = image.special(sqc.SO_SCHEDULERASSOCIATIONPOINTER)
+    w0 = w.fetch(0)
+    assert str(w0) == "'Processor'" 
+    w0 = w.fetch(1)
+    assert str(w0) == "a ProcessorScheduler" 
+   
+def test_special_classes0():
+    image = get_image()
+    w = image.special(sqc.SO_BITMAP_CLASS)
+    assert str(w) == "Bitmap class" 
+    w = image.special(sqc.SO_SMALLINTEGER_CLASS)
+    assert str(w) == "SmallInteger class" 
+    w = image.special(sqc.SO_STRING_CLASS)
+    assert str(w) == "String class" 
+    w = image.special(sqc.SO_ARRAY_CLASS)
+    assert str(w) == "Array class" 
+    w = image.special(sqc.SO_FLOAT_CLASS)
+    assert str(w) == "Float class" 
+    w = image.special(sqc.SO_METHODCONTEXT_CLASS)
+    assert str(w) == "MethodContext class" 
+    w = image.special(sqc.SO_BLOCKCONTEXT_CLASS)
+    assert str(w) == "BlockContext class" 
+    w = image.special(sqc.SO_POINT_CLASS)
+    assert str(w) == "Point class" 
+    w = image.special(sqc.SO_LARGEPOSITIVEINTEGER_CLASS)
+    assert str(w) == "LargePositiveInteger class" 
+
+    # to be continued
+
+    """SO_SMALLTALK = 8
+     SO_DISPLAY_CLASS = 14
+    SO_MESSAGE_CLASS = 15
+    SO_COMPILEDMETHOD_CLASS = 16
+    SO_LOW_SPACE_SEMAPHORE = 17
+    SO_SEMAPHORE_CLASS = 18
+    SO_CHARACTER_CLASS = 19
+    SO_DOES_NOT_UNDERSTAND = 20
+    SO_CANNOT_RETURN = 21
+    # no clue what 22 is doing
+    SO_SPECIAL_SELECTORS_ARRAY = 23
+    SO_CHARACTER_TABLE_ARRAY = 24
+    SO_MUST_BE_BOOLEAN = 25
+    SO_BYTEARRAY_CLASS = 26
+    SO_PROCESS_CLASS = 27
+    SO_COMPACT_CLASSES_ARRAY = 28
+    SO_DELAY_SEMAPHORE = 29
+    SO_USER_INTERRUPT_SEMAPHORE = 30
+    SO_FLOAT_ZERO = 31
+    SO_LARGEPOSITIVEINTEGER_ZERO = 32
+    SO_A_POINT = 33
+    SO_CANNOT_INTERPRET = 34
+    SO_A_METHODCONTEXT = 35
+    # no clue what 36 is doing
+    SO_A_BLOCKCONTEXT = 37
+    SO_AN_ARRAY = 38
+    SO_PSEUDOCONTEXT_CLASS = 39
+    SO_TRANSLATEDMETHOD_CLASS = 40
+    SO_FINALIZATION_SEMPAHORE = 41
+    SO_LARGENEGATIVEINTEGER_CLASS = 42"""
+
+
 
 def test_lookup_abs_in_integer(int=10):
     image = get_image()



More information about the Pypy-commit mailing list