Fix up quoting keywords.

Fixes this:

=> :foo
'\ufdd0:foo'
=> `:foo
'\ufdd0\ufdd0:foo'
This commit is contained in:
Paul Tagliamonte 2014-02-17 17:57:27 -05:00
parent 6e0486ba78
commit e219973853
2 changed files with 9 additions and 1 deletions

View File

@ -29,5 +29,8 @@ class HyKeyword(HyObject, str_type):
""" """
def __new__(cls, value): def __new__(cls, value):
obj = str_type.__new__(cls, "\uFDD0" + value) if not value.startswith("\uFDD0"):
value = "\uFDD0" + value
obj = str_type.__new__(cls, value)
return obj return obj

View File

@ -983,3 +983,8 @@
(assert (is bar (get foo 1))) (assert (is bar (get foo 1)))
(setv (. foo [1] test) "hello") (setv (. foo [1] test) "hello")
(assert (= (getattr (. foo [1]) "test") "hello"))) (assert (= (getattr (. foo [1]) "test") "hello")))
(defn test-keyword-quoting []
"NATIVE: test keyword quoting magic"
(assert (= :foo "\ufdd0:foo"))
(assert (= `:foo "\ufdd0:foo")))