ffi 1.9.5-x86-mingw32 → 1.9.6-x86-mingw32

Sign up to get free protection for your applications and to get access to all the features.

Potentially problematic release.


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

Files changed (46) hide show
  1. checksums.yaml +15 -7
  2. data/Rakefile +13 -6
  3. data/ext/ffi_c/extconf.rb +2 -2
  4. data/lib/1.8/ffi_c.so +0 -0
  5. data/lib/1.9/ffi_c.so +0 -0
  6. data/lib/2.0/ffi_c.so +0 -0
  7. data/lib/2.1/ffi_c.so +0 -0
  8. data/lib/ffi.rb +2 -0
  9. data/lib/ffi/version.rb +1 -1
  10. data/spec/ffi/async_callback_spec.rb +4 -5
  11. data/spec/ffi/bool_spec.rb +9 -8
  12. data/spec/ffi/buffer_spec.rb +64 -37
  13. data/spec/ffi/callback_spec.rb +195 -116
  14. data/spec/ffi/custom_param_type.rb +1 -1
  15. data/spec/ffi/custom_type_spec.rb +5 -6
  16. data/spec/ffi/dup_spec.rb +6 -8
  17. data/spec/ffi/enum_spec.rb +135 -129
  18. data/spec/ffi/errno_spec.rb +2 -2
  19. data/spec/ffi/ffi.log +5833 -0
  20. data/spec/ffi/ffi_spec.rb +4 -6
  21. data/spec/ffi/function_spec.rb +22 -11
  22. data/spec/ffi/io_spec.rb +0 -1
  23. data/spec/ffi/library_spec.rb +71 -36
  24. data/spec/ffi/long_double.rb +3 -4
  25. data/spec/ffi/managed_struct_spec.rb +14 -4
  26. data/spec/ffi/memorypointer_spec.rb +7 -1
  27. data/spec/ffi/number_spec.rb +43 -34
  28. data/spec/ffi/platform_spec.rb +76 -59
  29. data/spec/ffi/pointer_spec.rb +35 -31
  30. data/spec/ffi/rbx/attach_function_spec.rb +3 -4
  31. data/spec/ffi/rbx/memory_pointer_spec.rb +24 -22
  32. data/spec/ffi/rbx/spec_helper.rb +0 -1
  33. data/spec/ffi/rbx/struct_spec.rb +1 -2
  34. data/spec/ffi/spec_helper.rb +5 -2
  35. data/spec/ffi/string_spec.rb +22 -14
  36. data/spec/ffi/strptr_spec.rb +6 -7
  37. data/spec/ffi/struct_by_ref_spec.rb +4 -5
  38. data/spec/ffi/struct_by_ref_spec.rb.orig +43 -0
  39. data/spec/ffi/struct_callback_spec.rb +6 -7
  40. data/spec/ffi/struct_initialize_spec.rb +2 -3
  41. data/spec/ffi/struct_packed_spec.rb +12 -14
  42. data/spec/ffi/struct_spec.rb +203 -129
  43. data/spec/ffi/typedef_spec.rb +11 -10
  44. data/spec/ffi/union_spec.rb +8 -7
  45. data/spec/ffi/variadic_spec.rb +13 -10
  46. metadata +150 -139
@@ -4,7 +4,6 @@
4
4
  #
5
5
 
6
6
  require File.expand_path(File.join(File.dirname(__FILE__), "spec_helper"))
7
- require 'ffi'
8
7
 
9
8
  describe "Callback" do
10
9
  # module LibC
@@ -85,161 +84,197 @@ describe "Callback" do
85
84
  attach_function :testOptionalCallbackCrV, :testOptionalClosureBrV, [ :cbCrV, :char ], :void
86
85
 
87
86
  end
87
+
88
88
  it "returning :char (0)" do
89
- LibTest.testCallbackVrS8 { 0 }.should == 0
89
+ expect(LibTest.testCallbackVrS8 { 0 }).to eq(0)
90
90
  end
91
+
91
92
  it "returning :char (127)" do
92
- LibTest.testCallbackVrS8 { 127 }.should == 127
93
+ expect(LibTest.testCallbackVrS8 { 127 }).to eq(127)
93
94
  end
95
+
94
96
  it "returning :char (-128)" do
95
- LibTest.testCallbackVrS8 { -128 }.should == -128
97
+ expect(LibTest.testCallbackVrS8 { -128 }).to eq(-128)
96
98
  end
97
99
  # test wrap around
98
100
  it "returning :char (128)" do
99
- LibTest.testCallbackVrS8 { 128 }.should == -128
101
+ expect(LibTest.testCallbackVrS8 { 128 }).to eq(-128)
100
102
  end
103
+
101
104
  it "returning :char (255)" do
102
- LibTest.testCallbackVrS8 { 0xff }.should == -1
105
+ expect(LibTest.testCallbackVrS8 { 0xff }).to eq(-1)
103
106
  end
107
+
104
108
  it "returning :uchar (0)" do
105
- LibTest.testCallbackVrU8 { 0 }.should == 0
109
+ expect(LibTest.testCallbackVrU8 { 0 }).to eq(0)
106
110
  end
111
+
107
112
  it "returning :uchar (0xff)" do
108
- LibTest.testCallbackVrU8 { 0xff }.should == 0xff
113
+ expect(LibTest.testCallbackVrU8 { 0xff }).to eq(0xff)
109
114
  end
115
+
110
116
  it "returning :uchar (-1)" do
111
- LibTest.testCallbackVrU8 { -1 }.should == 0xff
117
+ expect(LibTest.testCallbackVrU8 { -1 }).to eq(0xff)
112
118
  end
119
+
113
120
  it "returning :uchar (128)" do
114
- LibTest.testCallbackVrU8 { 128 }.should == 128
121
+ expect(LibTest.testCallbackVrU8 { 128 }).to eq(128)
115
122
  end
123
+
116
124
  it "returning :uchar (-128)" do
117
- LibTest.testCallbackVrU8 { -128 }.should == 128
125
+ expect(LibTest.testCallbackVrU8 { -128 }).to eq(128)
118
126
  end
127
+
119
128
  it "returning :short (0)" do
120
- LibTest.testCallbackVrS16 { 0 }.should == 0
129
+ expect(LibTest.testCallbackVrS16 { 0 }).to eq(0)
121
130
  end
131
+
122
132
  it "returning :short (0x7fff)" do
123
- LibTest.testCallbackVrS16 { 0x7fff }.should == 0x7fff
133
+ expect(LibTest.testCallbackVrS16 { 0x7fff }).to eq(0x7fff)
124
134
  end
125
135
  # test wrap around
126
136
  it "returning :short (0x8000)" do
127
- LibTest.testCallbackVrS16 { 0x8000 }.should == -0x8000
137
+ expect(LibTest.testCallbackVrS16 { 0x8000 }).to eq(-0x8000)
128
138
  end
139
+
129
140
  it "returning :short (0xffff)" do
130
- LibTest.testCallbackVrS16 { 0xffff }.should == -1
141
+ expect(LibTest.testCallbackVrS16 { 0xffff }).to eq(-1)
131
142
  end
143
+
132
144
  it "returning :ushort (0)" do
133
- LibTest.testCallbackVrU16 { 0 }.should == 0
145
+ expect(LibTest.testCallbackVrU16 { 0 }).to eq(0)
134
146
  end
147
+
135
148
  it "returning :ushort (0x7fff)" do
136
- LibTest.testCallbackVrU16 { 0x7fff }.should == 0x7fff
149
+ expect(LibTest.testCallbackVrU16 { 0x7fff }).to eq(0x7fff)
137
150
  end
151
+
138
152
  it "returning :ushort (0x8000)" do
139
- LibTest.testCallbackVrU16 { 0x8000 }.should == 0x8000
153
+ expect(LibTest.testCallbackVrU16 { 0x8000 }).to eq(0x8000)
140
154
  end
155
+
141
156
  it "returning :ushort (0xffff)" do
142
- LibTest.testCallbackVrU16 { 0xffff }.should == 0xffff
157
+ expect(LibTest.testCallbackVrU16 { 0xffff }).to eq(0xffff)
143
158
  end
159
+
144
160
  it "returning :ushort (-1)" do
145
- LibTest.testCallbackVrU16 { -1 }.should == 0xffff
161
+ expect(LibTest.testCallbackVrU16 { -1 }).to eq(0xffff)
146
162
  end
163
+
147
164
  it "returning :int (0)" do
148
- LibTest.testCallbackVrS32 { 0 }.should == 0
165
+ expect(LibTest.testCallbackVrS32 { 0 }).to eq(0)
149
166
  end
167
+
150
168
  it "returning :int (0x7fffffff)" do
151
- LibTest.testCallbackVrS32 { 0x7fffffff }.should == 0x7fffffff
169
+ expect(LibTest.testCallbackVrS32 { 0x7fffffff }).to eq(0x7fffffff)
152
170
  end
153
171
  # test wrap around
154
172
  it "returning :int (-0x80000000)" do
155
- LibTest.testCallbackVrS32 { -0x80000000 }.should == -0x80000000
173
+ expect(LibTest.testCallbackVrS32 { -0x80000000 }).to eq(-0x80000000)
156
174
  end
175
+
157
176
  it "returning :int (-1)" do
158
- LibTest.testCallbackVrS32 { -1 }.should == -1
177
+ expect(LibTest.testCallbackVrS32 { -1 }).to eq(-1)
159
178
  end
179
+
160
180
  it "returning :uint (0)" do
161
- LibTest.testCallbackVrU32 { 0 }.should == 0
181
+ expect(LibTest.testCallbackVrU32 { 0 }).to eq(0)
162
182
  end
183
+
163
184
  it "returning :uint (0x7fffffff)" do
164
- LibTest.testCallbackVrU32 { 0x7fffffff }.should == 0x7fffffff
185
+ expect(LibTest.testCallbackVrU32 { 0x7fffffff }).to eq(0x7fffffff)
165
186
  end
166
187
  # test wrap around
167
188
  it "returning :uint (0x80000000)" do
168
- LibTest.testCallbackVrU32 { 0x80000000 }.should == 0x80000000
189
+ expect(LibTest.testCallbackVrU32 { 0x80000000 }).to eq(0x80000000)
169
190
  end
191
+
170
192
  it "returning :uint (0xffffffff)" do
171
- LibTest.testCallbackVrU32 { 0xffffffff }.should == 0xffffffff
193
+ expect(LibTest.testCallbackVrU32 { 0xffffffff }).to eq(0xffffffff)
172
194
  end
195
+
173
196
  it "returning :uint (-1)" do
174
- LibTest.testCallbackVrU32 { -1 }.should == 0xffffffff
197
+ expect(LibTest.testCallbackVrU32 { -1 }).to eq(0xffffffff)
175
198
  end
199
+
176
200
  it "returning :long (0)" do
177
- LibTest.testCallbackVrL { 0 }.should == 0
201
+ expect(LibTest.testCallbackVrL { 0 }).to eq(0)
178
202
  end
203
+
179
204
  it "returning :long (0x7fffffff)" do
180
- LibTest.testCallbackVrL { 0x7fffffff }.should == 0x7fffffff
205
+ expect(LibTest.testCallbackVrL { 0x7fffffff }).to eq(0x7fffffff)
181
206
  end
182
207
  # test wrap around
183
208
  it "returning :long (-0x80000000)" do
184
- LibTest.testCallbackVrL { -0x80000000 }.should == -0x80000000
209
+ expect(LibTest.testCallbackVrL { -0x80000000 }).to eq(-0x80000000)
185
210
  end
211
+
186
212
  it "returning :long (-1)" do
187
- LibTest.testCallbackVrL { -1 }.should == -1
213
+ expect(LibTest.testCallbackVrL { -1 }).to eq(-1)
188
214
  end
215
+
189
216
  it "returning :ulong (0)" do
190
- LibTest.testCallbackVrUL { 0 }.should == 0
217
+ expect(LibTest.testCallbackVrUL { 0 }).to eq(0)
191
218
  end
219
+
192
220
  it "returning :ulong (0x7fffffff)" do
193
- LibTest.testCallbackVrUL { 0x7fffffff }.should == 0x7fffffff
221
+ expect(LibTest.testCallbackVrUL { 0x7fffffff }).to eq(0x7fffffff)
194
222
  end
195
223
  # test wrap around
196
224
  it "returning :ulong (0x80000000)" do
197
- LibTest.testCallbackVrUL { 0x80000000 }.should == 0x80000000
225
+ expect(LibTest.testCallbackVrUL { 0x80000000 }).to eq(0x80000000)
198
226
  end
227
+
199
228
  it "returning :ulong (0xffffffff)" do
200
- LibTest.testCallbackVrUL { 0xffffffff }.should == 0xffffffff
229
+ expect(LibTest.testCallbackVrUL { 0xffffffff }).to eq(0xffffffff)
201
230
  end
231
+
202
232
  it "Callback returning :ulong (-1)" do
203
233
  if FFI::Platform::LONG_SIZE == 32
204
- LibTest.testCallbackVrUL { -1 }.should == 0xffffffff
234
+ expect(LibTest.testCallbackVrUL { -1 }).to eq(0xffffffff)
205
235
  else
206
- LibTest.testCallbackVrUL { -1 }.should == 0xffffffffffffffff
236
+ expect(LibTest.testCallbackVrUL { -1 }).to eq(0xffffffffffffffff)
207
237
  end
208
238
  end
239
+
209
240
  it "returning :long_long (0)" do
210
- LibTest.testCallbackVrS64 { 0 }.should == 0
241
+ expect(LibTest.testCallbackVrS64 { 0 }).to eq(0)
211
242
  end
243
+
212
244
  it "returning :long_long (0x7fffffffffffffff)" do
213
- LibTest.testCallbackVrS64 { 0x7fffffffffffffff }.should == 0x7fffffffffffffff
245
+ expect(LibTest.testCallbackVrS64 { 0x7fffffffffffffff }).to eq(0x7fffffffffffffff)
214
246
  end
215
247
  # test wrap around
216
248
  it "returning :long_long (-0x8000000000000000)" do
217
- LibTest.testCallbackVrS64 { -0x8000000000000000 }.should == -0x8000000000000000
249
+ expect(LibTest.testCallbackVrS64 { -0x8000000000000000 }).to eq(-0x8000000000000000)
218
250
  end
251
+
219
252
  it "returning :long_long (-1)" do
220
- LibTest.testCallbackVrS64 { -1 }.should == -1
253
+ expect(LibTest.testCallbackVrS64 { -1 }).to eq(-1)
221
254
  end
255
+
222
256
  it "returning bool" do
223
- LibTest.testCallbackVrZ { true }.should be_true
257
+ expect(LibTest.testCallbackVrZ { true }).to be true
224
258
  end
259
+
225
260
  it "returning :pointer (nil)" do
226
- LibTest.testCallbackVrP { nil }.null?.should be_true
261
+ expect(LibTest.testCallbackVrP { nil }).to be_null
227
262
  end
263
+
228
264
  it "returning :pointer (MemoryPointer)" do
229
265
  p = FFI::MemoryPointer.new :long
230
- LibTest.testCallbackVrP { p }.should == p
266
+ expect(LibTest.testCallbackVrP { p }).to eq(p)
231
267
  end
232
268
 
233
-
234
269
  it "returning struct by value" do
235
270
  s = LibTest::S8F32S32.new
236
271
  s[:s8] = 0x12
237
272
  s[:s32] = 0x1eefbeef
238
273
  s[:f32] = 1.234567
239
274
  ret = LibTest.testCallbackVrT { s }
240
- ret[:s8].should == s[:s8]
241
- ret[:f32].should == s[:f32]
242
- ret[:s32].should == s[:s32]
275
+ expect(ret[:s8]).to eq(s[:s8])
276
+ expect(ret[:f32]).to eq(s[:f32])
277
+ expect(ret[:s32]).to eq(s[:s32])
243
278
 
244
279
  end
245
280
 
@@ -249,11 +284,13 @@ describe "Callback" do
249
284
  s[:s32] = 0x1eefbeef
250
285
  s[:f32] = 1.234567
251
286
  s2 = LibTest::S8F32S32.new
287
+
252
288
  LibTest.testCallbackTrV(s) do |struct|
253
289
  s2[:s8] = struct[:s8]
254
290
  s2[:f32] = struct[:f32]
255
291
  s2[:s32] = struct[:s32]
256
292
  end
293
+
257
294
  expect(s2[:s8]).to eql 0x12
258
295
  expect(s2[:s32]).to eql 0x1eefbeef
259
296
  expect(s2[:f32]).to be_within(0.0000001).of 1.234567
@@ -263,12 +300,12 @@ describe "Callback" do
263
300
  it "global variable" do
264
301
  proc = Proc.new { 0x1e }
265
302
  LibTest.cbVrS8 = proc
266
- LibTest.testGVarCallbackVrS8(LibTest.pVrS8).should == 0x1e
303
+ expect(LibTest.testGVarCallbackVrS8(LibTest.pVrS8)).to eq(0x1e)
267
304
  end
268
305
 
269
306
  describe "When the callback is considered optional by the underlying library" do
270
307
  it "should handle receiving 'nil' in place of the closure" do
271
- LibTest.testOptionalCallbackCrV(nil, 13).should be_nil
308
+ expect(LibTest.testOptionalCallbackCrV(nil, 13)).to be_nil
272
309
  end
273
310
  end
274
311
 
@@ -279,20 +316,20 @@ describe "Callback" do
279
316
  ffi_lib TestLibrary::PATH
280
317
  attach_function :testAnonymousCallbackVrS8, :testClosureVrB, [ callback([ ], :char) ], :char
281
318
  end
282
- LibTest.testAnonymousCallbackVrS8 { 0 }.should == 0
319
+ expect(LibTest.testAnonymousCallbackVrS8 { 0 }).to eq(0)
283
320
  end
284
321
  end
285
322
 
286
323
  describe "as return value" do
287
324
 
288
325
  it "should not blow up when a callback is defined that returns a callback" do
289
- module LibTest
326
+ expect(module LibTest
290
327
  extend FFI::Library
291
328
  ffi_lib TestLibrary::PATH
292
329
  callback :cb_return_type_1, [ :short ], :short
293
330
  callback :cb_lookup_1, [ :short ], :cb_return_type_1
294
331
  attach_function :testReturnsCallback_1, :testReturnsClosure, [ :cb_lookup_1, :short ], :cb_return_type_1
295
- end.should be_an_instance_of FFI::Function
332
+ end).to be_an_instance_of FFI::Function
296
333
  end
297
334
 
298
335
  it "should return a callback" do
@@ -317,9 +354,9 @@ describe "Callback" do
317
354
  end
318
355
 
319
356
  val = LibTest.testReturnsCallback(lookup_proc, 0x1234)
320
- val.should == 0x1234 * 2
321
- lookup_proc_called.should be_true
322
- return_proc_called.should be_true
357
+ expect(val).to eq(0x1234 * 2)
358
+ expect(lookup_proc_called).to be true
359
+ expect(return_proc_called).to be true
323
360
  end
324
361
 
325
362
  it "should return a method callback" do
@@ -339,17 +376,17 @@ describe "Callback" do
339
376
  end
340
377
  end
341
378
 
342
- LibTest.testReturnsCallback_2(MethodCallback.method(:lookup), 0x1234).should == 0x2468
379
+ expect(LibTest.testReturnsCallback_2(MethodCallback.method(:lookup), 0x1234)).to eq(0x2468)
343
380
  end
344
381
 
345
382
  it 'should not blow up when a callback takes a callback as argument' do
346
- module LibTest
383
+ expect(module LibTest
347
384
  extend FFI::Library
348
385
  ffi_lib TestLibrary::PATH
349
386
  callback :cb_argument, [ :int ], :int
350
387
  callback :cb_with_cb_argument, [ :cb_argument, :int ], :int
351
388
  attach_function :testCallbackAsArgument_2, :testArgumentClosure, [ :cb_with_cb_argument, :int ], :int
352
- end.should be_an_instance_of FFI::Function
389
+ end).to be_an_instance_of FFI::Function
353
390
  end
354
391
  it 'should be able to use the callback argument' do
355
392
  module LibTest
@@ -360,7 +397,7 @@ describe "Callback" do
360
397
  attach_function :testCallbackAsArgument, :testArgumentClosure, [ :cb_with_cb_argument, :cb_argument, :int ], :int
361
398
  end
362
399
  callback_arg_called = false
363
- callback_with_callback_arg_called = false
400
+ callback_with_callback_arg_called = false
364
401
  callback_arg = Proc.new do |val|
365
402
  callback_arg_called = true
366
403
  val * 2
@@ -370,9 +407,9 @@ describe "Callback" do
370
407
  cb.call(val)
371
408
  end
372
409
  val = LibTest.testCallbackAsArgument(callback_with_callback_arg, callback_arg, 0xff1)
373
- val.should == 0xff1 * 2
374
- callback_arg_called.should be_true
375
- callback_with_callback_arg_called.should be_true
410
+ expect(val).to eq(0xff1 * 2)
411
+ expect(callback_arg_called).to be true
412
+ expect(callback_with_callback_arg_called).to be true
376
413
  end
377
414
  it 'function returns callable object' do
378
415
  module LibTest
@@ -382,7 +419,7 @@ describe "Callback" do
382
419
  attach_function :testReturnsFunctionPointer, [ ], :funcptr
383
420
  end
384
421
  f = LibTest.testReturnsFunctionPointer
385
- f.call(3).should == 6
422
+ expect(f.call(3)).to eq(6)
386
423
  end
387
424
  end
388
425
 
@@ -433,239 +470,281 @@ describe "Callback with " do
433
470
  attach_function :testCallbackPrV, :testClosurePrV, [ :cbPrV, :pointer], :void
434
471
  attach_function :testCallbackYrV, :testClosurePrV, [ :cbYrV, S8F32S32.in ], :void
435
472
  end
473
+
436
474
  it "function with Callback plus another arg should raise error if no arg given" do
437
- lambda { LibTest.testCallbackCrV { |*a| }}.should raise_error
475
+ expect { LibTest.testCallbackCrV { |*a| }}.to raise_error
438
476
  end
477
+
439
478
  it ":char (0) argument" do
440
479
  v = 0xdeadbeef
441
480
  LibTest.testCallbackCrV(0) { |i| v = i }
442
- v.should == 0
481
+ expect(v).to eq(0)
443
482
  end
483
+
444
484
  it ":char (127) argument" do
445
485
  v = 0xdeadbeef
446
486
  LibTest.testCallbackCrV(127) { |i| v = i }
447
- v.should == 127
487
+ expect(v).to eq(127)
448
488
  end
489
+
449
490
  it ":char (-128) argument" do
450
491
  v = 0xdeadbeef
451
492
  LibTest.testCallbackCrV(-128) { |i| v = i }
452
- v.should == -128
493
+ expect(v).to eq(-128)
453
494
  end
495
+
454
496
  it ":char (-1) argument" do
455
497
  v = 0xdeadbeef
456
498
  LibTest.testCallbackCrV(-1) { |i| v = i }
457
- v.should == -1
499
+ expect(v).to eq(-1)
458
500
  end
501
+
459
502
  it ":uchar (0) argument" do
460
503
  v = 0xdeadbeef
461
504
  LibTest.testCallbackU8rV(0) { |i| v = i }
462
- v.should == 0
505
+ expect(v).to eq(0)
463
506
  end
507
+
464
508
  it ":uchar (127) argument" do
465
509
  v = 0xdeadbeef
466
510
  LibTest.testCallbackU8rV(127) { |i| v = i }
467
- v.should == 127
511
+ expect(v).to eq(127)
468
512
  end
513
+
469
514
  it ":uchar (128) argument" do
470
515
  v = 0xdeadbeef
471
516
  LibTest.testCallbackU8rV(128) { |i| v = i }
472
- v.should == 128
517
+ expect(v).to eq(128)
473
518
  end
519
+
474
520
  it ":uchar (255) argument" do
475
521
  v = 0xdeadbeef
476
522
  LibTest.testCallbackU8rV(255) { |i| v = i }
477
- v.should == 255
523
+ expect(v).to eq(255)
478
524
  end
479
525
 
480
526
  it ":short (0) argument" do
481
527
  v = 0xdeadbeef
482
528
  LibTest.testCallbackSrV(0) { |i| v = i }
483
- v.should == 0
529
+ expect(v).to eq(0)
484
530
  end
531
+
485
532
  it ":short (0x7fff) argument" do
486
533
  v = 0xdeadbeef
487
534
  LibTest.testCallbackSrV(0x7fff) { |i| v = i }
488
- v.should == 0x7fff
535
+ expect(v).to eq(0x7fff)
489
536
  end
537
+
490
538
  it ":short (-0x8000) argument" do
491
539
  v = 0xdeadbeef
492
540
  LibTest.testCallbackSrV(-0x8000) { |i| v = i }
493
- v.should == -0x8000
541
+ expect(v).to eq(-0x8000)
494
542
  end
543
+
495
544
  it ":short (-1) argument" do
496
545
  v = 0xdeadbeef
497
546
  LibTest.testCallbackSrV(-1) { |i| v = i }
498
- v.should == -1
547
+ expect(v).to eq(-1)
499
548
  end
549
+
500
550
  it ":ushort (0) argument" do
501
551
  v = 0xdeadbeef
502
552
  LibTest.testCallbackU16rV(0) { |i| v = i }
503
- v.should == 0
553
+ expect(v).to eq(0)
504
554
  end
555
+
505
556
  it ":ushort (0x7fff) argument" do
506
557
  v = 0xdeadbeef
507
558
  LibTest.testCallbackU16rV(0x7fff) { |i| v = i }
508
- v.should == 0x7fff
559
+ expect(v).to eq(0x7fff)
509
560
  end
561
+
510
562
  it ":ushort (0x8000) argument" do
511
563
  v = 0xdeadbeef
512
564
  LibTest.testCallbackU16rV(0x8000) { |i| v = i }
513
- v.should == 0x8000
565
+ expect(v).to eq(0x8000)
514
566
  end
567
+
515
568
  it ":ushort (0xffff) argument" do
516
569
  v = 0xdeadbeef
517
570
  LibTest.testCallbackU16rV(0xffff) { |i| v = i }
518
- v.should == 0xffff
571
+ expect(v).to eq(0xffff)
519
572
  end
573
+
520
574
  it ":bool (true) argument" do
521
575
  v = false
522
576
  LibTest.testCallbackZrV(true) { |i| v = i }
523
- v.should be_true
577
+ expect(v).to be true
524
578
  end
579
+
525
580
  it ":int (0) argument" do
526
581
  v = 0xdeadbeef
527
582
  LibTest.testCallbackIrV(0) { |i| v = i }
528
- v.should == 0
583
+ expect(v).to eq(0)
529
584
  end
585
+
530
586
  it ":int (0x7fffffff) argument" do
531
587
  v = 0xdeadbeef
532
588
  LibTest.testCallbackIrV(0x7fffffff) { |i| v = i }
533
- v.should == 0x7fffffff
589
+ expect(v).to eq(0x7fffffff)
534
590
  end
591
+
535
592
  it ":int (-0x80000000) argument" do
536
593
  v = 0xdeadbeef
537
594
  LibTest.testCallbackIrV(-0x80000000) { |i| v = i }
538
- v.should == -0x80000000
595
+ expect(v).to eq(-0x80000000)
539
596
  end
597
+
540
598
  it ":int (-1) argument" do
541
599
  v = 0xdeadbeef
542
600
  LibTest.testCallbackIrV(-1) { |i| v = i }
543
- v.should == -1
601
+ expect(v).to eq(-1)
544
602
  end
603
+
545
604
  it ":uint (0) argument" do
546
605
  v = 0xdeadbeef
547
606
  LibTest.testCallbackU32rV(0) { |i| v = i }
548
- v.should == 0
607
+ expect(v).to eq(0)
549
608
  end
609
+
550
610
  it ":uint (0x7fffffff) argument" do
551
611
  v = 0xdeadbeef
552
612
  LibTest.testCallbackU32rV(0x7fffffff) { |i| v = i }
553
- v.should == 0x7fffffff
613
+ expect(v).to eq(0x7fffffff)
554
614
  end
615
+
555
616
  it ":uint (0x80000000) argument" do
556
617
  v = 0xdeadbeef
557
618
  LibTest.testCallbackU32rV(0x80000000) { |i| v = i }
558
- v.should == 0x80000000
619
+ expect(v).to eq(0x80000000)
559
620
  end
621
+
560
622
  it ":uint (0xffffffff) argument" do
561
623
  v = 0xdeadbeef
562
624
  LibTest.testCallbackU32rV(0xffffffff) { |i| v = i }
563
- v.should == 0xffffffff
625
+ expect(v).to eq(0xffffffff)
564
626
  end
627
+
565
628
  it ":long (0) argument" do
566
629
  v = 0xdeadbeef
567
630
  LibTest.testCallbackLrV(0) { |i| v = i }
568
- v.should == 0
631
+ expect(v).to eq(0)
569
632
  end
633
+
570
634
  it ":long (0x7fffffff) argument" do
571
635
  v = 0xdeadbeef
572
636
  LibTest.testCallbackLrV(0x7fffffff) { |i| v = i }
573
- v.should == 0x7fffffff
637
+ expect(v).to eq(0x7fffffff)
574
638
  end
639
+
575
640
  it ":long (-0x80000000) argument" do
576
641
  v = 0xdeadbeef
577
642
  LibTest.testCallbackLrV(-0x80000000) { |i| v = i }
578
- v.should == -0x80000000
643
+ expect(v).to eq(-0x80000000)
579
644
  end
645
+
580
646
  it ":long (-1) argument" do
581
647
  v = 0xdeadbeef
582
648
  LibTest.testCallbackLrV(-1) { |i| v = i }
583
- v.should == -1
649
+ expect(v).to eq(-1)
584
650
  end
651
+
585
652
  it ":ulong (0) argument" do
586
653
  v = 0xdeadbeef
587
654
  LibTest.testCallbackULrV(0) { |i| v = i }
588
- v.should == 0
655
+ expect(v).to eq(0)
589
656
  end
657
+
590
658
  it ":ulong (0x7fffffff) argument" do
591
659
  v = 0xdeadbeef
592
660
  LibTest.testCallbackULrV(0x7fffffff) { |i| v = i }
593
- v.should == 0x7fffffff
661
+ expect(v).to eq(0x7fffffff)
594
662
  end
663
+
595
664
  it ":ulong (0x80000000) argument" do
596
665
  v = 0xdeadbeef
597
666
  LibTest.testCallbackULrV(0x80000000) { |i| v = i }
598
- v.should == 0x80000000
667
+ expect(v).to eq(0x80000000)
599
668
  end
669
+
600
670
  it ":ulong (0xffffffff) argument" do
601
671
  v = 0xdeadbeef
602
672
  LibTest.testCallbackULrV(0xffffffff) { |i| v = i }
603
- v.should == 0xffffffff
673
+ expect(v).to eq(0xffffffff)
604
674
  end
675
+
605
676
  it ":long_long (0) argument" do
606
677
  v = 0xdeadbeef
607
678
  LibTest.testCallbackLLrV(0) { |i| v = i }
608
- v.should == 0
679
+ expect(v).to eq(0)
609
680
  end
681
+
610
682
  it ":long_long (0x7fffffffffffffff) argument" do
611
683
  v = 0xdeadbeef
612
684
  LibTest.testCallbackLLrV(0x7fffffffffffffff) { |i| v = i }
613
- v.should == 0x7fffffffffffffff
685
+ expect(v).to eq(0x7fffffffffffffff)
614
686
  end
687
+
615
688
  it ":long_long (-0x8000000000000000) argument" do
616
689
  v = 0xdeadbeef
617
690
  LibTest.testCallbackLLrV(-0x8000000000000000) { |i| v = i }
618
- v.should == -0x8000000000000000
691
+ expect(v).to eq(-0x8000000000000000)
619
692
  end
693
+
620
694
  it ":long_long (-1) argument" do
621
695
  v = 0xdeadbeef
622
696
  LibTest.testCallbackLLrV(-1) { |i| v = i }
623
- v.should == -1
697
+ expect(v).to eq(-1)
624
698
  end
699
+
625
700
  it ":string argument" do
626
701
  v = nil
627
702
  LibTest.testCallbackArV("Hello, World") { |i| v = i }
628
- v.should == "Hello, World"
703
+ expect(v).to eq("Hello, World")
629
704
  end
705
+
630
706
  it ":string (nil) argument" do
631
707
  v = "Hello, World"
632
708
  LibTest.testCallbackArV(nil) { |i| v = i }
633
- v.should be_nil
709
+ expect(v).to be_nil
634
710
  end
711
+
635
712
  it ":pointer argument" do
636
713
  v = nil
637
714
  magic = FFI::Pointer.new(0xdeadbeef)
638
715
  LibTest.testCallbackPrV(magic) { |i| v = i }
639
- v.should == magic
716
+ expect(v).to eq(magic)
640
717
  end
718
+
641
719
  it ":pointer (nil) argument" do
642
720
  v = "Hello, World"
643
721
  LibTest.testCallbackPrV(nil) { |i| v = i }
644
- v.should == FFI::Pointer::NULL
722
+ expect(v).to eq(FFI::Pointer::NULL)
645
723
  end
724
+
646
725
  it "struct by reference argument" do
647
726
  v = nil
648
727
  magic = LibTest::S8F32S32.new
649
728
  LibTest.testCallbackYrV(magic) { |i| v = i }
650
- v.class.should == magic.class
651
- v.pointer.should == magic.pointer
729
+ expect(v.class).to eq(magic.class)
730
+ expect(v.pointer).to eq(magic.pointer)
652
731
  end
653
732
 
654
733
  it "struct by reference argument with nil value" do
655
734
  v = LibTest::S8F32S32.new
656
735
  LibTest.testCallbackYrV(nil) { |i| v = i }
657
- v.is_a?(FFI::Struct).should be_true
658
- v.pointer.should == FFI::Pointer::NULL
736
+ expect(v.is_a?(FFI::Struct)).to be true
737
+ expect(v.pointer).to eq(FFI::Pointer::NULL)
659
738
  end
660
739
 
661
740
  it "varargs parameters are rejected" do
662
- lambda {
741
+ expect {
663
742
  Module.new do
664
743
  extend FFI::Library
665
744
  ffi_lib TestLibrary::PATH
666
745
  callback :cbVrL, [ :varargs ], :long
667
746
  end
668
- }.should raise_error(ArgumentError)
747
+ }.to raise_error(ArgumentError)
669
748
  end
670
749
 
671
750
  #
@@ -687,8 +766,8 @@ describe "Callback with " do
687
766
  po = FFI::MemoryPointer.new :long
688
767
  pr = proc{|a,i| v = a,i; i }
689
768
  res = LibTestStdcall.testCallbackStdcall(po, pr, 0x7fffffff)
690
- v.should == [po, 0x7fffffff]
691
- res.should be_true
769
+ expect(v).to eq([po, 0x7fffffff])
770
+ expect(res).to be true
692
771
  end
693
772
  end
694
773
  end