[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Guile-commits] 11/47: Add more R6RS port encoding tests
From: |
Andy Wingo |
Subject: |
[Guile-commits] 11/47: Add more R6RS port encoding tests |
Date: |
Sun, 22 May 2016 18:23:04 +0000 (UTC) |
wingo pushed a commit to branch master
in repository guile.
commit 82357f7bd875afce351a2965a15baabf864338e3
Author: Mark H Weaver <address@hidden>
Date: Sat Mar 28 16:01:23 2015 -0400
Add more R6RS port encoding tests
Originally applied to stable-2.0 as "Fix bytevector and custom binary
ports to actually use ISO-8859-1 encoding.", commit
d574d96f879c147c6c14df43f2e4ff9e8a6876b9. Related to
http://bugs.gnu.org/20200, which was introduced in in stable-2.0 but
never existed on master. Test modified by Andy Wingo to add a
`force-output' where needed.
* test-suite/tests/r6rs-ports.test: Add tests.
---
test-suite/tests/r6rs-ports.test | 47 ++++++++++++++++++++++++++++++++++++++
1 file changed, 47 insertions(+)
diff --git a/test-suite/tests/r6rs-ports.test b/test-suite/tests/r6rs-ports.test
index 1441daf..4941dd7 100644
--- a/test-suite/tests/r6rs-ports.test
+++ b/test-suite/tests/r6rs-ports.test
@@ -356,6 +356,11 @@
(with-fluids ((%default-port-encoding "UTF-8"))
(binary-port? (open-bytevector-input-port #vu8(1 2 3)))))
+ (pass-if-equal "bytevector-input-port uses ISO-8859-1 (Guile extension)"
+ "©©"
+ (with-fluids ((%default-port-encoding "UTF-8"))
+ (get-string-all (open-bytevector-input-port #vu8(194 169 194 169)))))
+
(pass-if-exception "bytevector-input-port is read-only"
exception:wrong-type-arg
@@ -416,6 +421,23 @@
(input-port? port)
(bytevector=? (get-bytevector-all port) source))))
+ (pass-if-equal "make-custom-binary-input-port uses ISO-8859-1 (Guile
extension)"
+ "©©"
+ (with-fluids ((%default-port-encoding "UTF-8"))
+ (let* ((source #vu8(194 169 194 169))
+ (read! (let ((pos 0)
+ (len (bytevector-length source)))
+ (lambda (bv start count)
+ (let ((amount (min count (- len pos))))
+ (if (> amount 0)
+ (bytevector-copy! source pos
+ bv start amount))
+ (set! pos (+ pos amount))
+ amount))))
+ (port (make-custom-binary-input-port "the port" read!
+ #f #f #f)))
+ (get-string-all port))))
+
(pass-if "custom binary input port does not support `port-position'"
(let* ((str "Hello Port!")
(source (open-bytevector-input-port
@@ -716,6 +738,14 @@ not `set-port-position!'"
(pass-if "bytevector-output-port is binary"
(binary-port? (open-bytevector-output-port)))
+ (pass-if-equal "bytevector-output-port uses ISO-8859-1 (Guile extension)"
+ #vu8(194 169 194 169)
+ (with-fluids ((%default-port-encoding "UTF-8"))
+ (let-values (((port get-content)
+ (open-bytevector-output-port)))
+ (put-string port "©©")
+ (get-content))))
+
(pass-if "open-bytevector-output-port [extract after close]"
(let-values (((port get-content)
(open-bytevector-output-port)))
@@ -819,6 +849,23 @@ not `set-port-position!'"
(not eof?)
(bytevector=? sink source))))
+ (pass-if-equal "custom-binary-output-port uses ISO-8859-1 (Guile extension)"
+ '(194 169 194 169)
+ (with-fluids ((%default-port-encoding "UTF-8"))
+ (let* ((sink '())
+ (write! (lambda (bv start count)
+ (if (= 0 count) ; EOF
+ 0
+ (let ((u8 (bytevector-u8-ref bv start)))
+ ;; Get one byte at a time.
+ (set! sink (cons u8 sink))
+ 1))))
+ (port (make-custom-binary-output-port "cbop" write!
+ #f #f #f)))
+ (put-string port "©©")
+ (force-output port)
+ (reverse sink))))
+
(pass-if "standard-output-port is binary"
(with-fluids ((%default-port-encoding "UTF-8"))
(binary-port? (standard-output-port))))
- [Guile-commits] 26/47: docs: Fix external representation of <toplevel-define> in tree-il., (continued)
- [Guile-commits] 26/47: docs: Fix external representation of <toplevel-define> in tree-il., Andy Wingo, 2016/05/22
- [Guile-commits] 25/47: web: Fix 'close' method of delimited input ports., Andy Wingo, 2016/05/22
- [Guile-commits] 40/47: http: Test that responses lacking CR/LF are rejected., Andy Wingo, 2016/05/22
- [Guile-commits] 45/47: http: Accept date strings with a leading space for hours., Andy Wingo, 2016/05/22
- [Guile-commits] 46/47: doc: Fix typo in Web documentation., Andy Wingo, 2016/05/22
- [Guile-commits] 44/47: Bump user-visible copyright years to 2016., Andy Wingo, 2016/05/22
- [Guile-commits] 03/47: Implement 'string-utf8-length' and 'scm_c_string_utf8_length'., Andy Wingo, 2016/05/22
- [Guile-commits] 12/47: doc: Update libgc URL., Andy Wingo, 2016/05/22
- [Guile-commits] 09/47: Work around requirement that size be non-zero in GDB 'open-memory'., Andy Wingo, 2016/05/22
- [Guile-commits] 07/47: Correct docstring of 'symlink'., Andy Wingo, 2016/05/22
- [Guile-commits] 11/47: Add more R6RS port encoding tests,
Andy Wingo <=
- [Guile-commits] 01/47: tests: Use 'pass-if-equal' in web-http chunked encoding tests., Andy Wingo, 2016/05/22
- [Guile-commits] 13/47: Fix typo in manual., Andy Wingo, 2016/05/22
- [Guile-commits] 19/47: Fix uses of 'scm_gc_protect', which does not exist, in the manual., Andy Wingo, 2016/05/22
- [Guile-commits] 21/47: psyntax: Fix bug in match-each+., Andy Wingo, 2016/05/22
- [Guile-commits] 15/47: i18n: Check for non-POSIX strtol_l., Andy Wingo, 2016/05/22
- [Guile-commits] 28/47: i18n: Add new collation test for posterity., Andy Wingo, 2016/05/22
- [Guile-commits] 05/47: tests: Make 'test-guild-compile' more reliable., Andy Wingo, 2016/05/22
- [Guile-commits] 32/47: Remove SIGEV constant definitions., Andy Wingo, 2016/05/22
- [Guile-commits] 04/47: Don't return expressions from void functions in numbers.c, Andy Wingo, 2016/05/22
- [Guile-commits] 31/47: Add Hurd signal and error constants., Andy Wingo, 2016/05/22