From 4f2706e18e5148a4cb6049b5c0197e93a4c0afaf Mon Sep 17 00:00:00 2001 From: Kodi Arfer Date: Tue, 31 Oct 2017 11:35:46 -0700 Subject: [PATCH] Test a case where hy-repr shouldn't round-trip --- tests/native_tests/contrib/hy_repr.hy | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/tests/native_tests/contrib/hy_repr.hy b/tests/native_tests/contrib/hy_repr.hy index 45129c9..5085cc3 100644 --- a/tests/native_tests/contrib/hy_repr.hy +++ b/tests/native_tests/contrib/hy_repr.hy @@ -65,6 +65,19 @@ (setv rep (hy-repr (eval (read-str original-str)))) (assert (= rep original-str)))) +(defn test-hy-repr-no-roundtrip [] + ; Test one of the corner cases in which hy-repr doesn't + ; round-trip: when a HyObject contains a non-HyObject, we + ; promote the constituent to a HyObject. + + (setv orig `[a ~5.0]) + (setv reprd (hy-repr orig)) + (assert (= reprd "'[a 5.0]")) + (setv result (eval (read-str reprd))) + + (assert (is (type (get orig 1)) float)) + (assert (is (type (get result 1)) HyFloat))) + (defn test-hy-model-constructors [] (import hy) (assert (= (hy-repr (hy.HyInteger 7)) "'7"))