guile-commits
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Guile-commits] GNU Guile branch, string_abstraction2, updated. 823e4440


From: Michael Gran
Subject: [Guile-commits] GNU Guile branch, string_abstraction2, updated. 823e444052817ee120d87a3575acb4f767f17475
Date: Mon, 25 May 2009 18:04:54 +0000

This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "GNU Guile".

http://git.savannah.gnu.org/cgit/guile.git/commit/?id=823e444052817ee120d87a3575acb4f767f17475

The branch, string_abstraction2 has been updated
       via  823e444052817ee120d87a3575acb4f767f17475 (commit)
      from  b507262d75db26b6034328396b0be8837f2d1437 (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.

- Log -----------------------------------------------------------------
commit 823e444052817ee120d87a3575acb4f767f17475
Author: Michael Gran <address@hidden>
Date:   Sun May 24 17:15:10 2009 -0700

    add tests for encoding/decoding wide strings
    
        * test-suite/tests/encoding_utf8.test: new
        * test-suite/tests/encoding_iso88591.test: new
        * test-suite/tests/encoding_iso88597.test: new
        * test-suite/tests/encoding_escapes.test: new

-----------------------------------------------------------------------

Summary of changes:
 test-suite/tests/encoding_escapes.test  |  131 ++++++++++++++++++++++++++++++
 test-suite/tests/encoding_iso88591.test |  132 ++++++++++++++++++++++++++++++
 test-suite/tests/encoding_iso88597.test |  133 +++++++++++++++++++++++++++++++
 test-suite/tests/encoding_utf8.test     |  125 +++++++++++++++++++++++++++++
 4 files changed, 521 insertions(+), 0 deletions(-)
 create mode 100644 test-suite/tests/encoding_escapes.test
 create mode 100644 test-suite/tests/encoding_iso88591.test
 create mode 100644 test-suite/tests/encoding_iso88597.test
 create mode 100644 test-suite/tests/encoding_utf8.test

diff --git a/test-suite/tests/encoding_escapes.test 
b/test-suite/tests/encoding_escapes.test
new file mode 100644
index 0000000..8597e74
--- /dev/null
+++ b/test-suite/tests/encoding_escapes.test
@@ -0,0 +1,131 @@
+;;;; strings.test --- test suite for Guile's string functions    -*- mode: 
scheme; coding: utf-8 -*-
+;;;;
+;;;; Copyright (C) 2009 Free Software Foundation, Inc.
+;;;; 
+;;;; This program is free software; you can redistribute it and/or modify
+;;;; it under the terms of the GNU General Public License as published by
+;;;; the Free Software Foundation; either version 2, or (at your option)
+;;;; any later version.
+;;;; 
+;;;; This program is distributed in the hope that it will be useful,
+;;;; but WITHOUT ANY WARRANTY; without even the implied warranty of
+;;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+;;;; GNU General Public License for more details.
+;;;; 
+;;;; You should have received a copy of the GNU General Public License
+;;;; along with this software; see the file COPYING.  If not, write to
+;;;; the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+;;;; Boston, MA 02110-1301 USA
+
+(define-module (test-strings)
+  #:use-module (test-suite lib)
+  #:use-module (srfi srfi-1))
+
+(define exception:conversion
+  (cons 'misc-error "^cannot convert to output locale"))
+
+;; Create a string from integer char values, eg. (string-ints 65) => "A"
+(define (string-ints . args)
+  (apply string (map integer->char args)))
+
+(setlocale LC_ALL "en_US.utf8")
+
+(define s1 "última")
+(define s2 "cédula")
+(define s3 "años")
+(define s4 "羅生門")
+
+(setencoding "ASCII")
+
+(with-test-prefix
+ "internal encoding"
+
+ (pass-if "ultima"
+         (string=? s1 (string-ints #xfa #x6c #x74 #x69 #x6d #x61)))
+
+ (pass-if "cedula"
+         (string=? s2 (string-ints #x63 #xe9 #x64 #x75 #x6c #x61)))
+
+ (pass-if "anos"
+         (string=? s3 (string-ints #x61 #xf1 #x6f #x73)))
+ 
+ (pass-if "Rashomon"
+         (string=? s4 (string-ints #x7f85 #x751f #x9580))))
+
+(with-test-prefix
+ "chars"
+ 
+  (pass-if "ultima"
+          (list= eqv? (string->list s1)
+                 (list #\372 #\l #\t #\i #\m #\a)))
+
+  (pass-if "cedula"
+          (list= eqv? (string->list s2)
+                 (list #\c #\351 #\d #\u #\l #\a)))
+
+  (pass-if "anos"
+          (list= eqv? (string->list s3)
+                 (list #\a #\361 #\o #\s)))
+
+  (pass-if "Rashomon"
+          (list= eqv? (string->list s4)
+                 (list #\77605 #\72437 #\112600))))
+
+
+;; Check that an error is flagged on display output when the output
+;; error strategy is 'error
+(set-conversion-error-behavior! 'error)
+
+(with-test-prefix
+ "display output errors"
+
+ (pass-if-exception "ultima"
+      exception:conversion
+      (with-output-to-string (lambda() (display s1))))
+
+ (pass-if-exception "Rashomon"
+      exception:conversion
+      (with-output-to-string (lambda() (display s4)))))
+
+
+;; Check that questions marks or substitutions appear when the conversion
+;; mode is substitute
+(set-conversion-error-behavior! 'substitute)
+
+(with-test-prefix
+ "display output substitutions"
+ (pass-if "ultima"
+          (string=? "?ltima"
+                   (with-output-to-string (lambda() (display s1)))))
+ (pass-if "Rashomon"
+         (string=? "???"
+                   (with-output-to-string (lambda() (display s4))))))
+
+
+;; Check that hex escapes appear in the write output and that no error
+;; is thrown.  The output error strategy should be irrelevant here.
+(set-conversion-error-behavior! 'escape)
+
+(with-test-prefix
+ "display output escapes"
+ (pass-if "ultima"
+          (string=? "\\xfaltima"
+                   (with-output-to-string (lambda() (display s1)))))
+ (pass-if "Rashomon"
+         (string=? "\\u7F85\\u751F\\u9580"
+                   (with-output-to-string (lambda() (display s4))))))
+ 
+
+(setlocale LC_ALL "en_US.utf8")
+
+(with-test-prefix
+ "input escapes"
+
+ (pass-if  "última"
+          (string=? "última"
+                    (with-input-from-string "\"\\xfaltima\"" read)))
+
+ (pass-if "羅生門"
+         (string=? "羅生門"
+                   (with-input-from-string "\"\\u7F85\\u751F\\u9580\"" read))))
+ 
diff --git a/test-suite/tests/encoding_iso88591.test 
b/test-suite/tests/encoding_iso88591.test
new file mode 100644
index 0000000..44af345
--- /dev/null
+++ b/test-suite/tests/encoding_iso88591.test
@@ -0,0 +1,132 @@
+;;;; strings.test --- test suite for Guile's string functions    -*- scheme -*-
+;;;;
+;;;; Copyright (C) 2009 Free Software Foundation, Inc.
+;;;; 
+;;;; This program is free software; you can redistribute it and/or modify
+;;;; it under the terms of the GNU General Public License as published by
+;;;; the Free Software Foundation; either version 2, or (at your option)
+;;;; any later version.
+;;;; 
+;;;; This program is distributed in the hope that it will be useful,
+;;;; but WITHOUT ANY WARRANTY; without even the implied warranty of
+;;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+;;;; GNU General Public License for more details.
+;;;; 
+;;;; You should have received a copy of the GNU General Public License
+;;;; along with this software; see the file COPYING.  If not, write to
+;;;; the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+;;;; Boston, MA 02110-1301 USA
+
+(define-module (test-strings)
+  #:use-module (test-suite lib)
+  #:use-module (srfi srfi-1))
+
+(define exception:conversion
+  (cons 'misc-error "^cannot convert to output locale"))
+
+;; Create a string from integer char values, eg. (string-ints 65) => "A"
+(define (string-ints . args)
+  (apply string (map integer->char args)))
+
+(setlocale LC_ALL "es_MX.ISO-8859-1")
+
+(define s1 "última")
+(define s2 "cédula")
+(define s3 "años")
+(define s4 "¿Cómo?")
+
+(with-test-prefix 
+ "string length"
+
+ (pass-if "última"
+         (eq? (string-length s1) 6))
+    
+ (pass-if "cédula"
+         (eq? (string-length s2) 6))
+
+ (pass-if "años"
+         (eq? (string-length s3) 4))
+
+ (pass-if "¿Cómo?"
+         (eq? (string-length s4) 6)))
+
+(with-test-prefix
+ "internal encoding"
+
+ (pass-if "última"
+         (string=? s1 (string-ints #xfa #x6c #x74 #x69 #x6d #x61)))
+
+ (pass-if "cédula"
+         (string=? s2 (string-ints #x63 #xe9 #x64 #x75 #x6c #x61)))
+
+ (pass-if "años"
+         (string=? s3 (string-ints #x61 #xf1 #x6f #x73)))
+ 
+ (pass-if "¿Cómo?"
+         (string=? s4 (string-ints #xbf #x43 #xf3 #x6d #x6f #x3f))))
+
+(with-test-prefix
+ "chars"
+ 
+  (pass-if "última"
+          (list= eqv? (string->list s1)
+                 (list #\ú #\l #\t #\i #\m #\a)))
+
+  (pass-if "cédula"
+          (list= eqv? (string->list s2)
+                 (list #\c #\é #\d #\u #\l #\a)))
+
+  (pass-if "años"
+          (list= eqv? (string->list s3)
+                 (list #\a #\ñ #\o #\s)))
+
+  (pass-if "¿Cómo?"
+          (list= eqv? (string->list s4)
+                 (list #\¿ #\C #\ó #\m #\o #\?))))
+
+;; Check that the output is in ISO-8859-1 encoding
+(with-test-prefix
+ "display"
+ 
+ (pass-if "s1"
+          (list= eqv? (list #xfa #x6c #x74 #x69 #x6d #x61)
+                 (map char->integer
+                      (string->list (with-output-to-string (lambda()
+                                                             (display s1)))))))
+ (pass-if "s2"
+          (list= eqv? (list #x63 #xe9 #x64 #x75 #x6c #x61)
+                 (map char->integer
+                      (string->list (with-output-to-string (lambda()
+                                                             (display 
s2))))))))
+
+(with-test-prefix
+ "symbols == strings"
+
+ (pass-if "última"
+         (eq? (string->symbol s1) 'última))
+
+ (pass-if "cédula"
+         (eq? (string->symbol s2) 'cédula))
+
+ (pass-if "años"
+         (eq? (string->symbol s3) 'años))
+ 
+ (pass-if "¿Cómo?"
+         (eq? (string->symbol s4) '¿Cómo?)))
+
+(with-test-prefix
+ "non-ascii variable names"
+
+ (pass-if "1"
+         (let ((á 1)
+               (ñ 2))
+           (eq? (+ á ñ) 3))))
+
+(set-conversion-error-behavior! 'error)
+
+(with-test-prefix
+ "output errors"
+
+ (pass-if-exception "char 256"
+      exception:conversion
+      (with-output-to-string (lambda() (display (string-ints 256))))))
diff --git a/test-suite/tests/encoding_iso88597.test 
b/test-suite/tests/encoding_iso88597.test
new file mode 100644
index 0000000..6395815
--- /dev/null
+++ b/test-suite/tests/encoding_iso88597.test
@@ -0,0 +1,133 @@
+;;;; strings.test --- test suite for Guile's string functions    -*- mode: 
scheme; coding: iso-8859-7 -*-
+;;;;
+;;;; Copyright (C) 2009 Free Software Foundation, Inc.
+;;;; 
+;;;; This program is free software; you can redistribute it and/or modify
+;;;; it under the terms of the GNU General Public License as published by
+;;;; the Free Software Foundation; either version 2, or (at your option)
+;;;; any later version.
+;;;; 
+;;;; This program is distributed in the hope that it will be useful,
+;;;; but WITHOUT ANY WARRANTY; without even the implied warranty of
+;;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+;;;; GNU General Public License for more details.
+;;;; 
+;;;; You should have received a copy of the GNU General Public License
+;;;; along with this software; see the file COPYING.  If not, write to
+;;;; the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+;;;; Boston, MA 02110-1301 USA
+
+(define-module (test-strings)
+  #:use-module (test-suite lib)
+  #:use-module (srfi srfi-1))
+
+(define exception:conversion
+  (cons 'misc-error "^cannot convert to output locale"))
+
+;; Create a string from integer char values, eg. (string-ints 65) => "A"
+(define (string-ints . args)
+  (apply string (map integer->char args)))
+
+(setencoding "ISO-8859-7")
+
+(define s1 "Ðåñß")
+(define s2 "ôçò")
+(define s3 "êñéôéêÞò")
+(define s4 "êáé")
+
+(with-test-prefix 
+ "string length"
+
+ (pass-if "s1"
+         (eq? (string-length s1) 4))
+    
+ (pass-if "s2"
+         (eq? (string-length s2) 3))
+
+ (pass-if "s3"
+         (eq? (string-length s3) 8))
+
+ (pass-if "s4" 
+         (eq? (string-length s4) 3)))
+
+(with-test-prefix
+ "internal encoding"
+
+ (pass-if "s1"
+         (string=? s1 (string-ints #x03a0 #x03b5 #x03c1 #x03af)))
+
+ (pass-if "s2"
+         (string=? s2 (string-ints #x03c4 #x03b7 #x03c2)))
+
+ (pass-if "s3"
+         (string=? s3 (string-ints #x03ba #x03c1 #x03b9 #x03c4 #x03b9 #x03ba 
#x03ae #x03c2)))
+ 
+ (pass-if "s4"
+         (string=? s4 (string-ints #x03ba #x03b1 #x03b9))))
+
+(with-test-prefix
+ "chars"
+ 
+  (pass-if "s1"
+          (list= eqv? (string->list s1)
+                 (list #\Ð #\å #\ñ #\ß)))
+
+  (pass-if "s2"
+          (list= eqv? (string->list s2)
+                 (list #\ô #\ç #\ò)))
+
+  (pass-if "s3"
+          (list= eqv? (string->list s3)
+                 (list #\ê #\ñ #\é #\ô #\é #\ê #\Þ #\ò)))
+
+  (pass-if "s4"
+          (list= eqv? (string->list s4)
+                 (list #\ê #\á #\é))))
+
+;; Testing that the display of the string is output in the ISO-8859-7
+;; encoding
+(with-test-prefix
+ "display"
+ 
+ (pass-if "s1"
+         (list= eqv? (list #xd0 #xe5 #xf1 #xdf)
+                (map char->integer 
+                     (string->list (with-output-to-string (lambda() 
+                                                            (display s1)))))))
+ (pass-if "s2"
+         (list= eqv? (list #xf4 #xe7 #xf2)
+                (map char->integer 
+                     (string->list (with-output-to-string (lambda() 
+                                                            (display s2))))))))
+
+(with-test-prefix
+ "symbols == strings"
+
+ (pass-if "Ðåñß"
+         (eq? (string->symbol s1) 'Ðåñß))
+
+ (pass-if "ôçò"
+         (eq? (string->symbol s2) 'ôçò))
+
+ (pass-if "êñéôéêÞò"
+         (eq? (string->symbol s3) 'êñéôéêÞò))
+ 
+ (pass-if "êáé"
+         (eq? (string->symbol s4) 'êáé)))
+
+(with-test-prefix
+ "non-ascii variable names"
+
+ (pass-if "1"
+         (let ((á 1)
+               (ñ 2))
+           (eq? (+ á ñ) 3))))
+
+(set-conversion-error-behavior! 'error)
+
+(with-test-prefix
+ "output errors"
+
+ (pass-if-exception "char #x0400"
+      exception:conversion
+      (with-output-to-string (lambda() (display (string-ints #x0400))))))
\ No newline at end of file
diff --git a/test-suite/tests/encoding_utf8.test 
b/test-suite/tests/encoding_utf8.test
new file mode 100644
index 0000000..2b43874
--- /dev/null
+++ b/test-suite/tests/encoding_utf8.test
@@ -0,0 +1,125 @@
+;;;; strings.test --- test suite for Guile's string functions    -*- mode: 
scheme; coding: utf-8 -*-
+;;;;
+;;;; Copyright (C) 2009 Free Software Foundation, Inc.
+;;;; 
+;;;; This program is free software; you can redistribute it and/or modify
+;;;; it under the terms of the GNU General Public License as published by
+;;;; the Free Software Foundation; either version 2, or (at your option)
+;;;; any later version.
+;;;; 
+;;;; This program is distributed in the hope that it will be useful,
+;;;; but WITHOUT ANY WARRANTY; without even the implied warranty of
+;;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+;;;; GNU General Public License for more details.
+;;;; 
+;;;; You should have received a copy of the GNU General Public License
+;;;; along with this software; see the file COPYING.  If not, write to
+;;;; the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+;;;; Boston, MA 02110-1301 USA
+
+(define-module (test-strings)
+  #:use-module (test-suite lib)
+  #:use-module (srfi srfi-1))
+
+(define exception:conversion
+  (cons 'misc-error "^cannot convert to output locale"))
+
+;; Create a string from integer char values, eg. (string-ints 65) => "A"
+(define (string-ints . args)
+  (apply string (map integer->char args)))
+
+(setlocale LC_ALL "en_US.utf8")
+
+(define s1 "última")
+(define s2 "cédula")
+(define s3 "años")
+(define s4 "羅生門")
+
+(with-test-prefix 
+ "string length"
+
+ (pass-if "última"
+         (eq? (string-length s1) 6))
+    
+ (pass-if "cédula"
+         (eq? (string-length s2) 6))
+
+ (pass-if "años"
+         (eq? (string-length s3) 4))
+
+ (pass-if "羅生門"
+         (eq? (string-length s4) 3)))
+
+(with-test-prefix
+ "internal encoding"
+
+ (pass-if "última"
+         (string=? s1 (string-ints #xfa #x6c #x74 #x69 #x6d #x61)))
+
+ (pass-if "cédula"
+         (string=? s2 (string-ints #x63 #xe9 #x64 #x75 #x6c #x61)))
+
+ (pass-if "años"
+         (string=? s3 (string-ints #x61 #xf1 #x6f #x73)))
+ 
+ (pass-if "羅生門"
+         (string=? s4 (string-ints #x7f85 #x751f #x9580))))
+
+(with-test-prefix
+ "chars"
+ 
+  (pass-if "última"
+          (list= eqv? (string->list s1)
+                 (list #\ú #\l #\t #\i #\m #\a)))
+
+  (pass-if "cédula"
+          (list= eqv? (string->list s2)
+                 (list #\c #\é #\d #\u #\l #\a)))
+
+  (pass-if "años"
+          (list= eqv? (string->list s3)
+                 (list #\a #\ñ #\o #\s)))
+
+  (pass-if "羅生門"
+          (list= eqv? (string->list s4)
+                 (list #\羅 #\生 #\門))))
+
+;; Check that the output is in UTF-8 encoding
+(with-test-prefix
+ "display"
+ 
+ (pass-if "s1"
+          (list= eqv? (list #xc3 #xba #x6c #x74 #x69 #x6d #x61)
+                 (map char->integer
+                      (string->list (with-output-to-string (lambda()
+                                                             (display s1)))))))
+ (pass-if "s2"
+          (list= eqv? (list #x63 #xc3 #xa9 #x64 #x75 #x6c #x61)
+                 (map char->integer
+                      (string->list (with-output-to-string (lambda()
+                                                             (display 
s2))))))))
+
+(with-test-prefix
+ "symbols == strings"
+
+ (pass-if "última"
+         (eq? (string->symbol s1) 'última))
+
+ (pass-if "cédula"
+         (eq? (string->symbol s2) 'cédula))
+
+ (pass-if "años"
+         (eq? (string->symbol s3) 'años))
+ 
+ (pass-if "羅生門"
+         (eq? (string->symbol s4) '羅生門)))
+
+(with-test-prefix
+ "non-ascii variable names"
+
+ (pass-if "1"
+         (let ((芥川龍之介  1)
+               (ñ 2))
+           (eq? (+  芥川龍之介 ñ) 3))))
+
+


hooks/post-receive
-- 
GNU Guile




reply via email to

[Prev in Thread] Current Thread [Next in Thread]