[uim-commit] r3170 - in branches/r5rs/sigscheme: src test

yamaken at freedesktop.org yamaken at freedesktop.org
Sat Mar 18 03:20:24 PST 2006


Author: yamaken
Date: 2006-03-18 03:20:19 -0800 (Sat, 18 Mar 2006)
New Revision: 3170

Modified:
   branches/r5rs/sigscheme/src/format.c
   branches/r5rs/sigscheme/test/test-formatplus.scm
   branches/r5rs/sigscheme/test/test-srfi48.scm
Log:
* sigscheme/src/format.c
  - (MSG_SRFI48_DIRECTIVE_HELP, MSG_SSCM_DIRECTIVE_HELP): Fill with
    meaningful strings
* sigscheme/test/test-srfi48.scm
* sigscheme/test/test-formatplus.scm
  - Follow the change


Modified: branches/r5rs/sigscheme/src/format.c
===================================================================
--- branches/r5rs/sigscheme/src/format.c	2006-03-18 09:34:26 UTC (rev 3169)
+++ branches/r5rs/sigscheme/src/format.c	2006-03-18 11:20:19 UTC (rev 3170)
@@ -32,6 +32,32 @@
  *  ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 ===========================================================================*/
 
+/* The help strings (MSG_SRFI48_DIRECTIVE_HELP and MSG_SSCM_DIRECTIVE_HELP) are
+ * derived from the reference implementation of SRFI-48. Here is the copyright
+ * for the strings. No other part is covered by this copyright.
+ *   -- 2006-03-18 YamaKen */
+/*
+ * Copyright (C) Kenneth A Dickey (2003). All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to
+ * deal in the Software without restriction, including without limitation the
+ * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
+ * sell copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+ * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
+ * IN THE SOFTWARE.
+ */
+
 #include "config.h"
 
 /*=======================================
@@ -55,18 +81,51 @@
 =======================================*/
 #define PRETTY_PRINT_PROCEDURE_NAME "pretty-print"
 
-/* FIXME */
-#define MSG_SRFI48_DIRECTIVE_HELP \
-    "\n" \
-    "\n" \
-    "\n"
+#define MSG_SRFI48_DIRECTIVE_HELP                                             \
+"(format [<port>] <format-string> [<arg>...])\n"                              \
+"  - <port> is #t, #f or an output-port\n"                                    \
+"  - any escape sequence is case insensitive\n"                               \
+"\n"                                                                          \
+"SEQ   MNEMONIC        DESCRIPTION\n"                                         \
+"~H    [Help]          output this text\n"                                    \
+"~A    [Any]           (display arg) for humans\n"                            \
+"~S    [Slashified]    (write arg) for parsers\n"                             \
+"~W    [WriteCircular] like ~s but outputs with write/ss\n"                   \
+"~~    [tilde]         output a tilde\n"                                      \
+"~T    [Tab]           output a tab character\n"                              \
+"~%    [Newline]       output a newline character\n"                          \
+"~&    [Freshline]     output a newline if the previous output was not a newline\n" \
+"~D    [Decimal]       the arg is a number which is output in decimal radix\n" \
+"~X    [heXadecimal]   the arg is a number which is output in hexdecimal radix\n" \
+"~O    [Octal]         the arg is a number which is output in octal radix\n"  \
+"~B    [Binary]        the arg is a number which is output in binary radix\n" \
+"~F\n"                                                                        \
+"~wF   [Fixed]         the arg is a string or number which has width w and\n" \
+"~w,dF                 d digits after the decimal\n"                          \
+"~C    [Character]     charater arg is output by write-char\n"                \
+"~_    [Space]         a single space character is output\n"                  \
+"~Y    [Yuppify]       the list arg is pretty-printed to the output\n"        \
+"~?    [Indirection]   recursive format: next 2 args are format-string and list\n" \
+"                      of arguments\n"                                        \
+"~K    [Indirection]   same as ~?\n"
 
 #if SCM_USE_SSCM_FORMAT_EXTENSION
-/* FIXME */
-#define MSG_SSCM_DIRECTIVE_HELP \
-    "\n" \
-    "\n" \
-    "\n"
+#define MSG_SSCM_DIRECTIVE_HELP                                              \
+"(format+ [<port>] <format-string> [<arg>...])\n"                            \
+"  - <port> is #t, #f or an output-port\n"                                   \
+"  - any escape sequence is case insensitive\n"                              \
+"\n"                                                                         \
+"  The format+ procedure is a SigScheme-specific superset of SRFI-48.\n"     \
+"  Following directives accept optional width w and d digits after the decimal,\n" \
+"  and w accepts leading zero as zero-digit-padding specifier. All other rules\n" \
+"  are same as SRFI-48. See also the help message for SRFI-48.\n"            \
+"\n"                                                                         \
+"SEQ        MNEMONIC       DESCRIPTION\n"                                    \
+"~[w[,d]]D  [Decimal]      the arg is a number output in decimal radix\n"    \
+"~[w[,d]]X  [heXadecimal]  the arg is a number output in hexdecimal radix\n" \
+"~[w[,d]]O  [Octal]        the arg is a number output in octal radix\n"      \
+"~[w[,d]]B  [Binary]       the arg is a number output in binary radix\n"     \
+"~[w[,d]]F  [Fixed]        the arg is a string or number\n"
 #endif /* SCM_USE_SSCM_FORMAT_EXTENSION */
 
 #define NEWLINE_CHAR                                                         \

Modified: branches/r5rs/sigscheme/test/test-formatplus.scm
===================================================================
--- branches/r5rs/sigscheme/test/test-formatplus.scm	2006-03-18 09:34:26 UTC (rev 3169)
+++ branches/r5rs/sigscheme/test/test-formatplus.scm	2006-03-18 11:20:19 UTC (rev 3170)
@@ -1,5 +1,3 @@
-#! /usr/bin/env sscm -C UTF-8
-
 ;;  FileName : test-formatplus.scm
 ;;  About    : unit test for SigScheme-specific procedure format+
 ;;
@@ -32,7 +30,7 @@
 ;;  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)
+;; All tests in this file are passed against r3170 (new repository)
 
 (load "./test/unittest.scm")
 
@@ -196,4 +194,25 @@
                "0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000123"
                (format+ "~0127f" 123))
 
+(tn "format ~h")
+(define help-str
+"(format+ [<port>] <format-string> [<arg>...])
+  - <port> is #t, #f or an output-port
+  - any escape sequence is case insensitive
+
+  The format+ procedure is a SigScheme-specific superset of SRFI-48.
+  Following directives accept optional width w and d digits after the decimal,
+  and w accepts leading zero as zero-digit-padding specifier. All other rules
+  are same as SRFI-48. See also the help message for SRFI-48.
+
+SEQ        MNEMONIC       DESCRIPTION
+~[w[,d]]D  [Decimal]      the arg is a number output in decimal radix
+~[w[,d]]X  [heXadecimal]  the arg is a number output in hexdecimal radix
+~[w[,d]]O  [Octal]        the arg is a number output in octal radix
+~[w[,d]]B  [Binary]       the arg is a number output in binary radix
+~[w[,d]]F  [Fixed]        the arg is a string or number
+")
+(assert-equal? (tn) help-str (format "~h"))
+(assert-equal? (tn) help-str (format "~H"))
+
 (total-report)

Modified: branches/r5rs/sigscheme/test/test-srfi48.scm
===================================================================
--- branches/r5rs/sigscheme/test/test-srfi48.scm	2006-03-18 09:34:26 UTC (rev 3169)
+++ branches/r5rs/sigscheme/test/test-srfi48.scm	2006-03-18 11:20:19 UTC (rev 3170)
@@ -32,7 +32,7 @@
 ;;  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 r3167 (new repository)
+;; All tests in this file are passed against r3170 (new repository)
 
 (load "./test/unittest.scm")
 
@@ -662,18 +662,43 @@
 
 (tn "format ~h")
 (define help-str
-"
+"(format [<port>] <format-string> [<arg>...])
+  - <port> is #t, #f or an output-port
+  - any escape sequence is case insensitive
 
-
+SEQ   MNEMONIC        DESCRIPTION
+~H    [Help]          output this text
+~A    [Any]           (display arg) for humans
+~S    [Slashified]    (write arg) for parsers
+~W    [WriteCircular] like ~s but outputs with write/ss
+~~    [tilde]         output a tilde
+~T    [Tab]           output a tab character
+~%    [Newline]       output a newline character
+~&    [Freshline]     output a newline if the previous output was not a newline
+~D    [Decimal]       the arg is a number which is output in decimal radix
+~X    [heXadecimal]   the arg is a number which is output in hexdecimal radix
+~O    [Octal]         the arg is a number which is output in octal radix
+~B    [Binary]        the arg is a number which is output in binary radix
+~F
+~wF   [Fixed]         the arg is a string or number which has width w and
+~w,dF                 d digits after the decimal
+~C    [Character]     charater arg is output by write-char
+~_    [Space]         a single space character is output
+~Y    [Yuppify]       the list arg is pretty-printed to the output
+~?    [Indirection]   recursive format: next 2 args are format-string and list
+                      of arguments
+~K    [Indirection]   same as ~?
 ")
-(assert-error  (tn) (lambda () (format "~h" #t)))
-(assert-error  (tn) (lambda () (format "~h" 0)))
-(assert-error  (tn) (lambda () (format "~h" #\a)))
-(assert-error  (tn) (lambda () (format "~h" "aBc")))
-(assert-error  (tn) (lambda () (format "~h" '(0 1))))
-(assert-error  (tn) (lambda () (format "~h" '#(0 1))))
-(assert-error  (tn) (lambda () (format "~1h")))
-(assert-equal? (tn) help-str (format "~h"))
-(assert-equal? (tn) help-str (format "~H"))
+(if (not testing-format+?)
+    (begin
+      (assert-error  (tn) (lambda () (format "~h" #t)))
+      (assert-error  (tn) (lambda () (format "~h" 0)))
+      (assert-error  (tn) (lambda () (format "~h" #\a)))
+      (assert-error  (tn) (lambda () (format "~h" "aBc")))
+      (assert-error  (tn) (lambda () (format "~h" '(0 1))))
+      (assert-error  (tn) (lambda () (format "~h" '#(0 1))))
+      (assert-error  (tn) (lambda () (format "~1h")))
+      (assert-equal? (tn) help-str (format "~h"))
+      (assert-equal? (tn) help-str (format "~H"))))
 
 (total-report)



More information about the uim-commit mailing list