ruby-cldr 0.0.2 → 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/Gemfile +8 -2
- data/Gemfile.lock +55 -5
- data/VERSION +1 -1
- data/lib/cldr/download.rb +15 -11
- data/lib/cldr/export.rb +64 -16
- data/lib/cldr/export/data.rb +18 -10
- data/lib/cldr/export/data/calendars/gregorian.rb +45 -22
- data/lib/cldr/export/data/currencies.rb +6 -1
- data/lib/cldr/export/data/currency_digits_and_rounding.rb +22 -0
- data/lib/cldr/export/data/layout.rb +22 -0
- data/lib/cldr/export/data/lists.rb +28 -0
- data/lib/cldr/export/data/metazones.rb +45 -0
- data/lib/cldr/export/data/numbering_systems.rb +41 -0
- data/lib/cldr/export/data/numbers.rb +9 -0
- data/lib/cldr/export/data/plurals.rb +8 -7
- data/lib/cldr/export/data/plurals/rules.rb +114 -31
- data/lib/cldr/export/data/rbnf.rb +64 -0
- data/lib/cldr/export/data/rbnf_root.rb +19 -0
- data/lib/cldr/export/data/timezones.rb +29 -6
- data/lib/cldr/export/data/units.rb +23 -6
- data/lib/cldr/export/data/windows_zones.rb +23 -0
- data/lib/cldr/export/yaml.rb +2 -1
- data/lib/cldr/format/datetime/base.rb +1 -1
- data/lib/cldr/format/time.rb +1 -1
- data/lib/cldr/thor.rb +1 -1
- data/lib/core_ext/string/camelize.rb +1 -1
- data/test/export/data/calendars_test.rb +23 -18
- data/test/export/data/currencies_test.rb +24 -24
- data/test/export/data/languages_test.rb +52 -48
- data/test/export/data/metazones_test.rb +17 -0
- data/test/export/data/numbers_test.rb +34 -3
- data/test/export/data/plurals_test.rb +133 -32
- data/test/export/data/territories_test.rb +22 -22
- data/test/export/data/timezones_test.rb +49 -26
- data/test/export/data/units_test.rb +16 -17
- data/test/export/data/windows_zones_test.rb +12 -0
- data/test/export_test.rb +4 -1
- data/test/format/date_test.rb +2 -2
- data/test/test_autotest.rb +1 -1
- metadata +94 -32
@@ -0,0 +1,17 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
3
|
+
require File.expand_path(File.join(File.dirname(__FILE__) + '/../../test_helper'))
|
4
|
+
require 'date'
|
5
|
+
|
6
|
+
class TestCldrDataMetazones < Test::Unit::TestCase
|
7
|
+
test 'metazone timezones' do
|
8
|
+
timezones = Cldr::Export::Data::Metazones.new[:timezones]
|
9
|
+
assert_equal({ 'from' => DateTime.parse('1990-05-05T21:00:00+00:00'), 'metazone' => 'Europe_Eastern' }, timezones[:'Europe/Chisinau'].last)
|
10
|
+
end
|
11
|
+
|
12
|
+
test 'metazone primaryzones' do
|
13
|
+
primaryzones = Cldr::Export::Data::Metazones.new[:primaryzones]
|
14
|
+
assert_equal('Europe/Berlin', primaryzones[:'DE'])
|
15
|
+
end
|
16
|
+
|
17
|
+
end
|
@@ -14,9 +14,8 @@ class TestCldrDataNumbers < Test::Unit::TestCase
|
|
14
14
|
:percent_sign => "%",
|
15
15
|
:list => ";",
|
16
16
|
:per_mille => "‰",
|
17
|
-
:native_zero_digit => "0",
|
18
17
|
:infinity => "∞",
|
19
|
-
:
|
18
|
+
:superscripting_exponent => "·"
|
20
19
|
}
|
21
20
|
assert_equal expected, Cldr::Export::Data::Numbers.new('de')[:numbers][:symbols]
|
22
21
|
end
|
@@ -24,21 +23,53 @@ class TestCldrDataNumbers < Test::Unit::TestCase
|
|
24
23
|
test "number formats :de" do
|
25
24
|
expected = {
|
26
25
|
:decimal => {
|
26
|
+
:number_system => "latn",
|
27
27
|
:patterns => {
|
28
|
-
:default => "#,##0.###"
|
28
|
+
:default => "#,##0.###",
|
29
|
+
"long" => {
|
30
|
+
"1000" => "0 Tausend",
|
31
|
+
"10000" => "00 Tausend",
|
32
|
+
"100000" => "000 Tausend",
|
33
|
+
"1000000" => "0 Millionen",
|
34
|
+
"10000000" => "00 Millionen",
|
35
|
+
"100000000" => "000 Millionen",
|
36
|
+
"1000000000" => "0 Milliarden",
|
37
|
+
"10000000000" => "00 Milliarden",
|
38
|
+
"100000000000" => "000 Milliarden",
|
39
|
+
"1000000000000" => "0 Billionen",
|
40
|
+
"10000000000000" => "00 Billionen",
|
41
|
+
"100000000000000" => "000 Billionen"
|
42
|
+
},
|
43
|
+
"short" => {
|
44
|
+
"1000" => "0 Tsd",
|
45
|
+
"10000" => "00 Tsd",
|
46
|
+
"100000" => "000 Tsd",
|
47
|
+
"1000000" => "0 Mio",
|
48
|
+
"10000000" => "00 Mio",
|
49
|
+
"100000000" => "000 Mio",
|
50
|
+
"1000000000" => "0 Mrd",
|
51
|
+
"10000000000" => "00 Mrd",
|
52
|
+
"100000000000" => "000 Mrd",
|
53
|
+
"1000000000000" => "0 Bio",
|
54
|
+
"10000000000000" => "00 Bio",
|
55
|
+
"100000000000000" => "000 Bio"
|
56
|
+
}
|
29
57
|
}
|
30
58
|
},
|
31
59
|
:scientific => {
|
60
|
+
:number_system => "latn",
|
32
61
|
:patterns => {
|
33
62
|
:default => "#E0"
|
34
63
|
}
|
35
64
|
},
|
36
65
|
:percent => {
|
66
|
+
:number_system => "latn",
|
37
67
|
:patterns => {
|
38
68
|
:default => "#,##0 %" # includes a non-breaking space (\302\240)
|
39
69
|
}
|
40
70
|
},
|
41
71
|
:currency => {
|
72
|
+
:number_system => "latn",
|
42
73
|
:patterns => {
|
43
74
|
:default => "#,##0.00 ¤", # includes a non-breaking space (\302\240)
|
44
75
|
},
|
@@ -21,121 +21,222 @@ class TestCldrDataPluralParser < Test::Unit::TestCase
|
|
21
21
|
end
|
22
22
|
|
23
23
|
def test_lookup_rule_by_locale
|
24
|
-
assert_equal
|
24
|
+
assert_equal 'lambda { |n| n = n.respond_to?(:abs) ? n.abs : ((m = n.to_s)[0] == "-" ? m[1,m.length] : m); (n.to_i == 1 && ((v = n.to_s.split(".")[1]) ? v.length : 0) == 0) ? :one : :other }', cldr_rules.rule(:de).to_ruby
|
25
25
|
end
|
26
26
|
|
27
|
-
def
|
28
|
-
assert Cldr::Export::Data::Plurals::Rule.parse('
|
27
|
+
def test_parses_empty
|
28
|
+
assert Cldr::Export::Data::Plurals::Rule.parse('').is_a?(Cldr::Export::Data::Plurals::Expression)
|
29
|
+
assert Cldr::Export::Data::Plurals::Rule.parse(' ').is_a?(Cldr::Export::Data::Plurals::Expression)
|
30
|
+
assert Cldr::Export::Data::Plurals::Rule.parse(' @integer').is_a?(Cldr::Export::Data::Plurals::Expression)
|
31
|
+
assert Cldr::Export::Data::Plurals::Rule.parse('@decimal').is_a?(Cldr::Export::Data::Plurals::Expression)
|
29
32
|
end
|
30
33
|
|
31
34
|
def test_parses_n_is_1
|
32
35
|
rule = Cldr::Export::Data::Plurals::Rule.parse('n is 1')
|
33
|
-
assert_equal [:is,
|
36
|
+
assert_equal [:is, 1], [rule.operator, rule.operand]
|
34
37
|
end
|
35
38
|
|
36
39
|
def test_parses_n_mod_1_is_1
|
37
40
|
rule = Cldr::Export::Data::Plurals::Rule.parse('n mod 1 is 1')
|
38
|
-
assert_equal [:is, '1', '
|
41
|
+
assert_equal [:is, 1, '1', 'n'], [rule.operator, rule.operand, rule.mod, rule.type]
|
39
42
|
end
|
40
43
|
|
41
44
|
def test_parses_n_is_not_1
|
42
45
|
rule = Cldr::Export::Data::Plurals::Rule.parse('n is not 1')
|
43
|
-
assert_equal [:is,
|
46
|
+
assert_equal [:is, 1, true, 'n'], [rule.operator, rule.operand, rule.negate, rule.type]
|
44
47
|
end
|
45
48
|
|
46
49
|
def test_parses_n_mod_1_is_not_1
|
47
50
|
rule = Cldr::Export::Data::Plurals::Rule.parse('n mod 1 is not 1')
|
48
|
-
assert_equal [:is,
|
51
|
+
assert_equal [:is, 1, true, '1', 'n'], [rule.operator, rule.operand, rule.negate, rule.mod, rule.type]
|
49
52
|
end
|
50
53
|
|
51
54
|
def test_parses_n_in_1_2
|
52
55
|
rule = Cldr::Export::Data::Plurals::Rule.parse('n in 1..2')
|
53
|
-
assert_equal [:in,
|
56
|
+
assert_equal [:in, [[],[1..2]], 'n'], [rule.operator, rule.operand, rule.type]
|
54
57
|
end
|
55
58
|
|
56
59
|
def test_parses_n_mod_1_in_1_2
|
57
60
|
rule = Cldr::Export::Data::Plurals::Rule.parse('n mod 1 in 1..2')
|
58
|
-
assert_equal [:in,
|
61
|
+
assert_equal [:in, [[],[1..2]], '1', 'n'], [rule.operator, rule.operand, rule.mod, rule.type]
|
59
62
|
end
|
60
63
|
|
61
64
|
def test_parses_n_not_in_1_2
|
62
65
|
rule = Cldr::Export::Data::Plurals::Rule.parse('n not in 1..2')
|
63
|
-
assert_equal [:in,
|
66
|
+
assert_equal [:in, [[],[1..2]], true, 'n'], [rule.operator, rule.operand, rule.negate, rule.type]
|
64
67
|
end
|
65
68
|
|
66
69
|
def test_parses_n_mod_1_not_in_1_2
|
67
70
|
rule = Cldr::Export::Data::Plurals::Rule.parse('n mod 1 not in 1..2')
|
68
|
-
assert_equal [:in,
|
71
|
+
assert_equal [:in, [[],[1..2]], true, '1', 'n'], [rule.operator, rule.operand, rule.negate, rule.mod, rule.type]
|
69
72
|
end
|
70
73
|
|
71
74
|
def test_parses_n_within_0_2
|
72
75
|
expression = Cldr::Export::Data::Plurals::Rule.parse('n within 0..2')
|
73
|
-
assert_equal [:within,
|
76
|
+
assert_equal [:within, 0..2, 'n'], [expression.operator, expression.operand, expression.type]
|
77
|
+
end
|
78
|
+
|
79
|
+
def test_parses_n_list_range
|
80
|
+
expression = Cldr::Export::Data::Plurals::Rule.parse('n % 100 != 10..19,30,34,39,90..99')
|
81
|
+
assert_equal [:in, [[30, 34, 39],[10..19, 90..99]], true, '100', 'n'], [expression.operator, expression.operand, expression.negate, expression.mod, expression.type]
|
74
82
|
end
|
75
83
|
|
76
84
|
def test_parses_or_condition
|
77
85
|
rule = Cldr::Export::Data::Plurals::Rule.parse('n mod 1 is not 2 or n mod 2 in 3..4')
|
78
86
|
assert_equal 2, rule.size
|
79
|
-
assert_equal [:is,
|
80
|
-
assert_equal [:in,
|
87
|
+
assert_equal [:is, 2, true, '1', 'n'], [rule[0].operator, rule[0].operand, rule[0].negate, rule[0].mod, rule[0].type]
|
88
|
+
assert_equal [:in, [[],[3..4]], false, '2', 'n'], [rule[1].operator, rule[1].operand, rule[1].negate, rule[1].mod, rule[1].type]
|
81
89
|
end
|
82
90
|
|
83
91
|
def test_parses_and_condition
|
84
92
|
rule = Cldr::Export::Data::Plurals::Rule.parse('n mod 1 is not 2 and n mod 2 in 3..4')
|
85
93
|
assert_equal 2, rule.size
|
86
|
-
assert_equal [:is,
|
87
|
-
assert_equal [:in,
|
94
|
+
assert_equal [:is, 2, true, '1', 'n'], [rule[0].operator, rule[0].operand, rule[0].negate, rule[0].mod, rule[0].type]
|
95
|
+
assert_equal [:in, [[],[3..4]], false, '2', 'n'], [rule[1].operator, rule[1].operand, rule[1].negate, rule[1].mod, rule[1].type]
|
96
|
+
end
|
97
|
+
|
98
|
+
def test_parses_and_priority
|
99
|
+
rule = Cldr::Export::Data::Plurals::Rule.parse('i = 0 or v != 1 and f % 2 = 3..4')
|
100
|
+
assert_equal 2, rule.size
|
101
|
+
assert_equal 2, rule[1].size
|
102
|
+
assert_equal [:is, 0, 'i'], [rule[0].operator, rule[0].operand, rule[0].type]
|
103
|
+
assert_equal [:is, 1, true, 'v'], [rule[1][0].operator, rule[1][0].operand, rule[1][0].negate, rule[1][0].type]
|
104
|
+
assert_equal [:in, [[],[3..4]], '2', 'f'], [rule[1][1].operator, rule[1][1].operand, rule[1][1].mod, rule[1][1].type]
|
88
105
|
end
|
89
106
|
|
90
|
-
def
|
91
|
-
assert_equal
|
107
|
+
def test_compiles_empty
|
108
|
+
assert_equal nil, Cldr::Export::Data::Plurals::Rule.parse('').to_ruby
|
109
|
+
assert_equal nil, Cldr::Export::Data::Plurals::Rule.parse(' ').to_ruby
|
110
|
+
assert_equal nil, Cldr::Export::Data::Plurals::Rule.parse(' @integer').to_ruby
|
111
|
+
assert_equal nil, Cldr::Export::Data::Plurals::Rule.parse('@decimal').to_ruby
|
92
112
|
end
|
93
113
|
|
94
114
|
def test_compiles_n_is_2
|
95
|
-
assert_equal 'n == 2', Cldr::Export::Data::Plurals::Rule.parse('n is 2').to_ruby
|
115
|
+
assert_equal 'n.to_f == 2', Cldr::Export::Data::Plurals::Rule.parse('n is 2').to_ruby
|
96
116
|
end
|
97
117
|
|
98
118
|
def test_compiles_n_mod_1_is_2
|
99
|
-
assert_equal 'n % 1 == 2', Cldr::Export::Data::Plurals::Rule.parse('n mod 1 is 2').to_ruby
|
119
|
+
assert_equal 'n.to_f % 1 == 2', Cldr::Export::Data::Plurals::Rule.parse('n mod 1 is 2').to_ruby
|
100
120
|
end
|
101
121
|
|
102
122
|
def test_compiles_n_is_not_2
|
103
|
-
assert_equal 'n != 2', Cldr::Export::Data::Plurals::Rule.parse('n is not 2').to_ruby
|
123
|
+
assert_equal 'n.to_f != 2', Cldr::Export::Data::Plurals::Rule.parse('n is not 2').to_ruby
|
104
124
|
end
|
105
125
|
|
106
126
|
def test_compiles_n_mod_1_is_not_2
|
107
|
-
assert_equal 'n % 1 != 2', Cldr::Export::Data::Plurals::Rule.parse('n mod 1 is not 2').to_ruby
|
127
|
+
assert_equal 'n.to_f % 1 != 2', Cldr::Export::Data::Plurals::Rule.parse('n mod 1 is not 2').to_ruby
|
108
128
|
end
|
109
129
|
|
110
130
|
def test_compiles_n_in_1_2
|
111
|
-
assert_equal '
|
131
|
+
assert_equal '((n.to_f % 1).zero? && (1..2).include?(n.to_f))', Cldr::Export::Data::Plurals::Rule.parse('n in 1..2').to_ruby
|
112
132
|
end
|
113
133
|
|
114
134
|
def test_compiles_n_mod_1_in_1_2
|
115
|
-
assert_equal '
|
135
|
+
assert_equal '(((n.to_f % 1) % 1).zero? && (1..2).include?(n.to_f % 1))', Cldr::Export::Data::Plurals::Rule.parse('n mod 1 in 1..2').to_ruby
|
116
136
|
end
|
117
137
|
|
118
138
|
def test_compiles_n_not_in_1_2
|
119
|
-
assert_equal '!
|
139
|
+
assert_equal '((n.to_f % 1).zero? && !(1..2).include?(n.to_f))', Cldr::Export::Data::Plurals::Rule.parse('n not in 1..2').to_ruby
|
120
140
|
end
|
121
141
|
|
122
142
|
def test_compiles_n_mod_1_not_in_1_2
|
123
|
-
assert_equal '!
|
143
|
+
assert_equal '(((n.to_f % 1) % 1).zero? && !(1..2).include?(n.to_f % 1))', Cldr::Export::Data::Plurals::Rule.parse('n mod 1 not in 1..2').to_ruby
|
124
144
|
end
|
125
145
|
|
126
146
|
def test_compiles_or_condition
|
127
|
-
assert_equal 'n % 1 != 2 ||
|
147
|
+
assert_equal '(n.to_f % 1 != 2 || (((n.to_f % 2) % 1).zero? && (3..4).include?(n.to_f % 2)))', Cldr::Export::Data::Plurals::Rule.parse('n mod 1 is not 2 or n mod 2 in 3..4').to_ruby
|
128
148
|
end
|
129
149
|
|
130
150
|
def test_compiles_and_condition
|
131
|
-
assert_equal 'n % 1 != 2 &&
|
151
|
+
assert_equal '(n.to_f % 1 != 2 && (((n.to_f % 2) % 1).zero? && (3..4).include?(n.to_f % 2)))', Cldr::Export::Data::Plurals::Rule.parse('n mod 1 is not 2 and n mod 2 in 3..4').to_ruby
|
152
|
+
end
|
153
|
+
|
154
|
+
def test_compiles_and_priority
|
155
|
+
assert_equal '(n.to_i == 0 || (((v = n.to_s.split(".")[1]) ? v.length : 0) != 1 && (3..4).include?(((t = n.to_s.split(".")[1]) ? t.gsub(/0+$/, "").to_i : 0) % 2)))', Cldr::Export::Data::Plurals::Rule.parse('i = 0 or v != 1 and t mod 2 = 3..4').to_ruby
|
132
156
|
end
|
133
157
|
|
134
158
|
def test_compiles_n_mod_100_in_3_99
|
135
|
-
assert_equal '
|
159
|
+
assert_equal '(((n.to_f % 100) % 1).zero? && (3..6).include?(n.to_f % 100))', Cldr::Export::Data::Plurals::Rule.parse('n mod 100 in 3..6').to_ruby
|
136
160
|
end
|
137
161
|
|
138
162
|
def test_compiles_n_within_0_2
|
139
|
-
assert_equal 'n.between?(0, 2)', Cldr::Export::Data::Plurals::Rule.parse('n within 0..2').to_ruby
|
140
|
-
end
|
141
|
-
|
163
|
+
assert_equal 'n.to_f.between?(0, 2)', Cldr::Export::Data::Plurals::Rule.parse('n within 0..2').to_ruby
|
164
|
+
end
|
165
|
+
|
166
|
+
def test_compiles_n_list_range
|
167
|
+
assert_equal '(![30, 34, 39].include?(n.to_f % 100) || (((n.to_f % 100) % 1).zero? && (!(10..19).include?(n.to_f % 100) || !(90..99).include?(n.to_f % 100))))', Cldr::Export::Data::Plurals::Rule.parse('n % 100 != 10..19,30,34,39,90..99').to_ruby
|
168
|
+
end
|
169
|
+
|
170
|
+
def test_compiles_n_list_range2
|
171
|
+
assert_equal '((n.to_f % 100) != 100 || (((n.to_f % 100) % 1).zero? && (!(10..19).include?(n.to_f % 100) || !(90..99).include?(n.to_f % 100))))', Cldr::Export::Data::Plurals::Rule.parse('n % 100 != 10..19,90..99,100').to_ruby
|
172
|
+
end
|
173
|
+
|
174
|
+
def test_eval_n_in
|
175
|
+
n = 3.3
|
176
|
+
assert_equal false, eval(Cldr::Export::Data::Plurals::Rule.parse('n mod 100 in 3..6').to_ruby, binding)
|
177
|
+
end
|
178
|
+
|
179
|
+
def test_n_negative
|
180
|
+
# one: i = 1 and v = 0 @integer 1
|
181
|
+
# other: @integer 0, 2~16, 100, 1000, 10000, 100000, 1000000, … @decimal 0.0~1.5, 10.0, 100.0, 1000.0, 10000.0, 100000.0, 1000000.0, …
|
182
|
+
fn = eval(cldr_rules.rule(:de).to_ruby)
|
183
|
+
assert_equal :one, fn.call(-1)
|
184
|
+
assert_equal :one, fn.call("-1")
|
185
|
+
assert_equal :one, fn.call(1)
|
186
|
+
assert_equal :other, fn.call("1.0")
|
187
|
+
assert_equal :other, fn.call("-1.0")
|
188
|
+
assert_equal :other, fn.call(-5)
|
189
|
+
end
|
190
|
+
|
191
|
+
def test_n_digit
|
192
|
+
# one: n = 0..1 or n = 11..99 @integer 0, 1, 11~24 @decimal 0.0, 1.0, 11.0, 12.0, 13.0, 14.0, 15.0, 16.0, 17.0, 18.0, 19.0, 20.0, 21.0, 22.0, 23.0, 24.0
|
193
|
+
# other: @integer 2~10, 100~106, 1000, 10000, 100000, 1000000, … @decimal 0.1~0.9, 1.1~1.7, 10.0, 100.0, 1000.0, 10000.0, 100000.0, 1000000.0, …
|
194
|
+
fn = eval(cldr_rules.rule(:tzm).to_ruby)
|
195
|
+
assert_equal :one, fn.call(0)
|
196
|
+
assert_equal :one, fn.call(1)
|
197
|
+
assert_equal :one, fn.call(11)
|
198
|
+
assert_equal :one, fn.call(25.0)
|
199
|
+
assert_equal :one, fn.call("-62.00")
|
200
|
+
assert_equal :other, fn.call(2)
|
201
|
+
assert_equal :other, fn.call(10)
|
202
|
+
assert_equal :other, fn.call(25.1)
|
203
|
+
assert_equal :other, fn.call(111)
|
204
|
+
end
|
205
|
+
|
206
|
+
def test_n_string
|
207
|
+
# one: i = 1 and v = 0 or i = 0 and t = 1 @integer 1 @decimal 0.1, 0.01, 0.10, 0.001, 0.010, 0.100, 0.0001, 0.0010, 0.0100, 0.1000
|
208
|
+
# other: @integer 0, 2~16, 100, 1000, 10000, 100000, 1000000, … @decimal 0.0, 0.2~1.6, 10.0, 100.0, 1000.0, 10000.0, 100000.0, 1000000.0, …
|
209
|
+
fn = eval(cldr_rules.rule(:pt).to_ruby)
|
210
|
+
assert_equal :one, fn.call("1")
|
211
|
+
assert_equal :one, fn.call("0.00100")
|
212
|
+
assert_equal :one, fn.call("-0.01")
|
213
|
+
assert_equal :other, fn.call("0")
|
214
|
+
assert_equal :other, fn.call("1.1")
|
215
|
+
assert_equal :other, fn.call("0.21")
|
216
|
+
end
|
217
|
+
|
218
|
+
def test_n_mod
|
219
|
+
# one: v = 0 and i % 10 = 1 and i % 100 != 11 or f % 10 = 1 and f % 100 != 11 @integer 1, 21, 31, 41, 51, 61, 71, 81, 101, 1001, … @decimal 0.1, 1.1, 2.1, 3.1, 4.1, 5.1, 6.1, 7.1, 10.1, 100.1, 1000.1, …
|
220
|
+
# few: v = 0 and i % 10 = 2..4 and i % 100 != 12..14 or f % 10 = 2..4 and f % 100 != 12..14 @integer 2~4, 22~24, 32~34, 42~44, 52~54, 62, 102, 1002, … @decimal 0.2~0.4, 1.2~1.4, 2.2~2.4, 3.2~3.4, 4.2~4.4, 5.2, 10.2, 100.2, 1000.2, …
|
221
|
+
# other: @integer 0, 5~19, 100, 1000, 10000, 100000, 1000000, … @decimal 0.0, 0.5~1.0, 1.5~2.0, 2.5~2.7, 10.0, 100.0, 1000.0, 10000.0, 100000.0, 1000000.0, …
|
222
|
+
fn = eval(cldr_rules.rule(:hr).to_ruby)
|
223
|
+
assert_equal :one, fn.call(1)
|
224
|
+
assert_equal :one, fn.call("21")
|
225
|
+
assert_equal :one, fn.call("131")
|
226
|
+
assert_equal :one, fn.call(11.321)
|
227
|
+
assert_equal :one, fn.call("25.01")
|
228
|
+
assert_equal :few, fn.call(24)
|
229
|
+
assert_equal :few, fn.call("252")
|
230
|
+
assert_equal :few, fn.call(2.04)
|
231
|
+
assert_equal :few, fn.call("113.0022")
|
232
|
+
assert_equal :other, fn.call("10")
|
233
|
+
assert_equal :other, fn.call("11")
|
234
|
+
assert_equal :other, fn.call(311)
|
235
|
+
assert_equal :other, fn.call("13")
|
236
|
+
assert_equal :other, fn.call(1212)
|
237
|
+
assert_equal :other, fn.call("0.10")
|
238
|
+
assert_equal :other, fn.call(0.11)
|
239
|
+
assert_equal :other, fn.call("0.220")
|
240
|
+
assert_equal :other, fn.call("41.0")
|
241
|
+
end
|
242
|
+
end
|
@@ -6,28 +6,28 @@ class TestCldrDataTerritories < Test::Unit::TestCase
|
|
6
6
|
test 'territories :de' do
|
7
7
|
codes = [:"001", :"002", :"003", :"005", :"009", :"011", :"013", :"014",
|
8
8
|
:"015", :"017", :"018", :"019", :"021", :"029", :"030", :"034",
|
9
|
-
:"035", :"039", :"053", :"054", :"057", :"061", :"
|
10
|
-
:"
|
11
|
-
:
|
12
|
-
:
|
13
|
-
:
|
14
|
-
:
|
15
|
-
:
|
16
|
-
:EE, :EG, :EH, :ER, :ES, :ET, :FI, :FJ, :FK, :FM, :FO, :FR,
|
17
|
-
:GB, :GD, :GE, :GF, :GG, :GH, :GI, :GL, :GM, :GN, :GP, :GQ,
|
18
|
-
:GS, :GT, :GU, :GW, :GY, :HK, :HM, :HN, :HR, :HT, :HU, :
|
19
|
-
:IL, :IM, :IN, :IO, :IQ, :IR, :IS, :IT, :JE, :JM, :JO,
|
20
|
-
:KG, :KH, :KI, :KM, :KN, :KP, :KR, :KW, :KY, :KZ, :LA,
|
21
|
-
:LI, :LK, :LR, :LS, :LT, :LU, :LV, :LY, :MA, :MC, :MD,
|
22
|
-
:MG, :MH, :MK, :ML, :MM, :MN, :MO, :MP, :MQ, :MR, :MS,
|
23
|
-
:MV, :MW, :MX, :MY, :MZ, :NA, :NC, :NE, :NF, :NG, :NI,
|
24
|
-
:NP, :NR, :NU, :NZ, :OM, :PA, :PE, :PF, :PG, :PH, :PK,
|
25
|
-
:PN, :PR, :PS, :PT, :PW, :PY, :QA, :QO, :
|
26
|
-
:RW, :SA, :SB, :SC, :SD, :SE, :SG, :SH, :SI, :SJ, :SK, :SL,
|
27
|
-
:SN, :SO, :SR, :
|
28
|
-
:
|
29
|
-
:
|
30
|
-
:YT, :ZA, :ZM, :ZW, :ZZ]
|
9
|
+
:"035", :"039", :"053", :"054", :"057", :"061", :"142", :"143",
|
10
|
+
:"145", :"150", :"151", :"154", :"155", :"419", :AC, :AD, :AE,
|
11
|
+
:AF, :AG, :AI, :AL, :AM, :AN, :AO, :AQ, :AR, :AS, :AT, :AU, :AW,
|
12
|
+
:AX, :AZ, :BA, :BB, :BD, :BE, :BF, :BG, :BH, :BI, :BJ, :BL, :BM,
|
13
|
+
:BN, :BO, :BQ, :BR, :BS, :BT, :BV, :BW, :BY, :BZ, :CA, :CC, :CD,
|
14
|
+
:CF, :CG, :CH, :CI, :CK, :CL, :CM, :CN, :CO, :CP, :CR, :CU, :CV,
|
15
|
+
:CW, :CX, :CY, :CZ, :DE, :DG, :DJ, :DK, :DM, :DO, :DZ, :EA, :EC,
|
16
|
+
:EE, :EG, :EH, :ER, :ES, :ET, :EU, :FI, :FJ, :FK, :FM, :FO, :FR,
|
17
|
+
:GA, :GB, :GD, :GE, :GF, :GG, :GH, :GI, :GL, :GM, :GN, :GP, :GQ,
|
18
|
+
:GR, :GS, :GT, :GU, :GW, :GY, :HK, :HM, :HN, :HR, :HT, :HU, :IC,
|
19
|
+
:ID, :IE, :IL, :IM, :IN, :IO, :IQ, :IR, :IS, :IT, :JE, :JM, :JO,
|
20
|
+
:JP, :KE, :KG, :KH, :KI, :KM, :KN, :KP, :KR, :KW, :KY, :KZ, :LA,
|
21
|
+
:LB, :LC, :LI, :LK, :LR, :LS, :LT, :LU, :LV, :LY, :MA, :MC, :MD,
|
22
|
+
:ME, :MF, :MG, :MH, :MK, :ML, :MM, :MN, :MO, :MP, :MQ, :MR, :MS,
|
23
|
+
:MT, :MU, :MV, :MW, :MX, :MY, :MZ, :NA, :NC, :NE, :NF, :NG, :NI,
|
24
|
+
:NL, :NO, :NP, :NR, :NU, :NZ, :OM, :PA, :PE, :PF, :PG, :PH, :PK,
|
25
|
+
:PL, :PM, :PN, :PR, :PS, :PT, :PW, :PY, :QA, :QO, :RE, :RO, :RS,
|
26
|
+
:RU, :RW, :SA, :SB, :SC, :SD, :SE, :SG, :SH, :SI, :SJ, :SK, :SL,
|
27
|
+
:SM, :SN, :SO, :SR, :SS, :ST, :SV, :SX, :SY, :SZ, :TA, :TC, :TD,
|
28
|
+
:TF, :TG, :TH, :TJ, :TK, :TL, :TM, :TN, :TO, :TR, :TT, :TV, :TW,
|
29
|
+
:TZ, :UA, :UG, :UM, :US, :UY, :UZ, :VA, :VC, :VE, :VG, :VI, :VN,
|
30
|
+
:VU, :WF, :WS, :XK, :YE, :YT, :ZA, :ZM, :ZW, :ZZ]
|
31
31
|
|
32
32
|
territories = Cldr::Export::Data::Territories.new(:de)[:territories]
|
33
33
|
assert (territories.keys - codes).empty? && (codes - territories.keys).empty?
|
@@ -5,41 +5,64 @@ require File.expand_path(File.join(File.dirname(__FILE__) + '/../../test_helper'
|
|
5
5
|
class TestCldrDataTimezones < Test::Unit::TestCase
|
6
6
|
test 'timezones :de' do
|
7
7
|
codes = [:"Etc/Unknown", :"Europe/Tirane", :"Asia/Yerevan",
|
8
|
-
:"
|
9
|
-
:"Antarctica/
|
10
|
-
:"
|
11
|
-
:"Atlantic/Bermuda", :"
|
12
|
-
:"America/
|
13
|
-
:"Asia/
|
14
|
-
:"
|
8
|
+
:"Antarctica/South_Pole", :"Antarctica/Vostok",
|
9
|
+
:"Antarctica/DumontDUrville", :"Europe/Vienna", :"Europe/Brussels",
|
10
|
+
:"Africa/Ouagadougou", :"Africa/Porto-Novo", :"America/St_Barthelemy",
|
11
|
+
:"Atlantic/Bermuda", :"America/Sao_Paulo", :"America/Coral_Harbour",
|
12
|
+
:"America/St_Johns", :"Europe/Zurich", :"Pacific/Easter",
|
13
|
+
:"Asia/Kashgar", :"America/Bogota", :"America/Havana",
|
14
|
+
:"Atlantic/Cape_Verde", :"America/Curacao", :"Indian/Christmas",
|
15
|
+
:"Asia/Nicosia", :"Europe/Prague", :"Europe/Busingen",
|
16
|
+
:"Africa/Djibouti", :"Europe/Copenhagen", :"Africa/Algiers",
|
17
|
+
:"Africa/Cairo", :"Africa/El_Aaiun", :"Africa/Asmera",
|
15
18
|
:"Atlantic/Canary", :"Africa/Addis_Ababa", :"Pacific/Fiji",
|
16
|
-
:"
|
17
|
-
:"Europe/
|
18
|
-
:"
|
19
|
-
:"
|
20
|
-
:"
|
21
|
-
:"America/
|
22
|
-
:"
|
23
|
-
:"
|
24
|
-
:"
|
25
|
-
:"
|
26
|
-
:"
|
27
|
-
:"Europe/
|
28
|
-
:"
|
19
|
+
:"Pacific/Truk", :"Pacific/Ponape", :"Atlantic/Faeroe",
|
20
|
+
:"Europe/London", :"Asia/Tbilisi", :"Africa/Accra", :"America/Godthab",
|
21
|
+
:"America/Scoresbysund", :"Europe/Athens", :"Atlantic/South_Georgia",
|
22
|
+
:"Asia/Hong_Kong", :"Asia/Jayapura", :"Europe/Dublin", :"Asia/Calcutta",
|
23
|
+
:"Asia/Baghdad", :"Asia/Tehran", :"Atlantic/Reykjavik", :"Europe/Rome",
|
24
|
+
:"America/Jamaica", :"Asia/Tokyo", :"Asia/Bishkek", :"Indian/Comoro",
|
25
|
+
:"America/St_Kitts", :"Asia/Pyongyang", :"America/Cayman",
|
26
|
+
:"Asia/Aqtobe", :"America/St_Lucia", :"Europe/Vilnius",
|
27
|
+
:"Europe/Luxembourg", :"Africa/Tripoli", :"Europe/Chisinau",
|
28
|
+
:"Asia/Macau", :"Indian/Maldives", :"America/Mexico_City",
|
29
|
+
:"Asia/Katmandu", :"Asia/Muscat", :"Europe/Warsaw", :"Atlantic/Azores",
|
30
|
+
:"Europe/Lisbon", :"America/Asuncion", :"Asia/Qatar", :"Indian/Reunion",
|
31
|
+
:"Europe/Bucharest", :"Europe/Belgrade", :"Europe/Moscow",
|
32
|
+
:"Europe/Volgograd", :"Asia/Yekaterinburg", :"Asia/Novosibirsk",
|
33
|
+
:"Asia/Novokuznetsk", :"Asia/Krasnoyarsk", :"Asia/Yakutsk",
|
29
34
|
:"Asia/Vladivostok", :"Asia/Sakhalin", :"Asia/Kamchatka",
|
30
35
|
:"Asia/Riyadh", :"Africa/Khartoum", :"Asia/Singapore",
|
31
36
|
:"Atlantic/St_Helena", :"Africa/Mogadishu", :"Africa/Sao_Tome",
|
32
|
-
:"America/El_Salvador", :"
|
33
|
-
:"
|
34
|
-
:"
|
35
|
-
:"
|
36
|
-
:"America/
|
37
|
-
|
37
|
+
:"America/El_Salvador", :"America/Lower_Princes", :"Asia/Damascus",
|
38
|
+
:"Africa/Lome", :"Asia/Dushanbe", :"America/Port_of_Spain",
|
39
|
+
:"Asia/Taipei", :"Africa/Dar_es_Salaam", :"Europe/Uzhgorod",
|
40
|
+
:"Europe/Kiev", :"Europe/Zaporozhye", :"America/North_Dakota/Beulah",
|
41
|
+
:"America/North_Dakota/New_Salem", :"America/North_Dakota/Center",
|
42
|
+
:"America/Indiana/Vincennes", :"America/Indiana/Petersburg",
|
43
|
+
:"America/Indiana/Tell_City", :"America/Indiana/Knox",
|
44
|
+
:"America/Indiana/Winamac", :"America/Indiana/Marengo",
|
45
|
+
:"America/Indiana/Vevay", :"America/Kentucky/Monticello",
|
46
|
+
:"Asia/Tashkent", :"Europe/Vatican", :"America/St_Vincent",
|
47
|
+
:"America/St_Thomas", :"Asia/Saigon"]
|
48
|
+
|
38
49
|
timezones = Cldr::Export::Data::Timezones.new(:de)[:timezones]
|
39
50
|
assert (timezones.keys - codes).empty? && (codes - timezones.keys).empty?
|
40
51
|
assert_equal({ :city => 'Wien' }, timezones[:"Europe/Vienna"])
|
41
52
|
end
|
42
53
|
|
54
|
+
test 'timezone daylight' do
|
55
|
+
london = Cldr::Export::Data::Timezones.new(:de)[:timezones][:'Europe/London']
|
56
|
+
assert_equal({ :long => { :daylight => 'Britische Sommerzeit'} }, london)
|
57
|
+
end
|
58
|
+
|
59
|
+
test 'metazone :de Europe_Western' do
|
60
|
+
europe_western = Cldr::Export::Data::Timezones.new(:de)[:metazones][:Europe_Western]
|
61
|
+
long = { :generic => 'Westeuropäische Zeit', :standard => 'Westeuropäische Normalzeit', :daylight => 'Westeuropäische Sommerzeit' }
|
62
|
+
short = { :generic => 'WEZ', :standard => 'WEZ', :daylight => 'WESZ' }
|
63
|
+
assert_equal({ :long => long, :short => short }, europe_western)
|
64
|
+
end
|
65
|
+
|
43
66
|
# Cldr::Export::Data.locales.each do |locale|
|
44
67
|
# test "extract timezones for #{locale}" do
|
45
68
|
# assert_nothing_raised do
|