summaryrefslogtreecommitdiff
path: root/vendor/plugins/globalize2/test/locale/fallbacks_test.rb
diff options
context:
space:
mode:
authorhukl <contact@smyck.org>2010-01-14 22:21:43 +0100
committerhukl <contact@smyck.org>2010-01-14 22:21:43 +0100
commit57d1382013c85a7b11ac8ce5e683f6006b12b328 (patch)
tree19646c4fa5952fa1cf0a2c874952affa346373f1 /vendor/plugins/globalize2/test/locale/fallbacks_test.rb
parent1b86bf5f2e35d1820bfa32d979bcc2d9ff9a9a8e (diff)
Updated globalize2 to latest version. Modified existing code accoringly
Diffstat (limited to 'vendor/plugins/globalize2/test/locale/fallbacks_test.rb')
-rw-r--r--vendor/plugins/globalize2/test/locale/fallbacks_test.rb154
1 files changed, 0 insertions, 154 deletions
diff --git a/vendor/plugins/globalize2/test/locale/fallbacks_test.rb b/vendor/plugins/globalize2/test/locale/fallbacks_test.rb
deleted file mode 100644
index 304d3da0..00000000
--- a/vendor/plugins/globalize2/test/locale/fallbacks_test.rb
+++ /dev/null
@@ -1,154 +0,0 @@
1require File.join( File.dirname(__FILE__), '..', 'test_helper' )
2require 'globalize/locale/fallbacks'
3
4include Globalize::Locale
5I18n.default_locale = :'en-US' # This has to be set explicitly, no longer default for I18n
6
7class FallbacksTest < ActiveSupport::TestCase
8 def setup
9 I18n.fallbacks = Fallbacks.new
10 end
11
12 def teardown
13 I18n.default_locale = :'en-US'
14 end
15
16 test "#[] caches computed results" do
17 I18n.fallbacks['en']
18 assert_equal( { :en => [:en, :"en-US", :root] }, I18n.fallbacks )
19 end
20
21 test "#defaults always reflect the I18n.default_locale if no default has been set manually" do
22 I18n.default_locale = :'en-US'
23 assert_equal( [:'en-US', :en, :root], I18n.fallbacks.defaults )
24 end
25
26 test "#defaults always reflect a manually passed default locale if any" do
27 I18n.fallbacks = Fallbacks.new(:'fi-FI')
28 assert_equal( [:'fi-FI', :fi, :root], I18n.fallbacks.defaults )
29 I18n.default_locale = :'de-DE'
30 assert_equal( [:'fi-FI', :fi, :root], I18n.fallbacks.defaults )
31 end
32
33 test "#defaults allows to set multiple defaults" do
34 I18n.fallbacks = Fallbacks.new(:'fi-FI', :'se-FI')
35 assert_equal( [:'fi-FI', :fi, :'se-FI', :se, :root], I18n.fallbacks.defaults )
36 end
37end
38
39class NoMappingFallbacksTest < ActiveSupport::TestCase
40 def setup
41 @fallbacks = Fallbacks.new(:'en-US')
42 end
43
44 test "returns [:es, :en-US, :root] for :es" do
45 assert_equal [:es, :"en-US", :en, :root], @fallbacks[:es]
46 end
47
48 test "returns [:es-ES, :es, :en-US, :root] for :es-ES" do
49 assert_equal [:"es-ES", :es, :"en-US", :en, :root], @fallbacks[:"es-ES"]
50 end
51
52 test "returns [:es-MX, :es, :en-US, :root] for :es-MX" do
53 assert_equal [:"es-MX", :es, :"en-US", :en, :root], @fallbacks[:"es-MX"]
54 end
55
56 test "returns [:es-Latn-ES, :es-Latn, :es, :en-US, :root] for :es-Latn-ES" do
57 assert_equal [:"es-Latn-ES", :"es-Latn", :es, :"en-US", :en, :root], @fallbacks[:'es-Latn-ES']
58 end
59
60 test "returns [:en, :en-US, :root] for :en" do
61 assert_equal [:en, :"en-US", :root], @fallbacks[:en]
62 end
63
64 test "returns [:en-US, :en, :root] for :en-US (special case: locale == default)" do
65 assert_equal [:"en-US", :en, :root], @fallbacks[:"en-US"]
66 end
67end
68
69class CaMappingFallbacksTest < ActiveSupport::TestCase
70 # Most people who speak Catalan also live in Spain, so test is safe to assume
71 # that they also speak Spanish as spoken in Spain.
72 def setup
73 @fallbacks = Fallbacks.new(:'en-US')
74 @fallbacks.map :ca => :"es-ES"
75 end
76
77 test "returns [:ca, :es-ES, :es, :en-US, :root] for :ca" do
78 assert_equal [:ca, :"es-ES", :es, :"en-US", :en, :root], @fallbacks[:ca]
79 end
80
81 test "returns [:ca-ES, :ca, :es-ES, :es, :en-US, :root] for :ca-ES" do
82 assert_equal [:"ca-ES", :ca, :"es-ES", :es, :"en-US", :en, :root], @fallbacks[:"ca-ES"]
83 end
84end
85
86class ArMappingFallbacksTest < ActiveSupport::TestCase
87 # People who speak Arabic as spoken in Palestine often times also speak
88 # Hebrew as spoken in Israel. However test is in no way safe to assume that
89 # everybody who speaks Arabic also speaks Hebrew.
90 def setup
91 @fallbacks = Fallbacks.new(:'en-US')
92 @fallbacks.map :"ar-PS" => :"he-IL"
93 end
94
95 test "returns [:ar, :en-US, :root] for :ar" do
96 assert_equal [:ar, :"en-US", :en, :root], @fallbacks[:ar]
97 end
98
99 test "returns [:ar-EG, :ar, :en-US, :root] for :ar-EG" do
100 assert_equal [:"ar-EG", :ar, :"en-US", :en, :root], @fallbacks[:"ar-EG"]
101 end
102
103 test "returns [:ar-PS, :ar, :he-IL, :he, :en-US, :root] for :ar-PS" do
104 assert_equal [:"ar-PS", :ar, :"he-IL", :he, :"en-US", :en, :root], @fallbacks[:"ar-PS"]
105 end
106end
107
108class SmsMappingFallbacksTest < ActiveSupport::TestCase
109 # Sami people live in several scandinavian countries. In Finnland many people
110 # know Swedish and Finnish. Thus, test can be assumed that Sami living in
111 # Finnland also speak Swedish and Finnish.
112 def setup
113 @fallbacks = Fallbacks.new(:'en-US')
114 @fallbacks.map :sms => [:"se-FI", :"fi-FI"]
115 end
116
117 test "returns [:sms-FI, :sms, :se-FI, :se, :fi-FI, :fi, :en-US, :root] for :sms-FI" do
118 assert_equal [:"sms-FI", :sms, :"se-FI", :se, :"fi-FI", :fi, :"en-US", :en, :root], @fallbacks[:"sms-FI"]
119 end
120end
121
122class DeAtMappingFallbacksTest < ActiveSupport::TestCase
123 def setup
124 @fallbacks = Fallbacks.new(:'en-US')
125 @fallbacks.map :"de-AT" => :"de-DE"
126 end
127
128 test "returns [:de, :en-US, :root] for de" do
129 assert_equal [:de, :"en-US", :en, :root], @fallbacks[:"de"]
130 end
131
132 test "returns [:de-DE, :de, :en-US, :root] for de-DE" do
133 assert_equal [:"de-DE", :de, :"en-US", :en, :root], @fallbacks[:"de-DE"]
134 end
135
136 test "returns [:de-AT, :de, :de-DE, :en-US, :root] for de-AT" do
137 assert_equal [:"de-AT", :de, :"de-DE", :"en-US", :en, :root], @fallbacks[:"de-AT"]
138 end
139end
140
141class DeMappingFallbacksTest < ActiveSupport::TestCase
142 def setup
143 @fallbacks = Fallbacks.new(:'en-US')
144 @fallbacks.map :de => :en, :he => :en
145 end
146
147 test "returns [:de, :en, :root] for :de" do
148 assert_equal [:de, :en, :"en-US", :root], @fallbacks[:de]
149 end
150
151 test "returns [:he, :en, :root] for :de" do
152 assert_equal [:he, :en, :"en-US", :root], @fallbacks[:he]
153 end
154end