bindata 2.3.3 → 2.3.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.

Potentially problematic release.


This version of bindata might be problematic. Click here for more details.

Files changed (60) hide show
  1. checksums.yaml +4 -4
  2. data/ChangeLog.rdoc +4 -0
  3. data/Rakefile +2 -2
  4. data/examples/gzip.rb +24 -24
  5. data/examples/ip_address.rb +3 -4
  6. data/examples/list.rb +20 -20
  7. data/examples/nbt.rb +14 -14
  8. data/examples/tcp_ip.rb +12 -14
  9. data/lib/bindata/alignment.rb +2 -2
  10. data/lib/bindata/array.rb +22 -23
  11. data/lib/bindata/base.rb +13 -12
  12. data/lib/bindata/base_primitive.rb +20 -17
  13. data/lib/bindata/bits.rb +4 -4
  14. data/lib/bindata/buffer.rb +5 -5
  15. data/lib/bindata/choice.rb +11 -13
  16. data/lib/bindata/count_bytes_remaining.rb +1 -2
  17. data/lib/bindata/delayed_io.rb +11 -11
  18. data/lib/bindata/dsl.rb +57 -64
  19. data/lib/bindata/float.rb +16 -13
  20. data/lib/bindata/int.rb +6 -6
  21. data/lib/bindata/io.rb +16 -16
  22. data/lib/bindata/lazy.rb +3 -3
  23. data/lib/bindata/name.rb +2 -2
  24. data/lib/bindata/offset.rb +3 -3
  25. data/lib/bindata/params.rb +13 -15
  26. data/lib/bindata/primitive.rb +3 -3
  27. data/lib/bindata/registry.rb +12 -12
  28. data/lib/bindata/rest.rb +1 -2
  29. data/lib/bindata/sanitize.rb +17 -18
  30. data/lib/bindata/skip.rb +7 -8
  31. data/lib/bindata/string.rb +6 -6
  32. data/lib/bindata/stringz.rb +3 -3
  33. data/lib/bindata/struct.rb +16 -16
  34. data/lib/bindata/trace.rb +9 -8
  35. data/lib/bindata/version.rb +1 -1
  36. data/lib/bindata/virtual.rb +3 -3
  37. data/lib/bindata/warnings.rb +6 -2
  38. data/test/alignment_test.rb +4 -4
  39. data/test/array_test.rb +29 -29
  40. data/test/base_primitive_test.rb +17 -17
  41. data/test/base_test.rb +6 -6
  42. data/test/bits_test.rb +1 -1
  43. data/test/buffer_test.rb +19 -19
  44. data/test/choice_test.rb +20 -20
  45. data/test/count_bytes_remaining_test.rb +1 -1
  46. data/test/delayed_io_test.rb +26 -26
  47. data/test/lazy_test.rb +16 -16
  48. data/test/offset_test.rb +8 -8
  49. data/test/params_test.rb +11 -11
  50. data/test/primitive_test.rb +11 -11
  51. data/test/record_test.rb +50 -50
  52. data/test/registry_test.rb +26 -26
  53. data/test/rest_test.rb +1 -1
  54. data/test/skip_test.rb +27 -27
  55. data/test/string_test.rb +24 -24
  56. data/test/stringz_test.rb +1 -1
  57. data/test/struct_test.rb +76 -75
  58. data/test/system_test.rb +51 -51
  59. data/test/virtual_test.rb +3 -3
  60. metadata +2 -2
@@ -102,7 +102,7 @@ describe BinData::BasePrimitive, "after initialisation" do
102
102
  let(:obj) { ExampleSingle.new }
103
103
 
104
104
  it "does not allow both :initial_value and :value" do
105
- params = {:initial_value => 1, :value => 2}
105
+ params = {initial_value: 1, value: 2}
106
106
  lambda { ExampleSingle.new(params) }.must_raise ArgumentError
107
107
  end
108
108
 
@@ -141,7 +141,7 @@ describe BinData::BasePrimitive, "after initialisation" do
141
141
  end
142
142
 
143
143
  describe BinData::BasePrimitive, "with :initial_value" do
144
- let(:obj) { ExampleSingle.new(:initial_value => 5) }
144
+ let(:obj) { ExampleSingle.new(initial_value: 5) }
145
145
 
146
146
  it "initial state" do
147
147
  obj.value.must_equal 5
@@ -165,7 +165,7 @@ describe BinData::BasePrimitive, "with :initial_value" do
165
165
  end
166
166
 
167
167
  describe BinData::BasePrimitive, "with :value" do
168
- let(:obj) { ExampleSingle.new(:value => 5) }
168
+ let(:obj) { ExampleSingle.new(value: 5) }
169
169
  let(:io) { ExampleSingle.io_with_value(56) }
170
170
 
171
171
  it "initial state" do
@@ -195,45 +195,45 @@ describe BinData::BasePrimitive, "asserting value" do
195
195
 
196
196
  describe ":assert is non boolean" do
197
197
  it "asserts sensible value" do
198
- data = ExampleSingle.new(:assert => 0)
198
+ data = ExampleSingle.new(assert: 0)
199
199
  data.assert!
200
200
  data.value.must_equal 0
201
201
  end
202
202
 
203
203
  it "succeeds when assert is correct" do
204
- data = ExampleSingle.new(:assert => 12)
204
+ data = ExampleSingle.new(assert: 12)
205
205
  data.read(io)
206
206
  data.value.must_equal 12
207
207
  end
208
208
 
209
209
  it "fails when assert is incorrect" do
210
- data = ExampleSingle.new(:assert => lambda { 99 })
210
+ data = ExampleSingle.new(assert: -> { 99 })
211
211
  lambda { data.read(io) }.must_raise BinData::ValidityError
212
212
  end
213
213
  end
214
214
 
215
215
  describe ":assert is boolean" do
216
216
  it "succeeds when assert is true" do
217
- data = ExampleSingle.new(:assert => lambda { value < 20 })
217
+ data = ExampleSingle.new(assert: -> { value < 20 })
218
218
  data.read(io)
219
219
  data.value.must_equal 12
220
220
  end
221
221
 
222
222
  it "fails when assert is false" do
223
- data = ExampleSingle.new(:assert => lambda { value > 20 })
223
+ data = ExampleSingle.new(assert: -> { value > 20 })
224
224
  lambda { data.read(io) }.must_raise BinData::ValidityError
225
225
  end
226
226
  end
227
227
 
228
228
  describe "assigning with :assert" do
229
229
  it "succeeds when assert is correct" do
230
- data = ExampleSingle.new(:assert => 12)
230
+ data = ExampleSingle.new(assert: 12)
231
231
  data.assign(12)
232
232
  data.value.must_equal 12
233
233
  end
234
234
 
235
235
  it "fails when assert is incorrect" do
236
- data = ExampleSingle.new(:assert => 12)
236
+ data = ExampleSingle.new(assert: 12)
237
237
  lambda { data.assign(99) }.must_raise BinData::ValidityError
238
238
  end
239
239
  end
@@ -241,19 +241,19 @@ end
241
241
 
242
242
  describe BinData::BasePrimitive, ":asserted_value" do
243
243
  it "has :value" do
244
- data = ExampleSingle.new(:asserted_value => lambda { 12 })
244
+ data = ExampleSingle.new(asserted_value: -> { 12 })
245
245
  data.value.must_equal 12
246
246
  end
247
247
 
248
248
  describe "assigning with :assert" do
249
249
  it "succeeds when assert is correct" do
250
- data = ExampleSingle.new(:asserted_value => lambda { 12 })
250
+ data = ExampleSingle.new(asserted_value: -> { 12 })
251
251
  data.assign(12)
252
252
  data.value.must_equal 12
253
253
  end
254
254
 
255
255
  it "fails when assert is incorrect" do
256
- data = ExampleSingle.new(:asserted_value => lambda { 12 })
256
+ data = ExampleSingle.new(asserted_value: -> { 12 })
257
257
  lambda { data.assign(99) }.must_raise BinData::ValidityError
258
258
  end
259
259
  end
@@ -261,13 +261,13 @@ end
261
261
 
262
262
  describe BinData::BasePrimitive do
263
263
  it "conforms to rule 1 for returning a value" do
264
- data = ExampleSingle.new(:value => 5)
264
+ data = ExampleSingle.new(value: 5)
265
265
  data.must_equal 5
266
266
  end
267
267
 
268
268
  it "conforms to rule 2 for returning a value" do
269
269
  io = ExampleSingle.io_with_value(42)
270
- data = ExampleSingle.new(:value => 5)
270
+ data = ExampleSingle.new(value: 5)
271
271
  data.read(io)
272
272
 
273
273
  data.stub :reading?, true do
@@ -276,13 +276,13 @@ describe BinData::BasePrimitive do
276
276
  end
277
277
 
278
278
  it "conforms to rule 3 for returning a value" do
279
- data = ExampleSingle.new(:initial_value => 5)
279
+ data = ExampleSingle.new(initial_value: 5)
280
280
  assert data.clear?
281
281
  data.must_equal 5
282
282
  end
283
283
 
284
284
  it "conforms to rule 4 for returning a value" do
285
- data = ExampleSingle.new(:initial_value => 5)
285
+ data = ExampleSingle.new(initial_value: 5)
286
286
  data.assign(17)
287
287
  refute data.clear?
288
288
  data.must_equal 17
data/test/base_test.rb CHANGED
@@ -61,12 +61,12 @@ describe BinData::Base, "ArgExtractor" do
61
61
  it "parses parameters" do
62
62
  par = BinData::Base.new
63
63
  data = [
64
- [[3 ], 3, [], nil],
65
- [[3, par], 3, [], par],
66
- [[ {:a => 1} ], nil, [:a], nil],
67
- [[ {:a => 1}, par], nil, [:a], par],
68
- [[3, {:a => 1} ], 3, [:a], nil],
69
- [[3, {:a => 1}, par], 3, [:a], par],
64
+ [[3 ], 3, [], nil],
65
+ [[3, par], 3, [], par],
66
+ [[ {a: 1} ], nil, [:a], nil],
67
+ [[ {a: 1}, par], nil, [:a], par],
68
+ [[3, {a: 1} ], 3, [:a], nil],
69
+ [[3, {a: 1}, par], 3, [:a], par],
70
70
  ]
71
71
 
72
72
  data.each do |el|
data/test/bits_test.rb CHANGED
@@ -109,7 +109,7 @@ def generate_bit_classes_to_test(endian, signed)
109
109
  (start .. 64).each do |nbits|
110
110
  name = "#{base}"
111
111
  name << "Le" if endian == :little
112
- obj = BinData.const_get(name).new(:nbits => nbits)
112
+ obj = BinData.const_get(name).new(nbits: nbits)
113
113
  bits << [obj, nbits]
114
114
  end
115
115
 
data/test/buffer_test.rb CHANGED
@@ -12,19 +12,19 @@ describe BinData::Buffer, "when instantiating" do
12
12
 
13
13
  describe "with some but not all mandatory parameters supplied" do
14
14
  it "raises an error" do
15
- args = {:length => 3}
15
+ args = {length: 3}
16
16
  lambda { BinData::Buffer.new(args) }.must_raise ArgumentError
17
17
  end
18
18
  end
19
19
 
20
20
  it "fails if a given type is unknown" do
21
- args = {:type => :does_not_exist, :length => 3}
21
+ args = {type: :does_not_exist, length: 3}
22
22
  lambda { BinData::Buffer.new(args) }.must_raise BinData::UnRegisteredTypeError
23
23
  end
24
24
 
25
25
  it "accepts BinData::Base as :type" do
26
- obj = BinData::Int8.new(:initial_value => 5)
27
- array = BinData::Buffer.new(:type => obj, :length => 3)
26
+ obj = BinData::Int8.new(initial_value: 5)
27
+ array = BinData::Buffer.new(type: obj, length: 3)
28
28
  array.must_equal 5
29
29
  end
30
30
  end
@@ -32,7 +32,7 @@ end
32
32
  describe BinData::Buffer, "subclassed with a single type" do
33
33
  class IntBuffer < BinData::Buffer
34
34
  endian :big
35
- default_parameter :length => 5
35
+ default_parameter length: 5
36
36
 
37
37
  uint16
38
38
  end
@@ -68,14 +68,14 @@ end
68
68
  describe BinData::Buffer, "subclassed with multiple types" do
69
69
  class TupleBuffer < BinData::Buffer
70
70
  endian :big
71
- default_parameter :length => 5
71
+ default_parameter length: 5
72
72
 
73
73
  uint16 :a
74
74
  uint16 :b
75
75
  end
76
76
 
77
77
  it "behaves as type" do
78
- obj = TupleBuffer.new(:a => 1, :b => 2)
78
+ obj = TupleBuffer.new(a: 1, b: 2)
79
79
  obj.a.must_equal 1
80
80
  obj.b.must_equal 2
81
81
  end
@@ -97,7 +97,7 @@ describe BinData::Buffer, "subclassed with multiple types" do
97
97
  end
98
98
 
99
99
  it "writes data" do
100
- obj = TupleBuffer.new(:a => 1, :b => 2)
100
+ obj = TupleBuffer.new(a: 1, b: 2)
101
101
  obj.to_binary_s.must_equal_binary "\000\001\000\002\000"
102
102
  end
103
103
  end
@@ -106,11 +106,11 @@ describe BinData::Buffer, "inside a Record" do
106
106
  class BufferRecord < BinData::Record
107
107
  endian :little
108
108
 
109
- uint16 :buffer_length, :value => lambda { 2 * list.length + 1 }
110
- buffer :list, :length => :buffer_length do
111
- array :type => :int16, :read_until => :eof
109
+ uint16 :buffer_length, value: -> { 2 * list.length + 1 }
110
+ buffer :list, length: :buffer_length do
111
+ array type: :int16, read_until: :eof
112
112
  end
113
- string :footer, :read_length => 2, :asserted_value => "ZZ"
113
+ string :footer, read_length: 2, asserted_value: "ZZ"
114
114
  end
115
115
 
116
116
  it "reads" do
@@ -119,22 +119,22 @@ describe BinData::Buffer, "inside a Record" do
119
119
  end
120
120
 
121
121
  it "writes" do
122
- obj = BufferRecord.new(:list => [1, 2, 3, 4, 5])
122
+ obj = BufferRecord.new(list: [1, 2, 3, 4, 5])
123
123
  obj.to_binary_s.must_equal_binary "\013\000\001\000\002\000\003\000\004\000\005\000\000ZZ"
124
124
  end
125
125
  end
126
126
 
127
127
  describe BinData::Buffer, "nested buffers" do
128
128
  class NestedBufferRecord < BinData::Record
129
- buffer :a, :length => 10 do
130
- buffer :aa, :length => 5 do
131
- string :read_length => 5
129
+ buffer :a, length: 10 do
130
+ buffer :aa, length: 5 do
131
+ string read_length: 5
132
132
  end
133
- buffer :bb, :length => 20 do
134
- string :read_length => 5
133
+ buffer :bb, length: 20 do
134
+ string read_length: 5
135
135
  end
136
136
  end
137
- string :b, :read_length => 5
137
+ string :b, read_length: 5
138
138
  end
139
139
 
140
140
  it "restricts large nested buffer" do
data/test/choice_test.rb CHANGED
@@ -17,7 +17,7 @@ end
17
17
 
18
18
  def create_choice(choices, options = {})
19
19
  chooser = Chooser.new
20
- params = {:choices => choices, :selection => lambda { chooser.choice } }.merge(options)
20
+ params = {choices: choices, selection: -> { chooser.choice } }.merge(options)
21
21
  choice = BinData::Choice.new(params)
22
22
  choice.set_chooser(chooser)
23
23
  choice
@@ -28,30 +28,30 @@ describe BinData::Choice, "when instantiating" do
28
28
  args = {}
29
29
  lambda { BinData::Choice.new(args) }.must_raise ArgumentError
30
30
 
31
- args = {:selection => 1}
31
+ args = {selection: 1}
32
32
  lambda { BinData::Choice.new(args) }.must_raise ArgumentError
33
33
 
34
- args = {:choices => []}
34
+ args = {choices: []}
35
35
  lambda { BinData::Choice.new(args) }.must_raise ArgumentError
36
36
  end
37
37
 
38
38
  it "fails when a given type is unknown" do
39
- args = {:choices => [:does_not_exist], :selection => 0}
39
+ args = {choices: [:does_not_exist], selection: 0}
40
40
  lambda { BinData::Choice.new(args) }.must_raise BinData::UnRegisteredTypeError
41
41
  end
42
42
 
43
43
  it "fails when a given type is unknown" do
44
- args = {:choices => {0 => :does_not_exist}, :selection => 0}
44
+ args = {choices: {0 => :does_not_exist}, selection: 0}
45
45
  lambda { BinData::Choice.new(args) }.must_raise BinData::UnRegisteredTypeError
46
46
  end
47
47
 
48
48
  it "fails when :choices Hash has a symbol as key" do
49
- args = {:choices => {:a => :uint8}, :selection => 0}
49
+ args = {choices: {a: :uint8}, selection: 0}
50
50
  lambda { BinData::Choice.new(args) }.must_raise ArgumentError
51
51
  end
52
52
 
53
53
  it "fails when :choices Hash has a nil key" do
54
- args = {:choices => {nil => :uint8}, :selection => 0}
54
+ args = {choices: {nil => :uint8}, selection: 0}
55
55
  lambda { BinData::Choice.new(args) }.must_raise ArgumentError
56
56
  end
57
57
  end
@@ -112,9 +112,9 @@ describe BinData::Choice, "with sparse choices array" do
112
112
 
113
113
  let(:obj) {
114
114
  choices = [nil, nil, nil,
115
- [:uint8, {:value => 30}], nil,
116
- [:uint8, {:value => 50}], nil,
117
- [:uint8, {:value => 70}]]
115
+ [:uint8, {value: 30}], nil,
116
+ [:uint8, {value: 50}], nil,
117
+ [:uint8, {value: 70}]]
118
118
  create_choice(choices)
119
119
  }
120
120
  end
@@ -123,9 +123,9 @@ describe BinData::Choice, "with choices hash" do
123
123
  include ChoiceInitializedWithArrayOrHash
124
124
 
125
125
  let(:obj) {
126
- choices = {3 => [:uint8, {:value => 30}],
127
- 5 => [:uint8, {:value => 50}],
128
- 7 => [:uint8, {:value => 70}]}
126
+ choices = {3 => [:uint8, {value: 30}],
127
+ 5 => [:uint8, {value: 50}],
128
+ 7 => [:uint8, {value: 70}]}
129
129
  create_choice(choices)
130
130
  }
131
131
  end
@@ -202,7 +202,7 @@ end
202
202
  describe BinData::Choice, "with copy_on_change => true" do
203
203
  let(:obj) {
204
204
  choices = {3 => :uint8, 5 => :uint8, 7 => :uint8}
205
- create_choice(choices, :copy_on_change => true)
205
+ create_choice(choices, copy_on_change: true)
206
206
  }
207
207
 
208
208
  it "copies value when changing selection" do
@@ -215,15 +215,15 @@ describe BinData::Choice, "with copy_on_change => true" do
215
215
  end
216
216
 
217
217
  describe BinData::Choice, "with :default" do
218
- let(:choices) { { "a" => :int8, :default => :int16be } }
218
+ let(:choices) { { "a" => :int8, default: :int16be } }
219
219
 
220
220
  it "selects for existing case" do
221
- obj = BinData::Choice.new(:selection => "a", :choices => choices)
221
+ obj = BinData::Choice.new(selection: "a", choices: choices)
222
222
  obj.num_bytes.must_equal 1
223
223
  end
224
224
 
225
225
  it "selects for default case" do
226
- obj = BinData::Choice.new(:selection => "other", :choices => choices)
226
+ obj = BinData::Choice.new(selection: "other", choices: choices)
227
227
  obj.num_bytes.must_equal 2
228
228
  end
229
229
  end
@@ -231,7 +231,7 @@ end
231
231
  describe BinData::Choice, "subclassed with default parameters" do
232
232
  class DerivedChoice < BinData::Choice
233
233
  endian :big
234
- default_parameter :selection => 'a'
234
+ default_parameter selection: 'a'
235
235
 
236
236
  uint16 'a'
237
237
  uint32 'b'
@@ -244,12 +244,12 @@ describe BinData::Choice, "subclassed with default parameters" do
244
244
  end
245
245
 
246
246
  it "overides default parameter" do
247
- obj = DerivedChoice.new(:selection => 'b')
247
+ obj = DerivedChoice.new(selection: 'b')
248
248
  obj.num_bytes.must_equal 4
249
249
  end
250
250
 
251
251
  it "selects default selection" do
252
- obj = DerivedChoice.new(:selection => 'z')
252
+ obj = DerivedChoice.new(selection: 'z')
253
253
  obj.num_bytes.must_equal 8
254
254
  end
255
255
  end
@@ -33,7 +33,7 @@ describe BinData::CountBytesRemaining do
33
33
  end
34
34
 
35
35
  it "accepts BinData::BasePrimitive parameters" do
36
- count = BinData::CountBytesRemaining.new(:assert => 2)
36
+ count = BinData::CountBytesRemaining.new(assert: 2)
37
37
  lambda {
38
38
  count.read("xyz")
39
39
  }.must_raise BinData::ValidityError
@@ -12,19 +12,19 @@ describe BinData::DelayedIO, "when instantiating" do
12
12
 
13
13
  describe "with some but not all mandatory parameters supplied" do
14
14
  it "raises an error" do
15
- args = {:read_abs_offset => 3}
15
+ args = {read_abs_offset: 3}
16
16
  lambda { BinData::DelayedIO.new(args) }.must_raise ArgumentError
17
17
  end
18
18
  end
19
19
 
20
20
  it "fails if a given type is unknown" do
21
- args = {:type => :does_not_exist, :length => 3}
21
+ args = {type: :does_not_exist, length: 3}
22
22
  lambda { BinData::DelayedIO.new(args) }.must_raise BinData::UnRegisteredTypeError
23
23
  end
24
24
 
25
25
  it "accepts BinData::Base as :type" do
26
- obj = BinData::Int8.new(:initial_value => 5)
27
- array = BinData::DelayedIO.new(:type => obj, :read_abs_offset => 3)
26
+ obj = BinData::Int8.new(initial_value: 5)
27
+ array = BinData::DelayedIO.new(type: obj, read_abs_offset: 3)
28
28
  array.must_equal 5
29
29
  end
30
30
  end
@@ -32,7 +32,7 @@ end
32
32
  describe BinData::DelayedIO, "subclassed with a single type" do
33
33
  class IntDelayedIO < BinData::DelayedIO
34
34
  endian :big
35
- default_parameter :read_abs_offset => 5
35
+ default_parameter read_abs_offset: 5
36
36
 
37
37
  uint16
38
38
  end
@@ -120,27 +120,27 @@ end
120
120
  describe BinData::DelayedIO, "subclassed with multiple types" do
121
121
  class StringDelayedIO < BinData::DelayedIO
122
122
  endian :big
123
- default_parameter :read_abs_offset => 5
123
+ default_parameter read_abs_offset: 5
124
124
 
125
- uint16 :len, :value => lambda { str.length }
126
- string :str, :read_length => :len
125
+ uint16 :len, value: -> { str.length }
126
+ string :str, read_length: :len
127
127
  end
128
128
 
129
129
  it "behaves as type" do
130
- obj = StringDelayedIO.new(:str => "hello")
131
- obj.snapshot.must_equal({:len => 5, :str => "hello"})
130
+ obj = StringDelayedIO.new(str: "hello")
131
+ obj.snapshot.must_equal({len: 5, str: "hello"})
132
132
  end
133
133
 
134
134
  it "reads explicitly" do
135
135
  obj = StringDelayedIO.read "\001\002\003\004\005\000\003abc\013"
136
136
  obj.read_now!
137
137
 
138
- obj.snapshot.must_equal({:len => 3, :str => "abc"})
138
+ obj.snapshot.must_equal({len: 3, str: "abc"})
139
139
  end
140
140
 
141
141
  it "writes explicitly" do
142
142
  io = StringIO.new "\001\002\003\004\005\006\007\010\011\012\013\014\015"
143
- obj = StringDelayedIO.new(:str => "hello")
143
+ obj = StringDelayedIO.new(str: "hello")
144
144
  obj.write(io)
145
145
  obj.write_now!
146
146
  io.value.must_equal "\001\002\003\004\005\000\005hello\015"
@@ -151,19 +151,19 @@ describe BinData::DelayedIO, "inside a Record" do
151
151
  class DelayedIORecord < BinData::Record
152
152
  endian :little
153
153
 
154
- uint16 :str_length, :value => lambda { str.length }
155
- delayed_io :str, :read_abs_offset => 4 do
156
- string :read_length => :str_length
154
+ uint16 :str_length, value: -> { str.length }
155
+ delayed_io :str, read_abs_offset: 4 do
156
+ string read_length: :str_length
157
157
  end
158
- delayed_io :my_int, :read_abs_offset => 2 do
159
- uint16 :initial_value => 7
158
+ delayed_io :my_int, read_abs_offset: 2 do
159
+ uint16 initial_value: 7
160
160
  end
161
161
  end
162
162
 
163
163
  it "reads" do
164
164
  obj = DelayedIORecord.read "\x05\x00\x03\x0012345"
165
165
  obj.num_bytes.must_equal 2
166
- obj.snapshot.must_equal({:str_length => 0, :str => "", :my_int => 7})
166
+ obj.snapshot.must_equal({str_length: 0, str: "", my_int: 7})
167
167
  end
168
168
 
169
169
  it "reads explicitly" do
@@ -171,11 +171,11 @@ describe BinData::DelayedIO, "inside a Record" do
171
171
  obj.str.read_now!
172
172
  obj.my_int.read_now!
173
173
  obj.num_bytes.must_equal 2
174
- obj.snapshot.must_equal({:str_length => 5, :str => "12345", :my_int => 3})
174
+ obj.snapshot.must_equal({str_length: 5, str: "12345", my_int: 3})
175
175
  end
176
176
 
177
177
  it "writes" do
178
- obj = DelayedIORecord.new(:str => "abc", :my_int => 2)
178
+ obj = DelayedIORecord.new(str: "abc", my_int: 2)
179
179
  io = StringIO.new
180
180
  obj.write(io)
181
181
  obj.str.write_now!
@@ -188,36 +188,36 @@ describe BinData::DelayedIO, "with auto_call" do
188
188
  class AutoCallDelayedIORecord < BinData::Record
189
189
  auto_call_delayed_io
190
190
  uint8 :a
191
- delayed_io :b, :read_abs_offset => 1 do
191
+ delayed_io :b, read_abs_offset: 1 do
192
192
  uint8
193
193
  end
194
194
  end
195
195
 
196
196
  it "class reads" do
197
197
  obj = AutoCallDelayedIORecord.read "\x01\x02"
198
- obj.snapshot.must_equal({:a => 1, :b => 2})
198
+ obj.snapshot.must_equal({a: 1, b: 2})
199
199
  end
200
200
 
201
201
  it "reads" do
202
202
  obj = AutoCallDelayedIORecord.new
203
203
  obj.read "\x01\x02"
204
- obj.snapshot.must_equal({:a => 1, :b => 2})
204
+ obj.snapshot.must_equal({a: 1, b: 2})
205
205
  end
206
206
 
207
207
  it "writes" do
208
- obj = AutoCallDelayedIORecord.new(:a => 1, :b => 2)
208
+ obj = AutoCallDelayedIORecord.new(a: 1, b: 2)
209
209
  io = StringIO.new
210
210
  obj.write(io)
211
211
  io.value.must_equal "\x01\x02"
212
212
  end
213
213
 
214
214
  it "to_binary_s" do
215
- obj = AutoCallDelayedIORecord.new(:a => 1, :b => 2)
215
+ obj = AutoCallDelayedIORecord.new(a: 1, b: 2)
216
216
  obj.to_binary_s.must_equal_binary "\x01\x02"
217
217
  end
218
218
 
219
219
  it "num_bytes" do
220
- obj = AutoCallDelayedIORecord.new(:a => 1, :b => 2)
220
+ obj = AutoCallDelayedIORecord.new(a: 1, b: 2)
221
221
  obj.num_bytes.must_equal 2
222
222
  end
223
223
  end