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,60 +0,0 @@
|
|
1
|
-
# encoding: utf-8
|
2
|
-
|
3
|
-
require 'spec_helper'
|
4
|
-
|
5
|
-
describe Erlang::ETF::NewReference do
|
6
|
-
let(:term_class) { Erlang::ETF::NewReference }
|
7
|
-
|
8
|
-
let(:node) { Erlang::ETF::Atom.new("node@host").tap(&:serialize) }
|
9
|
-
let(:ids) { [1234, 5678] }
|
10
|
-
let(:creation) { 1 }
|
11
|
-
|
12
|
-
describe '[class]' do
|
13
|
-
describe 'deserialize' do
|
14
|
-
let(:buffer) { StringIO.new(bytes.pack('C*')) }
|
15
|
-
subject { term_class.deserialize(buffer) }
|
16
|
-
|
17
|
-
let(:bytes) { [0, 2, 100, 0, 9, 110, 111, 100, 101, 64, 104, 111, 115, 116, 1, 0, 0, 4, 210, 0, 0, 22, 46] }
|
18
|
-
|
19
|
-
its(:node) { should eq(node) }
|
20
|
-
its(:len) { should eq(2) }
|
21
|
-
its(:creation) { should eq(creation) }
|
22
|
-
its(:ids) { should eq(ids) }
|
23
|
-
end
|
24
|
-
|
25
|
-
describe 'new' do
|
26
|
-
subject { term_class.new(node, creation, ids) }
|
27
|
-
|
28
|
-
its(:node) { should eq(node) }
|
29
|
-
its(:len) { should eq(2) }
|
30
|
-
its(:creation) { should eq(creation) }
|
31
|
-
its(:ids) { should eq(ids) }
|
32
|
-
end
|
33
|
-
end
|
34
|
-
|
35
|
-
describe '[instance]' do
|
36
|
-
let(:term) { term_class.new(node, creation, ids) }
|
37
|
-
|
38
|
-
describe 'serialize' do
|
39
|
-
subject { term.serialize }
|
40
|
-
|
41
|
-
let(:bytes) { [114, 0, 2, 100, 0, 9, 110, 111, 100, 101, 64, 104, 111, 115, 116, 1, 0, 0, 4, 210, 0, 0, 22, 46].pack('C*') }
|
42
|
-
|
43
|
-
it { should eq(bytes) }
|
44
|
-
end
|
45
|
-
|
46
|
-
describe '__erlang_type__' do
|
47
|
-
subject { term.__erlang_type__ }
|
48
|
-
|
49
|
-
it { should eq(:new_reference) }
|
50
|
-
end
|
51
|
-
|
52
|
-
describe '__ruby_evolve__' do
|
53
|
-
let(:ruby_obj) { term }
|
54
|
-
subject { term.__ruby_evolve__ }
|
55
|
-
|
56
|
-
it { should eq(ruby_obj) }
|
57
|
-
end
|
58
|
-
end
|
59
|
-
|
60
|
-
end
|
data/spec/erlang/etf/nil_spec.rb
DELETED
@@ -1,50 +0,0 @@
|
|
1
|
-
# encoding: utf-8
|
2
|
-
|
3
|
-
require 'spec_helper'
|
4
|
-
|
5
|
-
describe Erlang::ETF::Nil do
|
6
|
-
let(:term_class) { Erlang::ETF::Nil }
|
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(:bytes) { [] }
|
14
|
-
|
15
|
-
it { should eq(term_class.new) }
|
16
|
-
end
|
17
|
-
|
18
|
-
describe 'new' do
|
19
|
-
subject { term_class.new }
|
20
|
-
|
21
|
-
it { should eq(term_class.new) }
|
22
|
-
end
|
23
|
-
end
|
24
|
-
|
25
|
-
describe '[instance]' do
|
26
|
-
let(:term) { term_class.new }
|
27
|
-
|
28
|
-
describe 'serialize' do
|
29
|
-
subject { term.serialize }
|
30
|
-
|
31
|
-
let(:bytes) { [106].pack('C*') }
|
32
|
-
|
33
|
-
it { should eq(bytes) }
|
34
|
-
end
|
35
|
-
|
36
|
-
describe '__erlang_type__' do
|
37
|
-
subject { term.__erlang_type__ }
|
38
|
-
|
39
|
-
it { should eq(:nil) }
|
40
|
-
end
|
41
|
-
|
42
|
-
describe '__ruby_evolve__' do
|
43
|
-
let(:ruby_obj) { [] }
|
44
|
-
subject { term.__ruby_evolve__ }
|
45
|
-
|
46
|
-
it { should eq(ruby_obj) }
|
47
|
-
end
|
48
|
-
end
|
49
|
-
|
50
|
-
end
|
data/spec/erlang/etf/pid_spec.rb
DELETED
@@ -1,61 +0,0 @@
|
|
1
|
-
# encoding: utf-8
|
2
|
-
|
3
|
-
require 'spec_helper'
|
4
|
-
|
5
|
-
describe Erlang::ETF::Pid do
|
6
|
-
let(:term_class) { Erlang::ETF::Pid }
|
7
|
-
|
8
|
-
let(:node) { Erlang::ETF::Atom.new("node@host").tap(&:serialize) }
|
9
|
-
let(:id) { 1234 }
|
10
|
-
let(:serial) { 13 }
|
11
|
-
let(:creation) { 1 }
|
12
|
-
|
13
|
-
describe '[class]' do
|
14
|
-
describe 'deserialize' do
|
15
|
-
let(:buffer) { StringIO.new(bytes.pack('C*')) }
|
16
|
-
subject { term_class.deserialize(buffer) }
|
17
|
-
|
18
|
-
let(:bytes) { [100, 0, 9, 110, 111, 100, 101, 64, 104, 111, 115, 116, 0, 0, 4, 210, 0, 0, 0, 13, 1] }
|
19
|
-
|
20
|
-
its(:node) { should eq(node) }
|
21
|
-
its(:id) { should eq(id) }
|
22
|
-
its(:serial) { should eq(serial) }
|
23
|
-
its(:creation) { should eq(creation) }
|
24
|
-
end
|
25
|
-
|
26
|
-
describe 'new' do
|
27
|
-
subject { term_class.new(node, id, serial, creation) }
|
28
|
-
|
29
|
-
its(:node) { should eq(node) }
|
30
|
-
its(:id) { should eq(id) }
|
31
|
-
its(:serial) { should eq(serial) }
|
32
|
-
its(:creation) { should eq(creation) }
|
33
|
-
end
|
34
|
-
end
|
35
|
-
|
36
|
-
describe '[instance]' do
|
37
|
-
let(:term) { term_class.new(node, id, serial, creation) }
|
38
|
-
|
39
|
-
describe 'serialize' do
|
40
|
-
subject { term.serialize }
|
41
|
-
|
42
|
-
let(:bytes) { [103, 100, 0, 9, 110, 111, 100, 101, 64, 104, 111, 115, 116, 0, 0, 4, 210, 0, 0, 0, 13, 1].pack('C*') }
|
43
|
-
|
44
|
-
it { should eq(bytes) }
|
45
|
-
end
|
46
|
-
|
47
|
-
describe '__erlang_type__' do
|
48
|
-
subject { term.__erlang_type__ }
|
49
|
-
|
50
|
-
it { should eq(:pid) }
|
51
|
-
end
|
52
|
-
|
53
|
-
describe '__ruby_evolve__' do
|
54
|
-
let(:ruby_obj) { ::Erlang::Pid.new(:'node@host', 1234, 13, 1) }
|
55
|
-
subject { term.__ruby_evolve__ }
|
56
|
-
|
57
|
-
it { should eq(ruby_obj) }
|
58
|
-
end
|
59
|
-
end
|
60
|
-
|
61
|
-
end
|
@@ -1,58 +0,0 @@
|
|
1
|
-
# encoding: utf-8
|
2
|
-
|
3
|
-
require 'spec_helper'
|
4
|
-
|
5
|
-
describe Erlang::ETF::Port do
|
6
|
-
let(:term_class) { Erlang::ETF::Port }
|
7
|
-
|
8
|
-
let(:node) { Erlang::ETF::Atom.new("node@host").tap(&:serialize) }
|
9
|
-
let(:id) { 1234 }
|
10
|
-
let(:creation) { 1 }
|
11
|
-
|
12
|
-
describe '[class]' do
|
13
|
-
describe 'deserialize' do
|
14
|
-
let(:buffer) { StringIO.new(bytes.pack('C*')) }
|
15
|
-
subject { term_class.deserialize(buffer) }
|
16
|
-
|
17
|
-
let(:bytes) { [100, 0, 9, 110, 111, 100, 101, 64, 104, 111, 115, 116, 0, 0, 4, 210, 1] }
|
18
|
-
|
19
|
-
its(:node) { should eq(node) }
|
20
|
-
its(:id) { should eq(id) }
|
21
|
-
its(:creation) { should eq(creation) }
|
22
|
-
end
|
23
|
-
|
24
|
-
describe 'new' do
|
25
|
-
subject { term_class.new(node, id, creation) }
|
26
|
-
|
27
|
-
its(:node) { should eq(node) }
|
28
|
-
its(:id) { should eq(id) }
|
29
|
-
its(:creation) { should eq(creation) }
|
30
|
-
end
|
31
|
-
end
|
32
|
-
|
33
|
-
describe '[instance]' do
|
34
|
-
let(:term) { term_class.new(node, id, creation) }
|
35
|
-
|
36
|
-
describe 'serialize' do
|
37
|
-
subject { term.serialize }
|
38
|
-
|
39
|
-
let(:bytes) { [102, 100, 0, 9, 110, 111, 100, 101, 64, 104, 111, 115, 116, 0, 0, 4, 210, 1].pack('C*') }
|
40
|
-
|
41
|
-
it { should eq(bytes) }
|
42
|
-
end
|
43
|
-
|
44
|
-
describe '__erlang_type__' do
|
45
|
-
subject { term.__erlang_type__ }
|
46
|
-
|
47
|
-
it { should eq(:port) }
|
48
|
-
end
|
49
|
-
|
50
|
-
describe '__ruby_evolve__' do
|
51
|
-
let(:ruby_obj) { term }
|
52
|
-
subject { term.__ruby_evolve__ }
|
53
|
-
|
54
|
-
it { should eq(ruby_obj) }
|
55
|
-
end
|
56
|
-
end
|
57
|
-
|
58
|
-
end
|
@@ -1,58 +0,0 @@
|
|
1
|
-
# encoding: utf-8
|
2
|
-
|
3
|
-
require 'spec_helper'
|
4
|
-
|
5
|
-
describe Erlang::ETF::Reference do
|
6
|
-
let(:term_class) { Erlang::ETF::Reference }
|
7
|
-
|
8
|
-
let(:node) { Erlang::ETF::Atom.new("node@host").tap(&:serialize) }
|
9
|
-
let(:id) { 1234 }
|
10
|
-
let(:creation) { 1 }
|
11
|
-
|
12
|
-
describe '[class]' do
|
13
|
-
describe 'deserialize' do
|
14
|
-
let(:buffer) { StringIO.new(bytes.pack('C*')) }
|
15
|
-
subject { term_class.deserialize(buffer) }
|
16
|
-
|
17
|
-
let(:bytes) { [100, 0, 9, 110, 111, 100, 101, 64, 104, 111, 115, 116, 0, 0, 4, 210, 1] }
|
18
|
-
|
19
|
-
its(:node) { should eq(node) }
|
20
|
-
its(:id) { should eq(id) }
|
21
|
-
its(:creation) { should eq(creation) }
|
22
|
-
end
|
23
|
-
|
24
|
-
describe 'new' do
|
25
|
-
subject { term_class.new(node, id, creation) }
|
26
|
-
|
27
|
-
its(:node) { should eq(node) }
|
28
|
-
its(:id) { should eq(id) }
|
29
|
-
its(:creation) { should eq(creation) }
|
30
|
-
end
|
31
|
-
end
|
32
|
-
|
33
|
-
describe '[instance]' do
|
34
|
-
let(:term) { term_class.new(node, id, creation) }
|
35
|
-
|
36
|
-
describe 'serialize' do
|
37
|
-
subject { term.serialize }
|
38
|
-
|
39
|
-
let(:bytes) { [101, 100, 0, 9, 110, 111, 100, 101, 64, 104, 111, 115, 116, 0, 0, 4, 210, 1].pack('C*') }
|
40
|
-
|
41
|
-
it { should eq(bytes) }
|
42
|
-
end
|
43
|
-
|
44
|
-
describe '__erlang_type__' do
|
45
|
-
subject { term.__erlang_type__ }
|
46
|
-
|
47
|
-
it { should eq(:reference) }
|
48
|
-
end
|
49
|
-
|
50
|
-
describe '__ruby_evolve__' do
|
51
|
-
let(:ruby_obj) { term }
|
52
|
-
subject { term.__ruby_evolve__ }
|
53
|
-
|
54
|
-
it { should eq(ruby_obj) }
|
55
|
-
end
|
56
|
-
end
|
57
|
-
|
58
|
-
end
|
@@ -1,90 +0,0 @@
|
|
1
|
-
# encoding: utf-8
|
2
|
-
|
3
|
-
require 'spec_helper'
|
4
|
-
|
5
|
-
describe Erlang::ETF::SmallAtom do
|
6
|
-
let(:term_class) { Erlang::ETF::SmallAtom }
|
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 "ASCII bytes" do
|
14
|
-
let(:bytes) { [4, 116, 101, 115, 116] }
|
15
|
-
|
16
|
-
its(:len) { should eq(4) }
|
17
|
-
its(:atom_name) { should eq("test") }
|
18
|
-
end
|
19
|
-
|
20
|
-
context "UTF-8 bytes" do
|
21
|
-
let(:bytes) { [2, 206, 169] }
|
22
|
-
|
23
|
-
its(:len) { should eq(2) }
|
24
|
-
its(:atom_name) { should eq("Ω") }
|
25
|
-
end
|
26
|
-
end
|
27
|
-
|
28
|
-
describe 'new' do
|
29
|
-
subject { term_class.new(atom_name) }
|
30
|
-
|
31
|
-
context "ASCII" do
|
32
|
-
let(:atom_name) { "test" }
|
33
|
-
|
34
|
-
its(:atom_name) { should eq(atom_name) }
|
35
|
-
end
|
36
|
-
|
37
|
-
context "UTF-8" do
|
38
|
-
let(:atom_name) { "Ω" }
|
39
|
-
|
40
|
-
its(:atom_name) { should eq(atom_name) }
|
41
|
-
end
|
42
|
-
end
|
43
|
-
end
|
44
|
-
|
45
|
-
describe '[instance]' do
|
46
|
-
let(:term) { term_class.new(atom_name) }
|
47
|
-
|
48
|
-
describe 'serialize' do
|
49
|
-
subject { term.serialize }
|
50
|
-
|
51
|
-
context "ASCII" do
|
52
|
-
let(:atom_name) { "test" }
|
53
|
-
let(:bytes) { [115, 4, 116, 101, 115, 116].pack('C*') }
|
54
|
-
|
55
|
-
it { should eq(bytes) }
|
56
|
-
end
|
57
|
-
|
58
|
-
context "UTF-8" do
|
59
|
-
let(:atom_name) { "Ω" }
|
60
|
-
let(:bytes) { [115, 2, 206, 169].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(:atom_name) { "test" }
|
70
|
-
it { should eq(:small_atom) }
|
71
|
-
end
|
72
|
-
|
73
|
-
describe '__ruby_evolve__' do
|
74
|
-
subject { term.__ruby_evolve__ }
|
75
|
-
|
76
|
-
context "ASCII" do
|
77
|
-
let(:atom_name) { "test" }
|
78
|
-
|
79
|
-
it { should eq(:test) }
|
80
|
-
end
|
81
|
-
|
82
|
-
context "UTF-8" do
|
83
|
-
let(:atom_name) { "Ω" }
|
84
|
-
|
85
|
-
it { should eq(:'Ω') }
|
86
|
-
end
|
87
|
-
end
|
88
|
-
end
|
89
|
-
|
90
|
-
end
|
@@ -1,90 +0,0 @@
|
|
1
|
-
# encoding: utf-8
|
2
|
-
|
3
|
-
require 'spec_helper'
|
4
|
-
|
5
|
-
describe Erlang::ETF::SmallAtomUTF8 do
|
6
|
-
let(:term_class) { Erlang::ETF::SmallAtomUTF8 }
|
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 "ASCII bytes" do
|
14
|
-
let(:bytes) { [4, 116, 101, 115, 116] }
|
15
|
-
|
16
|
-
its(:len) { should eq(4) }
|
17
|
-
its(:atom_name) { should eq("test") }
|
18
|
-
end
|
19
|
-
|
20
|
-
context "UTF-8 bytes" do
|
21
|
-
let(:bytes) { [2, 206, 169] }
|
22
|
-
|
23
|
-
its(:len) { should eq(2) }
|
24
|
-
its(:atom_name) { should eq("Ω") }
|
25
|
-
end
|
26
|
-
end
|
27
|
-
|
28
|
-
describe 'new' do
|
29
|
-
subject { term_class.new(atom_name) }
|
30
|
-
|
31
|
-
context "ASCII" do
|
32
|
-
let(:atom_name) { "test" }
|
33
|
-
|
34
|
-
its(:atom_name) { should eq(atom_name) }
|
35
|
-
end
|
36
|
-
|
37
|
-
context "UTF-8" do
|
38
|
-
let(:atom_name) { "Ω" }
|
39
|
-
|
40
|
-
its(:atom_name) { should eq(atom_name) }
|
41
|
-
end
|
42
|
-
end
|
43
|
-
end
|
44
|
-
|
45
|
-
describe '[instance]' do
|
46
|
-
let(:term) { term_class.new(atom_name) }
|
47
|
-
|
48
|
-
describe 'serialize' do
|
49
|
-
subject { term.serialize }
|
50
|
-
|
51
|
-
context "ASCII" do
|
52
|
-
let(:atom_name) { "test" }
|
53
|
-
let(:bytes) { [119, 4, 116, 101, 115, 116].pack('C*') }
|
54
|
-
|
55
|
-
it { should eq(bytes) }
|
56
|
-
end
|
57
|
-
|
58
|
-
context "UTF-8" do
|
59
|
-
let(:atom_name) { "Ω" }
|
60
|
-
let(:bytes) { [119, 2, 206, 169].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(:atom_name) { "Ω" }
|
70
|
-
it { should eq(:small_atom_utf8) }
|
71
|
-
end
|
72
|
-
|
73
|
-
describe '__ruby_evolve__' do
|
74
|
-
subject { term.__ruby_evolve__ }
|
75
|
-
|
76
|
-
context "ASCII" do
|
77
|
-
let(:atom_name) { "test" }
|
78
|
-
|
79
|
-
it { should eq(:test) }
|
80
|
-
end
|
81
|
-
|
82
|
-
context "UTF-8" do
|
83
|
-
let(:atom_name) { "Ω" }
|
84
|
-
|
85
|
-
it { should eq(:'Ω') }
|
86
|
-
end
|
87
|
-
end
|
88
|
-
end
|
89
|
-
|
90
|
-
end
|