From 3503ed902728b5cfaa58d7b6fc028310a3e7b3b4 Mon Sep 17 00:00:00 2001 From: Ian Denhardt Date: Sun, 21 Sep 2014 12:08:14 -0400 Subject: [PATCH] Add tests for _wrap_value --- tests/macros/test_wrap_value.py | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) create mode 100644 tests/macros/test_wrap_value.py diff --git a/tests/macros/test_wrap_value.py b/tests/macros/test_wrap_value.py new file mode 100644 index 0000000..0a6e7d5 --- /dev/null +++ b/tests/macros/test_wrap_value.py @@ -0,0 +1,28 @@ +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.macros import _wrap_value + + +def test_wrap_long_type(): + """ Test conversion of integers.""" + wrapped = _wrap_value(long_type(0)) + assert type(wrapped) == HyInteger + + +def test_wrap_tuple(): + """ Test conversion of tuples.""" + wrapped = _wrap_value((HyInteger(0),)) + 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)])) + assert type(wrapped) == HyExpression + assert type(wrapped[0]) == HyInteger + assert wrapped == HyExpression([HyInteger(0)])