guile-commits
[Top][All Lists]
Advanced

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

[Guile-commits] GNU Guile branch, stable-2.0, updated. v2.0.1-22-ge6e286


From: Ludovic Courtès
Subject: [Guile-commits] GNU Guile branch, stable-2.0, updated. v2.0.1-22-ge6e286b
Date: Wed, 04 May 2011 21:54:24 +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=e6e286bb5895197a9433817fe3998a7c7c525386

The branch, stable-2.0 has been updated
       via  e6e286bb5895197a9433817fe3998a7c7c525386 (commit)
      from  00b6ef23f320afff35fcc3a163bc66d5f9a230e8 (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 e6e286bb5895197a9433817fe3998a7c7c525386
Author: Ludovic Courtès <address@hidden>
Date:   Wed May 4 23:52:53 2011 +0200

    Automatically generate `peek-char' decoding error tests.
    
    * test-suite/tests/ports.test ("string ports")[make-peek+read-checks]:
      New macro.
      [test-decoding-error]: Change to take a list of expected characters or
      conditions.  Use `make-peek+read-checks' to generate a `peek-char'
      test.
      [(#xc2 #x41 #x42), (#xe0 #xa0 #x41 #x42)]: New tests.

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

Summary of changes:
 test-suite/tests/ports.test |  134 +++++++++++++++++++++----------------------
 1 files changed, 66 insertions(+), 68 deletions(-)

diff --git a/test-suite/tests/ports.test b/test-suite/tests/ports.test
index 69e028f..7b646a1 100644
--- a/test-suite/tests/ports.test
+++ b/test-suite/tests/ports.test
@@ -495,97 +495,95 @@
                    (syntax-rules ()
                      ((_ port check ...)
                       (and (make-check port check) ...))))
+                  (make-peek+read-checks
+                   (syntax-rules ()
+                     ((_ port (result ...) e1 expected ...)
+                      (make-peek+read-checks port
+                                             (result ...
+                                                     (peek-char -> e1)
+                                                     (read-char -> e1))
+                                             expected ...))
+                     ((_ port (result ...))
+                      (make-checks port result ...))
+                     ((_ port #f e1 expected ...)
+                      (make-peek+read-checks port
+                                             ((peek-char -> e1)
+                                              (read-char -> e1))
+                                             expected ...))))
                   (test-decoding-error
-                      (syntax-rules (tests)
-                        ((_ sequence encoding strategy (tests checks ...))
-                         (pass-if (format #f "test-decoding-error: ~s ~s ~s ~s"
-                                          (caar '(checks ...))
-                                          'sequence encoding strategy)
-                           (let ((p (open-bytevector-input-port
-                                     (u8-list->bytevector 'sequence))))
-                             (set-port-encoding! p encoding)
-                             (set-port-conversion-strategy! p strategy)
-                             (make-checks p checks ...)))))))
+                      (syntax-rules ()
+                        ((_ sequence encoding strategy (expected ...))
+                         (begin
+                          (pass-if (format #f "test-decoding-error: ~s ~s ~s"
+                                           'sequence encoding strategy)
+                            (let ((p (open-bytevector-input-port
+                                      (u8-list->bytevector 'sequence))))
+                              (set-port-encoding! p encoding)
+                              (set-port-conversion-strategy! p strategy)
+                              (make-checks p
+                                           (read-char -> expected) ...)))
+
+                          ;; Generate the same test, but with one
+                          ;; `peek-char' call before each `read-char'.
+                          ;; Both should yield the same result.
+                          (pass-if (format #f "test-decoding-error: ~s ~s ~s + 
peek-char"
+                                           'sequence encoding strategy)
+                            (let ((p (open-bytevector-input-port
+                                      (u8-list->bytevector 'sequence))))
+                              (set-port-encoding! p encoding)
+                              (set-port-conversion-strategy! p strategy)
+                              (make-peek+read-checks p #f expected ...))))))))
 
     (test-decoding-error (255 65 66 67) "UTF-8" 'error
-      (tests
-       (read-char -> error)
-       (read-char -> #\A)
-       (read-char -> #\B)
-       (read-char -> #\C)
-       (read-char -> eof)))
+      (error #\A #\B #\C eof))
 
     (test-decoding-error (255 65 66 67) "UTF-8" 'escape
       ;; `escape' should behave exactly like `error'.
-      (tests
-       (read-char -> error)
-       (read-char -> #\A)
-       (read-char -> #\B)
-       (read-char -> #\C)
-       (read-char -> eof)))
+      (error #\A #\B #\C eof))
 
     (test-decoding-error (255 206 187 206 188) "UTF-8" 'substitute
-      (tests
-       (read-char -> #\?)
-       (read-char -> #\λ)
-       (read-char -> #\μ)
-       (read-char -> eof)))
+      (#\? #\λ #\μ eof))
 
     (test-decoding-error (206 187 206) "UTF-8" 'error
       ;; Unterminated sequence.
-      (tests
-       (read-char -> #\λ)
-       (read-char -> error)
-       (read-char -> eof)))
+      (#\λ error eof))
 
     (test-decoding-error (206 187 206) "UTF-8" 'substitute
       ;; Unterminated sequence.
-      (tests
-       (read-char -> #\λ)
-       (read-char -> #\?)
-       (read-char -> eof)))
-
-    (test-decoding-error (255 65 66 67) "UTF-8" 'error
-      (tests
-       ;; `peek-char' should repeatedly raise an error.
-       (peek-char -> error)
-       (peek-char -> error)
-       (peek-char -> error)
-
-       ;; Move past the error.
-       (read-char -> error)
-
-       (read-char -> #\A)
-       (read-char -> #\B)
-       (read-char -> #\C)
-       (read-char -> eof)))
+      (#\λ #\? eof))
 
     ;; Check how ill-formed UTF-8 sequences are handled (see Table 3-7
     ;; of the "Conformance" chapter of Unicode 6.0.0.)
 
     (test-decoding-error (#xc0 #x80 #x41) "UTF-8" 'error
-      (tests
-       (read-char -> error) ;; C0: should be in the C2..DF range
-       (read-char -> error) ;; 80: invalid
-       (read-char -> #\A)
-       (read-char -> eof)))
-
-    (test-decoding-error (#xc0 #x80 #x41) "UTF-8" 'error
-      (tests
-       (read-char -> error) ;; C0: should be in the C2..DF range
-       (read-char -> error) ;; 80: invalid
-       (read-char -> #\A)
-       (read-char -> eof)))
+      (error                ;; C0: should be in the C2..DF range
+       error                ;; 80: invalid
+       #\A
+       eof))
+
+    (test-decoding-error (#xc0 #x80 #x41) "UTF-8" 'substitute
+      (#\?                  ;; C0: should be in the C2..DF range
+       #\?                  ;; 80: invalid
+       #\A
+       eof))
+
+    (test-decoding-error (#xc2 #x41 #x42) "UTF-8" 'error
+      (error                ;; 41: should be in the 80..BF range
+       #\B
+       eof))
 
     (test-decoding-error (#xe0 #x88 #x88) "UTF-8" 'error
-      (tests
-       (read-char -> error) ;; 2nd byte should be in the A0..BF range
-       (read-char -> eof)))
+      (error                ;; 2nd byte should be in the A0..BF range
+       eof))
+
+    (test-decoding-error (#xe0 #xa0 #x41 #x42) "UTF-8" 'error
+      (error                ;; 3rd byte should be in the 80..BF range
+       #\B
+       eof))
 
     (test-decoding-error (#xf0 #x88 #x88 #x88) "UTF-8" 'error
-      (tests
-       (read-char -> error) ;; 2nd byte should be in the 90..BF range
-       (read-char -> eof)))))
+      (error                ;; 2nd byte should be in the 90..BF range
+       eof))))
 
 (with-test-prefix "call-with-output-string"
 


hooks/post-receive
-- 
GNU Guile



reply via email to

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