gir_ffi 0.2.3 → 0.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/History.txt +14 -0
- data/README.rdoc +3 -1
- data/examples/02_hello_world.rb +1 -0
- data/examples/03_upgraded_hello_world.rb +2 -1
- data/examples/05_notification.rb +2 -2
- data/examples/hard_coded.rb +31 -8
- data/lib/ffi-glib/array.rb +1 -1
- data/lib/ffi-glib/container_class_methods.rb +25 -0
- data/lib/ffi-glib/hash_table.rb +41 -38
- data/lib/ffi-glib/list.rb +15 -22
- data/lib/ffi-glib/list_methods.rb +16 -16
- data/lib/ffi-glib/ptr_array.rb +20 -15
- data/lib/ffi-glib/s_list.rb +15 -23
- data/lib/ffi-glib.rb +7 -0
- data/lib/ffi-gobject/base.rb +0 -13
- data/lib/ffi-gobject/object.rb +6 -0
- data/lib/ffi-gobject/ruby_style.rb +21 -0
- data/lib/ffi-gobject.rb +44 -0
- data/lib/ffi-gobject_introspection/i_object_info.rb +7 -0
- data/lib/ffi-gobject_introspection/lib.rb +1 -0
- data/lib/gir_ffi/arg_helper.rb +8 -6
- data/lib/gir_ffi/builder/argument.rb +1 -1
- data/lib/gir_ffi/builder/field.rb +6 -3
- data/lib/gir_ffi/builder/property.rb +28 -0
- data/lib/gir_ffi/builder/type/base.rb +6 -4
- data/lib/gir_ffi/builder/type/interface.rb +1 -0
- data/lib/gir_ffi/builder/type/object.rb +26 -1
- data/lib/gir_ffi/builder/type/registered_type.rb +9 -1
- data/lib/gir_ffi/builder/type/unintrospectable.rb +26 -8
- data/lib/gir_ffi/builder/type/user_defined.rb +119 -0
- data/lib/gir_ffi/builder/type/with_layout.rb +3 -3
- data/lib/gir_ffi/builder.rb +5 -0
- data/lib/gir_ffi/class_base.rb +6 -6
- data/lib/gir_ffi/info_ext/i_property_info.rb +12 -0
- data/lib/gir_ffi/info_ext/i_type_info.rb +4 -0
- data/lib/gir_ffi/user_defined/i_base_info.rb +7 -0
- data/lib/gir_ffi/user_defined/i_object_info.rb +13 -0
- data/lib/gir_ffi/user_defined/i_property_info.rb +9 -0
- data/lib/gir_ffi/user_defined/i_registered_type_info.rb +10 -0
- data/lib/gir_ffi/version.rb +1 -1
- data/lib/gir_ffi.rb +6 -0
- data/tasks/test.rake +12 -2
- data/test/builder_test.rb +0 -124
- data/test/ffi-glib/hash_table_test.rb +0 -14
- data/test/ffi-glib/list_test.rb +0 -13
- data/test/ffi-glib/ptr_array_test.rb +26 -8
- data/test/ffi-glib/s_list_test.rb +4 -4
- data/test/ffi-gobject/g_object_overrides_test.rb +16 -32
- data/test/ffi-gobject/gobject_test.rb +28 -1
- data/test/ffi-gobject/object_class_test.rb +21 -0
- data/test/ffi-gobject/object_test.rb +4 -0
- data/test/ffi-gobject/ruby_style_test.rb +38 -0
- data/test/ffi-gobject_introspection/i_constant_info_test.rb +5 -5
- data/test/ffi-gobject_introspection/i_repository_test.rb +4 -4
- data/test/ffi-gtk/gtk_test.rb +36 -0
- data/test/gir_ffi_test_helper.rb +8 -4
- data/test/integration/derived_classes_test.rb +34 -18
- data/test/integration/generated_gimarshallingtests_test.rb +20 -23
- data/test/integration/generated_gio_test.rb +5 -0
- data/test/integration/generated_gobject_test.rb +2 -2
- data/test/integration/generated_gtk_test.rb +1 -1
- data/test/integration/generated_pango_test.rb +20 -0
- data/test/integration/generated_regress_test.rb +1003 -955
- data/test/integration/pretty_print_test.rb +3 -1
- data/test/test_helper.rb +5 -0
- data/test/type_builder_test.rb +2 -19
- data/test/unit/arg_helper_test.rb +87 -1
- data/test/unit/builder_test.rb +113 -1
- data/test/unit/function_builder_test.rb +6 -5
- data/test/unit/gir_ffi_test.rb +69 -0
- data/test/unit/in_out_pointer_test.rb +3 -3
- data/test/unit/in_pointer_test.rb +1 -1
- data/test/unit/interface_builder_test.rb +16 -0
- data/test/unit/object_type_builder_test.rb +15 -0
- data/test/unit/struct_builder_test.rb +5 -1
- data/test/{unintrospectable_type_builder_test.rb → unit/unintrospectable_type_builder_test.rb} +18 -1
- data/test/unit/user_defined_object_info_test.rb +18 -0
- data/test/unit/user_defined_property_info_test.rb +14 -0
- data/test/unit/user_defined_registered_type_info_test.rb +10 -0
- data/test/unit/user_defined_type_builder_test.rb +41 -0
- metadata +34 -17
- data/tasks/notes.rake +0 -121
- data/tasks/rdoc.rake +0 -9
- data/tasks/yardoc.rake +0 -9
- data/test/arg_helper_test.rb +0 -33
- data/test/gtk_overrides_test.rb +0 -35
- data/test/interface_type_builder_test.rb +0 -17
@@ -1,1245 +1,1293 @@
|
|
1
1
|
# coding: utf-8
|
2
2
|
require File.expand_path('../gir_ffi_test_helper.rb', File.dirname(__FILE__))
|
3
3
|
|
4
|
+
GirFFI.setup :Regress
|
5
|
+
|
6
|
+
def get_field_value obj, field
|
7
|
+
struct = obj.instance_variable_get :@struct
|
8
|
+
struct[field]
|
9
|
+
end
|
10
|
+
|
4
11
|
# Tests generated methods and functions in the Regress namespace.
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
12
|
+
describe Regress, "The generated Regress module" do
|
13
|
+
it "has the constant DOUBLE_CONSTANT" do
|
14
|
+
assert_equal 44.22, Regress::DOUBLE_CONSTANT
|
15
|
+
end
|
16
|
+
|
17
|
+
it "has the constant INT_CONSTANT" do
|
18
|
+
assert_equal 4422, Regress::INT_CONSTANT
|
19
|
+
end
|
20
|
+
|
21
|
+
it "has the constant Mixed_Case_Constant" do
|
22
|
+
assert_equal 4423, Regress::Mixed_Case_Constant
|
23
|
+
end
|
24
|
+
|
25
|
+
it "has the constant STRING_CONSTANT" do
|
26
|
+
assert_equal "Some String", Regress::STRING_CONSTANT
|
27
|
+
end
|
28
|
+
|
29
|
+
describe Regress::TestBoxed do
|
30
|
+
it "creates an instance using #new" do
|
31
|
+
tb = Regress::TestBoxed.new
|
32
|
+
assert_instance_of Regress::TestBoxed, tb
|
9
33
|
end
|
10
34
|
|
11
|
-
it "
|
12
|
-
|
35
|
+
it "creates an instance using #new_alternative_constructor1" do
|
36
|
+
tb = Regress::TestBoxed.new_alternative_constructor1 1
|
37
|
+
assert_instance_of Regress::TestBoxed, tb
|
38
|
+
assert_equal 1, tb.some_int8
|
13
39
|
end
|
14
40
|
|
15
|
-
it "
|
16
|
-
|
41
|
+
it "creates an instance using #new_alternative_constructor2" do
|
42
|
+
tb = Regress::TestBoxed.new_alternative_constructor2 1, 2
|
43
|
+
assert_instance_of Regress::TestBoxed, tb
|
44
|
+
assert_equal 1 + 2, tb.some_int8
|
17
45
|
end
|
18
46
|
|
19
|
-
it "
|
20
|
-
|
47
|
+
it "creates an instance using #new_alternative_constructor3" do
|
48
|
+
tb = Regress::TestBoxed.new_alternative_constructor3 "54"
|
49
|
+
assert_instance_of Regress::TestBoxed, tb
|
50
|
+
assert_equal 54, tb.some_int8
|
21
51
|
end
|
22
52
|
|
23
|
-
it "has
|
24
|
-
|
53
|
+
it "has non-zero positive result for #get_gtype" do
|
54
|
+
assert Regress::TestBoxed.get_gtype > 0
|
25
55
|
end
|
26
56
|
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
assert_instance_of Regress::TestBoxed, tb
|
57
|
+
describe "an instance" do
|
58
|
+
setup do
|
59
|
+
@tb = Regress::TestBoxed.new_alternative_constructor1 123
|
31
60
|
end
|
32
61
|
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
assert_equal 1, tb.some_int8
|
62
|
+
it "has a working equals method" do
|
63
|
+
tb2 = Regress::TestBoxed.new_alternative_constructor2 120, 3
|
64
|
+
assert_equal true, @tb.equals(tb2)
|
37
65
|
end
|
38
66
|
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
67
|
+
describe "its copy method" do
|
68
|
+
setup do
|
69
|
+
@tb2 = @tb.copy
|
70
|
+
end
|
71
|
+
|
72
|
+
it "returns an instance of TestBoxed" do
|
73
|
+
assert_instance_of Regress::TestBoxed, @tb2
|
74
|
+
end
|
75
|
+
|
76
|
+
it "copies fields" do
|
77
|
+
assert_equal 123, @tb2.some_int8
|
78
|
+
end
|
79
|
+
|
80
|
+
it "creates a true copy" do
|
81
|
+
@tb.some_int8 = 89
|
82
|
+
assert_equal 123, @tb2.some_int8
|
83
|
+
end
|
43
84
|
end
|
85
|
+
end
|
86
|
+
end
|
87
|
+
|
88
|
+
describe "the Regress::TestEnum type" do
|
89
|
+
it "is of type FFI::Enum" do
|
90
|
+
assert_instance_of FFI::Enum, Regress::TestEnum
|
91
|
+
end
|
92
|
+
end
|
44
93
|
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
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]
|
98
|
+
end
|
99
|
+
|
100
|
+
describe Regress::TestFloating do
|
101
|
+
describe "an instance" do
|
102
|
+
setup do
|
103
|
+
@o = Regress::TestFloating.new
|
49
104
|
end
|
50
105
|
|
51
|
-
|
52
|
-
|
106
|
+
it "has a reference count of 1" do
|
107
|
+
assert_equal 1, ref_count(@o)
|
53
108
|
end
|
54
109
|
|
55
|
-
|
56
|
-
|
57
|
-
@tb = Regress::TestBoxed.new_alternative_constructor1 123
|
58
|
-
end
|
59
|
-
|
60
|
-
should "have a working equals method" do
|
61
|
-
tb2 = Regress::TestBoxed.new_alternative_constructor2 120, 3
|
62
|
-
assert_equal true, @tb.equals(tb2)
|
63
|
-
end
|
64
|
-
|
65
|
-
context "its copy method" do
|
66
|
-
setup do
|
67
|
-
@tb2 = @tb.copy
|
68
|
-
end
|
69
|
-
|
70
|
-
should "return an instance of TestBoxed" do
|
71
|
-
assert_instance_of Regress::TestBoxed, @tb2
|
72
|
-
end
|
73
|
-
|
74
|
-
should "copy fields" do
|
75
|
-
assert_equal 123, @tb2.some_int8
|
76
|
-
end
|
77
|
-
|
78
|
-
should "create a true copy" do
|
79
|
-
@tb.some_int8 = 89
|
80
|
-
assert_equal 123, @tb2.some_int8
|
81
|
-
end
|
82
|
-
end
|
110
|
+
it "has been sunk" do
|
111
|
+
assert !is_floating?(@o)
|
83
112
|
end
|
84
113
|
end
|
114
|
+
end
|
85
115
|
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
end
|
116
|
+
describe "TestFundamentalObject" do
|
117
|
+
it "must exist" do
|
118
|
+
Regress::TestFundamentalObject
|
90
119
|
end
|
91
120
|
|
92
|
-
it "
|
93
|
-
|
94
|
-
|
95
|
-
assert_equal 4, Regress::TestFlags[:flag3]
|
121
|
+
it "does not have GObject::Object as an ancestor" do
|
122
|
+
refute_includes Regress::TestFundamentalObject.ancestors,
|
123
|
+
GObject::Object
|
96
124
|
end
|
125
|
+
# TODO: Test more, if possible (e.g., cannot be instantiated).
|
126
|
+
end
|
97
127
|
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
end
|
128
|
+
describe "TestFundamentalSubObject" do
|
129
|
+
before do
|
130
|
+
@so = Regress::TestFundamentalSubObject.new "foo"
|
131
|
+
end
|
103
132
|
|
104
|
-
|
105
|
-
|
106
|
-
|
133
|
+
it "can be instantiated" do
|
134
|
+
pass
|
135
|
+
end
|
107
136
|
|
108
|
-
|
109
|
-
|
110
|
-
end
|
111
|
-
end
|
137
|
+
it "is a subclass of TestFundamentalObject" do
|
138
|
+
assert_kind_of Regress::TestFundamentalObject, @so
|
112
139
|
end
|
113
140
|
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
end
|
141
|
+
it "has a field :data storing the constructor parameter" do
|
142
|
+
assert_equal "foo", @so.data
|
143
|
+
end
|
118
144
|
|
119
|
-
|
120
|
-
|
121
|
-
|
145
|
+
it "can access its parent class' fields directly" do
|
146
|
+
assert_nothing_raised do
|
147
|
+
@so.flags
|
122
148
|
end
|
123
|
-
# TODO: Test more, if possible (e.g., cannot be instantiated).
|
124
149
|
end
|
125
150
|
|
126
|
-
|
127
|
-
|
128
|
-
|
129
|
-
|
151
|
+
it "has a refcount of 1" do
|
152
|
+
# FIXME: Should be able to do @so.refcount
|
153
|
+
assert_equal 1, @so.fundamental_object.refcount
|
154
|
+
end
|
155
|
+
end
|
130
156
|
|
131
|
-
|
132
|
-
|
133
|
-
|
157
|
+
describe "TestInterface" do
|
158
|
+
it "is a module" do
|
159
|
+
assert_instance_of Module, Regress::TestInterface
|
160
|
+
end
|
134
161
|
|
135
|
-
|
136
|
-
|
137
|
-
|
162
|
+
it "extends InterfaceBase" do
|
163
|
+
metaclass = class << Regress::TestInterface; self; end
|
164
|
+
assert_includes metaclass.ancestors, GirFFI::InterfaceBase
|
165
|
+
end
|
138
166
|
|
139
|
-
|
140
|
-
|
141
|
-
|
167
|
+
it "has non-zero positive result for #get_gtype" do
|
168
|
+
Regress::TestInterface.get_gtype.must_be :>, 0
|
169
|
+
end
|
170
|
+
end
|
142
171
|
|
143
|
-
|
144
|
-
|
145
|
-
|
172
|
+
describe Regress::TestObj do
|
173
|
+
it "creates an instance using #new_from_file" do
|
174
|
+
o = Regress::TestObj.new_from_file("foo")
|
175
|
+
assert_instance_of Regress::TestObj, o
|
146
176
|
end
|
147
177
|
|
148
|
-
|
149
|
-
|
150
|
-
|
151
|
-
|
178
|
+
it "creates an instance using #new_callback" do
|
179
|
+
a = 1
|
180
|
+
o = Regress::TestObj.new_callback Proc.new { a = 2 }, nil, nil
|
181
|
+
assert_instance_of Regress::TestObj, o
|
182
|
+
a.must_equal 2
|
183
|
+
end
|
152
184
|
|
153
|
-
|
154
|
-
|
155
|
-
|
156
|
-
end
|
185
|
+
it "has a working #static_method" do
|
186
|
+
rv = Regress::TestObj.static_method 623
|
187
|
+
assert_equal 623.0, rv
|
157
188
|
end
|
158
189
|
|
159
|
-
|
160
|
-
|
161
|
-
|
162
|
-
|
190
|
+
describe "#static_method_callback" do
|
191
|
+
it "works when called with a Proc" do
|
192
|
+
a = 1
|
193
|
+
Regress::TestObj.static_method_callback Proc.new { a = 2 }
|
194
|
+
assert_equal 2, a
|
163
195
|
end
|
164
196
|
|
165
|
-
|
166
|
-
|
167
|
-
|
168
|
-
|
197
|
+
it "works when called with nil" do
|
198
|
+
assert_nothing_raised do
|
199
|
+
Regress::TestObj.static_method_callback nil
|
200
|
+
end
|
169
201
|
end
|
202
|
+
end
|
170
203
|
|
171
|
-
|
172
|
-
|
173
|
-
|
204
|
+
describe "an instance" do
|
205
|
+
setup do
|
206
|
+
@o = Regress::TestObj.new_from_file("foo")
|
174
207
|
end
|
175
208
|
|
176
|
-
|
177
|
-
|
178
|
-
|
179
|
-
|
180
|
-
assert_equal
|
209
|
+
describe "its gtype" do
|
210
|
+
it "can be found through get_gtype and GObject.type_from_instance" do
|
211
|
+
gtype = Regress::TestObj.get_gtype
|
212
|
+
r = GObject.type_from_instance @o
|
213
|
+
assert_equal gtype, r
|
181
214
|
end
|
215
|
+
end
|
182
216
|
|
183
|
-
|
184
|
-
|
185
|
-
|
186
|
-
|
217
|
+
describe "#get_property" do
|
218
|
+
it "gets the 'bare' property" do
|
219
|
+
obj = Regress::TestObj.new_from_file("bar")
|
220
|
+
@o.set_bare obj
|
221
|
+
|
222
|
+
obj2 = @o.get_property("bare")
|
223
|
+
|
224
|
+
assert_equal obj.to_ptr, obj2.to_ptr
|
225
|
+
assert_instance_of Regress::TestObj, obj2
|
187
226
|
end
|
188
|
-
end
|
189
227
|
|
190
|
-
|
191
|
-
|
192
|
-
|
193
|
-
end
|
228
|
+
it "gets the 'boxed' property" do
|
229
|
+
tb = Regress::TestBoxed.new_alternative_constructor1 75
|
230
|
+
@o.set_property "boxed", tb
|
194
231
|
|
195
|
-
|
196
|
-
|
197
|
-
|
198
|
-
|
199
|
-
assert_equal gtype, r
|
200
|
-
end
|
232
|
+
tb2 = @o.get_property("boxed")
|
233
|
+
|
234
|
+
assert_instance_of Regress::TestBoxed, tb2
|
235
|
+
assert_equal 75, tb2.some_int8
|
201
236
|
end
|
202
237
|
|
203
|
-
|
204
|
-
|
205
|
-
|
206
|
-
|
238
|
+
it "gets the 'hash-table' property" do
|
239
|
+
ht = GLib::HashTable.new :utf8, :gint8
|
240
|
+
ht.insert "foo", 34
|
241
|
+
ht.insert "bar", 83
|
207
242
|
|
208
|
-
|
243
|
+
@o.set_property "hash-table", ht
|
209
244
|
|
210
|
-
|
211
|
-
|
212
|
-
|
245
|
+
ht2 = @o.get_property "hash-table"
|
246
|
+
assert_equal({"foo" => 34, "bar" => 83}, ht2.to_hash)
|
247
|
+
end
|
213
248
|
|
214
|
-
|
215
|
-
|
216
|
-
|
249
|
+
it "gets the 'float' property" do
|
250
|
+
@o.set_property "float", 3.14
|
251
|
+
assert_in_epsilon 3.14, @o.get_property("float")
|
252
|
+
end
|
217
253
|
|
218
|
-
|
254
|
+
it "gets the 'double' property" do
|
255
|
+
@o.set_property "double", 3.14
|
256
|
+
assert_in_epsilon 3.14, @o.get_property("double")
|
257
|
+
end
|
219
258
|
|
220
|
-
|
221
|
-
|
222
|
-
|
259
|
+
it "gets the 'int' property" do
|
260
|
+
@o.set_property "int", 42
|
261
|
+
assert_equal 42, @o.get_property("int")
|
262
|
+
end
|
223
263
|
|
224
|
-
|
225
|
-
|
226
|
-
ht.insert "foo", 34
|
227
|
-
ht.insert "bar", 83
|
264
|
+
it "gets the 'list' property" do
|
265
|
+
lst = GLib::List.new(:utf8).append("foo").append("bar")
|
228
266
|
|
229
|
-
|
267
|
+
@o.set_property "list", lst
|
230
268
|
|
231
|
-
|
232
|
-
|
233
|
-
|
269
|
+
lst2 = @o.get_property "list"
|
270
|
+
assert_equal ["foo", "bar"], lst2.to_a
|
271
|
+
end
|
234
272
|
|
235
|
-
|
236
|
-
|
237
|
-
|
238
|
-
|
273
|
+
it "gets the 'string' property" do
|
274
|
+
@o.set_property "string", "foobar"
|
275
|
+
assert_equal "foobar", @o.get_property("string")
|
276
|
+
end
|
277
|
+
end
|
239
278
|
|
240
|
-
|
241
|
-
|
242
|
-
|
243
|
-
|
279
|
+
describe "#set_property" do
|
280
|
+
it "sets the 'bare' property" do
|
281
|
+
obj = Regress::TestObj.new_from_file("bar")
|
282
|
+
@o.set_property "bare", obj
|
283
|
+
assert_equal obj.to_ptr, @o.bare.to_ptr
|
284
|
+
end
|
244
285
|
|
245
|
-
|
246
|
-
|
247
|
-
|
248
|
-
|
286
|
+
it "sets the 'boxed' property" do
|
287
|
+
tb = Regress::TestBoxed.new_alternative_constructor1 75
|
288
|
+
@o.set_property "boxed", tb
|
289
|
+
tb2 = @o.boxed
|
290
|
+
assert_equal 75, tb2.some_int8
|
291
|
+
end
|
249
292
|
|
250
|
-
|
251
|
-
|
293
|
+
it "sets the 'hash-table' property" do
|
294
|
+
@o.set_property("hash-table", {"foo" => 34, "bar" => 83})
|
252
295
|
|
253
|
-
|
296
|
+
ht = @o.hash_table
|
297
|
+
ht.key_type = :utf8
|
298
|
+
ht.value_type = :gint32
|
254
299
|
|
255
|
-
|
256
|
-
|
257
|
-
end
|
300
|
+
assert_equal({"foo" => 34, "bar" => 83}, ht.to_hash)
|
301
|
+
end
|
258
302
|
|
259
|
-
|
260
|
-
|
261
|
-
|
262
|
-
end
|
303
|
+
it "sets the 'float' property" do
|
304
|
+
@o.set_property "float", 3.14
|
305
|
+
assert_in_epsilon 3.14, get_field_value(@o, :some_float)
|
263
306
|
end
|
264
307
|
|
265
|
-
|
266
|
-
|
267
|
-
|
268
|
-
|
269
|
-
assert_equal obj.to_ptr, @o.bare.to_ptr
|
270
|
-
end
|
308
|
+
it "sets the 'double' property" do
|
309
|
+
@o.set_property "double", 3.14
|
310
|
+
assert_in_epsilon 3.14, get_field_value(@o, :some_double)
|
311
|
+
end
|
271
312
|
|
272
|
-
|
273
|
-
|
274
|
-
|
275
|
-
|
276
|
-
assert_equal 75, tb2.some_int8
|
277
|
-
end
|
313
|
+
it "sets the 'int' property" do
|
314
|
+
@o.set_property "int", 42
|
315
|
+
assert_equal 42, get_field_value(@o, :some_int8)
|
316
|
+
end
|
278
317
|
|
279
|
-
|
280
|
-
|
318
|
+
it "sets the 'list' property" do
|
319
|
+
@o.set_property "list", ["foo", "bar"]
|
320
|
+
assert_equal ["foo", "bar"],
|
321
|
+
GLib::List.wrap(:utf8, @o.list.to_ptr).to_a
|
322
|
+
end
|
281
323
|
|
282
|
-
|
283
|
-
|
284
|
-
|
324
|
+
it "sets the 'string' property" do
|
325
|
+
@o.set_property "string", "foobar"
|
326
|
+
assert_equal "foobar", @o.string
|
327
|
+
end
|
328
|
+
end
|
285
329
|
|
286
|
-
|
287
|
-
|
330
|
+
describe "its 'int' property" do
|
331
|
+
it "is set with #int=" do
|
332
|
+
@o.int = 41
|
333
|
+
assert_equal 41, @o.get_property("int")
|
334
|
+
end
|
288
335
|
|
289
|
-
|
290
|
-
|
291
|
-
|
292
|
-
|
336
|
+
it "is retrieved with #int" do
|
337
|
+
@o.set_property "int", 43
|
338
|
+
assert_equal 43, @o.int
|
339
|
+
end
|
340
|
+
end
|
293
341
|
|
294
|
-
|
295
|
-
|
296
|
-
|
297
|
-
end
|
342
|
+
it "has a reference count of 1" do
|
343
|
+
assert_equal 1, ref_count(@o)
|
344
|
+
end
|
298
345
|
|
299
|
-
|
300
|
-
|
301
|
-
|
302
|
-
end
|
346
|
+
it "does not float" do
|
347
|
+
assert !is_floating?(@o)
|
348
|
+
end
|
303
349
|
|
304
|
-
|
305
|
-
|
306
|
-
|
307
|
-
|
308
|
-
end
|
350
|
+
it "has a working (virtual) #matrix method" do
|
351
|
+
rv = @o.matrix "bar"
|
352
|
+
assert_equal 42, rv
|
353
|
+
end
|
309
354
|
|
310
|
-
|
311
|
-
|
312
|
-
|
313
|
-
|
314
|
-
|
355
|
+
it "has a working #set_bare method" do
|
356
|
+
obj = Regress::TestObj.new_from_file("bar")
|
357
|
+
@o.set_bare obj
|
358
|
+
# TODO: What is the correct value to retrieve from the fields?
|
359
|
+
assert_equal obj.to_ptr, @o.bare.to_ptr
|
360
|
+
end
|
315
361
|
|
316
|
-
|
317
|
-
|
318
|
-
|
319
|
-
|
320
|
-
should "not float" do
|
321
|
-
assert !is_floating?(@o)
|
322
|
-
end
|
323
|
-
|
324
|
-
should "have a working (virtual) #matrix method" do
|
325
|
-
rv = @o.matrix "bar"
|
326
|
-
assert_equal 42, rv
|
327
|
-
end
|
328
|
-
|
329
|
-
should "have a working #set_bare method" do
|
330
|
-
obj = Regress::TestObj.new_from_file("bar")
|
331
|
-
@o.set_bare obj
|
332
|
-
# TODO: What is the correct value to retrieve from the fields?
|
333
|
-
assert_equal obj.to_ptr, @o.bare.to_ptr
|
334
|
-
end
|
335
|
-
|
336
|
-
should "have a working #instance_method method" do
|
337
|
-
rv = @o.instance_method
|
338
|
-
assert_equal(-1, rv)
|
339
|
-
end
|
340
|
-
|
341
|
-
should "have a working #torture_signature_0 method" do
|
342
|
-
y, z, q = @o.torture_signature_0(-21, "hello", 13)
|
343
|
-
assert_equal [-21, 2 * -21, "hello".length + 13],
|
344
|
-
[y, z, q]
|
345
|
-
end
|
346
|
-
|
347
|
-
context "its #torture_signature_1 method" do
|
348
|
-
should "work for m even" do
|
349
|
-
ret, y, z, q = @o.torture_signature_1(-21, "hello", 12)
|
350
|
-
assert_equal [true, -21, 2 * -21, "hello".length + 12],
|
351
|
-
[ret, y, z, q]
|
352
|
-
end
|
353
|
-
|
354
|
-
should "throw an exception for m odd" do
|
355
|
-
assert_raises RuntimeError do
|
356
|
-
@o.torture_signature_1(-21, "hello", 11)
|
357
|
-
end
|
358
|
-
end
|
359
|
-
end
|
360
|
-
|
361
|
-
should "have a working #instance_method_callback method" do
|
362
|
-
a = 1
|
363
|
-
@o.instance_method_callback Proc.new { a = 2 }
|
364
|
-
assert_equal 2, a
|
365
|
-
end
|
366
|
-
|
367
|
-
should "not respond to #static_method" do
|
368
|
-
assert_raises(NoMethodError) { @o.static_method 1 }
|
369
|
-
end
|
370
|
-
# TODO: Test instance's fields and properies.
|
362
|
+
it "has a working #instance_method method" do
|
363
|
+
rv = @o.instance_method
|
364
|
+
assert_equal(-1, rv)
|
371
365
|
end
|
372
366
|
|
373
|
-
|
374
|
-
|
375
|
-
|
376
|
-
|
377
|
-
GObject.signal_connect(o, "test", 2) { |i, d| a = d; b = i }
|
378
|
-
GObject.signal_emit o, "test"
|
379
|
-
# TODO: store o's identity somewhere so we can make o == b.
|
380
|
-
assert_equal [2, o.to_ptr], [a, b.to_ptr]
|
381
|
-
end
|
367
|
+
it "has a working #torture_signature_0 method" do
|
368
|
+
y, z, q = @o.torture_signature_0(-21, "hello", 13)
|
369
|
+
assert_equal [-21, 2 * -21, "hello".length + 13],
|
370
|
+
[y, z, q]
|
382
371
|
end
|
383
372
|
|
384
|
-
|
385
|
-
|
373
|
+
describe "its #torture_signature_1 method" do
|
374
|
+
it "works for m even" do
|
375
|
+
ret, y, z, q = @o.torture_signature_1(-21, "hello", 12)
|
376
|
+
assert_equal [true, -21, 2 * -21, "hello".length + 12],
|
377
|
+
[ret, y, z, q]
|
378
|
+
end
|
386
379
|
|
387
|
-
|
388
|
-
|
389
|
-
|
390
|
-
|
380
|
+
it "throws an exception for m odd" do
|
381
|
+
assert_raises RuntimeError do
|
382
|
+
@o.torture_signature_1(-21, "hello", 11)
|
383
|
+
end
|
384
|
+
end
|
391
385
|
end
|
392
386
|
|
393
|
-
|
394
|
-
|
395
|
-
|
396
|
-
|
397
|
-
@obj.some_int8 = 36
|
398
|
-
@obj.some_double = 23.53
|
399
|
-
@obj.some_enum = :value2
|
400
|
-
end
|
401
|
-
|
402
|
-
context "its equals method" do
|
403
|
-
setup do
|
404
|
-
@ob2 = Regress::TestSimpleBoxedA.new
|
405
|
-
@ob2.some_int = 4236
|
406
|
-
@ob2.some_int8 = 36
|
407
|
-
@ob2.some_double = 23.53
|
408
|
-
@ob2.some_enum = :value2
|
409
|
-
end
|
410
|
-
|
411
|
-
should "return true if values are the same" do
|
412
|
-
assert_equal true, @obj.equals(@ob2)
|
413
|
-
end
|
414
|
-
|
415
|
-
should "return true if enum values differ" do
|
416
|
-
@ob2.some_enum = :value3
|
417
|
-
assert_equal true, @obj.equals(@ob2)
|
418
|
-
end
|
419
|
-
|
420
|
-
should "return false if other values differ" do
|
421
|
-
@ob2.some_int = 1
|
422
|
-
assert_equal false, @obj.equals(@ob2)
|
423
|
-
end
|
424
|
-
end
|
425
|
-
|
426
|
-
context "its copy method" do
|
427
|
-
setup do
|
428
|
-
@ob2 = @obj.copy
|
429
|
-
end
|
430
|
-
|
431
|
-
should "return an instance of TestSimpleBoxedA" do
|
432
|
-
assert_instance_of Regress::TestSimpleBoxedA, @ob2
|
433
|
-
end
|
434
|
-
|
435
|
-
should "copy fields" do
|
436
|
-
assert_equal 4236, @ob2.some_int
|
437
|
-
assert_equal 36, @ob2.some_int8
|
438
|
-
assert_equal 23.53, @ob2.some_double
|
439
|
-
assert_equal :value2, @ob2.some_enum
|
440
|
-
end
|
441
|
-
|
442
|
-
should "create a true copy" do
|
443
|
-
@obj.some_int8 = 89
|
444
|
-
assert_equal 36, @ob2.some_int8
|
445
|
-
end
|
446
|
-
end
|
387
|
+
it "has a working #instance_method_callback method" do
|
388
|
+
a = 1
|
389
|
+
@o.instance_method_callback Proc.new { a = 2 }
|
390
|
+
assert_equal 2, a
|
447
391
|
end
|
448
|
-
end
|
449
392
|
|
450
|
-
|
451
|
-
|
452
|
-
should "have a working clone method" do
|
453
|
-
a = Regress::TestStructA.new
|
454
|
-
a.some_int = 2556
|
455
|
-
a.some_int8 = -10
|
456
|
-
a.some_double = 1.03455e20
|
457
|
-
a.some_enum = :value2
|
458
|
-
|
459
|
-
b = a.clone
|
460
|
-
|
461
|
-
assert_equal 2556, b.some_int
|
462
|
-
assert_equal(-10, b.some_int8)
|
463
|
-
assert_equal 1.03455e20, b.some_double
|
464
|
-
assert_equal :value2, b.some_enum
|
465
|
-
end
|
393
|
+
it "does not respond to #static_method" do
|
394
|
+
assert_raises(NoMethodError) { @o.static_method 1 }
|
466
395
|
end
|
396
|
+
# TODO: Test instance's fields and properies.
|
467
397
|
end
|
468
398
|
|
469
|
-
describe "
|
470
|
-
|
471
|
-
|
472
|
-
|
473
|
-
|
474
|
-
|
475
|
-
|
476
|
-
|
477
|
-
a.nested_a.some_enum = :value2
|
478
|
-
|
479
|
-
b = a.clone
|
480
|
-
|
481
|
-
assert_equal 42, b.some_int8
|
482
|
-
assert_equal 2556, b.nested_a.some_int
|
483
|
-
assert_equal(-10, b.nested_a.some_int8)
|
484
|
-
assert_equal 1.03455e20, b.nested_a.some_double
|
485
|
-
assert_equal :value2, b.nested_a.some_enum
|
486
|
-
end
|
399
|
+
describe "its 'test' signal" do
|
400
|
+
it "properly passes its arguments" do
|
401
|
+
a = b = nil
|
402
|
+
o = Regress::TestSubObj.new
|
403
|
+
GObject.signal_connect(o, "test", 2) { |i, d| a = d; b = i }
|
404
|
+
GObject.signal_emit o, "test"
|
405
|
+
# TODO: store o's identity somewhere so we can make o == b.
|
406
|
+
assert_equal [2, o.to_ptr], [a, b.to_ptr]
|
487
407
|
end
|
488
408
|
end
|
489
409
|
|
490
|
-
|
491
|
-
|
410
|
+
# TODO: Test other signals.
|
411
|
+
end
|
412
|
+
|
413
|
+
describe Regress::TestSimpleBoxedA do
|
414
|
+
it "creates an instance using #new" do
|
415
|
+
obj = Regress::TestSimpleBoxedA.new
|
416
|
+
assert_instance_of Regress::TestSimpleBoxedA, obj
|
492
417
|
end
|
493
418
|
|
494
|
-
describe "
|
495
|
-
|
496
|
-
|
497
|
-
|
419
|
+
describe "an instance" do
|
420
|
+
setup do
|
421
|
+
@obj = Regress::TestSimpleBoxedA.new
|
422
|
+
@obj.some_int = 4236
|
423
|
+
@obj.some_int8 = 36
|
424
|
+
@obj.some_double = 23.53
|
425
|
+
@obj.some_enum = :value2
|
498
426
|
end
|
499
427
|
|
500
|
-
describe "
|
501
|
-
|
502
|
-
@
|
428
|
+
describe "its equals method" do
|
429
|
+
setup do
|
430
|
+
@ob2 = Regress::TestSimpleBoxedA.new
|
431
|
+
@ob2.some_int = 4236
|
432
|
+
@ob2.some_int8 = 36
|
433
|
+
@ob2.some_double = 23.53
|
434
|
+
@ob2.some_enum = :value2
|
503
435
|
end
|
504
436
|
|
505
|
-
it "
|
506
|
-
|
507
|
-
assert_equal 0, res
|
437
|
+
it "returns true if values are the same" do
|
438
|
+
assert_equal true, @obj.equals(@ob2)
|
508
439
|
end
|
509
440
|
|
510
|
-
it "
|
511
|
-
@
|
512
|
-
|
441
|
+
it "returns true if enum values differ" do
|
442
|
+
@ob2.some_enum = :value3
|
443
|
+
assert_equal true, @obj.equals(@ob2)
|
513
444
|
end
|
514
445
|
|
515
|
-
it "
|
516
|
-
|
446
|
+
it "returns false if other values differ" do
|
447
|
+
@ob2.some_int = 1
|
448
|
+
assert_equal false, @obj.equals(@ob2)
|
517
449
|
end
|
518
450
|
end
|
519
|
-
end
|
520
451
|
|
521
|
-
|
522
|
-
|
523
|
-
|
524
|
-
|
525
|
-
|
452
|
+
describe "its copy method" do
|
453
|
+
setup do
|
454
|
+
@ob2 = @obj.copy
|
455
|
+
end
|
456
|
+
|
457
|
+
it "returns an instance of TestSimpleBoxedA" do
|
458
|
+
assert_instance_of Regress::TestSimpleBoxedA, @ob2
|
459
|
+
end
|
460
|
+
|
461
|
+
it "copies fields" do
|
462
|
+
assert_equal 4236, @ob2.some_int
|
463
|
+
assert_equal 36, @ob2.some_int8
|
464
|
+
assert_equal 23.53, @ob2.some_double
|
465
|
+
assert_equal :value2, @ob2.some_enum
|
466
|
+
end
|
526
467
|
|
527
|
-
|
528
|
-
|
468
|
+
it "creates a true copy" do
|
469
|
+
@obj.some_int8 = 89
|
470
|
+
assert_equal 36, @ob2.some_int8
|
471
|
+
end
|
529
472
|
end
|
473
|
+
end
|
474
|
+
end
|
530
475
|
|
531
|
-
|
532
|
-
|
533
|
-
|
534
|
-
|
535
|
-
|
536
|
-
|
537
|
-
|
538
|
-
|
539
|
-
|
540
|
-
|
541
|
-
|
542
|
-
|
543
|
-
|
544
|
-
|
545
|
-
|
546
|
-
@obj.set_testbool true
|
547
|
-
assert_equal true, @obj.get_testbool
|
548
|
-
end
|
549
|
-
|
550
|
-
it "gets its boolean field with #get_property" do
|
551
|
-
@obj.set_testbool true
|
552
|
-
val = @obj.get_property "testbool"
|
553
|
-
assert_equal true, val
|
554
|
-
end
|
476
|
+
describe Regress::TestStructA do
|
477
|
+
describe "an instance" do
|
478
|
+
it "has a working clone method" do
|
479
|
+
a = Regress::TestStructA.new
|
480
|
+
a.some_int = 2556
|
481
|
+
a.some_int8 = -10
|
482
|
+
a.some_double = 1.03455e20
|
483
|
+
a.some_enum = :value2
|
484
|
+
|
485
|
+
b = a.clone
|
486
|
+
|
487
|
+
assert_equal 2556, b.some_int
|
488
|
+
assert_equal(-10, b.some_int8)
|
489
|
+
assert_equal 1.03455e20, b.some_double
|
490
|
+
assert_equal :value2, b.some_enum
|
555
491
|
end
|
556
492
|
end
|
493
|
+
end
|
557
494
|
|
558
|
-
|
559
|
-
|
495
|
+
describe Regress::TestStructB do
|
496
|
+
describe "an instance" do
|
497
|
+
it "has a working method #clone" do
|
498
|
+
a = Regress::TestStructB.new
|
499
|
+
a.some_int8 = 42
|
500
|
+
a.nested_a.some_int = 2556
|
501
|
+
a.nested_a.some_int8 = -10
|
502
|
+
a.nested_a.some_double = 1.03455e20
|
503
|
+
a.nested_a.some_enum = :value2
|
504
|
+
|
505
|
+
b = a.clone
|
506
|
+
|
507
|
+
assert_equal 42, b.some_int8
|
508
|
+
assert_equal 2556, b.nested_a.some_int
|
509
|
+
assert_equal(-10, b.nested_a.some_int8)
|
510
|
+
assert_equal 1.03455e20, b.nested_a.some_double
|
511
|
+
assert_equal :value2, b.nested_a.some_enum
|
512
|
+
end
|
560
513
|
end
|
514
|
+
end
|
561
515
|
|
562
|
-
|
563
|
-
|
564
|
-
|
516
|
+
# TODO: Test the following classes.
|
517
|
+
# Regress::TestStructC
|
518
|
+
# Regress::TestStructD
|
519
|
+
# Regress::TestStructE
|
520
|
+
# Regress::TestStructFixedArray
|
521
|
+
|
522
|
+
describe Regress::TestSubObj do
|
523
|
+
it "is created with #new" do
|
524
|
+
tso = Regress::TestSubObj.new
|
525
|
+
assert_instance_of Regress::TestSubObj, tso
|
565
526
|
end
|
566
527
|
|
567
|
-
describe "
|
528
|
+
describe "an instance" do
|
568
529
|
before do
|
569
|
-
@
|
530
|
+
@tso = Regress::TestSubObj.new
|
570
531
|
end
|
571
532
|
|
572
|
-
it "
|
573
|
-
|
533
|
+
it "has a working method #instance_method" do
|
534
|
+
res = @tso.instance_method
|
535
|
+
assert_equal 0, res
|
574
536
|
end
|
575
537
|
|
576
|
-
it "
|
577
|
-
@
|
578
|
-
|
579
|
-
}
|
538
|
+
it "has a working method #unset_bare" do
|
539
|
+
@tso.unset_bare
|
540
|
+
pass
|
580
541
|
end
|
581
542
|
|
582
|
-
it "
|
583
|
-
|
584
|
-
@result.each {|o|
|
585
|
-
assert_equal gtype, GObject.type_from_instance(o)
|
586
|
-
}
|
543
|
+
it "does not have a field parent_instance" do
|
544
|
+
assert_raises(NoMethodError) { @tso.parent_instance }
|
587
545
|
end
|
588
546
|
end
|
547
|
+
end
|
589
548
|
|
590
|
-
|
591
|
-
|
592
|
-
|
549
|
+
describe Regress::TestWi8021x do
|
550
|
+
it "creates an instance using #new" do
|
551
|
+
o = Regress::TestWi8021x.new
|
552
|
+
assert_instance_of Regress::TestWi8021x, o
|
553
|
+
end
|
554
|
+
|
555
|
+
it "has a working #static_method" do
|
556
|
+
assert_equal(-84, Regress::TestWi8021x.static_method(-42))
|
557
|
+
end
|
558
|
+
|
559
|
+
describe "an instance" do
|
560
|
+
setup do
|
561
|
+
@obj = Regress::TestWi8021x.new
|
593
562
|
end
|
594
563
|
|
595
|
-
|
596
|
-
|
597
|
-
|
598
|
-
|
564
|
+
it "sets its boolean field with #set_testbool" do
|
565
|
+
@obj.set_testbool true
|
566
|
+
assert_equal 1, get_field_value(@obj, :testbool)
|
567
|
+
@obj.set_testbool false
|
568
|
+
assert_equal 0, get_field_value(@obj, :testbool)
|
599
569
|
end
|
600
|
-
end
|
601
570
|
|
602
|
-
|
603
|
-
|
604
|
-
|
571
|
+
it "gets its boolean field with #get_testbool" do
|
572
|
+
@obj.set_testbool false
|
573
|
+
assert_equal false, @obj.get_testbool
|
574
|
+
@obj.set_testbool true
|
575
|
+
assert_equal true, @obj.get_testbool
|
576
|
+
end
|
605
577
|
|
606
|
-
|
607
|
-
|
608
|
-
|
578
|
+
it "gets its boolean field with #get_property" do
|
579
|
+
@obj.set_testbool true
|
580
|
+
val = @obj.get_property "testbool"
|
581
|
+
assert_equal true, val
|
582
|
+
end
|
609
583
|
|
610
|
-
|
611
|
-
|
612
|
-
|
584
|
+
it "gets its boolean field with #testbool" do
|
585
|
+
@obj.set_testbool true
|
586
|
+
assert_equal true, @obj.testbool
|
587
|
+
@obj.set_testbool false
|
588
|
+
assert_equal false, @obj.testbool
|
589
|
+
end
|
613
590
|
|
614
|
-
|
615
|
-
|
591
|
+
it "sets its boolean field with #testbool=" do
|
592
|
+
@obj.testbool = true
|
593
|
+
assert_equal true, @obj.testbool
|
594
|
+
@obj.testbool = false
|
595
|
+
assert_equal false, @obj.testbool
|
596
|
+
end
|
616
597
|
end
|
598
|
+
end
|
617
599
|
|
618
|
-
|
619
|
-
|
620
|
-
|
600
|
+
it "has the constant UTF8_CONSTANT" do
|
601
|
+
assert_equal "const ♥ utf8", Regress::UTF8_CONSTANT
|
602
|
+
end
|
621
603
|
|
622
|
-
|
623
|
-
|
624
|
-
|
604
|
+
it "has the function #set_abort_on_error" do
|
605
|
+
Regress.set_abort_on_error false
|
606
|
+
Regress.set_abort_on_error true
|
607
|
+
end
|
625
608
|
|
626
|
-
|
627
|
-
|
628
|
-
|
629
|
-
|
609
|
+
describe "#test_array_fixed_out_objects" do
|
610
|
+
before do
|
611
|
+
begin
|
612
|
+
@result = Regress.test_array_fixed_out_objects
|
613
|
+
rescue NoMethodError
|
614
|
+
skip
|
615
|
+
end
|
630
616
|
end
|
631
617
|
|
632
|
-
|
633
|
-
assert_equal
|
618
|
+
it "returns an array of two items" do
|
619
|
+
assert_equal 2, @result.length
|
634
620
|
end
|
635
621
|
|
636
|
-
|
637
|
-
|
622
|
+
it "returns an array TestObj objects" do
|
623
|
+
@result.each {|o|
|
624
|
+
assert_instance_of Regress::TestObj, o
|
625
|
+
}
|
638
626
|
end
|
639
627
|
|
640
|
-
|
641
|
-
|
628
|
+
it "returns objects with the correct GType" do
|
629
|
+
gtype = Regress::TestObj.get_gtype
|
630
|
+
@result.each {|o|
|
631
|
+
assert_equal gtype, GObject.type_from_instance(o)
|
632
|
+
}
|
642
633
|
end
|
634
|
+
end
|
643
635
|
|
644
|
-
|
645
|
-
|
636
|
+
describe "#test_array_fixed_size_int_in" do
|
637
|
+
it "returns the correct result" do
|
638
|
+
assert_equal 5 + 4 + 3 + 2 + 1, Regress.test_array_fixed_size_int_in([5, 4, 3, 2, 1])
|
646
639
|
end
|
647
640
|
|
648
|
-
|
649
|
-
|
641
|
+
it "raises an error when called with the wrong number of arguments" do
|
642
|
+
assert_raises ArgumentError do
|
643
|
+
Regress.test_array_fixed_size_int_in [2]
|
644
|
+
end
|
650
645
|
end
|
646
|
+
end
|
651
647
|
|
652
|
-
|
653
|
-
|
654
|
-
|
648
|
+
it "has correct test_array_fixed_size_int_out" do
|
649
|
+
assert_equal [0, 1, 2, 3, 4], Regress.test_array_fixed_size_int_out
|
650
|
+
end
|
655
651
|
|
656
|
-
|
657
|
-
|
658
|
-
|
652
|
+
it "has correct test_array_fixed_size_int_return" do
|
653
|
+
assert_equal [0, 1, 2, 3, 4], Regress.test_array_fixed_size_int_return
|
654
|
+
end
|
659
655
|
|
660
|
-
|
661
|
-
|
662
|
-
|
656
|
+
it "has correct test_array_gint16_in" do
|
657
|
+
assert_equal 5 + 4 + 3, Regress.test_array_gint16_in([5, 4, 3])
|
658
|
+
end
|
663
659
|
|
664
|
-
|
665
|
-
|
666
|
-
|
667
|
-
}
|
660
|
+
it "has correct test_array_gint32_in" do
|
661
|
+
assert_equal 5 + 4 + 3, Regress.test_array_gint32_in([5, 4, 3])
|
662
|
+
end
|
668
663
|
|
669
|
-
|
664
|
+
it "has correct test_array_gint64_in" do
|
665
|
+
assert_equal 5 + 4 + 3, Regress.test_array_gint64_in([5, 4, 3])
|
666
|
+
end
|
670
667
|
|
671
|
-
|
672
|
-
|
668
|
+
it "has correct test_array_gint8_in" do
|
669
|
+
assert_equal 5 + 4 + 3, Regress.test_array_gint8_in([5, 4, 3])
|
670
|
+
end
|
673
671
|
|
674
|
-
|
675
|
-
|
676
|
-
|
677
|
-
|
672
|
+
it "has correct test_array_gtype_in" do
|
673
|
+
t1 = GObject.type_from_name "gboolean"
|
674
|
+
t2 = GObject.type_from_name "gint64"
|
675
|
+
assert_equal "[gboolean,gint64,]", Regress.test_array_gtype_in([t1, t2])
|
676
|
+
end
|
678
677
|
|
679
|
-
|
680
|
-
|
681
|
-
|
678
|
+
it "has correct test_array_int_full_out" do
|
679
|
+
assert_equal [0, 1, 2, 3, 4], Regress.test_array_int_full_out
|
680
|
+
end
|
682
681
|
|
683
|
-
|
684
|
-
|
685
|
-
|
682
|
+
it "has correct test_array_int_in" do
|
683
|
+
assert_equal 5 + 4 + 3, Regress.test_array_int_in([5, 4, 3])
|
684
|
+
end
|
686
685
|
|
687
|
-
|
688
|
-
|
689
|
-
|
690
|
-
end
|
686
|
+
it "has correct test_array_int_inout" do
|
687
|
+
assert_equal [3, 4], Regress.test_array_int_inout([5, 2, 3])
|
688
|
+
end
|
691
689
|
|
692
|
-
|
693
|
-
|
694
|
-
|
695
|
-
end
|
690
|
+
it "has correct test_array_int_none_out" do
|
691
|
+
assert_equal [1, 2, 3, 4, 5], Regress.test_array_int_none_out
|
692
|
+
end
|
696
693
|
|
697
|
-
|
698
|
-
|
699
|
-
|
700
|
-
end
|
694
|
+
it "has correct test_array_int_null_in" do
|
695
|
+
assert_nothing_raised { Regress.test_array_int_null_in nil }
|
696
|
+
end
|
701
697
|
|
702
|
-
|
703
|
-
|
704
|
-
|
705
|
-
end
|
698
|
+
it "has correct test_array_int_null_out" do
|
699
|
+
assert_equal nil, Regress.test_array_int_null_out
|
700
|
+
end
|
706
701
|
|
707
|
-
|
708
|
-
|
709
|
-
|
710
|
-
end
|
702
|
+
it "has correct test_array_int_out" do
|
703
|
+
assert_equal [0, 1, 2, 3, 4], Regress.test_array_int_out
|
704
|
+
end
|
711
705
|
|
712
|
-
|
713
|
-
|
714
|
-
|
715
|
-
end
|
706
|
+
it "has correct test_async_ready_callback" do
|
707
|
+
# FIXME: Use GLib::MainLoop.new eventually.
|
708
|
+
main_loop = GLib.main_loop_new nil, false
|
716
709
|
|
717
|
-
|
718
|
-
|
719
|
-
|
720
|
-
|
710
|
+
a = 1
|
711
|
+
Regress.test_async_ready_callback Proc.new {
|
712
|
+
main_loop.quit
|
713
|
+
a = 2
|
714
|
+
}
|
721
715
|
|
722
|
-
|
723
|
-
a = 1
|
724
|
-
Regress.test_callback_async Proc.new {|b|
|
725
|
-
a = 2
|
726
|
-
b
|
727
|
-
}, 44
|
728
|
-
r = Regress.test_callback_thaw_async
|
729
|
-
assert_equal 44, r
|
730
|
-
assert_equal 2, a
|
731
|
-
end
|
716
|
+
main_loop.run
|
732
717
|
|
733
|
-
|
734
|
-
|
735
|
-
r1 = Regress.test_callback_destroy_notify Proc.new {|b|
|
736
|
-
a = 2
|
737
|
-
b
|
738
|
-
}, 42, Proc.new { a = 3 }
|
739
|
-
assert_equal 2, a
|
740
|
-
assert_equal 42, r1
|
741
|
-
r2 = Regress.test_callback_thaw_notifications
|
742
|
-
assert_equal 3, a
|
743
|
-
assert_equal 42, r2
|
744
|
-
end
|
718
|
+
assert_equal 2, a
|
719
|
+
end
|
745
720
|
|
746
|
-
|
747
|
-
|
748
|
-
|
749
|
-
|
750
|
-
end
|
721
|
+
it "has correct test_boolean" do
|
722
|
+
assert_equal false, Regress.test_boolean(false)
|
723
|
+
assert_equal true, Regress.test_boolean(true)
|
724
|
+
end
|
751
725
|
|
752
|
-
|
753
|
-
|
754
|
-
|
755
|
-
a = u
|
756
|
-
5
|
757
|
-
}, true
|
758
|
-
assert_equal true, a
|
759
|
-
end
|
760
|
-
end
|
726
|
+
it "has correct test_boolean_false" do
|
727
|
+
assert_equal false, Regress.test_boolean_false(false)
|
728
|
+
end
|
761
729
|
|
762
|
-
|
763
|
-
|
764
|
-
|
765
|
-
assert_equal 5235, r
|
766
|
-
end
|
730
|
+
it "has correct test_boolean_true" do
|
731
|
+
assert_equal true, Regress.test_boolean_true(true)
|
732
|
+
end
|
767
733
|
|
768
|
-
|
769
|
-
|
770
|
-
|
771
|
-
|
772
|
-
end
|
734
|
+
it "has correct #test_cairo_context_full_return" do
|
735
|
+
ct = Regress.test_cairo_context_full_return
|
736
|
+
assert_instance_of Cairo::Context, ct
|
737
|
+
end
|
773
738
|
|
774
|
-
|
775
|
-
|
776
|
-
|
777
|
-
|
778
|
-
[date.get_year, date.get_month, date.get_day]
|
779
|
-
end
|
739
|
+
it "has correct #test_cairo_context_none_in" do
|
740
|
+
ct = Regress.test_cairo_context_full_return
|
741
|
+
Regress.test_cairo_context_none_in ct
|
742
|
+
end
|
780
743
|
|
781
|
-
|
782
|
-
|
783
|
-
|
784
|
-
|
744
|
+
it "has correct #test_cairo_surface_full_out" do
|
745
|
+
cs = Regress.test_cairo_surface_full_out
|
746
|
+
assert_instance_of Cairo::Surface, cs
|
747
|
+
end
|
785
748
|
|
786
|
-
|
787
|
-
|
788
|
-
|
789
|
-
|
749
|
+
it "has correct #test_cairo_surface_full_return" do
|
750
|
+
cs = Regress.test_cairo_surface_full_return
|
751
|
+
assert_instance_of Cairo::Surface, cs
|
752
|
+
end
|
753
|
+
|
754
|
+
it "has correct #test_cairo_surface_none_in" do
|
755
|
+
cs = Regress.test_cairo_surface_full_return
|
756
|
+
Regress.test_cairo_surface_none_in cs
|
757
|
+
end
|
758
|
+
|
759
|
+
it "has correct #test_cairo_surface_none_return" do
|
760
|
+
cs = Regress.test_cairo_surface_none_return
|
761
|
+
assert_instance_of Cairo::Surface, cs
|
762
|
+
end
|
763
|
+
|
764
|
+
it "has correct test_callback" do
|
765
|
+
result = Regress.test_callback Proc.new { 5 }
|
766
|
+
assert_equal 5, result
|
767
|
+
end
|
768
|
+
|
769
|
+
it "has correct test_callback_async" do
|
770
|
+
a = 1
|
771
|
+
Regress.test_callback_async Proc.new {|b|
|
772
|
+
a = 2
|
773
|
+
b
|
774
|
+
}, 44
|
775
|
+
r = Regress.test_callback_thaw_async
|
776
|
+
assert_equal 44, r
|
777
|
+
assert_equal 2, a
|
778
|
+
end
|
790
779
|
|
791
|
-
|
792
|
-
|
793
|
-
|
794
|
-
|
780
|
+
it "has correct test_callback_destroy_notify" do
|
781
|
+
a = 1
|
782
|
+
r1 = Regress.test_callback_destroy_notify Proc.new {|b|
|
783
|
+
a = 2
|
784
|
+
b
|
785
|
+
}, 42, Proc.new { a = 3 }
|
786
|
+
assert_equal 2, a
|
787
|
+
assert_equal 42, r1
|
788
|
+
r2 = Regress.test_callback_thaw_notifications
|
789
|
+
assert_equal 3, a
|
790
|
+
assert_equal 42, r2
|
791
|
+
end
|
792
|
+
|
793
|
+
describe "the #test_callback_user_data function" do
|
794
|
+
it "returns the callbacks return value" do
|
795
|
+
result = Regress.test_callback_user_data Proc.new {|u| 5 }, nil
|
796
|
+
assert_equal 5, result
|
795
797
|
end
|
796
798
|
|
797
|
-
|
798
|
-
|
799
|
-
|
799
|
+
it "handles boolean user_data" do
|
800
|
+
a = false
|
801
|
+
Regress.test_callback_user_data Proc.new {|u|
|
802
|
+
a = u
|
803
|
+
5
|
804
|
+
}, true
|
805
|
+
assert_equal true, a
|
800
806
|
end
|
807
|
+
end
|
801
808
|
|
802
|
-
|
803
|
-
|
804
|
-
|
805
|
-
|
809
|
+
it "has correct test_closure" do
|
810
|
+
c = GObject::RubyClosure.new { 5235 }
|
811
|
+
r = Regress.test_closure c
|
812
|
+
assert_equal 5235, r
|
813
|
+
end
|
806
814
|
|
807
|
-
|
808
|
-
|
809
|
-
|
815
|
+
it "has correct test_closure_one_arg" do
|
816
|
+
c = GObject::RubyClosure.new { |a| a * 2 }
|
817
|
+
r = Regress.test_closure_one_arg c, 2
|
818
|
+
assert_equal 4, r
|
819
|
+
end
|
810
820
|
|
811
|
-
|
812
|
-
|
813
|
-
|
814
|
-
|
815
|
-
|
816
|
-
|
817
|
-
|
821
|
+
it "has a correct #test_date_in_gvalue function" do
|
822
|
+
r = Regress.test_date_in_gvalue
|
823
|
+
date = r.ruby_value
|
824
|
+
skip unless date.respond_to? :get_year
|
825
|
+
assert_equal [1984, :december, 5],
|
826
|
+
[date.get_year, date.get_month, date.get_day]
|
827
|
+
end
|
818
828
|
|
819
|
-
|
820
|
-
|
821
|
-
|
822
|
-
|
823
|
-
|
824
|
-
it "returns an instance of GLib::HashTable" do
|
825
|
-
@hash.must_be_instance_of GLib::HashTable
|
826
|
-
end
|
829
|
+
it "has correct test_double" do
|
830
|
+
r = Regress.test_double 5435.32
|
831
|
+
assert_equal 5435.32, r
|
832
|
+
end
|
827
833
|
|
828
|
-
|
829
|
-
|
830
|
-
|
831
|
-
|
832
|
-
end
|
834
|
+
it "has correct test_enum_param" do
|
835
|
+
r = Regress.test_enum_param :value3
|
836
|
+
assert_equal "value3", r
|
837
|
+
end
|
833
838
|
|
834
|
-
|
835
|
-
|
836
|
-
|
837
|
-
|
838
|
-
|
839
|
+
# TODO: Find a way to test encoding issues.
|
840
|
+
it "has correct #test_filename_return" do
|
841
|
+
arr = Regress.test_filename_return
|
842
|
+
assert_equal ["åäö", "/etc/fstab"], arr.to_a
|
843
|
+
end
|
839
844
|
|
840
|
-
|
841
|
-
|
845
|
+
it "has correct test_float" do
|
846
|
+
r = Regress.test_float 5435.32
|
847
|
+
assert_in_delta 5435.32, r, 0.001
|
848
|
+
end
|
842
849
|
|
843
|
-
|
844
|
-
|
845
|
-
|
850
|
+
describe "#test_garray_container_return" do
|
851
|
+
before do
|
852
|
+
skip unless get_introspection_data 'Regress', 'test_garray_container_return'
|
853
|
+
@arr = Regress.test_garray_container_return
|
846
854
|
end
|
847
855
|
|
848
|
-
it "
|
849
|
-
|
850
|
-
"qux" => "quux"})
|
856
|
+
it "returns an instance of GLib::PtrArray" do
|
857
|
+
@arr.must_be_instance_of GLib::PtrArray
|
851
858
|
end
|
852
859
|
|
853
|
-
it "
|
854
|
-
|
855
|
-
|
856
|
-
|
860
|
+
it "returns the correct values" do
|
861
|
+
@arr.len.must_be :==, 1
|
862
|
+
ptr = @arr.pdata
|
863
|
+
ptr2 = ptr.read_pointer
|
864
|
+
ptr2.read_string.must_be :==, "regress"
|
857
865
|
end
|
866
|
+
end
|
858
867
|
|
859
|
-
|
860
|
-
|
861
|
-
|
862
|
-
"qux" => "quux"}
|
868
|
+
describe "#test_ghash_container_return" do
|
869
|
+
before do
|
870
|
+
@hash = Regress.test_ghash_container_return
|
863
871
|
end
|
864
872
|
|
865
|
-
it "
|
866
|
-
|
873
|
+
it "returns an instance of GLib::HashTable" do
|
874
|
+
@hash.must_be_instance_of GLib::HashTable
|
867
875
|
end
|
868
876
|
|
869
|
-
it "
|
870
|
-
|
871
|
-
|
877
|
+
it "returns the correct values" do
|
878
|
+
@hash.to_hash.must_be :==, {"foo" => "bar", "baz" => "bat",
|
879
|
+
"qux" => "quux"}
|
872
880
|
end
|
881
|
+
end
|
873
882
|
|
874
|
-
|
875
|
-
|
876
|
-
|
877
|
-
|
883
|
+
it "has correct #test_ghash_everything_return" do
|
884
|
+
ghash = Regress.test_ghash_everything_return
|
885
|
+
ghash.to_hash.must_be :==, {"foo" => "bar", "baz" => "bat",
|
886
|
+
"qux" => "quux"}
|
887
|
+
end
|
878
888
|
|
879
|
-
|
880
|
-
|
881
|
-
@list = Regress.test_glist_container_return
|
882
|
-
end
|
889
|
+
it "has correct test_ghash_nested_everything_return"
|
890
|
+
it "has correct test_ghash_nested_everything_return2"
|
883
891
|
|
884
|
-
|
885
|
-
|
886
|
-
|
892
|
+
it "has correct #test_ghash_nothing_in" do
|
893
|
+
Regress.test_ghash_nothing_in({"foo" => "bar", "baz" => "bat",
|
894
|
+
"qux" => "quux"})
|
895
|
+
end
|
887
896
|
|
888
|
-
|
889
|
-
|
890
|
-
|
891
|
-
|
897
|
+
it "has correct #test_ghash_nothing_in2" do
|
898
|
+
Regress.test_ghash_nothing_in2({"foo" => "bar", "baz" => "bat",
|
899
|
+
"qux" => "quux"})
|
900
|
+
end
|
892
901
|
|
893
|
-
|
894
|
-
|
895
|
-
|
896
|
-
|
902
|
+
it "has correct #test_ghash_nothing_return" do
|
903
|
+
ghash = Regress.test_ghash_nothing_return
|
904
|
+
ghash.to_hash.must_be :==, {"foo" => "bar", "baz" => "bat",
|
905
|
+
"qux" => "quux"}
|
906
|
+
end
|
897
907
|
|
898
|
-
|
899
|
-
|
900
|
-
|
901
|
-
|
902
|
-
|
908
|
+
it "has correct #test_ghash_nothing_return2" do
|
909
|
+
ghash = Regress.test_ghash_nothing_return2
|
910
|
+
ghash.to_hash.must_be :==, {"foo" => "bar", "baz" => "bat",
|
911
|
+
"qux" => "quux"}
|
912
|
+
end
|
903
913
|
|
904
|
-
|
905
|
-
|
906
|
-
|
907
|
-
}
|
908
|
-
end
|
914
|
+
it "has correct #test_ghash_null_in" do
|
915
|
+
Regress.test_ghash_null_in(nil)
|
916
|
+
end
|
909
917
|
|
910
|
-
|
911
|
-
|
912
|
-
|
913
|
-
|
918
|
+
it "has correct #test_ghash_null_out" do
|
919
|
+
ghash = Regress.test_ghash_null_out
|
920
|
+
ghash.must_be_nil
|
921
|
+
end
|
914
922
|
|
915
|
-
|
916
|
-
|
917
|
-
|
923
|
+
it "has correct #test_ghash_null_return" do
|
924
|
+
ghash = Regress.test_ghash_null_return
|
925
|
+
ghash.must_be_nil
|
926
|
+
end
|
927
|
+
|
928
|
+
describe "#test_glist_container_return" do
|
929
|
+
setup do
|
930
|
+
@list = Regress.test_glist_container_return
|
918
931
|
end
|
919
932
|
|
920
|
-
|
921
|
-
|
922
|
-
Regress.test_glist_null_in nil
|
923
|
-
}
|
933
|
+
it "returns an instance of GLib::SList" do
|
934
|
+
assert_instance_of GLib::List, @list
|
924
935
|
end
|
925
936
|
|
926
|
-
|
927
|
-
|
928
|
-
assert_equal nil, result
|
937
|
+
it "returns the correct values" do
|
938
|
+
assert_equal ["1", "2", "3"], @list.to_a
|
929
939
|
end
|
940
|
+
end
|
930
941
|
|
931
|
-
|
932
|
-
|
933
|
-
|
934
|
-
|
942
|
+
it "has correct test_glist_everything_return" do
|
943
|
+
list = Regress.test_glist_everything_return
|
944
|
+
assert_equal ["1", "2", "3"], list.to_a
|
945
|
+
end
|
935
946
|
|
936
|
-
|
937
|
-
|
938
|
-
|
947
|
+
it "has correct test_glist_nothing_in" do
|
948
|
+
assert_nothing_raised {
|
949
|
+
Regress.test_glist_nothing_in ["1", "2", "3"]
|
950
|
+
}
|
951
|
+
end
|
939
952
|
|
940
|
-
|
941
|
-
|
942
|
-
|
943
|
-
|
953
|
+
it "has correct test_glist_nothing_in2" do
|
954
|
+
assert_nothing_raised {
|
955
|
+
Regress.test_glist_nothing_in2 ["1", "2", "3"]
|
956
|
+
}
|
957
|
+
end
|
944
958
|
|
945
|
-
|
946
|
-
|
947
|
-
|
948
|
-
|
959
|
+
it "has correct test_glist_nothing_return" do
|
960
|
+
list = Regress.test_glist_nothing_return
|
961
|
+
assert_equal ["1", "2", "3"], list.to_a
|
962
|
+
end
|
949
963
|
|
950
|
-
|
951
|
-
|
952
|
-
|
953
|
-
|
954
|
-
end
|
964
|
+
it "has correct test_glist_nothing_return2" do
|
965
|
+
list = Regress.test_glist_nothing_return2
|
966
|
+
assert_equal ["1", "2", "3"], list.to_a
|
967
|
+
end
|
955
968
|
|
956
|
-
|
957
|
-
|
958
|
-
|
959
|
-
|
960
|
-
|
969
|
+
it "has correct test_glist_null_in" do
|
970
|
+
assert_nothing_raised {
|
971
|
+
Regress.test_glist_null_in nil
|
972
|
+
}
|
973
|
+
end
|
961
974
|
|
962
|
-
|
963
|
-
|
964
|
-
|
965
|
-
|
975
|
+
it "has correct test_glist_null_out" do
|
976
|
+
result = Regress.test_glist_null_out
|
977
|
+
assert_equal nil, result
|
978
|
+
end
|
966
979
|
|
967
|
-
|
968
|
-
|
969
|
-
|
980
|
+
describe "#test_gslist_container_return" do
|
981
|
+
setup do
|
982
|
+
@slist = Regress.test_gslist_container_return
|
970
983
|
end
|
971
984
|
|
972
|
-
|
973
|
-
|
974
|
-
Regress.test_gslist_null_in nil
|
975
|
-
}
|
985
|
+
it "returns a GLib::SList object" do
|
986
|
+
assert_instance_of GLib::SList, @slist
|
976
987
|
end
|
977
988
|
|
978
|
-
|
979
|
-
|
980
|
-
result = Regress.test_gslist_null_out
|
981
|
-
assert_equal nil, result
|
982
|
-
end
|
989
|
+
it "returns the correct values" do
|
990
|
+
assert_equal ["1", "2", "3"], @slist.to_a
|
983
991
|
end
|
992
|
+
end
|
984
993
|
|
985
|
-
|
986
|
-
|
987
|
-
|
988
|
-
|
994
|
+
it "has correct test_gslist_everything_return" do
|
995
|
+
slist = Regress.test_gslist_everything_return
|
996
|
+
assert_equal ["1", "2", "3"], slist.to_a
|
997
|
+
end
|
989
998
|
|
990
|
-
|
991
|
-
|
992
|
-
|
993
|
-
|
999
|
+
it "has correct test_gslist_nothing_in" do
|
1000
|
+
assert_nothing_raised {
|
1001
|
+
Regress.test_gslist_nothing_in ["1", "2", "3"]
|
1002
|
+
}
|
1003
|
+
end
|
994
1004
|
|
995
|
-
|
996
|
-
|
997
|
-
|
998
|
-
|
1005
|
+
it "has correct test_gslist_nothing_in2" do
|
1006
|
+
assert_nothing_raised {
|
1007
|
+
Regress.test_gslist_nothing_in2 ["1", "2", "3"]
|
1008
|
+
}
|
1009
|
+
end
|
999
1010
|
|
1000
|
-
|
1001
|
-
|
1002
|
-
|
1003
|
-
|
1011
|
+
it "has correct test_gslist_nothing_return" do
|
1012
|
+
slist = Regress.test_gslist_nothing_return
|
1013
|
+
assert_equal ["1", "2", "3"], slist.to_a
|
1014
|
+
end
|
1004
1015
|
|
1005
|
-
|
1006
|
-
|
1007
|
-
|
1008
|
-
|
1016
|
+
it "has correct test_gslist_nothing_return2" do
|
1017
|
+
slist = Regress.test_gslist_nothing_return2
|
1018
|
+
assert_equal ["1", "2", "3"], slist.to_a
|
1019
|
+
end
|
1009
1020
|
|
1010
|
-
|
1011
|
-
|
1012
|
-
|
1013
|
-
|
1021
|
+
it "has correct test_gslist_null_in" do
|
1022
|
+
assert_nothing_raised {
|
1023
|
+
Regress.test_gslist_null_in nil
|
1024
|
+
}
|
1025
|
+
end
|
1014
1026
|
|
1015
|
-
|
1016
|
-
|
1017
|
-
|
1027
|
+
describe "#test_gslist_null_out" do
|
1028
|
+
it "returns nil" do
|
1029
|
+
result = Regress.test_gslist_null_out
|
1030
|
+
assert_equal nil, result
|
1018
1031
|
end
|
1032
|
+
end
|
1019
1033
|
|
1020
|
-
|
1021
|
-
|
1022
|
-
|
1023
|
-
|
1024
|
-
result = Regress.test_int_value_arg gv
|
1025
|
-
assert_equal 343, result
|
1026
|
-
end
|
1034
|
+
it "has correct test_gtype" do
|
1035
|
+
result = Regress.test_gtype 23
|
1036
|
+
assert_equal 23, result
|
1037
|
+
end
|
1027
1038
|
|
1028
|
-
|
1029
|
-
|
1030
|
-
|
1031
|
-
|
1039
|
+
it "has correct test_int" do
|
1040
|
+
result = Regress.test_int 23
|
1041
|
+
assert_equal 23, result
|
1042
|
+
end
|
1032
1043
|
|
1033
|
-
|
1034
|
-
|
1035
|
-
|
1036
|
-
|
1037
|
-
23
|
1038
|
-
}
|
1039
|
-
assert_equal 2 * 23, result
|
1040
|
-
assert_equal 3, a
|
1041
|
-
end
|
1044
|
+
it "has correct test_int16" do
|
1045
|
+
result = Regress.test_int16 23
|
1046
|
+
assert_equal 23, result
|
1047
|
+
end
|
1042
1048
|
|
1043
|
-
|
1044
|
-
|
1045
|
-
|
1046
|
-
|
1047
|
-
end
|
1049
|
+
it "has correct test_int32" do
|
1050
|
+
result = Regress.test_int32 23
|
1051
|
+
assert_equal 23, result
|
1052
|
+
end
|
1048
1053
|
|
1049
|
-
|
1050
|
-
|
1051
|
-
|
1052
|
-
|
1054
|
+
it "has correct test_int64" do
|
1055
|
+
result = Regress.test_int64 2300000000000
|
1056
|
+
assert_equal 2300000000000, result
|
1057
|
+
end
|
1053
1058
|
|
1054
|
-
|
1055
|
-
|
1056
|
-
|
1057
|
-
|
1059
|
+
it "has correct test_int8" do
|
1060
|
+
result = Regress.test_int8 23
|
1061
|
+
assert_equal 23, result
|
1062
|
+
end
|
1058
1063
|
|
1059
|
-
|
1060
|
-
|
1061
|
-
|
1062
|
-
|
1063
|
-
assert_equal 1, a
|
1064
|
-
end
|
1064
|
+
it "has correct test_int_out_utf8" do
|
1065
|
+
len = Regress.test_int_out_utf8 "How long?"
|
1066
|
+
assert_equal 9, len
|
1067
|
+
end
|
1065
1068
|
|
1066
|
-
|
1067
|
-
|
1068
|
-
|
1069
|
-
|
1070
|
-
|
1071
|
-
|
1072
|
-
|
1073
|
-
end
|
1074
|
-
end
|
1069
|
+
it "has correct test_int_value_arg" do
|
1070
|
+
gv = GObject::Value.new
|
1071
|
+
gv.init GObject.type_from_name "gint"
|
1072
|
+
gv.set_int 343
|
1073
|
+
result = Regress.test_int_value_arg gv
|
1074
|
+
assert_equal 343, result
|
1075
|
+
end
|
1075
1076
|
|
1076
|
-
|
1077
|
-
|
1078
|
-
|
1077
|
+
it "has correct test_long" do
|
1078
|
+
long_val = FFI.type_size(:long) == 8 ? 2_300_000_000_000 : 2_000_000_000
|
1079
|
+
result = Regress.test_long long_val
|
1080
|
+
assert_equal long_val, result
|
1081
|
+
end
|
1079
1082
|
|
1080
|
-
|
1081
|
-
|
1082
|
-
|
1083
|
+
it "has correct test_multi_callback" do
|
1084
|
+
a = 1
|
1085
|
+
result = Regress.test_multi_callback Proc.new {
|
1086
|
+
a += 1
|
1087
|
+
23
|
1088
|
+
}
|
1089
|
+
assert_equal 2 * 23, result
|
1090
|
+
assert_equal 3, a
|
1091
|
+
end
|
1083
1092
|
|
1084
|
-
|
1085
|
-
|
1086
|
-
|
1093
|
+
it "has correct test_multi_double_args" do
|
1094
|
+
one, two = Regress.test_multi_double_args 23.1
|
1095
|
+
assert_equal 2 * 23.1, one
|
1096
|
+
assert_equal 3 * 23.1, two
|
1097
|
+
end
|
1087
1098
|
|
1088
|
-
|
1089
|
-
|
1090
|
-
|
1091
|
-
|
1099
|
+
it "has correct test_short" do
|
1100
|
+
result = Regress.test_short 23
|
1101
|
+
assert_equal 23, result
|
1102
|
+
end
|
1092
1103
|
|
1093
|
-
|
1094
|
-
|
1095
|
-
|
1096
|
-
|
1104
|
+
it "has correct test_simple_boxed_a_const_return" do
|
1105
|
+
result = Regress.test_simple_boxed_a_const_return
|
1106
|
+
assert_equal [5, 6, 7.0], [result.some_int, result.some_int8, result.some_double]
|
1107
|
+
end
|
1097
1108
|
|
1098
|
-
|
1099
|
-
|
1100
|
-
|
1109
|
+
describe "the #test_simple_callback function" do
|
1110
|
+
it "calls the passed-in proc" do
|
1111
|
+
a = 0
|
1112
|
+
Regress.test_simple_callback Proc.new { a = 1 }
|
1113
|
+
assert_equal 1, a
|
1101
1114
|
end
|
1102
1115
|
|
1103
|
-
|
1104
|
-
|
1105
|
-
|
1116
|
+
# XXX: The scope data does not seem to be reliable enough.
|
1117
|
+
if false
|
1118
|
+
it "does not store the proc in CALLBACKS" do
|
1119
|
+
n = Regress::Lib::CALLBACKS.length
|
1120
|
+
Regress.test_simple_callback Proc.new { }
|
1121
|
+
assert_equal n, Regress::Lib::CALLBACKS.length
|
1106
1122
|
end
|
1107
|
-
|
1108
|
-
it "has correct #test_strv_outarg" do
|
1109
|
-
arr = Regress.test_strv_outarg
|
1110
|
-
assert_equal ['1', '2', '3'], arr.to_a
|
1111
1123
|
end
|
1124
|
+
end
|
1112
1125
|
|
1113
|
-
|
1114
|
-
|
1115
|
-
|
1116
|
-
result = Regress.test_timet(t.to_i)
|
1117
|
-
assert_equal t, Time.at(result)
|
1118
|
-
end
|
1126
|
+
it "has correct test_size" do
|
1127
|
+
assert_equal 2354, Regress.test_size(2354)
|
1128
|
+
end
|
1119
1129
|
|
1120
|
-
|
1121
|
-
|
1122
|
-
|
1123
|
-
end
|
1130
|
+
it "has correct test_ssize" do
|
1131
|
+
assert_equal(-2_000_000, Regress.test_ssize(-2_000_000))
|
1132
|
+
end
|
1124
1133
|
|
1125
|
-
|
1126
|
-
|
1127
|
-
|
1128
|
-
assert_equal [true, -21, 2 * -21, "hello".length + 12], [ret, y, z, q]
|
1129
|
-
end
|
1134
|
+
it "has correct test_strv_in" do
|
1135
|
+
assert_equal true, Regress.test_strv_in(['1', '2', '3'])
|
1136
|
+
end
|
1130
1137
|
|
1131
|
-
|
1132
|
-
|
1133
|
-
|
1134
|
-
|
1135
|
-
end
|
1136
|
-
end
|
1137
|
-
|
1138
|
-
should "have correct test_torture_signature_2" do
|
1139
|
-
a = 1
|
1140
|
-
y, z, q = Regress.test_torture_signature_2 244,
|
1141
|
-
Proc.new {|u| a = u }, 2, Proc.new { a = 3 },
|
1142
|
-
"foofoo", 31
|
1143
|
-
assert_equal [244, 2*244, 6+31], [y, z, q]
|
1144
|
-
assert_equal 3, a
|
1145
|
-
end
|
1138
|
+
it "has correct #test_strv_in_gvalue" do
|
1139
|
+
gv = Regress.test_strv_in_gvalue
|
1140
|
+
assert_equal ['one', 'two', 'three'], gv.ruby_value.to_a
|
1141
|
+
end
|
1146
1142
|
|
1147
|
-
|
1148
|
-
|
1149
|
-
|
1143
|
+
it "has correct #test_strv_out" do
|
1144
|
+
arr = Regress.test_strv_out
|
1145
|
+
assert_equal ["thanks", "for", "all", "the", "fish"], arr.to_a
|
1146
|
+
end
|
1150
1147
|
|
1151
|
-
|
1152
|
-
|
1153
|
-
|
1148
|
+
it "has correct #test_strv_out_c" do
|
1149
|
+
arr = Regress.test_strv_out_c
|
1150
|
+
assert_equal ["thanks", "for", "all", "the", "fish"], arr.to_a
|
1151
|
+
end
|
1154
1152
|
|
1155
|
-
|
1156
|
-
|
1157
|
-
|
1153
|
+
it "has correct #test_strv_out_container" do
|
1154
|
+
arr = Regress.test_strv_out_container
|
1155
|
+
assert_equal ['1', '2', '3'], arr.to_a
|
1156
|
+
end
|
1158
1157
|
|
1159
|
-
|
1160
|
-
|
1161
|
-
|
1158
|
+
it "has correct #test_strv_outarg" do
|
1159
|
+
arr = Regress.test_strv_outarg
|
1160
|
+
assert_equal ['1', '2', '3'], arr.to_a
|
1161
|
+
end
|
1162
1162
|
|
1163
|
-
|
1164
|
-
|
1165
|
-
|
1163
|
+
it "has correct test_timet" do
|
1164
|
+
# Time rounded to seconds.
|
1165
|
+
t = Time.at(Time.now.to_i)
|
1166
|
+
result = Regress.test_timet(t.to_i)
|
1167
|
+
assert_equal t, Time.at(result)
|
1168
|
+
end
|
1166
1169
|
|
1167
|
-
|
1168
|
-
|
1169
|
-
|
1170
|
+
it "has correct test_torture_signature_0" do
|
1171
|
+
y, z, q = Regress.test_torture_signature_0 86, "foo", 2
|
1172
|
+
assert_equal [86, 2*86, 3+2], [y, z, q]
|
1173
|
+
end
|
1170
1174
|
|
1171
|
-
|
1172
|
-
|
1173
|
-
|
1175
|
+
describe "its #test_torture_signature_1 method" do
|
1176
|
+
it "works for m even" do
|
1177
|
+
ret, y, z, q = Regress.test_torture_signature_1(-21, "hello", 12)
|
1178
|
+
assert_equal [true, -21, 2 * -21, "hello".length + 12], [ret, y, z, q]
|
1174
1179
|
end
|
1175
1180
|
|
1176
|
-
it "
|
1177
|
-
|
1178
|
-
|
1181
|
+
it "throws an exception for m odd" do
|
1182
|
+
assert_raises RuntimeError do
|
1183
|
+
Regress.test_torture_signature_1(-21, "hello", 11)
|
1184
|
+
end
|
1179
1185
|
end
|
1186
|
+
end
|
1187
|
+
|
1188
|
+
it "has correct test_torture_signature_2" do
|
1189
|
+
a = 1
|
1190
|
+
y, z, q = Regress.test_torture_signature_2 244,
|
1191
|
+
Proc.new {|u| a = u }, 2, Proc.new { a = 3 },
|
1192
|
+
"foofoo", 31
|
1193
|
+
assert_equal [244, 2*244, 6+31], [y, z, q]
|
1194
|
+
assert_equal 3, a
|
1195
|
+
end
|
1180
1196
|
|
1181
|
-
|
1182
|
-
|
1183
|
-
|
1197
|
+
it "has correct test_uint" do
|
1198
|
+
assert_equal 31, Regress.test_uint(31)
|
1199
|
+
end
|
1184
1200
|
|
1185
|
-
|
1186
|
-
|
1187
|
-
|
1188
|
-
end
|
1189
|
-
end
|
1201
|
+
it "has correct test_uint16" do
|
1202
|
+
assert_equal 31, Regress.test_uint16(31)
|
1203
|
+
end
|
1190
1204
|
|
1191
|
-
|
1192
|
-
|
1193
|
-
|
1194
|
-
end
|
1205
|
+
it "has correct test_uint32" do
|
1206
|
+
assert_equal 540000, Regress.test_uint32(540000)
|
1207
|
+
end
|
1195
1208
|
|
1196
|
-
|
1197
|
-
|
1198
|
-
|
1199
|
-
end
|
1209
|
+
it "has correct test_uint64" do
|
1210
|
+
assert_equal 54_000_000_000_000, Regress.test_uint64(54_000_000_000_000)
|
1211
|
+
end
|
1200
1212
|
|
1201
|
-
|
1202
|
-
|
1203
|
-
|
1204
|
-
end
|
1213
|
+
it "has correct test_uint8" do
|
1214
|
+
assert_equal 31, Regress.test_uint8(31)
|
1215
|
+
end
|
1205
1216
|
|
1206
|
-
|
1207
|
-
|
1208
|
-
|
1209
|
-
end
|
1210
|
-
end
|
1217
|
+
it "has correct test_ulong" do
|
1218
|
+
assert_equal 54_000_000_000_000, Regress.test_uint64(54_000_000_000_000)
|
1219
|
+
end
|
1211
1220
|
|
1212
|
-
|
1213
|
-
|
1214
|
-
|
1221
|
+
it "has a correct #test_unichar" do
|
1222
|
+
assert_equal 120, Regress.test_unichar(120)
|
1223
|
+
assert_equal 540_000, Regress.test_unichar(540_000)
|
1224
|
+
end
|
1215
1225
|
|
1216
|
-
|
1217
|
-
|
1218
|
-
|
1219
|
-
|
1226
|
+
it "has a correct #test_unsigned_enum_param" do
|
1227
|
+
assert_equal "value1", Regress.test_unsigned_enum_param(:value1)
|
1228
|
+
assert_equal "value2", Regress.test_unsigned_enum_param(:value2)
|
1229
|
+
end
|
1220
1230
|
|
1221
|
-
|
1222
|
-
|
1223
|
-
|
1224
|
-
end
|
1231
|
+
it "has correct test_ushort" do
|
1232
|
+
assert_equal 54_000_000, Regress.test_uint64(54_000_000)
|
1233
|
+
end
|
1225
1234
|
|
1226
|
-
|
1227
|
-
|
1228
|
-
|
1235
|
+
it "has correct test_utf8_const_in" do
|
1236
|
+
assert_nothing_raised do
|
1237
|
+
Regress.test_utf8_const_in("const \xe2\x99\xa5 utf8")
|
1229
1238
|
end
|
1239
|
+
end
|
1230
1240
|
|
1231
|
-
|
1232
|
-
|
1233
|
-
|
1234
|
-
|
1241
|
+
it "has correct test_utf8_const_return" do
|
1242
|
+
result = Regress.test_utf8_const_return
|
1243
|
+
assert_equal "const \xe2\x99\xa5 utf8", result
|
1244
|
+
end
|
1235
1245
|
|
1236
|
-
|
1237
|
-
|
1238
|
-
|
1239
|
-
|
1240
|
-
|
1241
|
-
|
1246
|
+
it "has correct test_utf8_inout" do
|
1247
|
+
result = Regress.test_utf8_inout "const \xe2\x99\xa5 utf8"
|
1248
|
+
assert_equal "nonconst \xe2\x99\xa5 utf8", result
|
1249
|
+
end
|
1250
|
+
|
1251
|
+
it "has correct test_utf8_nonconst_return" do
|
1252
|
+
result = Regress.test_utf8_nonconst_return
|
1253
|
+
assert_equal "nonconst \xe2\x99\xa5 utf8", result
|
1254
|
+
end
|
1255
|
+
|
1256
|
+
it "has correct test_utf8_null_in" do
|
1257
|
+
assert_nothing_raised do
|
1258
|
+
Regress.test_utf8_null_in nil
|
1242
1259
|
end
|
1243
1260
|
end
|
1244
1261
|
|
1262
|
+
it "has correct test_utf8_null_out" do
|
1263
|
+
assert_equal nil, Regress.test_utf8_null_out
|
1264
|
+
end
|
1265
|
+
|
1266
|
+
it "has correct test_utf8_out" do
|
1267
|
+
result = Regress.test_utf8_out
|
1268
|
+
assert_equal "nonconst \xe2\x99\xa5 utf8", result
|
1269
|
+
end
|
1270
|
+
|
1271
|
+
it "has correct test_utf8_out_nonconst_return" do
|
1272
|
+
r, out = Regress.test_utf8_out_nonconst_return
|
1273
|
+
assert_equal ["first", "second"], [r, out]
|
1274
|
+
end
|
1275
|
+
|
1276
|
+
it "has correct test_utf8_out_out" do
|
1277
|
+
out0, out1 = Regress.test_utf8_out_nonconst_return
|
1278
|
+
assert_equal ["first", "second"], [out0, out1]
|
1279
|
+
end
|
1280
|
+
|
1281
|
+
it "has correct test_value_return" do
|
1282
|
+
result = Regress.test_value_return 3423
|
1283
|
+
assert_equal 3423, result.get_int
|
1284
|
+
end
|
1285
|
+
|
1286
|
+
it "raises an appropriate NoMethodError when a function is not found" do
|
1287
|
+
begin
|
1288
|
+
Regress.this_method_does_not_exist
|
1289
|
+
rescue => e
|
1290
|
+
assert_equal "undefined method `this_method_does_not_exist' for Regress:Module", e.message
|
1291
|
+
end
|
1292
|
+
end
|
1245
1293
|
end
|