hy-repr: Support #* and #**

This commit is contained in:
Kodi Arfer 2017-07-19 10:25:24 -07:00
parent 784a44601b
commit 0bbb5f8e34
2 changed files with 8 additions and 3 deletions

View File

@ -37,6 +37,10 @@
(+ "~" (f (second x) q))
(= (first x) 'unquote_splice)
(+ "~@" (f (second x) q))
(= (first x) 'unpack_iterable)
(+ "#* " (f (second x) q))
(= (first x) 'unpack_mapping)
(+ "#** " (f (second x) q))
; else
(+ "(" (catted) ")"))
(+ "(" (catted) ")"))

View File

@ -28,8 +28,8 @@
[1 2 3] (, 1 2 3) #{1 2 3} (frozenset #{1 2 3})
'[1 2 3] '(, 1 2 3) '#{1 2 3} '(frozenset #{1 2 3})
{"a" 1 "b" 2 "a" 3} '{"a" 1 "b" 2 "a" 3}
[1 [2 3] (, 4 (, 'mysymbol :mykeyword)) {"a" b"hello"}]
'[1 [2 3] (, 4 (, mysymbol :mykeyword)) {"a" b"hello"}]])
[1 [2 3] (, 4 (, 'mysymbol :mykeyword)) {"a" b"hello"} '(f #* a #** b)]
'[1 [2 3] (, 4 (, mysymbol :mykeyword)) {"a" b"hello"} (f #* a #** b)]])
(for [original-val values]
(setv evaled (eval (read-str (hy-repr original-val))))
(assert (= evaled original-val))
@ -59,7 +59,8 @@
"{1 20}"
"'{1 10 1 20}"
"'asymbol"
":akeyword"])
":akeyword"
"'(f #* args #** kwargs)"])
(for [original-str strs]
(setv rep (hy-repr (eval (read-str original-str))))
(assert (= rep original-str))))