gir_ffi 0.15.2 → 0.15.7

Sign up to get free protection for your applications and to get access to all the features.
Files changed (190) hide show
  1. checksums.yaml +4 -4
  2. data/Changelog.md +41 -0
  3. data/README.md +5 -6
  4. data/TODO.md +14 -35
  5. data/docs/Documentation.md +6 -0
  6. data/docs/Subclassing.md +38 -0
  7. data/lib/ffi-glib.rb +8 -3
  8. data/lib/ffi-glib/byte_array.rb +2 -1
  9. data/lib/ffi-glib/container_class_methods.rb +1 -3
  10. data/lib/ffi-glib/destroy_notify.rb +2 -2
  11. data/lib/ffi-glib/hash_table.rb +1 -2
  12. data/lib/ffi-glib/list.rb +11 -5
  13. data/lib/ffi-glib/list_methods.rb +12 -0
  14. data/lib/ffi-glib/s_list.rb +10 -4
  15. data/lib/ffi-gobject.rb +2 -5
  16. data/lib/ffi-gobject/object.rb +102 -92
  17. data/lib/ffi-gobject/object_class.rb +1 -1
  18. data/lib/ffi-gobject/ruby_closure.rb +1 -1
  19. data/lib/ffi-gobject/value.rb +108 -117
  20. data/lib/ffi-gobject_introspection/i_base_info.rb +35 -27
  21. data/lib/gir_ffi-base/gobject/lib.rb +4 -0
  22. data/lib/gir_ffi/array_element_convertor.rb +3 -4
  23. data/lib/gir_ffi/boxed_base.rb +13 -11
  24. data/lib/gir_ffi/builder.rb +3 -4
  25. data/lib/gir_ffi/builder_helper.rb +10 -2
  26. data/lib/gir_ffi/builders/base_argument_builder.rb +2 -2
  27. data/lib/gir_ffi/builders/base_method_builder.rb +1 -1
  28. data/lib/gir_ffi/builders/base_type_builder.rb +1 -1
  29. data/lib/gir_ffi/builders/callback_argument_builder.rb +2 -0
  30. data/lib/gir_ffi/builders/callback_builder.rb +25 -11
  31. data/lib/gir_ffi/builders/callback_return_value_builder.rb +4 -6
  32. data/lib/gir_ffi/builders/enum_builder.rb +9 -5
  33. data/lib/gir_ffi/builders/field_builder.rb +2 -1
  34. data/lib/gir_ffi/builders/function_builder.rb +1 -1
  35. data/lib/gir_ffi/builders/interface_builder.rb +3 -1
  36. data/lib/gir_ffi/builders/mapping_method_builder.rb +1 -1
  37. data/lib/gir_ffi/builders/marshalling_method_builder.rb +5 -2
  38. data/lib/gir_ffi/builders/method_template.rb +4 -4
  39. data/lib/gir_ffi/builders/module_builder.rb +4 -2
  40. data/lib/gir_ffi/builders/null_argument_builder.rb +0 -2
  41. data/lib/gir_ffi/builders/null_return_value_builder.rb +0 -2
  42. data/lib/gir_ffi/builders/object_builder.rb +18 -6
  43. data/lib/gir_ffi/builders/property_builder.rb +1 -2
  44. data/lib/gir_ffi/builders/signal_closure_builder.rb +3 -5
  45. data/lib/gir_ffi/builders/struct_builder.rb +34 -7
  46. data/lib/gir_ffi/builders/user_defined_builder.rb +8 -1
  47. data/lib/gir_ffi/builders/vfunc_argument_builder.rb +1 -1
  48. data/lib/gir_ffi/callback_base.rb +7 -8
  49. data/lib/gir_ffi/class_base.rb +1 -0
  50. data/lib/gir_ffi/core.rb +17 -2
  51. data/lib/gir_ffi/glib_error.rb +1 -2
  52. data/lib/gir_ffi/in_pointer.rb +10 -2
  53. data/lib/gir_ffi/interface_base.rb +5 -0
  54. data/lib/gir_ffi/object_base.rb +27 -0
  55. data/lib/gir_ffi/return_value_info.rb +1 -2
  56. data/lib/gir_ffi/struct_base.rb +1 -9
  57. data/lib/gir_ffi/struct_like_base.rb +9 -5
  58. data/lib/gir_ffi/type_map.rb +1 -0
  59. data/lib/gir_ffi/unintrospectable_type_info.rb +1 -1
  60. data/lib/gir_ffi/union_base.rb +1 -9
  61. data/lib/gir_ffi/user_defined_object_info.rb +3 -2
  62. data/lib/gir_ffi/version.rb +1 -1
  63. data/lib/gir_ffi/vfunc_implementation.rb +1 -0
  64. metadata +106 -143
  65. data/Gemfile +0 -14
  66. data/Rakefile +0 -9
  67. data/tasks/test.rake +0 -204
  68. data/test/base_test_helper.rb +0 -70
  69. data/test/ffi-glib/array_test.rb +0 -203
  70. data/test/ffi-glib/byte_array_test.rb +0 -28
  71. data/test/ffi-glib/bytes_test.rb +0 -61
  72. data/test/ffi-glib/closure_test.rb +0 -38
  73. data/test/ffi-glib/destroy_notify_test.rb +0 -18
  74. data/test/ffi-glib/hash_table_test.rb +0 -68
  75. data/test/ffi-glib/list_test.rb +0 -86
  76. data/test/ffi-glib/main_loop_test.rb +0 -53
  77. data/test/ffi-glib/ptr_array_test.rb +0 -112
  78. data/test/ffi-glib/ruby_closure_test.rb +0 -62
  79. data/test/ffi-glib/s_list_test.rb +0 -76
  80. data/test/ffi-glib/strv_test.rb +0 -60
  81. data/test/ffi-glib/variant_test.rb +0 -12
  82. data/test/ffi-gobject/gobject_test.rb +0 -76
  83. data/test/ffi-gobject/object_class_test.rb +0 -31
  84. data/test/ffi-gobject/object_test.rb +0 -122
  85. data/test/ffi-gobject/param_spec_test.rb +0 -32
  86. data/test/ffi-gobject/value_test.rb +0 -390
  87. data/test/ffi-gobject_introspection/gobject_type_init_test.rb +0 -26
  88. data/test/ffi-gobject_introspection/i_base_info_test.rb +0 -52
  89. data/test/ffi-gobject_introspection/i_constant_info_test.rb +0 -29
  90. data/test/ffi-gobject_introspection/i_enum_info_test.rb +0 -18
  91. data/test/ffi-gobject_introspection/i_function_info_test.rb +0 -6
  92. data/test/ffi-gobject_introspection/i_interface_info_test.rb +0 -23
  93. data/test/ffi-gobject_introspection/i_object_info_test.rb +0 -49
  94. data/test/ffi-gobject_introspection/i_property_info_test.rb +0 -47
  95. data/test/ffi-gobject_introspection/i_registered_type_info_test.rb +0 -27
  96. data/test/ffi-gobject_introspection/i_repository_test.rb +0 -81
  97. data/test/ffi-gobject_introspection/i_struct_info_test.rb +0 -23
  98. data/test/ffi-gobject_introspection/i_type_info_test.rb +0 -30
  99. data/test/ffi-gobject_introspection/i_union_info_test.rb +0 -17
  100. data/test/ffi-gobject_introspection/i_vfunc_info_test.rb +0 -41
  101. data/test/ffi-gobject_introspection/lib_test.rb +0 -13
  102. data/test/ffi-gobject_introspection/strv_test.rb +0 -46
  103. data/test/ffi-gobject_test.rb +0 -151
  104. data/test/gir_ffi/allocation_helper_test.rb +0 -36
  105. data/test/gir_ffi/arg_helper_test.rb +0 -139
  106. data/test/gir_ffi/boolean_test.rb +0 -43
  107. data/test/gir_ffi/boxed_base_test.rb +0 -65
  108. data/test/gir_ffi/builder_test.rb +0 -322
  109. data/test/gir_ffi/builders/argument_builder_test.rb +0 -651
  110. data/test/gir_ffi/builders/base_argument_builder_test.rb +0 -6
  111. data/test/gir_ffi/builders/callback_argument_builder_test.rb +0 -126
  112. data/test/gir_ffi/builders/callback_builder_test.rb +0 -117
  113. data/test/gir_ffi/builders/callback_return_value_builder_test.rb +0 -81
  114. data/test/gir_ffi/builders/constant_builder_test.rb +0 -6
  115. data/test/gir_ffi/builders/constructor_builder_test.rb +0 -37
  116. data/test/gir_ffi/builders/enum_builder_test.rb +0 -23
  117. data/test/gir_ffi/builders/field_builder_test.rb +0 -134
  118. data/test/gir_ffi/builders/function_builder_test.rb +0 -550
  119. data/test/gir_ffi/builders/initializer_builder_test.rb +0 -54
  120. data/test/gir_ffi/builders/interface_builder_test.rb +0 -32
  121. data/test/gir_ffi/builders/module_builder_test.rb +0 -43
  122. data/test/gir_ffi/builders/object_builder_test.rb +0 -98
  123. data/test/gir_ffi/builders/property_builder_test.rb +0 -158
  124. data/test/gir_ffi/builders/registered_type_builder_test.rb +0 -54
  125. data/test/gir_ffi/builders/return_value_builder_test.rb +0 -433
  126. data/test/gir_ffi/builders/signal_closure_builder_test.rb +0 -197
  127. data/test/gir_ffi/builders/struct_builder_test.rb +0 -93
  128. data/test/gir_ffi/builders/unintrospectable_boxed_builder_test.rb +0 -29
  129. data/test/gir_ffi/builders/unintrospectable_builder_test.rb +0 -84
  130. data/test/gir_ffi/builders/union_builder_test.rb +0 -28
  131. data/test/gir_ffi/builders/user_defined_builder_test.rb +0 -524
  132. data/test/gir_ffi/builders/vfunc_argument_builder_test.rb +0 -101
  133. data/test/gir_ffi/builders/vfunc_builder_test.rb +0 -241
  134. data/test/gir_ffi/callback_base_test.rb +0 -22
  135. data/test/gir_ffi/class_base_test.rb +0 -166
  136. data/test/gir_ffi/core_test.rb +0 -98
  137. data/test/gir_ffi/enum_base_test.rb +0 -43
  138. data/test/gir_ffi/error_type_info_test.rb +0 -50
  139. data/test/gir_ffi/ffi_ext/pointer_test.rb +0 -20
  140. data/test/gir_ffi/g_type_test.rb +0 -31
  141. data/test/gir_ffi/in_pointer_test.rb +0 -203
  142. data/test/gir_ffi/info_ext/i_callable_info_test.rb +0 -26
  143. data/test/gir_ffi/info_ext/i_callback_info_test.rb +0 -21
  144. data/test/gir_ffi/info_ext/i_field_info_test.rb +0 -37
  145. data/test/gir_ffi/info_ext/i_function_info_test.rb +0 -74
  146. data/test/gir_ffi/info_ext/i_signal_info_test.rb +0 -32
  147. data/test/gir_ffi/info_ext/i_type_info_test.rb +0 -711
  148. data/test/gir_ffi/info_ext/i_unresolved_info_test.rb +0 -19
  149. data/test/gir_ffi/info_ext/safe_constant_name_test.rb +0 -26
  150. data/test/gir_ffi/info_ext/safe_function_name_test.rb +0 -26
  151. data/test/gir_ffi/interface_base_test.rb +0 -20
  152. data/test/gir_ffi/method_stubber_test.rb +0 -65
  153. data/test/gir_ffi/object_base_test.rb +0 -64
  154. data/test/gir_ffi/object_store_test.rb +0 -41
  155. data/test/gir_ffi/receiver_argument_info_test.rb +0 -33
  156. data/test/gir_ffi/sized_array_test.rb +0 -206
  157. data/test/gir_ffi/struct_base_test.rb +0 -23
  158. data/test/gir_ffi/struct_like_base_test.rb +0 -167
  159. data/test/gir_ffi/type_map_test.rb +0 -17
  160. data/test/gir_ffi/unintrospectable_type_info_test.rb +0 -121
  161. data/test/gir_ffi/union_base_test.rb +0 -23
  162. data/test/gir_ffi/user_defined_object_info_test.rb +0 -119
  163. data/test/gir_ffi/user_defined_property_info_test.rb +0 -39
  164. data/test/gir_ffi/variable_name_generator_test.rb +0 -18
  165. data/test/gir_ffi/version_test.rb +0 -9
  166. data/test/gir_ffi/zero_terminated_test.rb +0 -108
  167. data/test/gir_ffi_test_helper.rb +0 -84
  168. data/test/integration/callback_exceptions_test.rb +0 -59
  169. data/test/integration/derived_classes_test.rb +0 -53
  170. data/test/integration/generated_everything_test.rb +0 -452
  171. data/test/integration/generated_gimarshallingtests_test.rb +0 -3096
  172. data/test/integration/generated_gio_test.rb +0 -116
  173. data/test/integration/generated_glib_test.rb +0 -10
  174. data/test/integration/generated_gobject_test.rb +0 -124
  175. data/test/integration/generated_gst_test.rb +0 -38
  176. data/test/integration/generated_gtk_source_test.rb +0 -32
  177. data/test/integration/generated_gtop_test.rb +0 -22
  178. data/test/integration/generated_pango_ft2_test.rb +0 -17
  179. data/test/integration/generated_pango_test.rb +0 -24
  180. data/test/integration/generated_regress_test.rb +0 -4062
  181. data/test/integration/generated_secret_test.rb +0 -14
  182. data/test/integration/generated_utility_test.rb +0 -174
  183. data/test/integration/generated_warnlib_test.rb +0 -43
  184. data/test/integration/method_lookup_test.rb +0 -34
  185. data/test/introspection_test_helper.rb +0 -93
  186. data/test/lib/Makefile.am +0 -110
  187. data/test/lib/autogen.sh +0 -4
  188. data/test/lib/configure.ac +0 -34
  189. data/test/lib/m4/jhflags.m4 +0 -21
  190. data/test/minitest/stats_plugin.rb +0 -30
@@ -1,116 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require "gir_ffi_test_helper"
4
-
5
- GirFFI.setup :Gio
6
-
7
- # Tests generated methods and functions in the Gio namespace.
8
- describe "The generated Gio module" do
9
- describe "File#new_for_path, a method returning an interface," do
10
- it "returns an object of a more specific class" do
11
- file = Gio::File.new_for_path("/")
12
- _(file.class.registered_ancestors).must_equal [file.class, Gio::File, GObject::Object]
13
-
14
- refute_instance_of Gio::File, file
15
- assert_includes file.class.registered_ancestors, Gio::File
16
- end
17
- end
18
-
19
- describe "the result of #file_new_from_path" do
20
- before do
21
- @it = Gio.file_new_for_path("/")
22
- end
23
-
24
- it "is able to set up a method in a class that is not the first ancestor" do
25
- refute_defines_instance_method @it.class, :get_qdata
26
- refute_defines_instance_method Gio::File, :get_qdata
27
- assert_defines_instance_method GObject::Object, :get_qdata
28
-
29
- @it.setup_and_call :get_qdata, 1
30
- end
31
-
32
- it "knows its GType" do
33
- instance_gtype = GObject.type_from_instance @it
34
- _(@it.class.gtype).must_equal instance_gtype
35
- end
36
- end
37
-
38
- describe "the FileInfo class" do
39
- describe "an instance" do
40
- before do
41
- file = Gio.file_new_for_path("/")
42
- @fileinfo = file.query_info "*", :none, nil
43
- end
44
-
45
- it "has a working #get_attribute_type method" do
46
- type = @fileinfo.get_attribute_type "standard::display-name"
47
- assert_equal :string, type
48
- end
49
- end
50
- end
51
-
52
- describe "the action-added signal" do
53
- before do
54
- @grp = Gio::SimpleActionGroup.new
55
- end
56
-
57
- it "correctly passes on the string parameter 'action_name'" do
58
- a = nil
59
- GObject.signal_connect @grp, "action-added" do |_grp, action_name, _user_data|
60
- a = action_name
61
- end
62
- GObject.signal_emit @grp, "action-added", "foo"
63
- assert_equal "foo", a
64
- end
65
- end
66
-
67
- describe "the reply signal" do
68
- before do
69
- @mo = Gio::MountOperation.new
70
- end
71
-
72
- it "correctly passes on the enum parameter 'result'" do
73
- a = nil
74
- GObject.signal_connect @mo, "reply" do |_mnt, result, _user_data|
75
- a = result
76
- end
77
- GObject.signal_emit @mo, "reply", :unhandled
78
- assert_equal :unhandled, a
79
- end
80
- end
81
-
82
- describe "the CharsetConverter class" do
83
- it "includes two interfaces" do
84
- klass = Gio::CharsetConverter
85
- _(klass.included_interfaces).must_equal [Gio::Initable, Gio::Converter]
86
- end
87
-
88
- it "allows an instance to find the #reset method" do
89
- cnv = Gio::CharsetConverter.new "utf8", "utf8"
90
- cnv.reset
91
- pass
92
- end
93
- end
94
-
95
- describe "the SocketSourceFunc callback" do
96
- it "can be cast to a native function" do
97
- Gio::SocketSourceFunc.new { |*args| p args }.to_native
98
- end
99
- end
100
-
101
- describe "Gio::SimpleAction" do
102
- let(:simple_action) { Gio::SimpleAction.new("test", "d") }
103
-
104
- it 'can read the property "state-type" with #get_property' do
105
- _(simple_action.get_property("state-type")).must_be_nil
106
- end
107
-
108
- it 'can read the property "state-type" with #state_type' do
109
- _(simple_action.state_type).must_be_nil
110
- end
111
-
112
- it 'cannot write the property "state-type" with #state_type=' do
113
- _(simple_action).wont_respond_to :state_type=
114
- end
115
- end
116
- end
@@ -1,10 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require "gir_ffi_test_helper"
4
-
5
- # Tests generated classes, methods and functions in the GLib namespace.
6
- describe "The generated GLib module" do
7
- it "can auto-generate the GLib::SOURCE_REMOVE constant" do
8
- _(GLib::SOURCE_REMOVE).must_equal false
9
- end
10
- end
@@ -1,124 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require "gir_ffi_test_helper"
4
-
5
- GirFFI.setup :Regress
6
-
7
- describe GObject do
8
- describe ".type_interfaces" do
9
- it "works, showing that returning an array of GType works" do
10
- klass = GObject::TypeModule
11
- ifcs = GObject.type_interfaces klass.gtype
12
- assert_equal 1, ifcs.size
13
- end
14
- end
15
-
16
- describe ".signal_set_va_marshaller" do
17
- it "can be set up" do
18
- result = GObject.setup_method "signal_set_va_marshaller"
19
- _(result).must_equal true
20
- end
21
- end
22
-
23
- describe GObject::TypeInfo do
24
- let(:instance) { GObject::TypeInfo.new }
25
- it "has a working field setter for class_init" do
26
- instance.class_init = proc do |_object_class, _data|
27
- end
28
- end
29
-
30
- it "has a working field getter for class_init" do
31
- _(instance.class_init).must_be_nil
32
- instance.class_init = proc do |_object_class, _data|
33
- end
34
- result = instance.class_init
35
- _(result).wont_be_nil
36
- _(result).must_be_instance_of FFI::Function
37
- end
38
- end
39
-
40
- describe GObject::TypePlugin do
41
- it "is implemented as a module" do
42
- mod = GObject::TypePlugin
43
- assert_instance_of Module, mod
44
- refute_instance_of Class, mod
45
- end
46
- end
47
-
48
- describe GObject::TypeModule do
49
- it "has the GObject::TypePlugin module as an ancestor" do
50
- klass = GObject::TypeModule
51
- assert_includes klass.registered_ancestors, GObject::TypePlugin
52
- end
53
- end
54
-
55
- describe GObject::ValueArray do
56
- it "uses the constructor provided by GObject" do
57
- instance = GObject::ValueArray.new 16
58
- _(instance.n_prealloced).must_equal 16
59
- _(instance.n_values).must_equal 0
60
- end
61
- end
62
-
63
- describe GObject::SignalQuery do
64
- it "works" do
65
- GObject::SignalQuery.new
66
- pass
67
- end
68
-
69
- it "uses the n_params field for the length of param_types" do
70
- gtype = GObject::Object.gtype
71
- signals = GObject.signal_list_ids gtype
72
- signal_query = GObject.signal_query signals.first
73
- _(signal_query.n_params).must_equal 1
74
- _(signal_query.param_types.size).must_equal 1
75
- end
76
- end
77
-
78
- describe GObject::Binding do
79
- it "is created with GObject::Object#bind_property" do
80
- source = Regress::TestObj.constructor
81
- target = Regress::TestObj.constructor
82
- binding = source.bind_property "double", target, "double", :default
83
- _(binding).must_be_kind_of GObject::Binding
84
- end
85
-
86
- describe "an instance" do
87
- let(:source) { Regress::TestObj.constructor }
88
- let(:target) { Regress::TestObj.constructor }
89
- let(:binding) { source.bind_property "double", target, "double", :default }
90
-
91
- it 'can read the property "target-property" with #get_property' do
92
- _(binding.get_property("target-property")).must_equal "double"
93
- end
94
-
95
- it 'can read the property "target-property" with #target_property' do
96
- _(binding.target_property).must_equal "double"
97
- end
98
-
99
- it 'cannot write the property "target-property" with #target_property=' do
100
- _(binding).wont_respond_to :target_property=
101
- end
102
- end
103
- end
104
-
105
- describe GObject::ParamSpec do
106
- it "has a generated field accessor for #flags but not #get_flags method" do
107
- pspec = GObject.param_spec_int("foo", "foo bar",
108
- "The Foo Bar Property",
109
- 10, 20, 15,
110
- 3)
111
- _(pspec).wont_respond_to :get_flags
112
- _(pspec.method(:flags).original_name).must_equal :flags
113
- end
114
-
115
- it "aliases #get_name to #name instead of having a separate field accessor" do
116
- pspec = GObject.param_spec_int("foo", "foo bar",
117
- "The Foo Bar Property",
118
- 10, 20, 15,
119
- 3)
120
- _(pspec).must_respond_to :get_name
121
- _(pspec.method(:name).original_name).must_equal :get_name
122
- end
123
- end
124
- end
@@ -1,38 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require "gir_ffi_test_helper"
4
-
5
- GirFFI.setup :Gst
6
- Gst.init []
7
-
8
- # Tests behavior of objects in the generated Gio namespace.
9
- describe "the generated Gst module" do
10
- describe "Gst::FakeSink" do
11
- let(:instance) { Gst::ElementFactory.make("fakesink", "sink") }
12
-
13
- it "allows the handoff signal to be connected and emitted" do
14
- a = nil
15
- instance.signal_connect("handoff") { a = 10 }
16
- GObject.signal_emit(instance, "handoff")
17
- _(a).must_equal 10
18
- end
19
-
20
- it "correctly fetches the name" do
21
- _(instance.name).must_equal "sink"
22
- end
23
-
24
- it "allows the can-activate-push property to be read" do
25
- _(instance.get_property("can-activate-push")).must_equal true
26
- end
27
- end
28
-
29
- describe "Gst::AutoAudioSink" do
30
- let(:instance) { Gst::ElementFactory.make("autoaudiosink", "audiosink") }
31
-
32
- it "correctly fetches the name" do
33
- skip "Audio sink was not created" unless instance
34
- _(instance.get_name).must_equal "audiosink"
35
- _(instance.name).must_equal "audiosink"
36
- end
37
- end
38
- end
@@ -1,32 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require "gir_ffi_test_helper"
4
-
5
- GirFFI.setup :GtkSource
6
-
7
- # Tests behavior of objects in the generated GtkSource namespace.
8
- describe "The generated GtkSource module" do
9
- describe "GtkSource::CompletionContext" do
10
- let(:instance) { GtkSource::CompletionContext.new }
11
-
12
- it "allows adding proposals" do
13
- # Interface changed in GtkSourceView 3.24
14
- proposals = if GtkSource::CompletionItem.instance_methods.include? :set_label
15
- Array.new(3) do |i|
16
- GtkSource::CompletionItem.new.tap do |item|
17
- item.label = "Proposal #{i}"
18
- item.text = "Proposal #{i}"
19
- item.info = "blah #{i}"
20
- end
21
- end
22
- else
23
- [
24
- GtkSource::CompletionItem.new("Proposal 1", "Proposal 1", nil, "blah 1"),
25
- GtkSource::CompletionItem.new("Proposal 2", "Proposal 2", nil, "blah 2"),
26
- GtkSource::CompletionItem.new("Proposal 3", "Proposal 3", nil, "blah 3")
27
- ]
28
- end
29
- instance.add_proposals nil, proposals, true
30
- end
31
- end
32
- end
@@ -1,22 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require "gir_ffi_test_helper"
4
-
5
- GirFFI.setup :GTop
6
-
7
- # Tests generated methods and functions in the GTop namespace. This namespace
8
- # contains types with bad names, like 'glibtop_cpu'.
9
- describe "The generated GTop module" do
10
- describe "Glibtop" do
11
- it "is a valid struct class" do
12
- # Superclass is either BoxedBase or StructBase, depending on library
13
- # versions. This means StructBase is always one of the ancestors.
14
- assert GTop::Glibtop < GirFFI::StructBase
15
- end
16
-
17
- it "can be created using Glibtop.init" do
18
- instance = GTop::Glibtop.init
19
- _(instance).must_be_kind_of GTop::Glibtop
20
- end
21
- end
22
- end
@@ -1,17 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require "gir_ffi_test_helper"
4
-
5
- GirFFI.setup :PangoFT2
6
-
7
- # Tests generated methods and functions in the PangoFT2 namespace.
8
- describe PangoFT2 do
9
- describe PangoFT2::FontMap do
10
- it "has a working method #load_font" do
11
- font_map = PangoFT2::FontMap.new
12
- context = font_map.create_context
13
- font_description = Pango::FontDescription.new
14
- font_map.load_font context, font_description
15
- end
16
- end
17
- end
@@ -1,24 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require "gir_ffi_test_helper"
4
-
5
- GirFFI.setup :Pango
6
-
7
- # Tests generated methods and functions in the Pango namespace.
8
- describe Pango do
9
- describe Pango::Language do
10
- it "has a working method #get_scripts" do
11
- lang = Pango::Language.from_string "ja"
12
- result = lang.get_scripts
13
-
14
- if result.is_a? GirFFI::SizedArray
15
- scripts = result
16
- else
17
- ptr, size = *result
18
- scripts = GirFFI::SizedArray.new Pango::Script, size, ptr
19
- end
20
-
21
- _(scripts).must_be :==, [:han, :katakana, :hiragana]
22
- end
23
- end
24
- end
@@ -1,4062 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require "gir_ffi_test_helper"
4
-
5
- GirFFI.setup :Regress
6
-
7
- class ConcreteDrawable < Regress::TestInheritDrawable
8
- end
9
-
10
- GirFFI.define_type ConcreteDrawable
11
-
12
- # Tests generated methods and functions in the Regress namespace.
13
- describe Regress do
14
- describe Regress::Lib do
15
- it "extends FFI::Library" do
16
- _(Regress::Lib.singleton_class).must_be :include?, FFI::Library
17
- end
18
- end
19
- it "has the constant ANNOTATION_CALCULATED_DEFINE" do
20
- _(Regress::ANNOTATION_CALCULATED_DEFINE).must_equal 100
21
- end
22
- it "has the constant ANNOTATION_CALCULATED_LARGE" do
23
- skip "Constant is marked with the wrong type"
24
- _(Regress::ANNOTATION_CALCULATED_LARGE).must_equal 10_000_000_000
25
- end
26
- it "has the constant ANNOTATION_CALCULATED_LARGE_DIV" do
27
- _(Regress::ANNOTATION_CALCULATED_LARGE_DIV).must_equal 1_000_000
28
- end
29
- describe "Regress::ATestError" do
30
- it "has the member :code0" do
31
- _(Regress::ATestError[:code0]).must_equal 0
32
- end
33
-
34
- it "has the member :code1" do
35
- _(Regress::ATestError[:code1]).must_equal 1
36
- end
37
-
38
- it "has the member :code2" do
39
- _(Regress::ATestError[:code2]).must_equal 2
40
- end
41
- end
42
-
43
- describe "Regress::AnAnonymousUnion" do
44
- let(:instance) { Regress::AnAnonymousUnion.new }
45
-
46
- it "has a writable field x" do
47
- _(instance.x).must_equal 0
48
- instance.x = 42
49
- _(instance.x).must_equal 42
50
- end
51
-
52
- it "has a writable field a" do
53
- skip "Anonymous union fields are not exposed in the GIR data"
54
- end
55
-
56
- it "has a writable field padding" do
57
- skip "Anonymous union fields are not exposed in the GIR data"
58
- end
59
- end
60
-
61
- describe "Regress::AnnotationBitfield" do
62
- it "has the member :foo" do
63
- _(Regress::AnnotationBitfield[:foo]).must_equal 1
64
- end
65
-
66
- it "has the member :bar" do
67
- _(Regress::AnnotationBitfield[:bar]).must_equal 2
68
- end
69
- end
70
-
71
- describe "Regress::AnnotationFields" do
72
- let(:instance) { Regress::AnnotationFields.new }
73
-
74
- it "has a writable field field1" do
75
- _(instance.field1).must_equal 0
76
- instance.field1 = 42
77
- _(instance.field1).must_equal 42
78
- end
79
-
80
- it "has a writable field arr" do
81
- _(instance.arr).must_be_nil
82
- instance.arr = [1, 2, 3]
83
- # TODO: len should be set automatically
84
- instance.len = 3
85
- _(instance.arr.to_a).must_equal [1, 2, 3]
86
- _(instance.len).must_equal 3
87
- end
88
-
89
- it "has a writable field len" do
90
- skip "len should not be set independently"
91
- end
92
- end
93
-
94
- describe "Regress::AnnotationObject" do
95
- let(:instance) { Regress::AnnotationObject.new }
96
-
97
- it "has an attribute org.example.Test" do
98
- info = get_introspection_data("Regress", "AnnotationObject")
99
- _(info.attribute("org.example.Test")).must_equal "cows"
100
- end
101
-
102
- it "has a working method #allow_none" do
103
- _(instance.allow_none("hello!")).must_be_nil
104
- _(instance.allow_none(nil)).must_be_nil
105
- _(instance.allow_none).must_be_nil
106
- end
107
-
108
- it "has a working method #calleeowns" do
109
- result, object = instance.calleeowns
110
- _(result).must_equal 1
111
- _(object).must_be_nil
112
- end
113
-
114
- it "has a working method #calleesowns" do
115
- result, toown1, toown2 = instance.calleesowns
116
- _(result).must_equal 1
117
- _(toown1).must_be_nil
118
- _(toown2).must_be_nil
119
- end
120
-
121
- it "has a working method #compute_sum" do
122
- instance.compute_sum [1, 2, 3]
123
- pass
124
- end
125
-
126
- it "has a working method #compute_sum_n" do
127
- instance.compute_sum_n [1, 2, 3]
128
- pass
129
- end
130
-
131
- it "has a working method #compute_sum_nz" do
132
- instance.compute_sum_nz [1, 2, 3]
133
- pass
134
- end
135
-
136
- it "has a working method #create_object" do
137
- result = instance.create_object
138
- _(result).must_equal instance
139
- end
140
-
141
- it "has a working method #do_not_use" do
142
- # TODO: Handle deprecation
143
- _(instance.do_not_use).must_be_nil
144
- end
145
-
146
- it "has a working method #extra_annos" do
147
- info = get_method_introspection_data("Regress", "AnnotationObject", "extra_annos")
148
- _(info.attribute("org.foobar")).must_equal "testvalue"
149
-
150
- _(instance.extra_annos).must_be_nil
151
- end
152
-
153
- it "has a working method #foreach" do
154
- a = 1
155
- instance.foreach { a += 1 }
156
- _(a).must_equal 1
157
- end
158
-
159
- it "has a working method #get_hash" do
160
- result = instance.get_hash
161
- hash = result.to_hash
162
- _(hash["one"]).must_equal instance
163
- _(hash["two"]).must_equal instance
164
- end
165
-
166
- it "has a working method #get_objects" do
167
- list = instance.get_objects
168
- _(list.to_a).must_equal [instance]
169
- end
170
-
171
- it "has a working method #get_strings" do
172
- list = instance.get_strings
173
- _(list.to_a).must_equal %w(bar regress_annotation)
174
- end
175
-
176
- it "has a working method #hidden_self" do
177
- _(instance.hidden_self).must_be_nil
178
- end
179
-
180
- it "has a working method #in" do
181
- # TODO: Automatically convert to pointer argument
182
- ptr = FFI::MemoryPointer.new(:int, 1)
183
- ptr.put_int 0, 2342
184
- _(instance.in(ptr)).must_equal 2342
185
- end
186
-
187
- it "has a working method #inout" do
188
- _(instance.inout(2342)).must_equal [2343, 2343]
189
- end
190
-
191
- it "has a working method #inout2" do
192
- _(instance.inout2(2342)).must_equal [2343, 2343]
193
- end
194
-
195
- it "has a working method #inout3" do
196
- _(instance.inout3(2342)).must_equal [2343, 2342]
197
- end
198
-
199
- it "has a working method #method" do
200
- _(instance.method).must_equal 1
201
- end
202
-
203
- it "has a working method #notrans" do
204
- _(instance.notrans).must_be_nil
205
- end
206
-
207
- it "has a working method #out" do
208
- _(instance.out).must_equal [1, 2]
209
- end
210
-
211
- it "has a working method #parse_args" do
212
- _(instance.parse_args(%w(one two)).to_a).must_equal %w(one two)
213
- end
214
-
215
- it "has a working method #set_data" do
216
- # TODO: Explicitely allow or deny passing a string here.
217
- _(instance.set_data([1, 2, 3])).must_be_nil
218
- end
219
-
220
- it "has a working method #set_data2" do
221
- _(instance.set_data2([1, -2, 3])).must_be_nil
222
- end
223
-
224
- it "has a working method #set_data3" do
225
- _(instance.set_data3([1, 2, 3])).must_be_nil
226
- end
227
-
228
- it "has a working method #string_out" do
229
- _(instance.string_out).must_equal [false, nil]
230
- end
231
-
232
- it "has a working method #use_buffer" do
233
- skip "Ingoing pointer argument conversion is not implemented yet"
234
- _(instance.use_buffer(FFI::MemoryPointer.new(:void, 1))).must_be_nil
235
- end
236
-
237
- it "has a working method #watch_full" do
238
- instance.watch {}
239
- end
240
-
241
- it "has a working method #with_voidp" do
242
- # NOTE: Anything implementing #to_ptr could be passed in here
243
- obj = Regress::AnnotationObject.new
244
- _(instance.with_voidp(obj)).must_be_nil
245
- end
246
-
247
- describe "its 'function-property' property" do
248
- it "can be retrieved with #get_property" do
249
- _(instance.get_property("function-property")).must_be_nil
250
- end
251
-
252
- it "can be retrieved with #function_property" do
253
- _(instance.function_property).must_be_nil
254
- end
255
-
256
- it "can be set with #set_property" do
257
- instance.set_property("function-property", proc {})
258
- # AnnotationObject doesn't actually store stuff
259
- _(instance.function_property).must_be_nil
260
- end
261
-
262
- it "can be set with #function_property=" do
263
- instance.function_property = proc {}
264
- # AnnotationObject doesn't actually store stuff
265
- _(instance.get_property("function-property")).must_be_nil
266
- end
267
- end
268
-
269
- describe "its 'string-property' property" do
270
- it "can be retrieved with #get_property" do
271
- _(instance.get_property("string-property")).must_be_nil
272
- end
273
-
274
- it "can be retrieved with #string_property" do
275
- _(instance.string_property).must_be_nil
276
- end
277
-
278
- it "can be set with #set_property" do
279
- instance.set_property("string-property", "hello 42")
280
- # AnnotationObject doesn't actually store stuff
281
- _(instance.string_property).must_be_nil
282
- end
283
-
284
- it "can be set with #string_property=" do
285
- instance.string_property = "hello 42"
286
- # AnnotationObject doesn't actually store stuff
287
- _(instance.get_property("string-property")).must_be_nil
288
- end
289
- end
290
-
291
- describe "its 'tab-property' property" do
292
- it "can be retrieved with #get_property" do
293
- _(instance.get_property("tab-property")).must_be_nil
294
- end
295
-
296
- it "can be retrieved with #tab_property" do
297
- _(instance.tab_property).must_be_nil
298
- end
299
-
300
- it "can be set with #set_property" do
301
- instance.set_property("tab-property", "hello 42")
302
- # AnnotationObject doesn't actually store stuff
303
- _(instance.tab_property).must_be_nil
304
- end
305
-
306
- it "can be set with #tab_property=" do
307
- instance.tab_property = "hello 42"
308
- # AnnotationObject doesn't actually store stuff
309
- _(instance.get_property("tab-property")).must_be_nil
310
- end
311
- end
312
-
313
- it "handles the 'attribute-signal' signal" do
314
- signal_info = get_signal_introspection_data("Regress",
315
- "AnnotationObject",
316
- "attribute-signal")
317
- argument_infos = signal_info.args
318
- _(argument_infos.first.attribute("some.annotation.foo1")).must_equal "val1"
319
- _(argument_infos.last.attribute("some.annotation.foo2")).must_equal "val2"
320
-
321
- result = nil
322
- instance.signal_connect "attribute-signal" do |_obj, _arg1, _arg2, _user_data|
323
- # This signal uses a null marshaller, so the return value is never passed on.
324
- result = "hello"
325
- end
326
-
327
- GObject.signal_emit instance, "attribute-signal", "foo", "bar"
328
- _(result).must_equal "hello"
329
- end
330
-
331
- it "handles the 'doc-empty-arg-parsing' signal" do
332
- test = nil
333
- instance.signal_connect "doc-empty-arg-parsing" do |_obj, arg1, _user_data|
334
- test = arg1
335
- end
336
-
337
- result = GObject.signal_emit instance, "doc-empty-arg-parsing", FFI::Pointer.new(123)
338
- _(result).must_be_nil
339
- _(test.address).must_equal 123
340
- end
341
-
342
- it "handles the 'list-signal' signal" do
343
- result = nil
344
- instance.signal_connect "list-signal" do |_obj, list, _user_data|
345
- result = list
346
- end
347
-
348
- # TODO: Automatically convert to GLib::List
349
- GObject.signal_emit instance, "list-signal", GLib::List.from(:utf8, %w(foo bar))
350
- _(result.to_a).must_equal %w(foo bar)
351
- end
352
-
353
- it "handles the 'string-signal' signal" do
354
- result = nil
355
- instance.signal_connect "string-signal" do |_obj, string, _user_data|
356
- result = string
357
- end
358
-
359
- GObject.signal_emit instance, "string-signal", "foo"
360
- _(result).must_equal "foo"
361
- end
362
- end
363
-
364
- describe "Regress::AnnotationStruct" do
365
- let(:instance) { Regress::AnnotationStruct.new }
366
-
367
- it "has a writable field objects" do
368
- _(instance.objects.to_a).must_equal [nil] * 10
369
-
370
- obj = Regress::AnnotationObject.new
371
- instance.objects = [nil] * 5 + [obj] + [nil] * 4
372
- _(instance.objects.to_a[5]).must_equal obj
373
- end
374
- end
375
-
376
- describe "Regress::AnonymousUnionAndStruct" do
377
- let(:instance) { Regress::AnonymousUnionAndStruct.new }
378
-
379
- before { skip_below "1.49.1" }
380
-
381
- it "has a writable field x" do
382
- instance.x = 42
383
- _(instance.x).must_equal 42
384
- end
385
-
386
- it "has a writable field a" do
387
- skip "Anonymous struct fields are not exposed in the GIR data"
388
- end
389
-
390
- it "has a writable field b" do
391
- skip "Anonymous struct fields are not exposed in the GIR data"
392
- end
393
-
394
- it "has a writable field padding" do
395
- skip "Anonymous union fields are not exposed in the GIR data"
396
- end
397
- end
398
- it "has the constant BOOL_CONSTANT" do
399
- _(Regress::BOOL_CONSTANT).must_equal true
400
- end
401
-
402
- it "has the constant DOUBLE_CONSTANT" do
403
- assert_equal 44.22, Regress::DOUBLE_CONSTANT
404
- end
405
-
406
- it "has the constant FOO_DEFINE_SHOULD_BE_EXPOSED" do
407
- _(Regress::FOO_DEFINE_SHOULD_BE_EXPOSED).must_equal "should be exposed"
408
- end
409
-
410
- it "has the constant FOO_FLAGS_SECOND_AND_THIRD" do
411
- skip_below "1.55.2"
412
- _(Regress::FOO_FLAGS_SECOND_AND_THIRD).must_equal 6
413
- end
414
-
415
- it "has the constant FOO_PIE_IS_TASTY" do
416
- _(Regress::FOO_PIE_IS_TASTY).must_equal 3.141590
417
- end
418
-
419
- it "has the constant FOO_SUCCESS_INT" do
420
- _(Regress::FOO_SUCCESS_INT).must_equal 4408
421
- end
422
-
423
- describe "Regress::FooASingle" do
424
- it "has the member :foo_some_single_enum" do
425
- _(Regress::FooASingle[:foo_some_single_enum]).must_equal 0
426
- end
427
- end
428
-
429
- describe "Regress::FooAddressType" do
430
- it "has the member :invalid" do
431
- _(Regress::FooAddressType[:invalid]).must_equal 0
432
- end
433
-
434
- it "has the member :ipv4" do
435
- _(Regress::FooAddressType[:ipv4]).must_equal 1
436
- end
437
-
438
- it "has the member :ipv6" do
439
- _(Regress::FooAddressType[:ipv6]).must_equal 2
440
- end
441
- end
442
-
443
- describe "Regress::FooBRect" do
444
- let(:instance) { Regress::FooBRect.wrap(Regress::FooBRect::Struct.new.to_ptr) }
445
-
446
- it "has a writable field x" do
447
- _(instance.x).must_equal 0.0
448
- instance.x = 23.42
449
- _(instance.x).must_equal 23.42
450
- end
451
-
452
- it "has a writable field y" do
453
- _(instance.y).must_equal 0.0
454
- instance.y = 23.42
455
- _(instance.y).must_equal 23.42
456
- end
457
-
458
- it "creates an instance using #new" do
459
- skip "This function is defined in the header but not implemented"
460
- end
461
-
462
- it "has a working method #add" do
463
- skip "This function is defined in the header but not implemented"
464
- end
465
- end
466
-
467
- describe "Regress::FooBUnion" do
468
- let(:instance) { Regress::FooBUnion.wrap(Regress::FooBUnion::Struct.new.to_ptr) }
469
-
470
- it "has a writable field type" do
471
- _(instance.type).must_equal 0
472
- instance.type = 42
473
- _(instance.type).must_equal 42
474
- end
475
-
476
- it "has a writable field v" do
477
- _(instance.v).must_equal 0.0
478
- instance.v = 23.42
479
- _(instance.v).must_equal 23.42
480
- end
481
-
482
- it "has a writable field rect" do
483
- _(instance.rect).must_be_nil
484
- rect = Regress::FooBRect.wrap(Regress::FooBRect::Struct.new.to_ptr)
485
- rect.x = 42
486
- rect.y = 23
487
- skip "Cannot copy FooBRect structs"
488
- instance.rect = rect
489
- _(instance.rect.x).must_equal 42.0
490
- _(instance.rect.y).must_equal 23.0
491
- end
492
-
493
- it "creates an instance using #new" do
494
- skip "This function is defined in the header but not implemented"
495
- end
496
-
497
- it "has a working method #get_contained_type" do
498
- skip "This function is defined in the header but not implemented"
499
- end
500
- end
501
-
502
- describe "Regress::FooBoxed" do
503
- let(:instance) { Regress::FooBoxed.new }
504
-
505
- it "creates an instance using #new" do
506
- _(instance).must_be_instance_of Regress::FooBoxed
507
- end
508
-
509
- it "has a working method #method" do
510
- _(instance.method).must_be_nil
511
- end
512
- end
513
-
514
- describe "Regress::FooBuffer" do
515
- let(:instance) { Regress::FooBuffer.new }
516
-
517
- it "creates an instance using #new" do
518
- _(instance).must_be_instance_of Regress::FooBuffer
519
- end
520
-
521
- it "has a working method #some_method" do
522
- _(instance.some_method).must_be_nil
523
- end
524
- end
525
-
526
- describe "Regress::FooDBusData" do
527
- let(:instance) { Regress::FooDBusData.new }
528
-
529
- it "creates an instance using #new" do
530
- _(instance).must_be_instance_of Regress::FooDBusData
531
- end
532
-
533
- it "has a working method #method" do
534
- skip "This function is defined in the header but not implemented"
535
- end
536
- end
537
-
538
- describe "Regress::FooEnumFullname" do
539
- it "has the member :one" do
540
- _(Regress::FooEnumFullname[:one]).must_equal 1
541
- end
542
-
543
- it "has the member :two" do
544
- _(Regress::FooEnumFullname[:two]).must_equal 2
545
- end
546
-
547
- it "has the member :three" do
548
- _(Regress::FooEnumFullname[:three]).must_equal 3
549
- end
550
- end
551
-
552
- describe "Regress::FooEnumNoType" do
553
- it "has the member :un" do
554
- _(Regress::FooEnumNoType[:un]).must_equal 1
555
- end
556
-
557
- it "has the member :deux" do
558
- _(Regress::FooEnumNoType[:deux]).must_equal 2
559
- end
560
-
561
- it "has the member :trois" do
562
- _(Regress::FooEnumNoType[:trois]).must_equal 3
563
- end
564
-
565
- it "has the member :neuf" do
566
- _(Regress::FooEnumNoType[:neuf]).must_equal 9
567
- end
568
- end
569
-
570
- describe "Regress::FooEnumType" do
571
- it "has the member :alpha" do
572
- _(Regress::FooEnumType[:alpha]).must_equal 0
573
- end
574
-
575
- it "has the member :beta" do
576
- _(Regress::FooEnumType[:beta]).must_equal 1
577
- end
578
-
579
- it "has the member :delta" do
580
- _(Regress::FooEnumType[:delta]).must_equal 2
581
- end
582
-
583
- it "has a working function #method" do
584
- skip "This function is defined in the header but not implemented"
585
- end
586
-
587
- it "has a working function #returnv" do
588
- skip "This function is defined in the header but not implemented"
589
- end
590
- end
591
-
592
- describe "Regress::FooError" do
593
- it "has the member :good" do
594
- _(Regress::FooError[:good]).must_equal 0
595
- end
596
-
597
- it "has the member :bad" do
598
- _(Regress::FooError[:bad]).must_equal 1
599
- end
600
-
601
- it "has the member :ugly" do
602
- _(Regress::FooError[:ugly]).must_equal 2
603
- end
604
-
605
- it "has a working function #quark" do
606
- quark = Regress::FooError.quark
607
- _(GLib.quark_to_string(quark)).must_equal "regress_foo-error-quark"
608
- end
609
- end
610
-
611
- describe "Regress::FooEvent" do
612
- let(:instance) { Regress::FooEvent.new }
613
-
614
- it "has a writable field type" do
615
- _(instance.type).must_equal 0
616
- instance.type = 23
617
- _(instance.type).must_equal 23
618
- end
619
-
620
- it "has a writable field any" do
621
- _(instance.any.send_event).must_equal 0
622
- any = Regress::FooEventAny.new
623
- any.send_event = 42
624
- instance.any = any
625
- _(instance.any.send_event).must_equal 42
626
- end
627
-
628
- it "has a writable field expose" do
629
- _(instance.expose.send_event).must_equal 0
630
- _(instance.expose.count).must_equal 0
631
- expose = Regress::FooEventExpose.new
632
- expose.send_event = 23
633
- expose.count = 14
634
- instance.expose = expose
635
- _(instance.expose.send_event).must_equal 23
636
- _(instance.expose.count).must_equal 14
637
- end
638
- end
639
-
640
- describe "Regress::FooEventAny" do
641
- let(:instance) { Regress::FooEventAny.new }
642
-
643
- it "has a writable field send_event" do
644
- _(instance.send_event).must_equal 0
645
- instance.send_event = 23
646
- _(instance.send_event).must_equal 23
647
- end
648
- end
649
-
650
- describe "Regress::FooEventExpose" do
651
- let(:instance) { Regress::FooEventExpose.new }
652
-
653
- it "has a writable field send_event" do
654
- _(instance.send_event).must_equal 0
655
- instance.send_event = 23
656
- _(instance.send_event).must_equal 23
657
- end
658
-
659
- it "has a writable field count" do
660
- _(instance.count).must_equal 0
661
- instance.count = 42
662
- _(instance.count).must_equal 42
663
- end
664
- end
665
-
666
- describe "Regress::FooFlagsNoType" do
667
- it "has the member :ett" do
668
- _(Regress::FooFlagsNoType[:ett]).must_equal 1
669
- end
670
-
671
- it "has the member :tva" do
672
- _(Regress::FooFlagsNoType[:tva]).must_equal 2
673
- end
674
-
675
- it "has the member :fyra" do
676
- _(Regress::FooFlagsNoType[:fyra]).must_equal 4
677
- end
678
- end
679
-
680
- describe "Regress::FooFlagsType" do
681
- it "has the member :first" do
682
- _(Regress::FooFlagsType[:first]).must_equal 1
683
- end
684
-
685
- it "has the member :second" do
686
- _(Regress::FooFlagsType[:second]).must_equal 2
687
- end
688
-
689
- it "has the member :third" do
690
- _(Regress::FooFlagsType[:third]).must_equal 4
691
- end
692
- end
693
-
694
- describe "Regress::FooForeignStruct" do
695
- let(:instance) { Regress::FooForeignStruct.new }
696
-
697
- it "has a writable field regress_foo" do
698
- _(instance.regress_foo).must_equal 0
699
- instance.regress_foo = 143
700
- _(instance.regress_foo).must_equal 143
701
- end
702
-
703
- it "creates an instance using #new" do
704
- _(instance).must_be_instance_of Regress::FooForeignStruct
705
- end
706
-
707
- it "has a working method #copy" do
708
- instance.regress_foo = 585
709
- result = instance.copy
710
- instance.regress_foo = 0
711
- _(result.regress_foo).must_equal 585
712
- end
713
- end
714
-
715
- describe "Regress::FooInterface" do
716
- it "has a working function #static_method" do
717
- _(Regress::FooInterface.static_method(42)).must_be_nil
718
- end
719
-
720
- it "has a working method #do_regress_foo" do
721
- instance = Regress::FooObject.new
722
- _(instance).must_be_kind_of Regress::FooInterface
723
- _(instance.do_regress_foo(42)).must_be_nil
724
- end
725
- end
726
-
727
- describe "Regress::FooObject" do
728
- let(:instance) { Regress::FooObject.new }
729
-
730
- it "creates an instance using #new" do
731
- _(instance).must_be_instance_of Regress::FooObject
732
- end
733
-
734
- it "creates an instance using #new_as_super" do
735
- other_instance = Regress::FooObject.new_as_super
736
- _(other_instance).must_be_instance_of Regress::FooObject
737
- end
738
-
739
- it "has a working function #a_global_method" do
740
- skip "This function is defined in the header but not implemented"
741
- end
742
-
743
- it "has a working function #get_default" do
744
- _(Regress::FooObject.get_default).must_be_nil
745
- end
746
-
747
- it "has a working function #static_meth" do
748
- skip "This function is defined in the header but not implemented"
749
- end
750
-
751
- it "has a working method #append_new_stack_layer" do
752
- _(instance.append_new_stack_layer(42)).must_be_nil
753
- end
754
-
755
- it "has a working method #dup_name" do
756
- _(instance.dup_name).must_equal "regress_foo"
757
- end
758
-
759
- it "has a working method #external_type" do
760
- result = instance.external_type
761
- _(result).must_be_nil
762
- end
763
-
764
- it "has a working method #get_name" do
765
- _(instance.get_name).must_equal "regress_foo"
766
- end
767
-
768
- it "has a working method #handle_glyph" do
769
- skip "This function is defined in the header but not implemented"
770
- end
771
-
772
- it "has a working method #is_it_time_yet" do
773
- _(instance.is_it_time_yet(Time.now.to_i)).must_be_nil
774
- end
775
-
776
- it "has a working method #read" do
777
- _(instance.read(12, 13)).must_be_nil
778
- end
779
-
780
- it "has a working method #various" do
781
- skip "This function is defined in the header but not implemented"
782
- end
783
-
784
- it "has a working method #virtual_method" do
785
- skip "This function is defined in the header but not implemented"
786
- end
787
-
788
- describe "its 'string' property" do
789
- it "can be retrieved with #get_property" do
790
- _(instance.get_property("string")).must_be_nil
791
- end
792
-
793
- it "can be retrieved with #string" do
794
- _(instance.string).must_be_nil
795
- end
796
-
797
- it "can be set with #set_property" do
798
- instance.set_property "string", "hello 42"
799
- # FooObject doesn't actually store stuff
800
- _(instance.string).must_be_nil
801
- _(instance.get_property("string")).must_be_nil
802
- end
803
-
804
- it "can be set with #string=" do
805
- instance.string = "hello 42"
806
- # FooObject doesn't actually store stuff
807
- _(instance.string).must_be_nil
808
- _(instance.get_property("string")).must_be_nil
809
- end
810
- end
811
-
812
- it "handles the 'signal' signal" do
813
- instance.signal_connect "signal" do
814
- "hello"
815
- end
816
-
817
- result = GObject.signal_emit instance, "signal"
818
- _(result).must_equal "hello"
819
- end
820
- end
821
-
822
- describe "Regress::FooOtherObject" do
823
- it "is derived from GObject::Object" do
824
- _(Regress::FooOtherObject.superclass).must_equal GObject::Object
825
- end
826
- end
827
-
828
- describe "Regress::FooRectangle" do
829
- let(:instance) { Regress::FooRectangle.new }
830
-
831
- it "has a writable field x" do
832
- _(instance.x).must_equal 0
833
- instance.x = 23
834
- _(instance.x).must_equal 23
835
- end
836
-
837
- it "has a writable field y" do
838
- _(instance.y).must_equal 0
839
- instance.y = 23
840
- _(instance.y).must_equal 23
841
- end
842
-
843
- it "has a writable field width" do
844
- _(instance.width).must_equal 0
845
- instance.width = 23
846
- _(instance.width).must_equal 23
847
- end
848
-
849
- it "has a writable field height" do
850
- _(instance.height).must_equal 0
851
- instance.height = 23
852
- _(instance.height).must_equal 23
853
- end
854
-
855
- it "has a working method #add" do
856
- other_instance = Regress::FooRectangle.new
857
- result = instance.add other_instance
858
- # NOTE: inout annotation has no effect on the method receiver
859
- _(result).must_be_nil
860
- end
861
- end
862
-
863
- describe "Regress::FooStackLayer" do
864
- it "has the member :desktop" do
865
- _(Regress::FooStackLayer[:desktop]).must_equal 0
866
- end
867
-
868
- it "has the member :bottom" do
869
- _(Regress::FooStackLayer[:bottom]).must_equal 1
870
- end
871
-
872
- it "has the member :normal" do
873
- _(Regress::FooStackLayer[:normal]).must_equal 2
874
- end
875
-
876
- it "has the member :top" do
877
- _(Regress::FooStackLayer[:top]).must_equal 4
878
- end
879
-
880
- it "has the member :dock" do
881
- _(Regress::FooStackLayer[:dock]).must_equal 4
882
- end
883
-
884
- it "has the member :fullscreen" do
885
- _(Regress::FooStackLayer[:fullscreen]).must_equal 5
886
- end
887
-
888
- it "has the member :focused_window" do
889
- _(Regress::FooStackLayer[:focused_window]).must_equal 6
890
- end
891
-
892
- it "has the member :override_redirect" do
893
- _(Regress::FooStackLayer[:override_redirect]).must_equal 7
894
- end
895
-
896
- it "has the member :last" do
897
- _(Regress::FooStackLayer[:last]).must_equal 8
898
- end
899
- end
900
-
901
- describe "Regress::FooStruct" do
902
- let(:instance) { Regress::FooStruct.new }
903
-
904
- it "blocks access to the hidden struct field priv" do
905
- _(proc { instance.priv = nil }).must_raise NoMethodError
906
- _(proc { instance.priv }).must_raise NoMethodError
907
- end
908
-
909
- it "has a writable field member" do
910
- _(instance.member).must_equal 0
911
- instance.member = 23
912
- _(instance.member).must_equal 23
913
- end
914
- end
915
-
916
- describe "Regress::FooSubInterface" do
917
- let(:derived_klass) do
918
- Object.const_set("DerivedClass#{Sequence.next}",
919
- Class.new(Regress::FooObject))
920
- end
921
-
922
- def make_derived_instance
923
- derived_klass.send :include, Regress::FooSubInterface
924
- GirFFI.define_type derived_klass do |info|
925
- yield info if block_given?
926
- end
927
- derived_klass.new
928
- end
929
-
930
- it "has a working method #do_bar" do
931
- result = nil
932
- instance = make_derived_instance do |info|
933
- info.install_vfunc_implementation :do_bar, proc { |obj| result = obj.get_name }
934
- end
935
- instance.do_bar
936
- _(result).must_equal "regress_foo"
937
- end
938
-
939
- it "has a working method #do_baz" do
940
- a = nil
941
- instance = make_derived_instance do |info|
942
- # TODO: Do not pass callback again in user_data if destroy notifier is absent
943
- info.install_vfunc_implementation :do_baz,
944
- proc { |obj, callback, _user_data|
945
- callback.call
946
- a = obj.get_name
947
- }
948
- end
949
- b = nil
950
- instance.do_baz { b = "hello" }
951
- _(a).must_equal "regress_foo"
952
- _(b).must_equal "hello"
953
- end
954
-
955
- it "handles the 'destroy-event' signal" do
956
- a = nil
957
- instance = make_derived_instance
958
- instance.signal_connect "destroy-event" do
959
- a = "hello"
960
- end
961
- GObject.signal_emit instance, "destroy-event"
962
- _(a).must_equal "hello"
963
- end
964
- end
965
-
966
- describe "Regress::FooSubobject" do
967
- it "creates an instance using #new" do
968
- skip "This function is defined in the header but not implemented"
969
- end
970
- end
971
-
972
- describe "Regress::FooThingWithArray" do
973
- let(:instance) { Regress::FooThingWithArray.new }
974
-
975
- it "has a writable field x" do
976
- _(instance.x).must_equal 0
977
- instance.x = 23
978
- _(instance.x).must_equal 23
979
- end
980
-
981
- it "has a writable field y" do
982
- _(instance.y).must_equal 0
983
- instance.y = 23
984
- _(instance.y).must_equal 23
985
- end
986
-
987
- it "has a writable field lines" do
988
- _(instance.lines).must_be :==, [0] * 80
989
- instance.lines = (1..80).to_a
990
- _(instance.lines).must_be :==, (1..80).to_a
991
- end
992
-
993
- it "has a writable field data" do
994
- _(instance.data).must_equal FFI::Pointer::NULL
995
- instance.data = FFI::Pointer.new(23)
996
- _(instance.data).must_equal FFI::Pointer.new(23)
997
- end
998
- end
999
-
1000
- describe "Regress::FooUnion" do
1001
- let(:instance) { Regress::FooUnion.new }
1002
-
1003
- it "has a writable field regress_foo" do
1004
- _(instance.regress_foo).must_equal 0
1005
- instance.regress_foo = 23
1006
- _(instance.regress_foo).must_equal 23
1007
- end
1008
- end
1009
-
1010
- describe "Regress::FooUtilityStruct" do
1011
- let(:instance) { Regress::FooUtilityStruct.new }
1012
-
1013
- it "has a writable field bar" do
1014
- struct = Utility::Struct.new
1015
- struct.field = 23
1016
-
1017
- _(instance.bar.field).must_equal 0
1018
- instance.bar = struct
1019
- _(instance.bar.field).must_equal 23
1020
- end
1021
- end
1022
-
1023
- it "has the constant GI_SCANNER_ELSE" do
1024
- _(Regress::GI_SCANNER_ELSE).must_equal 3
1025
- end
1026
-
1027
- it "has the constant GI_SCANNER_IFDEF" do
1028
- _(Regress::GI_SCANNER_IFDEF).must_equal 3
1029
- end
1030
-
1031
- it "has the constant GUINT64_CONSTANT" do
1032
- _(Regress::GUINT64_CONSTANT).must_equal 18_446_744_073_709_551_615
1033
- end
1034
-
1035
- it "has the constant GUINT64_CONSTANTA" do
1036
- _(Regress::GUINT64_CONSTANTA).must_equal 18_446_744_073_709_551_615
1037
- end
1038
-
1039
- it "has the constant G_GINT64_CONSTANT" do
1040
- _(Regress::G_GINT64_CONSTANT).must_equal 1000
1041
- end
1042
-
1043
- it "has the constant INT_CONSTANT" do
1044
- assert_equal 4422, Regress::INT_CONSTANT
1045
- end
1046
-
1047
- it "has the constant LONG_STRING_CONSTANT" do
1048
- _(Regress::LONG_STRING_CONSTANT).must_equal %w(TYPE VALUE ENCODING CHARSET
1049
- LANGUAGE DOM INTL POSTAL PARCEL
1050
- HOME WORK PREF VOICE FAX MSG
1051
- CELL PAGER BBS MODEM CAR ISDN
1052
- VIDEO AOL APPLELINK ATTMAIL CIS
1053
- EWORLD INTERNET IBMMAIL MCIMAIL
1054
- POWERSHARE PRODIGY TLX X400 GIF
1055
- CGM WMF BMP MET PMB DIB PICT
1056
- TIFF PDF PS JPEG QTIME MPEG
1057
- MPEG2 AVI WAVE AIFF PCM X509
1058
- PGP).join(",")
1059
- end
1060
-
1061
- describe "Regress::LikeGnomeKeyringPasswordSchema" do
1062
- it "creates an instance using #new" do
1063
- obj = Regress::LikeGnomeKeyringPasswordSchema.new
1064
- _(obj).must_be_instance_of Regress::LikeGnomeKeyringPasswordSchema
1065
- end
1066
-
1067
- let(:instance) { Regress::LikeGnomeKeyringPasswordSchema.new }
1068
-
1069
- it "has a writable field dummy" do
1070
- _(instance.dummy).must_equal 0
1071
- instance.dummy = 42
1072
- _(instance.dummy).must_equal 42
1073
- end
1074
-
1075
- it "has a writable field attributes" do
1076
- skip "Introspection data cannot deal with type of this field yet"
1077
- end
1078
-
1079
- it "has a writable field dummy2" do
1080
- _(instance.dummy2).must_equal 0.0
1081
- instance.dummy2 = 42.42
1082
- _(instance.dummy2).must_equal 42.42
1083
- end
1084
- end
1085
-
1086
- describe "Regress::LikeXklConfigItem" do
1087
- let(:instance) { Regress::LikeXklConfigItem.new }
1088
- let(:name_array) { "foo".bytes.to_a + [0] * 29 }
1089
-
1090
- it "has a writable field name" do
1091
- # TODO: Should an array of gint8 be more string-like?
1092
- _(instance.name.to_a).must_equal [0] * 32
1093
- instance.name = name_array
1094
- _(instance.name.to_a).must_equal name_array
1095
- end
1096
-
1097
- it "has a working method #set_name" do
1098
- instance.set_name "foo"
1099
- _(instance.name.to_a).must_equal name_array
1100
- end
1101
- end
1102
-
1103
- it "has the constant MAXUINT64" do
1104
- _(Regress::MAXUINT64).must_equal 0xffff_ffff_ffff_ffff
1105
- end
1106
-
1107
- it "has the constant MININT64" do
1108
- _(Regress::MININT64).must_equal(-0x8000_0000_0000_0000)
1109
- end
1110
-
1111
- it "has the constant Mixed_Case_Constant" do
1112
- assert_equal 4423, Regress::Mixed_Case_Constant
1113
- end
1114
-
1115
- it "has the constant NEGATIVE_INT_CONSTANT" do
1116
- _(Regress::NEGATIVE_INT_CONSTANT).must_equal(-42)
1117
- end
1118
-
1119
- it "has the constant STRING_CONSTANT" do
1120
- assert_equal "Some String", Regress::STRING_CONSTANT
1121
- end
1122
-
1123
- describe "Regress::TestABCError" do
1124
- it "has the member :code1" do
1125
- _(Regress::TestABCError[:code1]).must_equal 1
1126
- end
1127
-
1128
- it "has the member :code2" do
1129
- _(Regress::TestABCError[:code2]).must_equal 2
1130
- end
1131
-
1132
- it "has the member :code3" do
1133
- _(Regress::TestABCError[:code3]).must_equal 3
1134
- end
1135
-
1136
- it "has a working function #quark" do
1137
- quark = Regress::TestABCError.quark
1138
- _(GLib.quark_to_string(quark)).must_equal "regress-test-abc-error"
1139
- end
1140
- end
1141
-
1142
- describe "Regress::TestBoxed" do
1143
- let(:instance) { Regress::TestBoxed.new_alternative_constructor1 123 }
1144
-
1145
- it "has a writable field some_int8" do
1146
- _(instance.some_int8).must_equal 123
1147
- instance.some_int8 = -43
1148
- _(instance.some_int8).must_equal(-43)
1149
- end
1150
-
1151
- it "has a writable field nested_a" do
1152
- _(instance.nested_a.some_int).must_equal 0
1153
- nested = Regress::TestSimpleBoxedA.new
1154
- nested.some_int = 12_345
1155
- instance.nested_a = nested
1156
- _(instance.nested_a.some_int).must_equal 12_345
1157
- end
1158
-
1159
- it "blocks access to the hidden struct field priv" do
1160
- _(proc { instance.priv = nil }).must_raise NoMethodError
1161
- _(proc { instance.priv }).must_raise NoMethodError
1162
- end
1163
-
1164
- it "creates an instance using #new" do
1165
- tb = Regress::TestBoxed.new
1166
- assert_instance_of Regress::TestBoxed, tb
1167
- end
1168
-
1169
- it "creates an instance using #new_alternative_constructor1" do
1170
- tb = Regress::TestBoxed.new_alternative_constructor1 1
1171
- assert_instance_of Regress::TestBoxed, tb
1172
- assert_equal 1, tb.some_int8
1173
- end
1174
-
1175
- it "creates an instance using #new_alternative_constructor2" do
1176
- tb = Regress::TestBoxed.new_alternative_constructor2 1, 2
1177
- assert_instance_of Regress::TestBoxed, tb
1178
- assert_equal 1 + 2, tb.some_int8
1179
- end
1180
-
1181
- it "creates an instance using #new_alternative_constructor3" do
1182
- tb = Regress::TestBoxed.new_alternative_constructor3 "54"
1183
- assert_instance_of Regress::TestBoxed, tb
1184
- assert_equal 54, tb.some_int8
1185
- end
1186
-
1187
- it "has non-zero positive result for #gtype" do
1188
- _(Regress::TestBoxed.gtype).must_be :>, 0
1189
- end
1190
-
1191
- it "has a working method #_not_a_method" do
1192
- # NOTE: This method is marked as moved, but this is not exposed in the typelib
1193
- instance._not_a_method
1194
- pass
1195
- end
1196
-
1197
- it "has a working method #copy" do
1198
- tb2 = instance.copy
1199
- assert_instance_of Regress::TestBoxed, tb2
1200
- assert_equal 123, tb2.some_int8
1201
- instance.some_int8 = 89
1202
- assert_equal 123, tb2.some_int8
1203
- end
1204
-
1205
- it "has a working method #equals" do
1206
- tb2 = Regress::TestBoxed.new_alternative_constructor2 120, 3
1207
- assert_equal true, instance.equals(tb2)
1208
- end
1209
- end
1210
-
1211
- describe "Regress::TestBoxedB" do
1212
- let(:instance) { Regress::TestBoxedB.new 8, 42 }
1213
-
1214
- it "has a writable field some_int8" do
1215
- _(instance.some_int8).must_equal 8
1216
- instance.some_int8 = -43
1217
- _(instance.some_int8).must_equal(-43)
1218
- end
1219
-
1220
- it "has a writable field some_long" do
1221
- _(instance.some_long).must_equal 42
1222
- instance.some_long = -4342
1223
- _(instance.some_long).must_equal(-4342)
1224
- end
1225
-
1226
- it "creates an instance using #new" do
1227
- tb = Regress::TestBoxedB.new 8, 42
1228
- assert_instance_of Regress::TestBoxedB, tb
1229
- end
1230
-
1231
- it "has a working method #copy" do
1232
- cp = instance.copy
1233
- _(cp).must_be_instance_of Regress::TestBoxedB
1234
- _(cp.some_int8).must_equal 8
1235
- _(cp.some_long).must_equal 42
1236
- instance.some_int8 = 2
1237
- _(cp.some_int8).must_equal 8
1238
- end
1239
- end
1240
-
1241
- describe "Regress::TestBoxedC" do
1242
- let(:instance) { Regress::TestBoxedC.new }
1243
-
1244
- it "has a writable field refcount" do
1245
- _(instance.refcount).must_equal 1
1246
- instance.refcount = 2
1247
- _(instance.refcount).must_equal 2
1248
- end
1249
-
1250
- it "has a writable field another_thing" do
1251
- _(instance.another_thing).must_equal 42
1252
- instance.another_thing = 4342
1253
- _(instance.another_thing).must_equal 4342
1254
- end
1255
-
1256
- it "creates an instance using #new" do
1257
- tb = Regress::TestBoxedC.new
1258
- assert_instance_of Regress::TestBoxedC, tb
1259
- end
1260
- end
1261
-
1262
- describe "Regress::TestBoxedD" do
1263
- let(:instance) { Regress::TestBoxedD.new "foo", 42 }
1264
-
1265
- it "creates an instance using #new" do
1266
- _(instance).must_be_instance_of Regress::TestBoxedD
1267
- end
1268
-
1269
- it "has a working method #copy" do
1270
- copy = instance.copy
1271
- _(copy).must_be_instance_of Regress::TestBoxedD
1272
- _(instance.get_magic).must_equal copy.get_magic
1273
- _(instance).wont_equal copy
1274
- end
1275
-
1276
- it "has a working method #free" do
1277
- skip "#free is used internally and shouldn't be exposed"
1278
- instance.free
1279
- pass
1280
- end
1281
-
1282
- it "has a working method #get_magic" do
1283
- _(instance.get_magic).must_equal "foo".length + 42
1284
- end
1285
- end
1286
-
1287
- describe "Regress::TestDEFError" do
1288
- it "has the member :code0" do
1289
- _(Regress::TestDEFError[:code0]).must_equal 0
1290
- end
1291
-
1292
- it "has the member :code1" do
1293
- _(Regress::TestDEFError[:code1]).must_equal 1
1294
- end
1295
-
1296
- it "has the member :code2" do
1297
- _(Regress::TestDEFError[:code2]).must_equal 2
1298
- end
1299
- end
1300
-
1301
- describe "Regress::TestEnum" do
1302
- it "has the member :value1" do
1303
- _(Regress::TestEnum[:value1]).must_equal 0
1304
- end
1305
-
1306
- it "has the member :value2" do
1307
- _(Regress::TestEnum[:value2]).must_equal 1
1308
- end
1309
-
1310
- it "has the member :value3" do
1311
- _(Regress::TestEnum[:value3]).must_equal(-1)
1312
- end
1313
-
1314
- it "has the member :value4" do
1315
- _(Regress::TestEnum[:value4]).must_equal 48
1316
- end
1317
-
1318
- it "has the member :value5" do
1319
- skip_below "1.55.2"
1320
- _(Regress::TestEnum[:value5]).must_equal 49
1321
- end
1322
-
1323
- it "has a working function #param" do
1324
- _(Regress::TestEnum.param(:value1)).must_equal("value1")
1325
- _(Regress::TestEnum.param(:value2)).must_equal("value2")
1326
- _(Regress::TestEnum.param(:value3)).must_equal("value3")
1327
- _(Regress::TestEnum.param(:value4)).must_equal("value4")
1328
- _(Regress::TestEnum.param(0)).must_equal("value1")
1329
- _(Regress::TestEnum.param(1)).must_equal("value2")
1330
- _(Regress::TestEnum.param(-1)).must_equal("value3")
1331
- _(Regress::TestEnum.param(48)).must_equal("value4")
1332
- end
1333
- end
1334
-
1335
- describe "Regress::TestEnumNoGEnum" do
1336
- it "has the member :evalue1" do
1337
- _(Regress::TestEnumNoGEnum[:evalue1]).must_equal 0
1338
- end
1339
-
1340
- it "has the member :evalue2" do
1341
- _(Regress::TestEnumNoGEnum[:evalue2]).must_equal 42
1342
- end
1343
-
1344
- it "has the member :evalue3" do
1345
- _(Regress::TestEnumNoGEnum[:evalue3]).must_equal 48
1346
- end
1347
- end
1348
-
1349
- describe "Regress::TestEnumUnsigned" do
1350
- it "has the member :value1" do
1351
- _(Regress::TestEnumUnsigned[:value1]).must_equal 1
1352
- end
1353
-
1354
- # NOTE In c, the positive and negative values are not distinguished
1355
- it "has the member :value2" do
1356
- _(Regress::TestEnumUnsigned[:value2]).must_equal(-2_147_483_648)
1357
- end
1358
- end
1359
-
1360
- describe "Regress::TestError" do
1361
- it "has the member :code1" do
1362
- _(Regress::TestError[:code1]).must_equal 1
1363
- end
1364
-
1365
- it "has the member :code2" do
1366
- _(Regress::TestError[:code2]).must_equal 2
1367
- end
1368
-
1369
- it "has the member :code3" do
1370
- _(Regress::TestError[:code3]).must_equal 3
1371
- end
1372
-
1373
- it "has a working function #quark" do
1374
- quark = Regress::TestError.quark
1375
- _(GLib.quark_to_string(quark)).must_equal "regress-test-error"
1376
- end
1377
- end
1378
-
1379
- describe "Regress::TestFlags" do
1380
- it "has the member :flag1" do
1381
- assert_equal 1, Regress::TestFlags[:flag1]
1382
- end
1383
- it "has the member :flag2" do
1384
- assert_equal 2, Regress::TestFlags[:flag2]
1385
- end
1386
- it "has the member :flag3" do
1387
- assert_equal 4, Regress::TestFlags[:flag3]
1388
- end
1389
- end
1390
-
1391
- describe "Regress::TestFloating" do
1392
- it "creates an instance using #new" do
1393
- o = Regress::TestFloating.new
1394
- _(o).must_be_instance_of Regress::TestFloating
1395
- end
1396
-
1397
- describe "an instance" do
1398
- before do
1399
- @o = Regress::TestFloating.new
1400
- end
1401
-
1402
- it "has a reference count of 1" do
1403
- assert_equal 1, object_ref_count(@o)
1404
- end
1405
-
1406
- it "has been sunk" do
1407
- _(@o).wont_be :floating?
1408
- end
1409
- end
1410
- end
1411
-
1412
- describe "Regress::TestFundamentalObject" do
1413
- it "does not have GObject::Object as an ancestor" do
1414
- refute(Regress::TestFundamentalObject < GObject::Object)
1415
- end
1416
-
1417
- it "cannot be instantiated" do
1418
- _(proc { Regress::TestFundamentalObject.new }).must_raise NoMethodError
1419
- end
1420
-
1421
- let(:derived_instance) { Regress::TestFundamentalSubObject.new "foo" }
1422
- let(:base_struct) { Regress::TestFundamentalObject::Struct.new derived_instance.to_ptr }
1423
-
1424
- it "has a working method #ref" do
1425
- _(base_struct[:refcount]).must_equal 1
1426
- derived_instance.ref
1427
- _(base_struct[:refcount]).must_equal 2
1428
- end
1429
-
1430
- it "has a working method #unref" do
1431
- _(base_struct[:refcount]).must_equal 1
1432
- derived_instance.unref
1433
- _(base_struct[:refcount]).must_equal 0
1434
- end
1435
- end
1436
-
1437
- describe "Regress::TestFundamentalSubObject" do
1438
- it "creates an instance using #new" do
1439
- obj = Regress::TestFundamentalSubObject.new "foo"
1440
- _(obj).must_be_instance_of Regress::TestFundamentalSubObject
1441
- end
1442
-
1443
- let(:instance) { Regress::TestFundamentalSubObject.new "foo" }
1444
-
1445
- it "is a subclass of TestFundamentalObject" do
1446
- assert_kind_of Regress::TestFundamentalObject, instance
1447
- end
1448
-
1449
- it "has a field :data storing the constructor parameter" do
1450
- assert_equal "foo", instance.struct[:data].to_utf8
1451
- end
1452
- end
1453
-
1454
- describe "Regress::TestInheritDrawable" do
1455
- it "cannot be instantiated" do
1456
- _(proc { Regress::TestInheritDrawable.new }).must_raise NoMethodError
1457
- end
1458
-
1459
- let(:derived_instance) { ConcreteDrawable.new }
1460
-
1461
- it "has a working method #do_foo" do
1462
- derived_instance.do_foo 42
1463
- pass
1464
- end
1465
-
1466
- it "has a working method #do_foo_maybe_throw" do
1467
- derived_instance.do_foo_maybe_throw 42
1468
- _(proc { derived_instance.do_foo_maybe_throw 41 }).must_raise GirFFI::GLibError
1469
- end
1470
-
1471
- it "has a working method #get_origin" do
1472
- _(derived_instance.get_origin).must_equal [0, 0]
1473
- end
1474
-
1475
- it "has a working method #get_size" do
1476
- _(derived_instance.get_size).must_equal [42, 42]
1477
- end
1478
- end
1479
-
1480
- describe "Regress::TestInheritPixmapObjectClass" do
1481
- it "has a writable field parent_class" do
1482
- skip "This is a class struct without defined class"
1483
- end
1484
- end
1485
-
1486
- describe "Regress::TestInterface" do
1487
- let(:derived_klass) do
1488
- klass = Object.const_set("DerivedClass#{Sequence.next}",
1489
- Class.new(Regress::FooObject))
1490
- klass.send :include, Regress::TestInterface
1491
- GirFFI.define_type klass do |info|
1492
- info.install_property GObject.param_spec_int("number", "Number", "Number",
1493
- 0, 10, 0,
1494
- readwrite: true, construct: true)
1495
- end
1496
- klass
1497
- end
1498
-
1499
- it "is a module" do
1500
- assert_instance_of Module, Regress::TestInterface
1501
- end
1502
-
1503
- it "extends InterfaceBase" do
1504
- _(Regress::TestInterface.singleton_class).must_include GirFFI::InterfaceBase
1505
- end
1506
-
1507
- it "has non-zero positive result for #gtype" do
1508
- _(Regress::TestInterface.gtype).must_be :>, 0
1509
- end
1510
-
1511
- it "has a working method #emit_signal" do
1512
- skip_below "1.57.2"
1513
- a = nil
1514
- instance = derived_klass.new
1515
- GObject.signal_connect instance, "interface-signal" do
1516
- a = "hello"
1517
- end
1518
- instance.emit_signal
1519
- _(a).must_equal "hello"
1520
- end
1521
-
1522
- describe "its 'number' property" do
1523
- before { skip_below "1.59.1" }
1524
-
1525
- let(:instance) { derived_klass.new }
1526
-
1527
- it "can be retrieved with #get_property" do
1528
- _(instance.get_property("number")).must_equal 0
1529
- end
1530
-
1531
- it "can be retrieved with #number" do
1532
- _(instance.number).must_equal 0
1533
- end
1534
-
1535
- it "can be set with #set_property" do
1536
- instance.set_property("number", 10)
1537
- _(instance.get_property("number")).must_equal 10
1538
- end
1539
-
1540
- it "can be set with #number=" do
1541
- instance.number = 4
1542
-
1543
- _(instance.number).must_equal 4
1544
- _(instance.get_property("number")).must_equal 4
1545
- end
1546
- end
1547
-
1548
- it "handles the 'interface-signal' signal" do
1549
- skip_below "1.57.2"
1550
- a = nil
1551
- instance = derived_klass.new
1552
- GObject.signal_connect instance, "interface-signal" do
1553
- a = "hello"
1554
- end
1555
- GObject.signal_emit instance, "interface-signal"
1556
- _(a).must_equal "hello"
1557
- end
1558
- end
1559
-
1560
- describe "Regress::TestObj" do
1561
- it "creates an instance using #constructor" do
1562
- obj = Regress::TestObj.constructor
1563
- _(obj).must_be_instance_of Regress::TestObj
1564
- end
1565
-
1566
- it "creates an instance using #new" do
1567
- o1 = Regress::TestObj.constructor
1568
- o2 = Regress::TestObj.new o1
1569
- _(o2).must_be_instance_of Regress::TestObj
1570
- end
1571
-
1572
- it "creates an instance using #new_callback" do
1573
- a = 1
1574
- o = Regress::TestObj.new_callback { a = 2 }
1575
- assert_instance_of Regress::TestObj, o
1576
- _(a).must_equal 2
1577
-
1578
- # Regress::TestObj.new_callback adds a callback to the list of notified
1579
- # callbacks. Thaw the callbacks to make sure the list is cleared for
1580
- # later tests.
1581
- result = Regress.test_callback_thaw_notifications
1582
- _(result).must_equal 2
1583
- end
1584
-
1585
- it "creates an instance using #new_from_file" do
1586
- o = Regress::TestObj.new_from_file("foo")
1587
- assert_instance_of Regress::TestObj, o
1588
- end
1589
-
1590
- it "has a working function #null_out" do
1591
- obj = Regress::TestObj.null_out
1592
- _(obj).must_be_nil
1593
- end
1594
-
1595
- it "has a working function #static_method" do
1596
- rv = Regress::TestObj.static_method 623
1597
- assert_equal 623.0, rv
1598
- end
1599
-
1600
- it "has a working function #static_method_callback" do
1601
- a = 1
1602
- Regress::TestObj.static_method_callback { a = 2 }
1603
- assert_equal 2, a
1604
- end
1605
-
1606
- let(:instance) { Regress::TestObj.new_from_file("foo") }
1607
-
1608
- describe "its gtype" do
1609
- it "can be found through gtype and GObject.type_from_instance" do
1610
- gtype = Regress::TestObj.gtype
1611
- r = GObject.type_from_instance instance
1612
- assert_equal gtype, r
1613
- end
1614
- end
1615
-
1616
- it "has a reference count of 1" do
1617
- assert_equal 1, object_ref_count(instance)
1618
- end
1619
-
1620
- it "does not float" do
1621
- _(instance).wont_be :floating?
1622
- end
1623
-
1624
- it "has a working method #matrix" do
1625
- _(instance.matrix("bar")).must_equal 42
1626
- end
1627
-
1628
- it "has a working method #do_matrix" do
1629
- _(instance.do_matrix("bar")).must_equal 42
1630
- end
1631
-
1632
- it "has a working method #emit_sig_with_array_len_prop" do
1633
- skip_below "1.47.92"
1634
- array = nil
1635
- instance.signal_connect "sig-with-array-len-prop" do |_obj, ary|
1636
- array = ary.to_a
1637
- end
1638
- instance.emit_sig_with_array_len_prop
1639
- _(array.to_a).must_equal [0, 1, 2, 3, 4]
1640
- end
1641
-
1642
- it "has a working method #emit_sig_with_error" do
1643
- skip_below "1.61.1"
1644
- error = nil
1645
- instance.signal_connect "sig-with-gerror" do |_obj, err|
1646
- error = err
1647
- end
1648
- instance.emit_sig_with_error
1649
- _(error).must_be_instance_of GLib::Error
1650
- end
1651
-
1652
- it "has a working method #emit_sig_with_foreign_struct" do
1653
- has_fired = false
1654
- instance.signal_connect "sig-with-foreign-struct" do |_obj, cr|
1655
- has_fired = true
1656
- _(cr).must_be_instance_of Cairo::Context
1657
- end
1658
- instance.emit_sig_with_foreign_struct
1659
- assert has_fired
1660
- end
1661
-
1662
- it "has a working method #emit_sig_with_inout_int" do
1663
- skip_below "1.57.2"
1664
- instance.signal_connect "sig-with-inout-int" do |_obj, i, _ud|
1665
- i + 1
1666
- end
1667
- instance.emit_sig_with_inout_int
1668
- end
1669
-
1670
- it "has a working method #emit_sig_with_int64" do
1671
- instance.signal_connect "sig-with-int64-prop" do |_obj, i, _ud|
1672
- i
1673
- end
1674
- instance.emit_sig_with_int64
1675
- end
1676
-
1677
- it "has a working method #emit_sig_with_null_error" do
1678
- skip_below "1.61.1"
1679
- error = nil
1680
- instance.signal_connect "sig-with-gerror" do |_obj, err|
1681
- error = err
1682
- end
1683
- instance.emit_sig_with_null_error
1684
- _(error).must_be_nil
1685
- end
1686
-
1687
- it "has a working method #emit_sig_with_obj" do
1688
- has_fired = false
1689
- instance.signal_connect "sig-with-obj" do |_it, obj|
1690
- has_fired = true
1691
- _(obj.int).must_equal 3
1692
- end
1693
- instance.emit_sig_with_obj
1694
- assert has_fired
1695
- end
1696
-
1697
- it "has a working method #emit_sig_with_uint64" do
1698
- instance.signal_connect "sig-with-uint64-prop" do |_obj, i, _ud|
1699
- i
1700
- end
1701
- instance.emit_sig_with_uint64
1702
- end
1703
-
1704
- it "has a working method #forced_method" do
1705
- instance.forced_method
1706
- pass
1707
- end
1708
-
1709
- it "has a working method #instance_method" do
1710
- rv = instance.instance_method
1711
- assert_equal(-1, rv)
1712
- end
1713
-
1714
- it "has a working method #instance_method_callback" do
1715
- a = 1
1716
- instance.instance_method_callback { a = 2 }
1717
- assert_equal 2, a
1718
- end
1719
-
1720
- it "has a working method #instance_method_full" do
1721
- _(object_ref_count(instance)).must_equal 1
1722
- instance.instance_method_full
1723
- _(object_ref_count(instance)).must_equal 1
1724
- end
1725
-
1726
- it "has a working method #name_conflict" do
1727
- skip_below "1.53.4"
1728
- _(instance.name_conflict).must_be_nil
1729
- end
1730
-
1731
- it "has a working method #not_nullable_element_typed_gpointer_in" do
1732
- skip_below "1.47.92"
1733
- instance.not_nullable_element_typed_gpointer_in [1, 2, 3]
1734
- # TODO: Make method raise when passed nil
1735
- end
1736
-
1737
- it "has a working method #not_nullable_typed_gpointer_in" do
1738
- skip_below "1.47.92"
1739
- obj = Regress::TestObj.new_from_file("bar")
1740
- instance.not_nullable_typed_gpointer_in obj
1741
- # TODO: Make method raise when passed nil
1742
- end
1743
-
1744
- it "has a working method #set_bare" do
1745
- obj = Regress::TestObj.new_from_file("bar")
1746
- instance.set_bare obj
1747
- _(instance.bare).must_equal obj
1748
- end
1749
-
1750
- it "has a working method #skip_inout_param" do
1751
- a = 1
1752
- c = 2.0
1753
- num1 = 3
1754
- num2 = 4
1755
- result, out_b, sum = instance.skip_inout_param a, c, num1, num2
1756
- _(result).must_equal true
1757
- _(out_b).must_equal a + 1
1758
- _(sum).must_equal num1 + 10 * num2
1759
- end
1760
-
1761
- it "has a working method #skip_out_param" do
1762
- a = 1
1763
- c = 2.0
1764
- d = 3
1765
- num1 = 4
1766
- num2 = 5
1767
- result, out_d, sum = instance.skip_out_param a, c, d, num1, num2
1768
- _(result).must_equal true
1769
- _(out_d).must_equal d + 1
1770
- _(sum).must_equal num1 + 10 * num2
1771
- end
1772
-
1773
- it "has a working method #skip_param" do
1774
- a = 1
1775
- d = 3
1776
- num1 = 4
1777
- num2 = 5
1778
- result, out_b, out_d, sum = instance.skip_param a, d, num1, num2
1779
- _(result).must_equal true
1780
- _(out_b).must_equal a + 1
1781
- _(out_d).must_equal d + 1
1782
- _(sum).must_equal num1 + 10 * num2
1783
- end
1784
-
1785
- it "has a working method #skip_return_val" do
1786
- a = 1
1787
- c = 2.0
1788
- d = 3
1789
- num1 = 4
1790
- num2 = 5
1791
- out_b, out_d, out_sum = instance.skip_return_val a, c, d, num1, num2
1792
- _(out_b).must_equal a + 1
1793
- _(out_d).must_equal d + 1
1794
- _(out_sum).must_equal num1 + 10 * num2
1795
- end
1796
-
1797
- it "has a working method #skip_return_val_no_out" do
1798
- result = instance.skip_return_val_no_out 1
1799
- _(result).must_be_nil
1800
-
1801
- _(proc { instance.skip_return_val_no_out 0 }).must_raise GirFFI::GLibError
1802
- end
1803
-
1804
- it "has a working method #torture_signature_0" do
1805
- y, z, q = instance.torture_signature_0(-21, "hello", 13)
1806
- assert_equal [-21, 2 * -21, "hello".length + 13],
1807
- [y, z, q]
1808
- end
1809
-
1810
- it "has a working method #torture_signature_1" do
1811
- ret, y, z, q = instance.torture_signature_1(-21, "hello", 12)
1812
- _([ret, y, z, q]).must_equal [true, -21, 2 * -21, "hello".length + 12]
1813
-
1814
- _(proc { instance.torture_signature_1(-21, "hello", 11) })
1815
- .must_raise GirFFI::GLibError
1816
- end
1817
-
1818
- describe "its 'bare' property" do
1819
- it "can be retrieved with #get_property" do
1820
- _(instance.get_property("bare")).must_be_nil
1821
- end
1822
-
1823
- it "can be retrieved with #bare" do
1824
- _(instance.bare).must_be_nil
1825
- end
1826
-
1827
- it "can be set with #set_property" do
1828
- obj = Regress::TestObj.new_from_file("bar")
1829
- instance.set_property "bare", obj
1830
- _(instance.get_property("bare")).must_equal obj
1831
- end
1832
-
1833
- it "can be set with #bare=" do
1834
- obj = Regress::TestObj.new_from_file("bar")
1835
- instance.bare = obj
1836
-
1837
- _(instance.bare).must_equal obj
1838
- _(instance.get_property("bare")).must_equal obj
1839
- end
1840
- end
1841
-
1842
- describe "its 'boxed' property" do
1843
- it "can be retrieved with #get_property" do
1844
- _(instance.get_property("boxed")).must_be_nil
1845
- end
1846
-
1847
- it "can be retrieved with #boxed" do
1848
- _(instance.boxed).must_be_nil
1849
- end
1850
-
1851
- it "can be set with #set_property" do
1852
- tb = Regress::TestBoxed.new_alternative_constructor1 75
1853
- instance.set_property "boxed", tb
1854
- _(instance.get_property("boxed").some_int8).must_equal 75
1855
- end
1856
-
1857
- it "can be set with #boxed=" do
1858
- tb = Regress::TestBoxed.new_alternative_constructor1 75
1859
- instance.boxed = tb
1860
- _(instance.boxed.some_int8).must_equal tb.some_int8
1861
- _(instance.get_property("boxed").some_int8).must_equal tb.some_int8
1862
- end
1863
- end
1864
-
1865
- describe "its 'byte-array' property" do
1866
- before { skip_below("1.57.2") }
1867
-
1868
- it "can be retrieved with #get_property" do
1869
- _(instance.get_property("byte-array")).must_be_nil
1870
- end
1871
-
1872
- it "can be retrieved with #byte_array" do
1873
- _(instance.byte_array).must_be_nil
1874
- end
1875
-
1876
- it "can be set with #set_property" do
1877
- instance.set_property "byte-array", "hello"
1878
- _(instance.get_property("byte-array").to_string).must_equal "hello"
1879
- end
1880
-
1881
- it "can be set with #byte_array=" do
1882
- instance.byte_array = "bye"
1883
- _(instance.byte_array.to_string).must_equal "bye"
1884
- instance.byte_array = GLib::ByteArray.from("byebye")
1885
- _(instance.get_property("byte-array").to_string).must_equal "byebye"
1886
- end
1887
- end
1888
-
1889
- describe "its 'double' property" do
1890
- it "can be retrieved with #get_property" do
1891
- _(instance.get_property("double")).must_equal 0.0
1892
- end
1893
-
1894
- it "can be retrieved with #double" do
1895
- _(instance.double).must_equal 0.0
1896
- end
1897
-
1898
- it "can be set with #set_property" do
1899
- instance.set_property "double", 3.14
1900
- _(instance.get_property("double")).must_equal 3.14
1901
- end
1902
-
1903
- it "can be set with #double=" do
1904
- instance.double = 3.14
1905
- _(instance.double).must_equal 3.14
1906
- _(instance.get_property("double")).must_equal 3.14
1907
- end
1908
- end
1909
-
1910
- describe "its 'float' property" do
1911
- it "can be retrieved with #get_property" do
1912
- _(instance.get_property("float")).must_equal 0.0
1913
- end
1914
-
1915
- it "can be retrieved with #float" do
1916
- _(instance.float).must_equal 0.0
1917
- end
1918
-
1919
- it "can be set with #set_property" do
1920
- instance.set_property "float", 3.14
1921
- _(instance.get_property("float")).must_be_close_to 3.14
1922
- end
1923
-
1924
- it "can be set with #float=" do
1925
- instance.float = 3.14
1926
- _(instance.float).must_be_close_to 3.14
1927
- _(instance.get_property("float")).must_be_close_to 3.14
1928
- end
1929
- end
1930
-
1931
- describe "its 'gtype' property" do
1932
- it "can be retrieved with #get_property" do
1933
- _(instance.get_property("gtype")).must_equal 0
1934
- end
1935
-
1936
- it "can be retrieved with #gtype" do
1937
- _(instance.gtype).must_equal 0
1938
- end
1939
-
1940
- it "can be set with #set_property" do
1941
- instance.set_property "gtype", GObject::TYPE_INT64
1942
- _(instance.get_property("gtype")).must_equal GObject::TYPE_INT64
1943
- end
1944
-
1945
- it "can be set with #gtype=" do
1946
- instance.gtype = GObject::TYPE_STRING
1947
- _(instance.gtype).must_equal GObject::TYPE_STRING
1948
- _(instance.get_property("gtype")).must_equal GObject::TYPE_STRING
1949
- end
1950
- end
1951
-
1952
- describe "its 'hash-table' property" do
1953
- it "can be retrieved with #get_property" do
1954
- _(instance.get_property("hash-table")).must_be_nil
1955
- end
1956
-
1957
- it "can be retrieved with #hash_table" do
1958
- _(instance.hash_table).must_be_nil
1959
- end
1960
-
1961
- it "can be set with #set_property" do
1962
- instance.set_property "hash-table", "foo" => -4, "bar" => 83
1963
- _(instance.hash_table.to_hash).must_equal("foo" => -4, "bar" => 83)
1964
- end
1965
-
1966
- it "can be set with #hash_table=" do
1967
- instance.hash_table = { "foo" => -4, "bar" => 83 }
1968
- _(instance.hash_table.to_hash).must_equal("foo" => -4, "bar" => 83)
1969
- _(instance.get_property("hash-table").to_hash).must_equal("foo" => -4,
1970
- "bar" => 83)
1971
- end
1972
- end
1973
-
1974
- describe "its 'hash-table-old' property" do
1975
- it "can be retrieved with #get_property" do
1976
- _(instance.get_property("hash-table-old")).must_be_nil
1977
- end
1978
-
1979
- it "can be retrieved with #hash_table_old" do
1980
- _(instance.hash_table_old).must_be_nil
1981
- end
1982
-
1983
- it "can be set with #set_property" do
1984
- instance.set_property "hash-table-old", "foo" => 34, "bar" => -3
1985
- _(instance.hash_table_old.to_hash).must_equal("foo" => 34, "bar" => -3)
1986
- end
1987
-
1988
- it "can be set with #hash_table_old=" do
1989
- instance.hash_table_old = { "foo" => 34, "bar" => -3 }
1990
- _(instance.hash_table_old.to_hash).must_equal("foo" => 34, "bar" => -3)
1991
- _(instance.get_property("hash-table-old").to_hash).must_equal("foo" => 34,
1992
- "bar" => -3)
1993
- end
1994
- end
1995
-
1996
- describe "its 'int' property" do
1997
- it "can be retrieved with #get_property" do
1998
- assert_equal 0, instance.get_property("int")
1999
- end
2000
-
2001
- it "can be retrieved with #int" do
2002
- assert_equal 0, instance.int
2003
- end
2004
-
2005
- it "can be set with #set_property" do
2006
- instance.set_property "int", 42
2007
- assert_equal 42, instance.get_property("int")
2008
- end
2009
-
2010
- it "can be set with #int=" do
2011
- instance.int = 41
2012
- assert_equal 41, instance.get_property("int")
2013
- assert_equal 41, instance.int
2014
- end
2015
- end
2016
-
2017
- describe "its 'list' property" do
2018
- it "can be retrieved with #get_property" do
2019
- _(instance.get_property("list")).must_be_nil
2020
- end
2021
-
2022
- it "can be retrieved with #list" do
2023
- _(instance.list).must_be_nil
2024
- end
2025
-
2026
- it "can be set with #set_property" do
2027
- instance.set_property "list", %w(foo bar)
2028
- _(instance.list.to_a).must_equal %w(foo bar)
2029
- end
2030
-
2031
- it "can be set with #list=" do
2032
- instance.list = %w(foo bar)
2033
- _(instance.list.to_a).must_equal %w(foo bar)
2034
- _(instance.get_property("list")).must_be :==, %w(foo bar)
2035
- end
2036
- end
2037
-
2038
- describe "its 'list-old' property" do
2039
- it "can be retrieved with #get_property" do
2040
- _(instance.get_property("list-old")).must_be_nil
2041
- end
2042
-
2043
- it "can be retrieved with #list_old" do
2044
- _(instance.list_old).must_be_nil
2045
- end
2046
-
2047
- it "can be set with #set_property" do
2048
- instance.set_property "list-old", %w(foo bar)
2049
- _(instance.list_old).must_be :==, %w(foo bar)
2050
- end
2051
-
2052
- it "can be set with #list_old=" do
2053
- instance.list_old = %w(foo bar)
2054
- _(instance.list_old).must_be :==, %w(foo bar)
2055
- _(instance.get_property("list-old")).must_be :==, %w(foo bar)
2056
- end
2057
- end
2058
-
2059
- describe "its 'name-conflict' property" do
2060
- before { skip_below "1.53.4" }
2061
-
2062
- it "can be retrieved with #get_property" do
2063
- _(instance.get_property("name-conflict")).must_equal 42
2064
- end
2065
-
2066
- it "cannot be retrieved with #name_conflict" do
2067
- # Method names are prioritized over property names, so we call the
2068
- # method here instead of fetching the property
2069
- _(instance.name_conflict).must_be_nil
2070
- end
2071
-
2072
- it "can be set with #set_property" do
2073
- instance.set_property("name-conflict", 23)
2074
- _(instance.get_property("name-conflict")).must_equal 23
2075
- end
2076
-
2077
- it "can be set with #name_conflict=" do
2078
- instance.name_conflict = 23
2079
- _(instance.get_property("name-conflict")).must_equal 23
2080
- end
2081
- end
2082
- describe "its 'pptrarray' property" do
2083
- before do
2084
- skip "The pptrarray property is not implemented properly"
2085
- end
2086
-
2087
- it "can be retrieved with #get_property" do
2088
- _(instance.get_property("pptrarray")).must_be_nil
2089
- end
2090
-
2091
- it "can be retrieved with #pptrarray" do
2092
- _(instance.pptrarray).must_be_nil
2093
- end
2094
-
2095
- it "can be set with #set_property" do
2096
- arr = Regress.test_garray_container_return
2097
- instance.set_property "pptrarray", arr
2098
- _(instance.pptrarray).must_be :==, arr
2099
- end
2100
-
2101
- it "can be set with #pptrarray=" do
2102
- arr = Regress.test_garray_container_return
2103
- instance.pptrarray = arr
2104
- _(instance.pptrarray).must_be :==, arr
2105
- _(instance.get_property("pptrarray")).must_be :==, arr
2106
- end
2107
- end
2108
-
2109
- describe "its 'string' property" do
2110
- it "can be retrieved with #get_property" do
2111
- assert_nil instance.get_property("string")
2112
- end
2113
-
2114
- it "can be retrieved with #string" do
2115
- assert_nil instance.string
2116
- end
2117
-
2118
- it "can be set with #set_property" do
2119
- instance.set_property "string", "foobar"
2120
- assert_equal "foobar", instance.get_property("string")
2121
- end
2122
-
2123
- it "can be set with #string=" do
2124
- instance.string = "foobar"
2125
- assert_equal "foobar", instance.string
2126
- assert_equal "foobar", instance.get_property("string")
2127
- end
2128
- end
2129
-
2130
- describe "its 'write-only' property" do
2131
- before { skip_below "1.59.1" }
2132
-
2133
- it "cannot be retrieved with #get_property" do
2134
- skip "Not implemented yet"
2135
- _(proc { instance.get_property("write-only") }).must_raise GirFFI::GLibError
2136
- end
2137
-
2138
- it "cannot be retrieved with #write_only" do
2139
- skip "Not implemented yet"
2140
- _(proc { instance.write_only }).must_raise NoMethodError
2141
- end
2142
-
2143
- it "can be set with #set_property" do
2144
- instance.int = 42
2145
- instance.set_property("write-only", false)
2146
- _(instance.int).must_equal 42
2147
- instance.set_property("write-only", true)
2148
- _(instance.int).must_equal 0
2149
- end
2150
-
2151
- it "can be set with #write_only=" do
2152
- instance.int = 42
2153
- instance.write_only = false
2154
- _(instance.int).must_equal 42
2155
- instance.write_only = true
2156
- _(instance.int).must_equal 0
2157
- end
2158
- end
2159
- it "handles the 'all' signal" do
2160
- a = nil
2161
- GObject.signal_connect(instance, "all") { a = 4 }
2162
- GObject.signal_emit instance, "all"
2163
- _(a).must_equal 4
2164
- end
2165
-
2166
- it "handles the 'cleanup' signal" do
2167
- a = nil
2168
- GObject.signal_connect(instance, "cleanup") { a = 4 }
2169
- GObject.signal_emit instance, "cleanup"
2170
- _(a).must_equal 4
2171
- end
2172
-
2173
- it "handles the 'first' signal" do
2174
- a = nil
2175
- GObject.signal_connect(instance, "first") { a = 4 }
2176
- GObject.signal_emit instance, "first"
2177
- _(a).must_equal 4
2178
- end
2179
-
2180
- it "handles the 'sig-with-array-len-prop' signal" do
2181
- a = nil
2182
-
2183
- GObject.signal_connect(instance, "sig-with-array-len-prop") do |_obj, arr, _user_data|
2184
- a = arr
2185
- end
2186
-
2187
- arr = GirFFI::InPointer.from_array(:uint, [1, 2, 3])
2188
- GObject.signal_emit instance, "sig-with-array-len-prop", arr, 3
2189
-
2190
- _(a.to_a).must_equal [1, 2, 3]
2191
- end
2192
-
2193
- it "handles the 'sig-with-array-prop' signal" do
2194
- a = nil
2195
- GObject.signal_connect(instance, "sig-with-array-prop") { |_, arr, _| a = arr }
2196
- GObject.signal_emit instance, "sig-with-array-prop",
2197
- GLib::Array.from(:uint, [1, 2, 3])
2198
- _(a.to_a).must_equal [1, 2, 3]
2199
- end
2200
-
2201
- it "handles the 'sig-with-foreign-struct' signal" do
2202
- a = nil
2203
- instance.signal_connect "sig-with-foreign-struct" do |_obj, ct|
2204
- a = ct
2205
- end
2206
-
2207
- cairo_context = Regress.test_cairo_context_full_return
2208
-
2209
- GObject.signal_emit instance, "sig-with-foreign-struct", cairo_context
2210
-
2211
- _(a).must_be_instance_of Cairo::Context
2212
- _(a).must_equal cairo_context
2213
- end
2214
-
2215
- it "handles the 'sig-with-gerror' signal" do
2216
- skip_below "1.61.1"
2217
- a = nil
2218
- GObject.signal_connect(instance, "sig-with-gerror") do |_obj, err|
2219
- a = err
2220
- end
2221
- GObject.signal_emit instance, "sig-with-gerror", GLib::Error.new
2222
- _(a).must_be_instance_of GLib::Error
2223
- end
2224
-
2225
- it "handles the 'sig-with-hash-prop' signal" do
2226
- a = nil
2227
-
2228
- GObject.signal_connect(instance, "sig-with-hash-prop") do |_, ghash, _|
2229
- a = ghash.to_hash
2230
- end
2231
-
2232
- g_hash_table = GLib::HashTable.from([:utf8, GObject::Value],
2233
- "foo" => GObject::Value.from("bar"))
2234
-
2235
- GObject.signal_emit instance, "sig-with-hash-prop", g_hash_table
2236
-
2237
- _(a["foo"]).must_be_instance_of GObject::Value
2238
- _(a["foo"].get_value).must_equal "bar"
2239
- end
2240
-
2241
- it "handles the 'sig-with-inout-int' signal" do
2242
- skip_below "1.53.4"
2243
- skip "Not implemented yet"
2244
- GObject.signal_connect instance, "sig-with-inout-int" do |_obj, i, _ud|
2245
- i + 2
2246
- end
2247
- result = GObject.signal_emit instance, "sig-with-inout-int", 65
2248
- _(result).must_equal 67
2249
- end
2250
-
2251
- it "handles the 'sig-with-int64-prop' signal" do
2252
- a = nil
2253
-
2254
- GObject.signal_connect(instance, "sig-with-int64-prop") do |_obj, int64, _user_data|
2255
- a = int64
2256
- end
2257
-
2258
- result = GObject.signal_emit instance, "sig-with-int64-prop", 0x7fff_ffff_ffff_ffff
2259
-
2260
- _(a).must_equal 0x7fff_ffff_ffff_ffff
2261
- _(result).must_equal 0x7fff_ffff_ffff_ffff
2262
- end
2263
-
2264
- it "handles the 'sig-with-intarray-ret' signal" do
2265
- a = nil
2266
-
2267
- GObject.signal_connect(instance, "sig-with-intarray-ret") do |_, i, _|
2268
- a = i
2269
- [3, 2, 1]
2270
- end
2271
-
2272
- result = GObject.signal_emit instance, "sig-with-intarray-ret", 3
2273
-
2274
- _(a).must_equal 3
2275
-
2276
- _(result.to_a).must_equal [3, 2, 1]
2277
- end
2278
-
2279
- it "handles the 'sig-with-obj' signal" do
2280
- a = nil
2281
-
2282
- GObject.signal_connect(instance, "sig-with-obj") do |_, obj, _|
2283
- a = obj
2284
- end
2285
-
2286
- object = Regress::TestObj.constructor
2287
- GObject.signal_emit instance, "sig-with-obj", object
2288
-
2289
- _(a).must_equal object
2290
- end
2291
-
2292
- it "handles the 'sig-with-strv' signal" do
2293
- a = nil
2294
-
2295
- GObject.signal_connect(instance, "sig-with-strv") do |_, strs, _|
2296
- a = strs
2297
- end
2298
-
2299
- GObject.signal_emit instance, "sig-with-strv", GLib::Strv.from(%w(foo bar))
2300
-
2301
- _(a.to_a).must_equal %w(foo bar)
2302
- end
2303
-
2304
- it "handles the 'sig-with-uint64-prop' signal" do
2305
- a = nil
2306
-
2307
- GObject.signal_connect(instance, "sig-with-uint64-prop") do |_, uint64, _|
2308
- a = uint64
2309
- end
2310
-
2311
- result = GObject.signal_emit instance, "sig-with-uint64-prop", 0xffff_ffff_ffff_ffff
2312
-
2313
- _(a).must_equal 0xffff_ffff_ffff_ffff
2314
- _(result).must_equal 0xffff_ffff_ffff_ffff
2315
- end
2316
-
2317
- it "handles the 'test' signal" do
2318
- a = b = nil
2319
- o = Regress::TestSubObj.new
2320
- GObject.signal_connect(o, "test", 2) do |i, d|
2321
- a = d
2322
- b = i
2323
- end
2324
- GObject.signal_emit o, "test"
2325
- assert_equal [2, o], [a, b]
2326
- end
2327
-
2328
- it "handles the 'test-with-static-scope-arg' signal" do
2329
- a = nil
2330
-
2331
- GObject.signal_connect(instance, "test-with-static-scope-arg") do |_, obj, _|
2332
- a = obj
2333
- end
2334
-
2335
- arg = Regress::TestSimpleBoxedA.new
2336
- arg.some_int = 12_345
2337
- GObject.signal_emit instance, "test-with-static-scope-arg", arg
2338
-
2339
- _(a.some_int).must_equal 12_345
2340
- end
2341
- end
2342
-
2343
- describe "Regress::TestOtherError" do
2344
- it "has the member :code1" do
2345
- _(Regress::TestOtherError[:code1]).must_equal 1
2346
- end
2347
-
2348
- it "has the member :code2" do
2349
- _(Regress::TestOtherError[:code2]).must_equal 2
2350
- end
2351
-
2352
- it "has the member :code3" do
2353
- _(Regress::TestOtherError[:code3]).must_equal 3
2354
- end
2355
-
2356
- it "has a working function #quark" do
2357
- quark = Regress::TestOtherError.quark
2358
- _(GLib.quark_to_string(quark)).must_equal "regress-test-other-error"
2359
- end
2360
- end
2361
-
2362
- describe "Regress::TestPrivateEnum" do
2363
- it "has the member :public_enum_before" do
2364
- _(Regress::TestPrivateEnum[:public_enum_before]).must_equal 1
2365
- end
2366
- it "does not have the member :private" do
2367
- _(Regress::TestPrivateEnum[:private]).must_be_nil
2368
- end
2369
- it "has the member :public_enum_after" do
2370
- _(Regress::TestPrivateEnum[:public_enum_after]).must_equal 4
2371
- end
2372
- end
2373
-
2374
- describe "Regress::TestPrivateStruct" do
2375
- let(:instance) { Regress::TestPrivateStruct.new }
2376
-
2377
- it "has a writable field this_is_public_before" do
2378
- _(instance.this_is_public_before).must_equal 0
2379
- instance.this_is_public_before = 42
2380
- _(instance.this_is_public_before).must_equal 42
2381
- end
2382
-
2383
- it "has a private field this_is_private" do
2384
- skip "This field is identified as readable in the typelib"
2385
- _(instance).wont_respond_to :this_is_private
2386
- _(instance).wont_respond_to :this_is_private=
2387
- end
2388
-
2389
- it "has a writable field this_is_public_after" do
2390
- _(instance.this_is_public_after).must_equal 0
2391
- instance.this_is_public_after = 42
2392
- _(instance.this_is_public_after).must_equal 42
2393
- end
2394
- end
2395
-
2396
- describe "Regress::TestReferenceCounters" do
2397
- let(:instance) { Regress::TestReferenceCounters.new }
2398
-
2399
- before { skip_below "1.59.1" }
2400
-
2401
- it "has a writable field refcount" do
2402
- _(instance.refcount).must_equal 0
2403
- instance.refcount = 42
2404
- _(instance.refcount).must_equal 42
2405
- end
2406
-
2407
- it "has a writable field atomicrefcount" do
2408
- _(instance.atomicrefcount).must_equal 0
2409
- instance.atomicrefcount = 42
2410
- _(instance.atomicrefcount).must_equal 42
2411
- end
2412
- end
2413
-
2414
- describe "Regress::TestReferenceEnum" do
2415
- it "has the member :0" do
2416
- _(Regress::TestReferenceEnum[:"0"]).must_equal 4
2417
- end
2418
-
2419
- it "has the member :1" do
2420
- _(Regress::TestReferenceEnum[:"1"]).must_equal 2
2421
- end
2422
-
2423
- it "has the member :2" do
2424
- _(Regress::TestReferenceEnum[:"2"]).must_equal 54
2425
- end
2426
-
2427
- it "has the member :3" do
2428
- _(Regress::TestReferenceEnum[:"3"]).must_equal 4
2429
- end
2430
-
2431
- it "has the member :4" do
2432
- _(Regress::TestReferenceEnum[:"4"]).must_equal 216
2433
- end
2434
-
2435
- it "has the member :5" do
2436
- _(Regress::TestReferenceEnum[:"5"]).must_equal(-217)
2437
- end
2438
- end
2439
-
2440
- describe "Regress::TestSimpleBoxedA" do
2441
- it "creates an instance using #new" do
2442
- obj = Regress::TestSimpleBoxedA.new
2443
- assert_instance_of Regress::TestSimpleBoxedA, obj
2444
- end
2445
-
2446
- let(:instance) { Regress::TestSimpleBoxedA.new }
2447
-
2448
- it "has a writable field some_int" do
2449
- _(instance.some_int).must_equal 0
2450
- instance.some_int = 42
2451
- _(instance.some_int).must_equal 42
2452
- end
2453
-
2454
- it "has a writable field some_int8" do
2455
- _(instance.some_int8).must_equal 0
2456
- instance.some_int8 = 42
2457
- _(instance.some_int8).must_equal 42
2458
- end
2459
-
2460
- it "has a writable field some_double" do
2461
- _(instance.some_double).must_equal 0.0
2462
- instance.some_double = 42.0
2463
- _(instance.some_double).must_equal 42.0
2464
- end
2465
-
2466
- it "has a writable field some_enum" do
2467
- _(instance.some_enum).must_equal :value1
2468
- instance.some_enum = :value4
2469
- _(instance.some_enum).must_equal :value4
2470
- end
2471
-
2472
- it "has a working method #copy" do
2473
- instance.some_int = 4236
2474
-
2475
- obj2 = instance.copy
2476
- _(obj2).must_be_instance_of Regress::TestSimpleBoxedA
2477
- _(obj2.some_int).must_equal instance.some_int
2478
-
2479
- instance.some_int = 89
2480
- _(obj2.some_int).wont_equal instance.some_int
2481
- end
2482
-
2483
- it "has a working method #equals" do
2484
- instance.some_int = 4236
2485
-
2486
- ob2 = Regress::TestSimpleBoxedA.new
2487
- ob2.some_int = 4236
2488
- _(ob2.equals(instance)).must_equal true
2489
- ob2.some_enum = :value3
2490
- _(ob2.equals(instance)).must_equal true
2491
- ob2.some_int = 42
2492
- _(ob2.equals(instance)).wont_equal true
2493
- end
2494
-
2495
- it "has a working function #const_return" do
2496
- result = Regress::TestSimpleBoxedA.const_return
2497
- _([result.some_int, result.some_int8, result.some_double]).must_equal [5, 6, 7.0]
2498
- end
2499
- end
2500
-
2501
- describe "Regress::TestSimpleBoxedB" do
2502
- let(:instance) { Regress::TestSimpleBoxedB.new }
2503
- it "has a writable field some_int8" do
2504
- _(instance.some_int8).must_equal 0
2505
- instance.some_int8 = 42
2506
- _(instance.some_int8).must_equal 42
2507
- end
2508
-
2509
- it "has a writable field nested_a" do
2510
- _(instance.nested_a.some_int).must_equal 0
2511
- instance.nested_a = Regress::TestSimpleBoxedA.const_return
2512
- _(instance.nested_a.some_int).must_equal 5
2513
- end
2514
-
2515
- it "has a working method #copy" do
2516
- instance.some_int8 = -42
2517
- instance.nested_a.some_int = 4242
2518
-
2519
- copy = instance.copy
2520
- _([copy.some_int8, copy.nested_a.some_int]).must_equal [-42, 4242]
2521
-
2522
- instance.some_int8 = 103
2523
- _(copy.some_int8).must_equal(-42)
2524
- end
2525
- end
2526
-
2527
- describe "Regress::TestStructA" do
2528
- let(:instance) { Regress::TestStructA.new }
2529
- it "has a writable field some_int" do
2530
- _(instance.some_int).must_equal 0
2531
- instance.some_int = 2556
2532
- _(instance.some_int).must_equal 2556
2533
- end
2534
-
2535
- it "has a writable field some_int8" do
2536
- _(instance.some_int8).must_equal 0
2537
- instance.some_int8 = -10
2538
- _(instance.some_int8).must_equal(-10)
2539
- end
2540
-
2541
- it "has a writable field some_double" do
2542
- _(instance.some_double).must_equal 0.0
2543
- instance.some_double = 1.03455e20
2544
- _(instance.some_double).must_equal 1.03455e20
2545
- end
2546
-
2547
- it "has a writable field some_enum" do
2548
- _(instance.some_enum).must_equal :value1
2549
- instance.some_enum = :value2
2550
- _(instance.some_enum).must_equal :value2
2551
- end
2552
-
2553
- it "has a working method #clone" do
2554
- a = Regress::TestStructA.new
2555
- a.some_int = 2556
2556
- a.some_int8 = -10
2557
- a.some_double = 1.03455e20
2558
- a.some_enum = :value2
2559
-
2560
- b = a.clone
2561
-
2562
- assert_equal 2556, b.some_int
2563
- assert_equal(-10, b.some_int8)
2564
- assert_equal 1.03455e20, b.some_double
2565
- assert_equal :value2, b.some_enum
2566
- end
2567
-
2568
- it "has a working function #parse" do
2569
- a = Regress::TestStructA.parse("this string is actually ignored")
2570
- _(a.some_int).must_equal 23
2571
- end
2572
- end
2573
-
2574
- describe "Regress::TestStructB" do
2575
- let(:instance) { Regress::TestStructB.new }
2576
- it "has a writable field some_int8" do
2577
- _(instance.some_int8).must_equal 0
2578
- instance.some_int8 = 42
2579
- _(instance.some_int8).must_equal 42
2580
- end
2581
-
2582
- it "has a writable field nested_a" do
2583
- _(instance.nested_a.some_int).must_equal 0
2584
-
2585
- nested = Regress::TestStructA.new
2586
- nested.some_int = -4321
2587
-
2588
- instance.nested_a = nested
2589
- _(instance.nested_a.some_int).must_equal(-4321)
2590
- end
2591
-
2592
- it "has a working method #clone" do
2593
- a = Regress::TestStructB.new
2594
- a.some_int8 = 42
2595
- a.nested_a.some_int = 2556
2596
- a.nested_a.some_int8 = -10
2597
- a.nested_a.some_double = 1.03455e20
2598
- a.nested_a.some_enum = :value2
2599
-
2600
- b = a.clone
2601
-
2602
- assert_equal 42, b.some_int8
2603
- assert_equal 2556, b.nested_a.some_int
2604
- assert_equal(-10, b.nested_a.some_int8)
2605
- assert_equal 1.03455e20, b.nested_a.some_double
2606
- assert_equal :value2, b.nested_a.some_enum
2607
- end
2608
- end
2609
-
2610
- describe "Regress::TestStructC" do
2611
- let(:instance) { Regress::TestStructC.new }
2612
- it "has a writable field another_int" do
2613
- _(instance.another_int).must_equal 0
2614
- instance.another_int = 42
2615
- _(instance.another_int).must_equal 42
2616
- end
2617
-
2618
- it "has a writable field obj" do
2619
- o = Regress::TestSubObj.new
2620
- _(instance.obj).must_be_nil
2621
- instance.obj = o
2622
- _(instance.obj).must_equal o
2623
- end
2624
- end
2625
-
2626
- describe "Regress::TestStructD" do
2627
- let(:instance) { Regress::TestStructD.new }
2628
- it "has a writable field array1" do
2629
- _(instance.array1).must_be :==, []
2630
- struct = Regress::TestStructA.new
2631
- instance.array1 = [struct]
2632
- _(instance.array1).must_be :==, [struct]
2633
- end
2634
-
2635
- it "has a writable field array2" do
2636
- _(instance.array2).must_be :==, []
2637
- o = Regress::TestSubObj.new
2638
- instance.array2 = [o]
2639
- _(instance.array2).must_be :==, [o]
2640
- end
2641
-
2642
- it "has a writable field field" do
2643
- _(instance.field).must_be_nil
2644
- o = Regress::TestSubObj.new
2645
- instance.field = o
2646
- _(instance.field).must_equal o
2647
- end
2648
-
2649
- it "has a writable field list" do
2650
- _(instance.list).must_be_nil
2651
- o = Regress::TestSubObj.new
2652
- instance.list = [o]
2653
- _(instance.list).must_be :==, [o]
2654
- end
2655
-
2656
- it "has a writable field garray" do
2657
- _(instance.garray).must_be_nil
2658
- o = Regress::TestSubObj.new
2659
- instance.garray = [o]
2660
- _(instance.garray).must_be :==, [o]
2661
- end
2662
- end
2663
-
2664
- describe "Regress::TestStructE" do
2665
- let(:instance) { Regress::TestStructE.new }
2666
- it "has a writable field some_type" do
2667
- _(instance.some_type).must_equal 0
2668
- instance.some_type = GObject::TYPE_STRING
2669
- _(instance.some_type).must_equal GObject::TYPE_STRING
2670
- end
2671
-
2672
- it "has a writable field some_union" do
2673
- _(instance.some_union.map(&:v_int)).must_equal [0, 0]
2674
-
2675
- union1 = Regress::TestStructE__some_union__union.new
2676
- union1.v_int = 42
2677
- union2 = Regress::TestStructE__some_union__union.new
2678
- union2.v_int = 84
2679
-
2680
- instance.some_union = [union1, union2]
2681
-
2682
- _(instance.some_union.map(&:v_int)).must_equal [42, 84]
2683
- end
2684
- end
2685
- describe "Regress::TestStructE__some_union__union" do
2686
- let(:instance) { Regress::TestStructE__some_union__union.new }
2687
- it "has a writable field v_int" do
2688
- _(instance.v_int).must_equal 0
2689
- instance.v_int = -54_321
2690
- _(instance.v_int).must_equal(-54_321)
2691
- end
2692
-
2693
- it "has a writable field v_uint" do
2694
- _(instance.v_uint).must_equal 0
2695
- instance.v_uint = 54_321
2696
- _(instance.v_uint).must_equal 54_321
2697
- end
2698
-
2699
- it "has a writable field v_long" do
2700
- _(instance.v_long).must_equal 0
2701
- instance.v_long = -54_321
2702
- _(instance.v_long).must_equal(-54_321)
2703
- end
2704
-
2705
- it "has a writable field v_ulong" do
2706
- _(instance.v_long).must_equal 0
2707
- instance.v_long = 54_321
2708
- _(instance.v_long).must_equal 54_321
2709
- end
2710
-
2711
- it "has a writable field v_int64" do
2712
- _(instance.v_int64).must_equal 0
2713
- instance.v_int64 = -54_321_000_000_000
2714
- _(instance.v_int64).must_equal(-54_321_000_000_000)
2715
- end
2716
- it "has a writable field v_uint64" do
2717
- _(instance.v_uint64).must_equal 0
2718
- instance.v_uint64 = 54_321_000_000_000
2719
- _(instance.v_uint64).must_equal 54_321_000_000_000
2720
- end
2721
- it "has a writable field v_float" do
2722
- _(instance.v_float).must_equal 0
2723
- instance.v_float = 3.1415
2724
- _(instance.v_float).must_be_close_to 3.1415
2725
- end
2726
- it "has a writable field v_double" do
2727
- _(instance.v_double).must_equal 0
2728
- instance.v_double = 3.1415
2729
- _(instance.v_double).must_equal 3.1415
2730
- end
2731
- it "has a writable field v_pointer" do
2732
- _(instance.v_pointer).must_be :null?
2733
- instance.v_pointer = FFI::Pointer.new 54_321
2734
- _(instance.v_pointer.address).must_equal 54_321
2735
- end
2736
- end
2737
- describe "Regress::TestStructF" do
2738
- let(:instance) { Regress::TestStructF.new }
2739
-
2740
- it "has a writable field ref_count" do
2741
- _(instance.ref_count).must_equal 0
2742
- instance.ref_count = 1
2743
- _(instance.ref_count).must_equal 1
2744
- end
2745
-
2746
- it "has a writable field data1" do
2747
- _(instance.data1).must_be :null?
2748
- instance.data1 = FFI::MemoryPointer.new(:int32).tap { |it| it.put_int(0, 42) }
2749
- _(instance.data1.read_int).must_equal 42
2750
- end
2751
-
2752
- # TODO: Check what gobject-introspection should/will do with these fields.
2753
- it "has a writable field data2" do
2754
- skip "Introspection data cannot deal with type of this field yet"
2755
- end
2756
-
2757
- it "has a writable field data3" do
2758
- skip "Introspection data cannot deal with type of this field yet"
2759
- end
2760
-
2761
- it "has a writable field data4" do
2762
- skip "Introspection data cannot deal with type of this field yet"
2763
- end
2764
-
2765
- it "has a writable field data5" do
2766
- skip "Introspection data cannot deal with type of this field yet"
2767
- end
2768
-
2769
- it "has a writable field data6" do
2770
- skip "Introspection data cannot deal with type of this field yet"
2771
- end
2772
-
2773
- it "has a writable field data7" do
2774
- skip_below "1.59.3"
2775
- instance.data7 = 42
2776
- _(instance.data7).must_equal 42
2777
- end
2778
- end
2779
-
2780
- describe "Regress::TestStructFixedArray" do
2781
- let(:instance) { Regress::TestStructFixedArray.new }
2782
- it "has a writable field just_int" do
2783
- _(instance.just_int).must_equal 0
2784
- instance.just_int = 42
2785
- _(instance.just_int).must_equal 42
2786
- end
2787
-
2788
- it "has a writable field array" do
2789
- _(instance.array).must_be :==, [0] * 10
2790
- instance.array = (1..10).to_a
2791
- _(instance.array).must_be :==, (1..10).to_a
2792
- end
2793
-
2794
- it "has a working method #frob" do
2795
- instance.array = (0..9).to_a
2796
- instance.frob
2797
- _(instance.array).must_be :==, (42..42 + 9).to_a
2798
- _(instance.just_int).must_equal 7
2799
- end
2800
- end
2801
-
2802
- describe "Regress::TestSubObj" do
2803
- it "creates an instance using #new" do
2804
- tso = Regress::TestSubObj.new
2805
- assert_instance_of Regress::TestSubObj, tso
2806
- end
2807
-
2808
- it "does not create an instance using its parent object's custom constructors" do
2809
- _(proc { Regress::TestSubObj.constructor }).must_raise NoMethodError
2810
- end
2811
-
2812
- let(:instance) { Regress::TestSubObj.new }
2813
-
2814
- it "has a working method #instance_method" do
2815
- res = instance.instance_method
2816
- assert_equal 0, res
2817
- end
2818
-
2819
- it "has a working method #unset_bare" do
2820
- instance.unset_bare
2821
- pass
2822
- end
2823
-
2824
- describe "its 'boolean' property" do
2825
- before { skip_below "1.59.1" }
2826
-
2827
- it "can be retrieved with #get_property" do
2828
- _(instance.get_property("boolean")).must_equal true
2829
- end
2830
-
2831
- it "can be retrieved with #boolean" do
2832
- _(instance.boolean).must_equal true
2833
- end
2834
-
2835
- it "can be set with #set_property" do
2836
- instance.set_property("boolean", false)
2837
- _(instance.get_property("boolean")).must_equal false
2838
- end
2839
-
2840
- it "can be set with #boolean=" do
2841
- instance.boolean = false
2842
- _(instance.get_property("boolean")).must_equal false
2843
- end
2844
- end
2845
-
2846
- it "does not have a field parent_instance" do
2847
- _(instance).wont_respond_to :parent_instance
2848
- end
2849
- end
2850
-
2851
- describe "Regress::TestWi8021x" do
2852
- it "creates an instance using #new" do
2853
- o = Regress::TestWi8021x.new
2854
- assert_instance_of Regress::TestWi8021x, o
2855
- end
2856
-
2857
- it "has a working function #static_method" do
2858
- assert_equal(-84, Regress::TestWi8021x.static_method(-42))
2859
- end
2860
-
2861
- let(:instance) { Regress::TestWi8021x.new }
2862
-
2863
- it "has a working method #get_testbool" do
2864
- _(instance.get_testbool).must_equal true
2865
- end
2866
-
2867
- it "has a working method #set_testbool" do
2868
- instance.set_testbool true
2869
- _(instance.get_testbool).must_equal true
2870
- instance.set_testbool false
2871
- _(instance.get_testbool).must_equal false
2872
- end
2873
-
2874
- describe "its 'testbool' property" do
2875
- it "can be retrieved with #get_property" do
2876
- _(instance.get_property("testbool")).must_equal true
2877
- end
2878
-
2879
- it "can be retrieved with #testbool" do
2880
- _(instance.testbool).must_equal true
2881
- end
2882
-
2883
- it "can be set with #set_property" do
2884
- instance.set_property "testbool", true
2885
- _(instance.get_testbool).must_equal true
2886
- _(instance.get_property("testbool")).must_equal true
2887
-
2888
- instance.set_property "testbool", false
2889
- _(instance.get_testbool).must_equal false
2890
- _(instance.get_property("testbool")).must_equal false
2891
- end
2892
-
2893
- it "can be set with #testbool=" do
2894
- instance.testbool = true
2895
- _(instance.testbool).must_equal true
2896
- _(instance.get_testbool).must_equal true
2897
- _(instance.get_property("testbool")).must_equal true
2898
-
2899
- instance.testbool = false
2900
- _(instance.testbool).must_equal false
2901
- _(instance.get_testbool).must_equal false
2902
- _(instance.get_property("testbool")).must_equal false
2903
- end
2904
- end
2905
- end
2906
-
2907
- it "has the constant UTF8_CONSTANT" do
2908
- assert_equal "const ♥ utf8", Regress::UTF8_CONSTANT
2909
- end
2910
-
2911
- it "has a working function #aliased_caller_alloc" do
2912
- result = Regress.aliased_caller_alloc
2913
- _(result).must_be_instance_of Regress::TestBoxed
2914
- end
2915
-
2916
- it "has a working function #annotation_attribute_func" do
2917
- info = get_introspection_data("Regress", "annotation_attribute_func")
2918
- param = info.args.last
2919
- _(param.attribute("some.annotation")).must_equal "value"
2920
- _(param.attribute("another.annotation")).must_equal "blahvalue"
2921
-
2922
- obj = Regress::AnnotationObject.new
2923
- _(Regress.annotation_attribute_func(obj, "hello")).must_equal 42
2924
- end
2925
-
2926
- it "has a working function #annotation_custom_destroy" do
2927
- result = Regress.annotation_custom_destroy {}
2928
- _(result).must_be_nil
2929
- end
2930
-
2931
- it "has a working function #annotation_get_source_file" do
2932
- _(Regress.annotation_get_source_file).must_be_nil
2933
- end
2934
-
2935
- it "has a working function #annotation_init" do
2936
- result = Regress.annotation_init %w(foo bar)
2937
- _(result.to_a).must_equal %w(foo bar)
2938
- end
2939
-
2940
- it "has a working function #annotation_invalid_regress_annotation" do
2941
- _(Regress.annotation_invalid_regress_annotation(42)).must_be_nil
2942
- end
2943
-
2944
- it "has a working function #annotation_ptr_array" do
2945
- # TODO: Automatically convert array elements to correct type
2946
- val1 = GObject::Value.from 1
2947
- val2 = GObject::Value.from "a"
2948
- _(Regress.annotation_ptr_array([val1, val2])).must_be_nil
2949
- end
2950
-
2951
- it "has a working function #annotation_return_array" do
2952
- _(Regress.annotation_return_array).must_be_nil
2953
- end
2954
-
2955
- it "has a working function #annotation_return_filename" do
2956
- skip "This function is wrongly annotated as transfer-ownership: full"
2957
- _(Regress.annotation_return_filename).must_equal "a utf-8 filename"
2958
- end
2959
-
2960
- it "has a working function #annotation_set_source_file" do
2961
- _(Regress.annotation_set_source_file("a filename")).must_be_nil
2962
- end
2963
-
2964
- it "has a working function #annotation_space_after_comment_bug631690" do
2965
- _(Regress.annotation_space_after_comment_bug631690).must_be_nil
2966
- end
2967
-
2968
- it "has a working function #annotation_string_array_length" do
2969
- _(Regress.annotation_string_array_length(%w(foo bar))).must_be_nil
2970
- end
2971
-
2972
- it "has a working function #annotation_string_zero_terminated" do
2973
- _(Regress.annotation_string_zero_terminated.to_a).must_equal []
2974
- end
2975
-
2976
- it "has a working function #annotation_string_zero_terminated_out" do
2977
- _(Regress.annotation_string_zero_terminated_out(%w(foo bar)).to_a)
2978
- .must_equal %w(foo bar)
2979
- end
2980
-
2981
- it "has a working function #annotation_test_parsing_bug630862" do
2982
- _(Regress.annotation_test_parsing_bug630862).must_be_nil
2983
- end
2984
-
2985
- it "has a working function #annotation_transfer_floating" do
2986
- Regress.setup_method! :annotation_transfer_floating
2987
- method = Regress.method :annotation_transfer_floating
2988
- # NOTE: The arity of this method was changed in GObjectIntrospection 1.53.2
2989
- if method.arity == 1
2990
- object = GObject::Object.new
2991
- _(Regress.annotation_transfer_floating(object)).must_be_nil
2992
- else
2993
- _(Regress.annotation_transfer_floating).must_be_nil
2994
- end
2995
- end
2996
-
2997
- it "has a working function #annotation_versioned" do
2998
- _(Regress.annotation_versioned).must_be_nil
2999
- end
3000
-
3001
- it "has a working function #atest_error_quark" do
3002
- result = Regress.atest_error_quark
3003
- _(GLib.quark_to_string(result)).must_equal "regress-atest-error"
3004
- end
3005
-
3006
- it "has a working function #foo_async_ready_callback" do
3007
- skip "This function is defined in the header but not implemented"
3008
- end
3009
-
3010
- it "has a working function #foo_destroy_notify_callback" do
3011
- skip "This function is defined in the header but not implemented"
3012
- end
3013
-
3014
- it "has a working function #foo_enum_type_method" do
3015
- skip "This function is defined in the header but not implemented"
3016
- end
3017
-
3018
- it "has a working function #foo_enum_type_returnv" do
3019
- skip "This function is defined in the header but not implemented"
3020
- end
3021
-
3022
- it "has a working function #foo_error_quark" do
3023
- result = Regress.foo_error_quark
3024
- _(GLib.quark_to_string(result)).must_equal("regress_foo-error-quark")
3025
- end
3026
-
3027
- it "has a working function #foo_init" do
3028
- _(Regress.foo_init).must_equal 0x1138
3029
- end
3030
-
3031
- it "has a working function #foo_interface_static_method" do
3032
- _(Regress.foo_interface_static_method(42)).must_be_nil
3033
- end
3034
-
3035
- it "has a working function #foo_method_external_references" do
3036
- skip "This function is defined in the header but not implemented"
3037
- end
3038
-
3039
- it "has a working function #foo_not_a_constructor_new" do
3040
- _(Regress.foo_not_a_constructor_new).must_be_nil
3041
- end
3042
-
3043
- it "has a working function #foo_test_array" do
3044
- _(Regress.foo_test_array).must_be_nil
3045
- end
3046
-
3047
- it "has a working function #foo_test_const_char_param" do
3048
- skip "This function is defined in the header but not implemented"
3049
- end
3050
-
3051
- it "has a working function #foo_test_const_char_retval" do
3052
- skip "This function is defined in the header but not implemented"
3053
- end
3054
-
3055
- it "has a working function #foo_test_const_struct_param" do
3056
- skip "This function is defined in the header but not implemented"
3057
- end
3058
-
3059
- it "has a working function #foo_test_const_struct_retval" do
3060
- skip "This function is defined in the header but not implemented"
3061
- end
3062
-
3063
- it "has a working function #foo_test_string_array" do
3064
- _(Regress.foo_test_string_array(%w(foo bar))).must_be_nil
3065
- end
3066
-
3067
- it "has a working function #foo_test_string_array_with_g" do
3068
- _(Regress.foo_test_string_array_with_g(%w(foo bar))).must_be_nil
3069
- end
3070
-
3071
- it "has a working function #foo_test_unsigned_qualifier" do
3072
- skip "This function is defined in the header but not implemented"
3073
- end
3074
-
3075
- it "has a working function #foo_test_unsigned_type" do
3076
- skip "This function is defined in the header but not implemented"
3077
- end
3078
-
3079
- it "has a working function #func_obj_null_in" do
3080
- Regress.func_obj_null_in nil
3081
- Regress.func_obj_null_in Regress::TestObj.constructor
3082
- pass
3083
- end
3084
-
3085
- it "has a working function #func_obj_nullable_in" do
3086
- Regress.func_obj_null_in nil
3087
- Regress.func_obj_null_in Regress::TestObj.constructor
3088
- pass
3089
- end
3090
-
3091
- it "has a working function #get_variant" do
3092
- skip_below "1.47.92"
3093
- var = Regress.get_variant
3094
- _(var.get_int32).must_equal 42
3095
- # TODO: Make var not floating
3096
- end
3097
-
3098
- it "has a working function #global_get_flags_out" do
3099
- result = Regress.global_get_flags_out
3100
- _(result).must_equal(flag1: true, flag3: true)
3101
- end
3102
-
3103
- it "has a working function #has_parameter_named_attrs" do
3104
- Regress.has_parameter_named_attrs 42, [23] * 32
3105
- pass
3106
- end
3107
-
3108
- it "has a working function #introspectable_via_alias" do
3109
- Regress.introspectable_via_alias []
3110
- pass
3111
- end
3112
-
3113
- it "has a working function #set_abort_on_error" do
3114
- Regress.set_abort_on_error false
3115
- Regress.set_abort_on_error true
3116
- pass
3117
- end
3118
-
3119
- it "has a working function #test_abc_error_quark" do
3120
- quark = Regress.test_abc_error_quark
3121
- _(GLib.quark_to_string(quark)).must_equal "regress-test-abc-error"
3122
- end
3123
-
3124
- it "has a working function #test_array_callback" do
3125
- a = nil
3126
- b = nil
3127
- c = 95
3128
-
3129
- result = Regress.test_array_callback do |one, two|
3130
- a = one
3131
- b = two
3132
- c
3133
- end
3134
-
3135
- _(result).must_equal 2 * c
3136
- _(a.to_a).must_equal [-1, 0, 1, 2]
3137
- _(b.to_a).must_equal %w(one two three)
3138
- end
3139
-
3140
- it "has a working function #test_array_fixed_out_objects" do
3141
- result = Regress.test_array_fixed_out_objects
3142
- gtype = Regress::TestObj.gtype
3143
-
3144
- _(result.size).must_equal 2
3145
-
3146
- result.each do |o|
3147
- assert_instance_of Regress::TestObj, o
3148
- assert_equal gtype, GObject.type_from_instance(o)
3149
- end
3150
- end
3151
-
3152
- it "has a working function #test_array_fixed_size_int_in" do
3153
- assert_equal 5 + 4 + 3 + 2 + 1, Regress.test_array_fixed_size_int_in([5, 4, 3, 2, 1])
3154
- end
3155
-
3156
- describe "#test_array_fixed_size_int_in" do
3157
- it "raises an error when called with the wrong number of arguments" do
3158
- assert_raises ArgumentError do
3159
- Regress.test_array_fixed_size_int_in [2]
3160
- end
3161
- end
3162
- end
3163
-
3164
- it "has a working function #test_array_fixed_size_int_out" do
3165
- _(Regress.test_array_fixed_size_int_out).must_be :==, [0, 1, 2, 3, 4]
3166
- end
3167
-
3168
- it "has a working function #test_array_fixed_size_int_return" do
3169
- _(Regress.test_array_fixed_size_int_return).must_be :==, [0, 1, 2, 3, 4]
3170
- end
3171
-
3172
- it "has a working function #test_array_gint16_in" do
3173
- assert_equal 5 + 4 + 3, Regress.test_array_gint16_in([5, 4, 3])
3174
- end
3175
-
3176
- it "has a working function #test_array_gint32_in" do
3177
- assert_equal 5 + 4 + 3, Regress.test_array_gint32_in([5, 4, 3])
3178
- end
3179
-
3180
- it "has a working function #test_array_gint64_in" do
3181
- assert_equal 5 + 4 + 3, Regress.test_array_gint64_in([5, 4, 3])
3182
- end
3183
-
3184
- it "has a working function #test_array_gint8_in" do
3185
- assert_equal 5 + 4 + 3, Regress.test_array_gint8_in([5, 4, 3])
3186
- end
3187
-
3188
- it "has a working function #test_array_gtype_in" do
3189
- t1 = GObject.type_from_name "gboolean"
3190
- t2 = GObject.type_from_name "gint64"
3191
- assert_equal "[gboolean,gint64,]", Regress.test_array_gtype_in([t1, t2])
3192
- end
3193
-
3194
- it "has a working function #test_array_inout_callback" do
3195
- Regress.test_array_inout_callback do |ints|
3196
- arr = ints.to_a
3197
- arr.shift
3198
- arr
3199
- end
3200
- pass
3201
- end
3202
-
3203
- it "has a working function #test_array_int_full_out" do
3204
- _(Regress.test_array_int_full_out).must_be :==, [0, 1, 2, 3, 4]
3205
- end
3206
-
3207
- it "has a working function #test_array_int_in" do
3208
- assert_equal 5 + 4 + 3, Regress.test_array_int_in([5, 4, 3])
3209
- end
3210
-
3211
- it "has a working function #test_array_int_inout" do
3212
- _(Regress.test_array_int_inout([5, 2, 3])).must_be :==, [3, 4]
3213
- end
3214
-
3215
- it "has a working function #test_array_int_none_out" do
3216
- _(Regress.test_array_int_none_out).must_be :==, [1, 2, 3, 4, 5]
3217
- end
3218
-
3219
- it "has a working function #test_array_int_null_in" do
3220
- Regress.test_array_int_null_in nil
3221
- pass
3222
- end
3223
-
3224
- it "has a working function #test_array_int_null_out" do
3225
- _(Regress.test_array_int_null_out).must_be_nil
3226
- end
3227
-
3228
- it "has a working function #test_array_int_out" do
3229
- _(Regress.test_array_int_out).must_be :==, [0, 1, 2, 3, 4]
3230
- end
3231
-
3232
- it "has a working function #test_array_struct_in_full" do
3233
- skip_below "1.59.4"
3234
- # FIXME: Allow passing field values to .new
3235
- arr = [Regress::TestStructA.new.tap { |it| it.some_int = 201 },
3236
- Regress::TestStructA.new.tap { |it| it.some_int = 202 }]
3237
- Regress.test_array_struct_in_full(arr)
3238
- end
3239
-
3240
- it "has a working function #test_array_struct_in_none" do
3241
- skip_below "1.59.4"
3242
- # FIXME: Allow passing field values to .new
3243
- arr = [Regress::TestStructA.new.tap { |it| it.some_int = 301 },
3244
- Regress::TestStructA.new.tap { |it| it.some_int = 302 },
3245
- Regress::TestStructA.new.tap { |it| it.some_int = 303 }]
3246
- Regress.test_array_struct_in_none(arr)
3247
- end
3248
-
3249
- it "has a working function #test_array_struct_out" do
3250
- skip_below "1.47.92"
3251
- result = Regress.test_array_struct_out
3252
- _(result.map(&:some_int)).must_equal [22, 33, 44]
3253
- end
3254
-
3255
- it "has a working function #test_array_struct_out_caller_alloc" do
3256
- skip_below "1.59.4"
3257
- skip "Not implemented yet"
3258
- result = Regress.test_array_struct_out_caller_alloc 3
3259
- _(result.map(&:some_int)).must_equal [22, 33, 44]
3260
- end
3261
-
3262
- it "has a working function #test_array_struct_out_container" do
3263
- skip_below "1.59.4"
3264
- result = Regress.test_array_struct_out_container
3265
- _(result.map(&:some_int)).must_equal [11, 13, 17, 19, 23]
3266
- end
3267
-
3268
- it "has a working function #test_array_struct_out_full_fixed" do
3269
- skip_below "1.59.4"
3270
- result = Regress.test_array_struct_out_full_fixed
3271
- _(result.map(&:some_int)).must_equal [2, 3, 5, 7]
3272
- end
3273
-
3274
- it "has a working function #test_array_struct_out_none" do
3275
- skip_below "1.59.4"
3276
- result = Regress.test_array_struct_out_none
3277
- _(result.map(&:some_int)).must_equal [111, 222, 333]
3278
- end
3279
-
3280
- it "has a working function #test_async_ready_callback" do
3281
- main_loop = GLib::MainLoop.new nil, false
3282
-
3283
- a = 1
3284
- Regress.test_async_ready_callback do
3285
- main_loop.quit
3286
- a = 2
3287
- end
3288
-
3289
- main_loop.run
3290
-
3291
- assert_equal 2, a
3292
- end
3293
-
3294
- it "has a working function #test_boolean" do
3295
- assert_equal false, Regress.test_boolean(false)
3296
- assert_equal true, Regress.test_boolean(true)
3297
- end
3298
-
3299
- it "has a working function #test_boolean_false" do
3300
- assert_equal false, Regress.test_boolean_false(false)
3301
- end
3302
-
3303
- it "has a working function #test_boolean_true" do
3304
- assert_equal true, Regress.test_boolean_true(true)
3305
- end
3306
-
3307
- it "has a working function #test_boxeds_not_a_method" do
3308
- boxed = Regress::TestBoxed.new_alternative_constructor1 123
3309
- Regress.test_boxeds_not_a_method boxed
3310
- pass
3311
- end
3312
-
3313
- it "has a working function #test_boxeds_not_a_static" do
3314
- Regress.test_boxeds_not_a_static
3315
- pass
3316
- end
3317
-
3318
- it "has a working function #test_cairo_context_full_return" do
3319
- ct = Regress.test_cairo_context_full_return
3320
- assert_instance_of Cairo::Context, ct
3321
- end
3322
-
3323
- it "has a working function #test_cairo_context_none_in" do
3324
- ct = Regress.test_cairo_context_full_return
3325
- Regress.test_cairo_context_none_in ct
3326
- end
3327
-
3328
- it "has a working function #test_cairo_surface_full_out" do
3329
- cs = Regress.test_cairo_surface_full_out
3330
- assert_instance_of Cairo::Surface, cs
3331
- end
3332
-
3333
- it "has a working function #test_cairo_surface_full_return" do
3334
- cs = Regress.test_cairo_surface_full_return
3335
- assert_instance_of Cairo::Surface, cs
3336
- end
3337
-
3338
- it "has a working function #test_cairo_surface_none_in" do
3339
- cs = Regress.test_cairo_surface_full_return
3340
- Regress.test_cairo_surface_none_in cs
3341
- end
3342
-
3343
- it "has a working function #test_cairo_surface_none_return" do
3344
- cs = Regress.test_cairo_surface_none_return
3345
- assert_instance_of Cairo::Surface, cs
3346
- end
3347
-
3348
- it "has a working function #test_callback" do
3349
- result = Regress.test_callback { 5 }
3350
- assert_equal 5, result
3351
- end
3352
-
3353
- it "has a working function #test_callback_async" do
3354
- a = 1
3355
- stored_proc = nil
3356
- Regress.test_callback_async do |user_data|
3357
- stored_proc = user_data
3358
- a = 2
3359
- end
3360
- result = Regress.test_callback_thaw_async
3361
- _(a).must_equal 2
3362
- _(stored_proc).wont_be_nil
3363
- _(result).must_equal 2
3364
- # TODO: See when we can clean up the stored callback for async callbacks.
3365
- stored_id = stored_proc.object_id
3366
- _(GirFFI::CallbackBase::CALLBACKS[stored_id].object_id).must_equal stored_id
3367
- end
3368
-
3369
- it "has a working function #test_callback_destroy_notify" do
3370
- a = 1
3371
- stored_proc = nil
3372
- r1 = Regress.test_callback_destroy_notify do |user_data|
3373
- stored_proc = user_data
3374
- a = 2
3375
- end
3376
- _(a).must_equal 2
3377
- stored_id = stored_proc.object_id
3378
- _(GirFFI::CallbackBase::CALLBACKS[stored_id].object_id).must_equal stored_id
3379
-
3380
- a = 3
3381
- r2 = Regress.test_callback_thaw_notifications
3382
- _(a).must_equal 2
3383
- _(r1).must_equal r2
3384
- _(GirFFI::CallbackBase::CALLBACKS[stored_id]).must_be_nil
3385
- end
3386
-
3387
- it "has a working function #test_callback_destroy_notify_no_user_data" do
3388
- callback_times_called = 0
3389
- b = :not_nil
3390
-
3391
- result = Regress.test_callback_destroy_notify_no_user_data do |user_data|
3392
- callback_times_called += 1
3393
- b = user_data
3394
- callback_times_called * 5
3395
- end
3396
-
3397
- _(callback_times_called).must_equal 1
3398
- _(result).must_equal 5
3399
- _(b).must_be_nil
3400
-
3401
- result = Regress.test_callback_thaw_notifications
3402
-
3403
- _(callback_times_called).must_equal 2
3404
- _(result).must_equal 10
3405
- _(b).must_be_nil
3406
- end
3407
-
3408
- it "has a working function #test_callback_return_full" do
3409
- obj = Regress::TestObj.constructor
3410
- Regress.test_callback_return_full { obj }
3411
- _(object_ref_count(obj)).must_equal 1
3412
- end
3413
-
3414
- it "has a working function #test_callback_thaw_async" do
3415
- invoked = []
3416
- Regress.test_callback_async do
3417
- invoked << 1
3418
- 1
3419
- end
3420
- Regress.test_callback_async do
3421
- invoked << 2
3422
- 2
3423
- end
3424
- Regress.test_callback_async do
3425
- invoked << 3
3426
- 3
3427
- end
3428
- result = Regress.test_callback_thaw_async
3429
- _(invoked).must_equal [3, 2, 1]
3430
- _(result).must_equal 1
3431
- end
3432
-
3433
- it "has a working function #test_callback_thaw_notifications" do
3434
- Regress.test_callback_destroy_notify { 42 }
3435
- Regress.test_callback_destroy_notify { 24 }
3436
- result = Regress.test_callback_thaw_notifications
3437
- _(result).must_equal 66
3438
- end
3439
-
3440
- it "has a working function #test_callback_user_data" do
3441
- stored_id = nil
3442
- result = Regress.test_callback_user_data do |u|
3443
- stored_id = u
3444
- 5
3445
- end
3446
- # TODO: Ensure that the key stored_id is no longer in the callback store
3447
- _(stored_id).wont_be_nil
3448
- _(result).must_equal 5
3449
- end
3450
-
3451
- it "has a working function #test_closure" do
3452
- c = GObject::RubyClosure.new { 5235 }
3453
- r = Regress.test_closure c
3454
- assert_equal 5235, r
3455
- end
3456
-
3457
- it "has a working function #test_closure_one_arg" do
3458
- c = GObject::RubyClosure.new { |a| a * 2 }
3459
- r = Regress.test_closure_one_arg c, 2
3460
- assert_equal 4, r
3461
- end
3462
-
3463
- it "has a working function #test_closure_variant" do
3464
- arg = GLib::Variant.new_string "foo"
3465
-
3466
- # TODO: Convert proc to RubyClosure automatically
3467
- closure = GObject::RubyClosure.new do |variant|
3468
- str = variant.get_string
3469
- if str == "foo"
3470
- GLib::Variant.new_int32 40
3471
- else
3472
- GLib::Variant.new_string "bar"
3473
- end
3474
- end
3475
-
3476
- result = Regress.test_closure_variant closure, arg
3477
-
3478
- _(result.get_int32).must_equal 40
3479
- end
3480
-
3481
- it "has a working function #test_create_fundamental_hidden_class_instance" do
3482
- skip_below "1.51.2"
3483
- instance = Regress.test_create_fundamental_hidden_class_instance
3484
- _(instance).must_be_kind_of Regress::TestFundamentalObject
3485
- g_type = instance.object_class.g_type
3486
- _(GObject.type_name(g_type)).must_equal "RegressTestFundamentalHiddenSubObject"
3487
- end
3488
-
3489
- it "has a working function #test_date_in_gvalue" do
3490
- date = Regress.test_date_in_gvalue
3491
- assert_equal [1984, :december, 5],
3492
- [date.get_year, date.get_month, date.get_day]
3493
- end
3494
-
3495
- it "has a working function #test_def_error_quark" do
3496
- quark = Regress.test_def_error_quark
3497
- _(GLib.quark_to_string(quark)).must_equal "regress-test-def-error"
3498
- end
3499
-
3500
- it "has a working function #test_double" do
3501
- r = Regress.test_double 5435.32
3502
- assert_equal 5435.32, r
3503
- end
3504
-
3505
- it "has a working function #test_enum_param" do
3506
- r = Regress.test_enum_param :value3
3507
- assert_equal "value3", r
3508
- end
3509
-
3510
- it "has a working function #test_error_quark" do
3511
- quark = Regress.test_error_quark
3512
- _(GLib.quark_to_string(quark)).must_equal "regress-test-error"
3513
- end
3514
-
3515
- it "has a working function #test_filename_return" do
3516
- arr = Regress.test_filename_return
3517
- _(arr).must_be :==, ["åäö", "/etc/fstab"]
3518
- end
3519
-
3520
- it "has a working function #test_float" do
3521
- r = Regress.test_float 5435.32
3522
- assert_in_delta 5435.32, r, 0.001
3523
- end
3524
-
3525
- it "has a working function #test_garray_container_return" do
3526
- arr = Regress.test_garray_container_return
3527
- _(arr).must_be_instance_of GLib::PtrArray
3528
- _(arr.len).must_equal 1
3529
- _(arr.to_a).must_equal ["regress"]
3530
- end
3531
-
3532
- it "has a working function #test_garray_full_return" do
3533
- result = Regress.test_garray_full_return
3534
- _(result.to_a).must_equal ["regress"]
3535
- end
3536
-
3537
- it "has a working function #test_gerror_callback" do
3538
- result = nil
3539
- Regress.test_gerror_callback { |err| result = err.message }
3540
- _(result).must_equal "regression test error"
3541
- end
3542
-
3543
- it "has a working function #test_ghash_container_return" do
3544
- hash = Regress.test_ghash_container_return
3545
- _(hash).must_be_instance_of GLib::HashTable
3546
- _(hash.to_hash).must_equal("foo" => "bar",
3547
- "baz" => "bat",
3548
- "qux" => "quux")
3549
- end
3550
-
3551
- it "has a working function #test_ghash_everything_return" do
3552
- ghash = Regress.test_ghash_everything_return
3553
- _(ghash.to_hash).must_be :==, "foo" => "bar",
3554
- "baz" => "bat",
3555
- "qux" => "quux"
3556
- end
3557
-
3558
- it "has a working function #test_ghash_gvalue_in" do
3559
- hash_table = Regress.test_ghash_gvalue_return
3560
- Regress.test_ghash_gvalue_in hash_table
3561
- end
3562
-
3563
- it "has a working function #test_ghash_gvalue_return" do
3564
- result = Regress.test_ghash_gvalue_return
3565
- hash = result.to_hash
3566
-
3567
- has_enum_and_flag_keys = hash.key?("flags")
3568
-
3569
- _(hash["integer"].get_value).must_equal 12
3570
- _(hash["boolean"].get_value).must_equal true
3571
- _(hash["string"].get_value).must_equal "some text"
3572
- _(hash["strings"].get_value.to_a).must_equal %w(first second third)
3573
-
3574
- if has_enum_and_flag_keys
3575
- _(hash["flags"].get_value).must_equal flag1: true, flag3: true
3576
- _(hash["enum"].get_value).must_equal :value2
3577
- end
3578
-
3579
- expected_keys = if has_enum_and_flag_keys
3580
- %w(boolean enum flags integer string strings)
3581
- else
3582
- %w(boolean integer string strings)
3583
- end
3584
-
3585
- _(hash.keys.sort).must_equal expected_keys
3586
- end
3587
-
3588
- it "has a working function #test_ghash_nested_everything_return" do
3589
- result = Regress.test_ghash_nested_everything_return
3590
- hash = result.to_hash
3591
- _(hash.keys).must_equal ["wibble"]
3592
- _(hash["wibble"].to_hash).must_equal("foo" => "bar",
3593
- "baz" => "bat",
3594
- "qux" => "quux")
3595
- end
3596
-
3597
- it "has a working function #test_ghash_nested_everything_return2" do
3598
- result = Regress.test_ghash_nested_everything_return2
3599
- hash = result.to_hash
3600
- _(hash.keys).must_equal ["wibble"]
3601
- _(hash["wibble"].to_hash).must_equal("foo" => "bar",
3602
- "baz" => "bat",
3603
- "qux" => "quux")
3604
- end
3605
-
3606
- it "has a working function #test_ghash_nothing_in" do
3607
- Regress.test_ghash_nothing_in("foo" => "bar",
3608
- "baz" => "bat",
3609
- "qux" => "quux")
3610
- end
3611
-
3612
- it "has a working function #test_ghash_nothing_in2" do
3613
- Regress.test_ghash_nothing_in2("foo" => "bar",
3614
- "baz" => "bat",
3615
- "qux" => "quux")
3616
- end
3617
-
3618
- it "has a working function #test_ghash_nothing_return" do
3619
- ghash = Regress.test_ghash_nothing_return
3620
- _(ghash.to_hash).must_be :==, "foo" => "bar",
3621
- "baz" => "bat",
3622
- "qux" => "quux"
3623
- end
3624
-
3625
- it "has a working function #test_ghash_nothing_return2" do
3626
- ghash = Regress.test_ghash_nothing_return2
3627
- _(ghash.to_hash).must_be :==, "foo" => "bar",
3628
- "baz" => "bat",
3629
- "qux" => "quux"
3630
- end
3631
-
3632
- it "has a working function #test_ghash_null_in" do
3633
- Regress.test_ghash_null_in(nil)
3634
- end
3635
-
3636
- it "has a working function #test_ghash_null_out" do
3637
- ghash = Regress.test_ghash_null_out
3638
- _(ghash).must_be_nil
3639
- end
3640
-
3641
- it "has a working function #test_ghash_null_return" do
3642
- ghash = Regress.test_ghash_null_return
3643
- _(ghash).must_be_nil
3644
- end
3645
-
3646
- it "has a working function #test_glist_container_return" do
3647
- list = Regress.test_glist_container_return
3648
- assert_instance_of GLib::List, list
3649
- _(list).must_be :==, %w(1 2 3)
3650
- end
3651
-
3652
- it "has a working function #test_glist_everything_return" do
3653
- list = Regress.test_glist_everything_return
3654
- _(list).must_be :==, %w(1 2 3)
3655
- end
3656
-
3657
- it "has a working function #test_glist_gtype_container_in" do
3658
- Regress.test_glist_gtype_container_in [Regress::TestObj.gtype, Regress::TestSubObj.gtype]
3659
- pass
3660
- end
3661
-
3662
- it "has a working function #test_glist_nothing_in" do
3663
- Regress.test_glist_nothing_in %w(1 2 3)
3664
- pass
3665
- end
3666
-
3667
- it "has a working function #test_glist_nothing_in2" do
3668
- Regress.test_glist_nothing_in2 %w(1 2 3)
3669
- pass
3670
- end
3671
-
3672
- it "has a working function #test_glist_nothing_return" do
3673
- list = Regress.test_glist_nothing_return
3674
- _(list).must_be :==, %w(1 2 3)
3675
- end
3676
-
3677
- it "has a working function #test_glist_nothing_return2" do
3678
- list = Regress.test_glist_nothing_return2
3679
- _(list).must_be :==, %w(1 2 3)
3680
- end
3681
-
3682
- it "has a working function #test_glist_null_in" do
3683
- Regress.test_glist_null_in nil
3684
- pass
3685
- end
3686
-
3687
- it "has a working function #test_glist_null_out" do
3688
- result = Regress.test_glist_null_out
3689
- _(result).must_be_nil
3690
- end
3691
-
3692
- it "has a working function #test_gslist_container_return" do
3693
- slist = Regress.test_gslist_container_return
3694
- assert_instance_of GLib::SList, slist
3695
- _(slist).must_be :==, %w(1 2 3)
3696
- end
3697
-
3698
- it "has a working function #test_gslist_everything_return" do
3699
- slist = Regress.test_gslist_everything_return
3700
- _(slist).must_be :==, %w(1 2 3)
3701
- end
3702
-
3703
- it "has a working function #test_gslist_nothing_in" do
3704
- Regress.test_gslist_nothing_in %w(1 2 3)
3705
- pass
3706
- end
3707
-
3708
- it "has a working function #test_gslist_nothing_in2" do
3709
- Regress.test_gslist_nothing_in2 %w(1 2 3)
3710
- pass
3711
- end
3712
-
3713
- it "has a working function #test_gslist_nothing_return" do
3714
- slist = Regress.test_gslist_nothing_return
3715
- _(slist).must_be :==, %w(1 2 3)
3716
- end
3717
-
3718
- it "has a working function #test_gslist_nothing_return2" do
3719
- slist = Regress.test_gslist_nothing_return2
3720
- _(slist).must_be :==, %w(1 2 3)
3721
- end
3722
-
3723
- it "has a working function #test_gslist_null_in" do
3724
- Regress.test_gslist_null_in nil
3725
- pass
3726
- end
3727
-
3728
- it "has a working function #test_gslist_null_out" do
3729
- result = Regress.test_gslist_null_out
3730
- _(result).must_be_nil
3731
- end
3732
-
3733
- it "has a working function #test_gtype" do
3734
- result = Regress.test_gtype 23
3735
- assert_equal 23, result
3736
- end
3737
-
3738
- it "has a working function #test_gvariant_as" do
3739
- _(Regress.test_gvariant_as.get_strv.to_a).must_equal %w(one two three)
3740
- end
3741
-
3742
- it "has a working function #test_gvariant_asv" do
3743
- result = Regress.test_gvariant_asv
3744
- _(result.n_children).must_equal 2
3745
- _(result.lookup_value("name").get_string).must_equal "foo"
3746
- _(result.lookup_value("timeout").get_int32).must_equal 10
3747
- end
3748
-
3749
- it "has a working function #test_gvariant_i" do
3750
- _(Regress.test_gvariant_i.get_int32).must_equal 1
3751
- end
3752
-
3753
- it "has a working function #test_gvariant_s" do
3754
- _(Regress.test_gvariant_s.get_string).must_equal "one"
3755
- end
3756
-
3757
- it "has a working function #test_gvariant_v" do
3758
- _(Regress.test_gvariant_v.get_variant.get_string).must_equal "contents"
3759
- end
3760
-
3761
- it "has a working function #test_hash_table_callback" do
3762
- value = nil
3763
- Regress.test_hash_table_callback("foo" => 42) { |hash| value = hash }
3764
- _(value.to_hash).must_equal("foo" => 42)
3765
- end
3766
-
3767
- it "has a working function #test_int" do
3768
- result = Regress.test_int 23
3769
- assert_equal 23, result
3770
- end
3771
-
3772
- it "has a working function #test_int16" do
3773
- result = Regress.test_int16 23
3774
- assert_equal 23, result
3775
- end
3776
-
3777
- it "has a working function #test_int32" do
3778
- result = Regress.test_int32 23
3779
- assert_equal 23, result
3780
- end
3781
-
3782
- it "has a working function #test_int64" do
3783
- result = Regress.test_int64 2_300_000_000_000
3784
- assert_equal 2_300_000_000_000, result
3785
- end
3786
-
3787
- it "has a working function #test_int8" do
3788
- result = Regress.test_int8 23
3789
- assert_equal 23, result
3790
- end
3791
-
3792
- it "has a working function #test_int_out_utf8" do
3793
- len = Regress.test_int_out_utf8 "How long?"
3794
- assert_equal 9, len
3795
- end
3796
-
3797
- it "has a working function #test_int_value_arg" do
3798
- gv = GObject::Value.new
3799
- gv.init GObject.type_from_name "gint"
3800
- gv.set_int 343
3801
- result = Regress.test_int_value_arg gv
3802
- assert_equal 343, result
3803
- end
3804
-
3805
- it "has a working function #test_long" do
3806
- long_val = FFI.type_size(:long) == 8 ? 2_300_000_000_000 : 2_000_000_000
3807
- result = Regress.test_long long_val
3808
- assert_equal long_val, result
3809
- end
3810
-
3811
- it "has a working function #test_multi_callback" do
3812
- a = 1
3813
- result = Regress.test_multi_callback do
3814
- a += 1
3815
- 23
3816
- end
3817
- assert_equal 2 * 23, result
3818
- assert_equal 3, a
3819
- end
3820
-
3821
- it "has a working function #test_multi_double_args" do
3822
- one, two = Regress.test_multi_double_args 23.1
3823
- assert_equal 2 * 23.1, one
3824
- assert_equal 3 * 23.1, two
3825
- end
3826
-
3827
- it "has a working function #test_multiline_doc_comments" do
3828
- _(Regress.test_multiline_doc_comments).must_be_nil
3829
- end
3830
-
3831
- it "has a working function #test_nested_parameter" do
3832
- _(Regress.test_nested_parameter(3)).must_be_nil
3833
- end
3834
-
3835
- it "has a working function #test_noptr_callback" do
3836
- skip_below "1.47.1"
3837
- a = 0
3838
- Regress.test_noptr_callback { a = 1 }
3839
- _(a).must_equal 1
3840
- end
3841
-
3842
- it "has a working function #test_null_gerror_callback" do
3843
- value = nil
3844
- Regress.test_owned_gerror_callback { |err| value = err }
3845
- _(value.message).must_equal "regression test owned error"
3846
- end
3847
-
3848
- it "has a working function #test_null_strv_in_gvalue" do
3849
- skip_below "1.53.1"
3850
- result = Regress.test_null_strv_in_gvalue
3851
- _(result.to_a).must_be :empty?
3852
- end
3853
-
3854
- it "has a working function #test_owned_gerror_callback" do
3855
- value = nil
3856
- Regress.test_owned_gerror_callback { |err| value = err }
3857
- _(value.message).must_equal "regression test owned error"
3858
- end
3859
-
3860
- it "has a working function #test_return_allow_none" do
3861
- skip_below "1.47.1"
3862
- result = Regress.test_return_allow_none
3863
- _(result).must_be_nil
3864
- end
3865
-
3866
- it "has a working function #test_return_nullable" do
3867
- skip_below "1.47.1"
3868
- result = Regress.test_return_nullable
3869
- _(result).must_be_nil
3870
- end
3871
-
3872
- it "has a working function #test_short" do
3873
- result = Regress.test_short 23
3874
- assert_equal 23, result
3875
- end
3876
-
3877
- it "has a working function #test_simple_boxed_a_const_return" do
3878
- result = Regress.test_simple_boxed_a_const_return
3879
- assert_equal [5, 6, 7.0], [result.some_int, result.some_int8, result.some_double]
3880
- end
3881
-
3882
- it "has a working function #test_simple_callback" do
3883
- a = 0
3884
- Regress.test_simple_callback { a = 1 }
3885
- assert_equal 1, a
3886
- end
3887
-
3888
- it "has a working function #test_size" do
3889
- assert_equal 2354, Regress.test_size(2354)
3890
- end
3891
-
3892
- it "has a working function #test_ssize" do
3893
- assert_equal(-2_000_000, Regress.test_ssize(-2_000_000))
3894
- end
3895
-
3896
- it "has a working function #test_struct_a_parse" do
3897
- a = Regress.test_struct_a_parse("this string is actually ignored")
3898
- _(a).must_be_instance_of Regress::TestStructA
3899
- _(a.some_int).must_equal 23
3900
- end
3901
-
3902
- it "has a working function #test_strv_in" do
3903
- assert_equal true, Regress.test_strv_in(%w(1 2 3))
3904
- end
3905
-
3906
- it "has a working function #test_strv_in_gvalue" do
3907
- arr = Regress.test_strv_in_gvalue
3908
- _(arr).must_be :==, %w(one two three)
3909
- end
3910
-
3911
- it "has a working function #test_strv_out" do
3912
- arr = Regress.test_strv_out
3913
- _(arr).must_be :==, %w(thanks for all the fish)
3914
- end
3915
-
3916
- it "has a working function #test_strv_out_c" do
3917
- arr = Regress.test_strv_out_c
3918
- _(arr).must_be :==, %w(thanks for all the fish)
3919
- end
3920
-
3921
- it "has a working function #test_strv_out_container" do
3922
- arr = Regress.test_strv_out_container
3923
- _(arr).must_be :==, %w(1 2 3)
3924
- end
3925
-
3926
- it "has a working function #test_strv_outarg" do
3927
- arr = Regress.test_strv_outarg
3928
- _(arr).must_be :==, %w(1 2 3)
3929
- end
3930
-
3931
- it "has a working function #test_timet" do
3932
- # Time rounded to seconds.
3933
- t = Time.at(Time.now.to_i)
3934
- result = Regress.test_timet(t.to_i)
3935
- assert_equal t, Time.at(result)
3936
- end
3937
-
3938
- it "has a working function #test_torture_signature_0" do
3939
- y, z, q = Regress.test_torture_signature_0 86, "foo", 2
3940
- assert_equal [86, 2 * 86, 3 + 2], [y, z, q]
3941
- end
3942
-
3943
- it "has a working function #test_torture_signature_1" do
3944
- ret, y, z, q = Regress.test_torture_signature_1(-21, "hello", 12)
3945
- _([ret, y, z, q]).must_equal [true, -21, 2 * -21, "hello".length + 12]
3946
-
3947
- _(proc { Regress.test_torture_signature_1(-21, "hello", 11) })
3948
- .must_raise GirFFI::GLibError
3949
- end
3950
-
3951
- it "has a working function #test_torture_signature_2" do
3952
- a = 1
3953
- y, z, q = Regress.test_torture_signature_2 244, "foofoo", 31 do |u|
3954
- a = u
3955
- end
3956
- assert_equal [244, 2 * 244, 6 + 31], [y, z, q]
3957
- _(a).must_be_instance_of Regress::TestCallbackUserData
3958
- end
3959
-
3960
- it "has a working function #test_uint" do
3961
- assert_equal 31, Regress.test_uint(31)
3962
- end
3963
-
3964
- it "has a working function #test_uint16" do
3965
- assert_equal 31, Regress.test_uint16(31)
3966
- end
3967
-
3968
- it "has a working function #test_uint32" do
3969
- assert_equal 540_000, Regress.test_uint32(540_000)
3970
- end
3971
-
3972
- it "has a working function #test_uint64" do
3973
- assert_equal 54_000_000_000_000, Regress.test_uint64(54_000_000_000_000)
3974
- end
3975
-
3976
- it "has a working function #test_uint8" do
3977
- assert_equal 31, Regress.test_uint8(31)
3978
- end
3979
-
3980
- it "has a working function #test_ulong" do
3981
- assert_equal 54_000_000_000_000, Regress.test_uint64(54_000_000_000_000)
3982
- end
3983
-
3984
- it "has a working function #test_unconventional_error_quark" do
3985
- result = Regress.test_unconventional_error_quark
3986
- _(GLib.quark_to_string(result)).must_equal "regress-test-other-error"
3987
- end
3988
-
3989
- it "has a working function #test_unichar" do
3990
- assert_equal 120, Regress.test_unichar(120)
3991
- assert_equal 540_000, Regress.test_unichar(540_000)
3992
- end
3993
-
3994
- it "has a working function #test_unsigned_enum_param" do
3995
- assert_equal "value1", Regress.test_unsigned_enum_param(:value1)
3996
- assert_equal "value2", Regress.test_unsigned_enum_param(:value2)
3997
- end
3998
-
3999
- it "has a working function #test_ushort" do
4000
- assert_equal 54_000_000, Regress.test_uint64(54_000_000)
4001
- end
4002
-
4003
- it "has a working function #test_utf8_const_in" do
4004
- Regress.test_utf8_const_in("const \xe2\x99\xa5 utf8")
4005
- pass
4006
- end
4007
-
4008
- it "has a working function #test_utf8_const_return" do
4009
- result = Regress.test_utf8_const_return
4010
- assert_equal "const \xe2\x99\xa5 utf8", result
4011
- end
4012
-
4013
- it "has a working function #test_utf8_inout" do
4014
- result = Regress.test_utf8_inout "const \xe2\x99\xa5 utf8"
4015
- assert_equal "nonconst \xe2\x99\xa5 utf8", result
4016
- end
4017
-
4018
- it "has a working function #test_utf8_nonconst_return" do
4019
- result = Regress.test_utf8_nonconst_return
4020
- assert_equal "nonconst \xe2\x99\xa5 utf8", result
4021
- end
4022
-
4023
- it "has a working function #test_utf8_null_in" do
4024
- Regress.test_utf8_null_in nil
4025
- pass
4026
- end
4027
-
4028
- it "has a working function #test_utf8_null_out" do
4029
- _(Regress.test_utf8_null_out).must_be_nil
4030
- end
4031
-
4032
- it "has a working function #test_utf8_out" do
4033
- result = Regress.test_utf8_out
4034
- assert_equal "nonconst \xe2\x99\xa5 utf8", result
4035
- end
4036
-
4037
- it "has a working function #test_utf8_out_nonconst_return" do
4038
- r, out = Regress.test_utf8_out_nonconst_return
4039
- assert_equal %w(first second), [r, out]
4040
- end
4041
-
4042
- it "has a working function #test_utf8_out_out" do
4043
- out0, out1 = Regress.test_utf8_out_nonconst_return
4044
- assert_equal %w(first second), [out0, out1]
4045
- end
4046
-
4047
- it "has a working function #test_value_return" do
4048
- result = Regress.test_value_return 3423
4049
- _(result).must_equal 3423
4050
- end
4051
-
4052
- it "has a working function #test_versioning" do
4053
- # TODO: Handle deprecation
4054
- Regress.test_versioning
4055
- pass
4056
- end
4057
-
4058
- it "raises an appropriate NoMethodError when a function is not found" do
4059
- result = _(proc { Regress.this_method_does_not_exist }).must_raise(NoMethodError)
4060
- _(result.message).must_match(/^undefined method `this_method_does_not_exist' (for Regress:Module|on Regress \(Module\))$/)
4061
- end
4062
- end