1
Fork 0
mirror of https://git.savannah.gnu.org/git/guile.git synced 2025-04-30 03:40:34 +02:00

Don't presume existence or success of setlocale in test-suite

* test-suite/lib.scm (with-locale, with-locale*): new test functions

* test-suite/tests/encoding-escapes: don't fail if en_US.utf8 doesn't exist

* test-suite/tests/encoding-iso88591.test: set and restore locale, if
  possible

* test-suite/tests/encoding-iso88597.test: set and restore locale, if
  possible

* test-suite/tests/encoding-utf8.test: set and restore locale, if possible

* test-suite/tests/srfi-14.test: don't need to setlocale to Latin-1 to
  test Latin-1 since string conversion is handled at read/compile time.
  Set and restore locale, if possible.
This commit is contained in:
Michael Gran 2009-08-28 06:27:00 -07:00
parent 8736ef70ac
commit ce3ed0125f
6 changed files with 123 additions and 129 deletions

View file

@ -46,6 +46,9 @@
;; Using the debugging evaluator.
with-debugging-evaluator with-debugging-evaluator*
;; Using a given locale
with-locale with-locale*
;; Reporting results in various ways.
register-reporter unregister-reporter reporter-registered?
make-count-reporter print-counts
@ -437,6 +440,26 @@
(define-macro (with-debugging-evaluator . body)
`(with-debugging-evaluator* (lambda () ,@body)))
;;; Call THUNK with a given locale
(define (with-locale* nloc thunk)
(let ((loc #f))
(dynamic-wind
(lambda ()
(if (defined? 'setlocale)
(begin
(set! loc
(false-if-exception (setlocale LC_ALL nloc)))
(if (not loc)
(throw 'unresolved)))
(throw 'unresolved)))
thunk
(lambda ()
(if (defined? 'setlocale)
(setlocale LC_ALL loc))))))
;;; Evaluate BODY... using the given locale.
(define-macro (with-locale loc . body)
`(with-locale* ,loc (lambda () ,@body)))
;;;; REPORTERS