[pypy-svn] r65459 - in pypy/branch/io-lang/pypy/lang/io: . test
david at codespeak.net
david at codespeak.net
Wed May 27 17:32:15 CEST 2009
Author: david
Date: Wed May 27 17:32:13 2009
New Revision: 65459
Modified:
pypy/branch/io-lang/pypy/lang/io/list.py
pypy/branch/io-lang/pypy/lang/io/model.py
pypy/branch/io-lang/pypy/lang/io/test/test_list.py
Log:
(cfbolz, david) fixed list append operation
Modified: pypy/branch/io-lang/pypy/lang/io/list.py
==============================================================================
--- pypy/branch/io-lang/pypy/lang/io/list.py (original)
+++ pypy/branch/io-lang/pypy/lang/io/list.py Wed May 27 17:32:13 2009
@@ -3,8 +3,8 @@
@register_method('List', 'append')
def list_append(space, w_target, w_message, w_context):
assert w_message.arguments, 'requires at least one argument'
- w_items = [x.eval(space, w_target, w_context) for x in w_message.arguments]
- w_target.append(w_items)
+ items_w = [x.eval(space, w_target, w_context) for x in w_message.arguments]
+ w_target.extend(items_w)
return w_target
@register_method('List', 'at', unwrap_spec=[object, int])
Modified: pypy/branch/io-lang/pypy/lang/io/model.py
==============================================================================
--- pypy/branch/io-lang/pypy/lang/io/model.py (original)
+++ pypy/branch/io-lang/pypy/lang/io/model.py Wed May 27 17:32:13 2009
@@ -55,8 +55,8 @@
W_Object.__init__(self, space, protos)
self.items = items
- def append(self, w_items):
- self.items += w_items
+ def extend(self, items_w):
+ self.items.extend(items_w)
def __getitem__(self, index):
try:
Modified: pypy/branch/io-lang/pypy/lang/io/test/test_list.py
==============================================================================
--- pypy/branch/io-lang/pypy/lang/io/test/test_list.py (original)
+++ pypy/branch/io-lang/pypy/lang/io/test/test_list.py Wed May 27 17:32:13 2009
@@ -26,6 +26,15 @@
inp = "a := list(); a append(1)"
res,space = interpret(inp)
assert res.items == [W_Number(space, 1)]
+
+def test_list_append_multiple():
+ inp = "a := list(1,2); a append(3,4,5)"
+ res,space = interpret(inp)
+ assert res.items == [W_Number(space, 1),
+ W_Number(space, 2),
+ W_Number(space, 3),
+ W_Number(space, 4),
+ W_Number(space, 5)]
def test_list_at():
inp = "a := list(1,2,3); a at(2)"
More information about the Pypy-commit
mailing list