Make HyList add returns HyList
Signed-off-by: Julien Danjou <julien@danjou.info>
This commit is contained in:
parent
27e74d43b1
commit
9b261a5004
@ -33,5 +33,8 @@ class HyList(HyObject, list):
|
|||||||
HyObject.replace(self, other)
|
HyObject.replace(self, other)
|
||||||
return self
|
return self
|
||||||
|
|
||||||
|
def __add__(self, other):
|
||||||
|
return self.__class__(super(HyList, self).__add__(other))
|
||||||
|
|
||||||
def __repr__(self):
|
def __repr__(self):
|
||||||
return "[%s]" % (" ".join([str(x) for x in self]))
|
return "[%s]" % (" ".join([str(x) for x in self]))
|
||||||
|
0
tests/models/__init__.py
Normal file
0
tests/models/__init__.py
Normal file
9
tests/models/test_list.py
Normal file
9
tests/models/test_list.py
Normal 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
|
Loading…
Reference in New Issue
Block a user