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,40 +0,0 @@
|
|
1
|
-
# encoding: utf-8
|
2
|
-
|
3
|
-
require 'spec_helper'
|
4
|
-
|
5
|
-
describe Erlang::ETF::Extensions::Array do
|
6
|
-
let(:klass) { ::Array }
|
7
|
-
|
8
|
-
describe '[instance]' do
|
9
|
-
let(:instance) { klass.new(*args) }
|
10
|
-
|
11
|
-
describe '__erlang_type__' do
|
12
|
-
subject { instance.__erlang_type__ }
|
13
|
-
|
14
|
-
context 'when empty' do
|
15
|
-
let(:args) {[ ]}
|
16
|
-
it { should eq(:nil) }
|
17
|
-
end
|
18
|
-
|
19
|
-
context 'when not empty' do
|
20
|
-
let(:args) {[ [:a] ]}
|
21
|
-
it { should eq(:list) }
|
22
|
-
end
|
23
|
-
end
|
24
|
-
|
25
|
-
describe '__erlang_evolve__' do
|
26
|
-
subject { instance.__erlang_evolve__ }
|
27
|
-
|
28
|
-
context 'when empty' do
|
29
|
-
let(:args) {[ ]}
|
30
|
-
it { should eq(Erlang::ETF::Nil.new) }
|
31
|
-
end
|
32
|
-
|
33
|
-
context 'when not empty' do
|
34
|
-
let(:args) {[ [:a] ]}
|
35
|
-
it { should eq(Erlang::ETF::List.new([Erlang::ETF::SmallAtom.new("a")])) }
|
36
|
-
end
|
37
|
-
end
|
38
|
-
end
|
39
|
-
|
40
|
-
end
|
@@ -1,26 +0,0 @@
|
|
1
|
-
# encoding: utf-8
|
2
|
-
|
3
|
-
require 'spec_helper'
|
4
|
-
|
5
|
-
describe Erlang::ETF::Extensions::BigDecimal do
|
6
|
-
let(:klass) { ::BigDecimal }
|
7
|
-
|
8
|
-
describe '[instance]' do
|
9
|
-
let(:instance) { klass.new(*args) }
|
10
|
-
|
11
|
-
describe '__erlang_type__' do
|
12
|
-
subject { instance.__erlang_type__ }
|
13
|
-
|
14
|
-
let(:args) {[ "1.1" ]}
|
15
|
-
it { should eq(:float) }
|
16
|
-
end
|
17
|
-
|
18
|
-
describe '__erlang_evolve__' do
|
19
|
-
subject { instance.__erlang_evolve__ }
|
20
|
-
|
21
|
-
let(:args) {[ "1.1" ]}
|
22
|
-
it { should eq(Erlang::ETF::Float.new(instance)) }
|
23
|
-
end
|
24
|
-
end
|
25
|
-
|
26
|
-
end
|
@@ -1,32 +0,0 @@
|
|
1
|
-
# encoding: utf-8
|
2
|
-
|
3
|
-
require 'spec_helper'
|
4
|
-
|
5
|
-
describe Erlang::ETF::Extensions::ErlangExport do
|
6
|
-
let(:klass) { ::Erlang::Export }
|
7
|
-
|
8
|
-
describe '[instance]' do
|
9
|
-
let(:instance) { klass.new(*args) }
|
10
|
-
|
11
|
-
describe '__erlang_type__' do
|
12
|
-
subject { instance.__erlang_type__ }
|
13
|
-
|
14
|
-
let(:args) {[ :erlang, :now, 0 ]}
|
15
|
-
it { should eq(:export) }
|
16
|
-
end
|
17
|
-
|
18
|
-
describe '__erlang_evolve__' do
|
19
|
-
subject { instance.__erlang_evolve__ }
|
20
|
-
|
21
|
-
let(:args) {[ :erlang, :now, 0 ]}
|
22
|
-
it { should eq(
|
23
|
-
Erlang::ETF::Export.new(
|
24
|
-
Erlang::ETF::SmallAtom.new("erlang"),
|
25
|
-
Erlang::ETF::SmallAtom.new("now"),
|
26
|
-
Erlang::ETF::SmallInteger.new(0)
|
27
|
-
)
|
28
|
-
) }
|
29
|
-
end
|
30
|
-
end
|
31
|
-
|
32
|
-
end
|
@@ -1,76 +0,0 @@
|
|
1
|
-
# encoding: utf-8
|
2
|
-
|
3
|
-
require 'spec_helper'
|
4
|
-
|
5
|
-
describe Erlang::ETF::Extensions::ErlangList do
|
6
|
-
let(:klass) { ::Erlang::List }
|
7
|
-
|
8
|
-
describe '[instance]' do
|
9
|
-
let(:instance) { klass[*elements].tail(tail) }
|
10
|
-
|
11
|
-
describe '__erlang_type__' do
|
12
|
-
subject { instance.__erlang_type__ }
|
13
|
-
|
14
|
-
context 'when empty and proper' do
|
15
|
-
let(:elements) { [] }
|
16
|
-
let(:tail) { [] }
|
17
|
-
|
18
|
-
it { should eq(:nil) }
|
19
|
-
end
|
20
|
-
|
21
|
-
context 'when empty and improper' do
|
22
|
-
let(:elements) { [] }
|
23
|
-
let(:tail) { :a }
|
24
|
-
|
25
|
-
it { should eq(:list) }
|
26
|
-
end
|
27
|
-
|
28
|
-
context 'when not empty and proper' do
|
29
|
-
let(:elements) { [:a] }
|
30
|
-
let(:tail) { [] }
|
31
|
-
|
32
|
-
it { should eq(:list) }
|
33
|
-
end
|
34
|
-
|
35
|
-
context 'when not empty and improper' do
|
36
|
-
let(:elements) { [:a] }
|
37
|
-
let(:tail) { :a }
|
38
|
-
|
39
|
-
it { should eq(:list) }
|
40
|
-
end
|
41
|
-
end
|
42
|
-
|
43
|
-
describe '__erlang_evolve__' do
|
44
|
-
subject { instance.__erlang_evolve__ }
|
45
|
-
|
46
|
-
context 'when empty and proper' do
|
47
|
-
let(:elements) { [] }
|
48
|
-
let(:tail) { [] }
|
49
|
-
|
50
|
-
it { should eq(Erlang::ETF::Nil.new) }
|
51
|
-
end
|
52
|
-
|
53
|
-
context 'when empty and improper' do
|
54
|
-
let(:elements) { [] }
|
55
|
-
let(:tail) { :a }
|
56
|
-
|
57
|
-
it { should eq(Erlang::ETF::List.new([], Erlang::ETF::SmallAtom.new("a"))) }
|
58
|
-
end
|
59
|
-
|
60
|
-
context 'when not empty and proper' do
|
61
|
-
let(:elements) { [:a] }
|
62
|
-
let(:tail) { [] }
|
63
|
-
|
64
|
-
it { should eq(Erlang::ETF::List.new([Erlang::ETF::SmallAtom.new("a")])) }
|
65
|
-
end
|
66
|
-
|
67
|
-
context 'when not empty and improper' do
|
68
|
-
let(:elements) { [:a] }
|
69
|
-
let(:tail) { :a }
|
70
|
-
|
71
|
-
it { should eq(Erlang::ETF::List.new([Erlang::ETF::SmallAtom.new("a")], Erlang::ETF::SmallAtom.new("a"))) }
|
72
|
-
end
|
73
|
-
end
|
74
|
-
end
|
75
|
-
|
76
|
-
end
|
@@ -1,48 +0,0 @@
|
|
1
|
-
# encoding: utf-8
|
2
|
-
|
3
|
-
require 'spec_helper'
|
4
|
-
|
5
|
-
describe Erlang::ETF::Extensions::ErlangMap do
|
6
|
-
let(:klass) { ::Erlang::Map }
|
7
|
-
|
8
|
-
describe '[instance]' do
|
9
|
-
let(:instance) { klass[keys.zip(values)] }
|
10
|
-
|
11
|
-
describe '__erlang_type__' do
|
12
|
-
subject { instance.__erlang_type__ }
|
13
|
-
|
14
|
-
context 'when empty' do
|
15
|
-
let(:keys) { [] }
|
16
|
-
let(:values) { [] }
|
17
|
-
|
18
|
-
it { should eq(:map) }
|
19
|
-
end
|
20
|
-
|
21
|
-
context 'when not empty' do
|
22
|
-
let(:keys) { [:a] }
|
23
|
-
let(:values) { [1] }
|
24
|
-
|
25
|
-
it { should eq(:map) }
|
26
|
-
end
|
27
|
-
end
|
28
|
-
|
29
|
-
describe '__erlang_evolve__' do
|
30
|
-
subject { instance.__erlang_evolve__ }
|
31
|
-
|
32
|
-
context 'when empty' do
|
33
|
-
let(:keys) { [] }
|
34
|
-
let(:values) { [] }
|
35
|
-
|
36
|
-
it { should eq(Erlang::ETF::Map.new([], [])) }
|
37
|
-
end
|
38
|
-
|
39
|
-
context 'when not empty' do
|
40
|
-
let(:keys) { [:a] }
|
41
|
-
let(:values) { [1] }
|
42
|
-
|
43
|
-
it { should eq(Erlang::ETF::Map.new([Erlang::ETF::SmallAtom.new("a")], [Erlang::ETF::SmallInteger.new(1)])) }
|
44
|
-
end
|
45
|
-
end
|
46
|
-
end
|
47
|
-
|
48
|
-
end
|
@@ -1,24 +0,0 @@
|
|
1
|
-
# encoding: utf-8
|
2
|
-
|
3
|
-
require 'spec_helper'
|
4
|
-
|
5
|
-
describe Erlang::ETF::Extensions::ErlangNil do
|
6
|
-
let(:klass) { ::Erlang::Nil }
|
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 eq(:nil) }
|
15
|
-
end
|
16
|
-
|
17
|
-
describe '__erlang_evolve__' do
|
18
|
-
subject { instance.__erlang_evolve__ }
|
19
|
-
|
20
|
-
it { should eq(Erlang::ETF::Nil.new) }
|
21
|
-
end
|
22
|
-
end
|
23
|
-
|
24
|
-
end
|
@@ -1,33 +0,0 @@
|
|
1
|
-
# encoding: utf-8
|
2
|
-
|
3
|
-
require 'spec_helper'
|
4
|
-
|
5
|
-
describe Erlang::ETF::Extensions::ErlangPid do
|
6
|
-
let(:klass) { ::Erlang::Pid }
|
7
|
-
|
8
|
-
describe '[instance]' do
|
9
|
-
let(:instance) { klass.new(*args) }
|
10
|
-
|
11
|
-
describe '__erlang_type__' do
|
12
|
-
subject { instance.__erlang_type__ }
|
13
|
-
|
14
|
-
let(:args) {[ :'nonode@nohost', 100, 10, 1 ]}
|
15
|
-
it { should eq(:pid) }
|
16
|
-
end
|
17
|
-
|
18
|
-
describe '__erlang_evolve__' do
|
19
|
-
subject { instance.__erlang_evolve__ }
|
20
|
-
|
21
|
-
let(:args) {[ :'nonode@nohost', 100, 10, 1 ]}
|
22
|
-
it { should eq(
|
23
|
-
Erlang::ETF::Pid.new(
|
24
|
-
Erlang::ETF::SmallAtom.new("nonode@nohost"),
|
25
|
-
100,
|
26
|
-
10,
|
27
|
-
1
|
28
|
-
)
|
29
|
-
) }
|
30
|
-
end
|
31
|
-
end
|
32
|
-
|
33
|
-
end
|
@@ -1,41 +0,0 @@
|
|
1
|
-
# encoding: utf-8
|
2
|
-
|
3
|
-
require 'spec_helper'
|
4
|
-
|
5
|
-
describe Erlang::ETF::Extensions::ErlangString do
|
6
|
-
let(:klass) { ::Erlang::String }
|
7
|
-
|
8
|
-
describe '[instance]' do
|
9
|
-
let(:instance) { klass.new(*args) }
|
10
|
-
|
11
|
-
describe '__erlang_type__' do
|
12
|
-
subject { instance.__erlang_type__ }
|
13
|
-
|
14
|
-
context 'simple string' do
|
15
|
-
let(:args) {[ "test" ]}
|
16
|
-
it { should eq(:string) }
|
17
|
-
end
|
18
|
-
|
19
|
-
context 'when bytesize larger than 1 << 16' do
|
20
|
-
let(:args) {[ "a" * (1 << 16) ]}
|
21
|
-
it { should eq(:list) }
|
22
|
-
end
|
23
|
-
end
|
24
|
-
|
25
|
-
describe '__erlang_evolve__' do
|
26
|
-
subject { instance.__erlang_evolve__ }
|
27
|
-
|
28
|
-
context 'simple string' do
|
29
|
-
let(:args) {[ "test" ]}
|
30
|
-
it { should eq(Erlang::ETF::String.new("test")) }
|
31
|
-
end
|
32
|
-
|
33
|
-
context 'when bytesize larger than 1 << 16' do
|
34
|
-
let(:args) {[ "a" * (1 << 16) ]}
|
35
|
-
its(:len) { should eq(1 << 16) }
|
36
|
-
it { should be_a(Erlang::ETF::List) }
|
37
|
-
end
|
38
|
-
end
|
39
|
-
end
|
40
|
-
|
41
|
-
end
|
@@ -1,57 +0,0 @@
|
|
1
|
-
# encoding: utf-8
|
2
|
-
|
3
|
-
require 'spec_helper'
|
4
|
-
|
5
|
-
describe Erlang::ETF::Extensions::ErlangTuple do
|
6
|
-
let(:klass) { ::Erlang::Tuple }
|
7
|
-
|
8
|
-
describe '[instance]' do
|
9
|
-
let(:instance) { klass[*elements] }
|
10
|
-
|
11
|
-
describe '__erlang_type__' do
|
12
|
-
subject { instance.__erlang_type__ }
|
13
|
-
|
14
|
-
context 'when empty' do
|
15
|
-
let(:elements) { [] }
|
16
|
-
|
17
|
-
it { should eq(:small_tuple) }
|
18
|
-
end
|
19
|
-
|
20
|
-
context 'when arity is less than 256' do
|
21
|
-
let(:elements) { [:a] }
|
22
|
-
|
23
|
-
it { should eq(:small_tuple) }
|
24
|
-
end
|
25
|
-
|
26
|
-
context 'when arity is greater than or equal to 256' do
|
27
|
-
let(:elements) { [[]] * 256 }
|
28
|
-
|
29
|
-
it { should eq(:large_tuple) }
|
30
|
-
end
|
31
|
-
end
|
32
|
-
|
33
|
-
describe '__erlang_evolve__' do
|
34
|
-
subject { instance.__erlang_evolve__ }
|
35
|
-
|
36
|
-
context 'when empty' do
|
37
|
-
let(:elements) { [] }
|
38
|
-
|
39
|
-
it { should eq(Erlang::ETF::SmallTuple.new([])) }
|
40
|
-
end
|
41
|
-
|
42
|
-
context 'when arity is less than 256' do
|
43
|
-
let(:elements) { [:a] }
|
44
|
-
|
45
|
-
it { should eq(Erlang::ETF::SmallTuple.new([Erlang::ETF::SmallAtom.new("a")])) }
|
46
|
-
end
|
47
|
-
|
48
|
-
context 'when arity is greater than or equal to 256' do
|
49
|
-
let(:elements) { [[]] * 256 }
|
50
|
-
|
51
|
-
its(:arity) { should eq(256) }
|
52
|
-
it { should be_a(Erlang::ETF::LargeTuple) }
|
53
|
-
end
|
54
|
-
end
|
55
|
-
end
|
56
|
-
|
57
|
-
end
|
@@ -1,29 +0,0 @@
|
|
1
|
-
# encoding: utf-8
|
2
|
-
|
3
|
-
require 'spec_helper'
|
4
|
-
|
5
|
-
describe Erlang::ETF::Extensions::FalseClass do
|
6
|
-
let(:klass) { ::FalseClass }
|
7
|
-
|
8
|
-
describe '[instance]' do
|
9
|
-
let(:instance) { false }
|
10
|
-
|
11
|
-
describe '__erlang_type__' do
|
12
|
-
subject { instance.__erlang_type__ }
|
13
|
-
|
14
|
-
it { should eq(:bert_boolean) }
|
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("false")
|
24
|
-
])
|
25
|
-
) }
|
26
|
-
end
|
27
|
-
end
|
28
|
-
|
29
|
-
end
|
@@ -1,24 +0,0 @@
|
|
1
|
-
# encoding: utf-8
|
2
|
-
|
3
|
-
require 'spec_helper'
|
4
|
-
|
5
|
-
describe Erlang::ETF::Extensions::Float do
|
6
|
-
let(:klass) { ::Float }
|
7
|
-
|
8
|
-
describe '[instance]' do
|
9
|
-
let(:instance) { 1.1 }
|
10
|
-
|
11
|
-
describe '__erlang_type__' do
|
12
|
-
subject { instance.__erlang_type__ }
|
13
|
-
|
14
|
-
it { should eq(:new_float) }
|
15
|
-
end
|
16
|
-
|
17
|
-
describe '__erlang_evolve__' do
|
18
|
-
subject { instance.__erlang_evolve__ }
|
19
|
-
|
20
|
-
it { should eq(Erlang::ETF::NewFloat.new(instance)) }
|
21
|
-
end
|
22
|
-
end
|
23
|
-
|
24
|
-
end
|
@@ -1,90 +0,0 @@
|
|
1
|
-
# encoding: utf-8
|
2
|
-
|
3
|
-
require 'spec_helper'
|
4
|
-
|
5
|
-
describe Erlang::ETF::Extensions::Hash do
|
6
|
-
let(:klass) { ::Hash }
|
7
|
-
|
8
|
-
describe '[instance]' do
|
9
|
-
let(:instance) { klass[*keyvalues] }
|
10
|
-
|
11
|
-
describe '__erlang_type__' do
|
12
|
-
subject { instance.__erlang_type__ }
|
13
|
-
|
14
|
-
context 'when empty' do
|
15
|
-
let(:keyvalues) { [] }
|
16
|
-
|
17
|
-
it { should eq(:bert_dict) }
|
18
|
-
end
|
19
|
-
|
20
|
-
context 'when arity is less than 256' do
|
21
|
-
let(:keyvalues) { [:a, 1] }
|
22
|
-
|
23
|
-
it { should eq(:bert_dict) }
|
24
|
-
end
|
25
|
-
|
26
|
-
context 'when arity is greater than or equal to 256' do
|
27
|
-
let(:keyvalues) { (1..256).zip([Erlang::Nil.new] * 256).flatten }
|
28
|
-
|
29
|
-
it { should eq(:bert_dict) }
|
30
|
-
end
|
31
|
-
end
|
32
|
-
|
33
|
-
describe '__erlang_evolve__' do
|
34
|
-
subject { instance.__erlang_evolve__ }
|
35
|
-
|
36
|
-
context 'when empty' do
|
37
|
-
let(:keyvalues) { [] }
|
38
|
-
|
39
|
-
it("should eq {:bert, :dict, []}") { should eq(
|
40
|
-
Erlang::ETF::SmallTuple.new([
|
41
|
-
Erlang::ETF::SmallAtom.new("bert"),
|
42
|
-
Erlang::ETF::SmallAtom.new("dict"),
|
43
|
-
Erlang::ETF::Nil.new
|
44
|
-
])
|
45
|
-
) }
|
46
|
-
end
|
47
|
-
|
48
|
-
context 'when arity is less than 256' do
|
49
|
-
let(:keyvalues) { [:a, 1] }
|
50
|
-
|
51
|
-
it("should eq {:bert, :dict, [{:a, 1}]}") { should eq(
|
52
|
-
Erlang::ETF::SmallTuple.new([
|
53
|
-
Erlang::ETF::SmallAtom.new("bert"),
|
54
|
-
Erlang::ETF::SmallAtom.new("dict"),
|
55
|
-
Erlang::ETF::List.new([
|
56
|
-
Erlang::ETF::SmallTuple.new([
|
57
|
-
Erlang::ETF::SmallAtom.new("a"),
|
58
|
-
Erlang::ETF::SmallInteger.new(1)
|
59
|
-
])
|
60
|
-
])
|
61
|
-
])
|
62
|
-
) }
|
63
|
-
end
|
64
|
-
|
65
|
-
context 'when arity is greater than or equal to 256' do
|
66
|
-
let(:keyvalues) { (1..256).zip([Erlang::Nil.new] * 256).flatten }
|
67
|
-
|
68
|
-
let(:elements) {
|
69
|
-
elements = []
|
70
|
-
1.upto(256) do |i|
|
71
|
-
elements << Erlang::ETF::SmallTuple.new([
|
72
|
-
i.__erlang_evolve__,
|
73
|
-
Erlang::ETF::Nil.new
|
74
|
-
])
|
75
|
-
end
|
76
|
-
elements
|
77
|
-
}
|
78
|
-
|
79
|
-
it("should eq {:bert, :dict, [{1, []}, {2, []}, ..., {256, []}]}") { should eq(
|
80
|
-
Erlang::ETF::SmallTuple.new([
|
81
|
-
Erlang::ETF::SmallAtom.new("bert"),
|
82
|
-
Erlang::ETF::SmallAtom.new("dict"),
|
83
|
-
Erlang::ETF::List.new(elements)
|
84
|
-
])
|
85
|
-
) }
|
86
|
-
end
|
87
|
-
end
|
88
|
-
end
|
89
|
-
|
90
|
-
end
|