additional format fixes

This commit is contained in:
Alex Shinn 2017-12-10 15:51:18 +09:00
parent 79f08129b2
commit 9cc2192026
2 changed files with 8 additions and 4 deletions

View file

@ -29,6 +29,9 @@
(test "abc def" (show #f "abc" (tab-to) "def")) (test "abc def" (show #f "abc" (tab-to) "def"))
(test "abc def" (show #f "abc" (tab-to 5) "def")) (test "abc def" (show #f "abc" (tab-to 5) "def"))
(test "abcdef" (show #f "abc" (tab-to 3) "def")) (test "abcdef" (show #f "abc" (tab-to 3) "def"))
(test "abc\ndef\n" (show #f "abc" nl "def" nl))
(test "abc\ndef\n" (show #f "abc" fl "def" nl fl))
(test "abc\ndef\n" (show #f "abc" fl "def" fl fl))
;; numbers ;; numbers
@ -70,7 +73,7 @@
(test "1.00" (show #f (with ((precision 2)) .99755))) (test "1.00" (show #f (with ((precision 2)) .99755)))
(test "1.00" (show #f (with ((precision 2)) .997))) (test "1.00" (show #f (with ((precision 2)) .997)))
(test "0.99" (show #f (with ((precision 2)) .99))) (test "0.99" (show #f (with ((precision 2)) .99)))
(test "-15." (show #f (with ((precision 0)) -14.99995999999362))) (test "-15" (show #f (with ((precision 0)) -14.99995999999362)))
(test " 3.14159" (show #f (with ((decimal-align 5)) (numeric 3.14159)))) (test " 3.14159" (show #f (with ((decimal-align 5)) (numeric 3.14159))))
(test " 31.4159" (show #f (with ((decimal-align 5)) (numeric 31.4159)))) (test " 31.4159" (show #f (with ((decimal-align 5)) (numeric 31.4159))))

View file

@ -134,7 +134,7 @@
(let ((res (- (char->integer ch) (char->integer #\0)))) (let ((res (- (char->integer ch) (char->integer #\0))))
(if (<= 0 res 9) (if (<= 0 res 9)
res res
0))) ch)))
(define (round-up ls) (define (round-up ls)
(let lp ((ls ls) (res '())) (let lp ((ls ls) (res '()))
(cond (cond
@ -224,9 +224,10 @@
(or (> next 5) (or (> next 5)
(and (= next 5) (and (= next 5)
(string-cursor>? last (string-cursor-start s)) (string-cursor>? last (string-cursor-start s))
(odd? (digit-value (memv (digit-value
(string-cursor-ref (string-cursor-ref
s (string-cursor-prev s last)))))))) s (string-cursor-prev s last)))
'(1 3 5 7 9))))))
(list->string (list->string
(reverse (reverse
(map char-digit (map char-digit