msgpack 1.6.0 → 1.6.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (61) hide show
  1. checksums.yaml +4 -4
  2. data/ChangeLog +6 -0
  3. data/ext/java/org/msgpack/jruby/ExtensionRegistry.java +4 -9
  4. data/ext/msgpack/buffer_class.c +4 -4
  5. data/ext/msgpack/extconf.rb +3 -1
  6. data/ext/msgpack/packer.c +1 -0
  7. data/ext/msgpack/packer_class.c +5 -19
  8. data/ext/msgpack/rbinit.c +1 -1
  9. data/ext/msgpack/unpacker.c +1 -0
  10. data/ext/msgpack/unpacker_class.c +5 -7
  11. data/lib/msgpack/buffer.rb +9 -0
  12. data/lib/msgpack/packer.rb +4 -0
  13. data/lib/msgpack/unpacker.rb +4 -0
  14. data/lib/msgpack/version.rb +1 -1
  15. data/lib/msgpack.rb +1 -0
  16. data/msgpack.gemspec +5 -2
  17. metadata +18 -47
  18. data/.github/workflows/ci.yaml +0 -57
  19. data/.gitignore +0 -23
  20. data/.rubocop.yml +0 -36
  21. data/Gemfile +0 -9
  22. data/Rakefile +0 -70
  23. data/appveyor.yml +0 -18
  24. data/bench/bench.rb +0 -78
  25. data/bin/console +0 -8
  26. data/doclib/msgpack/buffer.rb +0 -193
  27. data/doclib/msgpack/core_ext.rb +0 -101
  28. data/doclib/msgpack/error.rb +0 -19
  29. data/doclib/msgpack/extension_value.rb +0 -9
  30. data/doclib/msgpack/factory.rb +0 -145
  31. data/doclib/msgpack/packer.rb +0 -209
  32. data/doclib/msgpack/time.rb +0 -22
  33. data/doclib/msgpack/timestamp.rb +0 -44
  34. data/doclib/msgpack/unpacker.rb +0 -183
  35. data/doclib/msgpack.rb +0 -87
  36. data/msgpack.org.md +0 -46
  37. data/spec/bigint_spec.rb +0 -26
  38. data/spec/cases.json +0 -1
  39. data/spec/cases.msg +0 -0
  40. data/spec/cases_compact.msg +0 -0
  41. data/spec/cases_spec.rb +0 -39
  42. data/spec/cruby/buffer_io_spec.rb +0 -255
  43. data/spec/cruby/buffer_packer.rb +0 -29
  44. data/spec/cruby/buffer_spec.rb +0 -592
  45. data/spec/cruby/buffer_unpacker.rb +0 -19
  46. data/spec/cruby/unpacker_spec.rb +0 -70
  47. data/spec/ext_value_spec.rb +0 -99
  48. data/spec/exttypes.rb +0 -51
  49. data/spec/factory_spec.rb +0 -706
  50. data/spec/format_spec.rb +0 -301
  51. data/spec/jruby/benchmarks/shootout_bm.rb +0 -73
  52. data/spec/jruby/benchmarks/symbolize_keys_bm.rb +0 -25
  53. data/spec/jruby/unpacker_spec.rb +0 -186
  54. data/spec/msgpack_spec.rb +0 -214
  55. data/spec/pack_spec.rb +0 -61
  56. data/spec/packer_spec.rb +0 -575
  57. data/spec/random_compat.rb +0 -24
  58. data/spec/spec_helper.rb +0 -72
  59. data/spec/timestamp_spec.rb +0 -159
  60. data/spec/unpack_spec.rb +0 -57
  61. data/spec/unpacker_spec.rb +0 -869
@@ -1,159 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require 'spec_helper'
4
-
5
- describe MessagePack::Timestamp do
6
- describe 'malformed format' do
7
- it do
8
- expect do
9
- MessagePack::Timestamp.from_msgpack_ext([0xd4, 0x00].pack("C*"))
10
- end.to raise_error(MessagePack::MalformedFormatError)
11
- end
12
- end
13
-
14
- describe 'register_type with Time' do
15
- let(:factory) do
16
- factory = MessagePack::Factory.new
17
- factory.register_type(
18
- MessagePack::Timestamp::TYPE,
19
- Time,
20
- packer: MessagePack::Time::Packer,
21
- unpacker: MessagePack::Time::Unpacker
22
- )
23
- factory
24
- end
25
-
26
- let(:time) { Time.local(2019, 6, 17, 1, 2, 3, 123_456_789 / 1000.0) }
27
- it 'serializes and deserializes Time' do
28
- prefix_fixext8_with_type_id = [0xd7, -1].pack("c*")
29
-
30
- packed = factory.pack(time)
31
- expect(packed).to start_with(prefix_fixext8_with_type_id)
32
- expect(packed.size).to eq(10)
33
- unpacked = factory.unpack(packed)
34
- expect(unpacked.to_i).to eq(time.to_i)
35
- expect(unpacked.to_f).to eq(time.to_f)
36
- # expect(unpacked).to eq(time) # we can't do it because of nsec (rational vs float?)
37
- end
38
-
39
- let(:time_without_nsec) { Time.local(2019, 6, 17, 1, 2, 3, 0) }
40
- it 'serializes time without nanosec as fixext4' do
41
- prefix_fixext4_with_type_id = [0xd6, -1].pack("c*")
42
-
43
- packed = factory.pack(time_without_nsec)
44
- expect(packed).to start_with(prefix_fixext4_with_type_id)
45
- expect(packed.size).to eq(6)
46
- unpacked = factory.unpack(packed)
47
- expect(unpacked).to eq(time_without_nsec)
48
- end
49
-
50
- let(:time_after_2514) { Time.at(1 << 34) } # the max num of 34bit int means 2514-05-30 01:53:04 UTC
51
- it 'serializes time after 2038 as ext8' do
52
- prefix_ext8_with_12bytes_payload_and_type_id = [0xc7, 12, -1].pack("c*")
53
-
54
- expect(time_after_2514.to_i).to be > 0xffffffff
55
- packed = factory.pack(time_after_2514)
56
- expect(packed).to start_with(prefix_ext8_with_12bytes_payload_and_type_id)
57
- expect(packed.size).to eq(15)
58
- end
59
-
60
- it 'runs correctly (regression)' do
61
- expect(factory.unpack(factory.pack(Time.utc(2200)))).to eq(Time.utc(2200))
62
- end
63
-
64
- let(:time32_max) { Time.new(2106, 2, 7, 6, 28, 15, "+00:00") }
65
- it 'is serialized into timestamp32' do
66
- expect(factory.pack(time32_max).size).to be 6
67
- expect(factory.unpack(factory.pack(time32_max)).utc).to eq(time32_max)
68
- end
69
-
70
- let(:time64_min) { Time.new(2106, 2, 7, 6, 28, 16, "+00:00") }
71
- it 'is serialized into timestamp64' do
72
- expect(factory.pack(time64_min).size).to be 10
73
- expect(factory.unpack(factory.pack(time64_min)).utc).to eq(time64_min)
74
- end
75
-
76
- let(:time64_max) { Time.at(Time.new(2514, 5, 30, 1, 53, 3, "+00:00").to_i, 999999999 / 1000.0r).utc } # TODO: use Time.at(sec, nsec, :nsec) when removing Ruby 2.4 from the list
77
- it 'is serialized into timestamp64' do
78
- expect(factory.pack(time64_max).size).to be 10
79
- expect(factory.unpack(factory.pack(time64_max)).utc).to eq(time64_max)
80
- end
81
-
82
- let(:time96_positive_min) { Time.new(2514, 5, 30, 1, 53, 4, "+00:00") }
83
- it 'is serialized into timestamp96' do
84
- expect(factory.pack(time96_positive_min).size).to be 15
85
- expect(factory.unpack(factory.pack(time96_positive_min)).utc).to eq(time96_positive_min)
86
- end
87
-
88
- let(:time96_min) { Time.at(-2**63).utc }
89
- it 'is serialized into timestamp96' do
90
- skip if IS_JRUBY || IS_TRUFFLERUBY # JRuby and TruffleRuby both use underlying Java time classes that do not support |year| >= 1 billion
91
- expect(factory.pack(time96_min).size).to be 15
92
- expect(factory.unpack(factory.pack(time96_min)).utc).to eq(time96_min)
93
- end
94
-
95
- let(:time96_max) { Time.at(2**63 - 1).utc }
96
- it 'is serialized into timestamp96' do
97
- skip if IS_JRUBY || IS_TRUFFLERUBY # JRuby and TruffleRuby both use underlying Java time classes that do not support |year| >= 1 billion
98
- expect(factory.pack(time96_max).size).to be 15
99
- expect(factory.unpack(factory.pack(time96_max)).utc).to eq(time96_max)
100
- end
101
- end
102
-
103
- describe 'register_type with MessagePack::Timestamp' do
104
- let(:factory) do
105
- factory = MessagePack::Factory.new
106
- factory.register_type(MessagePack::Timestamp::TYPE, MessagePack::Timestamp)
107
- factory
108
- end
109
-
110
- let(:timestamp) { MessagePack::Timestamp.new(Time.now.tv_sec, 123_456_789) }
111
- it 'serializes and deserializes MessagePack::Timestamp' do
112
- packed = factory.pack(timestamp)
113
- unpacked = factory.unpack(packed)
114
- expect(unpacked).to eq(timestamp)
115
- end
116
- end
117
-
118
- describe 'timestamp32' do
119
- it 'handles [1, 0]' do
120
- t = MessagePack::Timestamp.new(1, 0)
121
-
122
- payload = t.to_msgpack_ext
123
- unpacked = MessagePack::Timestamp.from_msgpack_ext(payload)
124
-
125
- expect(unpacked).to eq(t)
126
- end
127
- end
128
-
129
- describe 'timestamp64' do
130
- it 'handles [1, 1]' do
131
- t = MessagePack::Timestamp.new(1, 1)
132
-
133
- payload = t.to_msgpack_ext
134
- unpacked = MessagePack::Timestamp.from_msgpack_ext(payload)
135
-
136
- expect(unpacked).to eq(t)
137
- end
138
- end
139
-
140
- describe 'timestamp96' do
141
- it 'handles [-1, 0]' do
142
- t = MessagePack::Timestamp.new(-1, 0)
143
-
144
- payload = t.to_msgpack_ext
145
- unpacked = MessagePack::Timestamp.from_msgpack_ext(payload)
146
-
147
- expect(unpacked).to eq(t)
148
- end
149
-
150
- it 'handles [-1, 999_999_999]' do
151
- t = MessagePack::Timestamp.new(-1, 999_999_999)
152
-
153
- payload = t.to_msgpack_ext
154
- unpacked = MessagePack::Timestamp.from_msgpack_ext(payload)
155
-
156
- expect(unpacked).to eq(t)
157
- end
158
- end
159
- end
data/spec/unpack_spec.rb DELETED
@@ -1,57 +0,0 @@
1
- # encoding: ascii-8bit
2
- require 'spec_helper'
3
-
4
- require 'stringio'
5
- if defined?(Encoding)
6
- Encoding.default_external = 'ASCII-8BIT'
7
- end
8
-
9
- describe MessagePack do
10
- it 'MessagePack.unpack symbolize_keys' do
11
- symbolized_hash = {:a => 'b', :c => 'd'}
12
- MessagePack.load(MessagePack.pack(symbolized_hash), :symbolize_keys => true).should == symbolized_hash
13
- MessagePack.unpack(MessagePack.pack(symbolized_hash), :symbolize_keys => true).should == symbolized_hash
14
- end
15
-
16
- it 'Unpacker#read symbolize_keys' do
17
- unpacker = MessagePack::Unpacker.new(:symbolize_keys => true)
18
- symbolized_hash = {:a => 'b', :c => 'd'}
19
- unpacker.feed(MessagePack.pack(symbolized_hash)).read.should == symbolized_hash
20
- end
21
-
22
- it "msgpack str 8 type" do
23
- MessagePack.unpack([0xd9, 0x00].pack('C*')).should == ""
24
- MessagePack.unpack([0xd9, 0x01].pack('C*') + 'a').should == "a"
25
- MessagePack.unpack([0xd9, 0x02].pack('C*') + 'aa').should == "aa"
26
- end
27
-
28
- it "msgpack str 16 type" do
29
- MessagePack.unpack([0xda, 0x00, 0x00].pack('C*')).should == ""
30
- MessagePack.unpack([0xda, 0x00, 0x01].pack('C*') + 'a').should == "a"
31
- MessagePack.unpack([0xda, 0x00, 0x02].pack('C*') + 'aa').should == "aa"
32
- end
33
-
34
- it "msgpack str 32 type" do
35
- MessagePack.unpack([0xdb, 0x00, 0x00, 0x00, 0x00].pack('C*')).should == ""
36
- MessagePack.unpack([0xdb, 0x00, 0x00, 0x00, 0x01].pack('C*') + 'a').should == "a"
37
- MessagePack.unpack([0xdb, 0x00, 0x00, 0x00, 0x02].pack('C*') + 'aa').should == "aa"
38
- end
39
-
40
- it "msgpack bin 8 type" do
41
- MessagePack.unpack([0xc4, 0x00].pack('C*')).should == ""
42
- MessagePack.unpack([0xc4, 0x01].pack('C*') + 'a').should == "a"
43
- MessagePack.unpack([0xc4, 0x02].pack('C*') + 'aa').should == "aa"
44
- end
45
-
46
- it "msgpack bin 16 type" do
47
- MessagePack.unpack([0xc5, 0x00, 0x00].pack('C*')).should == ""
48
- MessagePack.unpack([0xc5, 0x00, 0x01].pack('C*') + 'a').should == "a"
49
- MessagePack.unpack([0xc5, 0x00, 0x02].pack('C*') + 'aa').should == "aa"
50
- end
51
-
52
- it "msgpack bin 32 type" do
53
- MessagePack.unpack([0xc6, 0x00, 0x00, 0x00, 0x00].pack('C*')).should == ""
54
- MessagePack.unpack([0xc6, 0x00, 0x00, 0x00, 0x01].pack('C*') + 'a').should == "a"
55
- MessagePack.unpack([0xc6, 0x00, 0x00, 0x00, 0x02].pack('C*') + 'aa').should == "aa"
56
- end
57
- end