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

david at codespeak.net david at codespeak.net
Thu Jul 23 18:31:30 CEST 2009


Author: david
Date: Thu Jul 23 18:31:30 2009
New Revision: 66547

Modified:
   pypy/branch/io-lang/pypy/lang/io/message.py
   pypy/branch/io-lang/pypy/lang/io/test/test_message.py
Log:
name on Message

Modified: pypy/branch/io-lang/pypy/lang/io/message.py
==============================================================================
--- pypy/branch/io-lang/pypy/lang/io/message.py	(original)
+++ pypy/branch/io-lang/pypy/lang/io/message.py	Thu Jul 23 18:31:30 2009
@@ -1,5 +1,5 @@
 from pypy.lang.io.register import register_method
-from pypy.lang.io.model import W_Message
+from pypy.lang.io.model import W_Message, W_ImmutableSequence
 
 @register_method('Message', 'argAt', unwrap_spec=[object, int])
 def message_arg_at(space, w_message, arg_num):
@@ -10,7 +10,11 @@
 @register_method('Message', 'arguments')
 def message_arguments(space, w_receiver, w_message, w_context):
   return space.w_list.clone_and_init(space, w_receiver.arguments)
-  
+ 
+ at register_method('Message', 'name')
+def message_name(space, w_receiver, w_message, w_context):
+    # XXX TODO clone from space
+    return W_ImmutableSequence(space, w_receiver.name)
 
 # @register_method('Message', 'setIsActivatable', unwrap_spec=[object, bool])
 # def message_setIsActivatable(space, w_target, setting):

Modified: pypy/branch/io-lang/pypy/lang/io/test/test_message.py
==============================================================================
--- pypy/branch/io-lang/pypy/lang/io/test/test_message.py	(original)
+++ pypy/branch/io-lang/pypy/lang/io/test/test_message.py	Thu Jul 23 18:31:30 2009
@@ -1,5 +1,5 @@
 from pypy.lang.io.parserhack import interpret
-from pypy.lang.io.model import W_Message, W_Block, W_List
+from pypy.lang.io.model import W_Message, W_Block, W_List, W_ImmutableSequence
 import py
 
 
@@ -23,7 +23,14 @@
   assert res[0].name == 'C'
   assert res[0].next.name == 'D' 
   assert res[1].name == 'E'
-  
+
+def test_message_name():
+    inp = """msg := message(B(C D, E));
+    msg name"""
+    res, space = interpret(inp)
+    assert isinstance(res, W_ImmutableSequence)
+    assert res.value == 'B'
+    
 # def test_setIsActivatable():
 #     inp = "a := block(1);a setIsActivateable(true); a"
 #     res,space = interpret(inp)



More information about the Pypy-commit mailing list