twitter_cldr 3.0.1 → 3.0.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (94) hide show
  1. checksums.yaml +4 -4
  2. data/Gemfile +4 -2
  3. data/History.txt +4 -0
  4. data/README.md +17 -6
  5. data/lib/twitter_cldr/resources/postal_codes_importer.rb +12 -1
  6. data/lib/twitter_cldr/resources/regexp_ast_generator.rb +41 -0
  7. data/lib/twitter_cldr/resources.rb +1 -0
  8. data/lib/twitter_cldr/shared/postal_code_generator.rb +50 -0
  9. data/lib/twitter_cldr/shared/postal_codes.rb +48 -9
  10. data/lib/twitter_cldr/shared.rb +15 -14
  11. data/lib/twitter_cldr/utils/regexp_ast.rb +115 -0
  12. data/lib/twitter_cldr/utils/regexp_sampler.rb +149 -0
  13. data/lib/twitter_cldr/utils.rb +5 -3
  14. data/lib/twitter_cldr/version.rb +1 -1
  15. data/resources/shared/postal_codes.yml +1442 -159
  16. data/spec/bidi/bidi_spec.rb +1 -1
  17. data/spec/collation/collation_spec.rb +1 -1
  18. data/spec/collation/collator_spec.rb +31 -31
  19. data/spec/collation/implicit_collation_elements_spec.rb +6 -6
  20. data/spec/collation/sort_key_builder_spec.rb +28 -26
  21. data/spec/collation/tailoring_spec.rb +1 -1
  22. data/spec/collation/trie_builder_spec.rb +16 -16
  23. data/spec/collation/trie_dumps_spec.rb +2 -2
  24. data/spec/collation/trie_loader_spec.rb +8 -8
  25. data/spec/collation/trie_spec.rb +61 -61
  26. data/spec/collation/trie_with_fallback_spec.rb +5 -5
  27. data/spec/core_ext_spec.rb +1 -1
  28. data/spec/data_readers/additional_date_format_selector_spec.rb +38 -38
  29. data/spec/data_readers/date_time_data_reader_spec.rb +2 -2
  30. data/spec/data_readers/number_data_reader_spec.rb +1 -1
  31. data/spec/formatters/calendars/datetime_formatter_spec.rb +218 -218
  32. data/spec/formatters/list_formatter_spec.rb +8 -8
  33. data/spec/formatters/numbers/abbreviated/abbreviated_number_formatter_spec.rb +14 -14
  34. data/spec/formatters/numbers/abbreviated/long_decimal_formatter_spec.rb +4 -4
  35. data/spec/formatters/numbers/abbreviated/short_decimal_formatter_spec.rb +4 -4
  36. data/spec/formatters/numbers/currency_formatter_spec.rb +11 -11
  37. data/spec/formatters/numbers/decimal_formatter_spec.rb +3 -3
  38. data/spec/formatters/numbers/helpers/fraction_spec.rb +3 -3
  39. data/spec/formatters/numbers/helpers/integer_spec.rb +16 -16
  40. data/spec/formatters/numbers/number_formatter_spec.rb +21 -21
  41. data/spec/formatters/numbers/percent_formatter_spec.rb +3 -3
  42. data/spec/formatters/numbers/rbnf/rbnf_spec.rb +2 -2
  43. data/spec/formatters/plurals/plural_formatter_spec.rb +41 -41
  44. data/spec/formatters/plurals/rules_spec.rb +13 -13
  45. data/spec/localized/localized_array_spec.rb +12 -12
  46. data/spec/localized/localized_date_spec.rb +33 -33
  47. data/spec/localized/localized_datetime_spec.rb +11 -11
  48. data/spec/localized/localized_hash_spec.rb +4 -4
  49. data/spec/localized/localized_number_spec.rb +36 -36
  50. data/spec/localized/localized_object_spec.rb +8 -8
  51. data/spec/localized/localized_string_spec.rb +53 -53
  52. data/spec/localized/localized_symbol_spec.rb +9 -9
  53. data/spec/localized/localized_time_spec.rb +10 -10
  54. data/spec/localized/localized_timespan_spec.rb +8 -8
  55. data/spec/normalization_spec.rb +6 -6
  56. data/spec/parsers/number_parser_spec.rb +36 -36
  57. data/spec/parsers/parser_spec.rb +5 -5
  58. data/spec/parsers/segmentation_parser_spec.rb +19 -19
  59. data/spec/parsers/symbol_table_spec.rb +4 -4
  60. data/spec/parsers/unicode_regex/character_class_spec.rb +19 -19
  61. data/spec/parsers/unicode_regex/character_range_spec.rb +1 -1
  62. data/spec/parsers/unicode_regex/character_set_spec.rb +8 -8
  63. data/spec/parsers/unicode_regex/literal_spec.rb +5 -5
  64. data/spec/parsers/unicode_regex/unicode_string_spec.rb +2 -2
  65. data/spec/parsers/unicode_regex_parser_spec.rb +28 -28
  66. data/spec/resources/loader_spec.rb +32 -32
  67. data/spec/shared/break_iterator_spec.rb +13 -13
  68. data/spec/shared/calendar_spec.rb +59 -59
  69. data/spec/shared/casefolder_spec.rb +5 -5
  70. data/spec/shared/code_point_spec.rb +46 -46
  71. data/spec/shared/currencies_spec.rb +7 -7
  72. data/spec/shared/language_codes_spec.rb +34 -34
  73. data/spec/shared/languages_spec.rb +30 -30
  74. data/spec/shared/numbering_system_spec.rb +7 -7
  75. data/spec/shared/numbers_spec.rb +4 -4
  76. data/spec/shared/phone_codes_spec.rb +7 -7
  77. data/spec/shared/postal_code_generator_spec.rb +76 -0
  78. data/spec/shared/postal_codes_spec.rb +35 -29
  79. data/spec/shared/territories_spec.rb +40 -40
  80. data/spec/shared/unicode_regex_spec.rb +71 -71
  81. data/spec/spec_helper.rb +2 -2
  82. data/spec/tokenizers/calendars/date_tokenizer_spec.rb +1 -1
  83. data/spec/tokenizers/calendars/timespan_tokenizer_spec.rb +6 -6
  84. data/spec/tokenizers/composite_token_spec.rb +3 -3
  85. data/spec/tokenizers/token_spec.rb +3 -3
  86. data/spec/twitter_cldr_spec.rb +72 -72
  87. data/spec/utils/code_points_spec.rb +10 -10
  88. data/spec/utils/interpolation_spec.rb +32 -32
  89. data/spec/utils/range_set_spec.rb +36 -36
  90. data/spec/utils/regexp_ast_spec.rb +44 -0
  91. data/spec/utils/regexp_sampler_spec.rb +182 -0
  92. data/spec/utils/yaml/yaml_spec.rb +23 -23
  93. data/spec/utils_spec.rb +19 -19
  94. metadata +263 -258
@@ -67,6 +67,6 @@ describe Bidi do
67
67
  end
68
68
  end
69
69
 
70
- num_failed.should == 0
70
+ expect(num_failed).to eq(0)
71
71
  end
72
72
  end
@@ -41,7 +41,7 @@ describe 'Unicode Collation Algorithm' do
41
41
 
42
42
  if previous_sort_key
43
43
  result = (previous_sort_key <=> current_sort_key).nonzero? || (previous_code_points <=> current_code_points)
44
- result.should(eq(-1), error_message(previous_str_code_points, previous_sort_key, current_str_code_points, current_sort_key))
44
+ expect(result).to(eq(-1), error_message(previous_str_code_points, previous_sort_key, current_str_code_points, current_sort_key))
45
45
  end
46
46
 
47
47
  previous_sort_key = current_sort_key
@@ -21,15 +21,15 @@ describe Collator do
21
21
  end
22
22
 
23
23
  it 'returns default fractional collation elements trie' do
24
- Collator.default_trie.should == trie
24
+ expect(Collator.default_trie).to eq(trie)
25
25
  end
26
26
 
27
27
  it 'loads the trie only once' do
28
- Collator.default_trie.object_id.should == Collator.default_trie.object_id
28
+ expect(Collator.default_trie.object_id).to eq(Collator.default_trie.object_id)
29
29
  end
30
30
 
31
31
  it 'locks the trie' do
32
- Collator.default_trie.should be_locked
32
+ expect(Collator.default_trie).to be_locked
33
33
  end
34
34
  end
35
35
 
@@ -43,15 +43,15 @@ describe Collator do
43
43
  end
44
44
 
45
45
  it 'returns default fractional collation elements trie' do
46
- Collator.tailored_trie(locale).should == trie
46
+ expect(Collator.tailored_trie(locale)).to eq(trie)
47
47
  end
48
48
 
49
49
  it 'loads the trie only once' do
50
- Collator.tailored_trie(locale).object_id.should == Collator.tailored_trie(locale).object_id
50
+ expect(Collator.tailored_trie(locale).object_id).to eq(Collator.tailored_trie(locale).object_id)
51
51
  end
52
52
 
53
53
  it 'locks the trie' do
54
- Collator.tailored_trie(locale).should be_locked
54
+ expect(Collator.tailored_trie(locale)).to be_locked
55
55
  end
56
56
  end
57
57
 
@@ -62,17 +62,17 @@ describe Collator do
62
62
 
63
63
  context 'without locale' do
64
64
  it 'initializes default collator' do
65
- Collator.new.locale.should be_nil
65
+ expect(Collator.new.locale).to be_nil
66
66
  end
67
67
  end
68
68
 
69
69
  context 'with locale' do
70
70
  it 'initialized tailored collator with provided locale' do
71
- Collator.new(:ru).locale.should == :ru
71
+ expect(Collator.new(:ru).locale).to eq(:ru)
72
72
  end
73
73
 
74
74
  it 'converts locale' do
75
- Collator.new(:no).locale.should == :nb
75
+ expect(Collator.new(:no).locale).to eq(:nb)
76
76
  end
77
77
  end
78
78
  end
@@ -90,11 +90,11 @@ describe Collator do
90
90
  end
91
91
 
92
92
  it 'returns collation elements for a string' do
93
- collator.get_collation_elements(string).should == collation_elements
93
+ expect(collator.get_collation_elements(string)).to eq(collation_elements)
94
94
  end
95
95
 
96
96
  it 'returns collation elements for an array of code points (represented as hex strings)' do
97
- collator.get_collation_elements(code_points).should == collation_elements
97
+ expect(collator.get_collation_elements(code_points)).to eq(collation_elements)
98
98
  end
99
99
  end
100
100
 
@@ -112,12 +112,12 @@ describe Collator do
112
112
 
113
113
  it 'calculates sort key for a string' do
114
114
  mock(collator).get_collation_elements(string) { collation_elements }
115
- collator.get_sort_key(string).should == sort_key
115
+ expect(collator.get_sort_key(string)).to eq(sort_key)
116
116
  end
117
117
 
118
118
  it 'calculates sort key for an array of code points (represented as hex strings)' do
119
119
  mock(collator).get_collation_elements(code_points) { collation_elements }
120
- collator.get_sort_key(code_points).should == sort_key
120
+ expect(collator.get_sort_key(code_points)).to eq(sort_key)
121
121
  end
122
122
  end
123
123
 
@@ -135,7 +135,7 @@ describe Collator do
135
135
  mock(collator).get_collation_elements(code_points) { collation_elements }
136
136
  mock(TwitterCldr::Collation::SortKeyBuilder).build(collation_elements, :case_first => case_first, :maximum_level => nil) { sort_key }
137
137
 
138
- collator.get_sort_key(code_points).should == sort_key
138
+ expect(collator.get_sort_key(code_points)).to eq(sort_key)
139
139
  end
140
140
 
141
141
  it 'passes maximum_level option to sort key builder' do
@@ -147,7 +147,7 @@ describe Collator do
147
147
  mock(collator).get_collation_elements(code_points) { collation_elements }
148
148
  mock(TwitterCldr::Collation::SortKeyBuilder).build(collation_elements, :case_first => case_first, :maximum_level => maximum_level) { sort_key }
149
149
 
150
- collator.get_sort_key(code_points, :maximum_level => maximum_level).should == sort_key
150
+ expect(collator.get_sort_key(code_points, :maximum_level => maximum_level)).to eq(sort_key)
151
151
  end
152
152
 
153
153
  end
@@ -164,14 +164,14 @@ describe Collator do
164
164
  stub_sort_key(collator, 'foo', sort_key)
165
165
  stub_sort_key(collator, 'bar', another_sort_key)
166
166
 
167
- collator.compare('foo', 'bar').should == -1
168
- collator.compare('bar', 'foo').should == 1
167
+ expect(collator.compare('foo', 'bar')).to eq(-1)
168
+ expect(collator.compare('bar', 'foo')).to eq(1)
169
169
  end
170
170
 
171
171
  it 'returns 0 without computing sort keys if the strings are equal' do
172
172
  dont_allow(collator).get_sort_key
173
173
 
174
- collator.compare('foo', 'foo').should == 0
174
+ expect(collator.compare('foo', 'foo')).to eq(0)
175
175
  end
176
176
  end
177
177
 
@@ -188,18 +188,18 @@ describe Collator do
188
188
 
189
189
  describe '#sort' do
190
190
  it 'sorts strings by sort keys' do
191
- collator.sort(array).should == sorted
191
+ expect(collator.sort(array)).to eq(sorted)
192
192
  end
193
193
 
194
194
  it 'does not change the original array' do
195
- lambda { collator.sort(array) }.should_not change { array }
195
+ expect { collator.sort(array) }.not_to change { array }
196
196
  end
197
197
  end
198
198
 
199
199
  describe '#sort!' do
200
200
  it 'sorts strings array by sort keys in-place ' do
201
201
  collator.sort!(array)
202
- array.should == sorted
202
+ expect(array).to eq(sorted)
203
203
  end
204
204
  end
205
205
  end
@@ -224,28 +224,28 @@ describe Collator do
224
224
 
225
225
  describe 'tailoring rules support' do
226
226
  it 'tailored collation elements are used' do
227
- default_collator.get_collation_elements([0x490]).should == [[0x5C1A, 5, 0x93], [0, 0xDBB9, 9]]
228
- tailored_collator.get_collation_elements([0x490]).should == [[0x5C1B, 5, 0x86]]
227
+ expect(default_collator.get_collation_elements([0x490])).to eq([[0x5C1A, 5, 0x93], [0, 0xDBB9, 9]])
228
+ expect(tailored_collator.get_collation_elements([0x490])).to eq([[0x5C1B, 5, 0x86]])
229
229
 
230
- default_collator.get_collation_elements([0x491]).should == [[0x5C1A, 5, 9], [0, 0xDBB9, 9]]
231
- tailored_collator.get_collation_elements([0x491]).should == [[0x5C1B, 5, 5]]
230
+ expect(default_collator.get_collation_elements([0x491])).to eq([[0x5C1A, 5, 9], [0, 0xDBB9, 9]])
231
+ expect(tailored_collator.get_collation_elements([0x491])).to eq([[0x5C1B, 5, 5]])
232
232
  end
233
233
 
234
234
  it 'original contractions for tailored elements are applied' do
235
- default_collator.get_collation_elements([0x491, 0x306]).should == [[0x5C, 0xDB, 9]]
236
- tailored_collator.get_collation_elements([0x491, 0x306]).should == [[0x5C, 0xDB, 9]]
235
+ expect(default_collator.get_collation_elements([0x491, 0x306])).to eq([[0x5C, 0xDB, 9]])
236
+ expect(tailored_collator.get_collation_elements([0x491, 0x306])).to eq([[0x5C, 0xDB, 9]])
237
237
  end
238
238
  end
239
239
 
240
240
  describe 'contractions suppressing support' do
241
241
  it 'suppressed contractions are ignored' do
242
- default_collator.get_collation_elements([0x41A, 0x301]).should == [[0x5CCC, 5, 0x8F]]
243
- tailored_collator.get_collation_elements([0x41A, 0x301]).should == [[0x5C6C, 5, 0x8F], [0, 0x8D, 5]]
242
+ expect(default_collator.get_collation_elements([0x41A, 0x301])).to eq([[0x5CCC, 5, 0x8F]])
243
+ expect(tailored_collator.get_collation_elements([0x41A, 0x301])).to eq([[0x5C6C, 5, 0x8F], [0, 0x8D, 5]])
244
244
  end
245
245
 
246
246
  it 'non-suppressed contractions are used' do
247
- default_collator.get_collation_elements([0x415, 0x306]).should == [[0x5C36, 5, 0x8F]]
248
- tailored_collator.get_collation_elements([0x415, 0x306]).should == [[0x5C36, 5, 0x8F]]
247
+ expect(default_collator.get_collation_elements([0x415, 0x306])).to eq([[0x5C36, 5, 0x8F]])
248
+ expect(tailored_collator.get_collation_elements([0x415, 0x306])).to eq([[0x5C36, 5, 0x8F]])
249
249
  end
250
250
  end
251
251
 
@@ -10,15 +10,15 @@ include TwitterCldr::Collation
10
10
  describe ImplicitCollationElements do
11
11
 
12
12
  it 'computes correct implicit value for non-CJK code points' do
13
- ImplicitCollationElements.for_code_point(0xD801).should == [[0xE305C758, 0x5, 0x5]]
14
- ImplicitCollationElements.for_code_point(0xC0001).should == [[0xE44E70AC, 0x5, 0x5]]
15
- ImplicitCollationElements.for_code_point(0xFFF02).should == [[0xE4C25F74, 0x5, 0x5]]
13
+ expect(ImplicitCollationElements.for_code_point(0xD801)).to eq([[0xE305C758, 0x5, 0x5]])
14
+ expect(ImplicitCollationElements.for_code_point(0xC0001)).to eq([[0xE44E70AC, 0x5, 0x5]])
15
+ expect(ImplicitCollationElements.for_code_point(0xFFF02)).to eq([[0xE4C25F74, 0x5, 0x5]])
16
16
  end
17
17
 
18
18
  it 'computes correct implicit values for CJK code points' do
19
- ImplicitCollationElements.for_code_point(0x4E00).should == [[0xE00406, 0x5, 0x5]]
20
- ImplicitCollationElements.for_code_point(0x3400).should == [[0xE0ABCE, 0x5, 0x5]]
21
- ImplicitCollationElements.for_code_point(0x20000).should == [[0xE1302590, 0x5, 0x5]]
19
+ expect(ImplicitCollationElements.for_code_point(0x4E00)).to eq([[0xE00406, 0x5, 0x5]])
20
+ expect(ImplicitCollationElements.for_code_point(0x3400)).to eq([[0xE0ABCE, 0x5, 0x5]])
21
+ expect(ImplicitCollationElements.for_code_point(0x20000)).to eq([[0xE1302590, 0x5, 0x5]])
22
22
  end
23
23
 
24
24
  end
@@ -20,37 +20,37 @@ describe SortKeyBuilder do
20
20
  mock(SortKeyBuilder).new(collation_elements, nil) { sort_key }
21
21
  mock(sort_key).bytes_array { sort_key_bytes }
22
22
 
23
- SortKeyBuilder.build(collation_elements).should == sort_key_bytes
23
+ expect(SortKeyBuilder.build(collation_elements)).to eq(sort_key_bytes)
24
24
  end
25
25
  end
26
26
 
27
27
  describe '#initialize' do
28
28
  it 'assigns collation elements array' do
29
- SortKeyBuilder.new(collation_elements).collation_elements.should == collation_elements
29
+ expect(SortKeyBuilder.new(collation_elements).collation_elements).to eq(collation_elements)
30
30
  end
31
31
 
32
32
  it 'accepts case-first option as an option' do
33
33
  SortKeyBuilder::VALID_CASE_FIRST_OPTIONS.each do |case_first|
34
- lambda { SortKeyBuilder.new([], :case_first => case_first) }.should_not raise_error
34
+ expect { SortKeyBuilder.new([], :case_first => case_first) }.not_to raise_error
35
35
  end
36
36
  end
37
37
 
38
38
  it 'raises an ArgumentError for invalid case-first option' do
39
- lambda { SortKeyBuilder.new([], :case_first => :wat) }.should raise_error(ArgumentError)
39
+ expect { SortKeyBuilder.new([], :case_first => :wat) }.to raise_error(ArgumentError)
40
40
  end
41
41
 
42
42
  it 'raises an ArgumentError for an invalid maximum_level option' do
43
- lambda { SortKeyBuilder.new([], :maximum_level => :wat) }.should raise_error(ArgumentError)
43
+ expect { SortKeyBuilder.new([], :maximum_level => :wat) }.to raise_error(ArgumentError)
44
44
  end
45
45
 
46
46
  it 'raises an ArgumentError for non-hash second argument' do
47
- lambda { SortKeyBuilder.new([], :upper) }.should raise_error(ArgumentError)
47
+ expect { SortKeyBuilder.new([], :upper) }.to raise_error(ArgumentError)
48
48
  end
49
49
  end
50
50
 
51
51
  describe '#bytes_array' do
52
52
  it 'builds sort key bytes' do
53
- sort_key.bytes_array.should == sort_key_bytes
53
+ expect(sort_key.bytes_array).to eq(sort_key_bytes)
54
54
  end
55
55
 
56
56
  it 'builds bytes array only once' do
@@ -60,80 +60,82 @@ describe SortKeyBuilder do
60
60
 
61
61
  describe 'primary weights' do
62
62
  it 'compresses primary weights' do
63
- SortKeyBuilder.new([[0x7A72, 0, 0], [0x7A73, 0, 0], [0x7A75, 0, 0], [0x908, 0, 0], [0x7A73, 0, 0]]).bytes_array.should ==
63
+ expect(SortKeyBuilder.new([[0x7A72, 0, 0], [0x7A73, 0, 0], [0x7A75, 0, 0], [0x908, 0, 0], [0x7A73, 0, 0]]).bytes_array).to eq(
64
64
  [0x7A, 0x72, 0x73, 0x75, 0x3, 0x9, 0x08, 0x7A, 0x73, 1, 1]
65
+ )
65
66
 
66
- SortKeyBuilder.new([[0x7A72, 0, 0], [0x7A73, 0, 0], [0x7A75, 0, 0], [0x9508, 0, 0], [0x7A73, 0, 0]]).bytes_array.should ==
67
+ expect(SortKeyBuilder.new([[0x7A72, 0, 0], [0x7A73, 0, 0], [0x7A75, 0, 0], [0x9508, 0, 0], [0x7A73, 0, 0]]).bytes_array).to eq(
67
68
  [0x7A, 0x72, 0x73, 0x75, 0xFF, 0x95, 0x08, 0x7A, 0x73, 1, 1]
69
+ )
68
70
  end
69
71
 
70
72
  it 'works when there is an ignorable primary weight in the middle' do
71
- SortKeyBuilder.new([[0x1312, 0, 0], [0, 0, 0], [0x1415, 0, 0]]).bytes_array.should == [0x13, 0x12, 0x14, 0x15, 1, 1]
73
+ expect(SortKeyBuilder.new([[0x1312, 0, 0], [0, 0, 0], [0x1415, 0, 0]]).bytes_array).to eq([0x13, 0x12, 0x14, 0x15, 1, 1])
72
74
  end
73
75
 
74
76
  it 'do not compress single byte primary weights' do
75
- SortKeyBuilder.new([[0x13, 0, 0], [0x13, 0, 0]]).bytes_array.should == [0x13, 0x13, 1, 1]
77
+ expect(SortKeyBuilder.new([[0x13, 0, 0], [0x13, 0, 0]]).bytes_array).to eq([0x13, 0x13, 1, 1])
76
78
  end
77
79
 
78
80
  it 'resets primary lead bytes counter after a single byte weight' do
79
- SortKeyBuilder.new([[0x1415, 0, 0], [0x13, 0, 0], [0x13, 0, 0], [0x1412, 0, 0]]).bytes_array.should == [0x14, 0x15, 0x13, 0x13, 0x14, 0x12, 1, 1]
81
+ expect(SortKeyBuilder.new([[0x1415, 0, 0], [0x13, 0, 0], [0x13, 0, 0], [0x1412, 0, 0]]).bytes_array).to eq([0x14, 0x15, 0x13, 0x13, 0x14, 0x12, 1, 1])
80
82
  end
81
83
 
82
84
  it 'compresses only compressible primary weights' do
83
- SortKeyBuilder.new([[0x812, 0, 0], [0x811, 0, 0]]).bytes_array.should == [0x8, 0x12, 0x8, 0x11, 1, 1]
85
+ expect(SortKeyBuilder.new([[0x812, 0, 0], [0x811, 0, 0]]).bytes_array).to eq([0x8, 0x12, 0x8, 0x11, 1, 1])
84
86
  end
85
87
  end
86
88
 
87
89
  describe 'secondary weights' do
88
90
  it 'compresses secondary weights' do
89
- SortKeyBuilder.new([[0, 5, 0], [0, 5, 0], [0, 141, 0], [0, 5, 0], [0, 5, 0]]).bytes_array.should == [1, 133, 141, 6, 1]
91
+ expect(SortKeyBuilder.new([[0, 5, 0], [0, 5, 0], [0, 141, 0], [0, 5, 0], [0, 5, 0]]).bytes_array).to eq([1, 133, 141, 6, 1])
90
92
  end
91
93
 
92
94
  it 'compresses secondary weights into multiple bytes if necessary' do
93
- SortKeyBuilder.new([[0, 5, 0]] * 100).bytes_array.should == [1, 69, 40, 1]
95
+ expect(SortKeyBuilder.new([[0, 5, 0]] * 100).bytes_array).to eq([1, 69, 40, 1])
94
96
  end
95
97
  end
96
98
 
97
99
  describe 'tertiary weights' do
98
100
  context 'when case_first is not set' do
99
101
  it 'removes case bits and adds top addition to bytes that are greater than common' do
100
- SortKeyBuilder.new([[0, 0, 9], [0, 0, 73], [0, 0, 137], [0, 0, 201]]).bytes_array.should == [1, 1, 137, 137, 137, 137]
102
+ expect(SortKeyBuilder.new([[0, 0, 9], [0, 0, 73], [0, 0, 137], [0, 0, 201]]).bytes_array).to eq([1, 1, 137, 137, 137, 137])
101
103
  end
102
104
 
103
105
  it 'compresses tertiary weights' do
104
- SortKeyBuilder.new([[0, 0, 5], [0, 0, 5], [0, 0, 39], [0, 0, 5], [0, 0, 5]]).bytes_array.should == [1, 1, 0x84, 0xA7, 6]
106
+ expect(SortKeyBuilder.new([[0, 0, 5], [0, 0, 5], [0, 0, 39], [0, 0, 5], [0, 0, 5]]).bytes_array).to eq([1, 1, 0x84, 0xA7, 6])
105
107
  end
106
108
 
107
109
  it 'compresses tertiary weights into multiple bytes if necessary' do
108
- SortKeyBuilder.new([[0, 0, 5]] * 100).bytes_array.should == [1, 1, 0x30, 0x30, 0x12]
110
+ expect(SortKeyBuilder.new([[0, 0, 5]] * 100).bytes_array).to eq([1, 1, 0x30, 0x30, 0x12])
109
111
  end
110
112
  end
111
113
 
112
114
  context 'when case_first is :upper' do
113
115
  it 'inverts case bits and subtract bottom addition from bytes that are smaller than common' do
114
- SortKeyBuilder.new([[0, 0, 9], [0, 0, 80], [0, 0, 143]], :case_first => :upper).bytes_array.should == [1, 1, 201, 80, 15]
116
+ expect(SortKeyBuilder.new([[0, 0, 9], [0, 0, 80], [0, 0, 143]], :case_first => :upper).bytes_array).to eq([1, 1, 201, 80, 15])
115
117
  end
116
118
 
117
119
  it 'compresses tertiary weights' do
118
- SortKeyBuilder.new([[0, 0, 5], [0, 0, 5], [0, 0, 39], [0, 0, 5], [0, 0, 5]], :case_first => :upper).bytes_array.should == [1, 1, 0xC4, 0xE7, 0xC3]
120
+ expect(SortKeyBuilder.new([[0, 0, 5], [0, 0, 5], [0, 0, 39], [0, 0, 5], [0, 0, 5]], :case_first => :upper).bytes_array).to eq([1, 1, 0xC4, 0xE7, 0xC3])
119
121
  end
120
122
 
121
123
  it 'compresses tertiary weights into multiple bytes if necessary' do
122
- SortKeyBuilder.new([[0, 0, 5]] * 100, :case_first => :upper).bytes_array.should == [1, 1, 0x9C, 0x9C, 0xB3]
124
+ expect(SortKeyBuilder.new([[0, 0, 5]] * 100, :case_first => :upper).bytes_array).to eq([1, 1, 0x9C, 0x9C, 0xB3])
123
125
  end
124
126
  end
125
127
 
126
128
  context 'when case_first is :lower' do
127
129
  it 'leaves case bits and adds top addition to bytes that are greater than common' do
128
- SortKeyBuilder.new([[0, 0, 9], [0, 0, 80], [0, 0, 143]], :case_first => :lower).bytes_array.should == [1, 1, 73, 144, 207]
130
+ expect(SortKeyBuilder.new([[0, 0, 9], [0, 0, 80], [0, 0, 143]], :case_first => :lower).bytes_array).to eq([1, 1, 73, 144, 207])
129
131
  end
130
132
 
131
133
  it 'compresses tertiary weights' do
132
- SortKeyBuilder.new([[0, 0, 5], [0, 0, 5], [0, 0, 39], [0, 0, 5], [0, 0, 5]], :case_first => :lower).bytes_array.should == [1, 1, 0x44, 0x67, 6]
134
+ expect(SortKeyBuilder.new([[0, 0, 5], [0, 0, 5], [0, 0, 39], [0, 0, 5], [0, 0, 5]], :case_first => :lower).bytes_array).to eq([1, 1, 0x44, 0x67, 6])
133
135
  end
134
136
 
135
137
  it 'compresses tertiary weights into multiple bytes if necessary' do
136
- SortKeyBuilder.new([[0, 0, 5]] * 100, :case_first => :lower).bytes_array.should == [1, 1, 0x1A, 0x1A, 0x1A, 0x1A, 0x14]
138
+ expect(SortKeyBuilder.new([[0, 0, 5]] * 100, :case_first => :lower).bytes_array).to eq([1, 1, 0x1A, 0x1A, 0x1A, 0x1A, 0x14])
137
139
  end
138
140
  end
139
141
  end
@@ -141,12 +143,12 @@ describe SortKeyBuilder do
141
143
  describe ":maximum_level option" do
142
144
  context "when :maximum_level is 2" do
143
145
  it 'does not include tertiary weights' do
144
- SortKeyBuilder.new([[63, 13, 149], [66, 81, 143]], :maximum_level => 2).bytes_array.should == [63, 66, 1, 13, 81]
146
+ expect(SortKeyBuilder.new([[63, 13, 149], [66, 81, 143]], :maximum_level => 2).bytes_array).to eq([63, 66, 1, 13, 81])
145
147
  end
146
148
  end
147
149
  context "when :maximum_level is 1" do
148
150
  it 'only includes primary weights' do
149
- SortKeyBuilder.new([[63, 13, 149], [66, 81, 143]], :maximum_level => 1).bytes_array.should == [63, 66]
151
+ expect(SortKeyBuilder.new([[63, 13, 149], [66, 81, 143]], :maximum_level => 1).bytes_array).to eq([63, 66])
150
152
  end
151
153
  end
152
154
  end
@@ -49,7 +49,7 @@ describe 'Unicode collation tailoring' do
49
49
  else
50
50
  failures_info = "#{failures.size} failures: #{failures.inspect}"
51
51
  puts failures_info
52
- failures.should(be_empty, "#{locale} - #{failures_info}")
52
+ expect(failures).to(be_empty, "#{locale} - #{failures_info}")
53
53
  end
54
54
  end
55
55
  end
@@ -15,12 +15,12 @@ describe TrieBuilder do
15
15
  before(:each) { mock_default_table }
16
16
 
17
17
  it 'returns a Trie' do
18
- trie.should be_instance_of(Trie)
18
+ expect(trie).to be_instance_of(Trie)
19
19
  end
20
20
 
21
21
  it 'adds every collation element from the fractional collation elements table to the trie' do
22
22
  collation_elements_table.each do |code_points, collation_elements|
23
- trie.get(code_points).should == collation_elements
23
+ expect(trie.get(code_points)).to eq(collation_elements)
24
24
  end
25
25
  end
26
26
 
@@ -124,34 +124,34 @@ END
124
124
  end
125
125
 
126
126
  it 'returns a TrieWithFallback' do
127
- tailored_trie.should be_instance_of(TrieWithFallback)
127
+ expect(tailored_trie).to be_instance_of(TrieWithFallback)
128
128
  end
129
129
 
130
130
  it 'tailors elements in the trie' do
131
- fallback.get([0x0491]).should == [[0x5C1A, 5, 9], [0, 0xDBB9, 9]]
132
- fallback.get([0x0490]).should == [[0x5C1A, 5, 0x93], [0, 0xDBB9, 9]]
131
+ expect(fallback.get([0x0491])).to eq([[0x5C1A, 5, 9], [0, 0xDBB9, 9]])
132
+ expect(fallback.get([0x0490])).to eq([[0x5C1A, 5, 0x93], [0, 0xDBB9, 9]])
133
133
 
134
- tailored_trie.get([0x0491]).should == [[0x5C1B, 5, 5]]
135
- tailored_trie.get([0x0490]).should == [[0x5C1B, 5, 0x86]]
134
+ expect(tailored_trie.get([0x0491])).to eq([[0x5C1B, 5, 5]])
135
+ expect(tailored_trie.get([0x0490])).to eq([[0x5C1B, 5, 0x86]])
136
136
  end
137
137
 
138
138
  it 'makes contractions available in the tailored trie' do
139
- tailored_trie.get([0x491, 0x306]).should == [[0x5C, 0xDB, 9]]
140
- tailored_trie.get([0x415, 0x306]).should == [[0x5C36, 5, 0x8F]]
139
+ expect(tailored_trie.get([0x491, 0x306])).to eq([[0x5C, 0xDB, 9]])
140
+ expect(tailored_trie.get([0x415, 0x306])).to eq([[0x5C36, 5, 0x8F]])
141
141
  end
142
142
 
143
143
  it 'suppresses required contractions' do
144
- fallback.find_prefix([0x41A, 0x301]).first(2).should == [[[0x5CCC, 5, 0x8F]], 2]
145
- fallback.find_prefix([0x413, 0x301]).first(2).should == [[[0x5C30, 5, 0x8F]], 2]
144
+ expect(fallback.find_prefix([0x41A, 0x301]).first(2)).to eq([[[0x5CCC, 5, 0x8F]], 2])
145
+ expect(fallback.find_prefix([0x413, 0x301]).first(2)).to eq([[[0x5C30, 5, 0x8F]], 2])
146
146
 
147
- tailored_trie.find_prefix([0x41A, 0x301]).first(2).should == [[[0x5C6C, 5, 0x8F]], 1]
148
- tailored_trie.find_prefix([0x413, 0x301]).first(2).should == [[[0x5C1A, 5, 0x8F]], 1]
147
+ expect(tailored_trie.find_prefix([0x41A, 0x301]).first(2)).to eq([[[0x5C6C, 5, 0x8F]], 1])
148
+ expect(tailored_trie.find_prefix([0x413, 0x301]).first(2)).to eq([[[0x5C1A, 5, 0x8F]], 1])
149
149
  end
150
150
 
151
151
  it 'do not copy other collation elements from the fallback' do
152
152
  [0x301, 0x306, 0x41A, 0x413, 0x415].each_slice(1) do |code_points|
153
- tailored_trie.get(code_points).should_not be_nil
154
- tailored_trie.get(code_points).object_id.should == fallback.get(code_points).object_id
153
+ expect(tailored_trie.get(code_points)).not_to be_nil
154
+ expect(tailored_trie.get(code_points).object_id).to eq(fallback.get(code_points).object_id)
155
155
  end
156
156
  end
157
157
 
@@ -187,7 +187,7 @@ END
187
187
 
188
188
  it 'loads tailoring data' do
189
189
  mock(TwitterCldr).get_resource(:collation, :tailoring, locale) { tailoring_data }
190
- TrieBuilder.tailoring_data(locale).should == tailoring_data
190
+ expect(TrieBuilder.tailoring_data(locale)).to eq(tailoring_data)
191
191
  end
192
192
  end
193
193
 
@@ -12,7 +12,7 @@ describe 'trie dumps', :slow => true do
12
12
  let(:error_message) { 'expected trie dump to be up-to-date.' }
13
13
 
14
14
  it 'has a valid default Fractional Collation Elements trie dump' do
15
- TrieLoader.load_default_trie.to_hash.should(eq(default_trie.to_hash), error_message)
15
+ expect(TrieLoader.load_default_trie.to_hash).to(eq(default_trie.to_hash), error_message)
16
16
  end
17
17
 
18
18
  TwitterCldr.supported_locales.each do |locale|
@@ -20,7 +20,7 @@ describe 'trie dumps', :slow => true do
20
20
  loaded_trie = TrieLoader.load_tailored_trie(locale, Trie.new)
21
21
  fresh_trie = TrieBuilder.load_tailored_trie(locale, default_trie)
22
22
 
23
- loaded_trie.to_hash.should(eq(fresh_trie.to_hash), error_message)
23
+ expect(loaded_trie.to_hash).to(eq(fresh_trie.to_hash), error_message)
24
24
  end
25
25
  end
26
26
  end
@@ -19,15 +19,15 @@ describe TrieLoader do
19
19
  before(:each) { mock_trie_dump }
20
20
 
21
21
  it 'loads a Trie' do
22
- loaded_trie.should be_instance_of(Trie)
22
+ expect(loaded_trie).to be_instance_of(Trie)
23
23
  end
24
24
 
25
25
  it 'loads trie root' do
26
- loaded_trie.instance_variable_get(:@root).should == root
26
+ expect(loaded_trie.instance_variable_get(:@root)).to eq(root)
27
27
  end
28
28
 
29
29
  it 'loads trie as unlocked' do
30
- loaded_trie.should_not be_locked
30
+ expect(loaded_trie).not_to be_locked
31
31
  end
32
32
  end
33
33
 
@@ -43,25 +43,25 @@ describe TrieLoader do
43
43
  before(:each) { mock_trie_dump }
44
44
 
45
45
  it 'loads a TrieWithFallback' do
46
- loaded_trie.should be_instance_of(TrieWithFallback)
46
+ expect(loaded_trie).to be_instance_of(TrieWithFallback)
47
47
  end
48
48
 
49
49
  it 'loads trie root' do
50
- loaded_trie.instance_variable_get(:@root).should == root
50
+ expect(loaded_trie.instance_variable_get(:@root)).to eq(root)
51
51
  end
52
52
 
53
53
  it 'loads trie as unlocked' do
54
- loaded_trie.should_not be_locked
54
+ expect(loaded_trie).not_to be_locked
55
55
  end
56
56
 
57
57
  it 'sets trie fallback' do
58
- loaded_trie.fallback.should == new_fallback
58
+ expect(loaded_trie.fallback).to eq(new_fallback)
59
59
  end
60
60
  end
61
61
 
62
62
  describe '.dump_path' do
63
63
  it 'returns path to a trie dump for a specific locale' do
64
- TrieLoader.dump_path(:foo).should == File.join(TwitterCldr::RESOURCES_DIR, 'collation', 'tries', 'foo.dump')
64
+ expect(TrieLoader.dump_path(:foo)).to eq(File.join(TwitterCldr::RESOURCES_DIR, 'collation', 'tries', 'foo.dump'))
65
65
  end
66
66
  end
67
67