source: project/release/4/locale/trunk/tests/run.scm @ 15643

Last change on this file since 15643 was 15643, checked in by Kon Lovett, 11 years ago

Save. Bug in posix parse. Rmvd string const globals. Made 'locale' a "full export" module.

File size: 3.1 KB
Line 
1;;;; locale-test.scm
2
3(use test)
4(use locale posix)
5
6(test-group "Locale"
7
8        (test-group "Posix Timezone"
9
10          (let ((tz0 (make-timezone-components "PST+8:00" "TEST"))
11          (tz1 (make-timezone-components "PST+8:00PDT+7:00:00" '("POSIX" "TZ")))
12          (tz2 (make-timezone-components "PST+8:00PDT7,J23/12:34,34/1:00:01" "TEST")) )
13
14      (set! tz0
15        (update-timezone-components! tz0
16          'std-name "PST" 'std-offset (* 8 60 60)))
17      (set! tz1
18        (update-timezone-components! tz1
19          'std-name "PST" 'std-offset (* 8 60 60)
20          'dst-name "PDT" 'dst-offset (* 7 60 60)
21          'dst-start (make-timezone-dst-rule-mwd 4 1 0 3600)
22          'dst-end (make-timezone-dst-rule-mwd 10 5 0 3600)))
23      (set! tz2
24        (update-timezone-components! tz2
25          'std-name "PST" 'std-offset (* 8 60 60)
26          'dst-name "PDT" 'dst-offset (* 7 60 60)
27          'dst-start (make-timezone-dst-rule-julian-noleap 23 (+ (* 12 60 60) (* 34 60)))
28          'dst-end (make-timezone-dst-rule-julian-leap 34 (+ (* 1 60 60) 1))))
29
30      (test-assert "F1" (not (posix-timezone-string->timezone-components ":foo,bar,baz")))
31      (test-assert "F2" (not (posix-timezone-string->timezone-components "23,foo")))
32      (test-assert "F3" (not (posix-timezone-string->timezone-components "foo/23")))
33      (test-assert "F4" (not (posix-timezone-string->timezone-components "foo-23bar/23")))
34      (test-assert "F5" (not (posix-timezone-string->timezone-components "foo-23bar-22/23")))
35
36      (test "S1" tz0
37        (posix-timezone-string->timezone-components "PST+8:00" "TEST"))
38      (test "S2" tz1
39        (posix-timezone-string->timezone-components "PST+8:00PDT+7:00:00" '("POSIX" "TZ")))
40      (test "S3" tz2
41        (posix-timezone-string->timezone-components "PST+8:00PDT7,J23/12:34,34/1:00:01" "TEST"))
42
43      (setenv "TZ" "PST+8:00PDT+7:00:00")
44      (posix-load-timezone)
45      (test "S4" tz1 (current-timezone-components)) )
46        )
47
48        (test-group "Posix Locale"
49
50          (let ((lc0 (make-locale-components "en_US" '("POSIX" "LANG")))
51          (lc1 (make-locale-components "en-Latn_US.UTF8@foo,bar,baz" "TEST")) )
52
53      (set! lc0
54        (update-locale-components! lc0
55          'language "en"
56          'region "US"))
57      (set! lc1
58        (update-locale-components! lc1
59          'language "en"
60          'script "Latn"
61          'region "US"
62          'codeset "UTF8"
63          'modifier "foo,bar,baz"))
64
65      (test-assert "F1" (not (posix-locale-string->locale-components "/foo,bar,baz" "TEST")))
66      (test-assert "F2" (not (posix-locale-string->locale-components "23,bar,baz" "TEST")))
67      (test-assert "F3" (not (posix-locale-string->locale-components "foo-bar_1" "TEST")))
68
69      (test "S1" lc0 (posix-locale-string->locale-components "en_US" '("POSIX" "LANG")))
70      (test "S2" lc1 (posix-locale-string->locale-components "en-Latn_US.UTF8@foo,bar,baz" "TEST"))
71
72      (setenv "LANG" "en_US")
73      (posix-load-locale)
74      (test "S3" lc0 (current-locale-components))
75      (test "S4" lc0 (locale-category-ref 'monetary)) )
76        )
77
78  #;
79        (test-group "Local Timezone"
80          (with-tzset "" (lambda () ))
81        )
82)
Note: See TracBrowser for help on using the repository browser.