From 0bbb5f8e34abd643bcd2fbf970ab66c42ec21eef Mon Sep 17 00:00:00 2001 From: Kodi Arfer Date: Wed, 19 Jul 2017 10:25:24 -0700 Subject: [PATCH] hy-repr: Support #* and #** --- hy/contrib/hy_repr.hy | 4 ++++ tests/native_tests/contrib/hy_repr.hy | 7 ++++--- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/hy/contrib/hy_repr.hy b/hy/contrib/hy_repr.hy index 2053504..ea67efc 100644 --- a/hy/contrib/hy_repr.hy +++ b/hy/contrib/hy_repr.hy @@ -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) ")")) diff --git a/tests/native_tests/contrib/hy_repr.hy b/tests/native_tests/contrib/hy_repr.hy index 9bbdd09..a9c0475 100644 --- a/tests/native_tests/contrib/hy_repr.hy +++ b/tests/native_tests/contrib/hy_repr.hy @@ -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))))