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

lukas at codespeak.net lukas at codespeak.net
Fri Oct 26 17:59:08 CEST 2007


Author: lukas
Date: Fri Oct 26 17:59:06 2007
New Revision: 48082

Modified:
   pypy/dist/pypy/lang/smalltalk/primitives.py
   pypy/dist/pypy/lang/smalltalk/test/test_interpreter.py
   pypy/dist/pypy/lang/smalltalk/test/test_primitives.py
Log:
added test for #size bytecode and fixed the bug found in primitive and interpreter and associated tests


Modified: pypy/dist/pypy/lang/smalltalk/primitives.py
==============================================================================
--- pypy/dist/pypy/lang/smalltalk/primitives.py	(original)
+++ pypy/dist/pypy/lang/smalltalk/primitives.py	Fri Oct 26 17:59:06 2007
@@ -318,7 +318,7 @@
 def func(interp, w_obj):
     if not w_obj.shadow_of_my_class().isvariable():
         raise PrimitiveFailedError()
-    return wrap_int(w_obj.size())
+    return wrap_int(w_obj.size() - w_obj.shadow_of_my_class().instsize())
 
 @expose_primitive(STRING_AT, unwrap_spec=[object, index1_0])
 def func(interp, w_obj, n0):

Modified: pypy/dist/pypy/lang/smalltalk/test/test_interpreter.py
==============================================================================
--- pypy/dist/pypy/lang/smalltalk/test/test_interpreter.py	(original)
+++ pypy/dist/pypy/lang/smalltalk/test/test_interpreter.py	Fri Oct 26 17:59:06 2007
@@ -349,6 +349,15 @@
     assert interp.w_active_context.stack == []
     assert w_fakeinst.getclass() == w_fakeclass
     assert w_fakeinst.size() == 3
+ 
+def test_bytecodePrimSize():
+    w_fakeclass = mockclass(2, name='fakeclass', varsized=True)
+    w_fakeinst = w_fakeclass.as_class_get_shadow().new(5)
+    interp = new_interpreter(bytecodePrimSize)
+    interp.w_active_context.push(w_fakeinst)
+    interp.step()
+    assert interp.w_active_context.pop().value == 5
+    assert interp.w_active_context.stack == []
 
 # w_class - the class from which the method is going to be called
 # (and on which it is going to be installed)

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 17:59:06 2007
@@ -204,10 +204,6 @@
     assert prim(primitives.SIZE, [w_obj]).value == 0
     w_obj = mockclass(3, varsized=True).as_class_get_shadow().new(5)
     assert prim(primitives.SIZE, [w_obj]).value == 5
-    
-def test_size():
-    w_obj = mockclass(0).as_class_get_shadow().new(0)
-    prim_fails(primitives.SIZE, [w_obj])
 
 def test_string_at():
     assert prim(primitives.STRING_AT, ["foobar", 4]) == wrap("b")



More information about the Pypy-commit mailing list