Only in .: +changes-0.7.diff Only in /home/rotty/src/_readonly/fmt-0.7/: .hgignore Only in /home/rotty/src/_readonly/fmt-0.7/: Makefile Only in /home/rotty/src/_readonly/fmt-0.7/: README Only in /home/rotty/src/_readonly/fmt-0.7/: VERSION Only in /home/rotty/src/_readonly/fmt-0.7/: fmt Only in /home/rotty/src/_readonly/fmt-0.7/: fmt-c-chicken.scm Only in /home/rotty/src/_readonly/fmt-0.7/: fmt-c-gauche.scm Only in /home/rotty/src/_readonly/fmt-0.7/: fmt-c-mzscheme.scm Only in /home/rotty/src/_readonly/fmt-0.7/: fmt-chicken.scm Only in /home/rotty/src/_readonly/fmt-0.7/: fmt-color-chicken.scm Only in /home/rotty/src/_readonly/fmt-0.7/: fmt-color-gauche.scm Only in /home/rotty/src/_readonly/fmt-0.7/: fmt-color-mzscheme.scm Only in /home/rotty/src/_readonly/fmt-0.7/: fmt-gauche.scm Only in /home/rotty/src/_readonly/fmt-0.7/: fmt-mzscheme.scm Only in /home/rotty/src/_readonly/fmt-0.7/: fmt-scheme48.scm Only in /home/rotty/src/_readonly/fmt-0.7/: fmt-unicode-chicken.scm Only in /home/rotty/src/_readonly/fmt-0.7/: fmt-unicode-gauche.scm Only in /home/rotty/src/_readonly/fmt-0.7/: fmt-unicode-mzscheme.scm Only in /home/rotty/src/_readonly/fmt-0.7/: fmt.css Only in /home/rotty/src/_readonly/fmt-0.7/: fmt.html Only in /home/rotty/src/_readonly/fmt-0.7/: fmt.meta Only in /home/rotty/src/_readonly/fmt-0.7/: fmt.mistie Only in /home/rotty/src/_readonly/fmt-0.7/: fmt.setup Only in /home/rotty/src/_readonly/fmt-0.7/: let-optionals.scm Only in /home/rotty/src/_readonly/fmt-0.7/: make-eq-table.scm Only in /home/rotty/src/_readonly/fmt-0.7/: read-line.scm Only in /home/rotty/src/_readonly/fmt-0.7/: srfi-33.scm Only in /home/rotty/src/_readonly/fmt-0.7/: srfi-69.scm Only in /home/rotty/src/_readonly/fmt-0.7/: string-ports.scm diff -bur /home/rotty/src/_readonly/fmt-0.7//test-fmt.scm ./test-fmt.scm --- /home/rotty/src/_readonly/fmt-0.7//test-fmt.scm 2009-10-11 10:04:55.000000000 +0200 +++ ./test-fmt.scm 2010-04-12 11:03:16.000000000 +0200 @@ -1,21 +1,20 @@ -(cond-expand - (chicken (use test) (load "fmt-chicken.scm")) - (gauche - (use gauche.test) - (use text.fmt) - (define test-begin test-start) - (define orig-test (with-module gauche.test test)) - (define-syntax test +(define-syntax test (syntax-rules () - ((test name expected expr) - (guard (e (else #f)) - (orig-test name expected (lambda () expr)))) ((test expected expr) - (test (let ((s (with-output-to-string (lambda () (write 'expr))))) - (substring s 0 (min 60 (string-length s)))) - expected expr))))) - (else)) + (test-equal expected expr)))) + +;; pretty printing + +;; (define-macro (test-pretty str) +;; (let ((sexp (with-input-from-string str read))) +;; `(test ,str (fmt #f (pretty ',sexp))))) + +(define-syntax test-pretty + (syntax-rules () + ((test-pretty str) + (let ((sexp (call-with-string-input-port str read))) + (test str (fmt #f (pretty sexp))))))) (test-begin "fmt") @@ -123,12 +122,10 @@ (test "1.00" (fmt #f (fix 2 (num/fit 4 1)))) (test "#.##" (fmt #f (fix 2 (num/fit 4 12.345)))) -;; (cond -;; ((feature? 'full-numeric-tower) -;; (test "1+2i" (fmt #f (string->number "1+2i"))) -;; (test "1+2i" (fmt #f (num (string->number "1+2i")))) -;; (test "1.00+2.00i" (fmt #f (fix 2 (num (string->number "1+2i"))))) -;; (test "3.14+2.00i" (fmt #f (fix 2 (num (string->number "3.14159+2i"))))))) +(test "1+2i" (fmt #f (string->number "1+2i"))) +(test "1+2i" (fmt #f (num (string->number "1+2i")))) +(test "1.00+2.00i" (fmt #f (fix 2 (num (string->number "1+2i"))))) +(test "3.14+2.00i" (fmt #f (fix 2 (num (string->number "3.14159+2i"))))) (test "3.9Ki" (fmt #f (num/si 3986))) (test "4k" (fmt #f (num/si 3986 1000))) @@ -185,7 +182,7 @@ (test "prefix: defgh" (fmt #f "prefix: " (fit/left 5 "abcdefgh"))) (test "prefix: cdefg" (fmt #f "prefix: " (fit/both 5 "abcdefgh"))) -(test "abc\n123\n" (fmt #f (fmt-join/suffix (cut trim 3 <>) (string-split "abcdef\n123456\n" "\n") nl))) +(test "abc\n123\n" (fmt #f (fmt-join (cut trim 3 <>) (string-split "abcdef\n123456\n" "\n") nl))) ;; utilities @@ -224,18 +221,6 @@ (wrt/unshared (let ((ones (list 1))) (set-cdr! ones ones) ones))))) -;; pretty printing - -;; (define-macro (test-pretty str) -;; (let ((sexp (with-input-from-string str read))) -;; `(test ,str (fmt #f (pretty ',sexp))))) - -(define-syntax test-pretty - (syntax-rules () - ((test-pretty str) - (let ((sexp (with-input-from-string str read))) - (test str (fmt #f (pretty sexp))))))) - (test-pretty "(foo bar)\n") (test-pretty @@ -422,22 +407,24 @@ ;; misc extras +#; (define (string-hide-passwords str) (string-substitute (regexp "(pass(?:w(?:or)?d)?\\s?[:=>]\\s+)\\S+" #t) "\\1******" str #t)) - +#; (define hide-passwords (make-string-fmt-transformer string-hide-passwords)) +#; (define (string-mangle-email str) (string-substitute (regexp "\\b([-+.\\w]+)@((?:[-+\\w]+\\.)+[a-z]{2,4})\\b" #t) "\\1 _at_ \\2" str #t)) - +#; (define mangle-email (make-string-fmt-transformer string-mangle-email))