Skip to content

Commit

Permalink
CLJS-2880: cl-format octal and Unicode character directives fail
Browse files Browse the repository at this point in the history
  • Loading branch information
mfikes committed May 29, 2020
1 parent 790bcbf commit 39709c9
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/main/cljs/cljs/pprint.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -1362,8 +1362,8 @@ http://www.lispworks.com/documentation/HyperSpec/Body/22_c.htm"
(defn- readable-character [params navigator offsets]
(let [[c navigator] (next-arg navigator)]
(condp = (:char-format params)
\o (cl-format true "\\o~3, '0o" (char-code c))
\u (cl-format true "\\u~4, '0x" (char-code c))
\o (cl-format true "\\o~3,'0o" (char-code c))
\u (cl-format true "\\u~4,'0x" (char-code c))
nil (print-char c))
navigator))

Expand Down
7 changes: 7 additions & 0 deletions src/test/cljs/cljs/pprint_test.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -1087,6 +1087,13 @@ Usage: *hello*
"
)

(deftest test-cljs-2880
(are [expected format]
(= expected (with-out-str (cl-format true format \a)))
"\\a" "~@c"
"\\o141" "~'o@c"
"\\u0061" "~'u@c"))

(deftest test-cljs-2881
(are [expected ch]
(= expected (with-out-str (cl-format true "~@c" ch)))
Expand Down

0 comments on commit 39709c9

Please sign in to comment.