Make HyList add returns HyList

Signed-off-by: Julien Danjou <julien@danjou.info>
This commit is contained in:
Julien Danjou 2013-04-28 16:56:28 +02:00
parent 27e74d43b1
commit 9b261a5004
3 changed files with 12 additions and 0 deletions

View File

@ -33,5 +33,8 @@ class HyList(HyObject, list):
HyObject.replace(self, other)
return self
def __add__(self, other):
return self.__class__(super(HyList, self).__add__(other))
def __repr__(self):
return "[%s]" % (" ".join([str(x) for x in self]))

0
tests/models/__init__.py Normal file
View File

View File

@ -0,0 +1,9 @@
from hy.models.list import HyList
def test_list_add():
a = HyList([1, 2, 3])
b = HyList([3, 4, 5])
c = a + b
assert c == [1, 2, 3, 3, 4, 5]
assert c.__class__ == HyList