Skip to content

Commit

Permalink
Fix ratio formatting (closes #15)
Browse files Browse the repository at this point in the history
  • Loading branch information
tonsky committed Jun 16, 2021
1 parent 0b4fb4d commit 3a1cdec
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
3 changes: 2 additions & 1 deletion src/tongue/number.cljc
Expand Up @@ -34,7 +34,8 @@

:else
(fn [x]
(let [[_ sign integer-part fraction-part] (re-matches #"(-?)(\d+)\.?(\d*)" (str x))
(let [s (str #?(:clj (if (ratio? x) (double x) x) :cljs x))
[_ sign integer-part fraction-part] (re-matches #"(-?)(\d+)\.?(\d*)" s)
len (count integer-part)]
(str sign
(loop [idx (rem len 3)
Expand Down
3 changes: 2 additions & 1 deletion test/tongue/test/number.cljc
Expand Up @@ -22,7 +22,8 @@
-500 "-500"
-1500 "-1 500"
-100500 "-100 500"
-100500.1 "-100 500,1")))
-100500.1 "-100 500,1"
#?@(:clj [1/2 "0,5"]))))


(deftest test-translate
Expand Down

0 comments on commit 3a1cdec

Please sign in to comment.