gir_ffi 0.6.4 → 0.6.5

Sign up to get free protection for your applications and to get access to all the features.
Files changed (40) hide show
  1. data/History.txt +6 -0
  2. data/lib/ffi-glib/array.rb +12 -3
  3. data/lib/ffi-glib/list_methods.rb +4 -0
  4. data/lib/ffi-glib/ptr_array.rb +4 -0
  5. data/lib/ffi-glib/sized_array.rb +4 -0
  6. data/lib/ffi-glib/strv.rb +4 -1
  7. data/lib/gir_ffi/arg_helper.rb +5 -27
  8. data/lib/gir_ffi/class_base.rb +8 -0
  9. data/lib/gir_ffi/enum_base.rb +8 -0
  10. data/lib/gir_ffi/ffi_ext/pointer.rb +12 -0
  11. data/lib/gir_ffi/in_out_pointer.rb +3 -13
  12. data/lib/gir_ffi/in_pointer.rb +19 -1
  13. data/lib/gir_ffi/info_ext/i_enum_info.rb +0 -2
  14. data/lib/gir_ffi/info_ext/i_object_info.rb +1 -1
  15. data/lib/gir_ffi/info_ext/i_type_info.rb +3 -14
  16. data/lib/gir_ffi/module_base.rb +1 -0
  17. data/lib/gir_ffi/type_map.rb +6 -8
  18. data/lib/gir_ffi/version.rb +1 -1
  19. data/lib/gir_ffi/zero_terminated.rb +5 -1
  20. data/tasks/test.rake +1 -0
  21. data/test/ffi-glib/array_test.rb +41 -7
  22. data/test/ffi-glib/hash_table_test.rb +3 -3
  23. data/test/ffi-glib/list_test.rb +31 -3
  24. data/test/ffi-glib/ptr_array_test.rb +28 -0
  25. data/test/ffi-glib/s_list_test.rb +28 -0
  26. data/test/ffi-glib/sized_array_test.rb +30 -3
  27. data/test/ffi-glib/strv_test.rb +31 -0
  28. data/test/ffi-gobject_test.rb +2 -2
  29. data/test/gir_ffi/arg_helper_test.rb +3 -2
  30. data/test/gir_ffi/class_base_test.rb +62 -4
  31. data/test/gir_ffi/function_builder_test.rb +1 -1
  32. data/test/gir_ffi/in_pointer_test.rb +17 -0
  33. data/test/gir_ffi/info_ext/i_object_info_test.rb +14 -0
  34. data/test/gir_ffi/info_ext/i_type_info_test.rb +79 -25
  35. data/test/gir_ffi/type_map_test.rb +15 -0
  36. data/test/gir_ffi/zero_terminated_test.rb +28 -0
  37. data/test/integration/generated_gimarshallingtests_test.rb +90 -75
  38. data/test/integration/generated_pango_test.rb +1 -1
  39. data/test/integration/generated_regress_test.rb +64 -39
  40. metadata +8 -18
@@ -8,6 +8,7 @@ describe GirFFI::InfoExt::ITypeInfo do
8
8
  let(:elmtype_info) { klass.new }
9
9
  let(:keytype_info) { klass.new }
10
10
  let(:valtype_info) { klass.new }
11
+ let(:iface_info) { Object.new }
11
12
 
12
13
  describe "#to_ffitype" do
13
14
  it "returns an array with elements subtype and size for type :array" do
@@ -21,11 +22,25 @@ describe GirFFI::InfoExt::ITypeInfo do
21
22
  result = type_info.to_ffitype
22
23
  assert_equal [:foo, 2], result
23
24
  end
25
+
26
+ describe "for an :interface type" do
27
+ before do
28
+ stub(type_info).interface { iface_info }
29
+ stub(type_info).tag { :interface }
30
+ stub(type_info).pointer? { false }
31
+ end
32
+
33
+ it "maps a the interface's ffitype" do
34
+ stub(iface_info).to_ffitype { :foo }
35
+
36
+ type_info.to_ffitype.must_equal :foo
37
+ end
38
+ end
24
39
  end
25
40
 
26
41
  describe "#element_type" do
27
42
  it "returns the element type for lists" do
28
- mock(elmtype_info).tag { :foo }
43
+ stub(elmtype_info).tag { :foo }
29
44
  mock(elmtype_info).pointer? { false }
30
45
 
31
46
  mock(type_info).tag {:glist}
@@ -36,9 +51,9 @@ describe GirFFI::InfoExt::ITypeInfo do
36
51
  end
37
52
 
38
53
  it "returns the key and value types for ghashes" do
39
- mock(keytype_info).tag { :foo }
54
+ stub(keytype_info).tag { :foo }
40
55
  mock(keytype_info).pointer? { false }
41
- mock(valtype_info).tag { :bar }
56
+ stub(valtype_info).tag { :bar }
42
57
  mock(valtype_info).pointer? { false }
43
58
 
44
59
  mock(type_info).tag {:ghash}
@@ -149,7 +164,7 @@ describe GirFFI::InfoExt::ITypeInfo do
149
164
  describe "#tag_or_class_name" do
150
165
  describe "for the simple type :foo" do
151
166
  it "returns the string ':foo'" do
152
- mock(type_info).tag { :foo }
167
+ stub(type_info).tag { :foo }
153
168
  mock(type_info).pointer? { false }
154
169
 
155
170
  assert_equal ":foo", type_info.tag_or_class_name
@@ -158,20 +173,39 @@ describe GirFFI::InfoExt::ITypeInfo do
158
173
 
159
174
  describe "for :utf8" do
160
175
  it "returns the string ':utf8'" do
161
- mock(type_info).tag { :utf8 }
176
+ stub(type_info).tag { :utf8 }
162
177
  mock(type_info).pointer? { true }
163
178
 
164
179
  assert_equal ":utf8", type_info.tag_or_class_name
165
180
  end
166
181
  end
167
182
 
168
- describe "for an interface class" do
169
- it "returns the interface's full class name" do
170
- mock(type_info).tag { :interface }
171
- mock(type_info).interface_type_name { "-full-type-name-" }
183
+ describe "for an interface named Foo::Bar" do
184
+ let(:interface) { Object.new }
185
+
186
+ before do
187
+ stub(type_info).tag { :interface }
188
+ stub(type_info).interface { iface_info }
172
189
  mock(type_info).pointer? { false }
190
+ stub(interface).inspect { "Foo::Bar" }
173
191
 
174
- assert_equal "-full-type-name-", type_info.tag_or_class_name
192
+ mock(GirFFI::Builder).build_class(iface_info) { interface }
193
+ end
194
+
195
+ context "when the interface type is :enum" do
196
+ it "returns the interface's full class name" do
197
+ stub(iface_info).info_type { :enum }
198
+
199
+ assert_equal "Foo::Bar", type_info.tag_or_class_name
200
+ end
201
+ end
202
+
203
+ context "when the interface type is :object" do
204
+ it "returns the string [:pointer, Foo::Bar]" do
205
+ stub(iface_info).info_type { :object }
206
+
207
+ assert_equal "[:pointer, Foo::Bar]", type_info.tag_or_class_name
208
+ end
175
209
  end
176
210
  end
177
211
 
@@ -188,7 +222,7 @@ describe GirFFI::InfoExt::ITypeInfo do
188
222
  describe "#tag_or_class" do
189
223
  describe "for a simple type" do
190
224
  it "returns the type's tag" do
191
- mock(type_info).tag { :foo }
225
+ stub(type_info).tag { :foo }
192
226
  mock(type_info).pointer? { false }
193
227
 
194
228
  type_info.tag_or_class.must_equal :foo
@@ -197,7 +231,7 @@ describe GirFFI::InfoExt::ITypeInfo do
197
231
 
198
232
  describe "for utf8 strings" do
199
233
  it "returns the tag :utf8" do
200
- mock(type_info).tag { :utf8 }
234
+ stub(type_info).tag { :utf8 }
201
235
  mock(type_info).pointer? { true }
202
236
 
203
237
  type_info.tag_or_class.must_equal :utf8
@@ -206,7 +240,7 @@ describe GirFFI::InfoExt::ITypeInfo do
206
240
 
207
241
  describe "for filename strings" do
208
242
  it "returns the tag :filename" do
209
- mock(type_info).tag { :filename }
243
+ stub(type_info).tag { :filename }
210
244
  mock(type_info).pointer? { true }
211
245
 
212
246
  type_info.tag_or_class.must_equal :filename
@@ -214,23 +248,44 @@ describe GirFFI::InfoExt::ITypeInfo do
214
248
  end
215
249
 
216
250
  describe "for an interface class" do
217
- it "returns the class built from the interface" do
218
- interface_info = Object.new
219
- interface = Object.new
251
+ let(:interface) { Object.new }
220
252
 
221
- mock(type_info).tag { :interface }
222
- mock(type_info).interface { interface_info }
253
+ before do
254
+ stub(type_info).tag { :interface }
255
+ stub(type_info).interface { iface_info }
223
256
  mock(type_info).pointer? { false }
224
257
 
225
- mock(GirFFI::Builder).build_class(interface_info) { interface }
258
+ mock(GirFFI::Builder).build_class(iface_info) { interface }
259
+ end
260
+
261
+ context "when the interface type is :enum" do
262
+ it "returns the built interface module" do
263
+ stub(iface_info).info_type { :enum }
264
+
265
+ type_info.tag_or_class.must_equal interface
266
+ end
267
+ end
268
+
269
+ context "when the interface type is :object" do
270
+ it "returns an array with elements :pointer and built interface class" do
271
+ stub(iface_info).info_type { :object }
226
272
 
227
- type_info.tag_or_class.must_equal interface
273
+ type_info.tag_or_class.must_equal [:pointer, interface]
274
+ end
275
+ end
276
+
277
+ context "when the interface type is :struct" do
278
+ it "returns the built interface class" do
279
+ stub(iface_info).info_type { :struct }
280
+
281
+ type_info.tag_or_class.must_equal interface
282
+ end
228
283
  end
229
284
  end
230
285
 
231
286
  describe "for a pointer to simple type :foo" do
232
287
  it "returns [:pointer, :foo]" do
233
- mock(type_info).tag { :foo }
288
+ stub(type_info).tag { :foo }
234
289
  mock(type_info).pointer? { true }
235
290
 
236
291
  type_info.tag_or_class.must_equal [:pointer, :foo]
@@ -248,22 +303,21 @@ describe GirFFI::InfoExt::ITypeInfo do
248
303
  end
249
304
 
250
305
  describe "#to_callback_ffitype" do
251
- let(:iface) { Object.new }
252
306
  describe "for an :interface argument" do
253
307
  before do
254
- stub(type_info).interface { iface }
308
+ stub(type_info).interface { iface_info }
255
309
  stub(type_info).tag { :interface }
256
310
  stub(type_info).pointer? { false }
257
311
  end
258
312
 
259
313
  it "correctly maps a :union argument to :pointer" do
260
- stub(iface).info_type { :union }
314
+ stub(iface_info).info_type { :union }
261
315
 
262
316
  type_info.to_callback_ffitype.must_equal :pointer
263
317
  end
264
318
 
265
319
  it "correctly maps a :flags argument to :int32" do
266
- stub(iface).info_type { :flags }
320
+ stub(iface_info).info_type { :flags }
267
321
 
268
322
  type_info.to_callback_ffitype.must_equal :int32
269
323
  end
@@ -0,0 +1,15 @@
1
+ require 'gir_ffi_test_helper'
2
+
3
+ describe GirFFI::TypeMap do
4
+ describe ".type_specification_to_ffitype" do
5
+ it "returns the nested FFI::Enum for an Enum module" do
6
+ GirFFI::TypeMap.type_specification_to_ffitype(GLib::DateMonth).
7
+ must_equal GLib::DateMonth::Enum
8
+ end
9
+
10
+ it "returns the nested FFI::Struct for an Struct module" do
11
+ GirFFI::TypeMap.type_specification_to_ffitype(GObject::EnumValue).
12
+ must_equal GObject::EnumValue::Struct
13
+ end
14
+ end
15
+ end
@@ -51,6 +51,34 @@ describe GirFFI::ZeroTerminated do
51
51
 
52
52
  end
53
53
 
54
+ describe "#==" do
55
+ it "returns true when comparing to an array with the same elements" do
56
+ zero_terminated = GirFFI::ZeroTerminated.from :int32, [1, 2, 3]
57
+
58
+ (zero_terminated == [1, 2, 3]).must_equal true
59
+ end
60
+
61
+ it "returns false when comparing to an array with different elements" do
62
+ zero_terminated = GirFFI::ZeroTerminated.from :int32, [1, 2, 3]
63
+
64
+ (zero_terminated == [1, 2]).must_equal false
65
+ end
66
+
67
+ it "returns true when comparing to a zero-terminated array with the same elements" do
68
+ zero_terminated = GirFFI::ZeroTerminated.from :int32, [1, 2, 3]
69
+ other = GirFFI::ZeroTerminated.from :int32, [1, 2, 3]
70
+
71
+ (zero_terminated == other).must_equal true
72
+ end
73
+
74
+ it "returns false when comparing to a zero-terminated array with different elements" do
75
+ zero_terminated = GirFFI::ZeroTerminated.from :int32, [1, 2, 3]
76
+ other = GirFFI::ZeroTerminated.from :int32, [1, 2]
77
+
78
+ (zero_terminated == other).must_equal false
79
+ end
80
+ end
81
+
54
82
  it "includes Enumerable" do
55
83
  GirFFI::ZeroTerminated.must_include Enumerable
56
84
  end
@@ -34,9 +34,9 @@ describe GIMarshallingTests do
34
34
  end
35
35
 
36
36
  it "has a writable field g_strv" do
37
- assert_equal [], @bx.g_strv.to_a
37
+ @bx.g_strv.must_be :==, []
38
38
  @bx.g_strv = ["foo", "bar"]
39
- assert_equal ["foo", "bar"], @bx.g_strv.to_a
39
+ @bx.g_strv.must_be :==, ["foo", "bar"]
40
40
  end
41
41
  end
42
42
 
@@ -58,7 +58,7 @@ describe GIMarshallingTests do
58
58
  it "has a working function #returnv" do
59
59
  res = GIMarshallingTests::BoxedStruct.returnv
60
60
  assert_equal 42, res.long_
61
- assert_equal ["0", "1", "2"], res.g_strv.to_a
61
+ res.g_strv.must_be :==, ["0", "1", "2"]
62
62
  end
63
63
  end
64
64
 
@@ -244,7 +244,7 @@ describe GIMarshallingTests do
244
244
  ob = GIMarshallingTests::Object.new 42
245
245
  res = GIMarshallingTests::Object.full_inout ob
246
246
  assert_instance_of GIMarshallingTests::Object, res
247
- refute_equal res.to_ptr, ob.to_ptr
247
+ ob.wont_equal res
248
248
  end
249
249
 
250
250
  it "has a working function #full_out" do
@@ -265,7 +265,7 @@ describe GIMarshallingTests do
265
265
  ob = GIMarshallingTests::Object.new 42
266
266
  res = GIMarshallingTests::Object.none_inout ob
267
267
  assert_instance_of GIMarshallingTests::Object, res
268
- refute_equal res.to_ptr, ob.to_ptr
268
+ ob.wont_equal res
269
269
  end
270
270
 
271
271
  it "has a working function #none_out" do
@@ -335,17 +335,17 @@ describe GIMarshallingTests do
335
335
 
336
336
  it "has a working method #method_array_inout" do
337
337
  res = instance.method_array_inout [-1, 0, 1, 2]
338
- assert_equal [-2, -1, 0, 1, 2], res.to_a
338
+ res.must_be :==, [-2, -1, 0, 1, 2]
339
339
  end
340
340
 
341
341
  it "has a working method #method_array_out" do
342
342
  res = instance.method_array_out
343
- assert_equal [-1, 0, 1, 2], res.to_a
343
+ res.must_be :==, [-1, 0, 1, 2]
344
344
  end
345
345
 
346
346
  it "has a working method #method_array_return" do
347
347
  res = instance.method_array_return
348
- assert_equal [-1, 0, 1, 2], res.to_a
348
+ res.must_be :==, [-1, 0, 1, 2]
349
349
  end
350
350
 
351
351
  it "has a working method #method_int8_arg_and_out_callee" do
@@ -665,7 +665,7 @@ describe GIMarshallingTests do
665
665
 
666
666
  it "has a working function #array_fixed_inout" do
667
667
  res = GIMarshallingTests.array_fixed_inout [-1, 0, 1, 2]
668
- assert_equal [2, 1, 0, -1], res.to_a
668
+ res.must_be :==, [2, 1, 0, -1]
669
669
  end
670
670
 
671
671
  it "has a working function #array_fixed_int_in" do
@@ -675,12 +675,12 @@ describe GIMarshallingTests do
675
675
 
676
676
  it "has a working function #array_fixed_int_return" do
677
677
  res = GIMarshallingTests.array_fixed_int_return
678
- assert_equal [-1, 0, 1, 2], res.to_a
678
+ res.must_be :==, [-1, 0, 1, 2]
679
679
  end
680
680
 
681
681
  it "has a working function #array_fixed_out" do
682
682
  res = GIMarshallingTests.array_fixed_out
683
- assert_equal [-1, 0, 1, 2], res.to_a
683
+ res.must_be :==, [-1, 0, 1, 2]
684
684
  end
685
685
 
686
686
  it "has a working function #array_fixed_out_struct" do
@@ -695,7 +695,7 @@ describe GIMarshallingTests do
695
695
 
696
696
  it "has a working function #array_fixed_short_return" do
697
697
  res = GIMarshallingTests.array_fixed_short_return
698
- assert_equal [-1, 0, 1, 2], res.to_a
698
+ res.must_be :==, [-1, 0, 1, 2]
699
699
  end
700
700
 
701
701
  it "has a working function #array_gvariant_container_in" do
@@ -761,39 +761,42 @@ describe GIMarshallingTests do
761
761
 
762
762
  it "has a working function #array_inout" do
763
763
  res = GIMarshallingTests.array_inout [-1, 0, 1, 2]
764
- assert_equal [-2, -1, 0, 1, 2], res.to_a
764
+ res.must_be :==, [-2, -1, 0, 1, 2]
765
765
  end
766
766
 
767
767
  it "has a working function #array_inout_etc" do
768
768
  arr, sum = GIMarshallingTests.array_inout_etc 42, [-1, 0, 1, 2], 24
769
- arr.to_a.must_equal [42, -1, 0, 1, 24]
769
+ arr.must_be :==, [42, -1, 0, 1, 24]
770
770
  sum.must_equal 42 + 24
771
771
  end
772
772
 
773
773
  it "has a working function #array_out" do
774
774
  res = GIMarshallingTests.array_out
775
- assert_equal [-1, 0, 1, 2], res.to_a
775
+ res.must_be :==, [-1, 0, 1, 2]
776
776
  end
777
777
 
778
778
  it "has a working function #array_out_etc" do
779
779
  arr, sum = GIMarshallingTests.array_out_etc 42, 24
780
- arr.to_a.must_equal [42, 0, 1, 24]
780
+ arr.must_be :==, [42, 0, 1, 24]
781
781
  sum.must_equal 42 + 24
782
782
  end
783
783
 
784
784
  it "has a working function #array_return" do
785
785
  res = GIMarshallingTests.array_return
786
- assert_equal [-1, 0, 1, 2], res.to_a
786
+ res.must_be :==, [-1, 0, 1, 2]
787
787
  end
788
788
 
789
789
  it "has a working function #array_return_etc" do
790
790
  arr, sum = GIMarshallingTests.array_return_etc 42, 24
791
- arr.to_a.must_equal [42, 0, 1, 24]
791
+ arr.must_be :==, [42, 0, 1, 24]
792
792
  sum.must_equal 42 + 24
793
793
  end
794
794
 
795
795
  it "has a working function #array_simple_struct_in" do
796
- skip "Non-pointer arrays of complex types are not supported yet"
796
+ arr = [1, 2, 3].map { |val|
797
+ GIMarshallingTests::SimpleStruct.new.tap { |struct| struct.long_ = val }
798
+ }
799
+ GIMarshallingTests.array_simple_struct_in arr
797
800
  end
798
801
 
799
802
  it "has a working function #array_string_in" do
@@ -817,7 +820,11 @@ describe GIMarshallingTests do
817
820
  end
818
821
 
819
822
  it "has a working function #array_struct_value_in" do
820
- skip "Non-pointer arrays of complex types are not supported yet"
823
+ skip unless get_introspection_data 'GIMarshallingTests', 'array_struct_value_in'
824
+ arr = [1, 2, 3].map { |val|
825
+ GIMarshallingTests::BoxedStruct.new.tap { |struct| struct.long_ = val }
826
+ }
827
+ GIMarshallingTests.array_struct_value_in arr
821
828
  end
822
829
 
823
830
  it "has a working function #array_uint8_in" do
@@ -833,22 +840,22 @@ describe GIMarshallingTests do
833
840
 
834
841
  it "has a working function #array_zero_terminated_inout" do
835
842
  res = GIMarshallingTests.array_zero_terminated_inout ["0", "1", "2"]
836
- res.to_a.must_equal ["-1", "0", "1", "2"]
843
+ res.must_be :==, ["-1", "0", "1", "2"]
837
844
  end
838
845
 
839
846
  it "has a working function #array_zero_terminated_out" do
840
847
  res = GIMarshallingTests.array_zero_terminated_out
841
- assert_equal ["0", "1", "2"], res.to_a
848
+ res.must_be :==, ["0", "1", "2"]
842
849
  end
843
850
 
844
851
  it "has a working function #array_zero_terminated_return" do
845
852
  res = GIMarshallingTests.array_zero_terminated_return
846
- assert_equal ["0", "1", "2"], res.to_a
853
+ res.must_be :==, ["0", "1", "2"]
847
854
  end
848
855
 
849
856
  it "has a working function #array_zero_terminated_return_null" do
850
857
  res = GIMarshallingTests.array_zero_terminated_return_null
851
- res.to_a.must_equal []
858
+ res.must_be :==, []
852
859
  end
853
860
 
854
861
  it "has a working function #array_zero_terminated_return_struct" do
@@ -911,7 +918,7 @@ describe GIMarshallingTests do
911
918
  it "has a working function #boxed_struct_returnv" do
912
919
  res = GIMarshallingTests.boxed_struct_returnv
913
920
  assert_equal 42, res.long_
914
- assert_equal ["0", "1", "2"], res.g_strv.to_a
921
+ res.g_strv.must_be :==, ["0", "1", "2"]
915
922
  end
916
923
 
917
924
  it "has a working function #bytearray_full_return" do
@@ -1053,7 +1060,7 @@ describe GIMarshallingTests do
1053
1060
 
1054
1061
  it "has a working function #garray_int_none_return" do
1055
1062
  arr = GIMarshallingTests.garray_int_none_return
1056
- assert_equal [-1, 0, 1, 2], arr.to_a
1063
+ arr.must_be :==, [-1, 0, 1, 2]
1057
1064
  end
1058
1065
 
1059
1066
  it "has a working function #garray_uint64_none_in" do
@@ -1065,45 +1072,45 @@ describe GIMarshallingTests do
1065
1072
  it "has a working function #garray_uint64_none_return" do
1066
1073
  skip unless get_introspection_data 'GIMarshallingTests', 'garray_uint64_none_return'
1067
1074
  res = GIMarshallingTests.garray_uint64_none_return
1068
- res.to_a.must_equal [0, 0xffff_ffff_ffff_ffff]
1075
+ res.must_be :==, [0, 0xffff_ffff_ffff_ffff]
1069
1076
  end
1070
1077
 
1071
1078
  it "has a working function #garray_utf8_container_inout" do
1072
1079
  res = GIMarshallingTests.garray_utf8_container_inout ["0", "1", "2"]
1073
- res.to_a.must_equal ["-2", "-1", "0", "1"]
1080
+ res.must_be :==, ["-2", "-1", "0", "1"]
1074
1081
  end
1075
1082
 
1076
1083
  it "has a working function #garray_utf8_container_out" do
1077
1084
  res = GIMarshallingTests.garray_utf8_container_out
1078
- assert_equal ["0", "1", "2"], res.to_a
1085
+ res.must_be :==, ["0", "1", "2"]
1079
1086
  end
1080
1087
 
1081
1088
  it "has a working function #garray_utf8_container_return" do
1082
1089
  res = GIMarshallingTests.garray_utf8_container_return
1083
- assert_equal ["0", "1", "2"], res.to_a
1090
+ res.must_be :==, ["0", "1", "2"]
1084
1091
  end
1085
1092
 
1086
1093
  it "has a working function #garray_utf8_full_inout" do
1087
1094
  arr = ["0", "1", "2"]
1088
1095
  res = GIMarshallingTests.garray_utf8_full_inout arr
1089
- assert_equal ["-2", "-1", "0", "1"], res.to_a
1096
+ res.must_be :==, ["-2", "-1", "0", "1"]
1090
1097
  end
1091
1098
 
1092
1099
  it "has a working function #garray_utf8_full_out" do
1093
1100
  res = GIMarshallingTests.garray_utf8_full_out
1094
- assert_equal ["0", "1", "2"], res.to_a
1101
+ res.must_be :==, ["0", "1", "2"]
1095
1102
  end
1096
1103
 
1097
1104
  it "has a working function #garray_utf8_full_out_caller_allocated" do
1098
1105
  skip unless get_introspection_data 'GIMarshallingTests',
1099
1106
  'garray_utf8_full_out_caller_allocated'
1100
1107
  res = GIMarshallingTests.garray_utf8_full_out_caller_allocated
1101
- assert_equal ["0", "1", "2"], res.to_a
1108
+ res.must_be :==, ["0", "1", "2"]
1102
1109
  end
1103
1110
 
1104
1111
  it "has a working function #garray_utf8_full_return" do
1105
1112
  res = GIMarshallingTests.garray_utf8_full_return
1106
- assert_equal ["0", "1", "2"], res.to_a
1113
+ res.must_be :==, ["0", "1", "2"]
1107
1114
  end
1108
1115
 
1109
1116
  it "has a working function #garray_utf8_none_in" do
@@ -1115,17 +1122,17 @@ describe GIMarshallingTests do
1115
1122
  it "has a working function #garray_utf8_none_inout" do
1116
1123
  arr = ["0", "1", "2"]
1117
1124
  res = GIMarshallingTests.garray_utf8_none_inout arr
1118
- assert_equal ["-2", "-1", "0", "1"], res.to_a
1125
+ res.must_be :==, ["-2", "-1", "0", "1"]
1119
1126
  end
1120
1127
 
1121
1128
  it "has a working function #garray_utf8_none_out" do
1122
1129
  res = GIMarshallingTests.garray_utf8_none_out
1123
- assert_equal ["0", "1", "2"], res.to_a
1130
+ res.must_be :==, ["0", "1", "2"]
1124
1131
  end
1125
1132
 
1126
1133
  it "has a working function #garray_utf8_none_return" do
1127
1134
  res = GIMarshallingTests.garray_utf8_none_return
1128
- assert_equal ["0", "1", "2"], res.to_a
1135
+ res.must_be :==, ["0", "1", "2"]
1129
1136
  end
1130
1137
 
1131
1138
  it "has a working function #gbytes_full_return" do
@@ -1287,7 +1294,7 @@ describe GIMarshallingTests do
1287
1294
 
1288
1295
  it "has a working function #glist_int_none_return" do
1289
1296
  res = GIMarshallingTests.glist_int_none_return
1290
- assert_equal [-1, 0, 1, 2], res.to_a
1297
+ res.must_be :==, [-1, 0, 1, 2]
1291
1298
  end
1292
1299
 
1293
1300
  it "has a working function #glist_uint32_none_in" do
@@ -1299,37 +1306,37 @@ describe GIMarshallingTests do
1299
1306
  it "has a working function #glist_uint32_none_return" do
1300
1307
  skip unless get_introspection_data 'GIMarshallingTests', 'glist_uint32_none_return'
1301
1308
  res = GIMarshallingTests.glist_uint32_none_return
1302
- res.to_a.must_equal [0, 0xffff_ffff]
1309
+ res.must_be :==, [0, 0xffff_ffff]
1303
1310
  end
1304
1311
 
1305
1312
  it "has a working function #glist_utf8_container_inout" do
1306
1313
  res = GIMarshallingTests.glist_utf8_container_inout ["0", "1", "2"]
1307
- assert_equal ["-2", "-1", "0", "1"], res.to_a
1314
+ res.must_be :==, ["-2", "-1", "0", "1"]
1308
1315
  end
1309
1316
 
1310
1317
  it "has a working function #glist_utf8_container_out" do
1311
1318
  res = GIMarshallingTests.glist_utf8_container_out
1312
- assert_equal ["0", "1", "2"], res.to_a
1319
+ res.must_be :==, ["0", "1", "2"]
1313
1320
  end
1314
1321
 
1315
1322
  it "has a working function #glist_utf8_container_return" do
1316
1323
  res = GIMarshallingTests.glist_utf8_container_return
1317
- assert_equal ["0", "1", "2"], res.to_a
1324
+ res.must_be :==, ["0", "1", "2"]
1318
1325
  end
1319
1326
 
1320
1327
  it "has a working function #glist_utf8_full_inout" do
1321
1328
  res = GIMarshallingTests.glist_utf8_full_inout ["0", "1", "2"]
1322
- assert_equal ["-2", "-1", "0", "1"], res.to_a
1329
+ res.must_be :==, ["-2", "-1", "0", "1"]
1323
1330
  end
1324
1331
 
1325
1332
  it "has a working function #glist_utf8_full_out" do
1326
1333
  res = GIMarshallingTests.glist_utf8_full_out
1327
- assert_equal ["0", "1", "2"], res.to_a
1334
+ res.must_be :==, ["0", "1", "2"]
1328
1335
  end
1329
1336
 
1330
1337
  it "has a working function #glist_utf8_full_return" do
1331
1338
  res = GIMarshallingTests.glist_utf8_full_return
1332
- assert_equal ["0", "1", "2"], res.to_a
1339
+ res.must_be :==, ["0", "1", "2"]
1333
1340
  end
1334
1341
 
1335
1342
  it "has a working function #glist_utf8_none_in" do
@@ -1338,47 +1345,47 @@ describe GIMarshallingTests do
1338
1345
 
1339
1346
  it "has a working function #glist_utf8_none_inout" do
1340
1347
  res = GIMarshallingTests.glist_utf8_none_inout ["0", "1", "2"]
1341
- assert_equal ["-2", "-1", "0", "1"], res.to_a
1348
+ res.must_be :==, ["-2", "-1", "0", "1"]
1342
1349
  end
1343
1350
 
1344
1351
  it "has a working function #glist_utf8_none_out" do
1345
1352
  res = GIMarshallingTests.glist_utf8_none_out
1346
- assert_equal ["0", "1", "2"], res.to_a
1353
+ res.must_be :==, ["0", "1", "2"]
1347
1354
  end
1348
1355
 
1349
1356
  it "has a working function #glist_utf8_none_return" do
1350
1357
  res = GIMarshallingTests.glist_utf8_none_return
1351
- assert_equal ["0", "1", "2"], res.to_a
1358
+ res.must_be :==, ["0", "1", "2"]
1352
1359
  end
1353
1360
 
1354
1361
  it "has a working function #gptrarray_utf8_container_inout" do
1355
1362
  res = GIMarshallingTests.gptrarray_utf8_container_inout ["0", "1", "2"]
1356
- res.to_a.must_equal ["-2", "-1", "0", "1"]
1363
+ res.must_be :==, ["-2", "-1", "0", "1"]
1357
1364
  end
1358
1365
 
1359
1366
  it "has a working function #gptrarray_utf8_container_out" do
1360
1367
  res = GIMarshallingTests.gptrarray_utf8_container_out
1361
- res.to_a.must_equal ["0", "1", "2"]
1368
+ res.must_be :==, ["0", "1", "2"]
1362
1369
  end
1363
1370
 
1364
1371
  it "has a working function #gptrarray_utf8_container_return" do
1365
1372
  res = GIMarshallingTests.gptrarray_utf8_container_return
1366
- res.to_a.must_equal ["0", "1", "2"]
1373
+ res.must_be :==, ["0", "1", "2"]
1367
1374
  end
1368
1375
 
1369
1376
  it "has a working function #gptrarray_utf8_full_inout" do
1370
1377
  res = GIMarshallingTests.gptrarray_utf8_full_inout ["0", "1", "2"]
1371
- res.to_a.must_equal ["-2", "-1", "0", "1"]
1378
+ res.must_be :==, ["-2", "-1", "0", "1"]
1372
1379
  end
1373
1380
 
1374
1381
  it "has a working function #gptrarray_utf8_full_out" do
1375
1382
  res = GIMarshallingTests.gptrarray_utf8_full_out
1376
- res.to_a.must_equal ["0", "1", "2"]
1383
+ res.must_be :==, ["0", "1", "2"]
1377
1384
  end
1378
1385
 
1379
1386
  it "has a working function #gptrarray_utf8_full_return" do
1380
1387
  res = GIMarshallingTests.gptrarray_utf8_full_return
1381
- res.to_a.must_equal ["0", "1", "2"]
1388
+ res.must_be :==, ["0", "1", "2"]
1382
1389
  end
1383
1390
 
1384
1391
  it "has a working function #gptrarray_utf8_none_in" do
@@ -1387,17 +1394,17 @@ describe GIMarshallingTests do
1387
1394
 
1388
1395
  it "has a working function #gptrarray_utf8_none_inout" do
1389
1396
  res = GIMarshallingTests.gptrarray_utf8_none_inout ["0", "1", "2"]
1390
- res.to_a.must_equal ["-2", "-1", "0", "1"]
1397
+ res.must_be :==, ["-2", "-1", "0", "1"]
1391
1398
  end
1392
1399
 
1393
1400
  it "has a working function #gptrarray_utf8_none_out" do
1394
1401
  res = GIMarshallingTests.gptrarray_utf8_none_out
1395
- res.to_a.must_equal ["0", "1", "2"]
1402
+ res.must_be :==, ["0", "1", "2"]
1396
1403
  end
1397
1404
 
1398
1405
  it "has a working function #gptrarray_utf8_none_return" do
1399
1406
  res = GIMarshallingTests.gptrarray_utf8_none_return
1400
- res.to_a.must_equal ["0", "1", "2"]
1407
+ res.must_be :==, ["0", "1", "2"]
1401
1408
  end
1402
1409
 
1403
1410
  it "has a working function #gslist_int_none_in" do
@@ -1407,37 +1414,37 @@ describe GIMarshallingTests do
1407
1414
 
1408
1415
  it "has a working function #gslist_int_none_return" do
1409
1416
  res = GIMarshallingTests.gslist_int_none_return
1410
- assert_equal [-1, 0, 1, 2], res.to_a
1417
+ res.must_be :==, [-1, 0, 1, 2]
1411
1418
  end
1412
1419
 
1413
1420
  it "has a working function #gslist_utf8_container_inout" do
1414
1421
  res = GIMarshallingTests.gslist_utf8_container_inout ["0", "1", "2"]
1415
- assert_equal ["-2", "-1", "0", "1"], res.to_a
1422
+ res.must_be :==, ["-2", "-1", "0", "1"]
1416
1423
  end
1417
1424
 
1418
1425
  it "has a working function #gslist_utf8_container_out" do
1419
1426
  res = GIMarshallingTests.gslist_utf8_container_out
1420
- assert_equal ["0", "1", "2"], res.to_a
1427
+ res.must_be :==, ["0", "1", "2"]
1421
1428
  end
1422
1429
 
1423
1430
  it "has a working function #gslist_utf8_container_return" do
1424
1431
  res = GIMarshallingTests.gslist_utf8_container_return
1425
- assert_equal ["0", "1", "2"], res.to_a
1432
+ res.must_be :==, ["0", "1", "2"]
1426
1433
  end
1427
1434
 
1428
1435
  it "has a working function #gslist_utf8_full_inout" do
1429
1436
  res = GIMarshallingTests.gslist_utf8_full_inout ["0", "1", "2"]
1430
- assert_equal ["-2", "-1", "0", "1"], res.to_a
1437
+ res.must_be :==, ["-2", "-1", "0", "1"]
1431
1438
  end
1432
1439
 
1433
1440
  it "has a working function #gslist_utf8_full_out" do
1434
1441
  res = GIMarshallingTests.gslist_utf8_full_out
1435
- assert_equal ["0", "1", "2"], res.to_a
1442
+ res.must_be :==, ["0", "1", "2"]
1436
1443
  end
1437
1444
 
1438
1445
  it "has a working function #gslist_utf8_full_return" do
1439
1446
  res = GIMarshallingTests.gslist_utf8_full_return
1440
- assert_equal ["0", "1", "2"], res.to_a
1447
+ res.must_be :==, ["0", "1", "2"]
1441
1448
  end
1442
1449
 
1443
1450
  it "has a working function #gslist_utf8_none_in" do
@@ -1447,17 +1454,17 @@ describe GIMarshallingTests do
1447
1454
 
1448
1455
  it "has a working function #gslist_utf8_none_inout" do
1449
1456
  res = GIMarshallingTests.gslist_utf8_none_inout ["0", "1", "2"]
1450
- assert_equal ["-2", "-1", "0", "1"], res.to_a
1457
+ res.must_be :==, ["-2", "-1", "0", "1"]
1451
1458
  end
1452
1459
 
1453
1460
  it "has a working function #gslist_utf8_none_out" do
1454
1461
  res = GIMarshallingTests.gslist_utf8_none_out
1455
- assert_equal ["0", "1", "2"], res.to_a
1462
+ res.must_be :==, ["0", "1", "2"]
1456
1463
  end
1457
1464
 
1458
1465
  it "has a working function #gslist_utf8_none_return" do
1459
1466
  res = GIMarshallingTests.gslist_utf8_none_return
1460
- assert_equal ["0", "1", "2"], res.to_a
1467
+ res.must_be :==, ["0", "1", "2"]
1461
1468
  end
1462
1469
 
1463
1470
  it "has a working function #gstrv_in" do
@@ -1467,17 +1474,17 @@ describe GIMarshallingTests do
1467
1474
 
1468
1475
  it "has a working function #gstrv_inout" do
1469
1476
  res = GIMarshallingTests.gstrv_inout ["0", "1", "2"]
1470
- assert_equal ["-1", "0", "1", "2"], res.to_a
1477
+ res.must_be :==, ["-1", "0", "1", "2"]
1471
1478
  end
1472
1479
 
1473
1480
  it "has a working function #gstrv_out" do
1474
1481
  res = GIMarshallingTests.gstrv_out
1475
- assert_equal ["0", "1", "2"], res.to_a
1482
+ res.must_be :==, ["0", "1", "2"]
1476
1483
  end
1477
1484
 
1478
1485
  it "has a working function #gstrv_return" do
1479
1486
  res = GIMarshallingTests.gstrv_return
1480
- assert_equal ["0", "1", "2"], res.to_a
1487
+ res.must_be :==, ["0", "1", "2"]
1481
1488
  end
1482
1489
 
1483
1490
  it "has a working function #gtype_in" do
@@ -1516,11 +1523,13 @@ describe GIMarshallingTests do
1516
1523
  end
1517
1524
 
1518
1525
  it "has a working function #gvalue_flat_array" do
1519
- skip "Non-pointer arrays of complex types are not supported yet"
1526
+ # TODO: Convert array of Ruby values to GValues automatically?
1527
+ arr = [42, "42", true].map { |val| GObject::Value.wrap_ruby_value val }
1528
+ GIMarshallingTests.gvalue_flat_array arr
1520
1529
  end
1521
1530
 
1522
1531
  it "has a working function #gvalue_flat_array_round_trip" do
1523
- skip "Non-pointer arrays of complex types are not supported yet"
1532
+ skip "Passing structs by-value is not supported yet"
1524
1533
  end
1525
1534
 
1526
1535
  it "has a working function #gvalue_in" do
@@ -1585,7 +1594,7 @@ describe GIMarshallingTests do
1585
1594
  it "has a working function #init_function" do
1586
1595
  res, arr = GIMarshallingTests.init_function ["foo", "bar", "baz"]
1587
1596
  res.must_equal true
1588
- arr.to_a.must_equal ["foo", "bar"]
1597
+ arr.must_be :==, ["foo", "bar"]
1589
1598
  end
1590
1599
 
1591
1600
  it "has a working function #int16_in_max" do
@@ -1844,7 +1853,9 @@ describe GIMarshallingTests do
1844
1853
  end
1845
1854
 
1846
1855
  it "has a working function #multi_array_key_value_in" do
1847
- skip "Non-pointer arrays of complex types are not supported yet"
1856
+ keys = ["one", "two", "three"]
1857
+ values = [1, 2, 3].map { |val| GObject::Value.wrap_ruby_value val }
1858
+ GIMarshallingTests.multi_array_key_value_in keys, values
1848
1859
  end
1849
1860
 
1850
1861
  it "has a working function #no_type_flags_in" do
@@ -1916,7 +1927,11 @@ describe GIMarshallingTests do
1916
1927
  end
1917
1928
 
1918
1929
  it "has a working function #return_gvalue_flat_array" do
1919
- skip "Non-pointer arrays of complex types are not supported yet"
1930
+ result = GIMarshallingTests.return_gvalue_flat_array
1931
+ arr = result.to_a
1932
+ arr[0].get_value.must_equal 42
1933
+ arr[1].get_value.must_equal "42"
1934
+ arr[2].get_value.must_equal true
1920
1935
  end
1921
1936
 
1922
1937
  it "has a working function #short_in_max" do