[pypy-svn] r66631 - in pypy/branch/io-lang/pypy/lang/io: . test
david at codespeak.net
david at codespeak.net
Sat Jul 25 20:40:26 CEST 2009
Author: david
Date: Sat Jul 25 20:40:25 2009
New Revision: 66631
Modified:
pypy/branch/io-lang/pypy/lang/io/object.py
pypy/branch/io-lang/pypy/lang/io/test/test_object.py
Log:
Object doMessage
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 Sat Jul 25 20:40:25 2009
@@ -97,4 +97,13 @@
@register_method('Object', 'appendProto', unwrap_spec=[object, object])
def object_append_proto(space, w_target, w_proto):
w_target.protos.append(w_proto)
- return w_target
\ No newline at end of file
+ return w_target
+
+ at register_method('Object', 'doMessage',)
+def object_do_message(space, w_target, w_message, w_context):
+ w_msg = w_message.arguments[0].eval(space, w_context, w_context)
+ w_receiver = w_target
+ if len(w_message.arguments) == 2:
+ w_receiver = w_message.arguments[1].eval(space, w_context, w_context)
+
+ return w_msg.eval(space, w_receiver, w_receiver)
\ No newline at end of file
Modified: pypy/branch/io-lang/pypy/lang/io/test/test_object.py
==============================================================================
--- pypy/branch/io-lang/pypy/lang/io/test/test_object.py (original)
+++ pypy/branch/io-lang/pypy/lang/io/test/test_object.py Sat Jul 25 20:40:25 2009
@@ -94,4 +94,26 @@
x"""
res, _ = interpret(inp)
- assert res.value == 9
\ No newline at end of file
+ assert res.value == 9
+
+def test_object_append_proto():
+ inp = """a := Object clone
+ b := Object clone
+ a appendProto(b)"""
+ res, space = interpret(inp)
+ assert res.protos == [space.w_object, space.w_lobby.slots['b']]
+
+def test_object_doMessage():
+ inp = """m := message(asNumber + 123)
+ 1 doMessage(m)"""
+ res, space = interpret(inp)
+
+ assert res.value == 124
+
+
+def test_object_doMessage_optional_context():
+ inp = """m := message(asNumber + 123)
+ 1 doMessage(m, 2)"""
+ res, space = interpret(inp)
+
+ assert res.value == 125
\ No newline at end of file
More information about the Pypy-commit
mailing list