gir_ffi 0.4.3 → 0.5.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (83) hide show
  1. data/History.txt +8 -0
  2. data/README.md +1 -1
  3. data/TODO.rdoc +12 -4
  4. data/lib/ffi-glib.rb +0 -5
  5. data/lib/ffi-glib/list.rb +1 -1
  6. data/lib/ffi-glib/s_list.rb +1 -1
  7. data/lib/ffi-gobject.rb +2 -3
  8. data/lib/ffi-gobject/closure.rb +4 -3
  9. data/lib/ffi-gobject_introspection/i_base_info.rb +11 -14
  10. data/lib/ffi-gobject_introspection/i_constant_info.rb +1 -1
  11. data/lib/ffi-gobject_introspection/i_function_info.rb +0 -6
  12. data/lib/ffi-gobject_introspection/lib.rb +8 -2
  13. data/lib/gir_ffi.rb +5 -0
  14. data/lib/gir_ffi/arg_helper.rb +1 -1
  15. data/lib/gir_ffi/argument_builder.rb +161 -0
  16. data/lib/gir_ffi/base_argument_builder.rb +146 -0
  17. data/lib/gir_ffi/builder/field.rb +7 -5
  18. data/lib/gir_ffi/builder/module.rb +3 -14
  19. data/lib/gir_ffi/builder/property.rb +0 -2
  20. data/lib/gir_ffi/builder/type/callback.rb +0 -8
  21. data/lib/gir_ffi/builder/type/constant.rb +0 -4
  22. data/lib/gir_ffi/builder/type/enum.rb +0 -4
  23. data/lib/gir_ffi/builder/type/interface.rb +0 -4
  24. data/lib/gir_ffi/builder/type/object.rb +0 -1
  25. data/lib/gir_ffi/builder/type/struct_based.rb +0 -6
  26. data/lib/gir_ffi/builder/type/union.rb +0 -4
  27. data/lib/gir_ffi/builder/type/with_layout.rb +0 -1
  28. data/lib/gir_ffi/builder/type/with_methods.rb +1 -7
  29. data/lib/gir_ffi/callback.rb +9 -0
  30. data/lib/gir_ffi/callback_helper.rb +8 -1
  31. data/lib/gir_ffi/class_base.rb +6 -26
  32. data/lib/gir_ffi/error_argument_builder.rb +17 -0
  33. data/lib/gir_ffi/{builder/function.rb → function_builder.rb} +14 -11
  34. data/lib/gir_ffi/in_out_pointer.rb +29 -36
  35. data/lib/gir_ffi/in_pointer.rb +1 -1
  36. data/lib/gir_ffi/info_ext.rb +6 -0
  37. data/lib/gir_ffi/info_ext/i_field_info.rb +0 -2
  38. data/lib/gir_ffi/info_ext/i_type_info.rb +29 -10
  39. data/lib/gir_ffi/info_ext/safe_constant_name.rb +21 -0
  40. data/lib/gir_ffi/info_ext/safe_function_name.rb +13 -0
  41. data/lib/gir_ffi/interface_base.rb +1 -11
  42. data/lib/gir_ffi/module_base.rb +0 -10
  43. data/lib/gir_ffi/null_argument_builder.rb +9 -0
  44. data/lib/gir_ffi/return_value_builder.rb +75 -0
  45. data/lib/gir_ffi/setter_argument_info.rb +16 -0
  46. data/lib/gir_ffi/type_map.rb +10 -1
  47. data/lib/gir_ffi/version.rb +1 -1
  48. data/tasks/test.rake +61 -0
  49. data/test/base_test_helper.rb +0 -2
  50. data/test/ffi-gobject/value_test.rb +15 -0
  51. data/test/ffi-gobject_introspection/i_base_info_test.rb +31 -6
  52. data/test/ffi-gobject_introspection/i_function_info_test.rb +0 -17
  53. data/test/ffi-gobject_introspection/lib_test.rb +0 -55
  54. data/test/ffi-gobject_test.rb +2 -1
  55. data/test/gir_ffi/argument_builder_test.rb +414 -0
  56. data/test/gir_ffi/base_argument_builder_test.rb +13 -0
  57. data/test/gir_ffi/builder/module_test.rb +4 -40
  58. data/test/gir_ffi/builder/type/callback_test.rb +0 -27
  59. data/test/gir_ffi/builder/type/constant_test.rb +0 -12
  60. data/test/gir_ffi/builder/type/enum_test.rb +0 -20
  61. data/test/gir_ffi/builder/type/interface_test.rb +0 -11
  62. data/test/gir_ffi/builder/type/object_test.rb +2 -2
  63. data/test/gir_ffi/builder/type/struct_test.rb +0 -39
  64. data/test/gir_ffi/builder/type/unintrospectable_test.rb +1 -1
  65. data/test/gir_ffi/builder/type/union_test.rb +0 -11
  66. data/test/gir_ffi/builder_test.rb +3 -11
  67. data/test/gir_ffi/callback_helper_test.rb +7 -0
  68. data/test/gir_ffi/{builder/function_test.rb → function_builder_test.rb} +16 -28
  69. data/test/gir_ffi/in_out_pointer_test.rb +0 -20
  70. data/test/gir_ffi/info_ext/i_type_info_test.rb +112 -26
  71. data/test/gir_ffi/info_ext/safe_constant_name_test.rb +16 -0
  72. data/test/gir_ffi/info_ext/safe_function_name_test.rb +22 -0
  73. data/test/gir_ffi/return_value_builder_test.rb +355 -0
  74. data/test/integration/generated_gimarshallingtests_test.rb +608 -296
  75. data/test/integration/generated_regress_test.rb +879 -494
  76. metadata +35 -24
  77. data/lib/gir_ffi/builder/argument.rb +0 -569
  78. data/lib/gir_ffi/builder/argument/base.rb +0 -151
  79. data/lib/gir_ffi/builder/argument/in_base.rb +0 -14
  80. data/lib/gir_ffi/builder/argument/in_out_base.rb +0 -18
  81. data/lib/gir_ffi/builder/argument/out_base.rb +0 -15
  82. data/test/gir_ffi/builder/argument/base_test.rb +0 -55
  83. data/test/integration/pretty_print_test.rb +0 -33
@@ -9,15 +9,91 @@ def get_field_value obj, field
9
9
  end
10
10
 
11
11
  # Tests generated methods and functions in the Regress namespace.
12
- describe Regress, "The generated Regress module" do
12
+ describe Regress do
13
+ describe "Regress::ATestError" do
14
+ before do
15
+ skip unless get_introspection_data 'Regress', 'ATestError'
16
+ end
17
+
18
+ it "has the member :code0" do
19
+ Regress::ATestError[:code0].must_equal 0
20
+ end
21
+
22
+ it "has the member :code1" do
23
+ Regress::ATestError[:code1].must_equal 1
24
+ end
25
+
26
+ it "has the member :code2" do
27
+ Regress::ATestError[:code2].must_equal 2
28
+ end
29
+ end
30
+
13
31
  it "has the constant DOUBLE_CONSTANT" do
14
32
  assert_equal 44.22, Regress::DOUBLE_CONSTANT
15
33
  end
16
34
 
35
+ it "has the constant GUINT64_CONSTANT" do
36
+ skip unless get_introspection_data 'Regress', 'GUINT64_CONSTANT'
37
+ Regress::GUINT64_CONSTANT.must_equal 18446744073709551615
38
+ end
39
+
40
+ it "has the constant GUINT64_CONSTANTA" do
41
+ skip unless get_introspection_data 'Regress', 'GUINT64_CONSTANTA'
42
+ Regress::GUINT64_CONSTANTA.must_equal 18446744073709551615
43
+ end
44
+
45
+ it "has the constant G_GINT64_CONSTANT" do
46
+ skip unless get_introspection_data 'Regress', 'G_GINT64_CONSTANT'
47
+ Regress::G_GINT64_CONSTANT.must_equal 1000
48
+ end
49
+
17
50
  it "has the constant INT_CONSTANT" do
18
51
  assert_equal 4422, Regress::INT_CONSTANT
19
52
  end
20
53
 
54
+ it "has the constant LONG_STRING_CONSTANT" do
55
+ Regress::LONG_STRING_CONSTANT.must_equal %w(TYPE VALUE ENCODING CHARSET
56
+ LANGUAGE DOM INTL POSTAL PARCEL
57
+ HOME WORK PREF VOICE FAX MSG
58
+ CELL PAGER BBS MODEM CAR ISDN
59
+ VIDEO AOL APPLELINK ATTMAIL CIS
60
+ EWORLD INTERNET IBMMAIL MCIMAIL
61
+ POWERSHARE PRODIGY TLX X400 GIF
62
+ CGM WMF BMP MET PMB DIB PICT
63
+ TIFF PDF PS JPEG QTIME MPEG
64
+ MPEG2 AVI WAVE AIFF PCM X509
65
+ PGP).join(",")
66
+ end
67
+
68
+ describe "Regress::LikeGnomeKeyringPasswordSchema" do
69
+ before do
70
+ skip unless get_introspection_data 'Regress', 'LikeGnomeKeyringPasswordSchema'
71
+ end
72
+ it "creates an instance using #new" do
73
+ obj = Regress::LikeGnomeKeyringPasswordSchema.new
74
+ obj.must_be_instance_of Regress::LikeGnomeKeyringPasswordSchema
75
+ end
76
+
77
+ let(:instance) { Regress::LikeGnomeKeyringPasswordSchema.new }
78
+
79
+ it "has a writable field dummy" do
80
+ instance.dummy.must_equal 0
81
+ instance.dummy = 42
82
+ instance.dummy.must_equal 42
83
+ end
84
+
85
+ it "has a writable field attributes" do
86
+ skip "This does not work yet"
87
+ instance.attributes
88
+ end
89
+
90
+ it "has a writable field dummy2" do
91
+ instance.dummy2.must_equal 0.0
92
+ instance.dummy2 = 42.42
93
+ instance.dummy2.must_equal 42.42
94
+ end
95
+ end
96
+
21
97
  it "has the constant Mixed_Case_Constant" do
22
98
  assert_equal 4423, Regress::Mixed_Case_Constant
23
99
  end
@@ -26,7 +102,29 @@ describe Regress, "The generated Regress module" do
26
102
  assert_equal "Some String", Regress::STRING_CONSTANT
27
103
  end
28
104
 
29
- describe Regress::TestBoxed do
105
+ describe "Regress::TestABCError" do
106
+ before do
107
+ skip unless get_introspection_data 'Regress', 'TestABCError'
108
+ end
109
+
110
+ it "has the member :code1" do
111
+ Regress::TestABCError[:code1].must_equal 1
112
+ end
113
+
114
+ it "has the member :code2" do
115
+ Regress::TestABCError[:code2].must_equal 2
116
+ end
117
+
118
+ it "has the member :code3" do
119
+ Regress::TestABCError[:code3].must_equal 3
120
+ end
121
+
122
+ it "has a working function #quark" do
123
+ skip
124
+ end
125
+ end
126
+
127
+ describe "Regress::TestBoxed" do
30
128
  it "creates an instance using #new" do
31
129
  tb = Regress::TestBoxed.new
32
130
  assert_instance_of Regress::TestBoxed, tb
@@ -54,50 +152,154 @@ describe Regress, "The generated Regress module" do
54
152
  assert Regress::TestBoxed.get_gtype > 0
55
153
  end
56
154
 
57
- describe "an instance" do
58
- setup do
59
- @tb = Regress::TestBoxed.new_alternative_constructor1 123
60
- end
155
+ let(:instance) { Regress::TestBoxed.new_alternative_constructor1 123 }
61
156
 
62
- it "has a working equals method" do
63
- tb2 = Regress::TestBoxed.new_alternative_constructor2 120, 3
64
- assert_equal true, @tb.equals(tb2)
65
- end
157
+ it "has a working method #copy" do
158
+ tb2 = instance.copy
159
+ assert_instance_of Regress::TestBoxed, tb2
160
+ assert_equal 123, tb2.some_int8
161
+ instance.some_int8 = 89
162
+ assert_equal 123, tb2.some_int8
163
+ end
66
164
 
67
- describe "its copy method" do
68
- setup do
69
- @tb2 = @tb.copy
70
- end
165
+ it "has a working method #equals" do
166
+ tb2 = Regress::TestBoxed.new_alternative_constructor2 120, 3
167
+ assert_equal true, instance.equals(tb2)
168
+ end
169
+ end
71
170
 
72
- it "returns an instance of TestBoxed" do
73
- assert_instance_of Regress::TestBoxed, @tb2
74
- end
171
+ describe "Regress::TestBoxedB" do
172
+ it "creates an instance using #new" do
173
+ tb = Regress::TestBoxedB.new 8, 42
174
+ assert_instance_of Regress::TestBoxedB, tb
175
+ end
75
176
 
76
- it "copies fields" do
77
- assert_equal 123, @tb2.some_int8
78
- end
177
+ let(:instance) { Regress::TestBoxedB.new 8, 42 }
79
178
 
80
- it "creates a true copy" do
81
- @tb.some_int8 = 89
82
- assert_equal 123, @tb2.some_int8
83
- end
84
- end
179
+ it "has a working method #copy" do
180
+ cp = instance.copy
181
+ cp.must_be_instance_of Regress::TestBoxedB
182
+ cp.some_int8.must_equal 8
183
+ cp.some_long.must_equal 42
184
+ instance.some_int8 = 2
185
+ cp.some_int8.must_equal 8
85
186
  end
86
187
  end
87
188
 
88
- describe "the Regress::TestEnum type" do
89
- it "is of type FFI::Enum" do
90
- assert_instance_of FFI::Enum, Regress::TestEnum
189
+ describe "Regress::TestBoxedC" do
190
+ before do
191
+ skip unless get_introspection_data 'Regress', 'TestBoxedC'
192
+ end
193
+ it "creates an instance using #new" do
194
+ tb = Regress::TestBoxedC.new
195
+ assert_instance_of Regress::TestBoxedC, tb
91
196
  end
92
197
  end
93
198
 
94
- it "has the bitfield TestFlags" do
95
- assert_equal 1, Regress::TestFlags[:flag1]
96
- assert_equal 2, Regress::TestFlags[:flag2]
97
- assert_equal 4, Regress::TestFlags[:flag3]
199
+ describe "Regress::TestDEFError" do
200
+ before do
201
+ skip unless get_introspection_data 'Regress', 'TestDEFError'
202
+ end
203
+ it "has the member :code0" do
204
+ Regress::TestDEFError[:code0].must_equal 0
205
+ end
206
+
207
+ it "has the member :code1" do
208
+ Regress::TestDEFError[:code1].must_equal 1
209
+ end
210
+
211
+ it "has the member :code2" do
212
+ Regress::TestDEFError[:code2].must_equal 2
213
+ end
214
+ end
215
+
216
+ describe "Regress::TestEnum" do
217
+ it "has the member :value1" do
218
+ Regress::TestEnum[:value1].must_equal 0
219
+ end
220
+
221
+ it "has the member :value2" do
222
+ Regress::TestEnum[:value2].must_equal 1
223
+ end
224
+
225
+ it "has the member :value3" do
226
+ Regress::TestEnum[:value3].must_equal(-1)
227
+ end
228
+
229
+ it "has the member :value4" do
230
+ Regress::TestEnum[:value4].must_equal 48
231
+ end
232
+
233
+ it "has a working function #param" do
234
+ skip
235
+ end
236
+ end
237
+
238
+ describe "Regress::TestEnumNoGEnum" do
239
+ it "has the member :evalue1" do
240
+ Regress::TestEnumNoGEnum[:evalue1].must_equal 0
241
+ end
242
+
243
+ it "has the member :evalue2" do
244
+ Regress::TestEnumNoGEnum[:evalue2].must_equal 42
245
+ end
246
+
247
+ it "has the member :evalue3" do
248
+ Regress::TestEnumNoGEnum[:evalue3].must_equal 48
249
+ end
250
+ end
251
+
252
+ describe "Regress::TestEnumUnsigned" do
253
+ it "has the member :value1" do
254
+ Regress::TestEnumUnsigned[:value1].must_equal 1
255
+ end
256
+
257
+ # NOTE In c, the positive and negative values are not distinguished
258
+ it "has the member :value2" do
259
+ Regress::TestEnumUnsigned[:value2].must_equal(-2147483648)
260
+ end
98
261
  end
99
262
 
100
- describe Regress::TestFloating do
263
+ describe "Regress::TestError" do
264
+ before do
265
+ skip unless get_introspection_data 'Regress', 'TestError'
266
+ end
267
+
268
+ it "has the member :code1" do
269
+ Regress::TestError[:code1].must_equal 1
270
+ end
271
+
272
+ it "has the member :code2" do
273
+ Regress::TestError[:code2].must_equal 2
274
+ end
275
+
276
+ it "has the member :code3" do
277
+ Regress::TestError[:code3].must_equal 3
278
+ end
279
+
280
+ it "has a working function #quark" do
281
+ skip
282
+ end
283
+ end
284
+
285
+ describe "Regress::TestFlags" do
286
+ it "has the member :flag1" do
287
+ assert_equal 1, Regress::TestFlags[:flag1]
288
+ end
289
+ it "has the member :flag2" do
290
+ assert_equal 2, Regress::TestFlags[:flag2]
291
+ end
292
+ it "has the member :flag3" do
293
+ assert_equal 4, Regress::TestFlags[:flag3]
294
+ end
295
+ end
296
+
297
+ describe "Regress::TestFloating" do
298
+ it "creates an instance using #new" do
299
+ o = Regress::TestFloating.new
300
+ o.must_be_instance_of Regress::TestFloating
301
+ end
302
+
101
303
  describe "an instance" do
102
304
  setup do
103
305
  @o = Regress::TestFloating.new
@@ -113,47 +315,55 @@ describe Regress, "The generated Regress module" do
113
315
  end
114
316
  end
115
317
 
116
- describe "TestFundamentalObject" do
117
- it "must exist" do
118
- Regress::TestFundamentalObject
119
- end
120
-
318
+ describe "Regress::TestFundamentalObject" do
121
319
  it "does not have GObject::Object as an ancestor" do
122
320
  refute_includes Regress::TestFundamentalObject.ancestors,
123
321
  GObject::Object
124
322
  end
323
+
125
324
  # TODO: Test more, if possible (e.g., cannot be instantiated).
325
+
326
+ it "has a working method #ref" do
327
+ skip
328
+ end
329
+ it "has a working method #unref" do
330
+ skip
331
+ end
126
332
  end
127
333
 
128
- describe "TestFundamentalSubObject" do
129
- before do
130
- @so = Regress::TestFundamentalSubObject.new "foo"
334
+ describe "Regress::TestFundamentalSubObject" do
335
+ it "creates an instance using #new" do
336
+ obj = Regress::TestFundamentalSubObject.new "foo"
337
+ obj.must_be_instance_of Regress::TestFundamentalSubObject
131
338
  end
132
339
 
340
+ let(:instance) { Regress::TestFundamentalSubObject.new "foo" }
341
+
133
342
  it "can be instantiated" do
343
+ instance
134
344
  pass
135
345
  end
136
346
 
137
347
  it "is a subclass of TestFundamentalObject" do
138
- assert_kind_of Regress::TestFundamentalObject, @so
348
+ assert_kind_of Regress::TestFundamentalObject, instance
139
349
  end
140
350
 
141
351
  it "has a field :data storing the constructor parameter" do
142
- assert_equal "foo", @so.data
352
+ assert_equal "foo", instance.data
143
353
  end
144
354
 
145
355
  it "can access its parent class' fields directly" do
146
356
  assert_nothing_raised do
147
- @so.flags
357
+ instance.flags
148
358
  end
149
359
  end
150
360
 
151
361
  it "has a refcount of 1" do
152
- assert_equal 1, @so.refcount
362
+ assert_equal 1, instance.refcount
153
363
  end
154
364
  end
155
365
 
156
- describe "TestInterface" do
366
+ describe "Regress::TestInterface" do
157
367
  it "is a module" do
158
368
  assert_instance_of Module, Regress::TestInterface
159
369
  end
@@ -168,10 +378,16 @@ describe Regress, "The generated Regress module" do
168
378
  end
169
379
  end
170
380
 
171
- describe Regress::TestObj do
172
- it "creates an instance using #new_from_file" do
173
- o = Regress::TestObj.new_from_file("foo")
174
- assert_instance_of Regress::TestObj, o
381
+ describe "Regress::TestObj" do
382
+ it "creates an instance using #constructor" do
383
+ obj = Regress::TestObj.constructor
384
+ obj.must_be_instance_of Regress::TestObj
385
+ end
386
+
387
+ it "creates an instance using #new" do
388
+ o1 = Regress::TestObj.constructor
389
+ o2 = Regress::TestObj.new o1
390
+ o2.must_be_instance_of Regress::TestObj
175
391
  end
176
392
 
177
393
  it "creates an instance using #new_callback" do
@@ -181,220 +397,265 @@ describe Regress, "The generated Regress module" do
181
397
  a.must_equal 2
182
398
  end
183
399
 
184
- it "has a working #static_method" do
400
+ it "creates an instance using #new_from_file" do
401
+ o = Regress::TestObj.new_from_file("foo")
402
+ assert_instance_of Regress::TestObj, o
403
+ end
404
+
405
+ it "has a working function #null_out" do
406
+ obj = Regress::TestObj.null_out
407
+ obj.must_be_nil
408
+ end
409
+
410
+ it "has a working function #static_method" do
185
411
  rv = Regress::TestObj.static_method 623
186
412
  assert_equal 623.0, rv
187
413
  end
188
414
 
189
- describe "#static_method_callback" do
190
- it "works when called with a Proc" do
191
- a = 1
192
- Regress::TestObj.static_method_callback Proc.new { a = 2 }
193
- assert_equal 2, a
194
- end
195
-
196
- it "works when called with nil" do
197
- assert_nothing_raised do
198
- Regress::TestObj.static_method_callback nil
199
- end
200
- end
415
+ it "has a working function #static_method_callback" do
416
+ a = 1
417
+ Regress::TestObj.static_method_callback Proc.new { a = 2 }
418
+ assert_equal 2, a
201
419
  end
202
420
 
203
- describe "an instance" do
204
- setup do
205
- @o = Regress::TestObj.new_from_file("foo")
206
- end
421
+ let(:instance) { Regress::TestObj.new_from_file("foo") }
207
422
 
208
- describe "its gtype" do
209
- it "can be found through get_gtype and GObject.type_from_instance" do
210
- gtype = Regress::TestObj.get_gtype
211
- r = GObject.type_from_instance @o
212
- assert_equal gtype, r
213
- end
423
+ describe "its gtype" do
424
+ it "can be found through get_gtype and GObject.type_from_instance" do
425
+ gtype = Regress::TestObj.get_gtype
426
+ r = GObject.type_from_instance instance
427
+ assert_equal gtype, r
214
428
  end
429
+ end
215
430
 
216
- describe "#get_property" do
217
- it "gets the 'bare' property" do
218
- obj = Regress::TestObj.new_from_file("bar")
219
- @o.set_bare obj
220
-
221
- obj2 = @o.get_property("bare")
222
-
223
- assert_equal obj.to_ptr, obj2.to_ptr
224
- assert_instance_of Regress::TestObj, obj2
225
- end
226
-
227
- it "gets the 'boxed' property" do
228
- tb = Regress::TestBoxed.new_alternative_constructor1 75
229
- @o.set_property "boxed", tb
230
-
231
- tb2 = @o.get_property("boxed")
232
-
233
- assert_instance_of Regress::TestBoxed, tb2
234
- assert_equal 75, tb2.some_int8
235
- end
431
+ describe "#get_property" do
432
+ it "gets the 'bare' property" do
433
+ obj = Regress::TestObj.new_from_file("bar")
434
+ instance.set_bare obj
236
435
 
237
- it "gets the 'hash-table' property" do
238
- ht = GLib::HashTable.new :utf8, :gint8
239
- ht.insert "foo", 34
240
- ht.insert "bar", 83
436
+ obj2 = instance.get_property("bare")
241
437
 
242
- @o.set_property "hash-table", ht
438
+ assert_equal obj.to_ptr, obj2.to_ptr
439
+ assert_instance_of Regress::TestObj, obj2
440
+ end
243
441
 
244
- ht2 = @o.get_property "hash-table"
245
- assert_equal({"foo" => 34, "bar" => 83}, ht2.to_hash)
246
- end
442
+ it "gets the 'boxed' property" do
443
+ tb = Regress::TestBoxed.new_alternative_constructor1 75
444
+ instance.set_property "boxed", tb
247
445
 
248
- it "gets the 'float' property" do
249
- @o.set_property "float", 3.14
250
- assert_in_epsilon 3.14, @o.get_property("float")
251
- end
446
+ tb2 = instance.get_property("boxed")
252
447
 
253
- it "gets the 'double' property" do
254
- @o.set_property "double", 3.14
255
- assert_in_epsilon 3.14, @o.get_property("double")
256
- end
448
+ assert_instance_of Regress::TestBoxed, tb2
449
+ assert_equal 75, tb2.some_int8
450
+ end
257
451
 
258
- it "gets the 'int' property" do
259
- @o.set_property "int", 42
260
- assert_equal 42, @o.get_property("int")
261
- end
452
+ it "gets the 'hash-table' property" do
453
+ ht = GLib::HashTable.new :utf8, :gint8
454
+ ht.insert "foo", 34
455
+ ht.insert "bar", 83
262
456
 
263
- it "gets the 'list' property" do
264
- lst = GLib::List.new(:utf8).append("foo").append("bar")
457
+ instance.set_property "hash-table", ht
265
458
 
266
- @o.set_property "list", lst
459
+ ht2 = instance.get_property "hash-table"
460
+ assert_equal({"foo" => 34, "bar" => 83}, ht2.to_hash)
461
+ end
267
462
 
268
- lst2 = @o.get_property "list"
269
- assert_equal ["foo", "bar"], lst2.to_a
270
- end
463
+ it "gets the 'float' property" do
464
+ instance.set_property "float", 3.14
465
+ assert_in_epsilon 3.14, instance.get_property("float")
466
+ end
271
467
 
272
- it "gets the 'string' property" do
273
- @o.set_property "string", "foobar"
274
- assert_equal "foobar", @o.get_property("string")
275
- end
468
+ it "gets the 'double' property" do
469
+ instance.set_property "double", 3.14
470
+ assert_in_epsilon 3.14, instance.get_property("double")
276
471
  end
277
472
 
278
- describe "#set_property" do
279
- it "sets the 'bare' property" do
280
- obj = Regress::TestObj.new_from_file("bar")
281
- @o.set_property "bare", obj
282
- assert_equal obj.to_ptr, @o.bare.to_ptr
283
- end
473
+ it "gets the 'int' property" do
474
+ instance.set_property "int", 42
475
+ assert_equal 42, instance.get_property("int")
476
+ end
284
477
 
285
- it "sets the 'boxed' property" do
286
- tb = Regress::TestBoxed.new_alternative_constructor1 75
287
- @o.set_property "boxed", tb
288
- tb2 = @o.boxed
289
- assert_equal 75, tb2.some_int8
290
- end
478
+ it "gets the 'list' property" do
479
+ lst = GLib::List.new(:utf8).append("foo").append("bar")
291
480
 
292
- it "sets the 'hash-table' property" do
293
- @o.set_property("hash-table", {"foo" => 34, "bar" => 83})
481
+ instance.set_property "list", lst
294
482
 
295
- ht = @o.hash_table
296
- ht.key_type = :utf8
297
- ht.value_type = :gint32
483
+ lst2 = instance.get_property "list"
484
+ assert_equal ["foo", "bar"], lst2.to_a
485
+ end
298
486
 
299
- assert_equal({"foo" => 34, "bar" => 83}, ht.to_hash)
300
- end
487
+ it "gets the 'string' property" do
488
+ instance.set_property "string", "foobar"
489
+ assert_equal "foobar", instance.get_property("string")
490
+ end
491
+ end
301
492
 
302
- it "sets the 'float' property" do
303
- @o.set_property "float", 3.14
304
- assert_in_epsilon 3.14, get_field_value(@o, :some_float)
305
- end
493
+ describe "#set_property" do
494
+ it "sets the 'bare' property" do
495
+ obj = Regress::TestObj.new_from_file("bar")
496
+ instance.set_property "bare", obj
497
+ assert_equal obj.to_ptr, instance.bare.to_ptr
498
+ end
306
499
 
307
- it "sets the 'double' property" do
308
- @o.set_property "double", 3.14
309
- assert_in_epsilon 3.14, get_field_value(@o, :some_double)
310
- end
500
+ it "sets the 'boxed' property" do
501
+ tb = Regress::TestBoxed.new_alternative_constructor1 75
502
+ instance.set_property "boxed", tb
503
+ tb2 = instance.boxed
504
+ assert_equal 75, tb2.some_int8
505
+ end
311
506
 
312
- it "sets the 'int' property" do
313
- @o.set_property "int", 42
314
- assert_equal 42, get_field_value(@o, :some_int8)
315
- end
507
+ it "sets the 'hash-table' property" do
508
+ instance.set_property("hash-table", {"foo" => 34, "bar" => 83})
316
509
 
317
- it "sets the 'list' property" do
318
- @o.set_property "list", ["foo", "bar"]
319
- assert_equal ["foo", "bar"],
320
- GLib::List.wrap(:utf8, @o.list.to_ptr).to_a
321
- end
510
+ ht = instance.hash_table
511
+ ht.key_type = :utf8
512
+ ht.value_type = :gint32
322
513
 
323
- it "sets the 'string' property" do
324
- @o.set_property "string", "foobar"
325
- assert_equal "foobar", @o.string
326
- end
514
+ assert_equal({"foo" => 34, "bar" => 83}, ht.to_hash)
327
515
  end
328
516
 
329
- describe "its 'int' property" do
330
- it "is set with #int=" do
331
- @o.int = 41
332
- assert_equal 41, @o.get_property("int")
333
- end
334
-
335
- it "is retrieved with #int" do
336
- @o.set_property "int", 43
337
- assert_equal 43, @o.int
338
- end
517
+ it "sets the 'float' property" do
518
+ instance.set_property "float", 3.14
519
+ assert_in_epsilon 3.14, get_field_value(instance, :some_float)
339
520
  end
340
521
 
341
- it "has a reference count of 1" do
342
- assert_equal 1, ref_count(@o)
522
+ it "sets the 'double' property" do
523
+ instance.set_property "double", 3.14
524
+ assert_in_epsilon 3.14, get_field_value(instance, :some_double)
343
525
  end
344
526
 
345
- it "does not float" do
346
- assert !is_floating?(@o)
527
+ it "sets the 'int' property" do
528
+ instance.set_property "int", 42
529
+ assert_equal 42, get_field_value(instance, :some_int8)
347
530
  end
348
531
 
349
- it "has a working (virtual) #matrix method" do
350
- rv = @o.matrix "bar"
351
- assert_equal 42, rv
532
+ it "sets the 'list' property" do
533
+ instance.set_property "list", ["foo", "bar"]
534
+ assert_equal ["foo", "bar"],
535
+ GLib::List.wrap(:utf8, instance.list.to_ptr).to_a
352
536
  end
353
537
 
354
- it "has a working #set_bare method" do
355
- obj = Regress::TestObj.new_from_file("bar")
356
- @o.set_bare obj
357
- # TODO: What is the correct value to retrieve from the fields?
358
- assert_equal obj.to_ptr, @o.bare.to_ptr
538
+ it "sets the 'string' property" do
539
+ instance.set_property "string", "foobar"
540
+ assert_equal "foobar", instance.string
359
541
  end
542
+ end
360
543
 
361
- it "has a working #instance_method method" do
362
- rv = @o.instance_method
363
- assert_equal(-1, rv)
544
+ describe "its 'int' property" do
545
+ it "is set with #int=" do
546
+ instance.int = 41
547
+ assert_equal 41, instance.get_property("int")
364
548
  end
365
549
 
366
- it "has a working #torture_signature_0 method" do
367
- y, z, q = @o.torture_signature_0(-21, "hello", 13)
368
- assert_equal [-21, 2 * -21, "hello".length + 13],
369
- [y, z, q]
550
+ it "is retrieved with #int" do
551
+ instance.set_property "int", 43
552
+ assert_equal 43, instance.int
370
553
  end
554
+ end
371
555
 
372
- describe "its #torture_signature_1 method" do
373
- it "works for m even" do
374
- ret, y, z, q = @o.torture_signature_1(-21, "hello", 12)
375
- assert_equal [true, -21, 2 * -21, "hello".length + 12],
376
- [ret, y, z, q]
377
- end
556
+ it "has a reference count of 1" do
557
+ assert_equal 1, ref_count(instance)
558
+ end
378
559
 
379
- it "throws an exception for m odd" do
380
- assert_raises RuntimeError do
381
- @o.torture_signature_1(-21, "hello", 11)
382
- end
383
- end
560
+ it "does not float" do
561
+ assert !is_floating?(instance)
562
+ end
563
+
564
+ # FIXME: Should it be possible to invoke this method by its virtual name?
565
+ it "has a working method #matrix" do
566
+ rv = instance.matrix "bar"
567
+ assert_equal 42, rv
568
+ end
569
+
570
+ it "has a working method #do_matrix" do
571
+ result = instance.do_matrix "bar"
572
+ result.must_equal 42
573
+ end
574
+
575
+ it "has a working method #emit_sig_with_foreign_struct" do
576
+ skip
577
+ end
578
+
579
+ it "has a working method #emit_sig_with_int64" do
580
+ skip "This does not work yet"
581
+ instance.signal_connect "sig-with-int64-prop" do |obj, int, ud|
582
+ int
384
583
  end
584
+ instance.emit_sig_with_int64
585
+ end
586
+
587
+ it "has a working method #emit_sig_with_obj" do
588
+ skip
589
+ end
590
+ it "has a working method #emit_sig_with_uint64" do
591
+ skip
592
+ end
593
+ it "has a working method #forced_method" do
594
+ skip
595
+ end
596
+ it "has a working method #instance_method" do
597
+ rv = instance.instance_method
598
+ assert_equal(-1, rv)
599
+ end
385
600
 
386
- it "has a working #instance_method_callback method" do
387
- a = 1
388
- @o.instance_method_callback Proc.new { a = 2 }
389
- assert_equal 2, a
601
+ it "has a working method #instance_method_callback" do
602
+ a = 1
603
+ instance.instance_method_callback Proc.new { a = 2 }
604
+ assert_equal 2, a
605
+ end
606
+
607
+ it "has a working method #set_bare" do
608
+ obj = Regress::TestObj.new_from_file("bar")
609
+ instance.set_bare obj
610
+ # TODO: What is the correct value to retrieve from the fields?
611
+ assert_equal obj.to_ptr, instance.bare.to_ptr
612
+ end
613
+
614
+ it "has a working method #skip_inout_param" do
615
+ skip
616
+ end
617
+ it "has a working method #skip_out_param" do
618
+ skip
619
+ end
620
+ it "has a working method #skip_param" do
621
+ skip
622
+ end
623
+ it "has a working method #skip_return_val" do
624
+ skip
625
+ end
626
+ it "has a working method #skip_return_val_no_out" do
627
+ skip
628
+ end
629
+ it "has a working method #torture_signature_0" do
630
+ y, z, q = instance.torture_signature_0(-21, "hello", 13)
631
+ assert_equal [-21, 2 * -21, "hello".length + 13],
632
+ [y, z, q]
633
+ end
634
+
635
+ it "has a working method #torture_signature_1" do
636
+ # TODO: Merge with below
637
+ skip
638
+ end
639
+
640
+ describe "its #torture_signature_1" do
641
+ it "works for m even" do
642
+ ret, y, z, q = instance.torture_signature_1(-21, "hello", 12)
643
+ assert_equal [true, -21, 2 * -21, "hello".length + 12],
644
+ [ret, y, z, q]
390
645
  end
391
646
 
392
- it "does not respond to #static_method" do
393
- assert_raises(NoMethodError) { @o.static_method 1 }
647
+ it "throws an exception for m odd" do
648
+ assert_raises RuntimeError do
649
+ instance.torture_signature_1(-21, "hello", 11)
650
+ end
394
651
  end
395
- # TODO: Test instance's fields and properies.
396
652
  end
397
653
 
654
+ it "does not respond to #static_method" do
655
+ assert_raises(NoMethodError) { instance.static_method 1 }
656
+ end
657
+ # TODO: Test instance's fields and properies.
658
+
398
659
  describe "its 'test' signal" do
399
660
  it "properly passes its arguments" do
400
661
  a = b = nil
@@ -409,12 +670,46 @@ describe Regress, "The generated Regress module" do
409
670
  # TODO: Test other signals.
410
671
  end
411
672
 
412
- describe Regress::TestSimpleBoxedA do
673
+ describe "Regress::TestOtherError" do
674
+ it "has the member :code1" do
675
+ skip
676
+ end
677
+ it "has the member :code2" do
678
+ skip
679
+ end
680
+ it "has the member :code3" do
681
+ skip
682
+ end
683
+ it "has a working function #quark" do
684
+ skip
685
+ end
686
+ end
687
+ describe "Regress::TestPrivateEnum" do
688
+ it "has the member :public_enum_before" do
689
+ skip
690
+ end
691
+ it "has the member :public_enum_after" do
692
+ skip
693
+ end
694
+ end
695
+ describe "Regress::TestPrivateStruct" do
696
+ end
697
+ describe "Regress::TestSimpleBoxedA" do
413
698
  it "creates an instance using #new" do
414
699
  obj = Regress::TestSimpleBoxedA.new
415
700
  assert_instance_of Regress::TestSimpleBoxedA, obj
416
701
  end
417
702
 
703
+ it "has a working method #copy" do
704
+ skip
705
+ end
706
+ it "has a working method #equals" do
707
+ skip
708
+ end
709
+ it "has a working function #const_return" do
710
+ skip
711
+ end
712
+
418
713
  describe "an instance" do
419
714
  setup do
420
715
  @obj = Regress::TestSimpleBoxedA.new
@@ -472,106 +767,135 @@ describe Regress, "The generated Regress module" do
472
767
  end
473
768
  end
474
769
 
475
- describe Regress::TestStructA do
476
- describe "an instance" do
477
- it "has a working clone method" do
478
- a = Regress::TestStructA.new
479
- a.some_int = 2556
480
- a.some_int8 = -10
481
- a.some_double = 1.03455e20
482
- a.some_enum = :value2
483
-
484
- b = a.clone
485
-
486
- assert_equal 2556, b.some_int
487
- assert_equal(-10, b.some_int8)
488
- assert_equal 1.03455e20, b.some_double
489
- assert_equal :value2, b.some_enum
490
- end
770
+ describe "Regress::TestSimpleBoxedB" do
771
+ it "has a working method #copy" do
772
+ skip
491
773
  end
492
774
  end
493
775
 
494
- describe Regress::TestStructB do
495
- describe "an instance" do
496
- it "has a working method #clone" do
497
- a = Regress::TestStructB.new
498
- a.some_int8 = 42
499
- a.nested_a.some_int = 2556
500
- a.nested_a.some_int8 = -10
501
- a.nested_a.some_double = 1.03455e20
502
- a.nested_a.some_enum = :value2
503
-
504
- b = a.clone
505
-
506
- assert_equal 42, b.some_int8
507
- assert_equal 2556, b.nested_a.some_int
508
- assert_equal(-10, b.nested_a.some_int8)
509
- assert_equal 1.03455e20, b.nested_a.some_double
510
- assert_equal :value2, b.nested_a.some_enum
511
- end
776
+ describe "Regress::TestStructA" do
777
+ it "has a working method #clone" do
778
+ a = Regress::TestStructA.new
779
+ a.some_int = 2556
780
+ a.some_int8 = -10
781
+ a.some_double = 1.03455e20
782
+ a.some_enum = :value2
783
+
784
+ b = a.clone
785
+
786
+ assert_equal 2556, b.some_int
787
+ assert_equal(-10, b.some_int8)
788
+ assert_equal 1.03455e20, b.some_double
789
+ assert_equal :value2, b.some_enum
790
+ end
791
+
792
+ it "has a working function #parse" do
793
+ skip
512
794
  end
513
795
  end
514
796
 
515
- # TODO: Test the following classes.
516
- # Regress::TestStructC
517
- # Regress::TestStructD
518
- # Regress::TestStructE
519
- # Regress::TestStructFixedArray
797
+ describe "Regress::TestStructB" do
798
+ it "has a working method #clone" do
799
+ a = Regress::TestStructB.new
800
+ a.some_int8 = 42
801
+ a.nested_a.some_int = 2556
802
+ a.nested_a.some_int8 = -10
803
+ a.nested_a.some_double = 1.03455e20
804
+ a.nested_a.some_enum = :value2
805
+
806
+ b = a.clone
807
+
808
+ assert_equal 42, b.some_int8
809
+ assert_equal 2556, b.nested_a.some_int
810
+ assert_equal(-10, b.nested_a.some_int8)
811
+ assert_equal 1.03455e20, b.nested_a.some_double
812
+ assert_equal :value2, b.nested_a.some_enum
813
+ end
814
+ end
520
815
 
521
- describe Regress::TestSubObj do
522
- it "is created with #new" do
816
+ describe "Regress::TestStructC" do
817
+ it "must be tested" do
818
+ skip
819
+ end
820
+ end
821
+ describe "Regress::TestStructD" do
822
+ it "must be tested" do
823
+ skip
824
+ end
825
+ end
826
+ describe "Regress::TestStructE" do
827
+ it "must be tested" do
828
+ skip
829
+ end
830
+ end
831
+ describe "Regress::TestStructE__some_union__union" do
832
+ it "must be tested" do
833
+ skip
834
+ end
835
+ end
836
+ describe "Regress::TestStructF" do
837
+ it "must be tested" do
838
+ skip
839
+ end
840
+ end
841
+ describe "Regress::TestStructFixedArray" do
842
+ it "has a working method #frob" do
843
+ skip
844
+ end
845
+ end
846
+
847
+ describe "Regress::TestSubObj" do
848
+ it "creates an instance using #new" do
523
849
  tso = Regress::TestSubObj.new
524
850
  assert_instance_of Regress::TestSubObj, tso
525
851
  end
526
852
 
527
- describe "an instance" do
528
- before do
529
- @tso = Regress::TestSubObj.new
530
- end
853
+ let(:instance) { Regress::TestSubObj.new }
531
854
 
532
- it "has a working method #instance_method" do
533
- res = @tso.instance_method
534
- assert_equal 0, res
535
- end
855
+ it "has a working method #instance_method" do
856
+ res = instance.instance_method
857
+ assert_equal 0, res
858
+ end
536
859
 
537
- it "has a working method #unset_bare" do
538
- @tso.unset_bare
539
- pass
540
- end
860
+ it "has a working method #unset_bare" do
861
+ instance.unset_bare
862
+ pass
863
+ end
541
864
 
542
- it "does not have a field parent_instance" do
543
- assert_raises(NoMethodError) { @tso.parent_instance }
544
- end
865
+ it "does not have a field parent_instance" do
866
+ assert_raises(NoMethodError) { instance.parent_instance }
545
867
  end
546
868
  end
547
869
 
548
- describe Regress::TestWi8021x do
870
+ describe "Regress::TestWi8021x" do
549
871
  it "creates an instance using #new" do
550
872
  o = Regress::TestWi8021x.new
551
873
  assert_instance_of Regress::TestWi8021x, o
552
874
  end
553
875
 
554
- it "has a working #static_method" do
876
+ it "has a working function #static_method" do
555
877
  assert_equal(-84, Regress::TestWi8021x.static_method(-42))
556
878
  end
557
879
 
558
- describe "an instance" do
559
- setup do
560
- @obj = Regress::TestWi8021x.new
561
- end
880
+ let(:instance) { Regress::TestWi8021x.new }
562
881
 
563
- it "sets its boolean field with #set_testbool" do
564
- @obj.set_testbool true
565
- assert_equal 1, get_field_value(@obj, :testbool)
566
- @obj.set_testbool false
567
- assert_equal 0, get_field_value(@obj, :testbool)
568
- end
882
+ it "has a working method #get_testbool" do
883
+ instance.set_testbool false
884
+ assert_equal false, instance.get_testbool
885
+ instance.set_testbool true
886
+ assert_equal true, instance.get_testbool
887
+ end
569
888
 
570
- it "gets its boolean field with #get_testbool" do
571
- @obj.set_testbool false
572
- assert_equal false, @obj.get_testbool
573
- @obj.set_testbool true
574
- assert_equal true, @obj.get_testbool
889
+ it "has a working method #set_testbool" do
890
+ instance.set_testbool true
891
+ assert_equal 1, get_field_value(instance, :testbool)
892
+ instance.set_testbool false
893
+ assert_equal 0, get_field_value(instance, :testbool)
894
+ end
895
+
896
+ describe "an instance" do
897
+ setup do
898
+ @obj = instance
575
899
  end
576
900
 
577
901
  it "gets its boolean field with #get_property" do
@@ -600,40 +924,57 @@ describe Regress, "The generated Regress module" do
600
924
  assert_equal "const ♥ utf8", Regress::UTF8_CONSTANT
601
925
  end
602
926
 
603
- it "has the function #set_abort_on_error" do
927
+ it "has a working function #aliased_caller_alloc" do
928
+ skip
929
+ end
930
+ it "has a working function #atest_error_quark" do
931
+ skip
932
+ end
933
+ it "has a working function #func_obj_null_in" do
934
+ skip
935
+ end
936
+ it "has a working function #global_get_flags_out" do
937
+ skip
938
+ end
939
+ it "has a working function #has_parameter_named_attrs" do
940
+ skip
941
+ end
942
+ it "has a working function #introspectable_via_alias" do
943
+ skip
944
+ end
945
+
946
+ it "has a working function #set_abort_on_error" do
604
947
  Regress.set_abort_on_error false
605
948
  Regress.set_abort_on_error true
606
949
  end
607
950
 
608
- describe "#test_array_fixed_out_objects" do
609
- before do
610
- skip unless get_introspection_data 'Regress', 'test_array_fixed_out_objects'
611
- @result = Regress.test_array_fixed_out_objects
612
- end
951
+ it "has a working function #test_abc_error_quark" do
952
+ skip
953
+ end
954
+ it "has a working function #test_array_callback" do
955
+ skip
956
+ end
613
957
 
614
- it "returns an array of two items" do
615
- assert_equal 2, @result.length
616
- end
958
+ it "has a working function #test_array_fixed_out_objects" do
959
+ result = Regress.test_array_fixed_out_objects
617
960
 
618
- it "returns an array TestObj objects" do
619
- @result.each {|o|
620
- assert_instance_of Regress::TestObj, o
621
- }
622
- end
961
+ assert_equal 2, result.length
623
962
 
624
- it "returns objects with the correct GType" do
625
- gtype = Regress::TestObj.get_gtype
626
- @result.each {|o|
627
- assert_equal gtype, GObject.type_from_instance(o)
628
- }
629
- end
963
+ result.each {|o|
964
+ assert_instance_of Regress::TestObj, o
965
+ }
966
+
967
+ gtype = Regress::TestObj.get_gtype
968
+ result.each {|o|
969
+ assert_equal gtype, GObject.type_from_instance(o)
970
+ }
630
971
  end
631
972
 
632
- describe "#test_array_fixed_size_int_in" do
633
- it "returns the correct result" do
634
- assert_equal 5 + 4 + 3 + 2 + 1, Regress.test_array_fixed_size_int_in([5, 4, 3, 2, 1])
635
- end
973
+ it "has a working function #test_array_fixed_size_int_in" do
974
+ assert_equal 5 + 4 + 3 + 2 + 1, Regress.test_array_fixed_size_int_in([5, 4, 3, 2, 1])
975
+ end
636
976
 
977
+ describe "#test_array_fixed_size_int_in" do
637
978
  it "raises an error when called with the wrong number of arguments" do
638
979
  assert_raises ArgumentError do
639
980
  Regress.test_array_fixed_size_int_in [2]
@@ -641,65 +982,65 @@ describe Regress, "The generated Regress module" do
641
982
  end
642
983
  end
643
984
 
644
- it "has correct test_array_fixed_size_int_out" do
985
+ it "has a working function #test_array_fixed_size_int_out" do
645
986
  assert_equal [0, 1, 2, 3, 4], Regress.test_array_fixed_size_int_out
646
987
  end
647
988
 
648
- it "has correct test_array_fixed_size_int_return" do
989
+ it "has a working function #test_array_fixed_size_int_return" do
649
990
  assert_equal [0, 1, 2, 3, 4], Regress.test_array_fixed_size_int_return
650
991
  end
651
992
 
652
- it "has correct test_array_gint16_in" do
993
+ it "has a working function #test_array_gint16_in" do
653
994
  assert_equal 5 + 4 + 3, Regress.test_array_gint16_in([5, 4, 3])
654
995
  end
655
996
 
656
- it "has correct test_array_gint32_in" do
997
+ it "has a working function #test_array_gint32_in" do
657
998
  assert_equal 5 + 4 + 3, Regress.test_array_gint32_in([5, 4, 3])
658
999
  end
659
1000
 
660
- it "has correct test_array_gint64_in" do
1001
+ it "has a working function #test_array_gint64_in" do
661
1002
  assert_equal 5 + 4 + 3, Regress.test_array_gint64_in([5, 4, 3])
662
1003
  end
663
1004
 
664
- it "has correct test_array_gint8_in" do
1005
+ it "has a working function #test_array_gint8_in" do
665
1006
  assert_equal 5 + 4 + 3, Regress.test_array_gint8_in([5, 4, 3])
666
1007
  end
667
1008
 
668
- it "has correct test_array_gtype_in" do
1009
+ it "has a working function #test_array_gtype_in" do
669
1010
  t1 = GObject.type_from_name "gboolean"
670
1011
  t2 = GObject.type_from_name "gint64"
671
1012
  assert_equal "[gboolean,gint64,]", Regress.test_array_gtype_in([t1, t2])
672
1013
  end
673
1014
 
674
- it "has correct test_array_int_full_out" do
1015
+ it "has a working function #test_array_int_full_out" do
675
1016
  assert_equal [0, 1, 2, 3, 4], Regress.test_array_int_full_out
676
1017
  end
677
1018
 
678
- it "has correct test_array_int_in" do
1019
+ it "has a working function #test_array_int_in" do
679
1020
  assert_equal 5 + 4 + 3, Regress.test_array_int_in([5, 4, 3])
680
1021
  end
681
1022
 
682
- it "has correct test_array_int_inout" do
1023
+ it "has a working function #test_array_int_inout" do
683
1024
  assert_equal [3, 4], Regress.test_array_int_inout([5, 2, 3])
684
1025
  end
685
1026
 
686
- it "has correct test_array_int_none_out" do
1027
+ it "has a working function #test_array_int_none_out" do
687
1028
  assert_equal [1, 2, 3, 4, 5], Regress.test_array_int_none_out
688
1029
  end
689
1030
 
690
- it "has correct test_array_int_null_in" do
1031
+ it "has a working function #test_array_int_null_in" do
691
1032
  assert_nothing_raised { Regress.test_array_int_null_in nil }
692
1033
  end
693
1034
 
694
- it "has correct test_array_int_null_out" do
1035
+ it "has a working function #test_array_int_null_out" do
695
1036
  assert_equal nil, Regress.test_array_int_null_out
696
1037
  end
697
1038
 
698
- it "has correct test_array_int_out" do
1039
+ it "has a working function #test_array_int_out" do
699
1040
  assert_equal [0, 1, 2, 3, 4], Regress.test_array_int_out
700
1041
  end
701
1042
 
702
- it "has correct test_async_ready_callback" do
1043
+ it "has a working function #test_async_ready_callback" do
703
1044
  main_loop = GLib::MainLoop.new nil, false
704
1045
 
705
1046
  a = 1
@@ -713,55 +1054,55 @@ describe Regress, "The generated Regress module" do
713
1054
  assert_equal 2, a
714
1055
  end
715
1056
 
716
- it "has correct test_boolean" do
1057
+ it "has a working function #test_boolean" do
717
1058
  assert_equal false, Regress.test_boolean(false)
718
1059
  assert_equal true, Regress.test_boolean(true)
719
1060
  end
720
1061
 
721
- it "has correct test_boolean_false" do
1062
+ it "has a working function #test_boolean_false" do
722
1063
  assert_equal false, Regress.test_boolean_false(false)
723
1064
  end
724
1065
 
725
- it "has correct test_boolean_true" do
1066
+ it "has a working function #test_boolean_true" do
726
1067
  assert_equal true, Regress.test_boolean_true(true)
727
1068
  end
728
1069
 
729
- it "has correct #test_cairo_context_full_return" do
1070
+ it "has a working function #test_cairo_context_full_return" do
730
1071
  ct = Regress.test_cairo_context_full_return
731
1072
  assert_instance_of Cairo::Context, ct
732
1073
  end
733
1074
 
734
- it "has correct #test_cairo_context_none_in" do
1075
+ it "has a working function #test_cairo_context_none_in" do
735
1076
  ct = Regress.test_cairo_context_full_return
736
1077
  Regress.test_cairo_context_none_in ct
737
1078
  end
738
1079
 
739
- it "has correct #test_cairo_surface_full_out" do
1080
+ it "has a working function #test_cairo_surface_full_out" do
740
1081
  cs = Regress.test_cairo_surface_full_out
741
1082
  assert_instance_of Cairo::Surface, cs
742
1083
  end
743
1084
 
744
- it "has correct #test_cairo_surface_full_return" do
1085
+ it "has a working function #test_cairo_surface_full_return" do
745
1086
  cs = Regress.test_cairo_surface_full_return
746
1087
  assert_instance_of Cairo::Surface, cs
747
1088
  end
748
1089
 
749
- it "has correct #test_cairo_surface_none_in" do
1090
+ it "has a working function #test_cairo_surface_none_in" do
750
1091
  cs = Regress.test_cairo_surface_full_return
751
1092
  Regress.test_cairo_surface_none_in cs
752
1093
  end
753
1094
 
754
- it "has correct #test_cairo_surface_none_return" do
1095
+ it "has a working function #test_cairo_surface_none_return" do
755
1096
  cs = Regress.test_cairo_surface_none_return
756
1097
  assert_instance_of Cairo::Surface, cs
757
1098
  end
758
1099
 
759
- it "has correct test_callback" do
1100
+ it "has a working function #test_callback" do
760
1101
  result = Regress.test_callback Proc.new { 5 }
761
1102
  assert_equal 5, result
762
1103
  end
763
1104
 
764
- it "has correct test_callback_async" do
1105
+ it "has a working function #test_callback_async" do
765
1106
  a = 1
766
1107
  Regress.test_callback_async Proc.new {|b|
767
1108
  a = 2
@@ -772,7 +1113,7 @@ describe Regress, "The generated Regress module" do
772
1113
  assert_equal 2, a
773
1114
  end
774
1115
 
775
- it "has correct test_callback_destroy_notify" do
1116
+ it "has a working function #test_callback_destroy_notify" do
776
1117
  a = 1
777
1118
  r1 = Regress.test_callback_destroy_notify Proc.new {|b|
778
1119
  a = 2
@@ -785,12 +1126,27 @@ describe Regress, "The generated Regress module" do
785
1126
  assert_equal 42, r2
786
1127
  end
787
1128
 
788
- describe "the #test_callback_user_data function" do
789
- it "returns the callbacks return value" do
790
- result = Regress.test_callback_user_data Proc.new {|u| 5 }, nil
791
- assert_equal 5, result
792
- end
1129
+ it "has a working function #test_callback_destroy_notify_no_user_data" do
1130
+ skip
1131
+ end
1132
+ it "has a working function #test_callback_thaw_async" do
1133
+ skip
1134
+ end
1135
+ it "has a working function #test_callback_thaw_notifications" do
1136
+ skip
1137
+ end
1138
+
1139
+ it "has a working function #test_callback_user_data" do
1140
+ a = "old-value"
1141
+ result = Regress.test_callback_user_data Proc.new {|u|
1142
+ a = u
1143
+ 5
1144
+ }, "new-value"
1145
+ a.must_equal "new-value"
1146
+ result.must_equal 5
1147
+ end
793
1148
 
1149
+ describe "the #test_callback_user_data function" do
794
1150
  it "handles boolean user_data" do
795
1151
  a = false
796
1152
  Regress.test_callback_user_data Proc.new {|u|
@@ -801,19 +1157,23 @@ describe Regress, "The generated Regress module" do
801
1157
  end
802
1158
  end
803
1159
 
804
- it "has correct test_closure" do
1160
+ it "has a working function #test_closure" do
805
1161
  c = GObject::RubyClosure.new { 5235 }
806
1162
  r = Regress.test_closure c
807
1163
  assert_equal 5235, r
808
1164
  end
809
1165
 
810
- it "has correct test_closure_one_arg" do
1166
+ it "has a working function #test_closure_one_arg" do
811
1167
  c = GObject::RubyClosure.new { |a| a * 2 }
812
1168
  r = Regress.test_closure_one_arg c, 2
813
1169
  assert_equal 4, r
814
1170
  end
815
1171
 
816
- it "has a correct #test_date_in_gvalue function" do
1172
+ it "has a working function #test_closure_variant" do
1173
+ skip
1174
+ end
1175
+
1176
+ it "has a working function #test_date_in_gvalue" do
817
1177
  r = Regress.test_date_in_gvalue
818
1178
  date = r.ruby_value
819
1179
  skip unless date.respond_to? :get_year
@@ -821,247 +1181,258 @@ describe Regress, "The generated Regress module" do
821
1181
  [date.get_year, date.get_month, date.get_day]
822
1182
  end
823
1183
 
824
- it "has correct test_double" do
1184
+ it "has a working function #test_def_error_quark" do
1185
+ skip
1186
+ end
1187
+
1188
+ it "has a working function #test_double" do
825
1189
  r = Regress.test_double 5435.32
826
1190
  assert_equal 5435.32, r
827
1191
  end
828
1192
 
829
- it "has correct test_enum_param" do
1193
+ it "has a working function #test_enum_param" do
830
1194
  r = Regress.test_enum_param :value3
831
1195
  assert_equal "value3", r
832
1196
  end
833
1197
 
1198
+ it "has a working function #test_error_quark" do
1199
+ skip
1200
+ end
1201
+
834
1202
  # TODO: Find a way to test encoding issues.
835
- it "has correct #test_filename_return" do
1203
+ it "has a working function #test_filename_return" do
836
1204
  arr = Regress.test_filename_return
837
1205
  assert_equal ["åäö", "/etc/fstab"], arr.to_a
838
1206
  end
839
1207
 
840
- it "has correct test_float" do
1208
+ it "has a working function #test_float" do
841
1209
  r = Regress.test_float 5435.32
842
1210
  assert_in_delta 5435.32, r, 0.001
843
1211
  end
844
1212
 
845
- describe "#test_garray_container_return" do
846
- before do
847
- skip unless get_introspection_data 'Regress', 'test_garray_container_return'
848
- @arr = Regress.test_garray_container_return
849
- end
850
-
851
- it "returns an instance of GLib::PtrArray" do
852
- @arr.must_be_instance_of GLib::PtrArray
853
- end
1213
+ it "has a working function #test_garray_container_return" do
1214
+ arr = Regress.test_garray_container_return
1215
+ arr.must_be_instance_of GLib::PtrArray
1216
+ arr.len.must_equal 1
854
1217
 
855
- it "returns the correct values" do
856
- @arr.len.must_be :==, 1
857
- ptr = @arr.pdata
858
- ptr2 = ptr.read_pointer
859
- ptr2.read_string.must_be :==, "regress"
860
- end
1218
+ ptr = arr.pdata
1219
+ ptr2 = ptr.read_pointer
1220
+ ptr2.read_string.must_be :==, "regress"
861
1221
  end
862
1222
 
863
- describe "#test_ghash_container_return" do
864
- before do
865
- @hash = Regress.test_ghash_container_return
866
- end
867
-
868
- it "returns an instance of GLib::HashTable" do
869
- @hash.must_be_instance_of GLib::HashTable
870
- end
1223
+ it "has a working function #test_garray_full_return" do
1224
+ skip
1225
+ end
1226
+ it "has a working function #test_gerror_callback" do
1227
+ skip
1228
+ end
871
1229
 
872
- it "returns the correct values" do
873
- @hash.to_hash.must_be :==, {"foo" => "bar", "baz" => "bat",
874
- "qux" => "quux"}
875
- end
1230
+ it "has a working function #test_ghash_container_return" do
1231
+ hash = Regress.test_ghash_container_return
1232
+ hash.must_be_instance_of GLib::HashTable
1233
+ hash.to_hash.must_equal("foo" => "bar",
1234
+ "baz" => "bat",
1235
+ "qux" => "quux")
876
1236
  end
877
1237
 
878
- it "has correct #test_ghash_everything_return" do
1238
+ it "has a working function #test_ghash_everything_return" do
879
1239
  ghash = Regress.test_ghash_everything_return
880
1240
  ghash.to_hash.must_be :==, {"foo" => "bar", "baz" => "bat",
881
1241
  "qux" => "quux"}
882
1242
  end
883
1243
 
884
- it "has correct test_ghash_nested_everything_return"
885
- it "has correct test_ghash_nested_everything_return2"
1244
+ it "has a working function #test_ghash_gvalue_in" do
1245
+ skip
1246
+ end
1247
+ it "has a working function #test_ghash_gvalue_return" do
1248
+ skip
1249
+ end
1250
+ it "has a working function #test_ghash_nested_everything_return" do
1251
+ skip
1252
+ end
1253
+ it "has a working function #test_ghash_nested_everything_return2" do
1254
+ skip
1255
+ end
886
1256
 
887
- it "has correct #test_ghash_nothing_in" do
1257
+ it "has a working function #test_ghash_nothing_in" do
888
1258
  Regress.test_ghash_nothing_in({"foo" => "bar", "baz" => "bat",
889
1259
  "qux" => "quux"})
890
1260
  end
891
1261
 
892
- it "has correct #test_ghash_nothing_in2" do
1262
+ it "has a working function #test_ghash_nothing_in2" do
893
1263
  Regress.test_ghash_nothing_in2({"foo" => "bar", "baz" => "bat",
894
1264
  "qux" => "quux"})
895
1265
  end
896
1266
 
897
- it "has correct #test_ghash_nothing_return" do
1267
+ it "has a working function #test_ghash_nothing_return" do
898
1268
  ghash = Regress.test_ghash_nothing_return
899
1269
  ghash.to_hash.must_be :==, {"foo" => "bar", "baz" => "bat",
900
1270
  "qux" => "quux"}
901
1271
  end
902
1272
 
903
- it "has correct #test_ghash_nothing_return2" do
1273
+ it "has a working function #test_ghash_nothing_return2" do
904
1274
  ghash = Regress.test_ghash_nothing_return2
905
1275
  ghash.to_hash.must_be :==, {"foo" => "bar", "baz" => "bat",
906
1276
  "qux" => "quux"}
907
1277
  end
908
1278
 
909
- it "has correct #test_ghash_null_in" do
1279
+ it "has a working function #test_ghash_null_in" do
910
1280
  Regress.test_ghash_null_in(nil)
911
1281
  end
912
1282
 
913
- it "has correct #test_ghash_null_out" do
1283
+ it "has a working function #test_ghash_null_out" do
914
1284
  ghash = Regress.test_ghash_null_out
915
1285
  ghash.must_be_nil
916
1286
  end
917
1287
 
918
- it "has correct #test_ghash_null_return" do
1288
+ it "has a working function #test_ghash_null_return" do
919
1289
  ghash = Regress.test_ghash_null_return
920
1290
  ghash.must_be_nil
921
1291
  end
922
1292
 
923
- describe "#test_glist_container_return" do
924
- setup do
925
- @list = Regress.test_glist_container_return
926
- end
927
-
928
- it "returns an instance of GLib::SList" do
929
- assert_instance_of GLib::List, @list
930
- end
931
-
932
- it "returns the correct values" do
933
- assert_equal ["1", "2", "3"], @list.to_a
934
- end
1293
+ it "has a working function #test_glist_container_return" do
1294
+ list = Regress.test_glist_container_return
1295
+ assert_instance_of GLib::List, list
1296
+ assert_equal ["1", "2", "3"], list.to_a
935
1297
  end
936
1298
 
937
- it "has correct test_glist_everything_return" do
1299
+ it "has a working function #test_glist_everything_return" do
938
1300
  list = Regress.test_glist_everything_return
939
1301
  assert_equal ["1", "2", "3"], list.to_a
940
1302
  end
941
1303
 
942
- it "has correct test_glist_nothing_in" do
1304
+ it "has a working function #test_glist_nothing_in" do
943
1305
  assert_nothing_raised {
944
1306
  Regress.test_glist_nothing_in ["1", "2", "3"]
945
1307
  }
946
1308
  end
947
1309
 
948
- it "has correct test_glist_nothing_in2" do
1310
+ it "has a working function #test_glist_nothing_in2" do
949
1311
  assert_nothing_raised {
950
1312
  Regress.test_glist_nothing_in2 ["1", "2", "3"]
951
1313
  }
952
1314
  end
953
1315
 
954
- it "has correct test_glist_nothing_return" do
1316
+ it "has a working function #test_glist_nothing_return" do
955
1317
  list = Regress.test_glist_nothing_return
956
1318
  assert_equal ["1", "2", "3"], list.to_a
957
1319
  end
958
1320
 
959
- it "has correct test_glist_nothing_return2" do
1321
+ it "has a working function #test_glist_nothing_return2" do
960
1322
  list = Regress.test_glist_nothing_return2
961
1323
  assert_equal ["1", "2", "3"], list.to_a
962
1324
  end
963
1325
 
964
- it "has correct test_glist_null_in" do
1326
+ it "has a working function #test_glist_null_in" do
965
1327
  assert_nothing_raised {
966
1328
  Regress.test_glist_null_in nil
967
1329
  }
968
1330
  end
969
1331
 
970
- it "has correct test_glist_null_out" do
1332
+ it "has a working function #test_glist_null_out" do
971
1333
  result = Regress.test_glist_null_out
972
1334
  assert_equal nil, result
973
1335
  end
974
1336
 
975
- describe "#test_gslist_container_return" do
976
- setup do
977
- @slist = Regress.test_gslist_container_return
978
- end
979
-
980
- it "returns a GLib::SList object" do
981
- assert_instance_of GLib::SList, @slist
982
- end
983
-
984
- it "returns the correct values" do
985
- assert_equal ["1", "2", "3"], @slist.to_a
986
- end
1337
+ it "has a working function #test_gslist_container_return" do
1338
+ slist = Regress.test_gslist_container_return
1339
+ assert_instance_of GLib::SList, slist
1340
+ assert_equal ["1", "2", "3"], slist.to_a
987
1341
  end
988
1342
 
989
- it "has correct test_gslist_everything_return" do
1343
+ it "has a working function #test_gslist_everything_return" do
990
1344
  slist = Regress.test_gslist_everything_return
991
1345
  assert_equal ["1", "2", "3"], slist.to_a
992
1346
  end
993
1347
 
994
- it "has correct test_gslist_nothing_in" do
1348
+ it "has a working function #test_gslist_nothing_in" do
995
1349
  assert_nothing_raised {
996
1350
  Regress.test_gslist_nothing_in ["1", "2", "3"]
997
1351
  }
998
1352
  end
999
1353
 
1000
- it "has correct test_gslist_nothing_in2" do
1354
+ it "has a working function #test_gslist_nothing_in2" do
1001
1355
  assert_nothing_raised {
1002
1356
  Regress.test_gslist_nothing_in2 ["1", "2", "3"]
1003
1357
  }
1004
1358
  end
1005
1359
 
1006
- it "has correct test_gslist_nothing_return" do
1360
+ it "has a working function #test_gslist_nothing_return" do
1007
1361
  slist = Regress.test_gslist_nothing_return
1008
1362
  assert_equal ["1", "2", "3"], slist.to_a
1009
1363
  end
1010
1364
 
1011
- it "has correct test_gslist_nothing_return2" do
1365
+ it "has a working function #test_gslist_nothing_return2" do
1012
1366
  slist = Regress.test_gslist_nothing_return2
1013
1367
  assert_equal ["1", "2", "3"], slist.to_a
1014
1368
  end
1015
1369
 
1016
- it "has correct test_gslist_null_in" do
1370
+ it "has a working function #test_gslist_null_in" do
1017
1371
  assert_nothing_raised {
1018
1372
  Regress.test_gslist_null_in nil
1019
1373
  }
1020
1374
  end
1021
1375
 
1022
- describe "#test_gslist_null_out" do
1023
- it "returns nil" do
1024
- result = Regress.test_gslist_null_out
1025
- assert_equal nil, result
1026
- end
1376
+ it "has a working function #test_gslist_null_out" do
1377
+ result = Regress.test_gslist_null_out
1378
+ assert_equal nil, result
1027
1379
  end
1028
1380
 
1029
- it "has correct test_gtype" do
1381
+ it "has a working function #test_gtype" do
1030
1382
  result = Regress.test_gtype 23
1031
1383
  assert_equal 23, result
1032
1384
  end
1033
1385
 
1034
- it "has correct test_int" do
1386
+ it "has a working function #test_gvariant_as" do
1387
+ skip
1388
+ end
1389
+ it "has a working function #test_gvariant_asv" do
1390
+ skip
1391
+ end
1392
+ it "has a working function #test_gvariant_i" do
1393
+ skip
1394
+ end
1395
+ it "has a working function #test_gvariant_s" do
1396
+ skip
1397
+ end
1398
+ it "has a working function #test_gvariant_v" do
1399
+ skip
1400
+ end
1401
+ it "has a working function #test_hash_table_callback" do
1402
+ skip
1403
+ end
1404
+
1405
+ it "has a working function #test_int" do
1035
1406
  result = Regress.test_int 23
1036
1407
  assert_equal 23, result
1037
1408
  end
1038
1409
 
1039
- it "has correct test_int16" do
1410
+ it "has a working function #test_int16" do
1040
1411
  result = Regress.test_int16 23
1041
1412
  assert_equal 23, result
1042
1413
  end
1043
1414
 
1044
- it "has correct test_int32" do
1415
+ it "has a working function #test_int32" do
1045
1416
  result = Regress.test_int32 23
1046
1417
  assert_equal 23, result
1047
1418
  end
1048
1419
 
1049
- it "has correct test_int64" do
1420
+ it "has a working function #test_int64" do
1050
1421
  result = Regress.test_int64 2300000000000
1051
1422
  assert_equal 2300000000000, result
1052
1423
  end
1053
1424
 
1054
- it "has correct test_int8" do
1425
+ it "has a working function #test_int8" do
1055
1426
  result = Regress.test_int8 23
1056
1427
  assert_equal 23, result
1057
1428
  end
1058
1429
 
1059
- it "has correct test_int_out_utf8" do
1430
+ it "has a working function #test_int_out_utf8" do
1060
1431
  len = Regress.test_int_out_utf8 "How long?"
1061
1432
  assert_equal 9, len
1062
1433
  end
1063
1434
 
1064
- it "has correct test_int_value_arg" do
1435
+ it "has a working function #test_int_value_arg" do
1065
1436
  gv = GObject::Value.new
1066
1437
  gv.init GObject.type_from_name "gint"
1067
1438
  gv.set_int 343
@@ -1069,13 +1440,13 @@ describe Regress, "The generated Regress module" do
1069
1440
  assert_equal 343, result
1070
1441
  end
1071
1442
 
1072
- it "has correct test_long" do
1443
+ it "has a working function #test_long" do
1073
1444
  long_val = FFI.type_size(:long) == 8 ? 2_300_000_000_000 : 2_000_000_000
1074
1445
  result = Regress.test_long long_val
1075
1446
  assert_equal long_val, result
1076
1447
  end
1077
1448
 
1078
- it "has correct test_multi_callback" do
1449
+ it "has a working function #test_multi_callback" do
1079
1450
  a = 1
1080
1451
  result = Regress.test_multi_callback Proc.new {
1081
1452
  a += 1
@@ -1085,102 +1456,104 @@ describe Regress, "The generated Regress module" do
1085
1456
  assert_equal 3, a
1086
1457
  end
1087
1458
 
1088
- it "has correct test_multi_double_args" do
1459
+ it "has a working function #test_multi_double_args" do
1089
1460
  one, two = Regress.test_multi_double_args 23.1
1090
1461
  assert_equal 2 * 23.1, one
1091
1462
  assert_equal 3 * 23.1, two
1092
1463
  end
1093
1464
 
1094
- it "has correct test_short" do
1465
+ it "has a working function #test_multiline_doc_comments" do
1466
+ skip
1467
+ end
1468
+ it "has a working function #test_nested_parameter" do
1469
+ skip
1470
+ end
1471
+ it "has a working function #test_null_gerror_callback" do
1472
+ skip
1473
+ end
1474
+ it "has a working function #test_owned_gerror_callback" do
1475
+ skip
1476
+ end
1477
+
1478
+ it "has a working function #test_short" do
1095
1479
  result = Regress.test_short 23
1096
1480
  assert_equal 23, result
1097
1481
  end
1098
1482
 
1099
- it "has correct test_simple_boxed_a_const_return" do
1483
+ it "has a working function #test_simple_boxed_a_const_return" do
1100
1484
  result = Regress.test_simple_boxed_a_const_return
1101
1485
  assert_equal [5, 6, 7.0], [result.some_int, result.some_int8, result.some_double]
1102
1486
  end
1103
1487
 
1104
- describe "the #test_simple_callback function" do
1105
- it "calls the passed-in proc" do
1106
- a = 0
1107
- Regress.test_simple_callback Proc.new { a = 1 }
1108
- assert_equal 1, a
1109
- end
1110
-
1111
- # XXX: The scope data does not seem to be reliable enough.
1112
- if false
1113
- it "does not store the proc in CALLBACKS" do
1114
- n = Regress::Lib::CALLBACKS.length
1115
- Regress.test_simple_callback Proc.new { }
1116
- assert_equal n, Regress::Lib::CALLBACKS.length
1117
- end
1118
- end
1488
+ it "has a working function #test_simple_callback" do
1489
+ a = 0
1490
+ Regress.test_simple_callback Proc.new { a = 1 }
1491
+ assert_equal 1, a
1119
1492
  end
1120
1493
 
1121
- it "has correct test_size" do
1494
+ it "has a working function #test_size" do
1122
1495
  assert_equal 2354, Regress.test_size(2354)
1123
1496
  end
1124
1497
 
1125
- it "has correct test_ssize" do
1498
+ it "has a working function #test_ssize" do
1126
1499
  assert_equal(-2_000_000, Regress.test_ssize(-2_000_000))
1127
1500
  end
1128
1501
 
1129
- it "has correct test_strv_in" do
1502
+ it "has a working function #test_struct_a_parse" do
1503
+ skip
1504
+ end
1505
+
1506
+ it "has a working function #test_strv_in" do
1130
1507
  assert_equal true, Regress.test_strv_in(['1', '2', '3'])
1131
1508
  end
1132
1509
 
1133
- it "has correct #test_strv_in_gvalue" do
1510
+ it "has a working function #test_strv_in_gvalue" do
1134
1511
  gv = Regress.test_strv_in_gvalue
1135
1512
  assert_equal ['one', 'two', 'three'], gv.ruby_value.to_a
1136
1513
  end
1137
1514
 
1138
- it "has correct #test_strv_out" do
1515
+ it "has a working function #test_strv_out" do
1139
1516
  arr = Regress.test_strv_out
1140
1517
  assert_equal ["thanks", "for", "all", "the", "fish"], arr.to_a
1141
1518
  end
1142
1519
 
1143
- it "has correct #test_strv_out_c" do
1520
+ it "has a working function #test_strv_out_c" do
1144
1521
  arr = Regress.test_strv_out_c
1145
1522
  assert_equal ["thanks", "for", "all", "the", "fish"], arr.to_a
1146
1523
  end
1147
1524
 
1148
- it "has correct #test_strv_out_container" do
1525
+ it "has a working function #test_strv_out_container" do
1149
1526
  arr = Regress.test_strv_out_container
1150
1527
  assert_equal ['1', '2', '3'], arr.to_a
1151
1528
  end
1152
1529
 
1153
- it "has correct #test_strv_outarg" do
1530
+ it "has a working function #test_strv_outarg" do
1154
1531
  arr = Regress.test_strv_outarg
1155
1532
  assert_equal ['1', '2', '3'], arr.to_a
1156
1533
  end
1157
1534
 
1158
- it "has correct test_timet" do
1535
+ it "has a working function #test_timet" do
1159
1536
  # Time rounded to seconds.
1160
1537
  t = Time.at(Time.now.to_i)
1161
1538
  result = Regress.test_timet(t.to_i)
1162
1539
  assert_equal t, Time.at(result)
1163
1540
  end
1164
1541
 
1165
- it "has correct test_torture_signature_0" do
1542
+ it "has a working function #test_torture_signature_0" do
1166
1543
  y, z, q = Regress.test_torture_signature_0 86, "foo", 2
1167
1544
  assert_equal [86, 2*86, 3+2], [y, z, q]
1168
1545
  end
1169
1546
 
1170
- describe "its #test_torture_signature_1 method" do
1171
- it "works for m even" do
1172
- ret, y, z, q = Regress.test_torture_signature_1(-21, "hello", 12)
1173
- assert_equal [true, -21, 2 * -21, "hello".length + 12], [ret, y, z, q]
1174
- end
1547
+ it "has a working function #test_torture_signature_1" do
1548
+ ret, y, z, q = Regress.test_torture_signature_1(-21, "hello", 12)
1549
+ assert_equal [true, -21, 2 * -21, "hello".length + 12], [ret, y, z, q]
1175
1550
 
1176
- it "throws an exception for m odd" do
1177
- assert_raises RuntimeError do
1178
- Regress.test_torture_signature_1(-21, "hello", 11)
1179
- end
1551
+ assert_raises RuntimeError do
1552
+ Regress.test_torture_signature_1(-21, "hello", 11)
1180
1553
  end
1181
1554
  end
1182
-
1183
- it "has correct test_torture_signature_2" do
1555
+
1556
+ it "has a working function #test_torture_signature_2" do
1184
1557
  a = 1
1185
1558
  y, z, q = Regress.test_torture_signature_2 244,
1186
1559
  Proc.new {|u| a = u }, 2, Proc.new { a = 3 },
@@ -1189,95 +1562,107 @@ describe Regress, "The generated Regress module" do
1189
1562
  assert_equal 3, a
1190
1563
  end
1191
1564
 
1192
- it "has correct test_uint" do
1565
+ it "has a working function #test_uint" do
1193
1566
  assert_equal 31, Regress.test_uint(31)
1194
1567
  end
1195
1568
 
1196
- it "has correct test_uint16" do
1569
+ it "has a working function #test_uint16" do
1197
1570
  assert_equal 31, Regress.test_uint16(31)
1198
1571
  end
1199
1572
 
1200
- it "has correct test_uint32" do
1573
+ it "has a working function #test_uint32" do
1201
1574
  assert_equal 540000, Regress.test_uint32(540000)
1202
1575
  end
1203
1576
 
1204
- it "has correct test_uint64" do
1577
+ it "has a working function #test_uint64" do
1205
1578
  assert_equal 54_000_000_000_000, Regress.test_uint64(54_000_000_000_000)
1206
1579
  end
1207
1580
 
1208
- it "has correct test_uint8" do
1581
+ it "has a working function #test_uint8" do
1209
1582
  assert_equal 31, Regress.test_uint8(31)
1210
1583
  end
1211
1584
 
1212
- it "has correct test_ulong" do
1585
+ it "has a working function #test_ulong" do
1213
1586
  assert_equal 54_000_000_000_000, Regress.test_uint64(54_000_000_000_000)
1214
1587
  end
1215
1588
 
1216
- it "has a correct #test_unichar" do
1589
+ it "has a working function #test_unconventional_error_quark" do
1590
+ skip unless get_introspection_data 'Regress', 'test_unconventional_error_quark'
1591
+ result = Regress.test_unconventional_error_quark
1592
+ GLib.quark_to_string(result).must_equal "regress-test-other-error"
1593
+ end
1594
+
1595
+ it "has a working function #test_unichar" do
1217
1596
  assert_equal 120, Regress.test_unichar(120)
1218
1597
  assert_equal 540_000, Regress.test_unichar(540_000)
1219
1598
  end
1220
1599
 
1221
- it "has a correct #test_unsigned_enum_param" do
1600
+ it "has a working function #test_unsigned_enum_param" do
1222
1601
  assert_equal "value1", Regress.test_unsigned_enum_param(:value1)
1223
1602
  assert_equal "value2", Regress.test_unsigned_enum_param(:value2)
1224
1603
  end
1225
1604
 
1226
- it "has correct test_ushort" do
1605
+ it "has a working function #test_ushort" do
1227
1606
  assert_equal 54_000_000, Regress.test_uint64(54_000_000)
1228
1607
  end
1229
1608
 
1230
- it "has correct test_utf8_const_in" do
1609
+ it "has a working function #test_utf8_const_in" do
1231
1610
  assert_nothing_raised do
1232
1611
  Regress.test_utf8_const_in("const \xe2\x99\xa5 utf8")
1233
1612
  end
1234
1613
  end
1235
1614
 
1236
- it "has correct test_utf8_const_return" do
1615
+ it "has a working function #test_utf8_const_return" do
1237
1616
  result = Regress.test_utf8_const_return
1238
1617
  assert_equal "const \xe2\x99\xa5 utf8", result
1239
1618
  end
1240
1619
 
1241
- it "has correct test_utf8_inout" do
1620
+ it "has a working function #test_utf8_inout" do
1242
1621
  result = Regress.test_utf8_inout "const \xe2\x99\xa5 utf8"
1243
1622
  assert_equal "nonconst \xe2\x99\xa5 utf8", result
1244
1623
  end
1245
1624
 
1246
- it "has correct test_utf8_nonconst_return" do
1625
+ it "has a working function #test_utf8_nonconst_return" do
1247
1626
  result = Regress.test_utf8_nonconst_return
1248
1627
  assert_equal "nonconst \xe2\x99\xa5 utf8", result
1249
1628
  end
1250
1629
 
1251
- it "has correct test_utf8_null_in" do
1630
+ it "has a working function #test_utf8_null_in" do
1252
1631
  assert_nothing_raised do
1253
1632
  Regress.test_utf8_null_in nil
1254
1633
  end
1255
1634
  end
1256
1635
 
1257
- it "has correct test_utf8_null_out" do
1636
+ it "has a working function #test_utf8_null_out" do
1258
1637
  assert_equal nil, Regress.test_utf8_null_out
1259
1638
  end
1260
1639
 
1261
- it "has correct test_utf8_out" do
1640
+ it "has a working function #test_utf8_out" do
1262
1641
  result = Regress.test_utf8_out
1263
1642
  assert_equal "nonconst \xe2\x99\xa5 utf8", result
1264
1643
  end
1265
1644
 
1266
- it "has correct test_utf8_out_nonconst_return" do
1645
+ it "has a working function #test_utf8_out_nonconst_return" do
1267
1646
  r, out = Regress.test_utf8_out_nonconst_return
1268
1647
  assert_equal ["first", "second"], [r, out]
1269
1648
  end
1270
1649
 
1271
- it "has correct test_utf8_out_out" do
1650
+ it "has a working function #test_utf8_out_out" do
1272
1651
  out0, out1 = Regress.test_utf8_out_nonconst_return
1273
1652
  assert_equal ["first", "second"], [out0, out1]
1274
1653
  end
1275
1654
 
1276
- it "has correct test_value_return" do
1655
+ it "has a working function #test_value_return" do
1277
1656
  result = Regress.test_value_return 3423
1278
1657
  assert_equal 3423, result.get_int
1279
1658
  end
1280
1659
 
1660
+ it "has a working function #test_versioning" do
1661
+ skip unless get_introspection_data 'Regress', 'test_versioning'
1662
+ Regress.test_versioning
1663
+ pass
1664
+ end
1665
+
1281
1666
  it "raises an appropriate NoMethodError when a function is not found" do
1282
1667
  begin
1283
1668
  Regress.this_method_does_not_exist