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,32 +0,0 @@
|
|
1
|
-
# encoding: utf-8
|
2
|
-
|
3
|
-
require 'spec_helper'
|
4
|
-
|
5
|
-
describe Erlang::ETF::Extensions::Time do
|
6
|
-
let(:klass) { ::Time }
|
7
|
-
|
8
|
-
describe '[instance]' do
|
9
|
-
let(:instance) { klass.at(1363190400) }
|
10
|
-
|
11
|
-
describe '__erlang_type__' do
|
12
|
-
subject { instance.__erlang_type__ }
|
13
|
-
|
14
|
-
it { should eq(:bert_time) }
|
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("time"),
|
24
|
-
Erlang::ETF::Integer.new(1363),
|
25
|
-
Erlang::ETF::Integer.new(190400),
|
26
|
-
Erlang::ETF::SmallInteger.new(0)
|
27
|
-
])
|
28
|
-
) }
|
29
|
-
end
|
30
|
-
end
|
31
|
-
|
32
|
-
end
|
@@ -1,29 +0,0 @@
|
|
1
|
-
# encoding: utf-8
|
2
|
-
|
3
|
-
require 'spec_helper'
|
4
|
-
|
5
|
-
describe Erlang::ETF::Extensions::TrueClass do
|
6
|
-
let(:klass) { ::TrueClass }
|
7
|
-
|
8
|
-
describe '[instance]' do
|
9
|
-
let(:instance) { true }
|
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("true")
|
24
|
-
])
|
25
|
-
) }
|
26
|
-
end
|
27
|
-
end
|
28
|
-
|
29
|
-
end
|
@@ -1,92 +0,0 @@
|
|
1
|
-
# encoding: utf-8
|
2
|
-
|
3
|
-
require 'spec_helper'
|
4
|
-
|
5
|
-
describe Erlang::ETF::Float do
|
6
|
-
let(:term_class) { Erlang::ETF::Float }
|
7
|
-
|
8
|
-
describe '[class]' do
|
9
|
-
describe 'deserialize' do
|
10
|
-
let(:buffer) { StringIO.new(bytes.pack('C*')) }
|
11
|
-
subject { term_class.deserialize(buffer) }
|
12
|
-
|
13
|
-
context 'with 2 significant digits' do
|
14
|
-
let(:float_string) { "1.10000000000000000000e+00\0\0\0\0\0" }
|
15
|
-
let(:bytes) { [49, 46, 49, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 101, 43, 48, 48, 0, 0, 0, 0, 0] }
|
16
|
-
|
17
|
-
its(:float_string) { should eq(float_string) }
|
18
|
-
end
|
19
|
-
|
20
|
-
context 'with 21 significant digits' do
|
21
|
-
let(:float_string) { "1.12233445566778899001e-03\0\0\0\0\0" }
|
22
|
-
let(:bytes) { [49, 46, 49, 50, 50, 51, 51, 52, 52, 53, 53, 54, 54, 55, 55, 56, 56, 57, 57, 48, 48, 49, 101, 45, 48, 51, 0, 0, 0, 0, 0] }
|
23
|
-
|
24
|
-
its(:float_string) { should eq(float_string) }
|
25
|
-
end
|
26
|
-
end
|
27
|
-
|
28
|
-
describe 'new' do
|
29
|
-
subject { term_class.new(float_string) }
|
30
|
-
|
31
|
-
context 'with 2 significant digits as BigDecimal' do
|
32
|
-
let(:float_string) { BigDecimal.new("-1.1") }
|
33
|
-
|
34
|
-
its(:float_string) { should eq(float_string) }
|
35
|
-
end
|
36
|
-
|
37
|
-
context 'with 21 significant digits as String' do
|
38
|
-
let(:float_string) { "1.12233445566778899001e-03\0\0\0\0\0" }
|
39
|
-
|
40
|
-
its(:float_string) { should eq(float_string) }
|
41
|
-
end
|
42
|
-
end
|
43
|
-
end
|
44
|
-
|
45
|
-
describe '[instance]' do
|
46
|
-
let(:term) { term_class.new(float_string) }
|
47
|
-
|
48
|
-
describe 'serialize' do
|
49
|
-
subject { term.serialize }
|
50
|
-
|
51
|
-
context 'with 2 significant digits as BigDecimal' do
|
52
|
-
let(:float_string) { BigDecimal.new("-1.1") }
|
53
|
-
let(:bytes) { [99, 45, 49, 46, 49, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 56, 56, 56, 50, 101, 43, 48, 48, 0, 0, 0, 0].pack('C*') }
|
54
|
-
|
55
|
-
it { should eq(bytes) }
|
56
|
-
end
|
57
|
-
|
58
|
-
context 'with 21 significant digits as String' do
|
59
|
-
let(:float_string) { "1.12233445566778899001e-03\0\0\0\0\0" }
|
60
|
-
let(:bytes) { [99, 49, 46, 49, 50, 50, 51, 51, 52, 52, 53, 53, 54, 54, 55, 55, 56, 56, 57, 57, 48, 48, 49, 101, 45, 48, 51, 0, 0, 0, 0, 0].pack('C*') }
|
61
|
-
|
62
|
-
it { should eq(bytes) }
|
63
|
-
end
|
64
|
-
end
|
65
|
-
|
66
|
-
describe '__erlang_type__' do
|
67
|
-
subject { term.__erlang_type__ }
|
68
|
-
|
69
|
-
let(:float_string) { BigDecimal.new("1.1") }
|
70
|
-
it { should eq(:float) }
|
71
|
-
end
|
72
|
-
|
73
|
-
describe '__ruby_evolve__' do
|
74
|
-
subject { term.__ruby_evolve__ }
|
75
|
-
|
76
|
-
context 'with 2 significant digits as BigDecimal' do
|
77
|
-
let(:ruby_obj) { BigDecimal.new("1.1") }
|
78
|
-
let(:float_string) { BigDecimal.new("1.1") }
|
79
|
-
|
80
|
-
it { should eq(ruby_obj) }
|
81
|
-
end
|
82
|
-
|
83
|
-
context 'with 21 significant digits as String' do
|
84
|
-
let(:ruby_obj) { BigDecimal.new("0.00112233445566778899001") }
|
85
|
-
let(:float_string) { "1.12233445566778899001e-03\0\0\0\0\0" }
|
86
|
-
|
87
|
-
it { should eq(ruby_obj) }
|
88
|
-
end
|
89
|
-
end
|
90
|
-
end
|
91
|
-
|
92
|
-
end
|
data/spec/erlang/etf/fun_spec.rb
DELETED
@@ -1,132 +0,0 @@
|
|
1
|
-
# encoding: utf-8
|
2
|
-
|
3
|
-
require 'spec_helper'
|
4
|
-
|
5
|
-
describe Erlang::ETF::Fun do
|
6
|
-
let(:term_class) { Erlang::ETF::Fun }
|
7
|
-
|
8
|
-
let(:pid) { Erlang::ETF::Pid.new(Erlang::ETF::Atom.new("nonode@nohost"), 2, 0, 0) }
|
9
|
-
let(:mod) { Erlang::ETF::Atom.new("erl_eval") }
|
10
|
-
let(:index) { Erlang::ETF::SmallInteger.new(6) }
|
11
|
-
let(:uniq) { Erlang::ETF::Integer.new(17052888) }
|
12
|
-
let(:free_vars) {
|
13
|
-
[
|
14
|
-
Erlang::ETF::Nil.new,
|
15
|
-
Erlang::ETF::Atom.new("none"),
|
16
|
-
Erlang::ETF::Atom.new("none"),
|
17
|
-
Erlang::ETF::List.new([
|
18
|
-
Erlang::ETF::SmallTuple.new([
|
19
|
-
Erlang::ETF::Atom.new("clause"),
|
20
|
-
Erlang::ETF::SmallInteger.new(1),
|
21
|
-
Erlang::ETF::List.new([
|
22
|
-
Erlang::ETF::SmallTuple.new([
|
23
|
-
Erlang::ETF::Atom.new("atom"),
|
24
|
-
Erlang::ETF::SmallInteger.new(1),
|
25
|
-
Erlang::ETF::Atom.new("a")
|
26
|
-
])
|
27
|
-
]),
|
28
|
-
Erlang::ETF::Nil.new,
|
29
|
-
Erlang::ETF::List.new([
|
30
|
-
Erlang::ETF::SmallTuple.new([
|
31
|
-
Erlang::ETF::Atom.new("atom"),
|
32
|
-
Erlang::ETF::SmallInteger.new(1),
|
33
|
-
Erlang::ETF::Atom.new("true")
|
34
|
-
])
|
35
|
-
])
|
36
|
-
]),
|
37
|
-
Erlang::ETF::SmallTuple.new([
|
38
|
-
Erlang::ETF::Atom.new("clause"),
|
39
|
-
Erlang::ETF::SmallInteger.new(1),
|
40
|
-
Erlang::ETF::List.new([
|
41
|
-
Erlang::ETF::SmallTuple.new([
|
42
|
-
Erlang::ETF::Atom.new("var"),
|
43
|
-
Erlang::ETF::SmallInteger.new(1),
|
44
|
-
Erlang::ETF::Atom.new("_")
|
45
|
-
])
|
46
|
-
]),
|
47
|
-
Erlang::ETF::Nil.new,
|
48
|
-
Erlang::ETF::List.new([
|
49
|
-
Erlang::ETF::SmallTuple.new([
|
50
|
-
Erlang::ETF::Atom.new("atom"),
|
51
|
-
Erlang::ETF::SmallInteger.new(1),
|
52
|
-
Erlang::ETF::Atom.new("false")
|
53
|
-
])
|
54
|
-
])
|
55
|
-
])
|
56
|
-
])
|
57
|
-
]
|
58
|
-
}
|
59
|
-
|
60
|
-
describe '[class]' do
|
61
|
-
describe 'deserialize' do
|
62
|
-
let(:buffer) { StringIO.new(bytes.pack('C*')) }
|
63
|
-
subject { term_class.deserialize(buffer) }
|
64
|
-
|
65
|
-
# this has actually been deprecated since R10B, but here's the spec anyway
|
66
|
-
#
|
67
|
-
let(:bytes) { [
|
68
|
-
0,4,103,100,0,13,110,111,110,111,100,101,64,110,111,104,111,115,116,
|
69
|
-
0,0,0,2,0,0,0,0,0,100,0,8,101,114,108,95,101,118,97,108,97,6,98,1,4,52,216,
|
70
|
-
106,100,0,4,110,111,110,101,100,0,4,110,111,110,101,108,0,0,0,2,104,5,100,0,
|
71
|
-
6,99,108,97,117,115,101,97,1,108,0,0,0,1,104,3,100,0,4,97,116,111,109,97,1,
|
72
|
-
100,0,1,97,106,106,108,0,0,0,1,104,3,100,0,4,97,116,111,109,97,1,100,0,4,116,
|
73
|
-
114,117,101,106,104,5,100,0,6,99,108,97,117,115,101,97,1,108,0,0,0,1,104,3,
|
74
|
-
100,0,3,118,97,114,97,1,100,0,1,95,106,106,108,0,0,0,1,104,3,100,0,4,97,116,
|
75
|
-
111,109,97,1,100,0,5,102,97,108,115,101,106,106
|
76
|
-
] }
|
77
|
-
|
78
|
-
its(:num_free) { should eq(4) }
|
79
|
-
its(:pid) { should eq(pid) }
|
80
|
-
its(:mod) { should eq(mod) }
|
81
|
-
its(:index) { should eq(index) }
|
82
|
-
its(:uniq) { should eq(uniq) }
|
83
|
-
its(:free_vars) { should eq(free_vars) }
|
84
|
-
end
|
85
|
-
|
86
|
-
describe 'new' do
|
87
|
-
subject { term_class.new(pid, mod, index, uniq, free_vars) }
|
88
|
-
|
89
|
-
its(:num_free) { should eq(4) }
|
90
|
-
its(:pid) { should eq(pid) }
|
91
|
-
its(:mod) { should eq(mod) }
|
92
|
-
its(:index) { should eq(index) }
|
93
|
-
its(:uniq) { should eq(uniq) }
|
94
|
-
its(:free_vars) { should eq(free_vars) }
|
95
|
-
end
|
96
|
-
end
|
97
|
-
|
98
|
-
describe '[instance]' do
|
99
|
-
let(:term) { term_class.new(pid, mod, index, uniq, free_vars) }
|
100
|
-
|
101
|
-
describe 'serialize' do
|
102
|
-
subject { term.serialize }
|
103
|
-
|
104
|
-
let(:bytes) { [
|
105
|
-
117,0,4,103,100,0,13,110,111,110,111,100,101,64,110,111,104,111,115,116,
|
106
|
-
0,0,0,2,0,0,0,0,0,100,0,8,101,114,108,95,101,118,97,108,97,6,98,1,4,52,216,
|
107
|
-
106,100,0,4,110,111,110,101,100,0,4,110,111,110,101,108,0,0,0,2,104,5,100,0,
|
108
|
-
6,99,108,97,117,115,101,97,1,108,0,0,0,1,104,3,100,0,4,97,116,111,109,97,1,
|
109
|
-
100,0,1,97,106,106,108,0,0,0,1,104,3,100,0,4,97,116,111,109,97,1,100,0,4,116,
|
110
|
-
114,117,101,106,104,5,100,0,6,99,108,97,117,115,101,97,1,108,0,0,0,1,104,3,
|
111
|
-
100,0,3,118,97,114,97,1,100,0,1,95,106,106,108,0,0,0,1,104,3,100,0,4,97,116,
|
112
|
-
111,109,97,1,100,0,5,102,97,108,115,101,106,106
|
113
|
-
].pack('C*') }
|
114
|
-
|
115
|
-
it { should eq(bytes) }
|
116
|
-
end
|
117
|
-
|
118
|
-
describe '__erlang_type__' do
|
119
|
-
subject { term.__erlang_type__ }
|
120
|
-
|
121
|
-
it { should eq(:fun) }
|
122
|
-
end
|
123
|
-
|
124
|
-
describe '__ruby_evolve__' do
|
125
|
-
let(:ruby_obj) { term }
|
126
|
-
subject { term.__ruby_evolve__ }
|
127
|
-
|
128
|
-
it { should eq(ruby_obj) }
|
129
|
-
end
|
130
|
-
end
|
131
|
-
|
132
|
-
end
|
@@ -1,57 +0,0 @@
|
|
1
|
-
# encoding: utf-8
|
2
|
-
|
3
|
-
require 'spec_helper'
|
4
|
-
|
5
|
-
describe Erlang::ETF::Integer do
|
6
|
-
let(:term_class) { Erlang::ETF::Integer }
|
7
|
-
|
8
|
-
describe '[class]' do
|
9
|
-
describe 'deserialize' do
|
10
|
-
let(:buffer) { StringIO.new(bytes.pack('C*')) }
|
11
|
-
subject { term_class.deserialize(buffer) }
|
12
|
-
|
13
|
-
let(:int) { 3_13_1988 }
|
14
|
-
let(:bytes) { [0, 47, 202, 84] }
|
15
|
-
|
16
|
-
its(:int) { should eq(int) }
|
17
|
-
end
|
18
|
-
|
19
|
-
describe 'new' do
|
20
|
-
subject { term_class.new(int) }
|
21
|
-
|
22
|
-
let(:int) { 3_13_1988 }
|
23
|
-
|
24
|
-
its(:int) { should eq(int) }
|
25
|
-
end
|
26
|
-
end
|
27
|
-
|
28
|
-
describe '[instance]' do
|
29
|
-
let(:term) { term_class.new(int) }
|
30
|
-
|
31
|
-
describe 'serialize' do
|
32
|
-
subject { term.serialize }
|
33
|
-
|
34
|
-
let(:int) { 3_13_1988 }
|
35
|
-
let(:bytes) { [98, 0, 47, 202, 84].pack('C*') }
|
36
|
-
|
37
|
-
it { should eq(bytes) }
|
38
|
-
end
|
39
|
-
|
40
|
-
describe '__erlang_type__' do
|
41
|
-
subject { term.__erlang_type__ }
|
42
|
-
|
43
|
-
let(:int) { 3_13_1988 }
|
44
|
-
it { should eq(:integer) }
|
45
|
-
end
|
46
|
-
|
47
|
-
describe '__ruby_evolve__' do
|
48
|
-
subject { term.__ruby_evolve__ }
|
49
|
-
|
50
|
-
let(:ruby_obj) { 3_13_1988 }
|
51
|
-
let(:int) { 3_13_1988 }
|
52
|
-
|
53
|
-
it { should eq(ruby_obj) }
|
54
|
-
end
|
55
|
-
end
|
56
|
-
|
57
|
-
end
|
@@ -1,67 +0,0 @@
|
|
1
|
-
# encoding: utf-8
|
2
|
-
|
3
|
-
require 'spec_helper'
|
4
|
-
|
5
|
-
describe Erlang::ETF::LargeBig do
|
6
|
-
let(:term_class) { Erlang::ETF::LargeBig }
|
7
|
-
|
8
|
-
describe '[class]' do
|
9
|
-
describe 'deserialize' do
|
10
|
-
let(:buffer) { StringIO.new(bytes.pack('C*')) }
|
11
|
-
subject { term_class.deserialize(buffer) }
|
12
|
-
|
13
|
-
let(:n) { 256 }
|
14
|
-
let(:sign) { 0 }
|
15
|
-
let(:integer) { (+1 << (256 * 8)) - 1 }
|
16
|
-
let(:bytes) { [0, 0, 1, 0, 0, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255] }
|
17
|
-
|
18
|
-
its(:n) { should eq(n) }
|
19
|
-
its(:sign) { should eq(sign) }
|
20
|
-
its(:integer) { should eq(integer) }
|
21
|
-
end
|
22
|
-
|
23
|
-
describe 'new' do
|
24
|
-
subject { term_class.new(integer).tap(&:serialize) }
|
25
|
-
|
26
|
-
let(:n) { 256 }
|
27
|
-
let(:sign) { 1 }
|
28
|
-
let(:integer) { (-1 << (256 * 8)) + 1 }
|
29
|
-
|
30
|
-
its(:n) { should eq(n) }
|
31
|
-
its(:sign) { should eq(sign) }
|
32
|
-
its(:integer) { should eq(integer) }
|
33
|
-
end
|
34
|
-
end
|
35
|
-
|
36
|
-
describe '[instance]' do
|
37
|
-
let(:term) { term_class.new(integer) }
|
38
|
-
|
39
|
-
describe 'serialize' do
|
40
|
-
subject { term.serialize }
|
41
|
-
|
42
|
-
let(:n) { 256 }
|
43
|
-
let(:sign) { 1 }
|
44
|
-
let(:integer) { (-1 << (256 * 8)) + 1 }
|
45
|
-
let(:bytes) { [111, 0, 0, 1, 0, 1, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255].pack('C*') }
|
46
|
-
|
47
|
-
it { should eq(bytes) }
|
48
|
-
end
|
49
|
-
|
50
|
-
describe '__erlang_type__' do
|
51
|
-
subject { term.__erlang_type__ }
|
52
|
-
|
53
|
-
let(:integer) { (+1 << (256 * 8)) - 1 }
|
54
|
-
it { should eq(:large_big) }
|
55
|
-
end
|
56
|
-
|
57
|
-
describe '__ruby_evolve__' do
|
58
|
-
subject { term.__ruby_evolve__ }
|
59
|
-
|
60
|
-
let(:ruby_obj) { (+1 << (256 * 8)) - 1 }
|
61
|
-
let(:integer) { (+1 << (256 * 8)) - 1 }
|
62
|
-
|
63
|
-
it { should eq(ruby_obj) }
|
64
|
-
end
|
65
|
-
end
|
66
|
-
|
67
|
-
end
|
@@ -1,119 +0,0 @@
|
|
1
|
-
# encoding: utf-8
|
2
|
-
|
3
|
-
require 'spec_helper'
|
4
|
-
|
5
|
-
describe Erlang::ETF::LargeTuple do
|
6
|
-
let(:term_class) { Erlang::ETF::LargeTuple }
|
7
|
-
|
8
|
-
let(:atom) { Erlang::ETF::SmallAtom.new("test").tap(&:serialize) }
|
9
|
-
let(:binary) { Erlang::ETF::Binary.new("test").tap(&:serialize) }
|
10
|
-
let(:new_float) { Erlang::ETF::NewFloat.new(1.1) }
|
11
|
-
let(:small_integer) { Erlang::ETF::SmallInteger.new(13) }
|
12
|
-
let(:small_list) { Erlang::ETF::List.new([atom, binary, new_float, small_integer]) }
|
13
|
-
let(:small_tuple) { Erlang::ETF::SmallTuple.new([atom, binary, new_float, small_integer, small_list]) }
|
14
|
-
|
15
|
-
let(:erlang_nil) { Erlang::ETF::Nil.new }
|
16
|
-
|
17
|
-
describe '[class]' do
|
18
|
-
describe 'deserialize' do
|
19
|
-
let(:buffer) { StringIO.new(bytes.pack('C*')) }
|
20
|
-
subject { term_class.deserialize(buffer) }
|
21
|
-
|
22
|
-
context 'single item tuple' do
|
23
|
-
let(:bytes) { [0, 0, 0, 1, 100, 0, 1, 97] }
|
24
|
-
let(:atom_a) { Erlang::ETF::Atom.new("a").tap(&:serialize) }
|
25
|
-
|
26
|
-
its(:arity) { should eq(1) }
|
27
|
-
its(:elements) { should eq([atom_a]) }
|
28
|
-
end
|
29
|
-
|
30
|
-
context 'multiple item tuple' do
|
31
|
-
let(:bytes) { [0, 0, 0, 6, 115, 4, 116, 101, 115, 116, 109, 0, 0, 0, 4, 116, 101, 115, 116, 70, 63, 241, 153, 153, 153, 153, 153, 154, 97, 13, 104, 5, 115, 4, 116, 101, 115, 116, 109, 0, 0, 0, 4, 116, 101, 115, 116, 70, 63, 241, 153, 153, 153, 153, 153, 154, 97, 13, 108, 0, 0, 0, 4, 115, 4, 116, 101, 115, 116, 109, 0, 0, 0, 4, 116, 101, 115, 116, 70, 63, 241, 153, 153, 153, 153, 153, 154, 97, 13, 106, 108, 0, 0, 0, 4, 115, 4, 116, 101, 115, 116, 109, 0, 0, 0, 4, 116, 101, 115, 116, 70, 63, 241, 153, 153, 153, 153, 153, 154, 97, 13, 106] }
|
32
|
-
|
33
|
-
its(:arity) { should eq(6) }
|
34
|
-
its(:elements) { should eq([atom, binary, new_float, small_integer, small_tuple, small_list]) }
|
35
|
-
end
|
36
|
-
|
37
|
-
context 'very large tuple' do
|
38
|
-
let(:bytes) { [0, 0, 1, 0, 106, 106, 106, 106, 106, 106, 106, 106, 106, 106, 106, 106, 106, 106, 106, 106, 106, 106, 106, 106, 106, 106, 106, 106, 106, 106, 106, 106, 106, 106, 106, 106, 106, 106, 106, 106, 106, 106, 106, 106, 106, 106, 106, 106, 106, 106, 106, 106, 106, 106, 106, 106, 106, 106, 106, 106, 106, 106, 106, 106, 106, 106, 106, 106, 106, 106, 106, 106, 106, 106, 106, 106, 106, 106, 106, 106, 106, 106, 106, 106, 106, 106, 106, 106, 106, 106, 106, 106, 106, 106, 106, 106, 106, 106, 106, 106, 106, 106, 106, 106, 106, 106, 106, 106, 106, 106, 106, 106, 106, 106, 106, 106, 106, 106, 106, 106, 106, 106, 106, 106, 106, 106, 106, 106, 106, 106, 106, 106, 106, 106, 106, 106, 106, 106, 106, 106, 106, 106, 106, 106, 106, 106, 106, 106, 106, 106, 106, 106, 106, 106, 106, 106, 106, 106, 106, 106, 106, 106, 106, 106, 106, 106, 106, 106, 106, 106, 106, 106, 106, 106, 106, 106, 106, 106, 106, 106, 106, 106, 106, 106, 106, 106, 106, 106, 106, 106, 106, 106, 106, 106, 106, 106, 106, 106, 106, 106, 106, 106, 106, 106, 106, 106, 106, 106, 106, 106, 106, 106, 106, 106, 106, 106, 106, 106, 106, 106, 106, 106, 106, 106, 106, 106, 106, 106, 106, 106, 106, 106, 106, 106, 106, 106, 106, 106, 106, 106, 106, 106, 106, 106, 106, 106, 106, 106, 106, 106, 106, 106, 106, 106, 106, 106, 106, 106, 106, 106] }
|
39
|
-
|
40
|
-
its(:arity) { should eq(256) }
|
41
|
-
# its(:elements) { should eq([erlang_nil] * 256) }
|
42
|
-
end
|
43
|
-
end
|
44
|
-
end
|
45
|
-
|
46
|
-
describe '[instance]' do
|
47
|
-
let(:term) { term_class.new(elements) }
|
48
|
-
|
49
|
-
let(:atom_a) { Erlang::ETF::Atom.new("a").tap(&:serialize) }
|
50
|
-
|
51
|
-
describe 'serialize' do
|
52
|
-
subject { term.serialize }
|
53
|
-
|
54
|
-
context 'single item tuple' do
|
55
|
-
let(:bytes) { [105, 0, 0, 0, 1, 100, 0, 1, 97].pack('C*') }
|
56
|
-
|
57
|
-
let(:elements) { [atom_a] }
|
58
|
-
|
59
|
-
it { should eq(bytes) }
|
60
|
-
end
|
61
|
-
|
62
|
-
context 'multiple item tuple' do
|
63
|
-
let(:bytes) { [105, 0, 0, 0, 6, 115, 4, 116, 101, 115, 116, 109, 0, 0, 0, 4, 116, 101, 115, 116, 70, 63, 241, 153, 153, 153, 153, 153, 154, 97, 13, 104, 5, 115, 4, 116, 101, 115, 116, 109, 0, 0, 0, 4, 116, 101, 115, 116, 70, 63, 241, 153, 153, 153, 153, 153, 154, 97, 13, 108, 0, 0, 0, 4, 115, 4, 116, 101, 115, 116, 109, 0, 0, 0, 4, 116, 101, 115, 116, 70, 63, 241, 153, 153, 153, 153, 153, 154, 97, 13, 106, 108, 0, 0, 0, 4, 115, 4, 116, 101, 115, 116, 109, 0, 0, 0, 4, 116, 101, 115, 116, 70, 63, 241, 153, 153, 153, 153, 153, 154, 97, 13, 106].pack('C*') }
|
64
|
-
|
65
|
-
let(:elements) { [atom, binary, new_float, small_integer, small_tuple, small_list] }
|
66
|
-
|
67
|
-
it { should eq(bytes) }
|
68
|
-
end
|
69
|
-
end
|
70
|
-
|
71
|
-
describe 'serialize_header' do
|
72
|
-
subject { term.serialize_header("") }
|
73
|
-
|
74
|
-
context 'single item tuple' do
|
75
|
-
let(:bytes) { [105, 0, 0, 0, 1].pack('C*') }
|
76
|
-
|
77
|
-
let(:elements) { [atom_a] }
|
78
|
-
|
79
|
-
it { should eq(bytes) }
|
80
|
-
end
|
81
|
-
|
82
|
-
context 'multiple item tuple' do
|
83
|
-
let(:bytes) { [105, 0, 0, 0, 6].pack('C*') }
|
84
|
-
|
85
|
-
let(:elements) { [atom, binary, new_float, small_integer, small_tuple, small_list] }
|
86
|
-
|
87
|
-
it { should eq(bytes) }
|
88
|
-
end
|
89
|
-
end
|
90
|
-
|
91
|
-
describe '__erlang_type__' do
|
92
|
-
subject { term.__erlang_type__ }
|
93
|
-
|
94
|
-
let(:elements) { [atom_a] }
|
95
|
-
it { should eq(:large_tuple) }
|
96
|
-
end
|
97
|
-
|
98
|
-
describe '__ruby_evolve__' do
|
99
|
-
context 'single item tuple' do
|
100
|
-
let(:ruby_obj) { ::Erlang::Tuple[:a] }
|
101
|
-
subject { term.__ruby_evolve__ }
|
102
|
-
|
103
|
-
let(:elements) { [atom_a] }
|
104
|
-
|
105
|
-
it { should eq(ruby_obj) }
|
106
|
-
end
|
107
|
-
|
108
|
-
context 'multiple item tuple' do
|
109
|
-
let(:ruby_obj) { ::Erlang::Tuple[:test, "test", 1.1, 13, ::Erlang::Tuple[:test, "test", 1.1, 13, ::Erlang::List[:test, "test", 1.1, 13]], ::Erlang::List[:test, "test", 1.1, 13]] }
|
110
|
-
subject { term.__ruby_evolve__ }
|
111
|
-
|
112
|
-
let(:elements) { [atom, binary, new_float, small_integer, small_tuple, small_list] }
|
113
|
-
|
114
|
-
it { should eq(ruby_obj) }
|
115
|
-
end
|
116
|
-
end
|
117
|
-
end
|
118
|
-
|
119
|
-
end
|