(linenum→info "unix/slp.c:2238")

gauche/0.8.12/test/gettext.scm

    1: #! /usr/bin/env gosh
    2: 
    3: (use gauche.test)
    4: (use gauche.charconv)
    5: (use util.list)
    6: (use srfi-1)
    7: 
    8: (add-load-path "../test")
    9: (define *test-locale-dirs* '("../test/data/locale"))
   10: 
   11: ;; This hack is to avoid conversion errors due to supported encodings.
   12: ;; If you compile Gauche with utf8, most encodings should be OK.
   13: (define *available-locales*
   14:   (filter-map (lambda (p)
   15:                 (and (ces-conversion-supported? (car p) #f)
   16:                      (cdr p)))
   17:               '(("ISO-8859-15" . "en")
   18:                 ("eucJP" . "ja"))))
   19: 
   20: ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
   21: ;; load test data.  this defines *tests*
   22: 
   23: (let ((test-file #`"data/gettext.data.,(gauche-character-encoding)"))
   24:   (load test-file))
   25: 
   26: ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
   27: ;; run the tests
   28: 
   29: (test-start "gettext")
   30: (use text.gettext)
   31: (test-module 'text.gettext)
   32: 
   33: 
   34: (dolist (domain '("test" "motest"))
   35:   (test-section domain)
   36: 
   37:   (bindtextdomain (list domain) *test-locale-dirs*)
   38: 
   39:   (dolist (locale *available-locales*)
   40:     (let* ((gettext-dispatch (make-gettext domain locale))
   41:            (get (gettext-dispatch 'getter)))
   42:       (for-each
   43:        (lambda (t)
   44:          (test* (format "get-~A: ~S" locale (car t)) (get-optional (cdr t) (car t))
   45:                 (get (car t))))
   46:        (assoc-ref *tests* locale)))) 
   47: 
   48:   ;; plural forms
   49:   (dolist (locale *available-locales*)
   50:     (let* ((gettext-dispatch (make-gettext domain locale))
   51:            (nget (gettext-dispatch 'ngetter)))
   52:       (for-each
   53:        (lambda (t)
   54:          (let ((msg (car t)) (msg2 (cadr t)))
   55:            (for-each
   56:             (lambda (t2)
   57:               (test* (format "nget-~A: ~S (~D)" locale msg (car t2)) (cadr t2)
   58:                      (format #f (nget msg msg2 (car t2)) (car t2))))
   59:             (cddr t))))
   60:        (assoc-ref *plural-tests* locale))))
   61: 
   62:   ;; using the GNU gettext interface
   63:   (dolist (locale *available-locales*)
   64:     (textdomain domain locale)
   65:     (for-each
   66:      (lambda (t)
   67:        (test* (format "gettext-~A: ~S" locale (car t))
   68:               (get-optional (cdr t) (car t))
   69:               (gettext (car t)))
   70:        (test* (format "dcgettext-~A: ~S" locale (car t))
   71:               (get-optional (cdr t) (car t))
   72:               (dcgettext domain (car t) locale)))
   73:      (assoc-ref *tests* locale)))
   74:   )
   75: 
   76: (test-end)
   77: 
Syntax (Markdown)