erlang-etf 1.1.1 → 2.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.editorconfig +20 -0
- data/.gitignore +10 -18
- data/.ruby-gemset +1 -0
- data/.ruby-version +1 -0
- data/.travis.yml +15 -4
- data/CHANGELOG.md +7 -0
- data/Gemfile +10 -6
- data/LICENSE.txt +1 -1
- data/README.md +13 -13
- data/Rakefile +8 -6
- data/erlang-etf.gemspec +10 -10
- data/lib/erlang-etf.rb +1 -0
- data/lib/erlang/etf.rb +363 -30
- data/lib/erlang/etf/atom.rb +28 -48
- data/lib/erlang/etf/atom_utf8.rb +28 -48
- data/lib/erlang/etf/binary.rb +24 -23
- data/lib/erlang/etf/bit_binary.rb +35 -27
- data/lib/erlang/etf/compressed.rb +61 -35
- data/lib/erlang/etf/export.rb +44 -21
- data/lib/erlang/etf/float.rb +33 -29
- data/lib/erlang/etf/fun.rb +54 -32
- data/lib/erlang/etf/integer.rb +24 -12
- data/lib/erlang/etf/large_big.rb +31 -37
- data/lib/erlang/etf/large_tuple.rb +41 -30
- data/lib/erlang/etf/list.rb +55 -25
- data/lib/erlang/etf/map.rb +58 -28
- data/lib/erlang/etf/new_float.rb +25 -14
- data/lib/erlang/etf/new_fun.rb +70 -47
- data/lib/erlang/etf/new_reference.rb +51 -24
- data/lib/erlang/etf/nil.rb +21 -6
- data/lib/erlang/etf/pid.rb +48 -21
- data/lib/erlang/etf/port.rb +49 -13
- data/lib/erlang/etf/reference.rb +49 -13
- data/lib/erlang/etf/small_atom.rb +31 -27
- data/lib/erlang/etf/small_atom_utf8.rb +31 -27
- data/lib/erlang/etf/small_big.rb +30 -39
- data/lib/erlang/etf/small_integer.rb +27 -12
- data/lib/erlang/etf/small_tuple.rb +41 -30
- data/lib/erlang/etf/string.rb +23 -23
- data/lib/erlang/etf/term.rb +109 -70
- data/lib/erlang/etf/version.rb +1 -1
- metadata +33 -169
- data/.rspec +0 -2
- data/lib/erlang/etf/bert.rb +0 -74
- data/lib/erlang/etf/extensions.rb +0 -144
- data/lib/erlang/etf/extensions/array.rb +0 -27
- data/lib/erlang/etf/extensions/big_decimal.rb +0 -20
- data/lib/erlang/etf/extensions/erlang-export.rb +0 -24
- data/lib/erlang/etf/extensions/erlang-list.rb +0 -29
- data/lib/erlang/etf/extensions/erlang-map.rb +0 -26
- data/lib/erlang/etf/extensions/erlang-nil.rb +0 -20
- data/lib/erlang/etf/extensions/erlang-pid.rb +0 -20
- data/lib/erlang/etf/extensions/erlang-string.rb +0 -31
- data/lib/erlang/etf/extensions/erlang-tuple.rb +0 -29
- data/lib/erlang/etf/extensions/false_class.rb +0 -26
- data/lib/erlang/etf/extensions/float.rb +0 -18
- data/lib/erlang/etf/extensions/hash.rb +0 -30
- data/lib/erlang/etf/extensions/integer.rb +0 -46
- data/lib/erlang/etf/extensions/nil_class.rb +0 -27
- data/lib/erlang/etf/extensions/object.rb +0 -22
- data/lib/erlang/etf/extensions/regexp.rb +0 -32
- data/lib/erlang/etf/extensions/string.rb +0 -33
- data/lib/erlang/etf/extensions/symbol.rb +0 -43
- data/lib/erlang/etf/extensions/time.rb +0 -27
- data/lib/erlang/etf/extensions/true_class.rb +0 -26
- data/lib/erlang/etf/terms.rb +0 -132
- data/spec/erlang/etf/atom_spec.rb +0 -90
- data/spec/erlang/etf/atom_utf8_spec.rb +0 -90
- data/spec/erlang/etf/binary_spec.rb +0 -90
- data/spec/erlang/etf/bit_binary_spec.rb +0 -99
- data/spec/erlang/etf/compressed_spec.rb +0 -37
- data/spec/erlang/etf/export_spec.rb +0 -58
- data/spec/erlang/etf/extensions/array_spec.rb +0 -40
- data/spec/erlang/etf/extensions/big_decimal_spec.rb +0 -26
- data/spec/erlang/etf/extensions/erlang-export_spec.rb +0 -32
- data/spec/erlang/etf/extensions/erlang-list_spec.rb +0 -76
- data/spec/erlang/etf/extensions/erlang-map_spec.rb +0 -48
- data/spec/erlang/etf/extensions/erlang-nil_spec.rb +0 -24
- data/spec/erlang/etf/extensions/erlang-pid_spec.rb +0 -33
- data/spec/erlang/etf/extensions/erlang-string_spec.rb +0 -41
- data/spec/erlang/etf/extensions/erlang-tuple_spec.rb +0 -57
- data/spec/erlang/etf/extensions/false_class_spec.rb +0 -29
- data/spec/erlang/etf/extensions/float_spec.rb +0 -24
- data/spec/erlang/etf/extensions/hash_spec.rb +0 -90
- data/spec/erlang/etf/extensions/integer_spec.rb +0 -259
- data/spec/erlang/etf/extensions/nil_class_spec.rb +0 -29
- data/spec/erlang/etf/extensions/object_spec.rb +0 -30
- data/spec/erlang/etf/extensions/regexp_spec.rb +0 -35
- data/spec/erlang/etf/extensions/string_spec.rb +0 -43
- data/spec/erlang/etf/extensions/symbol_spec.rb +0 -64
- data/spec/erlang/etf/extensions/time_spec.rb +0 -32
- data/spec/erlang/etf/extensions/true_class_spec.rb +0 -29
- data/spec/erlang/etf/float_spec.rb +0 -92
- data/spec/erlang/etf/fun_spec.rb +0 -132
- data/spec/erlang/etf/integer_spec.rb +0 -57
- data/spec/erlang/etf/large_big_spec.rb +0 -67
- data/spec/erlang/etf/large_tuple_spec.rb +0 -119
- data/spec/erlang/etf/list_spec.rb +0 -159
- data/spec/erlang/etf/map_spec.rb +0 -100
- data/spec/erlang/etf/new_float_spec.rb +0 -92
- data/spec/erlang/etf/new_fun_spec.rb +0 -146
- data/spec/erlang/etf/new_reference_spec.rb +0 -60
- data/spec/erlang/etf/nil_spec.rb +0 -50
- data/spec/erlang/etf/pid_spec.rb +0 -61
- data/spec/erlang/etf/port_spec.rb +0 -58
- data/spec/erlang/etf/reference_spec.rb +0 -58
- data/spec/erlang/etf/small_atom_spec.rb +0 -90
- data/spec/erlang/etf/small_atom_utf8_spec.rb +0 -90
- data/spec/erlang/etf/small_big_spec.rb +0 -67
- data/spec/erlang/etf/small_integer_spec.rb +0 -57
- data/spec/erlang/etf/small_tuple_spec.rb +0 -112
- data/spec/erlang/etf/string_spec.rb +0 -92
- data/spec/erlang/etf/term_spec.rb +0 -27
- data/spec/erlang/etf/terms_spec.rb +0 -23
- data/spec/erlang/etf_spec.rb +0 -23
- data/spec/erlang_spec.rb +0 -95
- data/spec/spec_helper.rb +0 -31
@@ -1,259 +0,0 @@
|
|
1
|
-
# encoding: utf-8
|
2
|
-
|
3
|
-
require 'spec_helper'
|
4
|
-
|
5
|
-
describe Erlang::ETF::Extensions::Integer do
|
6
|
-
let(:klass) { ::Integer }
|
7
|
-
|
8
|
-
let(:small_integer_min) { Erlang::ETF::Extensions::Integer::UINT8_MIN }
|
9
|
-
let(:small_integer_max) { Erlang::ETF::Extensions::Integer::UINT8_MAX }
|
10
|
-
let(:integer_min) { Erlang::ETF::Extensions::Integer::INT32_MIN }
|
11
|
-
let(:integer_max) { Erlang::ETF::Extensions::Integer::INT32_MAX }
|
12
|
-
let(:small_big_min) { (-1 << (255 * 8)) + 1 }
|
13
|
-
let(:small_big_max) { (+1 << (255 * 8)) - 1 }
|
14
|
-
|
15
|
-
describe '[instance]' do
|
16
|
-
describe '__erlang_type__' do
|
17
|
-
subject { instance.__erlang_type__ }
|
18
|
-
|
19
|
-
context "when between #{Erlang::ETF::Extensions::Integer::UINT8_MIN} and #{Erlang::ETF::Extensions::Integer::UINT8_MAX}" do
|
20
|
-
let(:min) { small_integer_min }
|
21
|
-
let(:max) { small_integer_max }
|
22
|
-
|
23
|
-
let(:current) { :small_integer }
|
24
|
-
let(:positive) { :integer }
|
25
|
-
let(:negative) { :integer }
|
26
|
-
|
27
|
-
context 'minimum' do
|
28
|
-
let(:instance) { min }
|
29
|
-
it { should eq(current) }
|
30
|
-
end
|
31
|
-
|
32
|
-
context 'minimum + 1' do
|
33
|
-
let(:instance) { min + 1 }
|
34
|
-
it { should eq(current) }
|
35
|
-
end
|
36
|
-
|
37
|
-
context 'minimum - 1' do
|
38
|
-
let(:instance) { min - 1 }
|
39
|
-
it { should eq(negative) }
|
40
|
-
end
|
41
|
-
|
42
|
-
context 'maximum' do
|
43
|
-
let(:instance) { max }
|
44
|
-
it { should eq(current) }
|
45
|
-
end
|
46
|
-
|
47
|
-
context 'maximum + 1' do
|
48
|
-
let(:instance) { max + 1 }
|
49
|
-
it { should eq(positive) }
|
50
|
-
end
|
51
|
-
|
52
|
-
context 'maximum - 1' do
|
53
|
-
let(:instance) { max - 1 }
|
54
|
-
it { should eq(current) }
|
55
|
-
end
|
56
|
-
end
|
57
|
-
|
58
|
-
context "when between #{Erlang::ETF::Extensions::Integer::INT32_MIN} and #{Erlang::ETF::Extensions::Integer::INT32_MAX}" do
|
59
|
-
let(:min) { integer_min }
|
60
|
-
let(:max) { integer_max }
|
61
|
-
|
62
|
-
let(:current) { :integer }
|
63
|
-
let(:positive) { :small_big }
|
64
|
-
let(:negative) { :small_big }
|
65
|
-
|
66
|
-
context 'minimum' do
|
67
|
-
let(:instance) { min }
|
68
|
-
it { should eq(current) }
|
69
|
-
end
|
70
|
-
|
71
|
-
context 'minimum + 1' do
|
72
|
-
let(:instance) { min + 1 }
|
73
|
-
it { should eq(current) }
|
74
|
-
end
|
75
|
-
|
76
|
-
context 'minimum - 1' do
|
77
|
-
let(:instance) { min - 1 }
|
78
|
-
it { should eq(negative) }
|
79
|
-
end
|
80
|
-
|
81
|
-
context 'maximum' do
|
82
|
-
let(:instance) { max }
|
83
|
-
it { should eq(current) }
|
84
|
-
end
|
85
|
-
|
86
|
-
context 'maximum + 1' do
|
87
|
-
let(:instance) { max + 1 }
|
88
|
-
it { should eq(positive) }
|
89
|
-
end
|
90
|
-
|
91
|
-
context 'maximum - 1' do
|
92
|
-
let(:instance) { max - 1 }
|
93
|
-
it { should eq(current) }
|
94
|
-
end
|
95
|
-
end
|
96
|
-
|
97
|
-
context "when between ((-1 << (255 * 8)) + 1) and ((+1 << (255 * 8)) - 1)" do
|
98
|
-
let(:min) { small_big_min }
|
99
|
-
let(:max) { small_big_max }
|
100
|
-
|
101
|
-
let(:current) { :small_big }
|
102
|
-
let(:positive) { :large_big }
|
103
|
-
let(:negative) { :large_big }
|
104
|
-
|
105
|
-
context 'minimum' do
|
106
|
-
let(:instance) { min }
|
107
|
-
it { should eq(current) }
|
108
|
-
end
|
109
|
-
|
110
|
-
context 'minimum + 1' do
|
111
|
-
let(:instance) { min + 1 }
|
112
|
-
it { should eq(current) }
|
113
|
-
end
|
114
|
-
|
115
|
-
context 'minimum - 1' do
|
116
|
-
let(:instance) { min - 1 }
|
117
|
-
it { should eq(negative) }
|
118
|
-
end
|
119
|
-
|
120
|
-
context 'maximum' do
|
121
|
-
let(:instance) { max }
|
122
|
-
it { should eq(current) }
|
123
|
-
end
|
124
|
-
|
125
|
-
context 'maximum + 1' do
|
126
|
-
let(:instance) { max + 1 }
|
127
|
-
it { should eq(positive) }
|
128
|
-
end
|
129
|
-
|
130
|
-
context 'maximum - 1' do
|
131
|
-
let(:instance) { max - 1 }
|
132
|
-
it { should eq(current) }
|
133
|
-
end
|
134
|
-
end
|
135
|
-
end
|
136
|
-
|
137
|
-
describe '__erlang_evolve__' do
|
138
|
-
subject { instance.__erlang_evolve__ }
|
139
|
-
|
140
|
-
context "when >= #{Erlang::ETF::Extensions::Integer::UINT8_MIN} and <= #{Erlang::ETF::Extensions::Integer::UINT8_MAX}" do
|
141
|
-
let(:min) { small_integer_min }
|
142
|
-
let(:max) { small_integer_max }
|
143
|
-
|
144
|
-
let(:current) { Erlang::ETF::SmallInteger.new(instance) }
|
145
|
-
let(:positive) { Erlang::ETF::Integer.new(instance) }
|
146
|
-
let(:negative) { Erlang::ETF::Integer.new(instance) }
|
147
|
-
|
148
|
-
context 'minimum' do
|
149
|
-
let(:instance) { min }
|
150
|
-
it { should eq(current) }
|
151
|
-
end
|
152
|
-
|
153
|
-
context 'minimum + 1' do
|
154
|
-
let(:instance) { min + 1 }
|
155
|
-
it { should eq(current) }
|
156
|
-
end
|
157
|
-
|
158
|
-
context 'minimum - 1' do
|
159
|
-
let(:instance) { min - 1 }
|
160
|
-
it { should eq(negative) }
|
161
|
-
end
|
162
|
-
|
163
|
-
context 'maximum' do
|
164
|
-
let(:instance) { max }
|
165
|
-
it { should eq(current) }
|
166
|
-
end
|
167
|
-
|
168
|
-
context 'maximum + 1' do
|
169
|
-
let(:instance) { max + 1 }
|
170
|
-
it { should eq(positive) }
|
171
|
-
end
|
172
|
-
|
173
|
-
context 'maximum - 1' do
|
174
|
-
let(:instance) { max - 1 }
|
175
|
-
it { should eq(current) }
|
176
|
-
end
|
177
|
-
end
|
178
|
-
|
179
|
-
context "when between #{Erlang::ETF::Extensions::Integer::INT32_MIN} and #{Erlang::ETF::Extensions::Integer::INT32_MAX}" do
|
180
|
-
let(:min) { integer_min }
|
181
|
-
let(:max) { integer_max }
|
182
|
-
|
183
|
-
let(:current) { Erlang::ETF::Integer.new(instance) }
|
184
|
-
let(:positive) { Erlang::ETF::SmallBig.new(instance) }
|
185
|
-
let(:negative) { Erlang::ETF::SmallBig.new(instance) }
|
186
|
-
|
187
|
-
context 'minimum' do
|
188
|
-
let(:instance) { min }
|
189
|
-
it { should eq(current) }
|
190
|
-
end
|
191
|
-
|
192
|
-
context 'minimum + 1' do
|
193
|
-
let(:instance) { min + 1 }
|
194
|
-
it { should eq(current) }
|
195
|
-
end
|
196
|
-
|
197
|
-
context 'minimum - 1' do
|
198
|
-
let(:instance) { min - 1 }
|
199
|
-
it { should eq(negative) }
|
200
|
-
end
|
201
|
-
|
202
|
-
context 'maximum' do
|
203
|
-
let(:instance) { max }
|
204
|
-
it { should eq(current) }
|
205
|
-
end
|
206
|
-
|
207
|
-
context 'maximum + 1' do
|
208
|
-
let(:instance) { max + 1 }
|
209
|
-
it { should eq(positive) }
|
210
|
-
end
|
211
|
-
|
212
|
-
context 'maximum - 1' do
|
213
|
-
let(:instance) { max - 1 }
|
214
|
-
it { should eq(current) }
|
215
|
-
end
|
216
|
-
end
|
217
|
-
|
218
|
-
context "when between ((-1 << (255 * 8)) + 1) and ((+1 << (255 * 8)) - 1)" do
|
219
|
-
let(:min) { small_big_min }
|
220
|
-
let(:max) { small_big_max }
|
221
|
-
|
222
|
-
let(:current) { Erlang::ETF::SmallBig.new(instance) }
|
223
|
-
let(:positive) { Erlang::ETF::LargeBig.new(instance) }
|
224
|
-
let(:negative) { Erlang::ETF::LargeBig.new(instance) }
|
225
|
-
|
226
|
-
context 'minimum' do
|
227
|
-
let(:instance) { min }
|
228
|
-
it { should eq(current) }
|
229
|
-
end
|
230
|
-
|
231
|
-
context 'minimum + 1' do
|
232
|
-
let(:instance) { min + 1 }
|
233
|
-
it { should eq(current) }
|
234
|
-
end
|
235
|
-
|
236
|
-
context 'minimum - 1' do
|
237
|
-
let(:instance) { min - 1 }
|
238
|
-
it { should eq(negative) }
|
239
|
-
end
|
240
|
-
|
241
|
-
context 'maximum' do
|
242
|
-
let(:instance) { max }
|
243
|
-
it { should eq(current) }
|
244
|
-
end
|
245
|
-
|
246
|
-
context 'maximum + 1' do
|
247
|
-
let(:instance) { max + 1 }
|
248
|
-
it { should eq(positive) }
|
249
|
-
end
|
250
|
-
|
251
|
-
context 'maximum - 1' do
|
252
|
-
let(:instance) { max - 1 }
|
253
|
-
it { should eq(current) }
|
254
|
-
end
|
255
|
-
end
|
256
|
-
end
|
257
|
-
end
|
258
|
-
|
259
|
-
end
|
@@ -1,29 +0,0 @@
|
|
1
|
-
# encoding: utf-8
|
2
|
-
|
3
|
-
require 'spec_helper'
|
4
|
-
|
5
|
-
describe Erlang::ETF::Extensions::NilClass do
|
6
|
-
let(:klass) { ::NilClass }
|
7
|
-
|
8
|
-
describe '[instance]' do
|
9
|
-
let(:instance) { nil }
|
10
|
-
|
11
|
-
describe '__erlang_type__' do
|
12
|
-
subject { instance.__erlang_type__ }
|
13
|
-
|
14
|
-
it { should eq(:bert_nil) }
|
15
|
-
end
|
16
|
-
|
17
|
-
describe '__erlang_evolve__' do
|
18
|
-
subject { instance.__erlang_evolve__ }
|
19
|
-
|
20
|
-
it { should eq(
|
21
|
-
Erlang::ETF::SmallTuple.new([
|
22
|
-
Erlang::ETF::SmallAtom.new("bert"),
|
23
|
-
Erlang::ETF::SmallAtom.new("nil")
|
24
|
-
])
|
25
|
-
) }
|
26
|
-
end
|
27
|
-
end
|
28
|
-
|
29
|
-
end
|
@@ -1,30 +0,0 @@
|
|
1
|
-
# encoding: utf-8
|
2
|
-
|
3
|
-
require 'spec_helper'
|
4
|
-
|
5
|
-
describe Erlang::ETF::Extensions::Object do
|
6
|
-
let(:klass) { ::Object }
|
7
|
-
|
8
|
-
describe '[instance]' do
|
9
|
-
let(:instance) { klass.new }
|
10
|
-
|
11
|
-
describe '__erlang_type__' do
|
12
|
-
subject { -> { instance.__erlang_type__ } }
|
13
|
-
|
14
|
-
it { should raise_error(NotImplementedError) }
|
15
|
-
end
|
16
|
-
|
17
|
-
describe '__erlang_evolve__' do
|
18
|
-
subject { -> { instance.__erlang_evolve__ } }
|
19
|
-
|
20
|
-
it { should raise_error(NotImplementedError) }
|
21
|
-
end
|
22
|
-
|
23
|
-
describe '__erlang_dump__' do
|
24
|
-
subject { -> { instance.__erlang_dump__("") } }
|
25
|
-
|
26
|
-
it { should raise_error(NotImplementedError) }
|
27
|
-
end
|
28
|
-
end
|
29
|
-
|
30
|
-
end
|
@@ -1,35 +0,0 @@
|
|
1
|
-
# encoding: utf-8
|
2
|
-
|
3
|
-
require 'spec_helper'
|
4
|
-
|
5
|
-
describe Erlang::ETF::Extensions::Regexp do
|
6
|
-
let(:klass) { ::Regexp }
|
7
|
-
|
8
|
-
describe '[instance]' do
|
9
|
-
let(:instance) { /./imx }
|
10
|
-
|
11
|
-
describe '__erlang_type__' do
|
12
|
-
subject { instance.__erlang_type__ }
|
13
|
-
|
14
|
-
it { should eq(:bert_regex) }
|
15
|
-
end
|
16
|
-
|
17
|
-
describe '__erlang_evolve__' do
|
18
|
-
subject { instance.__erlang_evolve__ }
|
19
|
-
|
20
|
-
it { should eq(
|
21
|
-
Erlang::ETF::SmallTuple.new([
|
22
|
-
Erlang::ETF::SmallAtom.new("bert"),
|
23
|
-
Erlang::ETF::SmallAtom.new("regex"),
|
24
|
-
Erlang::ETF::Binary.new("."),
|
25
|
-
Erlang::ETF::List.new([
|
26
|
-
Erlang::ETF::SmallAtom.new("caseless"),
|
27
|
-
Erlang::ETF::SmallAtom.new("extended"),
|
28
|
-
Erlang::ETF::SmallAtom.new("multiline")
|
29
|
-
])
|
30
|
-
])
|
31
|
-
) }
|
32
|
-
end
|
33
|
-
end
|
34
|
-
|
35
|
-
end
|
@@ -1,43 +0,0 @@
|
|
1
|
-
# encoding: utf-8
|
2
|
-
|
3
|
-
require 'spec_helper'
|
4
|
-
|
5
|
-
describe Erlang::ETF::Extensions::String do
|
6
|
-
let(:klass) { ::String }
|
7
|
-
|
8
|
-
describe '[instance]' do
|
9
|
-
let(:instance) { "test" }
|
10
|
-
|
11
|
-
describe '__erlang_type__' do
|
12
|
-
subject { instance.__erlang_type__ }
|
13
|
-
|
14
|
-
it { should eq(:binary) }
|
15
|
-
end
|
16
|
-
|
17
|
-
describe '__erlang_evolve__' do
|
18
|
-
subject { instance.__erlang_evolve__ }
|
19
|
-
|
20
|
-
it { should eq(Erlang::ETF::Binary.new(instance)) }
|
21
|
-
end
|
22
|
-
|
23
|
-
describe 'to_utf8_binary' do
|
24
|
-
it "converts \"Ω\" to \"\\xCE\\xA9\"" do
|
25
|
-
expect("Ω".to_utf8_binary).to eq("\xCE\xA9".force_encoding('BINARY'))
|
26
|
-
end
|
27
|
-
|
28
|
-
it "handles EncodingError" do
|
29
|
-
string = "Ωomega"
|
30
|
-
string.should_receive(:encode).with(Erlang::ETF::Extensions::UTF8_ENCODING).and_raise(EncodingError)
|
31
|
-
|
32
|
-
expect(string.to_utf8_binary).to eq("\xCE\xA9omega".force_encoding('BINARY'))
|
33
|
-
end
|
34
|
-
end
|
35
|
-
|
36
|
-
describe 'from_utf8_binary' do
|
37
|
-
it "converts \"\\xCE\\xA9\" to \"Ω\"" do
|
38
|
-
expect("\xCE\xA9".force_encoding('BINARY').from_utf8_binary).to eq("Ω")
|
39
|
-
end
|
40
|
-
end
|
41
|
-
end
|
42
|
-
|
43
|
-
end
|
@@ -1,64 +0,0 @@
|
|
1
|
-
# encoding: utf-8
|
2
|
-
|
3
|
-
require 'spec_helper'
|
4
|
-
|
5
|
-
describe Erlang::ETF::Extensions::Symbol do
|
6
|
-
let(:klass) { ::Symbol }
|
7
|
-
|
8
|
-
describe '[instance]' do
|
9
|
-
describe '__erlang_type__' do
|
10
|
-
subject { instance.__erlang_type__ }
|
11
|
-
|
12
|
-
context 'when bytesize is < 256' do
|
13
|
-
let(:instance) { :a }
|
14
|
-
it { should eq(:small_atom) }
|
15
|
-
|
16
|
-
context 'when it contains UTF-8 characters' do
|
17
|
-
let(:instance) { :'Ω' }
|
18
|
-
it { should eq(:small_atom_utf8) }
|
19
|
-
end
|
20
|
-
end
|
21
|
-
|
22
|
-
context 'when bytesize is >= 256' do
|
23
|
-
let(:instance) { ("a" * 256).intern }
|
24
|
-
it { should eq(:atom) }
|
25
|
-
|
26
|
-
context 'when it contains UTF-8 characters' do
|
27
|
-
let(:instance) { ("Ω" * 256).intern }
|
28
|
-
it { should eq(:atom_utf8) }
|
29
|
-
end
|
30
|
-
end
|
31
|
-
end
|
32
|
-
|
33
|
-
describe '__erlang_evolve__' do
|
34
|
-
subject { instance.__erlang_evolve__ }
|
35
|
-
|
36
|
-
context 'when bytesize is < 256' do
|
37
|
-
let(:instance) { :a }
|
38
|
-
it { should eq(Erlang::ETF::SmallAtom.new(instance.to_s)) }
|
39
|
-
|
40
|
-
context 'when it contains UTF-8 characters' do
|
41
|
-
let(:instance) { :'Ω' }
|
42
|
-
it { should eq(Erlang::ETF::SmallAtomUTF8.new(instance.to_s)) }
|
43
|
-
end
|
44
|
-
end
|
45
|
-
|
46
|
-
context 'when bytesize is >= 256' do
|
47
|
-
let(:instance) { ("a" * 256).intern }
|
48
|
-
it { should eq(Erlang::ETF::Atom.new(instance.to_s)) }
|
49
|
-
|
50
|
-
context 'when it contains UTF-8 characters' do
|
51
|
-
let(:instance) { ("Ω" * 256).intern }
|
52
|
-
it { should eq(Erlang::ETF::AtomUTF8.new(instance.to_s)) }
|
53
|
-
end
|
54
|
-
end
|
55
|
-
end
|
56
|
-
|
57
|
-
describe 'to_utf8_binary' do
|
58
|
-
it "converts :Ω to \"\\xCE\\xA9\"" do
|
59
|
-
expect(:'Ω'.to_utf8_binary).to eq("\xCE\xA9".force_encoding('BINARY'))
|
60
|
-
end
|
61
|
-
end
|
62
|
-
end
|
63
|
-
|
64
|
-
end
|