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

niko at codespeak.net niko at codespeak.net
Fri Oct 26 12:07:46 CEST 2007


Author: niko
Date: Fri Oct 26 12:07:45 2007
New Revision: 48036

Modified:
   pypy/dist/pypy/lang/smalltalk/primitives.py
   pypy/dist/pypy/lang/smalltalk/test/test_interpreter.py
Log:
(niko, arigo, lukas)
introduce hack to give a value:value: method to the BlockContext
during the test bc_x_plus_y()



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 12:07:45 2007
@@ -627,7 +627,6 @@
     
 @expose_primitive(PRIMITIVE_VALUE)
 def func(interp, argument_count):
-    # XXX XXX XXX XXX test me
     # argument_count does NOT include the receiver.
     # This means that for argument_count == 3 the stack looks like:
     #  3      2       1      Top

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 12:07:45 2007
@@ -492,16 +492,21 @@
           176, 118, 176, 125, 32, 202, 124 ],
         fakeliterals(wrap_int(3)))
 
-# we skip this test, because it requires to lookup the method #value:value: 
-# in the BlockContext class, which we don't have at the moment
-#
-# def test_bc_x_plus_y():
-#     # value2
-#     # 	" (self >> #value2) byteCode "
-#     # 	" (self >> #value2) literals "
-#     # 
-#     # 	^ [ :x :y | x + y ] value: 3 value: 4
-#     interp_bc_and_check_result_is_7(
-#         [ 137, 119, 200, 164, 6, 105, 104, 16, 17,
-#           176, 125, 33, 34, 240, 124 ],
-#         fakeliterals("value:value:", wrap_int(3), wrap_int(4)))
\ No newline at end of file
+def test_bc_x_plus_y():
+    # value2
+    # 	" (self >> #value2) byteCode "
+    # 	" (self >> #value2) literals "
+    # 
+    # 	^ [ :x :y | x + y ] value: 3 value: 4
+    s_BlockContext = ct.w_BlockContext.as_class_get_shadow()
+    prim_meth = model.W_CompiledMethod(
+        0, "", argsize=2, primitive=primitives.PRIMITIVE_VALUE)
+    s_BlockContext.installmethod("value:value:", prim_meth)
+    try:
+        interp_bc_and_check_result_is_7(
+            [ 137, 119, 200, 164, 6, 105, 104, 16, 17,
+              176, 125, 33, 34, 240, 124 ],
+            fakeliterals("value:value:", wrap_int(3), wrap_int(4)))
+    finally:
+        del s_BlockContext.methoddict['value:value:']    # clean up after you
+



More information about the Pypy-commit mailing list