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

tverwaes at codespeak.net tverwaes at codespeak.net
Thu Oct 25 00:06:35 CEST 2007


Author: tverwaes
Date: Thu Oct 25 00:06:34 2007
New Revision: 47875

Modified:
   pypy/dist/pypy/lang/smalltalk/squeakimage.py
   pypy/dist/pypy/lang/smalltalk/test/test_miniimage.py
Log:
Moved abs-test from tool/analysis to miniimage test


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 00:06:34 2007
@@ -182,8 +182,6 @@
         return self.special_objects[index]  
         
 COMPACT_CLASSES_ARRAY = 28
-FLOAT_CLASS = 9
-          
 
 # ____________________________________________________________
 

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 00:06:34 2007
@@ -4,6 +4,8 @@
 import py
 from pypy.lang.smalltalk import squeakimage as sq
 from pypy.lang.smalltalk import model as sqm
+from pypy.lang.smalltalk import constants as sqc
+from pypy.lang.smalltalk import interpreter as sqi
 
 
 mini_image = py.magic.autopath().dirpath().dirpath().join('mini.image')
@@ -14,6 +16,14 @@
 def get_miniimage():
     return sq.ImageReader(sq.Stream(mini_image.open()))
 
+def create_squeakimage():
+    example = get_miniimage()
+    example.initialize()
+    
+    image = sq.SqueakImage()
+    image.from_reader(example)
+    return image
+
 def test_read_header():
     example = get_miniimage()
     example.read_header()
@@ -61,7 +71,7 @@
     for each in image.objects:
         each.invariant()
     
-    w_float_class = image.special(sq.FLOAT_CLASS)
+    w_float_class = image.special(sqc.SO_FLOAT_CLASS)
     
     assert w_float_class.size() == 9
     
@@ -70,3 +80,26 @@
     assert isinstance(w_float_class_name, sqm.W_BytesObject)
     
     assert w_float_class_name.bytes == list("Float")
+
+def test_lookup_abs_in_integer():
+    image = create_squeakimage()
+    amethod = None
+
+    w_smallint_class = image.special(sqc.SO_SMALLINTEGER_CLASS)
+
+    interp = sqi.Interpreter()
+
+    amethod = w_smallint_class.lookup("abs")
+                                  # First literal of the abs method is
+                                  # a real smalltalk int
+    w_frame = amethod.createFrame(amethod.literals[0], [])
+    interp.activeContext = w_frame
+
+    print amethod
+
+    while True:
+        try:
+            interp.step()
+            print interp.activeContext.stack
+        except sqi.ReturnFromTopLevel, e:
+            return e.object



More information about the Pypy-commit mailing list