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

niko at codespeak.net niko at codespeak.net
Fri Oct 26 16:20:12 CEST 2007


Author: niko
Date: Fri Oct 26 16:20:10 2007
New Revision: 48066

Modified:
   pypy/dist/pypy/lang/smalltalk/model.py
   pypy/dist/pypy/lang/smalltalk/test/test_primitives.py
Log:
(all)
change at0 and atput0 to use character in bytes-based objects.
we can't figure out if this is correct, but it makes the 
Squeak's 0 tinyBenchmarks run!



Modified: pypy/dist/pypy/lang/smalltalk/model.py
==============================================================================
--- pypy/dist/pypy/lang/smalltalk/model.py	(original)
+++ pypy/dist/pypy/lang/smalltalk/model.py	Fri Oct 26 16:20:10 2007
@@ -162,10 +162,11 @@
 
     def at0(self, index0):
         from pypy.lang.smalltalk import objtable
-        return objtable.wrap_int(self.getbyte(index0))
+        return objtable.CharacterTable[self.getbyte(index0)]
        
     def atput0(self, index0, w_value):
-        self.setbyte(index0, unwrap_int(w_value))
+        from pypy.lang.smalltalk import objtable
+        self.setbyte(index0, objtable.ord_w_char(w_value))
 
     def getbyte(self, n):
         return ord(self.bytes[n])

Modified: pypy/dist/pypy/lang/smalltalk/test/test_primitives.py
==============================================================================
--- pypy/dist/pypy/lang/smalltalk/test/test_primitives.py	(original)
+++ pypy/dist/pypy/lang/smalltalk/test/test_primitives.py	Fri Oct 26 16:20:10 2007
@@ -187,6 +187,16 @@
     assert prim(primitives.AT_PUT, [w_obj, 1, 22]).value == 22
     assert prim(primitives.AT, [w_obj, 1]).value == 22
     
+def test_at_bytes():
+    assert prim(primitives.AT, ["abc", 1]) is wrap("a")
+
+def test_at_put_bytes():
+    w_str = wrap("abc")
+    assert prim(primitives.AT_PUT, [w_str, 1, "d"]) is wrap("d")
+    assert prim(primitives.AT, [w_str, 1]) is wrap("d")
+    assert prim(primitives.AT, [w_str, 2]) is wrap("b")
+    assert prim(primitives.AT, [w_str, 3]) is wrap("c")
+
 def test_invalid_at_put():
     w_obj = mockclass(0).as_class_get_shadow().new()
     prim_fails(primitives.AT_PUT, [w_obj, 1, 22])



More information about the Pypy-commit mailing list