mirror of
https://git.savannah.gnu.org/git/guile.git
synced 2025-06-29 22:40:34 +02:00
More thorough ice-9 sports testing
* module/ice-9/sports.scm: Export read-line, %read-line, and read-delimited. Add these latest three to install-sports!, and fix install-sports! if the current module isn't (ice-9 sports). * test-suite/tests/sports.test: Use install-sports! instead of lexical bindings, to allow us to nicely frob bindings in rdelim. Include rdelim tests.
This commit is contained in:
parent
2badbd06f6
commit
2c95a21027
2 changed files with 23 additions and 13 deletions
|
@ -56,6 +56,9 @@
|
|||
read-char)
|
||||
#:export (lookahead-u8
|
||||
get-u8
|
||||
%read-line
|
||||
read-line
|
||||
read-delimited
|
||||
current-read-waiter
|
||||
current-write-waiter
|
||||
install-sports!
|
||||
|
@ -524,21 +527,23 @@
|
|||
(define saved-port-bindings #f)
|
||||
(define port-bindings
|
||||
'(((guile) read-char peek-char)
|
||||
((ice-9 binary-ports) get-u8 lookahead-u8)))
|
||||
((ice-9 binary-ports) get-u8 lookahead-u8)
|
||||
((ice-9 rdelim) %read-line read-line read-delimited)))
|
||||
(define (install-sports!)
|
||||
(unless saved-port-bindings
|
||||
(set! saved-port-bindings (make-hash-table))
|
||||
(for-each
|
||||
(match-lambda
|
||||
((mod . syms)
|
||||
(let ((mod (resolve-module mod)))
|
||||
(for-each (lambda (sym)
|
||||
(hashq-set! saved-port-bindings sym
|
||||
(module-ref mod sym))
|
||||
(module-set! mod sym
|
||||
(module-ref (current-module) sym)))
|
||||
syms))))
|
||||
port-bindings)))
|
||||
(let ((sports (resolve-module '(ice-9 sports))))
|
||||
(for-each
|
||||
(match-lambda
|
||||
((mod . syms)
|
||||
(let ((mod (resolve-module mod)))
|
||||
(for-each (lambda (sym)
|
||||
(hashq-set! saved-port-bindings sym
|
||||
(module-ref mod sym))
|
||||
(module-set! mod sym
|
||||
(module-ref sports sym)))
|
||||
syms))))
|
||||
port-bindings))))
|
||||
|
||||
(define (uninstall-sports!)
|
||||
(when saved-port-bindings
|
||||
|
|
|
@ -17,7 +17,7 @@
|
|||
;;;; <http://www.gnu.org/licenses/>.
|
||||
|
||||
(define-module (test-suite test-ports)
|
||||
#:use-module (ice-9 sports))
|
||||
#:use-module ((ice-9 sports) #:select (install-sports! uninstall-sports!)))
|
||||
|
||||
;; Include tests from ports.test.
|
||||
|
||||
|
@ -49,4 +49,9 @@
|
|||
#`((include-one #,exp) . #,(lp))))))))
|
||||
#:guess-encoding #t)))))
|
||||
|
||||
(install-sports!)
|
||||
|
||||
(include-tests "tests/ports.test")
|
||||
(include-tests "tests/rdelim.test")
|
||||
|
||||
(uninstall-sports!)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue