gir_ffi 0.0.6 → 0.0.7
Sign up to get free protection for your applications and to get access to all the features.
- data/History.txt +12 -0
- data/TODO.rdoc +10 -0
- data/examples/04_webkit.rb +16 -0
- data/lib/gir_ffi/arg_helper.rb +130 -38
- data/lib/gir_ffi/builder/argument.rb +552 -0
- data/lib/gir_ffi/{class_builder.rb → builder/class.rb} +89 -67
- data/lib/gir_ffi/{function_definition_builder.rb → builder/function.rb} +10 -10
- data/lib/gir_ffi/{module_builder.rb → builder/module.rb} +17 -16
- data/lib/gir_ffi/builder.rb +33 -28
- data/lib/gir_ffi/class_base.rb +7 -2
- data/lib/gir_ffi/i_base_info.rb +8 -0
- data/lib/gir_ffi/i_repository.rb +6 -0
- data/lib/gir_ffi/i_struct_info.rb +5 -1
- data/lib/gir_ffi/lib.rb +2 -0
- data/lib/gir_ffi/overrides/glib.rb +30 -0
- data/lib/gir_ffi/overrides/gobject.rb +143 -26
- data/tasks/test.rake +14 -0
- data/test/arg_helper_test.rb +19 -3
- data/test/builder_test.rb +85 -73
- data/test/class_builder_test.rb +15 -11
- data/test/function_definition_builder_test.rb +32 -49
- data/test/g_object_overrides_test.rb +103 -48
- data/test/{generated_everything_test.rb → generated_regress_test.rb} +229 -167
- data/test/i_object_info_test.rb +2 -2
- data/test/i_repository_test.rb +2 -2
- data/test/lib/Makefile.am +30 -0
- data/test/lib/autogen.sh +87 -0
- data/test/lib/configure.ac +30 -0
- data/test/lib/m4/jhflags.m4 +21 -0
- data/test/module_builder_test.rb +10 -10
- data/test/test_helper.rb +14 -10
- metadata +22 -12
- data/lib/gir_ffi/argument_builder.rb +0 -382
@@ -1,49 +1,50 @@
|
|
1
1
|
require File.expand_path('test_helper.rb', File.dirname(__FILE__))
|
2
2
|
|
3
|
-
# Tests generated methods and functions in the
|
4
|
-
class
|
5
|
-
context "The generated
|
3
|
+
# Tests generated methods and functions in the Regress namespace.
|
4
|
+
class GeneratedRegressTest < Test::Unit::TestCase
|
5
|
+
context "The generated Regress module" do
|
6
6
|
setup do
|
7
|
-
GirFFI.setup :
|
7
|
+
GirFFI.setup :Regress
|
8
8
|
GirFFI.setup :GObject
|
9
9
|
GirFFI.setup :GLib
|
10
|
+
GirFFI.setup :Gtk
|
10
11
|
end
|
11
12
|
|
12
|
-
context "the
|
13
|
+
context "the Regress::TestBoxed class" do
|
13
14
|
should "create an instance using #new" do
|
14
|
-
tb =
|
15
|
-
assert_instance_of
|
15
|
+
tb = Regress::TestBoxed.new
|
16
|
+
assert_instance_of Regress::TestBoxed, tb
|
16
17
|
end
|
17
18
|
|
18
19
|
should "create an instance using #new_alternative_constructor1" do
|
19
|
-
tb =
|
20
|
-
assert_instance_of
|
20
|
+
tb = Regress::TestBoxed.new_alternative_constructor1 1
|
21
|
+
assert_instance_of Regress::TestBoxed, tb
|
21
22
|
assert_equal 1, tb[:some_int8]
|
22
23
|
end
|
23
24
|
|
24
25
|
should "create an instance using #new_alternative_constructor2" do
|
25
|
-
tb =
|
26
|
-
assert_instance_of
|
26
|
+
tb = Regress::TestBoxed.new_alternative_constructor2 1, 2
|
27
|
+
assert_instance_of Regress::TestBoxed, tb
|
27
28
|
assert_equal 1 + 2, tb[:some_int8]
|
28
29
|
end
|
29
30
|
|
30
31
|
should "create an instance using #new_alternative_constructor3" do
|
31
|
-
tb =
|
32
|
-
assert_instance_of
|
32
|
+
tb = Regress::TestBoxed.new_alternative_constructor3 "54"
|
33
|
+
assert_instance_of Regress::TestBoxed, tb
|
33
34
|
assert_equal 54, tb[:some_int8]
|
34
35
|
end
|
35
36
|
|
36
37
|
should "have non-zero positive result for #get_gtype" do
|
37
|
-
assert
|
38
|
+
assert Regress::TestBoxed.get_gtype > 0
|
38
39
|
end
|
39
40
|
|
40
41
|
context "an instance" do
|
41
42
|
setup do
|
42
|
-
@tb =
|
43
|
+
@tb = Regress::TestBoxed.new_alternative_constructor1 123
|
43
44
|
end
|
44
45
|
|
45
46
|
should "have a working equals method" do
|
46
|
-
tb2 =
|
47
|
+
tb2 = Regress::TestBoxed.new_alternative_constructor2 120, 3
|
47
48
|
assert_equal true, @tb.equals(tb2)
|
48
49
|
end
|
49
50
|
|
@@ -53,7 +54,7 @@ class GeneratedEverythingTest < Test::Unit::TestCase
|
|
53
54
|
end
|
54
55
|
|
55
56
|
should "return an instance of TestBoxed" do
|
56
|
-
assert_instance_of
|
57
|
+
assert_instance_of Regress::TestBoxed, @tb2
|
57
58
|
end
|
58
59
|
|
59
60
|
should "copy fields" do
|
@@ -68,18 +69,18 @@ class GeneratedEverythingTest < Test::Unit::TestCase
|
|
68
69
|
end
|
69
70
|
end
|
70
71
|
|
71
|
-
context "the
|
72
|
+
context "the Regress::TestEnum type" do
|
72
73
|
should "be of type FFI::Enum" do
|
73
|
-
assert_instance_of FFI::Enum,
|
74
|
+
assert_instance_of FFI::Enum, Regress::TestEnum
|
74
75
|
end
|
75
76
|
end
|
76
77
|
|
77
78
|
# TestFlags
|
78
79
|
|
79
|
-
context "the
|
80
|
+
context "the Regress::TestFloating class" do
|
80
81
|
context "an instance" do
|
81
82
|
setup do
|
82
|
-
@o =
|
83
|
+
@o = Regress::TestFloating.new
|
83
84
|
end
|
84
85
|
|
85
86
|
should "have a reference count of 1" do
|
@@ -92,39 +93,39 @@ class GeneratedEverythingTest < Test::Unit::TestCase
|
|
92
93
|
end
|
93
94
|
end
|
94
95
|
|
95
|
-
context "the
|
96
|
+
context "the Regress::TestObj class" do
|
96
97
|
should "create an instance using #new_from_file" do
|
97
|
-
o =
|
98
|
-
assert_instance_of
|
98
|
+
o = Regress::TestObj.new_from_file("foo")
|
99
|
+
assert_instance_of Regress::TestObj, o
|
99
100
|
end
|
100
101
|
|
101
102
|
should "create an instance using #new_callback" do
|
102
|
-
o =
|
103
|
-
assert_instance_of
|
103
|
+
o = Regress::TestObj.new_callback Proc.new { }, nil, nil
|
104
|
+
assert_instance_of Regress::TestObj, o
|
104
105
|
end
|
105
106
|
|
106
107
|
should "have a working #static_method" do
|
107
|
-
rv =
|
108
|
+
rv = Regress::TestObj.static_method 623
|
108
109
|
assert_equal 623.0, rv
|
109
110
|
end
|
110
111
|
|
111
112
|
context "#static_method_callback" do
|
112
113
|
should "work when called with a Proc" do
|
113
114
|
a = 1
|
114
|
-
|
115
|
+
Regress::TestObj.static_method_callback Proc.new { a = 2 }
|
115
116
|
assert_equal 2, a
|
116
117
|
end
|
117
118
|
|
118
119
|
should "work when called with nil" do
|
119
120
|
assert_nothing_raised do
|
120
|
-
|
121
|
+
Regress::TestObj.static_method_callback nil
|
121
122
|
end
|
122
123
|
end
|
123
124
|
end
|
124
125
|
|
125
126
|
context "an instance" do
|
126
127
|
setup do
|
127
|
-
@o =
|
128
|
+
@o = Regress::TestObj.new_from_file("foo")
|
128
129
|
end
|
129
130
|
|
130
131
|
should "have a reference count of 1" do
|
@@ -141,7 +142,7 @@ class GeneratedEverythingTest < Test::Unit::TestCase
|
|
141
142
|
end
|
142
143
|
|
143
144
|
should "have a working #set_bare method" do
|
144
|
-
obj =
|
145
|
+
obj = Regress::TestObj.new_from_file("bar")
|
145
146
|
rv = @o.set_bare obj
|
146
147
|
# TODO: What is the correct value to retrieve from the fields?
|
147
148
|
assert_equal obj.to_ptr, @o[:bare]
|
@@ -184,15 +185,15 @@ class GeneratedEverythingTest < Test::Unit::TestCase
|
|
184
185
|
end
|
185
186
|
end
|
186
187
|
|
187
|
-
context "the
|
188
|
+
context "the Regress::TestSimpleBoxedA class" do
|
188
189
|
should "create an instance using #new" do
|
189
|
-
obj =
|
190
|
-
assert_instance_of
|
190
|
+
obj = Regress::TestSimpleBoxedA.new
|
191
|
+
assert_instance_of Regress::TestSimpleBoxedA, obj
|
191
192
|
end
|
192
193
|
|
193
194
|
context "an instance" do
|
194
195
|
setup do
|
195
|
-
@obj =
|
196
|
+
@obj = Regress::TestSimpleBoxedA.new
|
196
197
|
@obj[:some_int] = 4236
|
197
198
|
@obj[:some_int8] = 36
|
198
199
|
@obj[:some_double] = 23.53
|
@@ -201,7 +202,7 @@ class GeneratedEverythingTest < Test::Unit::TestCase
|
|
201
202
|
|
202
203
|
context "its equals method" do
|
203
204
|
setup do
|
204
|
-
@ob2 =
|
205
|
+
@ob2 = Regress::TestSimpleBoxedA.new
|
205
206
|
@ob2[:some_int] = 4236
|
206
207
|
@ob2[:some_int8] = 36
|
207
208
|
@ob2[:some_double] = 23.53
|
@@ -229,7 +230,7 @@ class GeneratedEverythingTest < Test::Unit::TestCase
|
|
229
230
|
end
|
230
231
|
|
231
232
|
should "return an instance of TestSimpleBoxedA" do
|
232
|
-
assert_instance_of
|
233
|
+
assert_instance_of Regress::TestSimpleBoxedA, @ob2
|
233
234
|
end
|
234
235
|
|
235
236
|
should "copy fields" do
|
@@ -247,10 +248,10 @@ class GeneratedEverythingTest < Test::Unit::TestCase
|
|
247
248
|
end
|
248
249
|
end
|
249
250
|
|
250
|
-
context "the
|
251
|
+
context "the Regress::TestStructA class" do
|
251
252
|
context "an instance" do
|
252
253
|
should "have a working clone method" do
|
253
|
-
a =
|
254
|
+
a = Regress::TestStructA.new
|
254
255
|
a[:some_int] = 2556
|
255
256
|
a[:some_int8] = -10
|
256
257
|
a[:some_double] = 1.03455e20
|
@@ -270,19 +271,19 @@ class GeneratedEverythingTest < Test::Unit::TestCase
|
|
270
271
|
# TestStructC
|
271
272
|
# TestSubObj
|
272
273
|
|
273
|
-
context "the
|
274
|
+
context "the Regress::TestWi8021x class" do
|
274
275
|
should "create an instance using #new" do
|
275
|
-
o =
|
276
|
-
assert_instance_of
|
276
|
+
o = Regress::TestWi8021x.new
|
277
|
+
assert_instance_of Regress::TestWi8021x, o
|
277
278
|
end
|
278
279
|
|
279
280
|
should "have a working #static_method" do
|
280
|
-
assert_equal(-84,
|
281
|
+
assert_equal(-84, Regress::TestWi8021x.static_method(-42))
|
281
282
|
end
|
282
283
|
|
283
284
|
context "an instance" do
|
284
285
|
setup do
|
285
|
-
@obj =
|
286
|
+
@obj = Regress::TestWi8021x.new
|
286
287
|
end
|
287
288
|
|
288
289
|
should "set its boolean struct member with #set_testbool" do
|
@@ -313,103 +314,98 @@ class GeneratedEverythingTest < Test::Unit::TestCase
|
|
313
314
|
|
314
315
|
context "test_array_fixed_size_int_in" do
|
315
316
|
should "return the correct result" do
|
316
|
-
assert_equal 5 + 4 + 3 + 2 + 1,
|
317
|
+
assert_equal 5 + 4 + 3 + 2 + 1, Regress.test_array_fixed_size_int_in([5, 4, 3, 2, 1])
|
317
318
|
end
|
318
319
|
|
319
320
|
should "raise an error when called with the wrong number of arguments" do
|
320
321
|
assert_raises ArgumentError do
|
321
|
-
|
322
|
+
Regress.test_array_fixed_size_int_in [2]
|
322
323
|
end
|
323
324
|
end
|
324
325
|
end
|
325
326
|
|
326
327
|
should "have correct test_array_fixed_size_int_out" do
|
327
|
-
assert_equal [0, 1, 2, 3, 4],
|
328
|
+
assert_equal [0, 1, 2, 3, 4], Regress.test_array_fixed_size_int_out
|
328
329
|
end
|
329
330
|
|
330
331
|
should "have correct test_array_fixed_size_int_return" do
|
331
|
-
assert_equal [0, 1, 2, 3, 4],
|
332
|
+
assert_equal [0, 1, 2, 3, 4], Regress.test_array_fixed_size_int_return
|
332
333
|
end
|
333
334
|
|
334
335
|
should "have correct test_array_gint16_in" do
|
335
|
-
assert_equal 5 + 4 + 3,
|
336
|
+
assert_equal 5 + 4 + 3, Regress.test_array_gint16_in([5, 4, 3])
|
336
337
|
end
|
337
338
|
|
338
339
|
should "have correct test_array_gint32_in" do
|
339
|
-
assert_equal 5 + 4 + 3,
|
340
|
+
assert_equal 5 + 4 + 3, Regress.test_array_gint32_in([5, 4, 3])
|
340
341
|
end
|
341
342
|
|
342
343
|
should "have correct test_array_gint64_in" do
|
343
|
-
assert_equal 5 + 4 + 3,
|
344
|
+
assert_equal 5 + 4 + 3, Regress.test_array_gint64_in([5, 4, 3])
|
344
345
|
end
|
345
346
|
|
346
347
|
should "have correct test_array_gint8_in" do
|
347
|
-
assert_equal 5 + 4 + 3,
|
348
|
+
assert_equal 5 + 4 + 3, Regress.test_array_gint8_in([5, 4, 3])
|
348
349
|
end
|
349
350
|
|
350
351
|
should "have correct test_array_gtype_in" do
|
351
352
|
t1 = GObject.type_from_name "gboolean"
|
352
353
|
t2 = GObject.type_from_name "gint64"
|
353
|
-
assert_equal "[gboolean,gint64,]",
|
354
|
+
assert_equal "[gboolean,gint64,]", Regress.test_array_gtype_in([t1, t2])
|
354
355
|
end
|
355
356
|
|
356
357
|
should "have correct test_array_int_full_out" do
|
357
|
-
assert_equal [0, 1, 2, 3, 4],
|
358
|
+
assert_equal [0, 1, 2, 3, 4], Regress.test_array_int_full_out
|
358
359
|
end
|
359
360
|
|
360
361
|
should "have correct test_array_int_in" do
|
361
|
-
assert_equal 5 + 4 + 3,
|
362
|
-
end
|
363
|
-
|
364
|
-
should "have correct test_array_int_in_take" do
|
365
|
-
assert_equal 5 + 4 + 3, Everything.test_array_int_in_take([5, 4, 3])
|
362
|
+
assert_equal 5 + 4 + 3, Regress.test_array_int_in([5, 4, 3])
|
366
363
|
end
|
367
364
|
|
368
365
|
should "have correct test_array_int_inout" do
|
369
|
-
assert_equal [3, 4],
|
366
|
+
assert_equal [3, 4], Regress.test_array_int_inout([5, 2, 3])
|
370
367
|
end
|
371
368
|
|
372
369
|
should "have correct test_array_int_none_out" do
|
373
|
-
assert_equal [1, 2, 3, 4, 5],
|
370
|
+
assert_equal [1, 2, 3, 4, 5], Regress.test_array_int_none_out
|
374
371
|
end
|
375
372
|
|
376
373
|
should "have correct test_array_int_null_in" do
|
377
|
-
assert_nothing_raised {
|
374
|
+
assert_nothing_raised { Regress.test_array_int_null_in nil }
|
378
375
|
end
|
379
376
|
|
380
377
|
should "have correct test_array_int_null_out" do
|
381
|
-
assert_equal nil,
|
378
|
+
assert_equal nil, Regress.test_array_int_null_out
|
382
379
|
end
|
383
380
|
|
384
381
|
should "have correct test_array_int_out" do
|
385
|
-
assert_equal [0, 1, 2, 3, 4],
|
382
|
+
assert_equal [0, 1, 2, 3, 4], Regress.test_array_int_out
|
386
383
|
end
|
387
384
|
|
388
385
|
should "have correct test_async_ready_callback" do
|
389
386
|
a = 1
|
390
|
-
main_loop = GLib.main_loop_new nil, false
|
391
387
|
|
392
|
-
|
393
|
-
|
388
|
+
Regress.test_async_ready_callback Proc.new {
|
389
|
+
Gtk.main_quit
|
394
390
|
a = 2
|
395
391
|
}
|
396
392
|
|
397
|
-
|
393
|
+
Gtk.main
|
398
394
|
|
399
395
|
assert_equal 2, a
|
400
396
|
end
|
401
397
|
|
402
398
|
should "have correct test_boolean" do
|
403
|
-
assert_equal false,
|
404
|
-
assert_equal true,
|
399
|
+
assert_equal false, Regress.test_boolean(false)
|
400
|
+
assert_equal true, Regress.test_boolean(true)
|
405
401
|
end
|
406
402
|
|
407
403
|
should "have correct test_boolean_false" do
|
408
|
-
assert_equal false,
|
404
|
+
assert_equal false, Regress.test_boolean_false(false)
|
409
405
|
end
|
410
406
|
|
411
407
|
should "have correct test_boolean_true" do
|
412
|
-
assert_equal true,
|
408
|
+
assert_equal true, Regress.test_boolean_true(true)
|
413
409
|
end
|
414
410
|
|
415
411
|
should "have correct test_cairo_context_full_return"
|
@@ -420,43 +416,43 @@ class GeneratedEverythingTest < Test::Unit::TestCase
|
|
420
416
|
should "have correct test_cairo_surface_none_return"
|
421
417
|
|
422
418
|
should "have correct test_callback" do
|
423
|
-
result =
|
419
|
+
result = Regress.test_callback Proc.new { 5 }
|
424
420
|
assert_equal 5, result
|
425
421
|
end
|
426
422
|
|
427
423
|
should "have correct test_callback_async" do
|
428
424
|
a = 1
|
429
|
-
|
425
|
+
Regress.test_callback_async Proc.new {|b|
|
430
426
|
a = 2
|
431
427
|
b
|
432
428
|
}, 44
|
433
|
-
r =
|
429
|
+
r = Regress.test_callback_thaw_async
|
434
430
|
assert_equal 44, r
|
435
431
|
assert_equal 2, a
|
436
432
|
end
|
437
433
|
|
438
434
|
should "have correct test_callback_destroy_notify" do
|
439
435
|
a = 1
|
440
|
-
r1 =
|
436
|
+
r1 = Regress.test_callback_destroy_notify Proc.new {|b|
|
441
437
|
a = 2
|
442
438
|
b
|
443
439
|
}, 42, Proc.new { a = 3 }
|
444
440
|
assert_equal 2, a
|
445
441
|
assert_equal 42, r1
|
446
|
-
r2 =
|
442
|
+
r2 = Regress.test_callback_thaw_notifications
|
447
443
|
assert_equal 3, a
|
448
444
|
assert_equal 42, r2
|
449
445
|
end
|
450
446
|
|
451
447
|
context "the test_callback_user_data function" do
|
452
448
|
should "return the callbacks return value" do
|
453
|
-
result =
|
449
|
+
result = Regress.test_callback_user_data Proc.new {|u| 5 }, nil
|
454
450
|
assert_equal 5, result
|
455
451
|
end
|
456
452
|
|
457
453
|
should "handle boolean user_data" do
|
458
454
|
a = false
|
459
|
-
result =
|
455
|
+
result = Regress.test_callback_user_data Proc.new {|u|
|
460
456
|
a = u
|
461
457
|
5
|
462
458
|
}, true
|
@@ -464,31 +460,37 @@ class GeneratedEverythingTest < Test::Unit::TestCase
|
|
464
460
|
end
|
465
461
|
end
|
466
462
|
|
467
|
-
should "have correct test_closure"
|
468
|
-
|
463
|
+
should "have correct test_closure" do
|
464
|
+
c = GObject::RubyClosure.new { 5235 }
|
465
|
+
r = Regress.test_closure c
|
466
|
+
assert_equal 5235, r
|
467
|
+
end
|
468
|
+
|
469
|
+
should "have correct test_closure_one_arg" do
|
470
|
+
c = GObject::RubyClosure.new { |a| a * 2 }
|
471
|
+
r = Regress.test_closure_one_arg c, 2
|
472
|
+
assert_equal 4, r
|
473
|
+
end
|
469
474
|
|
470
475
|
should "have correct test_double" do
|
471
|
-
r =
|
476
|
+
r = Regress.test_double 5435.32
|
472
477
|
assert_equal 5435.32, r
|
473
478
|
end
|
474
479
|
|
475
480
|
should "have correct test_enum_param" do
|
476
|
-
r =
|
481
|
+
r = Regress.test_enum_param :value3
|
477
482
|
assert_equal "value3", r
|
478
483
|
end
|
479
484
|
|
480
485
|
should "have correct test_filename_return"
|
481
486
|
|
482
487
|
should "have correct test_float" do
|
483
|
-
r =
|
488
|
+
r = Regress.test_float 5435.32
|
484
489
|
assert_in_delta 5435.32, r, 0.001
|
485
490
|
end
|
486
491
|
|
487
|
-
should "have correct test_ghash_container_in"
|
488
492
|
should "have correct test_ghash_container_return"
|
489
|
-
should "have correct test_ghash_everything_in"
|
490
493
|
should "have correct test_ghash_everything_return"
|
491
|
-
should "have correct test_ghash_free"
|
492
494
|
should "have correct test_ghash_nested_everything_return"
|
493
495
|
should "have correct test_ghash_nested_everything_return2"
|
494
496
|
should "have correct test_ghash_nothing_in"
|
@@ -498,61 +500,125 @@ class GeneratedEverythingTest < Test::Unit::TestCase
|
|
498
500
|
should "have correct test_ghash_null_in"
|
499
501
|
should "have correct test_ghash_null_out"
|
500
502
|
should "have correct test_ghash_null_return"
|
501
|
-
|
502
|
-
should "have correct test_glist_container_return"
|
503
|
-
|
504
|
-
|
505
|
-
|
506
|
-
|
507
|
-
should "have correct
|
508
|
-
|
509
|
-
|
510
|
-
|
511
|
-
|
512
|
-
should "have correct
|
513
|
-
|
514
|
-
|
515
|
-
|
516
|
-
|
517
|
-
|
518
|
-
should "have correct
|
519
|
-
|
520
|
-
|
521
|
-
|
522
|
-
|
503
|
+
|
504
|
+
should "have correct test_glist_container_return" do
|
505
|
+
arr = Regress.test_glist_container_return
|
506
|
+
assert_equal ["1", "2", "3"], arr
|
507
|
+
end
|
508
|
+
|
509
|
+
should "have correct test_glist_everything_return" do
|
510
|
+
arr = Regress.test_glist_everything_return
|
511
|
+
assert_equal ["1", "2", "3"], arr
|
512
|
+
end
|
513
|
+
|
514
|
+
should "have correct test_glist_nothing_in" do
|
515
|
+
assert_nothing_raised {
|
516
|
+
Regress.test_glist_nothing_in ["1", "2", "3"]
|
517
|
+
}
|
518
|
+
end
|
519
|
+
|
520
|
+
should "have correct test_glist_nothing_in2" do
|
521
|
+
assert_nothing_raised {
|
522
|
+
Regress.test_glist_nothing_in2 ["1", "2", "3"]
|
523
|
+
}
|
524
|
+
end
|
525
|
+
|
526
|
+
should "have correct test_glist_nothing_return" do
|
527
|
+
arr = Regress.test_glist_nothing_return
|
528
|
+
assert_equal ["1", "2", "3"], arr
|
529
|
+
end
|
530
|
+
|
531
|
+
should "have correct test_glist_nothing_return2" do
|
532
|
+
arr = Regress.test_glist_nothing_return2
|
533
|
+
assert_equal ["1", "2", "3"], arr
|
534
|
+
end
|
535
|
+
|
536
|
+
should "have correct test_glist_null_in" do
|
537
|
+
assert_nothing_raised {
|
538
|
+
Regress.test_glist_null_in nil
|
539
|
+
}
|
540
|
+
end
|
541
|
+
|
542
|
+
should "have correct test_glist_null_out" do
|
543
|
+
result = Regress.test_glist_null_out
|
544
|
+
assert_equal [], result
|
545
|
+
end
|
546
|
+
|
547
|
+
should "have correct test_gslist_container_return" do
|
548
|
+
arr = Regress.test_gslist_container_return
|
549
|
+
assert_equal ["1", "2", "3"], arr
|
550
|
+
end
|
551
|
+
|
552
|
+
should "have correct test_gslist_everything_return" do
|
553
|
+
arr = Regress.test_gslist_everything_return
|
554
|
+
assert_equal ["1", "2", "3"], arr
|
555
|
+
end
|
556
|
+
|
557
|
+
should "have correct test_gslist_nothing_in" do
|
558
|
+
assert_nothing_raised {
|
559
|
+
Regress.test_gslist_nothing_in ["1", "2", "3"]
|
560
|
+
}
|
561
|
+
end
|
562
|
+
|
563
|
+
should "have correct test_gslist_nothing_in2" do
|
564
|
+
assert_nothing_raised {
|
565
|
+
Regress.test_gslist_nothing_in2 ["1", "2", "3"]
|
566
|
+
}
|
567
|
+
end
|
568
|
+
|
569
|
+
should "have correct test_gslist_nothing_return" do
|
570
|
+
arr = Regress.test_gslist_nothing_return
|
571
|
+
assert_equal ["1", "2", "3"], arr
|
572
|
+
end
|
573
|
+
|
574
|
+
should "have correct test_gslist_nothing_return2" do
|
575
|
+
arr = Regress.test_gslist_nothing_return2
|
576
|
+
assert_equal ["1", "2", "3"], arr
|
577
|
+
end
|
578
|
+
|
579
|
+
should "have correct test_gslist_null_in" do
|
580
|
+
assert_nothing_raised {
|
581
|
+
Regress.test_gslist_null_in nil
|
582
|
+
}
|
583
|
+
end
|
584
|
+
|
585
|
+
should "have correct test_gslist_null_out" do
|
586
|
+
result = Regress.test_gslist_null_out
|
587
|
+
assert_equal [], result
|
588
|
+
end
|
523
589
|
|
524
590
|
should "have correct test_gtype" do
|
525
|
-
result =
|
591
|
+
result = Regress.test_gtype 23
|
526
592
|
assert_equal 23, result
|
527
593
|
end
|
528
594
|
|
529
595
|
should "have correct test_int" do
|
530
|
-
result =
|
596
|
+
result = Regress.test_int 23
|
531
597
|
assert_equal 23, result
|
532
598
|
end
|
533
599
|
|
534
600
|
should "have correct test_int16" do
|
535
|
-
result =
|
601
|
+
result = Regress.test_int16 23
|
536
602
|
assert_equal 23, result
|
537
603
|
end
|
538
604
|
|
539
605
|
should "have correct test_int32" do
|
540
|
-
result =
|
606
|
+
result = Regress.test_int32 23
|
541
607
|
assert_equal 23, result
|
542
608
|
end
|
543
609
|
|
544
610
|
should "have correct test_int64" do
|
545
|
-
result =
|
611
|
+
result = Regress.test_int64 2300000000000
|
546
612
|
assert_equal 2300000000000, result
|
547
613
|
end
|
548
614
|
|
549
615
|
should "have correct test_int8" do
|
550
|
-
result =
|
616
|
+
result = Regress.test_int8 23
|
551
617
|
assert_equal 23, result
|
552
618
|
end
|
553
619
|
|
554
620
|
should "have correct test_int_out_utf8" do
|
555
|
-
len =
|
621
|
+
len = Regress.test_int_out_utf8 "How long?"
|
556
622
|
assert_equal 9, len
|
557
623
|
end
|
558
624
|
|
@@ -560,18 +626,18 @@ class GeneratedEverythingTest < Test::Unit::TestCase
|
|
560
626
|
gv = GObject::Value.new
|
561
627
|
gv.init GObject.type_from_name "gint"
|
562
628
|
gv.set_int 343
|
563
|
-
result =
|
629
|
+
result = Regress.test_int_value_arg gv
|
564
630
|
assert_equal 343, result
|
565
631
|
end
|
566
632
|
|
567
633
|
should "have correct test_long" do
|
568
|
-
result =
|
634
|
+
result = Regress.test_long 2300000000000
|
569
635
|
assert_equal 2300000000000, result
|
570
636
|
end
|
571
637
|
|
572
638
|
should "have correct test_multi_callback" do
|
573
639
|
a = 1
|
574
|
-
result =
|
640
|
+
result = Regress.test_multi_callback Proc.new {
|
575
641
|
a += 1
|
576
642
|
23
|
577
643
|
}
|
@@ -580,81 +646,83 @@ class GeneratedEverythingTest < Test::Unit::TestCase
|
|
580
646
|
end
|
581
647
|
|
582
648
|
should "have correct test_multi_double_args" do
|
583
|
-
one, two =
|
649
|
+
one, two = Regress.test_multi_double_args 23.1
|
584
650
|
assert_equal 2 * 23.1, one
|
585
651
|
assert_equal 3 * 23.1, two
|
586
652
|
end
|
587
653
|
|
588
|
-
should "have correct test_object_null_in" do
|
589
|
-
assert_nothing_raised { Everything.test_object_null_in nil }
|
590
|
-
end
|
591
|
-
|
592
|
-
should "have correct test_object_null_out" do
|
593
|
-
result = Everything.test_object_null_out
|
594
|
-
assert_equal nil, result
|
595
|
-
end
|
596
|
-
|
597
654
|
should "have correct test_short" do
|
598
|
-
result =
|
655
|
+
result = Regress.test_short 23
|
599
656
|
assert_equal 23, result
|
600
657
|
end
|
601
658
|
|
602
659
|
should "have correct test_simple_boxed_a_const_return" do
|
603
|
-
result =
|
660
|
+
result = Regress.test_simple_boxed_a_const_return
|
604
661
|
assert_equal [5, 6, 7.0], [result[:some_int], result[:some_int8], result[:some_double]]
|
605
662
|
end
|
606
663
|
|
607
664
|
context "the test_simple_callback function" do
|
608
665
|
should "call the passed-in proc" do
|
609
666
|
a = 0
|
610
|
-
|
667
|
+
Regress.test_simple_callback Proc.new { a = 1 }
|
611
668
|
assert_equal 1, a
|
612
669
|
end
|
613
670
|
|
614
671
|
# XXX: The scope data does not seem to be reliable enough.
|
615
672
|
if false
|
616
673
|
should "not store the proc in CALLBACKS" do
|
617
|
-
n =
|
618
|
-
|
619
|
-
assert_equal n,
|
674
|
+
n = Regress::Lib::CALLBACKS.length
|
675
|
+
Regress.test_simple_callback Proc.new { }
|
676
|
+
assert_equal n, Regress::Lib::CALLBACKS.length
|
620
677
|
end
|
621
678
|
end
|
622
679
|
end
|
623
680
|
|
624
681
|
should "have correct test_size" do
|
625
|
-
assert_equal 2354,
|
682
|
+
assert_equal 2354, Regress.test_size(2354)
|
683
|
+
end
|
684
|
+
|
685
|
+
should "have correct test_ssize" do
|
686
|
+
assert_equal(-2_000_000, Regress.test_ssize(-2_000_000))
|
687
|
+
end
|
688
|
+
|
689
|
+
should "have correct test_strv_in" do
|
690
|
+
assert_equal true, Regress.test_strv_in(['1', '2', '3'])
|
626
691
|
end
|
627
692
|
|
628
|
-
should "have correct test_ssize"
|
629
|
-
should "have correct test_strv_in"
|
630
|
-
should "have correct test_strv_in_container"
|
631
693
|
should "have correct test_strv_out"
|
632
694
|
should "have correct test_strv_out_c"
|
633
695
|
should "have correct test_strv_out_container"
|
634
696
|
should "have correct test_strv_outarg"
|
635
|
-
|
697
|
+
|
698
|
+
should "have correct test_timet" do
|
699
|
+
# Time rounded to seconds.
|
700
|
+
t = Time.at(Time.now.to_i)
|
701
|
+
result = Regress.test_timet(t.to_i)
|
702
|
+
assert_equal t, Time.at(result)
|
703
|
+
end
|
636
704
|
|
637
705
|
should "have correct test_torture_signature_0" do
|
638
|
-
y, z, q =
|
706
|
+
y, z, q = Regress.test_torture_signature_0 86, "foo", 2
|
639
707
|
assert_equal [86, 2*86, 3+2], [y, z, q]
|
640
708
|
end
|
641
709
|
|
642
710
|
context "its #test_torture_signature_1 method" do
|
643
711
|
should "work for m even" do
|
644
|
-
ret, y, z, q =
|
712
|
+
ret, y, z, q = Regress.test_torture_signature_1(-21, "hello", 12)
|
645
713
|
assert_equal [true, -21, 2 * -21, "hello".length + 12], [ret, y, z, q]
|
646
714
|
end
|
647
715
|
|
648
716
|
should "throw an exception for m odd" do
|
649
717
|
assert_raises RuntimeError do
|
650
|
-
|
718
|
+
Regress.test_torture_signature_1(-21, "hello", 11)
|
651
719
|
end
|
652
720
|
end
|
653
721
|
end
|
654
722
|
|
655
723
|
should "have correct test_torture_signature_2" do
|
656
724
|
a = 1
|
657
|
-
y, z, q =
|
725
|
+
y, z, q = Regress.test_torture_signature_2 244,
|
658
726
|
Proc.new {|u| a = u }, 2, Proc.new { a = 3 },
|
659
727
|
"foofoo", 31
|
660
728
|
assert_equal [244, 2*244, 6+31], [y, z, q]
|
@@ -662,88 +730,82 @@ class GeneratedEverythingTest < Test::Unit::TestCase
|
|
662
730
|
end
|
663
731
|
|
664
732
|
should "have correct test_uint" do
|
665
|
-
assert_equal 31,
|
733
|
+
assert_equal 31, Regress.test_uint(31)
|
666
734
|
end
|
667
735
|
|
668
736
|
should "have correct test_uint16" do
|
669
|
-
assert_equal 31,
|
737
|
+
assert_equal 31, Regress.test_uint16(31)
|
670
738
|
end
|
671
739
|
|
672
740
|
should "have correct test_uint32" do
|
673
|
-
assert_equal 540000,
|
741
|
+
assert_equal 540000, Regress.test_uint32(540000)
|
674
742
|
end
|
675
743
|
|
676
744
|
should "have correct test_uint64" do
|
677
|
-
assert_equal 54_000_000_000_000,
|
745
|
+
assert_equal 54_000_000_000_000, Regress.test_uint64(54_000_000_000_000)
|
678
746
|
end
|
679
747
|
|
680
748
|
should "have correct test_uint8" do
|
681
|
-
assert_equal 31,
|
749
|
+
assert_equal 31, Regress.test_uint8(31)
|
682
750
|
end
|
683
751
|
|
684
752
|
should "have correct test_ulong" do
|
685
|
-
assert_equal 54_000_000_000_000,
|
753
|
+
assert_equal 54_000_000_000_000, Regress.test_uint64(54_000_000_000_000)
|
686
754
|
end
|
687
755
|
|
688
756
|
should "have correct test_ushort" do
|
689
|
-
assert_equal 54_000_000,
|
757
|
+
assert_equal 54_000_000, Regress.test_uint64(54_000_000)
|
690
758
|
end
|
691
759
|
|
692
760
|
should "have correct test_utf8_const_in" do
|
693
761
|
# TODO: Capture stderr to automatically look for error messages.
|
694
762
|
assert_nothing_raised do
|
695
|
-
|
763
|
+
Regress.test_utf8_const_in("const \xe2\x99\xa5 utf8")
|
696
764
|
end
|
697
765
|
end
|
698
766
|
|
699
767
|
should "have correct test_utf8_const_return" do
|
700
|
-
result =
|
768
|
+
result = Regress.test_utf8_const_return
|
701
769
|
assert_equal "const \xe2\x99\xa5 utf8", result
|
702
770
|
end
|
703
771
|
|
704
772
|
should "have correct test_utf8_inout" do
|
705
|
-
result =
|
773
|
+
result = Regress.test_utf8_inout "const \xe2\x99\xa5 utf8"
|
706
774
|
assert_equal "nonconst \xe2\x99\xa5 utf8", result
|
707
775
|
end
|
708
776
|
|
709
|
-
should "have correct test_utf8_nonconst_in" do
|
710
|
-
assert_nothing_raised do
|
711
|
-
Everything.test_utf8_nonconst_in "nonconst \xe2\x99\xa5 utf8"
|
712
|
-
end
|
713
|
-
end
|
714
|
-
|
715
777
|
should "have correct test_utf8_nonconst_return" do
|
716
|
-
result =
|
778
|
+
result = Regress.test_utf8_nonconst_return
|
717
779
|
assert_equal "nonconst \xe2\x99\xa5 utf8", result
|
718
780
|
end
|
719
781
|
|
720
782
|
should "have correct test_utf8_null_in" do
|
721
783
|
assert_nothing_raised do
|
722
|
-
|
784
|
+
Regress.test_utf8_null_in nil
|
723
785
|
end
|
724
786
|
end
|
725
787
|
|
726
788
|
should "have correct test_utf8_null_out" do
|
727
|
-
assert_equal nil,
|
789
|
+
assert_equal nil, Regress.test_utf8_null_out
|
728
790
|
end
|
729
791
|
|
730
792
|
should "have correct test_utf8_out" do
|
731
|
-
result =
|
793
|
+
result = Regress.test_utf8_out
|
732
794
|
assert_equal "nonconst \xe2\x99\xa5 utf8", result
|
733
795
|
end
|
734
796
|
|
735
797
|
should "have correct test_utf8_out_nonconst_return" do
|
736
|
-
r, out =
|
798
|
+
r, out = Regress.test_utf8_out_nonconst_return
|
737
799
|
assert_equal ["first", "second"], [r, out]
|
738
800
|
end
|
739
801
|
|
740
802
|
should "have correct test_utf8_out_out" do
|
741
|
-
out0, out1 =
|
803
|
+
out0, out1 = Regress.test_utf8_out_nonconst_return
|
742
804
|
assert_equal ["first", "second"], [out0, out1]
|
743
805
|
end
|
744
806
|
|
745
807
|
should "have correct test_value_return" do
|
746
|
-
result =
|
808
|
+
result = Regress.test_value_return 3423
|
747
809
|
assert_equal 3423, result.get_int
|
748
810
|
end
|
749
811
|
|