From 199bb70150c59187db4cec7e45adc41e8ed56321 Mon Sep 17 00:00:00 2001 From: Kodi Arfer Date: Tue, 31 Oct 2017 16:49:29 -0700 Subject: [PATCH] Add a hy-repr test for keyword-like bytes objects --- tests/native_tests/contrib/hy_repr.hy | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/tests/native_tests/contrib/hy_repr.hy b/tests/native_tests/contrib/hy_repr.hy index 5085cc3..8787435 100644 --- a/tests/native_tests/contrib/hy_repr.hy +++ b/tests/native_tests/contrib/hy_repr.hy @@ -3,6 +3,7 @@ ;; license. See the LICENSE. (import + [hy._compat [PY3]] [math [isnan]] [hy.contrib.hy-repr [hy-repr hy-repr-register]]) @@ -78,6 +79,14 @@ (assert (is (type (get orig 1)) float)) (assert (is (type (get result 1)) HyFloat))) +(when PY3 (defn test-bytes-keywords [] + ; Make sure that keyword-like bytes objects aren't hy-repred as if + ; they were real keywords. + (setv kw :mykeyword) + (assert (= (hy-repr kw) ":mykeyword")) + (assert (= (hy-repr (str ':mykeyword)) ":mykeyword")) + (assert (= (hy-repr (.encode kw "UTF-8") #[[b"\xef\xb7\x90:hello"]]))))) + (defn test-hy-model-constructors [] (import hy) (assert (= (hy-repr (hy.HyInteger 7)) "'7"))