; FILE AUTOMATICALLY GENERATED! ; ; This file was automatically generated by the svnwiki-scheme-library extension. ; The authoritative source for this is: ; ; http://wiki.freaks-unidos.net/weblogs/azul/format-compiler ; ; Generation data: ; ; Input revision: 16998 ; User: www-data ; Machine: mononykus.freaks-unidos.net ; Date: Mon Jul 5 21:33:46 2010 (module format-compiler (*formatter-params* *formatter-iteration* *formatter-caseconv* *formatter-chars* *formatter-numbers* *formatter-cond* *formatter-indirection* *formatter-jump* *formatter-objs* *formatter-flush* *formatter-plural* *formatter-tabulate* *format-spec* format formatter-padded) (import chicken scheme) (use embedded-test format-compiler-base srfi-1 ports data-structures) (test-group formatter->table (test ((vector-ref (formatter->table #f `(((#\a ,(constantly 1))))) (char->integer #\a))) 1) (test ((vector-ref (formatter->table #f `(((#\a ,(constantly 1))) ((#\a ,(constantly 2))))) (char->integer #\a))) 1) (test ((vector-ref (formatter->table #f `(((#\a ,(constantly 1))) ((#\A ,(constantly 2))))) (char->integer #\A))) 1) (test ((vector-ref (formatter->table #t `(((#\a ,(constantly 1))) ((#\A ,(constantly 2))))) (char->integer #\A))) 2) (test ((vector-ref (formatter->table #t `(((#\a ,(constantly 1)))) (constantly 2)) (char->integer #\A))) 2)) (test-group formatter-params (test (test-params "'A") '(1 #\A)) (test (test-params "'A,'B") '(2 #\A #\B)) (test (test-params "23") '(1 23)) (test (test-params ",,3,") '(3 #f #f 3)) (test (test-params "1,'b,-2,'a,+3,,4,") '(7 1 #\b -2 #\a 3 #f 4))) (test-group add-param-character-from-format (test (with-output-to-string (lambda () ((add-param-character-from-format (make-escape-call (make-compiler-state (make-compiler (formatter->table #f '()) #\~) "~'" 2 #f '()) 0 #f #f 0)) (make-default-state (current-output-port) '())))) "~'")) (test-group find-end-of-number (test (find-end-of-number "~23" 1) 3) (test (find-end-of-number "~+38,3,4" 1) 4)) (test-group format-case-convert (test (format #f "uN~(foo hey~)uN") "uNfoo heyuN") (test (format #f "uN~:(foo hey~)uN") "uNFoo HeyuN") (test (format #f "uN~:@(foo ~(there~) hey~)uN") "uNFOO THERE HEYuN")) (test-group case-convert (test (case-convert-string "foo bar hey" char-upcase char-downcase char-downcase) "Foo bar hey") (test (case-convert-string "foo bar hey" char-upcase char-upcase char-downcase) "Foo Bar Hey") (test (case-convert-string "foo bar hey" char-upcase char-downcase char-upcase) "FOO bAR hEY")) (test-group format-conditional-expressions (test (format #f "(~0[a~;b~])") "(a)") (test (format #f "(~1[a~;b~])") "(b)") (test (format #f "(~0[a~:;b~])") "(a)") (test (format #f "(~5[a~:;b~])") "(b)")) (test-group format-iteration (test (format #f "~{(~c)~}" '(#\a #\b #\c)) "(a)(b)(c)") (test (format #f "Data: ~{~c~^, ~}" '(#\a #\b #\c)) "Data: a, b, c") (test (format #f "~2{(~c)~}" '(#\a #\b #\c)) "(a)(b)") (test (format #f "<~:{(~@{~c~^, ~})~}>" '((#\a #\b #\c) (#\d) (#\e #\f))) "<(a, b, c)(d)(e, f)>") (test (format #f "<~@{~c~^, ~}>" #\a #\b #\c) "")) (test-group format-fixed-characters (test (format #f "~4%") "\n\n\n\n")) (test-group format-indirection (test (format #f "[~?]~A" "<~A,~A>" '(1 2) 3) "[<1,2>]3") (test (format #f "[~1,2@?]~A" "<~A,~A>" 3) "[<1,2>]3")) (test-group format-argument-jumping (test (format #f "(~*~C~C)" #\a #\b #\c) "(bc)") (test (format #f "(~2*~C)" #\a #\b #\c) "(c)") (test (format #f "(~2*~:*~C~C)" #\a #\b #\c) "(bc)") (test (format #f "(~2*~-1*~C~C)" #\a #\b #\c) "(bc)") (test (format #f "~*~@{<~-1*~C, ~C>~^, ~}" #\a #\b #\c #\d) ", , ") (test (format #f "~:@1*~@{~C~}" #\a #\b #\c #\d #\e) "de")) (test-group format-object-output (test (format #f "[~C][~C]" #\a #\b) "[a][b]") (test (format #f "~A ~A" "hey" "alejo") "hey alejo")) (test-group format-integer (test (format #f "(~D)" -12345678) "(-12345678)") (test (format #f "(~5D)" 123) "( 123)") (test (format #f "(~5,'#D)" 123) "(##123)") (test (format #f "(~,,',,3D)" 12345678) "(12345678)") (test (format #f "(~:D)" 12345678) "(12,345,678)") (test (format #f "(~,,'.,2:D)" 12345678) "(12.34.56.78)") (test (format #f "(~@5D)" 123) "( +123)") (test (format #f "(~@5D)" -123) "( -123)") (test (format #f "(~@X)" 193) "(+c1)") (test (format #f "(~O)" 17) "(21)") (test (format #f "(~B)" 23) "(10111)") (test (format #f "(~7@B)" 23) "( +10111)")) (test-group format-radix (test (format #f "~{~@R~^ ~}" (iota 11 5)) "V VI VII VIII IX X XI XII XIII XIV XV") (test (format #f "~@R ~@R" 2010 1998) "MMX MCMXCVIII") (test (format #f "~@:R" 1998) "MDCCCCLXXXXVIII") (test (format #f "~:R" 3035) "three thousand, thirty-fifth") (test (format #f "~:R" 3000) "three thousandth")) (test-group add-comma (test (add-comma #\, 3 (string->list "123")) (string->list "123")) (test (add-comma #\, 3 (string->list "1234567")) (string->list "1,234,567")) (test (add-comma #\, 3 (string->list "+123")) (string->list "+123")) (test (add-comma #\, 3 (string->list "+12")) (string->list "+12")) (test (add-comma #\, 3 (string->list "-1234567")) (string->list "-1,234,567"))) (test-group list-digits-in-base (test (list-digits-in-base 12034 10) '((1 4) (2 3) (3 1) (4 0)))) (test-group format-plural (test (format #f "~D famil~:*~@P" 3) "3 families") (test (format #f "~D famil~:*~@P: ~A" 1 "Alejo's") "1 family: Alejo's") (test (format #f "~D apple~:*~:P, ~D" 1) "1 apple, 1") (test (format #f "~D apple~:*~:P, ~D" 0) "0 apples, 0")) )