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

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

Use of scheme only in locale-timezone. Note about posix 'local-timezone-abbreviation' bug.

File size: 3.5 KB
Line 
1;;;; locale-test.scm
2
3(use test)
4(use locale posix)
5
6(test-group "Locale"
7
8        (test-group "Local Timezone"
9       
10          (test "TZN (fail)" "" (local-timezone (seconds->local-time (current-seconds))))
11          (test "TZO (fail)" -1 (local-timezone-offset (seconds->local-time (current-seconds))))
12       
13          #;(with-tzset "" (lambda () ))
14        )
15
16        (test-group "Posix Timezone"
17
18    ; unsupported but not an error
19    (test-assert "T1" (not (posix-timezone-string->timezone-components ":foo,bar,baz")))
20
21    ; cannot have a name composed of digits
22    (test-error "T2" (posix-timezone-string->timezone-components "23,foo"))
23 
24    ; this is actually legal!
25    (test-assert "T3" (posix-timezone-string->timezone-components "foo/23"))
26
27    ; this is actually legal!
28                (test-assert "T4" (posix-timezone-string->timezone-components "foo-23bar/23"))
29
30    ; the dst section is bad
31    (test-error "T5" (posix-timezone-string->timezone-components "foo-23bar-22/23"))
32
33          (let ((tz0 (make-timezone-components "PST+8:00" "TEST"))
34          (tz1 (make-timezone-components "PST+8:00PDT+7:00:00,M4.1.0,M10.5" '("POSIX" "TZ")))
35          (tz2 (make-timezone-components "PST+8:00PDT7,J23/12:34,34/1:00:01" "TEST")) )
36
37      (set! tz0
38        (update-timezone-components! tz0
39          'std-name "PST" 'std-offset (* 8 60 60)))
40      (test "TS1" tz0
41        (posix-timezone-string->timezone-components "PST+8:00" "TEST"))
42
43      (set! tz1
44        (update-timezone-components! tz1
45          'std-name "PST" 'std-offset (* 8 60 60)
46          'dst-name "PDT" 'dst-offset (* 7 60 60)
47          'dst-start (make-timezone-dst-rule-mwd 4 1 0 (* 2 60 60))
48          'dst-end (make-timezone-dst-rule-mwd 10 5 0 (* 2 60 60))))
49      (test "TS2" tz1
50        (posix-timezone-string->timezone-components "PST+8:00PDT+7:00:00,M4.1.0,M10.5" '("POSIX" "TZ")))
51
52      (set! tz2
53        (update-timezone-components! tz2
54          'std-name "PST" 'std-offset (* 8 60 60)
55          'dst-name "PDT" 'dst-offset (* 7 60 60)
56          'dst-start (make-timezone-dst-rule-julian-noleap 23 (+ (* 12 60 60) (* 34 60)))
57          'dst-end (make-timezone-dst-rule-julian-leap 34 (+ (* 1 60 60) 1))))
58      (test "TS3" tz2
59        (posix-timezone-string->timezone-components "PST+8:00PDT7,J23/12:34,34/1:00:01" "TEST"))
60
61      ;; This screws up any further testing of TZ related info
62      (setenv "TZ" "PST+8:00PDT+7:00:00,M4.1.0,M10.5")
63      (posix-load-timezone)
64      (test "TS4" tz1 (current-timezone-components)) )
65        )
66
67        (test-group "Posix Locale"
68
69          (let ((lc0 (make-locale-components "en_US" '("POSIX" "LANG")))
70          (lc1 (make-locale-components "en-Latn_US.UTF8@foo,bar,baz" "TEST")) )
71
72      (set! lc0
73        (update-locale-components! lc0
74          'language "en"
75          'region "US"))
76      (set! lc1
77        (update-locale-components! lc1
78          'language "en"
79          'script "Latn"
80          'region "US"
81          'codeset "UTF8"
82          'modifier "foo,bar,baz"))
83
84      (test-assert "L1" (not (posix-locale-string->locale-components "/foo,bar,baz" "TEST")))
85      (test-assert "L2" (not (posix-locale-string->locale-components "23,bar,baz" "TEST")))
86      (test-assert "L3" (not (posix-locale-string->locale-components "foo-bar_1" "TEST")))
87
88      (test "LS1" lc0 (posix-locale-string->locale-components "en_US" '("POSIX" "LANG")))
89      (test "LS2" lc1 (posix-locale-string->locale-components "en-Latn_US.UTF8@foo,bar,baz" "TEST"))
90
91      (setenv "LANG" "en_US")
92      (posix-load-locale)
93      (test "LS3" lc0 (current-locale-components))
94      (test "LS4" lc0 (locale-category-ref 'monetary)) )
95        )
96)
Note: See TracBrowser for help on using the repository browser.