[uim-commit] r3169 - in branches/r5rs/sigscheme: . doc src test

yamaken at freedesktop.org yamaken at freedesktop.org
Sat Mar 18 01:34:30 PST 2006


Author: yamaken
Date: 2006-03-18 01:34:26 -0800 (Sat, 18 Mar 2006)
New Revision: 3169

Added:
   branches/r5rs/sigscheme/test/test-formatplus.scm
Modified:
   branches/r5rs/sigscheme/TODO
   branches/r5rs/sigscheme/doc/spec.txt
   branches/r5rs/sigscheme/src/format.c
   branches/r5rs/sigscheme/src/number.c
   branches/r5rs/sigscheme/test/test-srfi48.scm
Log:
* sigscheme/src/number.c
  - (scm_int2string): Fix broken leading zero handling
* sigscheme/src/format.c
  - (read_number):
    * Expand max width to 127
    * Add range check for it
  - (format_raw_c_directive, format_directive): Ignore leading zero
    specification for string
* sigscheme/test/test-srfi48.scm
  - Make tests shareable with format+
  - Follow the max width change and add boundary tests for it
* sigscheme/test/test-formatplus.scm
  - New file
  - Add tests for format+
  - All tests are passed
* sigscheme/doc/spec.txt
  - Describe SRFI-48 conformance
* sigscheme/TODO
  - Update


Modified: branches/r5rs/sigscheme/TODO
===================================================================
--- branches/r5rs/sigscheme/TODO	2006-03-18 07:48:41 UTC (rev 3168)
+++ branches/r5rs/sigscheme/TODO	2006-03-18 09:34:26 UTC (rev 3169)
@@ -138,7 +138,6 @@
 Assigned to YamaKen:
 
 * Implement format string
-  - Write tests for format+
   - Replace asprintf and vasprintf
   - Obsolete vprintf method of port object
 

Modified: branches/r5rs/sigscheme/doc/spec.txt
===================================================================
--- branches/r5rs/sigscheme/doc/spec.txt	2006-03-18 07:48:41 UTC (rev 3168)
+++ branches/r5rs/sigscheme/doc/spec.txt	2006-03-18 09:34:26 UTC (rev 3169)
@@ -229,6 +229,21 @@
       procedure: exact->inexact z
       procedure: inexact->exact z
 
+* SRFI conformance
+  - SRFI-48
+
+    The 'd' part of ~w,dF directive is acceptable, but completely ignored on
+    output format. Since SigScheme only supports integer currently, number is
+    always formatted as integer even if the 'd' part is specified.
+
+    proper behavior:
+      (format "~3F"   3)  => "  3"
+      (format "~3,2F" 3)  => "3.00"
+
+    SigScheme:
+      (format "~3F"   3)  => "  3"
+      (format "~3,2F" 3)  => "  3"
+
 * SIOD compatibility
 
   - #f and '()

Modified: branches/r5rs/sigscheme/src/format.c
===================================================================
--- branches/r5rs/sigscheme/src/format.c	2006-03-18 07:48:41 UTC (rev 3168)
+++ branches/r5rs/sigscheme/src/format.c	2006-03-18 09:34:26 UTC (rev 3169)
@@ -199,7 +199,7 @@
     scm_int_t ret;
     scm_bool err;
     char *bufp;
-    char buf[sizeof("099")];
+    char buf[sizeof("0127")];
     DECLARE_INTERNAL_FUNCTION("format");
 
     for (bufp = buf;
@@ -214,6 +214,9 @@
     if (err)  /* empty case */
         ret = -1;
 
+    if (ret > 127)
+        ERR("too much column width: %d", (int)ret);
+
     return ret;
 }
 
@@ -302,7 +305,7 @@
         str_len = cstr_len;
 #endif
         for (i = str_len; i < vfmt.width; i++)
-            scm_port_put_char(port, vfmt.pad);
+            scm_port_put_char(port, ' ');  /* ignore leading zero */
         scm_port_puts(port, str);
         return (*str) ? str[cstr_len - 1] : c;
     }
@@ -420,7 +423,7 @@
             obj = POP_FORMAT_ARG(args);
             if (STRINGP(obj)) {
                 for (i = SCM_STRING_LEN(obj); i < vfmt.width; i++)
-                    scm_port_put_char(port, vfmt.pad);
+                    scm_port_put_char(port, ' ');  /* ignore leading zero */
                 scm_display(port, obj);
             } else {
                 if (!INTP(obj))

Modified: branches/r5rs/sigscheme/src/number.c
===================================================================
--- branches/r5rs/sigscheme/src/number.c	2006-03-18 07:48:41 UTC (rev 3168)
+++ branches/r5rs/sigscheme/src/number.c	2006-03-18 09:34:26 UTC (rev 3169)
@@ -443,7 +443,7 @@
     char buf[sizeof("-") + sizeof(uintmax_t) * CHAR_BIT];
     char *p, *end, *str;
     uintmax_t un;  /* must be unsinged to be capable of -INT_MIN */
-    int digit, len, pad_len;
+    int digit, sign_len, pad_len, len;
     scm_bool neg;
     DECLARE_INTERNAL_FUNCTION("scm_int2string");
 
@@ -461,14 +461,16 @@
     if (neg && vfmt.pad != '0')
         *--p = '-';
 
+    sign_len = (neg && vfmt.pad == '0') ? 1 : 0;
     len = end - p;
-    pad_len = (len < vfmt.width) ? vfmt.width - len : 0;
-    str = scm_malloc(pad_len + len + sizeof(""));
-    strcpy(&str[pad_len], p);
+    pad_len = (sign_len + len < vfmt.width) ? vfmt.width - sign_len - len : 0;
+
+    str = scm_malloc(sign_len + pad_len + len + sizeof(""));
+    strcpy(&str[sign_len + pad_len], p);
     while (pad_len)
-        str[--pad_len] = vfmt.pad;
+        str[sign_len + --pad_len] = vfmt.pad;
 
-    if (neg && vfmt.pad == '0')
+    if (sign_len)
         *str = '-';
 
     return str;

Added: branches/r5rs/sigscheme/test/test-formatplus.scm
===================================================================
--- branches/r5rs/sigscheme/test/test-formatplus.scm	2006-03-18 07:48:41 UTC (rev 3168)
+++ branches/r5rs/sigscheme/test/test-formatplus.scm	2006-03-18 09:34:26 UTC (rev 3169)
@@ -0,0 +1,199 @@
+#! /usr/bin/env sscm -C UTF-8
+
+;;  FileName : test-formatplus.scm
+;;  About    : unit test for SigScheme-specific procedure format+
+;;
+;;  Copyright (C) 2006 YamaKen <yamaken AT bp.iij4u.or.jp>
+;;
+;;  All rights reserved.
+;;
+;;  Redistribution and use in source and binary forms, with or without
+;;  modification, are permitted provided that the following conditions
+;;  are met:
+;;
+;;  1. Redistributions of source code must retain the above copyright
+;;     notice, this list of conditions and the following disclaimer.
+;;  2. Redistributions in binary form must reproduce the above copyright
+;;     notice, this list of conditions and the following disclaimer in the
+;;     documentation and/or other materials provided with the distribution.
+;;  3. Neither the name of authors nor the names of its contributors
+;;     may be used to endorse or promote products derived from this software
+;;     without specific prior written permission.
+;;
+;;  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ``AS
+;;  IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+;;  THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+;;  PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR
+;;  CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+;;  EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+;;  PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+;;  PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
+;;  LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+;;  NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+;;  SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+;; All tests in this file are passed against r3169 (new repository)
+
+(load "./test/unittest.scm")
+
+(use srfi-48)
+
+;; test SRFI-48 compatible part of format+
+(define format format+)
+(load "./test/test-srfi48.scm")
+(newline)
+
+(define tn test-name)
+
+(tn "format+ ~d")
+(assert-error  (tn) (lambda () (format+ "0128d"    1)))
+(assert-error  (tn) (lambda () (format+ "0128,1d"  1)))
+(assert-error  (tn) (lambda () (format+ "1,0128d"  1)))
+(assert-error  (tn) (lambda () (format+ "01024d"   1)))
+(assert-error  (tn) (lambda () (format+ "01024,1d" 1)))
+(assert-error  (tn) (lambda () (format+ "1,01024d" 1)))
+(assert-equal? (tn) "-100" (format+ "~0d" -100))
+(assert-equal? (tn) "-10"  (format+ "~0d" -10))
+(assert-equal? (tn) "-1"   (format+ "~0d" -1))
+(assert-equal? (tn) "0"    (format+ "~0d" 0))
+(assert-equal? (tn) "1"    (format+ "~0d" 1))
+(assert-equal? (tn) "10"   (format+ "~0d" 10))
+(assert-equal? (tn) "100"  (format+ "~0d" 100))
+
+(assert-equal? (tn) "-100" (format+ "~03d" -100))
+(assert-equal? (tn) "-10"  (format+ "~03d" -10))
+(assert-equal? (tn) "-01"  (format+ "~03d" -1))
+(assert-equal? (tn) "000"  (format+ "~03d" 0))
+(assert-equal? (tn) "001"  (format+ "~03d" 1))
+(assert-equal? (tn) "010"  (format+ "~03d" 10))
+(assert-equal? (tn) "100"  (format+ "~03d" 100))
+
+(assert-equal? (tn)
+               "                                                                                                                            123"
+               (format+ "~127d" 123))
+(assert-equal? (tn)
+               "0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000123"
+               (format+ "~0127d" 123))
+
+(tn "format+ ~x")
+(assert-error  (tn) (lambda () (format+ "0128x"    1)))
+(assert-error  (tn) (lambda () (format+ "0128,1x"  1)))
+(assert-error  (tn) (lambda () (format+ "1,0128x"  1)))
+(assert-error  (tn) (lambda () (format+ "01024x"   1)))
+(assert-error  (tn) (lambda () (format+ "01024,1x" 1)))
+(assert-error  (tn) (lambda () (format+ "1,01024x" 1)))
+(assert-equal? (tn) "-64"  (format+ "~0x" -100))
+(assert-equal? (tn) "-a"   (format+ "~0x" -10))
+(assert-equal? (tn) "-1"   (format+ "~0x" -1))
+(assert-equal? (tn) "0"    (format+ "~0x" 0))
+(assert-equal? (tn) "1"    (format+ "~0x" 1))
+(assert-equal? (tn) "a"    (format+ "~0x" 10))
+(assert-equal? (tn) "64"   (format+ "~0x" 100))
+
+(assert-equal? (tn) "-64"  (format+ "~03x" -100))
+(assert-equal? (tn) "-0a"  (format+ "~03x" -10))
+(assert-equal? (tn) "-01"  (format+ "~03x" -1))
+(assert-equal? (tn) "000"  (format+ "~03x" 0))
+(assert-equal? (tn) "001"  (format+ "~03x" 1))
+(assert-equal? (tn) "00a"  (format+ "~03x" 10))
+(assert-equal? (tn) "064"  (format+ "~03x" 100))
+
+(assert-equal? (tn)
+               "                                                                                                                            1ac"
+               (format+ "~127x" #x1ac))
+(assert-equal? (tn)
+               "00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001ac"
+               (format+ "~0127x" #x1ac))
+
+(tn "format+ ~o")
+(assert-error  (tn) (lambda () (format+ "0128o"    1)))
+(assert-error  (tn) (lambda () (format+ "0128,1o"  1)))
+(assert-error  (tn) (lambda () (format+ "1,0128o"  1)))
+(assert-error  (tn) (lambda () (format+ "01024o"   1)))
+(assert-error  (tn) (lambda () (format+ "01024,1o" 1)))
+(assert-error  (tn) (lambda () (format+ "1,01024o" 1)))
+(assert-equal? (tn) "-144" (format+ "~0o" -100))
+(assert-equal? (tn) "-12"  (format+ "~0o" -10))
+(assert-equal? (tn) "-1"   (format+ "~0o" -1))
+(assert-equal? (tn) "0"    (format+ "~0o" 0))
+(assert-equal? (tn) "1"    (format+ "~0o" 1))
+(assert-equal? (tn) "12"   (format+ "~0o" 10))
+(assert-equal? (tn) "144"  (format+ "~0o" 100))
+
+(assert-equal? (tn) "-144" (format+ "~03o" -100))
+(assert-equal? (tn) "-12"  (format+ "~03o" -10))
+(assert-equal? (tn) "-01"  (format+ "~03o" -1))
+(assert-equal? (tn) "000"  (format+ "~03o" 0))
+(assert-equal? (tn) "001"  (format+ "~03o" 1))
+(assert-equal? (tn) "012"  (format+ "~03o" 10))
+(assert-equal? (tn) "144"  (format+ "~03o" 100))
+
+(assert-equal? (tn)
+               "                                                                                                                            123"
+               (format+ "~127o" #o123))
+(assert-equal? (tn)
+               "0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000123"
+               (format+ "~0127o" #o123))
+
+(tn "format+ ~b")
+(assert-error  (tn) (lambda () (format+ "0128b"    1)))
+(assert-error  (tn) (lambda () (format+ "0128,1b"  1)))
+(assert-error  (tn) (lambda () (format+ "1,0128b"  1)))
+(assert-error  (tn) (lambda () (format+ "01024b"   1)))
+(assert-error  (tn) (lambda () (format+ "01024,1b" 1)))
+(assert-error  (tn) (lambda () (format+ "1,01024b" 1)))
+(assert-equal? (tn) "-1100100" (format+ "~0b" -100))
+(assert-equal? (tn) "-1010"    (format+ "~0b" -10))
+(assert-equal? (tn) "-1"       (format+ "~0b" -1))
+(assert-equal? (tn) "0"        (format+ "~0b" 0))
+(assert-equal? (tn) "1"        (format+ "~0b" 1))
+(assert-equal? (tn) "1010"     (format+ "~0b" 10))
+(assert-equal? (tn) "1100100"  (format+ "~0b" 100))
+
+(assert-equal? (tn) "-1100100" (format+ "~05b" -100))
+(assert-equal? (tn) "-1010"    (format+ "~05b" -10))
+(assert-equal? (tn) "-0001"    (format+ "~05b" -1))
+(assert-equal? (tn) "00000"    (format+ "~05b" 0))
+(assert-equal? (tn) "00001"    (format+ "~05b" 1))
+(assert-equal? (tn) "01010"    (format+ "~05b" 10))
+(assert-equal? (tn) "1100100"  (format+ "~05b" 100))
+
+(assert-equal? (tn)
+               "                                                                                                                            101"
+               (format+ "~127b" #b101))
+(assert-equal? (tn)
+               "0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000101"
+               (format+ "~0127b" #b101))
+
+(tn "format+ ~f (number)")
+(assert-equal? (tn) "-100" (format+ "~0f" -100))
+(assert-equal? (tn) "-10"  (format+ "~0f" -10))
+(assert-equal? (tn) "-1"   (format+ "~0f" -1))
+(assert-equal? (tn) "0"    (format+ "~0f" 0))
+(assert-equal? (tn) "1"    (format+ "~0f" 1))
+(assert-equal? (tn) "10"   (format+ "~0f" 10))
+(assert-equal? (tn) "100"  (format+ "~0f" 100))
+
+(assert-equal? (tn) "-100" (format "~03f" -100))
+(assert-equal? (tn) "-10"  (format "~03f" -10))
+(assert-equal? (tn) "-01"  (format "~03f" -1))
+(assert-equal? (tn) "000"  (format "~03f" 0))
+(assert-equal? (tn) "001"  (format "~03f" 1))
+(assert-equal? (tn) "010"  (format "~03f" 10))
+(assert-equal? (tn) "100"  (format "~03f" 100))
+
+(if (symbol-bound? 'exact->inexact)
+    (begin
+      (assert-equal? (tn) "-100.00" (format+ "~06,02f" -100))
+      (assert-equal? (tn) "-10.00"  (format+ "~06,02f" -10))
+      (assert-equal? (tn) "-01.00"  (format+ "~06,02f" -1))
+      (assert-equal? (tn) "000.00"  (format+ "~06,02f" 0))
+      (assert-equal? (tn) "001.00"  (format+ "~06,02f" 1))
+      (assert-equal? (tn) "010.00"  (format+ "~06,02f" 10))
+      (assert-equal? (tn) "100.00"  (format+ "~06,02f" 100))))
+
+(assert-equal? (tn)
+               "0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000123"
+               (format+ "~0127f" 123))
+
+(total-report)

Modified: branches/r5rs/sigscheme/test/test-srfi48.scm
===================================================================
--- branches/r5rs/sigscheme/test/test-srfi48.scm	2006-03-18 07:48:41 UTC (rev 3168)
+++ branches/r5rs/sigscheme/test/test-srfi48.scm	2006-03-18 09:34:26 UTC (rev 3169)
@@ -46,6 +46,9 @@
 
 (define tn test-name)
 
+(define testing-format+? (and (symbol-bound? 'format+)
+                              (eq? format format+)))
+
 (define cl (list 0 1))
 (set-cdr! (cdr cl) cl)
 
@@ -131,7 +134,8 @@
 (assert-error  (tn) (lambda () (format "~d" "aBc")))
 (assert-error  (tn) (lambda () (format "~d" '(0 1))))
 (assert-error  (tn) (lambda () (format "~d" '#(0 1))))
-(assert-error  (tn) (lambda () (format "~1d" 1)))
+(if (not testing-format+?)
+    (assert-error  (tn) (lambda () (format "~1d" 1))))
 (assert-equal? (tn) "-100" (format "~d" -100))
 (assert-equal? (tn) "-10"  (format "~d" -10))
 (assert-equal? (tn) "-1"   (format "~d" -1))
@@ -149,7 +153,8 @@
 (assert-error  (tn) (lambda () (format "~x" "aBc")))
 (assert-error  (tn) (lambda () (format "~x" '(0 1))))
 (assert-error  (tn) (lambda () (format "~x" '#(0 1))))
-(assert-error  (tn) (lambda () (format "~1x" 1)))
+(if (not testing-format+?)
+    (assert-error  (tn) (lambda () (format "~1x" 1))))
 (assert-equal? (tn) "-64"  (format "~x" -100))
 (assert-equal? (tn) "-a"   (format "~x" -10))
 (assert-equal? (tn) "-1"   (format "~x" -1))
@@ -167,7 +172,8 @@
 (assert-error  (tn) (lambda () (format "~o" "aBc")))
 (assert-error  (tn) (lambda () (format "~o" '(0 1))))
 (assert-error  (tn) (lambda () (format "~o" '#(0 1))))
-(assert-error  (tn) (lambda () (format "~1o" 1)))
+(if (not testing-format+?)
+    (assert-error  (tn) (lambda () (format "~1o" 1))))
 (assert-equal? (tn) "-144" (format "~o" -100))
 (assert-equal? (tn) "-12"  (format "~o" -10))
 (assert-equal? (tn) "-1"   (format "~o" -1))
@@ -185,7 +191,8 @@
 (assert-error  (tn) (lambda () (format "~b" "aBc")))
 (assert-error  (tn) (lambda () (format "~b" '(0 1))))
 (assert-error  (tn) (lambda () (format "~b" '#(0 1))))
-(assert-error  (tn) (lambda () (format "~1b" 1)))
+(if (not testing-format+?)
+    (assert-error  (tn) (lambda () (format "~1b" 1))))
 (assert-equal? (tn) "-1100100" (format "~b" -100))
 (assert-equal? (tn) "-1010"    (format "~b" -10))
 (assert-equal? (tn) "-1"       (format "~b" -1))
@@ -245,7 +252,6 @@
 (assert-equal? (tn) "\"" (format "~c" #\"))
 (assert-equal? (tn) "あ" (format "~c" #\あ))
 
-;; FIXME: prefixed format
 (tn "format ~f (number)")
 (assert-error  (tn) (lambda () (format "~f")))
 (assert-error  (tn) (lambda () (format "~f" 0 1)))
@@ -253,9 +259,12 @@
 (assert-error  (tn) (lambda () (format "~f" #\a)))
 (assert-error  (tn) (lambda () (format "~f" '(0 1))))
 (assert-error  (tn) (lambda () (format "~f" '#(0 1))))
-(assert-error  (tn) (lambda () (format "0100f"   1)))
-(assert-error  (tn) (lambda () (format "0100,1f" 1)))
-(assert-error  (tn) (lambda () (format "1,0100f" 1)))
+(assert-error  (tn) (lambda () (format "0128f"    1)))
+(assert-error  (tn) (lambda () (format "0128,1f"  1)))
+(assert-error  (tn) (lambda () (format "1,0128f"  1)))
+(assert-error  (tn) (lambda () (format "01024f"   1)))
+(assert-error  (tn) (lambda () (format "01024,1f" 1)))
+(assert-error  (tn) (lambda () (format "1,01024f" 1)))
 (assert-error  (tn) (lambda () (format "~-1f"    1)))
 (assert-error  (tn) (lambda () (format "~-0f"    1)))
 (assert-error  (tn) (lambda () (format "~0,-0f"  1)))
@@ -278,13 +287,15 @@
 (assert-equal? (tn) "10"   (format "~f" 10))
 (assert-equal? (tn) "100"  (format "~f" 100))
 
-(assert-equal? (tn) "-100" (format "~0f" -100))
-(assert-equal? (tn) "-10"  (format "~0f" -10))
-(assert-equal? (tn) "-1"   (format "~0f" -1))
-(assert-equal? (tn) "0"    (format "~0f" 0))
-(assert-equal? (tn) "1"    (format "~0f" 1))
-(assert-equal? (tn) "10"   (format "~0f" 10))
-(assert-equal? (tn) "100"  (format "~0f" 100))
+(if (not testing-format+?)
+    (begin
+      (assert-equal? (tn) "-100" (format "~0f" -100))
+      (assert-equal? (tn) "-10"  (format "~0f" -10))
+      (assert-equal? (tn) "-1"   (format "~0f" -1))
+      (assert-equal? (tn) "0"    (format "~0f" 0))
+      (assert-equal? (tn) "1"    (format "~0f" 1))
+      (assert-equal? (tn) "10"   (format "~0f" 10))
+      (assert-equal? (tn) "100"  (format "~0f" 100))))
 
 (assert-equal? (tn) "-100" (format "~1f" -100))
 (assert-equal? (tn) "-10"  (format "~1f" -10))
@@ -326,13 +337,15 @@
 (assert-equal? (tn) "   10" (format "~5f" 10))
 (assert-equal? (tn) "  100" (format "~5f" 100))
 
-(assert-equal? (tn) " -100" (format "~05f" -100))
-(assert-equal? (tn) "  -10" (format "~05f" -10))
-(assert-equal? (tn) "   -1" (format "~05f" -1))
-(assert-equal? (tn) "    0" (format "~05f" 0))
-(assert-equal? (tn) "    1" (format "~05f" 1))
-(assert-equal? (tn) "   10" (format "~05f" 10))
-(assert-equal? (tn) "  100" (format "~05f" 100))
+(if (not testing-format+?)
+    (begin
+      (assert-equal? (tn) " -100" (format "~05f" -100))
+      (assert-equal? (tn) "  -10" (format "~05f" -10))
+      (assert-equal? (tn) "   -1" (format "~05f" -1))
+      (assert-equal? (tn) "    0" (format "~05f" 0))
+      (assert-equal? (tn) "    1" (format "~05f" 1))
+      (assert-equal? (tn) "   10" (format "~05f" 10))
+      (assert-equal? (tn) "  100" (format "~05f" 100))))
 
 (if (symbol-bound? 'exact->inexact)
     (begin
@@ -360,20 +373,29 @@
       (assert-equal? (tn) "10.00"   (format "~5,2f" 10))
       (assert-equal? (tn) "100.00"  (format "~5,2f" 100))
 
-      (assert-equal? (tn) "-100.00" (format "~05,02f" -100))
-      (assert-equal? (tn) "-10.00"  (format "~05,02f" -10))
-      (assert-equal? (tn) "-1.00"   (format "~05,02f" -1))
-      (assert-equal? (tn) " 0.00"   (format "~05,02f" 0))
-      (assert-equal? (tn) " 1.00"   (format "~05,02f" 1))
-      (assert-equal? (tn) "10.00"   (format "~05,02f" 10))
-      (assert-equal? (tn) "100.00"  (format "~05,02f" 100))
+      (if (not testing-format+?)
+          (begin
+            (assert-equal? (tn) "-100.00" (format "~05,02f" -100))
+            (assert-equal? (tn) "-10.00"  (format "~05,02f" -10))
+            (assert-equal? (tn) "-1.00"   (format "~05,02f" -1))
+            (assert-equal? (tn) " 0.00"   (format "~05,02f" 0))
+            (assert-equal? (tn) " 1.00"   (format "~05,02f" 1))
+            (assert-equal? (tn) "10.00"   (format "~05,02f" 10))
+            (assert-equal? (tn) "100.00"  (format "~05,02f" 100))))
 
       (assert-equal? (tn) "100.0"  (format "~5,1F" 100))))
 
+(assert-equal? (tn)
+               "                                                                                                                            123"
+               (format "~127f" 123))
+(if (not testing-format+?)
+    (assert-equal? (tn)
+                   "                                                                                                                            123"
+                   (format "~0127f" 123)))
+
 (assert-equal? (tn) "10"    (format "~F" 10))
 (assert-equal? (tn) "  100" (format "~5F" 100))
 
-;; FIXME: prefixed format
 (tn "format ~f (string)")
 (assert-error  (tn) (lambda () (format "~f" "a" "b")))
 (assert-error  (tn) (lambda () (format "~f" '("a" "b"))))
@@ -445,6 +467,13 @@
 (assert-equal? (tn) "  aBc"   (format "~05,02f" "aBc"))
 (assert-equal? (tn) "  あbう" (format "~05,02f" "あbう"))
 
+(assert-equal? (tn)
+               "                                                                                                                            aBc"
+               (format "~127f" "aBc"))
+(assert-equal? (tn)
+               "                                                                                                                            aBc"
+               (format "~0127f" "aBc"))
+
 (assert-equal? (tn) "aBc"     (format "~F"      "aBc"))
 (assert-equal? (tn) "  aBc"   (format "~5F"     "aBc"))
 (assert-equal? (tn) "  aBc"   (format "~05F"    "aBc"))
@@ -608,7 +637,6 @@
 (assert-error  (tn) (lambda () (format "~1_")))
 (assert-equal? (tn) " " (format "~_"))
 
-;; FIXME: failed
 (tn "format ~&")
 (assert-error  (tn) (lambda () (format "~&" #t)))
 (assert-error  (tn) (lambda () (format "~&" 0)))



More information about the uim-commit mailing list