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
|
|
|
|
|
2015-01-24 01:32:20 +01:00
|
|
|
from hy.models import wrap_value
|
2014-09-21 18:08:14 +02:00
|
|
|
|
|
|
|
|
|
|
|
def test_wrap_long_type():
|
|
|
|
""" Test conversion of integers."""
|
2015-01-24 01:32:20 +01:00
|
|
|
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."""
|
2015-01-24 01:32:20 +01:00
|
|
|
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."""
|
2015-01-24 01:32:20 +01:00
|
|
|
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)])
|