Add a hy-repr test for keyword-like bytes objects

This commit is contained in:
Kodi Arfer 2017-10-31 16:49:29 -07:00
parent 4f2706e18e
commit 199bb70150

View File

@ -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"))