[pypy-svn] r64833 - in pypy/branch/io-lang/pypy/lang/io: . test

david at codespeak.net david at codespeak.net
Wed Apr 29 19:59:01 CEST 2009


Author: david
Date: Wed Apr 29 19:58:52 2009
New Revision: 64833

Modified:
   pypy/branch/io-lang/pypy/lang/io/object.py
   pypy/branch/io-lang/pypy/lang/io/test/test_method.py
Log:
add getSlot method to object and test call on method not-activated method objects

Modified: pypy/branch/io-lang/pypy/lang/io/object.py
==============================================================================
--- pypy/branch/io-lang/pypy/lang/io/object.py	(original)
+++ pypy/branch/io-lang/pypy/lang/io/object.py	Wed Apr 29 19:58:52 2009
@@ -9,6 +9,12 @@
     w_target.slots[w_name.value] = w_value
     return w_value
     
+ at register_method('Object', 'getSlot')
+def w_object_get_slot(space, w_target, w_message, w_context):
+    w_name = w_message.arguments[0].eval(space, w_context, w_context)
+    assert isinstance(w_name, W_ImmutableSequence)
+    return w_target.slots[w_name.value]
+
 @register_method('Object', 'method')
 def w_object_method(space, w_target, w_message, w_context):
     w_body = w_message.arguments[-1]

Modified: pypy/branch/io-lang/pypy/lang/io/test/test_method.py
==============================================================================
--- pypy/branch/io-lang/pypy/lang/io/test/test_method.py	(original)
+++ pypy/branch/io-lang/pypy/lang/io/test/test_method.py	Wed Apr 29 19:58:52 2009
@@ -45,4 +45,9 @@
     inp = 'Block'
     res,space = interpret(inp)
     assert isinstance(res, W_Block)
-    assert res.protos == [space.w_object]
\ No newline at end of file
+    assert res.protos == [space.w_object]
+    
+def test_call_on_method():
+    inp = 'a := method(x, x + 1); getSlot("a") call(3)'
+    res, space = interpret(inp)
+    assert res.value == 4
\ No newline at end of file



More information about the Pypy-commit mailing list