Test a case where hy-repr shouldn't round-trip
This commit is contained in:
parent
83c4f63bc2
commit
4f2706e18e
@ -65,6 +65,19 @@
|
|||||||
(setv rep (hy-repr (eval (read-str original-str))))
|
(setv rep (hy-repr (eval (read-str original-str))))
|
||||||
(assert (= rep 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 []
|
(defn test-hy-model-constructors []
|
||||||
(import hy)
|
(import hy)
|
||||||
(assert (= (hy-repr (hy.HyInteger 7)) "'7"))
|
(assert (= (hy-repr (hy.HyInteger 7)) "'7"))
|
||||||
|
Loading…
Reference in New Issue
Block a user