hy/tests/models/test_wrap_value.py

29 lines
851 B
Python
Raw Normal View History

2014-09-21 18:08:14 +02:00
from hy._compat import long_type
from hy.models.integer import HyInteger
from hy.models.list import HyList
from hy.models.expression import HyExpression
from hy.models import wrap_value
2014-09-21 18:08:14 +02:00
def test_wrap_long_type():
""" Test conversion of integers."""
wrapped = wrap_value(long_type(0))
2014-09-21 18:08:14 +02:00
assert type(wrapped) == HyInteger
def test_wrap_tuple():
""" Test conversion of tuples."""
wrapped = wrap_value((HyInteger(0),))
2014-09-21 18:08:14 +02:00
assert type(wrapped) == HyList
assert type(wrapped[0]) == HyInteger
assert wrapped == HyList([HyInteger(0)])
def test_wrap_nested_expr():
""" Test conversion of HyExpressions with embedded non-HyObjects."""
wrapped = wrap_value(HyExpression([long_type(0)]))
2014-09-21 18:08:14 +02:00
assert type(wrapped) == HyExpression
assert type(wrapped[0]) == HyInteger
assert wrapped == HyExpression([HyInteger(0)])