gir_ffi 0.15.0 → 0.15.5

Sign up to get free protection for your applications and to get access to all the features.
Files changed (191) hide show
  1. checksums.yaml +4 -4
  2. data/Changelog.md +39 -0
  3. data/README.md +10 -10
  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 +1 -4
  16. data/lib/ffi-gobject/object.rb +96 -92
  17. data/lib/ffi-gobject/object_class.rb +1 -1
  18. data/lib/ffi-gobject/value.rb +108 -107
  19. data/lib/ffi-gobject_introspection/i_base_info.rb +23 -22
  20. data/lib/ffi-gobject_introspection/lib.rb +1 -1
  21. data/lib/gir_ffi-base/gobject/lib.rb +4 -0
  22. data/lib/gir_ffi/array_element_convertor.rb +1 -2
  23. data/lib/gir_ffi/boxed_base.rb +1 -5
  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/argument_builder.rb +2 -2
  27. data/lib/gir_ffi/builders/argument_builder_collection.rb +2 -2
  28. data/lib/gir_ffi/builders/base_argument_builder.rb +2 -2
  29. data/lib/gir_ffi/builders/base_method_builder.rb +1 -1
  30. data/lib/gir_ffi/builders/base_type_builder.rb +1 -1
  31. data/lib/gir_ffi/builders/callback_argument_builder.rb +2 -0
  32. data/lib/gir_ffi/builders/callback_builder.rb +25 -11
  33. data/lib/gir_ffi/builders/callback_return_value_builder.rb +4 -6
  34. data/lib/gir_ffi/builders/enum_builder.rb +9 -5
  35. data/lib/gir_ffi/builders/field_builder.rb +4 -3
  36. data/lib/gir_ffi/builders/function_builder.rb +1 -1
  37. data/lib/gir_ffi/builders/interface_builder.rb +3 -1
  38. data/lib/gir_ffi/builders/mapping_method_builder.rb +1 -1
  39. data/lib/gir_ffi/builders/marshalling_method_builder.rb +5 -2
  40. data/lib/gir_ffi/builders/method_template.rb +4 -4
  41. data/lib/gir_ffi/builders/module_builder.rb +4 -2
  42. data/lib/gir_ffi/builders/null_argument_builder.rb +0 -2
  43. data/lib/gir_ffi/builders/null_return_value_builder.rb +0 -2
  44. data/lib/gir_ffi/builders/object_builder.rb +18 -6
  45. data/lib/gir_ffi/builders/property_builder.rb +1 -2
  46. data/lib/gir_ffi/builders/signal_closure_builder.rb +3 -5
  47. data/lib/gir_ffi/builders/struct_builder.rb +34 -7
  48. data/lib/gir_ffi/builders/user_defined_builder.rb +8 -1
  49. data/lib/gir_ffi/builders/vfunc_argument_builder.rb +1 -1
  50. data/lib/gir_ffi/builders/vfunc_builder.rb +2 -2
  51. data/lib/gir_ffi/callback_base.rb +6 -8
  52. data/lib/gir_ffi/class_base.rb +1 -0
  53. data/lib/gir_ffi/core.rb +17 -2
  54. data/lib/gir_ffi/glib_error.rb +1 -2
  55. data/lib/gir_ffi/in_pointer.rb +7 -0
  56. data/lib/gir_ffi/object_base.rb +27 -0
  57. data/lib/gir_ffi/return_value_info.rb +1 -2
  58. data/lib/gir_ffi/struct_base.rb +1 -9
  59. data/lib/gir_ffi/struct_like_base.rb +9 -5
  60. data/lib/gir_ffi/unintrospectable_type_info.rb +5 -1
  61. data/lib/gir_ffi/union_base.rb +1 -9
  62. data/lib/gir_ffi/user_defined_object_info.rb +3 -2
  63. data/lib/gir_ffi/version.rb +1 -1
  64. data/lib/gir_ffi/vfunc_implementation.rb +1 -0
  65. metadata +103 -140
  66. data/Gemfile +0 -14
  67. data/Rakefile +0 -9
  68. data/tasks/test.rake +0 -204
  69. data/test/base_test_helper.rb +0 -70
  70. data/test/ffi-glib/array_test.rb +0 -203
  71. data/test/ffi-glib/byte_array_test.rb +0 -28
  72. data/test/ffi-glib/bytes_test.rb +0 -61
  73. data/test/ffi-glib/closure_test.rb +0 -38
  74. data/test/ffi-glib/destroy_notify_test.rb +0 -18
  75. data/test/ffi-glib/hash_table_test.rb +0 -68
  76. data/test/ffi-glib/list_test.rb +0 -86
  77. data/test/ffi-glib/main_loop_test.rb +0 -53
  78. data/test/ffi-glib/ptr_array_test.rb +0 -112
  79. data/test/ffi-glib/ruby_closure_test.rb +0 -62
  80. data/test/ffi-glib/s_list_test.rb +0 -76
  81. data/test/ffi-glib/strv_test.rb +0 -60
  82. data/test/ffi-glib/variant_test.rb +0 -12
  83. data/test/ffi-gobject/gobject_test.rb +0 -76
  84. data/test/ffi-gobject/object_class_test.rb +0 -31
  85. data/test/ffi-gobject/object_test.rb +0 -122
  86. data/test/ffi-gobject/param_spec_test.rb +0 -32
  87. data/test/ffi-gobject/value_test.rb +0 -390
  88. data/test/ffi-gobject_introspection/gobject_type_init_test.rb +0 -26
  89. data/test/ffi-gobject_introspection/i_base_info_test.rb +0 -52
  90. data/test/ffi-gobject_introspection/i_constant_info_test.rb +0 -29
  91. data/test/ffi-gobject_introspection/i_enum_info_test.rb +0 -18
  92. data/test/ffi-gobject_introspection/i_function_info_test.rb +0 -6
  93. data/test/ffi-gobject_introspection/i_interface_info_test.rb +0 -23
  94. data/test/ffi-gobject_introspection/i_object_info_test.rb +0 -49
  95. data/test/ffi-gobject_introspection/i_property_info_test.rb +0 -47
  96. data/test/ffi-gobject_introspection/i_registered_type_info_test.rb +0 -27
  97. data/test/ffi-gobject_introspection/i_repository_test.rb +0 -81
  98. data/test/ffi-gobject_introspection/i_struct_info_test.rb +0 -23
  99. data/test/ffi-gobject_introspection/i_type_info_test.rb +0 -30
  100. data/test/ffi-gobject_introspection/i_union_info_test.rb +0 -17
  101. data/test/ffi-gobject_introspection/i_vfunc_info_test.rb +0 -41
  102. data/test/ffi-gobject_introspection/lib_test.rb +0 -13
  103. data/test/ffi-gobject_introspection/strv_test.rb +0 -46
  104. data/test/ffi-gobject_test.rb +0 -151
  105. data/test/gir_ffi/allocation_helper_test.rb +0 -36
  106. data/test/gir_ffi/arg_helper_test.rb +0 -139
  107. data/test/gir_ffi/boolean_test.rb +0 -43
  108. data/test/gir_ffi/boxed_base_test.rb +0 -65
  109. data/test/gir_ffi/builder_test.rb +0 -322
  110. data/test/gir_ffi/builders/argument_builder_test.rb +0 -651
  111. data/test/gir_ffi/builders/base_argument_builder_test.rb +0 -6
  112. data/test/gir_ffi/builders/callback_argument_builder_test.rb +0 -126
  113. data/test/gir_ffi/builders/callback_builder_test.rb +0 -117
  114. data/test/gir_ffi/builders/callback_return_value_builder_test.rb +0 -81
  115. data/test/gir_ffi/builders/constant_builder_test.rb +0 -6
  116. data/test/gir_ffi/builders/constructor_builder_test.rb +0 -37
  117. data/test/gir_ffi/builders/enum_builder_test.rb +0 -23
  118. data/test/gir_ffi/builders/field_builder_test.rb +0 -134
  119. data/test/gir_ffi/builders/function_builder_test.rb +0 -550
  120. data/test/gir_ffi/builders/initializer_builder_test.rb +0 -54
  121. data/test/gir_ffi/builders/interface_builder_test.rb +0 -32
  122. data/test/gir_ffi/builders/module_builder_test.rb +0 -43
  123. data/test/gir_ffi/builders/object_builder_test.rb +0 -98
  124. data/test/gir_ffi/builders/property_builder_test.rb +0 -158
  125. data/test/gir_ffi/builders/registered_type_builder_test.rb +0 -54
  126. data/test/gir_ffi/builders/return_value_builder_test.rb +0 -433
  127. data/test/gir_ffi/builders/signal_closure_builder_test.rb +0 -197
  128. data/test/gir_ffi/builders/struct_builder_test.rb +0 -93
  129. data/test/gir_ffi/builders/unintrospectable_boxed_builder_test.rb +0 -29
  130. data/test/gir_ffi/builders/unintrospectable_builder_test.rb +0 -73
  131. data/test/gir_ffi/builders/union_builder_test.rb +0 -28
  132. data/test/gir_ffi/builders/user_defined_builder_test.rb +0 -524
  133. data/test/gir_ffi/builders/vfunc_argument_builder_test.rb +0 -101
  134. data/test/gir_ffi/builders/vfunc_builder_test.rb +0 -241
  135. data/test/gir_ffi/callback_base_test.rb +0 -22
  136. data/test/gir_ffi/class_base_test.rb +0 -166
  137. data/test/gir_ffi/core_test.rb +0 -98
  138. data/test/gir_ffi/enum_base_test.rb +0 -43
  139. data/test/gir_ffi/error_type_info_test.rb +0 -50
  140. data/test/gir_ffi/ffi_ext/pointer_test.rb +0 -20
  141. data/test/gir_ffi/g_type_test.rb +0 -31
  142. data/test/gir_ffi/in_pointer_test.rb +0 -203
  143. data/test/gir_ffi/info_ext/i_callable_info_test.rb +0 -26
  144. data/test/gir_ffi/info_ext/i_callback_info_test.rb +0 -21
  145. data/test/gir_ffi/info_ext/i_field_info_test.rb +0 -37
  146. data/test/gir_ffi/info_ext/i_function_info_test.rb +0 -74
  147. data/test/gir_ffi/info_ext/i_signal_info_test.rb +0 -32
  148. data/test/gir_ffi/info_ext/i_type_info_test.rb +0 -711
  149. data/test/gir_ffi/info_ext/i_unresolved_info_test.rb +0 -19
  150. data/test/gir_ffi/info_ext/safe_constant_name_test.rb +0 -26
  151. data/test/gir_ffi/info_ext/safe_function_name_test.rb +0 -26
  152. data/test/gir_ffi/interface_base_test.rb +0 -20
  153. data/test/gir_ffi/method_stubber_test.rb +0 -65
  154. data/test/gir_ffi/object_base_test.rb +0 -64
  155. data/test/gir_ffi/object_store_test.rb +0 -41
  156. data/test/gir_ffi/receiver_argument_info_test.rb +0 -33
  157. data/test/gir_ffi/sized_array_test.rb +0 -206
  158. data/test/gir_ffi/struct_base_test.rb +0 -23
  159. data/test/gir_ffi/struct_like_base_test.rb +0 -167
  160. data/test/gir_ffi/type_map_test.rb +0 -17
  161. data/test/gir_ffi/unintrospectable_type_info_test.rb +0 -121
  162. data/test/gir_ffi/union_base_test.rb +0 -23
  163. data/test/gir_ffi/user_defined_object_info_test.rb +0 -119
  164. data/test/gir_ffi/user_defined_property_info_test.rb +0 -39
  165. data/test/gir_ffi/variable_name_generator_test.rb +0 -18
  166. data/test/gir_ffi/version_test.rb +0 -9
  167. data/test/gir_ffi/zero_terminated_test.rb +0 -108
  168. data/test/gir_ffi_test_helper.rb +0 -84
  169. data/test/integration/callback_exceptions_test.rb +0 -59
  170. data/test/integration/derived_classes_test.rb +0 -53
  171. data/test/integration/generated_everything_test.rb +0 -452
  172. data/test/integration/generated_gimarshallingtests_test.rb +0 -3096
  173. data/test/integration/generated_gio_test.rb +0 -116
  174. data/test/integration/generated_glib_test.rb +0 -10
  175. data/test/integration/generated_gobject_test.rb +0 -124
  176. data/test/integration/generated_gst_test.rb +0 -34
  177. data/test/integration/generated_gtk_source_test.rb +0 -32
  178. data/test/integration/generated_gtop_test.rb +0 -22
  179. data/test/integration/generated_pango_ft2_test.rb +0 -17
  180. data/test/integration/generated_pango_test.rb +0 -24
  181. data/test/integration/generated_regress_test.rb +0 -4038
  182. data/test/integration/generated_secret_test.rb +0 -14
  183. data/test/integration/generated_utility_test.rb +0 -174
  184. data/test/integration/generated_warnlib_test.rb +0 -43
  185. data/test/integration/method_lookup_test.rb +0 -34
  186. data/test/introspection_test_helper.rb +0 -93
  187. data/test/lib/Makefile.am +0 -110
  188. data/test/lib/autogen.sh +0 -4
  189. data/test/lib/configure.ac +0 -34
  190. data/test/lib/m4/jhflags.m4 +0 -21
  191. 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,34 +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
- end
24
-
25
- describe "Gst::AutoAudioSink" do
26
- let(:instance) { Gst::ElementFactory.make("autoaudiosink", "audiosink") }
27
-
28
- it "correctly fetches the name" do
29
- skip "Audio sink was not created" unless instance
30
- _(instance.get_name).must_equal "audiosink"
31
- _(instance.name).must_equal "audiosink"
32
- end
33
- end
34
- 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,4038 +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| callback.call; a = obj.get_name }
945
- end
946
- b = nil
947
- instance.do_baz { b = "hello" }
948
- _(a).must_equal "regress_foo"
949
- _(b).must_equal "hello"
950
- end
951
-
952
- it "handles the 'destroy-event' signal" do
953
- a = nil
954
- instance = make_derived_instance
955
- instance.signal_connect "destroy-event" do
956
- a = "hello"
957
- end
958
- GObject.signal_emit instance, "destroy-event"
959
- _(a).must_equal "hello"
960
- end
961
- end
962
-
963
- describe "Regress::FooSubobject" do
964
- it "creates an instance using #new" do
965
- skip "This function is defined in the header but not implemented"
966
- end
967
- end
968
-
969
- describe "Regress::FooThingWithArray" do
970
- let(:instance) { Regress::FooThingWithArray.new }
971
-
972
- it "has a writable field x" do
973
- _(instance.x).must_equal 0
974
- instance.x = 23
975
- _(instance.x).must_equal 23
976
- end
977
-
978
- it "has a writable field y" do
979
- _(instance.y).must_equal 0
980
- instance.y = 23
981
- _(instance.y).must_equal 23
982
- end
983
-
984
- it "has a writable field lines" do
985
- _(instance.lines).must_be :==, [0] * 80
986
- instance.lines = (1..80).to_a
987
- _(instance.lines).must_be :==, (1..80).to_a
988
- end
989
-
990
- it "has a writable field data" do
991
- _(instance.data).must_equal FFI::Pointer::NULL
992
- instance.data = FFI::Pointer.new(23)
993
- _(instance.data).must_equal FFI::Pointer.new(23)
994
- end
995
- end
996
-
997
- describe "Regress::FooUnion" do
998
- let(:instance) { Regress::FooUnion.new }
999
-
1000
- it "has a writable field regress_foo" do
1001
- _(instance.regress_foo).must_equal 0
1002
- instance.regress_foo = 23
1003
- _(instance.regress_foo).must_equal 23
1004
- end
1005
- end
1006
-
1007
- describe "Regress::FooUtilityStruct" do
1008
- let(:instance) { Regress::FooUtilityStruct.new }
1009
-
1010
- it "has a writable field bar" do
1011
- struct = Utility::Struct.new
1012
- struct.field = 23
1013
-
1014
- _(instance.bar.field).must_equal 0
1015
- instance.bar = struct
1016
- _(instance.bar.field).must_equal 23
1017
- end
1018
- end
1019
-
1020
- it "has the constant GI_SCANNER_ELSE" do
1021
- _(Regress::GI_SCANNER_ELSE).must_equal 3
1022
- end
1023
-
1024
- it "has the constant GI_SCANNER_IFDEF" do
1025
- _(Regress::GI_SCANNER_IFDEF).must_equal 3
1026
- end
1027
-
1028
- it "has the constant GUINT64_CONSTANT" do
1029
- _(Regress::GUINT64_CONSTANT).must_equal 18_446_744_073_709_551_615
1030
- end
1031
-
1032
- it "has the constant GUINT64_CONSTANTA" do
1033
- _(Regress::GUINT64_CONSTANTA).must_equal 18_446_744_073_709_551_615
1034
- end
1035
-
1036
- it "has the constant G_GINT64_CONSTANT" do
1037
- _(Regress::G_GINT64_CONSTANT).must_equal 1000
1038
- end
1039
-
1040
- it "has the constant INT_CONSTANT" do
1041
- assert_equal 4422, Regress::INT_CONSTANT
1042
- end
1043
-
1044
- it "has the constant LONG_STRING_CONSTANT" do
1045
- _(Regress::LONG_STRING_CONSTANT).must_equal %w(TYPE VALUE ENCODING CHARSET
1046
- LANGUAGE DOM INTL POSTAL PARCEL
1047
- HOME WORK PREF VOICE FAX MSG
1048
- CELL PAGER BBS MODEM CAR ISDN
1049
- VIDEO AOL APPLELINK ATTMAIL CIS
1050
- EWORLD INTERNET IBMMAIL MCIMAIL
1051
- POWERSHARE PRODIGY TLX X400 GIF
1052
- CGM WMF BMP MET PMB DIB PICT
1053
- TIFF PDF PS JPEG QTIME MPEG
1054
- MPEG2 AVI WAVE AIFF PCM X509
1055
- PGP).join(",")
1056
- end
1057
-
1058
- describe "Regress::LikeGnomeKeyringPasswordSchema" do
1059
- it "creates an instance using #new" do
1060
- obj = Regress::LikeGnomeKeyringPasswordSchema.new
1061
- _(obj).must_be_instance_of Regress::LikeGnomeKeyringPasswordSchema
1062
- end
1063
-
1064
- let(:instance) { Regress::LikeGnomeKeyringPasswordSchema.new }
1065
-
1066
- it "has a writable field dummy" do
1067
- _(instance.dummy).must_equal 0
1068
- instance.dummy = 42
1069
- _(instance.dummy).must_equal 42
1070
- end
1071
-
1072
- it "has a writable field attributes" do
1073
- skip "Introspection data cannot deal with type of this field yet"
1074
- end
1075
-
1076
- it "has a writable field dummy2" do
1077
- _(instance.dummy2).must_equal 0.0
1078
- instance.dummy2 = 42.42
1079
- _(instance.dummy2).must_equal 42.42
1080
- end
1081
- end
1082
-
1083
- describe "Regress::LikeXklConfigItem" do
1084
- let(:instance) { Regress::LikeXklConfigItem.new }
1085
- let(:name_array) { "foo".bytes.to_a + [0] * 29 }
1086
-
1087
- it "has a writable field name" do
1088
- # TODO: Should an array of gint8 be more string-like?
1089
- _(instance.name.to_a).must_equal [0] * 32
1090
- instance.name = name_array
1091
- _(instance.name.to_a).must_equal name_array
1092
- end
1093
-
1094
- it "has a working method #set_name" do
1095
- instance.set_name "foo"
1096
- _(instance.name.to_a).must_equal name_array
1097
- end
1098
- end
1099
-
1100
- it "has the constant MAXUINT64" do
1101
- _(Regress::MAXUINT64).must_equal 0xffff_ffff_ffff_ffff
1102
- end
1103
-
1104
- it "has the constant MININT64" do
1105
- _(Regress::MININT64).must_equal(-0x8000_0000_0000_0000)
1106
- end
1107
-
1108
- it "has the constant Mixed_Case_Constant" do
1109
- assert_equal 4423, Regress::Mixed_Case_Constant
1110
- end
1111
-
1112
- it "has the constant NEGATIVE_INT_CONSTANT" do
1113
- _(Regress::NEGATIVE_INT_CONSTANT).must_equal(-42)
1114
- end
1115
-
1116
- it "has the constant STRING_CONSTANT" do
1117
- assert_equal "Some String", Regress::STRING_CONSTANT
1118
- end
1119
-
1120
- describe "Regress::TestABCError" do
1121
- it "has the member :code1" do
1122
- _(Regress::TestABCError[:code1]).must_equal 1
1123
- end
1124
-
1125
- it "has the member :code2" do
1126
- _(Regress::TestABCError[:code2]).must_equal 2
1127
- end
1128
-
1129
- it "has the member :code3" do
1130
- _(Regress::TestABCError[:code3]).must_equal 3
1131
- end
1132
-
1133
- it "has a working function #quark" do
1134
- quark = Regress::TestABCError.quark
1135
- _(GLib.quark_to_string(quark)).must_equal "regress-test-abc-error"
1136
- end
1137
- end
1138
-
1139
- describe "Regress::TestBoxed" do
1140
- let(:instance) { Regress::TestBoxed.new_alternative_constructor1 123 }
1141
-
1142
- it "has a writable field some_int8" do
1143
- _(instance.some_int8).must_equal 123
1144
- instance.some_int8 = -43
1145
- _(instance.some_int8).must_equal(-43)
1146
- end
1147
-
1148
- it "has a writable field nested_a" do
1149
- _(instance.nested_a.some_int).must_equal 0
1150
- nested = Regress::TestSimpleBoxedA.new
1151
- nested.some_int = 12_345
1152
- instance.nested_a = nested
1153
- _(instance.nested_a.some_int).must_equal 12_345
1154
- end
1155
-
1156
- it "blocks access to the hidden struct field priv" do
1157
- _(proc { instance.priv = nil }).must_raise NoMethodError
1158
- _(proc { instance.priv }).must_raise NoMethodError
1159
- end
1160
-
1161
- it "creates an instance using #new" do
1162
- tb = Regress::TestBoxed.new
1163
- assert_instance_of Regress::TestBoxed, tb
1164
- end
1165
-
1166
- it "creates an instance using #new_alternative_constructor1" do
1167
- tb = Regress::TestBoxed.new_alternative_constructor1 1
1168
- assert_instance_of Regress::TestBoxed, tb
1169
- assert_equal 1, tb.some_int8
1170
- end
1171
-
1172
- it "creates an instance using #new_alternative_constructor2" do
1173
- tb = Regress::TestBoxed.new_alternative_constructor2 1, 2
1174
- assert_instance_of Regress::TestBoxed, tb
1175
- assert_equal 1 + 2, tb.some_int8
1176
- end
1177
-
1178
- it "creates an instance using #new_alternative_constructor3" do
1179
- tb = Regress::TestBoxed.new_alternative_constructor3 "54"
1180
- assert_instance_of Regress::TestBoxed, tb
1181
- assert_equal 54, tb.some_int8
1182
- end
1183
-
1184
- it "has non-zero positive result for #gtype" do
1185
- _(Regress::TestBoxed.gtype).must_be :>, 0
1186
- end
1187
-
1188
- it "has a working method #_not_a_method" do
1189
- # NOTE: This method is marked as moved, but this is not exposed in the typelib
1190
- instance._not_a_method
1191
- pass
1192
- end
1193
-
1194
- it "has a working method #copy" do
1195
- tb2 = instance.copy
1196
- assert_instance_of Regress::TestBoxed, tb2
1197
- assert_equal 123, tb2.some_int8
1198
- instance.some_int8 = 89
1199
- assert_equal 123, tb2.some_int8
1200
- end
1201
-
1202
- it "has a working method #equals" do
1203
- tb2 = Regress::TestBoxed.new_alternative_constructor2 120, 3
1204
- assert_equal true, instance.equals(tb2)
1205
- end
1206
- end
1207
-
1208
- describe "Regress::TestBoxedB" do
1209
- let(:instance) { Regress::TestBoxedB.new 8, 42 }
1210
-
1211
- it "has a writable field some_int8" do
1212
- _(instance.some_int8).must_equal 8
1213
- instance.some_int8 = -43
1214
- _(instance.some_int8).must_equal(-43)
1215
- end
1216
-
1217
- it "has a writable field some_long" do
1218
- _(instance.some_long).must_equal 42
1219
- instance.some_long = -4342
1220
- _(instance.some_long).must_equal(-4342)
1221
- end
1222
-
1223
- it "creates an instance using #new" do
1224
- tb = Regress::TestBoxedB.new 8, 42
1225
- assert_instance_of Regress::TestBoxedB, tb
1226
- end
1227
-
1228
- it "has a working method #copy" do
1229
- cp = instance.copy
1230
- _(cp).must_be_instance_of Regress::TestBoxedB
1231
- _(cp.some_int8).must_equal 8
1232
- _(cp.some_long).must_equal 42
1233
- instance.some_int8 = 2
1234
- _(cp.some_int8).must_equal 8
1235
- end
1236
- end
1237
-
1238
- describe "Regress::TestBoxedC" do
1239
- let(:instance) { Regress::TestBoxedC.new }
1240
-
1241
- it "has a writable field refcount" do
1242
- _(instance.refcount).must_equal 1
1243
- instance.refcount = 2
1244
- _(instance.refcount).must_equal 2
1245
- end
1246
-
1247
- it "has a writable field another_thing" do
1248
- _(instance.another_thing).must_equal 42
1249
- instance.another_thing = 4342
1250
- _(instance.another_thing).must_equal 4342
1251
- end
1252
-
1253
- it "creates an instance using #new" do
1254
- tb = Regress::TestBoxedC.new
1255
- assert_instance_of Regress::TestBoxedC, tb
1256
- end
1257
- end
1258
-
1259
- describe "Regress::TestBoxedD" do
1260
- let(:instance) { Regress::TestBoxedD.new "foo", 42 }
1261
-
1262
- it "creates an instance using #new" do
1263
- _(instance).must_be_instance_of Regress::TestBoxedD
1264
- end
1265
-
1266
- it "has a working method #copy" do
1267
- copy = instance.copy
1268
- _(copy).must_be_instance_of Regress::TestBoxedD
1269
- _(instance.get_magic).must_equal copy.get_magic
1270
- _(instance).wont_equal copy
1271
- end
1272
-
1273
- it "has a working method #free" do
1274
- skip "#free is used internally and shouldn't be exposed"
1275
- instance.free
1276
- pass
1277
- end
1278
-
1279
- it "has a working method #get_magic" do
1280
- _(instance.get_magic).must_equal "foo".length + 42
1281
- end
1282
- end
1283
-
1284
- describe "Regress::TestDEFError" do
1285
- it "has the member :code0" do
1286
- _(Regress::TestDEFError[:code0]).must_equal 0
1287
- end
1288
-
1289
- it "has the member :code1" do
1290
- _(Regress::TestDEFError[:code1]).must_equal 1
1291
- end
1292
-
1293
- it "has the member :code2" do
1294
- _(Regress::TestDEFError[:code2]).must_equal 2
1295
- end
1296
- end
1297
-
1298
- describe "Regress::TestEnum" do
1299
- it "has the member :value1" do
1300
- _(Regress::TestEnum[:value1]).must_equal 0
1301
- end
1302
-
1303
- it "has the member :value2" do
1304
- _(Regress::TestEnum[:value2]).must_equal 1
1305
- end
1306
-
1307
- it "has the member :value3" do
1308
- _(Regress::TestEnum[:value3]).must_equal(-1)
1309
- end
1310
-
1311
- it "has the member :value4" do
1312
- _(Regress::TestEnum[:value4]).must_equal 48
1313
- end
1314
-
1315
- it "has the member :value5" do
1316
- skip_below "1.55.2"
1317
- _(Regress::TestEnum[:value5]).must_equal 49
1318
- end
1319
-
1320
- it "has a working function #param" do
1321
- _(Regress::TestEnum.param(:value1)).must_equal("value1")
1322
- _(Regress::TestEnum.param(:value2)).must_equal("value2")
1323
- _(Regress::TestEnum.param(:value3)).must_equal("value3")
1324
- _(Regress::TestEnum.param(:value4)).must_equal("value4")
1325
- _(Regress::TestEnum.param(0)).must_equal("value1")
1326
- _(Regress::TestEnum.param(1)).must_equal("value2")
1327
- _(Regress::TestEnum.param(-1)).must_equal("value3")
1328
- _(Regress::TestEnum.param(48)).must_equal("value4")
1329
- end
1330
- end
1331
-
1332
- describe "Regress::TestEnumNoGEnum" do
1333
- it "has the member :evalue1" do
1334
- _(Regress::TestEnumNoGEnum[:evalue1]).must_equal 0
1335
- end
1336
-
1337
- it "has the member :evalue2" do
1338
- _(Regress::TestEnumNoGEnum[:evalue2]).must_equal 42
1339
- end
1340
-
1341
- it "has the member :evalue3" do
1342
- _(Regress::TestEnumNoGEnum[:evalue3]).must_equal 48
1343
- end
1344
- end
1345
-
1346
- describe "Regress::TestEnumUnsigned" do
1347
- it "has the member :value1" do
1348
- _(Regress::TestEnumUnsigned[:value1]).must_equal 1
1349
- end
1350
-
1351
- # NOTE In c, the positive and negative values are not distinguished
1352
- it "has the member :value2" do
1353
- _(Regress::TestEnumUnsigned[:value2]).must_equal(-2_147_483_648)
1354
- end
1355
- end
1356
-
1357
- describe "Regress::TestError" do
1358
- it "has the member :code1" do
1359
- _(Regress::TestError[:code1]).must_equal 1
1360
- end
1361
-
1362
- it "has the member :code2" do
1363
- _(Regress::TestError[:code2]).must_equal 2
1364
- end
1365
-
1366
- it "has the member :code3" do
1367
- _(Regress::TestError[:code3]).must_equal 3
1368
- end
1369
-
1370
- it "has a working function #quark" do
1371
- quark = Regress::TestError.quark
1372
- _(GLib.quark_to_string(quark)).must_equal "regress-test-error"
1373
- end
1374
- end
1375
-
1376
- describe "Regress::TestFlags" do
1377
- it "has the member :flag1" do
1378
- assert_equal 1, Regress::TestFlags[:flag1]
1379
- end
1380
- it "has the member :flag2" do
1381
- assert_equal 2, Regress::TestFlags[:flag2]
1382
- end
1383
- it "has the member :flag3" do
1384
- assert_equal 4, Regress::TestFlags[:flag3]
1385
- end
1386
- end
1387
-
1388
- describe "Regress::TestFloating" do
1389
- it "creates an instance using #new" do
1390
- o = Regress::TestFloating.new
1391
- _(o).must_be_instance_of Regress::TestFloating
1392
- end
1393
-
1394
- describe "an instance" do
1395
- before do
1396
- @o = Regress::TestFloating.new
1397
- end
1398
-
1399
- it "has a reference count of 1" do
1400
- assert_equal 1, object_ref_count(@o)
1401
- end
1402
-
1403
- it "has been sunk" do
1404
- _(@o).wont_be :floating?
1405
- end
1406
- end
1407
- end
1408
-
1409
- describe "Regress::TestFundamentalObject" do
1410
- it "does not have GObject::Object as an ancestor" do
1411
- refute(Regress::TestFundamentalObject < GObject::Object)
1412
- end
1413
-
1414
- it "cannot be instantiated" do
1415
- _(proc { Regress::TestFundamentalObject.new }).must_raise NoMethodError
1416
- end
1417
-
1418
- let(:derived_instance) { Regress::TestFundamentalSubObject.new "foo" }
1419
- let(:base_struct) { Regress::TestFundamentalObject::Struct.new derived_instance.to_ptr }
1420
-
1421
- it "has a working method #ref" do
1422
- _(base_struct[:refcount]).must_equal 1
1423
- derived_instance.ref
1424
- _(base_struct[:refcount]).must_equal 2
1425
- end
1426
-
1427
- it "has a working method #unref" do
1428
- _(base_struct[:refcount]).must_equal 1
1429
- derived_instance.unref
1430
- _(base_struct[:refcount]).must_equal 0
1431
- end
1432
- end
1433
-
1434
- describe "Regress::TestFundamentalSubObject" do
1435
- it "creates an instance using #new" do
1436
- obj = Regress::TestFundamentalSubObject.new "foo"
1437
- _(obj).must_be_instance_of Regress::TestFundamentalSubObject
1438
- end
1439
-
1440
- let(:instance) { Regress::TestFundamentalSubObject.new "foo" }
1441
-
1442
- it "is a subclass of TestFundamentalObject" do
1443
- assert_kind_of Regress::TestFundamentalObject, instance
1444
- end
1445
-
1446
- it "has a field :data storing the constructor parameter" do
1447
- assert_equal "foo", instance.struct[:data].to_utf8
1448
- end
1449
- end
1450
-
1451
- describe "Regress::TestInheritDrawable" do
1452
- it "cannot be instantiated" do
1453
- _(proc { Regress::TestInheritDrawable.new }).must_raise NoMethodError
1454
- end
1455
-
1456
- let(:derived_instance) { ConcreteDrawable.new }
1457
-
1458
- it "has a working method #do_foo" do
1459
- derived_instance.do_foo 42
1460
- pass
1461
- end
1462
-
1463
- it "has a working method #do_foo_maybe_throw" do
1464
- derived_instance.do_foo_maybe_throw 42
1465
- _(proc { derived_instance.do_foo_maybe_throw 41 }).must_raise GirFFI::GLibError
1466
- end
1467
-
1468
- it "has a working method #get_origin" do
1469
- _(derived_instance.get_origin).must_equal [0, 0]
1470
- end
1471
-
1472
- it "has a working method #get_size" do
1473
- _(derived_instance.get_size).must_equal [42, 42]
1474
- end
1475
- end
1476
-
1477
- describe "Regress::TestInheritPixmapObjectClass" do
1478
- it "has a writable field parent_class" do
1479
- skip "This is a class struct without defined class"
1480
- end
1481
- end
1482
-
1483
- describe "Regress::TestInterface" do
1484
- let(:derived_klass) do
1485
- klass = Object.const_set("DerivedClass#{Sequence.next}",
1486
- Class.new(Regress::FooObject))
1487
- klass.send :include, Regress::TestInterface
1488
- GirFFI.define_type klass do |info|
1489
- info.install_property GObject.param_spec_int("number", "Number", "Number",
1490
- 0, 10, 0,
1491
- readwrite: true, construct: true)
1492
- end
1493
- klass
1494
- end
1495
-
1496
- it "is a module" do
1497
- assert_instance_of Module, Regress::TestInterface
1498
- end
1499
-
1500
- it "extends InterfaceBase" do
1501
- _(Regress::TestInterface.singleton_class).must_include GirFFI::InterfaceBase
1502
- end
1503
-
1504
- it "has non-zero positive result for #gtype" do
1505
- _(Regress::TestInterface.gtype).must_be :>, 0
1506
- end
1507
-
1508
- it "has a working method #emit_signal" do
1509
- skip_below "1.57.2"
1510
- a = nil
1511
- instance = derived_klass.new
1512
- GObject.signal_connect instance, "interface-signal" do
1513
- a = "hello"
1514
- end
1515
- instance.emit_signal
1516
- _(a).must_equal "hello"
1517
- end
1518
-
1519
- describe "its 'number' property" do
1520
- before { skip_below "1.59.1" }
1521
-
1522
- let(:instance) { derived_klass.new }
1523
-
1524
- it "can be retrieved with #get_property" do
1525
- _(instance.get_property("number")).must_equal 0
1526
- end
1527
-
1528
- it "can be retrieved with #number" do
1529
- _(instance.number).must_equal 0
1530
- end
1531
-
1532
- it "can be set with #set_property" do
1533
- instance.set_property("number", 10)
1534
- _(instance.get_property("number")).must_equal 10
1535
- end
1536
-
1537
- it "can be set with #number=" do
1538
- instance.number = 4
1539
-
1540
- _(instance.number).must_equal 4
1541
- _(instance.get_property("number")).must_equal 4
1542
- end
1543
- end
1544
-
1545
- it "handles the 'interface-signal' signal" do
1546
- skip_below "1.57.2"
1547
- a = nil
1548
- instance = derived_klass.new
1549
- GObject.signal_connect instance, "interface-signal" do
1550
- a = "hello"
1551
- end
1552
- GObject.signal_emit instance, "interface-signal"
1553
- _(a).must_equal "hello"
1554
- end
1555
- end
1556
-
1557
- describe "Regress::TestObj" do
1558
- it "creates an instance using #constructor" do
1559
- obj = Regress::TestObj.constructor
1560
- _(obj).must_be_instance_of Regress::TestObj
1561
- end
1562
-
1563
- it "creates an instance using #new" do
1564
- o1 = Regress::TestObj.constructor
1565
- o2 = Regress::TestObj.new o1
1566
- _(o2).must_be_instance_of Regress::TestObj
1567
- end
1568
-
1569
- it "creates an instance using #new_callback" do
1570
- a = 1
1571
- o = Regress::TestObj.new_callback { a = 2 }
1572
- assert_instance_of Regress::TestObj, o
1573
- _(a).must_equal 2
1574
-
1575
- # Regress::TestObj.new_callback adds a callback to the list of notified
1576
- # callbacks. Thaw the callbacks to make sure the list is cleared for
1577
- # later tests.
1578
- result = Regress.test_callback_thaw_notifications
1579
- _(result).must_equal 2
1580
- end
1581
-
1582
- it "creates an instance using #new_from_file" do
1583
- o = Regress::TestObj.new_from_file("foo")
1584
- assert_instance_of Regress::TestObj, o
1585
- end
1586
-
1587
- it "has a working function #null_out" do
1588
- obj = Regress::TestObj.null_out
1589
- _(obj).must_be_nil
1590
- end
1591
-
1592
- it "has a working function #static_method" do
1593
- rv = Regress::TestObj.static_method 623
1594
- assert_equal 623.0, rv
1595
- end
1596
-
1597
- it "has a working function #static_method_callback" do
1598
- a = 1
1599
- Regress::TestObj.static_method_callback { a = 2 }
1600
- assert_equal 2, a
1601
- end
1602
-
1603
- let(:instance) { Regress::TestObj.new_from_file("foo") }
1604
-
1605
- describe "its gtype" do
1606
- it "can be found through gtype and GObject.type_from_instance" do
1607
- gtype = Regress::TestObj.gtype
1608
- r = GObject.type_from_instance instance
1609
- assert_equal gtype, r
1610
- end
1611
- end
1612
-
1613
- it "has a reference count of 1" do
1614
- assert_equal 1, object_ref_count(instance)
1615
- end
1616
-
1617
- it "does not float" do
1618
- _(instance).wont_be :floating?
1619
- end
1620
-
1621
- it "has a working method #matrix" do
1622
- _(instance.matrix("bar")).must_equal 42
1623
- end
1624
-
1625
- it "has a working method #do_matrix" do
1626
- _(instance.do_matrix("bar")).must_equal 42
1627
- end
1628
-
1629
- it "has a working method #emit_sig_with_array_len_prop" do
1630
- skip_below "1.47.92"
1631
- array = nil
1632
- instance.signal_connect "sig-with-array-len-prop" do |_obj, ary|
1633
- array = ary.to_a
1634
- end
1635
- instance.emit_sig_with_array_len_prop
1636
- _(array.to_a).must_equal [0, 1, 2, 3, 4]
1637
- end
1638
-
1639
- it "has a working method #emit_sig_with_error" do
1640
- skip_below "1.61.1"
1641
- error = nil
1642
- instance.signal_connect "sig-with-gerror" do |_obj, err|
1643
- error = err
1644
- end
1645
- instance.emit_sig_with_error
1646
- _(error).must_be_instance_of GLib::Error
1647
- end
1648
-
1649
- it "has a working method #emit_sig_with_foreign_struct" do
1650
- has_fired = false
1651
- instance.signal_connect "sig-with-foreign-struct" do |_obj, cr|
1652
- has_fired = true
1653
- _(cr).must_be_instance_of Cairo::Context
1654
- end
1655
- instance.emit_sig_with_foreign_struct
1656
- assert has_fired
1657
- end
1658
-
1659
- it "has a working method #emit_sig_with_inout_int" do
1660
- skip_below "1.57.2"
1661
- instance.signal_connect "sig-with-inout-int" do |_obj, i, _ud|
1662
- i + 1
1663
- end
1664
- instance.emit_sig_with_inout_int
1665
- end
1666
-
1667
- it "has a working method #emit_sig_with_int64" do
1668
- instance.signal_connect "sig-with-int64-prop" do |_obj, i, _ud|
1669
- i
1670
- end
1671
- instance.emit_sig_with_int64
1672
- end
1673
-
1674
- it "has a working method #emit_sig_with_null_error" do
1675
- skip_below "1.61.1"
1676
- error = nil
1677
- instance.signal_connect "sig-with-gerror" do |_obj, err|
1678
- error = err
1679
- end
1680
- instance.emit_sig_with_null_error
1681
- _(error).must_be_nil
1682
- end
1683
-
1684
- it "has a working method #emit_sig_with_obj" do
1685
- has_fired = false
1686
- instance.signal_connect "sig-with-obj" do |_it, obj|
1687
- has_fired = true
1688
- _(obj.int).must_equal 3
1689
- end
1690
- instance.emit_sig_with_obj
1691
- assert has_fired
1692
- end
1693
-
1694
- it "has a working method #emit_sig_with_uint64" do
1695
- instance.signal_connect "sig-with-uint64-prop" do |_obj, i, _ud|
1696
- i
1697
- end
1698
- instance.emit_sig_with_uint64
1699
- end
1700
-
1701
- it "has a working method #forced_method" do
1702
- instance.forced_method
1703
- pass
1704
- end
1705
-
1706
- it "has a working method #instance_method" do
1707
- rv = instance.instance_method
1708
- assert_equal(-1, rv)
1709
- end
1710
-
1711
- it "has a working method #instance_method_callback" do
1712
- a = 1
1713
- instance.instance_method_callback { a = 2 }
1714
- assert_equal 2, a
1715
- end
1716
-
1717
- it "has a working method #instance_method_full" do
1718
- _(object_ref_count(instance)).must_equal 1
1719
- instance.instance_method_full
1720
- _(object_ref_count(instance)).must_equal 1
1721
- end
1722
-
1723
- it "has a working method #name_conflict" do
1724
- skip_below "1.53.4"
1725
- _(instance.name_conflict).must_be_nil
1726
- end
1727
-
1728
- it "has a working method #not_nullable_element_typed_gpointer_in" do
1729
- skip_below "1.47.92"
1730
- instance.not_nullable_element_typed_gpointer_in [1, 2, 3]
1731
- # TODO: Make method raise when passed nil
1732
- end
1733
-
1734
- it "has a working method #not_nullable_typed_gpointer_in" do
1735
- skip_below "1.47.92"
1736
- obj = Regress::TestObj.new_from_file("bar")
1737
- instance.not_nullable_typed_gpointer_in obj
1738
- # TODO: Make method raise when passed nil
1739
- end
1740
-
1741
- it "has a working method #set_bare" do
1742
- obj = Regress::TestObj.new_from_file("bar")
1743
- instance.set_bare obj
1744
- _(instance.bare).must_equal obj
1745
- end
1746
-
1747
- it "has a working method #skip_inout_param" do
1748
- a = 1
1749
- c = 2.0
1750
- num1 = 3
1751
- num2 = 4
1752
- result, out_b, sum = instance.skip_inout_param a, c, num1, num2
1753
- _(result).must_equal true
1754
- _(out_b).must_equal a + 1
1755
- _(sum).must_equal num1 + 10 * num2
1756
- end
1757
-
1758
- it "has a working method #skip_out_param" do
1759
- a = 1
1760
- c = 2.0
1761
- d = 3
1762
- num1 = 4
1763
- num2 = 5
1764
- result, out_d, sum = instance.skip_out_param a, c, d, num1, num2
1765
- _(result).must_equal true
1766
- _(out_d).must_equal d + 1
1767
- _(sum).must_equal num1 + 10 * num2
1768
- end
1769
-
1770
- it "has a working method #skip_param" do
1771
- a = 1
1772
- d = 3
1773
- num1 = 4
1774
- num2 = 5
1775
- result, out_b, out_d, sum = instance.skip_param a, d, num1, num2
1776
- _(result).must_equal true
1777
- _(out_b).must_equal a + 1
1778
- _(out_d).must_equal d + 1
1779
- _(sum).must_equal num1 + 10 * num2
1780
- end
1781
-
1782
- it "has a working method #skip_return_val" do
1783
- a = 1
1784
- c = 2.0
1785
- d = 3
1786
- num1 = 4
1787
- num2 = 5
1788
- out_b, out_d, out_sum = instance.skip_return_val a, c, d, num1, num2
1789
- _(out_b).must_equal a + 1
1790
- _(out_d).must_equal d + 1
1791
- _(out_sum).must_equal num1 + 10 * num2
1792
- end
1793
-
1794
- it "has a working method #skip_return_val_no_out" do
1795
- result = instance.skip_return_val_no_out 1
1796
- _(result).must_be_nil
1797
-
1798
- _(proc { instance.skip_return_val_no_out 0 }).must_raise GirFFI::GLibError
1799
- end
1800
-
1801
- it "has a working method #torture_signature_0" do
1802
- y, z, q = instance.torture_signature_0(-21, "hello", 13)
1803
- assert_equal [-21, 2 * -21, "hello".length + 13],
1804
- [y, z, q]
1805
- end
1806
-
1807
- it "has a working method #torture_signature_1" do
1808
- ret, y, z, q = instance.torture_signature_1(-21, "hello", 12)
1809
- _([ret, y, z, q]).must_equal [true, -21, 2 * -21, "hello".length + 12]
1810
-
1811
- _(proc { instance.torture_signature_1(-21, "hello", 11) }).
1812
- must_raise GirFFI::GLibError
1813
- end
1814
-
1815
- describe "its 'bare' property" do
1816
- it "can be retrieved with #get_property" do
1817
- _(instance.get_property("bare")).must_be_nil
1818
- end
1819
-
1820
- it "can be retrieved with #bare" do
1821
- _(instance.bare).must_be_nil
1822
- end
1823
-
1824
- it "can be set with #set_property" do
1825
- obj = Regress::TestObj.new_from_file("bar")
1826
- instance.set_property "bare", obj
1827
- _(instance.get_property("bare")).must_equal obj
1828
- end
1829
-
1830
- it "can be set with #bare=" do
1831
- obj = Regress::TestObj.new_from_file("bar")
1832
- instance.bare = obj
1833
-
1834
- _(instance.bare).must_equal obj
1835
- _(instance.get_property("bare")).must_equal obj
1836
- end
1837
- end
1838
-
1839
- describe "its 'boxed' property" do
1840
- it "can be retrieved with #get_property" do
1841
- _(instance.get_property("boxed")).must_be_nil
1842
- end
1843
-
1844
- it "can be retrieved with #boxed" do
1845
- _(instance.boxed).must_be_nil
1846
- end
1847
-
1848
- it "can be set with #set_property" do
1849
- tb = Regress::TestBoxed.new_alternative_constructor1 75
1850
- instance.set_property "boxed", tb
1851
- _(instance.get_property("boxed").some_int8).must_equal 75
1852
- end
1853
-
1854
- it "can be set with #boxed=" do
1855
- tb = Regress::TestBoxed.new_alternative_constructor1 75
1856
- instance.boxed = tb
1857
- _(instance.boxed.some_int8).must_equal tb.some_int8
1858
- _(instance.get_property("boxed").some_int8).must_equal tb.some_int8
1859
- end
1860
- end
1861
-
1862
- describe "its 'byte-array' property" do
1863
- before { skip_below("1.57.2") }
1864
-
1865
- it "can be retrieved with #get_property" do
1866
- _(instance.get_property("byte-array")).must_be_nil
1867
- end
1868
-
1869
- it "can be retrieved with #byte_array" do
1870
- _(instance.byte_array).must_be_nil
1871
- end
1872
-
1873
- it "can be set with #set_property" do
1874
- instance.set_property "byte-array", "hello"
1875
- _(instance.get_property("byte-array").to_string).must_equal "hello"
1876
- end
1877
-
1878
- it "can be set with #byte_array=" do
1879
- instance.byte_array = "bye"
1880
- _(instance.byte_array.to_string).must_equal "bye"
1881
- instance.byte_array = GLib::ByteArray.from("byebye")
1882
- _(instance.get_property("byte-array").to_string).must_equal "byebye"
1883
- end
1884
- end
1885
-
1886
- describe "its 'double' property" do
1887
- it "can be retrieved with #get_property" do
1888
- _(instance.get_property("double")).must_equal 0.0
1889
- end
1890
-
1891
- it "can be retrieved with #double" do
1892
- _(instance.double).must_equal 0.0
1893
- end
1894
-
1895
- it "can be set with #set_property" do
1896
- instance.set_property "double", 3.14
1897
- _(instance.get_property("double")).must_equal 3.14
1898
- end
1899
-
1900
- it "can be set with #double=" do
1901
- instance.double = 3.14
1902
- _(instance.double).must_equal 3.14
1903
- _(instance.get_property("double")).must_equal 3.14
1904
- end
1905
- end
1906
-
1907
- describe "its 'float' property" do
1908
- it "can be retrieved with #get_property" do
1909
- _(instance.get_property("float")).must_equal 0.0
1910
- end
1911
-
1912
- it "can be retrieved with #float" do
1913
- _(instance.float).must_equal 0.0
1914
- end
1915
-
1916
- it "can be set with #set_property" do
1917
- instance.set_property "float", 3.14
1918
- _(instance.get_property("float")).must_be_close_to 3.14
1919
- end
1920
-
1921
- it "can be set with #float=" do
1922
- instance.float = 3.14
1923
- _(instance.float).must_be_close_to 3.14
1924
- _(instance.get_property("float")).must_be_close_to 3.14
1925
- end
1926
- end
1927
-
1928
- describe "its 'gtype' property" do
1929
- it "can be retrieved with #get_property" do
1930
- _(instance.get_property("gtype")).must_equal 0
1931
- end
1932
-
1933
- it "can be retrieved with #gtype" do
1934
- _(instance.gtype).must_equal 0
1935
- end
1936
-
1937
- it "can be set with #set_property" do
1938
- instance.set_property "gtype", GObject::TYPE_INT64
1939
- _(instance.get_property("gtype")).must_equal GObject::TYPE_INT64
1940
- end
1941
-
1942
- it "can be set with #gtype=" do
1943
- instance.gtype = GObject::TYPE_STRING
1944
- _(instance.gtype).must_equal GObject::TYPE_STRING
1945
- _(instance.get_property("gtype")).must_equal GObject::TYPE_STRING
1946
- end
1947
- end
1948
-
1949
- describe "its 'hash-table' property" do
1950
- it "can be retrieved with #get_property" do
1951
- _(instance.get_property("hash-table")).must_be_nil
1952
- end
1953
-
1954
- it "can be retrieved with #hash_table" do
1955
- _(instance.hash_table).must_be_nil
1956
- end
1957
-
1958
- it "can be set with #set_property" do
1959
- instance.set_property "hash-table", "foo" => -4, "bar" => 83
1960
- _(instance.hash_table.to_hash).must_equal("foo" => -4, "bar" => 83)
1961
- end
1962
-
1963
- it "can be set with #hash_table=" do
1964
- instance.hash_table = { "foo" => -4, "bar" => 83 }
1965
- _(instance.hash_table.to_hash).must_equal("foo" => -4, "bar" => 83)
1966
- _(instance.get_property("hash-table").to_hash).must_equal("foo" => -4,
1967
- "bar" => 83)
1968
- end
1969
- end
1970
-
1971
- describe "its 'hash-table-old' property" do
1972
- it "can be retrieved with #get_property" do
1973
- _(instance.get_property("hash-table-old")).must_be_nil
1974
- end
1975
-
1976
- it "can be retrieved with #hash_table_old" do
1977
- _(instance.hash_table_old).must_be_nil
1978
- end
1979
-
1980
- it "can be set with #set_property" do
1981
- instance.set_property "hash-table-old", "foo" => 34, "bar" => -3
1982
- _(instance.hash_table_old.to_hash).must_equal("foo" => 34, "bar" => -3)
1983
- end
1984
-
1985
- it "can be set with #hash_table_old=" do
1986
- instance.hash_table_old = { "foo" => 34, "bar" => -3 }
1987
- _(instance.hash_table_old.to_hash).must_equal("foo" => 34, "bar" => -3)
1988
- _(instance.get_property("hash-table-old").to_hash).must_equal("foo" => 34,
1989
- "bar" => -3)
1990
- end
1991
- end
1992
-
1993
- describe "its 'int' property" do
1994
- it "can be retrieved with #get_property" do
1995
- assert_equal 0, instance.get_property("int")
1996
- end
1997
-
1998
- it "can be retrieved with #int" do
1999
- assert_equal 0, instance.int
2000
- end
2001
-
2002
- it "can be set with #set_property" do
2003
- instance.set_property "int", 42
2004
- assert_equal 42, instance.get_property("int")
2005
- end
2006
-
2007
- it "can be set with #int=" do
2008
- instance.int = 41
2009
- assert_equal 41, instance.get_property("int")
2010
- assert_equal 41, instance.int
2011
- end
2012
- end
2013
-
2014
- describe "its 'list' property" do
2015
- it "can be retrieved with #get_property" do
2016
- _(instance.get_property("list")).must_be_nil
2017
- end
2018
-
2019
- it "can be retrieved with #list" do
2020
- _(instance.list).must_be_nil
2021
- end
2022
-
2023
- it "can be set with #set_property" do
2024
- instance.set_property "list", %w(foo bar)
2025
- _(instance.list.to_a).must_equal %w(foo bar)
2026
- end
2027
-
2028
- it "can be set with #list=" do
2029
- instance.list = %w(foo bar)
2030
- _(instance.list.to_a).must_equal %w(foo bar)
2031
- _(instance.get_property("list")).must_be :==, %w(foo bar)
2032
- end
2033
- end
2034
-
2035
- describe "its 'list-old' property" do
2036
- it "can be retrieved with #get_property" do
2037
- _(instance.get_property("list-old")).must_be_nil
2038
- end
2039
-
2040
- it "can be retrieved with #list_old" do
2041
- _(instance.list_old).must_be_nil
2042
- end
2043
-
2044
- it "can be set with #set_property" do
2045
- instance.set_property "list-old", %w(foo bar)
2046
- _(instance.list_old).must_be :==, %w(foo bar)
2047
- end
2048
-
2049
- it "can be set with #list_old=" do
2050
- instance.list_old = %w(foo bar)
2051
- _(instance.list_old).must_be :==, %w(foo bar)
2052
- _(instance.get_property("list-old")).must_be :==, %w(foo bar)
2053
- end
2054
- end
2055
-
2056
- describe "its 'name-conflict' property" do
2057
- before { skip_below "1.53.4" }
2058
-
2059
- it "can be retrieved with #get_property" do
2060
- _(instance.get_property("name-conflict")).must_equal 42
2061
- end
2062
-
2063
- it "cannot be retrieved with #name_conflict" do
2064
- # Method names are prioritized over property names, so we call the
2065
- # method here instead of fetching the property
2066
- _(instance.name_conflict).must_be_nil
2067
- end
2068
-
2069
- it "can be set with #set_property" do
2070
- instance.set_property("name-conflict", 23)
2071
- _(instance.get_property("name-conflict")).must_equal 23
2072
- end
2073
-
2074
- it "can be set with #name_conflict=" do
2075
- instance.name_conflict = 23
2076
- _(instance.get_property("name-conflict")).must_equal 23
2077
- end
2078
- end
2079
- describe "its 'pptrarray' property" do
2080
- before do
2081
- skip "The pptrarray property is not implemented properly"
2082
- end
2083
-
2084
- it "can be retrieved with #get_property" do
2085
- _(instance.get_property("pptrarray")).must_be_nil
2086
- end
2087
-
2088
- it "can be retrieved with #pptrarray" do
2089
- _(instance.pptrarray).must_be_nil
2090
- end
2091
-
2092
- it "can be set with #set_property" do
2093
- arr = Regress.test_garray_container_return
2094
- instance.set_property "pptrarray", arr
2095
- _(instance.pptrarray).must_be :==, arr
2096
- end
2097
-
2098
- it "can be set with #pptrarray=" do
2099
- arr = Regress.test_garray_container_return
2100
- instance.pptrarray = arr
2101
- _(instance.pptrarray).must_be :==, arr
2102
- _(instance.get_property("pptrarray")).must_be :==, arr
2103
- end
2104
- end
2105
-
2106
- describe "its 'string' property" do
2107
- it "can be retrieved with #get_property" do
2108
- assert_nil instance.get_property("string")
2109
- end
2110
-
2111
- it "can be retrieved with #string" do
2112
- assert_nil instance.string
2113
- end
2114
-
2115
- it "can be set with #set_property" do
2116
- instance.set_property "string", "foobar"
2117
- assert_equal "foobar", instance.get_property("string")
2118
- end
2119
-
2120
- it "can be set with #string=" do
2121
- instance.string = "foobar"
2122
- assert_equal "foobar", instance.string
2123
- assert_equal "foobar", instance.get_property("string")
2124
- end
2125
- end
2126
-
2127
- describe "its 'write-only' property" do
2128
- before { skip_below "1.59.1" }
2129
-
2130
- it "cannot be retrieved with #get_property" do
2131
- skip "Not implemented yet"
2132
- _(proc { instance.get_property("write-only") }).must_raise GirFFI::GLibError
2133
- end
2134
-
2135
- it "cannot be retrieved with #write_only" do
2136
- skip "Not implemented yet"
2137
- _(proc { instance.write_only }).must_raise NoMethodError
2138
- end
2139
-
2140
- it "can be set with #set_property" do
2141
- instance.int = 42
2142
- instance.set_property("write-only", false)
2143
- _(instance.int).must_equal 42
2144
- instance.set_property("write-only", true)
2145
- _(instance.int).must_equal 0
2146
- end
2147
-
2148
- it "can be set with #write_only=" do
2149
- instance.int = 42
2150
- instance.write_only = false
2151
- _(instance.int).must_equal 42
2152
- instance.write_only = true
2153
- _(instance.int).must_equal 0
2154
- end
2155
- end
2156
- it "handles the 'all' signal" do
2157
- a = nil
2158
- GObject.signal_connect(instance, "all") { a = 4 }
2159
- GObject.signal_emit instance, "all"
2160
- _(a).must_equal 4
2161
- end
2162
-
2163
- it "handles the 'cleanup' signal" do
2164
- a = nil
2165
- GObject.signal_connect(instance, "cleanup") { a = 4 }
2166
- GObject.signal_emit instance, "cleanup"
2167
- _(a).must_equal 4
2168
- end
2169
-
2170
- it "handles the 'first' signal" do
2171
- a = nil
2172
- GObject.signal_connect(instance, "first") { a = 4 }
2173
- GObject.signal_emit instance, "first"
2174
- _(a).must_equal 4
2175
- end
2176
-
2177
- it "handles the 'sig-with-array-len-prop' signal" do
2178
- a = nil
2179
-
2180
- GObject.signal_connect(instance, "sig-with-array-len-prop") do |_obj, arr, _user_data|
2181
- a = arr
2182
- end
2183
-
2184
- arr = GirFFI::InPointer.from_array(:uint, [1, 2, 3])
2185
- GObject.signal_emit instance, "sig-with-array-len-prop", arr, 3
2186
-
2187
- _(a.to_a).must_equal [1, 2, 3]
2188
- end
2189
-
2190
- it "handles the 'sig-with-array-prop' signal" do
2191
- a = nil
2192
- GObject.signal_connect(instance, "sig-with-array-prop") { |_, arr, _| a = arr }
2193
- GObject.signal_emit instance, "sig-with-array-prop",
2194
- GLib::Array.from(:uint, [1, 2, 3])
2195
- _(a.to_a).must_equal [1, 2, 3]
2196
- end
2197
-
2198
- it "handles the 'sig-with-foreign-struct' signal" do
2199
- a = nil
2200
- instance.signal_connect "sig-with-foreign-struct" do |_obj, ct|
2201
- a = ct
2202
- end
2203
-
2204
- cairo_context = Regress.test_cairo_context_full_return
2205
-
2206
- GObject.signal_emit instance, "sig-with-foreign-struct", cairo_context
2207
-
2208
- _(a).must_be_instance_of Cairo::Context
2209
- _(a).must_equal cairo_context
2210
- end
2211
-
2212
- it "handles the 'sig-with-gerror' signal" do
2213
- skip_below "1.61.1"
2214
- a = nil
2215
- GObject.signal_connect(instance, "sig-with-gerror") do |_obj, err|
2216
- a = err
2217
- end
2218
- GObject.signal_emit instance, "sig-with-gerror", GLib::Error.new
2219
- _(a).must_be_instance_of GLib::Error
2220
- end
2221
-
2222
- it "handles the 'sig-with-hash-prop' signal" do
2223
- a = nil
2224
-
2225
- GObject.signal_connect(instance, "sig-with-hash-prop") do |_, ghash, _|
2226
- a = ghash.to_hash
2227
- end
2228
-
2229
- g_hash_table = GLib::HashTable.from([:utf8, GObject::Value],
2230
- "foo" => GObject::Value.from("bar"))
2231
-
2232
- GObject.signal_emit instance, "sig-with-hash-prop", g_hash_table
2233
-
2234
- _(a["foo"]).must_be_instance_of GObject::Value
2235
- _(a["foo"].get_value).must_equal "bar"
2236
- end
2237
-
2238
- it "handles the 'sig-with-inout-int' signal" do
2239
- skip_below "1.53.4"
2240
- skip "Not implemented yet"
2241
- GObject.signal_connect instance, "sig-with-inout-int" do |_obj, i, _ud|
2242
- i + 2
2243
- end
2244
- result = GObject.signal_emit instance, "sig-with-inout-int", 65
2245
- _(result).must_equal 67
2246
- end
2247
-
2248
- it "handles the 'sig-with-int64-prop' signal" do
2249
- a = nil
2250
-
2251
- GObject.signal_connect(instance, "sig-with-int64-prop") do |_obj, int64, _user_data|
2252
- a = int64
2253
- end
2254
-
2255
- result = GObject.signal_emit instance, "sig-with-int64-prop", 0x7fff_ffff_ffff_ffff
2256
-
2257
- _(a).must_equal 0x7fff_ffff_ffff_ffff
2258
- _(result).must_equal 0x7fff_ffff_ffff_ffff
2259
- end
2260
-
2261
- it "handles the 'sig-with-intarray-ret' signal" do
2262
- a = nil
2263
-
2264
- GObject.signal_connect(instance, "sig-with-intarray-ret") do |_, i, _|
2265
- a = i
2266
- [3, 2, 1]
2267
- end
2268
-
2269
- result = GObject.signal_emit instance, "sig-with-intarray-ret", 3
2270
-
2271
- _(a).must_equal 3
2272
-
2273
- _(result.to_a).must_equal [3, 2, 1]
2274
- end
2275
-
2276
- it "handles the 'sig-with-obj' signal" do
2277
- a = nil
2278
-
2279
- GObject.signal_connect(instance, "sig-with-obj") do |_, obj, _|
2280
- a = obj
2281
- end
2282
-
2283
- object = Regress::TestObj.constructor
2284
- GObject.signal_emit instance, "sig-with-obj", object
2285
-
2286
- _(a).must_equal object
2287
- end
2288
-
2289
- it "handles the 'sig-with-strv' signal" do
2290
- a = nil
2291
-
2292
- GObject.signal_connect(instance, "sig-with-strv") do |_, strs, _|
2293
- a = strs
2294
- end
2295
-
2296
- GObject.signal_emit instance, "sig-with-strv", GLib::Strv.from(%w(foo bar))
2297
-
2298
- _(a.to_a).must_equal %w(foo bar)
2299
- end
2300
-
2301
- it "handles the 'sig-with-uint64-prop' signal" do
2302
- a = nil
2303
-
2304
- GObject.signal_connect(instance, "sig-with-uint64-prop") do |_, uint64, _|
2305
- a = uint64
2306
- end
2307
-
2308
- result = GObject.signal_emit instance, "sig-with-uint64-prop", 0xffff_ffff_ffff_ffff
2309
-
2310
- _(a).must_equal 0xffff_ffff_ffff_ffff
2311
- _(result).must_equal 0xffff_ffff_ffff_ffff
2312
- end
2313
-
2314
- it "handles the 'test' signal" do
2315
- a = b = nil
2316
- o = Regress::TestSubObj.new
2317
- GObject.signal_connect(o, "test", 2) { |i, d| a = d; b = i }
2318
- GObject.signal_emit o, "test"
2319
- assert_equal [2, o], [a, b]
2320
- end
2321
-
2322
- it "handles the 'test-with-static-scope-arg' signal" do
2323
- a = nil
2324
-
2325
- GObject.signal_connect(instance, "test-with-static-scope-arg") do |_, obj, _|
2326
- a = obj
2327
- end
2328
-
2329
- arg = Regress::TestSimpleBoxedA.new
2330
- arg.some_int = 12_345
2331
- GObject.signal_emit instance, "test-with-static-scope-arg", arg
2332
-
2333
- _(a.some_int).must_equal 12_345
2334
- end
2335
- end
2336
-
2337
- describe "Regress::TestOtherError" do
2338
- it "has the member :code1" do
2339
- _(Regress::TestOtherError[:code1]).must_equal 1
2340
- end
2341
-
2342
- it "has the member :code2" do
2343
- _(Regress::TestOtherError[:code2]).must_equal 2
2344
- end
2345
-
2346
- it "has the member :code3" do
2347
- _(Regress::TestOtherError[:code3]).must_equal 3
2348
- end
2349
-
2350
- it "has a working function #quark" do
2351
- quark = Regress::TestOtherError.quark
2352
- _(GLib.quark_to_string(quark)).must_equal "regress-test-other-error"
2353
- end
2354
- end
2355
-
2356
- describe "Regress::TestPrivateEnum" do
2357
- it "has the member :public_enum_before" do
2358
- _(Regress::TestPrivateEnum[:public_enum_before]).must_equal 1
2359
- end
2360
- it "does not have the member :private" do
2361
- _(Regress::TestPrivateEnum[:private]).must_be_nil
2362
- end
2363
- it "has the member :public_enum_after" do
2364
- _(Regress::TestPrivateEnum[:public_enum_after]).must_equal 4
2365
- end
2366
- end
2367
-
2368
- describe "Regress::TestPrivateStruct" do
2369
- let(:instance) { Regress::TestPrivateStruct.new }
2370
-
2371
- it "has a writable field this_is_public_before" do
2372
- _(instance.this_is_public_before).must_equal 0
2373
- instance.this_is_public_before = 42
2374
- _(instance.this_is_public_before).must_equal 42
2375
- end
2376
-
2377
- it "has a private field this_is_private" do
2378
- skip "This field is identified as readable in the typelib"
2379
- _(instance).wont_respond_to :this_is_private
2380
- _(instance).wont_respond_to :this_is_private=
2381
- end
2382
-
2383
- it "has a writable field this_is_public_after" do
2384
- _(instance.this_is_public_after).must_equal 0
2385
- instance.this_is_public_after = 42
2386
- _(instance.this_is_public_after).must_equal 42
2387
- end
2388
- end
2389
-
2390
- describe "Regress::TestReferenceCounters" do
2391
- let(:instance) { Regress::TestReferenceCounters.new }
2392
-
2393
- before { skip_below "1.59.1" }
2394
-
2395
- it "has a writable field refcount" do
2396
- _(instance.refcount).must_equal 0
2397
- instance.refcount = 42
2398
- _(instance.refcount).must_equal 42
2399
- end
2400
-
2401
- it "has a writable field atomicrefcount" do
2402
- _(instance.atomicrefcount).must_equal 0
2403
- instance.atomicrefcount = 42
2404
- _(instance.atomicrefcount).must_equal 42
2405
- end
2406
- end
2407
-
2408
- describe "Regress::TestReferenceEnum" do
2409
- it "has the member :0" do
2410
- _(Regress::TestReferenceEnum[:"0"]).must_equal 4
2411
- end
2412
-
2413
- it "has the member :1" do
2414
- _(Regress::TestReferenceEnum[:"1"]).must_equal 2
2415
- end
2416
-
2417
- it "has the member :2" do
2418
- _(Regress::TestReferenceEnum[:"2"]).must_equal 54
2419
- end
2420
-
2421
- it "has the member :3" do
2422
- _(Regress::TestReferenceEnum[:"3"]).must_equal 4
2423
- end
2424
-
2425
- it "has the member :4" do
2426
- _(Regress::TestReferenceEnum[:"4"]).must_equal 216
2427
- end
2428
-
2429
- it "has the member :5" do
2430
- _(Regress::TestReferenceEnum[:"5"]).must_equal(-217)
2431
- end
2432
- end
2433
-
2434
- describe "Regress::TestSimpleBoxedA" do
2435
- it "creates an instance using #new" do
2436
- obj = Regress::TestSimpleBoxedA.new
2437
- assert_instance_of Regress::TestSimpleBoxedA, obj
2438
- end
2439
-
2440
- let(:instance) { Regress::TestSimpleBoxedA.new }
2441
-
2442
- it "has a writable field some_int" do
2443
- _(instance.some_int).must_equal 0
2444
- instance.some_int = 42
2445
- _(instance.some_int).must_equal 42
2446
- end
2447
-
2448
- it "has a writable field some_int8" do
2449
- _(instance.some_int8).must_equal 0
2450
- instance.some_int8 = 42
2451
- _(instance.some_int8).must_equal 42
2452
- end
2453
-
2454
- it "has a writable field some_double" do
2455
- _(instance.some_double).must_equal 0.0
2456
- instance.some_double = 42.0
2457
- _(instance.some_double).must_equal 42.0
2458
- end
2459
-
2460
- it "has a writable field some_enum" do
2461
- _(instance.some_enum).must_equal :value1
2462
- instance.some_enum = :value4
2463
- _(instance.some_enum).must_equal :value4
2464
- end
2465
-
2466
- it "has a working method #copy" do
2467
- instance.some_int = 4236
2468
-
2469
- obj2 = instance.copy
2470
- _(obj2).must_be_instance_of Regress::TestSimpleBoxedA
2471
- _(obj2.some_int).must_equal instance.some_int
2472
-
2473
- instance.some_int = 89
2474
- _(obj2.some_int).wont_equal instance.some_int
2475
- end
2476
-
2477
- it "has a working method #equals" do
2478
- instance.some_int = 4236
2479
-
2480
- ob2 = Regress::TestSimpleBoxedA.new
2481
- ob2.some_int = 4236
2482
- _(ob2.equals(instance)).must_equal true
2483
- ob2.some_enum = :value3
2484
- _(ob2.equals(instance)).must_equal true
2485
- ob2.some_int = 42
2486
- _(ob2.equals(instance)).wont_equal true
2487
- end
2488
-
2489
- it "has a working function #const_return" do
2490
- result = Regress::TestSimpleBoxedA.const_return
2491
- _([result.some_int, result.some_int8, result.some_double]).must_equal [5, 6, 7.0]
2492
- end
2493
- end
2494
-
2495
- describe "Regress::TestSimpleBoxedB" do
2496
- let(:instance) { Regress::TestSimpleBoxedB.new }
2497
- it "has a writable field some_int8" do
2498
- _(instance.some_int8).must_equal 0
2499
- instance.some_int8 = 42
2500
- _(instance.some_int8).must_equal 42
2501
- end
2502
-
2503
- it "has a writable field nested_a" do
2504
- _(instance.nested_a.some_int).must_equal 0
2505
- instance.nested_a = Regress::TestSimpleBoxedA.const_return
2506
- _(instance.nested_a.some_int).must_equal 5
2507
- end
2508
-
2509
- it "has a working method #copy" do
2510
- instance.some_int8 = -42
2511
- instance.nested_a.some_int = 4242
2512
-
2513
- copy = instance.copy
2514
- _([copy.some_int8, copy.nested_a.some_int]).must_equal [-42, 4242]
2515
-
2516
- instance.some_int8 = 103
2517
- _(copy.some_int8).must_equal(-42)
2518
- end
2519
- end
2520
-
2521
- describe "Regress::TestStructA" do
2522
- let(:instance) { Regress::TestStructA.new }
2523
- it "has a writable field some_int" do
2524
- _(instance.some_int).must_equal 0
2525
- instance.some_int = 2556
2526
- _(instance.some_int).must_equal 2556
2527
- end
2528
-
2529
- it "has a writable field some_int8" do
2530
- _(instance.some_int8).must_equal 0
2531
- instance.some_int8 = -10
2532
- _(instance.some_int8).must_equal(-10)
2533
- end
2534
-
2535
- it "has a writable field some_double" do
2536
- _(instance.some_double).must_equal 0.0
2537
- instance.some_double = 1.03455e20
2538
- _(instance.some_double).must_equal 1.03455e20
2539
- end
2540
-
2541
- it "has a writable field some_enum" do
2542
- _(instance.some_enum).must_equal :value1
2543
- instance.some_enum = :value2
2544
- _(instance.some_enum).must_equal :value2
2545
- end
2546
-
2547
- it "has a working method #clone" do
2548
- a = Regress::TestStructA.new
2549
- a.some_int = 2556
2550
- a.some_int8 = -10
2551
- a.some_double = 1.03455e20
2552
- a.some_enum = :value2
2553
-
2554
- b = a.clone
2555
-
2556
- assert_equal 2556, b.some_int
2557
- assert_equal(-10, b.some_int8)
2558
- assert_equal 1.03455e20, b.some_double
2559
- assert_equal :value2, b.some_enum
2560
- end
2561
-
2562
- it "has a working function #parse" do
2563
- a = Regress::TestStructA.parse("this string is actually ignored")
2564
- _(a.some_int).must_equal 23
2565
- end
2566
- end
2567
-
2568
- describe "Regress::TestStructB" do
2569
- let(:instance) { Regress::TestStructB.new }
2570
- it "has a writable field some_int8" do
2571
- _(instance.some_int8).must_equal 0
2572
- instance.some_int8 = 42
2573
- _(instance.some_int8).must_equal 42
2574
- end
2575
-
2576
- it "has a writable field nested_a" do
2577
- _(instance.nested_a.some_int).must_equal 0
2578
-
2579
- nested = Regress::TestStructA.new
2580
- nested.some_int = -4321
2581
-
2582
- instance.nested_a = nested
2583
- _(instance.nested_a.some_int).must_equal(-4321)
2584
- end
2585
-
2586
- it "has a working method #clone" do
2587
- a = Regress::TestStructB.new
2588
- a.some_int8 = 42
2589
- a.nested_a.some_int = 2556
2590
- a.nested_a.some_int8 = -10
2591
- a.nested_a.some_double = 1.03455e20
2592
- a.nested_a.some_enum = :value2
2593
-
2594
- b = a.clone
2595
-
2596
- assert_equal 42, b.some_int8
2597
- assert_equal 2556, b.nested_a.some_int
2598
- assert_equal(-10, b.nested_a.some_int8)
2599
- assert_equal 1.03455e20, b.nested_a.some_double
2600
- assert_equal :value2, b.nested_a.some_enum
2601
- end
2602
- end
2603
-
2604
- describe "Regress::TestStructC" do
2605
- let(:instance) { Regress::TestStructC.new }
2606
- it "has a writable field another_int" do
2607
- _(instance.another_int).must_equal 0
2608
- instance.another_int = 42
2609
- _(instance.another_int).must_equal 42
2610
- end
2611
-
2612
- it "has a writable field obj" do
2613
- o = Regress::TestSubObj.new
2614
- _(instance.obj).must_be_nil
2615
- instance.obj = o
2616
- _(instance.obj).must_equal o
2617
- end
2618
- end
2619
-
2620
- describe "Regress::TestStructD" do
2621
- let(:instance) { Regress::TestStructD.new }
2622
- it "has a writable field array1" do
2623
- _(instance.array1).must_be :==, []
2624
- struct = Regress::TestStructA.new
2625
- instance.array1 = [struct]
2626
- _(instance.array1).must_be :==, [struct]
2627
- end
2628
-
2629
- it "has a writable field array2" do
2630
- _(instance.array2).must_be :==, []
2631
- o = Regress::TestSubObj.new
2632
- instance.array2 = [o]
2633
- _(instance.array2).must_be :==, [o]
2634
- end
2635
-
2636
- it "has a writable field field" do
2637
- _(instance.field).must_be_nil
2638
- o = Regress::TestSubObj.new
2639
- instance.field = o
2640
- _(instance.field).must_equal o
2641
- end
2642
-
2643
- it "has a writable field list" do
2644
- _(instance.list).must_be_nil
2645
- o = Regress::TestSubObj.new
2646
- instance.list = [o]
2647
- _(instance.list).must_be :==, [o]
2648
- end
2649
-
2650
- it "has a writable field garray" do
2651
- _(instance.garray).must_be_nil
2652
- o = Regress::TestSubObj.new
2653
- instance.garray = [o]
2654
- _(instance.garray).must_be :==, [o]
2655
- end
2656
- end
2657
-
2658
- describe "Regress::TestStructE" do
2659
- let(:instance) { Regress::TestStructE.new }
2660
- it "has a writable field some_type" do
2661
- _(instance.some_type).must_equal 0
2662
- instance.some_type = GObject::TYPE_STRING
2663
- _(instance.some_type).must_equal GObject::TYPE_STRING
2664
- end
2665
-
2666
- it "has a writable field some_union" do
2667
- _(instance.some_union.map(&:v_int)).must_equal [0, 0]
2668
-
2669
- union1 = Regress::TestStructE__some_union__union.new
2670
- union1.v_int = 42
2671
- union2 = Regress::TestStructE__some_union__union.new
2672
- union2.v_int = 84
2673
-
2674
- instance.some_union = [union1, union2]
2675
-
2676
- _(instance.some_union.map(&:v_int)).must_equal [42, 84]
2677
- end
2678
- end
2679
- describe "Regress::TestStructE__some_union__union" do
2680
- let(:instance) { Regress::TestStructE__some_union__union.new }
2681
- it "has a writable field v_int" do
2682
- _(instance.v_int).must_equal 0
2683
- instance.v_int = -54_321
2684
- _(instance.v_int).must_equal(-54_321)
2685
- end
2686
-
2687
- it "has a writable field v_uint" do
2688
- _(instance.v_uint).must_equal 0
2689
- instance.v_uint = 54_321
2690
- _(instance.v_uint).must_equal 54_321
2691
- end
2692
-
2693
- it "has a writable field v_long" do
2694
- _(instance.v_long).must_equal 0
2695
- instance.v_long = -54_321
2696
- _(instance.v_long).must_equal(-54_321)
2697
- end
2698
-
2699
- it "has a writable field v_ulong" 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_int64" do
2706
- _(instance.v_int64).must_equal 0
2707
- instance.v_int64 = -54_321_000_000_000
2708
- _(instance.v_int64).must_equal(-54_321_000_000_000)
2709
- end
2710
- it "has a writable field v_uint64" do
2711
- _(instance.v_uint64).must_equal 0
2712
- instance.v_uint64 = 54_321_000_000_000
2713
- _(instance.v_uint64).must_equal 54_321_000_000_000
2714
- end
2715
- it "has a writable field v_float" do
2716
- _(instance.v_float).must_equal 0
2717
- instance.v_float = 3.1415
2718
- _(instance.v_float).must_be_close_to 3.1415
2719
- end
2720
- it "has a writable field v_double" do
2721
- _(instance.v_double).must_equal 0
2722
- instance.v_double = 3.1415
2723
- _(instance.v_double).must_equal 3.1415
2724
- end
2725
- it "has a writable field v_pointer" do
2726
- _(instance.v_pointer).must_be :null?
2727
- instance.v_pointer = FFI::Pointer.new 54_321
2728
- _(instance.v_pointer.address).must_equal 54_321
2729
- end
2730
- end
2731
- describe "Regress::TestStructF" do
2732
- let(:instance) { Regress::TestStructF.new }
2733
-
2734
- it "has a writable field ref_count" do
2735
- _(instance.ref_count).must_equal 0
2736
- instance.ref_count = 1
2737
- _(instance.ref_count).must_equal 1
2738
- end
2739
-
2740
- it "has a writable field data1" do
2741
- _(instance.data1).must_be :null?
2742
- instance.data1 = FFI::MemoryPointer.new(:int32).tap { |it| it.put_int(0, 42) }
2743
- _(instance.data1.read_int).must_equal 42
2744
- end
2745
-
2746
- # TODO: Check what gobject-introspection should/will do with these fields.
2747
- it "has a writable field data2" do
2748
- skip "Introspection data cannot deal with type of this field yet"
2749
- end
2750
-
2751
- it "has a writable field data3" do
2752
- skip "Introspection data cannot deal with type of this field yet"
2753
- end
2754
-
2755
- it "has a writable field data4" do
2756
- skip "Introspection data cannot deal with type of this field yet"
2757
- end
2758
-
2759
- it "has a writable field data5" do
2760
- skip "Introspection data cannot deal with type of this field yet"
2761
- end
2762
-
2763
- it "has a writable field data6" do
2764
- skip "Introspection data cannot deal with type of this field yet"
2765
- end
2766
-
2767
- it "has a writable field data7" do
2768
- skip_below "1.59.3"
2769
- instance.data7 = 42
2770
- _(instance.data7).must_equal 42
2771
- end
2772
- end
2773
-
2774
- describe "Regress::TestStructFixedArray" do
2775
- let(:instance) { Regress::TestStructFixedArray.new }
2776
- it "has a writable field just_int" do
2777
- _(instance.just_int).must_equal 0
2778
- instance.just_int = 42
2779
- _(instance.just_int).must_equal 42
2780
- end
2781
-
2782
- it "has a writable field array" do
2783
- _(instance.array).must_be :==, [0] * 10
2784
- instance.array = (1..10).to_a
2785
- _(instance.array).must_be :==, (1..10).to_a
2786
- end
2787
-
2788
- it "has a working method #frob" do
2789
- instance.array = (0..9).to_a
2790
- instance.frob
2791
- _(instance.array).must_be :==, (42..42 + 9).to_a
2792
- _(instance.just_int).must_equal 7
2793
- end
2794
- end
2795
-
2796
- describe "Regress::TestSubObj" do
2797
- it "creates an instance using #new" do
2798
- tso = Regress::TestSubObj.new
2799
- assert_instance_of Regress::TestSubObj, tso
2800
- end
2801
-
2802
- it "does not create an instance using its parent object's custom constructors" do
2803
- _(proc { Regress::TestSubObj.constructor }).must_raise NoMethodError
2804
- end
2805
-
2806
- let(:instance) { Regress::TestSubObj.new }
2807
-
2808
- it "has a working method #instance_method" do
2809
- res = instance.instance_method
2810
- assert_equal 0, res
2811
- end
2812
-
2813
- it "has a working method #unset_bare" do
2814
- instance.unset_bare
2815
- pass
2816
- end
2817
-
2818
- describe "its 'boolean' property" do
2819
- before { skip_below "1.59.1" }
2820
-
2821
- it "can be retrieved with #get_property" do
2822
- _(instance.get_property("boolean")).must_equal true
2823
- end
2824
-
2825
- it "can be retrieved with #boolean" do
2826
- _(instance.boolean).must_equal true
2827
- end
2828
-
2829
- it "can be set with #set_property" do
2830
- instance.set_property("boolean", false)
2831
- _(instance.get_property("boolean")).must_equal false
2832
- end
2833
-
2834
- it "can be set with #boolean=" do
2835
- instance.boolean = false
2836
- _(instance.get_property("boolean")).must_equal false
2837
- end
2838
- end
2839
-
2840
- it "does not have a field parent_instance" do
2841
- _(instance).wont_respond_to :parent_instance
2842
- end
2843
- end
2844
-
2845
- describe "Regress::TestWi8021x" do
2846
- it "creates an instance using #new" do
2847
- o = Regress::TestWi8021x.new
2848
- assert_instance_of Regress::TestWi8021x, o
2849
- end
2850
-
2851
- it "has a working function #static_method" do
2852
- assert_equal(-84, Regress::TestWi8021x.static_method(-42))
2853
- end
2854
-
2855
- let(:instance) { Regress::TestWi8021x.new }
2856
-
2857
- it "has a working method #get_testbool" do
2858
- _(instance.get_testbool).must_equal true
2859
- end
2860
-
2861
- it "has a working method #set_testbool" do
2862
- instance.set_testbool true
2863
- _(instance.get_testbool).must_equal true
2864
- instance.set_testbool false
2865
- _(instance.get_testbool).must_equal false
2866
- end
2867
-
2868
- describe "its 'testbool' property" do
2869
- it "can be retrieved with #get_property" do
2870
- _(instance.get_property("testbool")).must_equal true
2871
- end
2872
-
2873
- it "can be retrieved with #testbool" do
2874
- _(instance.testbool).must_equal true
2875
- end
2876
-
2877
- it "can be set with #set_property" do
2878
- instance.set_property "testbool", true
2879
- _(instance.get_testbool).must_equal true
2880
- _(instance.get_property("testbool")).must_equal true
2881
-
2882
- instance.set_property "testbool", false
2883
- _(instance.get_testbool).must_equal false
2884
- _(instance.get_property("testbool")).must_equal false
2885
- end
2886
-
2887
- it "can be set with #testbool=" do
2888
- instance.testbool = true
2889
- _(instance.testbool).must_equal true
2890
- _(instance.get_testbool).must_equal true
2891
- _(instance.get_property("testbool")).must_equal true
2892
-
2893
- instance.testbool = false
2894
- _(instance.testbool).must_equal false
2895
- _(instance.get_testbool).must_equal false
2896
- _(instance.get_property("testbool")).must_equal false
2897
- end
2898
- end
2899
- end
2900
-
2901
- it "has the constant UTF8_CONSTANT" do
2902
- assert_equal "const ♥ utf8", Regress::UTF8_CONSTANT
2903
- end
2904
-
2905
- it "has a working function #aliased_caller_alloc" do
2906
- result = Regress.aliased_caller_alloc
2907
- _(result).must_be_instance_of Regress::TestBoxed
2908
- end
2909
-
2910
- it "has a working function #annotation_attribute_func" do
2911
- info = get_introspection_data("Regress", "annotation_attribute_func")
2912
- param = info.args.last
2913
- _(param.attribute("some.annotation")).must_equal "value"
2914
- _(param.attribute("another.annotation")).must_equal "blahvalue"
2915
-
2916
- obj = Regress::AnnotationObject.new
2917
- _(Regress.annotation_attribute_func(obj, "hello")).must_equal 42
2918
- end
2919
-
2920
- it "has a working function #annotation_custom_destroy" do
2921
- result = Regress.annotation_custom_destroy {}
2922
- _(result).must_be_nil
2923
- end
2924
-
2925
- it "has a working function #annotation_get_source_file" do
2926
- _(Regress.annotation_get_source_file).must_be_nil
2927
- end
2928
-
2929
- it "has a working function #annotation_init" do
2930
- result = Regress.annotation_init %w(foo bar)
2931
- _(result.to_a).must_equal %w(foo bar)
2932
- end
2933
-
2934
- it "has a working function #annotation_invalid_regress_annotation" do
2935
- _(Regress.annotation_invalid_regress_annotation(42)).must_be_nil
2936
- end
2937
-
2938
- it "has a working function #annotation_ptr_array" do
2939
- # TODO: Automatically convert array elements to correct type
2940
- val1 = GObject::Value.from 1
2941
- val2 = GObject::Value.from "a"
2942
- _(Regress.annotation_ptr_array([val1, val2])).must_be_nil
2943
- end
2944
-
2945
- it "has a working function #annotation_return_array" do
2946
- _(Regress.annotation_return_array).must_be_nil
2947
- end
2948
-
2949
- it "has a working function #annotation_return_filename" do
2950
- skip "This function is wrongly annotated as transfer-ownership: full"
2951
- _(Regress.annotation_return_filename).must_equal "a utf-8 filename"
2952
- end
2953
-
2954
- it "has a working function #annotation_set_source_file" do
2955
- _(Regress.annotation_set_source_file("a filename")).must_be_nil
2956
- end
2957
-
2958
- it "has a working function #annotation_space_after_comment_bug631690" do
2959
- _(Regress.annotation_space_after_comment_bug631690).must_be_nil
2960
- end
2961
-
2962
- it "has a working function #annotation_string_array_length" do
2963
- _(Regress.annotation_string_array_length(%w(foo bar))).must_be_nil
2964
- end
2965
-
2966
- it "has a working function #annotation_string_zero_terminated" do
2967
- _(Regress.annotation_string_zero_terminated.to_a).must_equal []
2968
- end
2969
-
2970
- it "has a working function #annotation_string_zero_terminated_out" do
2971
- _(Regress.annotation_string_zero_terminated_out(%w(foo bar)).to_a).
2972
- must_equal %w(foo bar)
2973
- end
2974
-
2975
- it "has a working function #annotation_test_parsing_bug630862" do
2976
- _(Regress.annotation_test_parsing_bug630862).must_be_nil
2977
- end
2978
-
2979
- it "has a working function #annotation_transfer_floating" do
2980
- Regress.setup_method! :annotation_transfer_floating
2981
- method = Regress.method :annotation_transfer_floating
2982
- # NOTE: The arity of this method was changed in GObjectIntrospection 1.53.2
2983
- if method.arity == 1
2984
- object = GObject::Object.new
2985
- _(Regress.annotation_transfer_floating(object)).must_be_nil
2986
- else
2987
- _(Regress.annotation_transfer_floating).must_be_nil
2988
- end
2989
- end
2990
-
2991
- it "has a working function #annotation_versioned" do
2992
- _(Regress.annotation_versioned).must_be_nil
2993
- end
2994
-
2995
- it "has a working function #atest_error_quark" do
2996
- result = Regress.atest_error_quark
2997
- _(GLib.quark_to_string(result)).must_equal "regress-atest-error"
2998
- end
2999
-
3000
- it "has a working function #foo_async_ready_callback" do
3001
- skip "This function is defined in the header but not implemented"
3002
- end
3003
-
3004
- it "has a working function #foo_destroy_notify_callback" do
3005
- skip "This function is defined in the header but not implemented"
3006
- end
3007
-
3008
- it "has a working function #foo_enum_type_method" do
3009
- skip "This function is defined in the header but not implemented"
3010
- end
3011
-
3012
- it "has a working function #foo_enum_type_returnv" do
3013
- skip "This function is defined in the header but not implemented"
3014
- end
3015
-
3016
- it "has a working function #foo_error_quark" do
3017
- result = Regress.foo_error_quark
3018
- _(GLib.quark_to_string(result)).must_equal("regress_foo-error-quark")
3019
- end
3020
-
3021
- it "has a working function #foo_init" do
3022
- _(Regress.foo_init).must_equal 0x1138
3023
- end
3024
-
3025
- it "has a working function #foo_interface_static_method" do
3026
- _(Regress.foo_interface_static_method(42)).must_be_nil
3027
- end
3028
-
3029
- it "has a working function #foo_method_external_references" do
3030
- skip "This function is defined in the header but not implemented"
3031
- end
3032
-
3033
- it "has a working function #foo_not_a_constructor_new" do
3034
- _(Regress.foo_not_a_constructor_new).must_be_nil
3035
- end
3036
-
3037
- it "has a working function #foo_test_array" do
3038
- _(Regress.foo_test_array).must_be_nil
3039
- end
3040
-
3041
- it "has a working function #foo_test_const_char_param" do
3042
- skip "This function is defined in the header but not implemented"
3043
- end
3044
-
3045
- it "has a working function #foo_test_const_char_retval" do
3046
- skip "This function is defined in the header but not implemented"
3047
- end
3048
-
3049
- it "has a working function #foo_test_const_struct_param" do
3050
- skip "This function is defined in the header but not implemented"
3051
- end
3052
-
3053
- it "has a working function #foo_test_const_struct_retval" do
3054
- skip "This function is defined in the header but not implemented"
3055
- end
3056
-
3057
- it "has a working function #foo_test_string_array" do
3058
- _(Regress.foo_test_string_array(%w(foo bar))).must_be_nil
3059
- end
3060
-
3061
- it "has a working function #foo_test_string_array_with_g" do
3062
- _(Regress.foo_test_string_array_with_g(%w(foo bar))).must_be_nil
3063
- end
3064
-
3065
- it "has a working function #foo_test_unsigned_qualifier" do
3066
- skip "This function is defined in the header but not implemented"
3067
- end
3068
-
3069
- it "has a working function #foo_test_unsigned_type" do
3070
- skip "This function is defined in the header but not implemented"
3071
- end
3072
-
3073
- it "has a working function #func_obj_null_in" do
3074
- Regress.func_obj_null_in nil
3075
- Regress.func_obj_null_in Regress::TestObj.constructor
3076
- pass
3077
- end
3078
-
3079
- it "has a working function #func_obj_nullable_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 #get_variant" do
3086
- skip_below "1.47.92"
3087
- var = Regress.get_variant
3088
- _(var.get_int32).must_equal 42
3089
- # TODO: Make var not floating
3090
- end
3091
-
3092
- it "has a working function #global_get_flags_out" do
3093
- result = Regress.global_get_flags_out
3094
- _(result).must_equal(flag1: true, flag3: true)
3095
- end
3096
-
3097
- it "has a working function #has_parameter_named_attrs" do
3098
- Regress.has_parameter_named_attrs 42, [23] * 32
3099
- pass
3100
- end
3101
-
3102
- it "has a working function #introspectable_via_alias" do
3103
- Regress.introspectable_via_alias []
3104
- pass
3105
- end
3106
-
3107
- it "has a working function #set_abort_on_error" do
3108
- Regress.set_abort_on_error false
3109
- Regress.set_abort_on_error true
3110
- pass
3111
- end
3112
-
3113
- it "has a working function #test_abc_error_quark" do
3114
- quark = Regress.test_abc_error_quark
3115
- _(GLib.quark_to_string(quark)).must_equal "regress-test-abc-error"
3116
- end
3117
-
3118
- it "has a working function #test_array_callback" do
3119
- a = nil
3120
- b = nil
3121
- c = 95
3122
-
3123
- result = Regress.test_array_callback do |one, two|
3124
- a = one
3125
- b = two
3126
- c
3127
- end
3128
-
3129
- _(result).must_equal 2 * c
3130
- _(a.to_a).must_equal [-1, 0, 1, 2]
3131
- _(b.to_a).must_equal %w(one two three)
3132
- end
3133
-
3134
- it "has a working function #test_array_fixed_out_objects" do
3135
- result = Regress.test_array_fixed_out_objects
3136
- gtype = Regress::TestObj.gtype
3137
-
3138
- _(result.size).must_equal 2
3139
-
3140
- result.each do |o|
3141
- assert_instance_of Regress::TestObj, o
3142
- assert_equal gtype, GObject.type_from_instance(o)
3143
- end
3144
- end
3145
-
3146
- it "has a working function #test_array_fixed_size_int_in" do
3147
- assert_equal 5 + 4 + 3 + 2 + 1, Regress.test_array_fixed_size_int_in([5, 4, 3, 2, 1])
3148
- end
3149
-
3150
- describe "#test_array_fixed_size_int_in" do
3151
- it "raises an error when called with the wrong number of arguments" do
3152
- assert_raises ArgumentError do
3153
- Regress.test_array_fixed_size_int_in [2]
3154
- end
3155
- end
3156
- end
3157
-
3158
- it "has a working function #test_array_fixed_size_int_out" do
3159
- _(Regress.test_array_fixed_size_int_out).must_be :==, [0, 1, 2, 3, 4]
3160
- end
3161
-
3162
- it "has a working function #test_array_fixed_size_int_return" do
3163
- _(Regress.test_array_fixed_size_int_return).must_be :==, [0, 1, 2, 3, 4]
3164
- end
3165
-
3166
- it "has a working function #test_array_gint16_in" do
3167
- assert_equal 5 + 4 + 3, Regress.test_array_gint16_in([5, 4, 3])
3168
- end
3169
-
3170
- it "has a working function #test_array_gint32_in" do
3171
- assert_equal 5 + 4 + 3, Regress.test_array_gint32_in([5, 4, 3])
3172
- end
3173
-
3174
- it "has a working function #test_array_gint64_in" do
3175
- assert_equal 5 + 4 + 3, Regress.test_array_gint64_in([5, 4, 3])
3176
- end
3177
-
3178
- it "has a working function #test_array_gint8_in" do
3179
- assert_equal 5 + 4 + 3, Regress.test_array_gint8_in([5, 4, 3])
3180
- end
3181
-
3182
- it "has a working function #test_array_gtype_in" do
3183
- t1 = GObject.type_from_name "gboolean"
3184
- t2 = GObject.type_from_name "gint64"
3185
- assert_equal "[gboolean,gint64,]", Regress.test_array_gtype_in([t1, t2])
3186
- end
3187
-
3188
- it "has a working function #test_array_inout_callback" do
3189
- Regress.test_array_inout_callback do |ints|
3190
- arr = ints.to_a
3191
- arr.shift
3192
- arr
3193
- end
3194
- pass
3195
- end
3196
-
3197
- it "has a working function #test_array_int_full_out" do
3198
- _(Regress.test_array_int_full_out).must_be :==, [0, 1, 2, 3, 4]
3199
- end
3200
-
3201
- it "has a working function #test_array_int_in" do
3202
- assert_equal 5 + 4 + 3, Regress.test_array_int_in([5, 4, 3])
3203
- end
3204
-
3205
- it "has a working function #test_array_int_inout" do
3206
- _(Regress.test_array_int_inout([5, 2, 3])).must_be :==, [3, 4]
3207
- end
3208
-
3209
- it "has a working function #test_array_int_none_out" do
3210
- _(Regress.test_array_int_none_out).must_be :==, [1, 2, 3, 4, 5]
3211
- end
3212
-
3213
- it "has a working function #test_array_int_null_in" do
3214
- Regress.test_array_int_null_in nil
3215
- pass
3216
- end
3217
-
3218
- it "has a working function #test_array_int_null_out" do
3219
- _(Regress.test_array_int_null_out).must_be_nil
3220
- end
3221
-
3222
- it "has a working function #test_array_int_out" do
3223
- _(Regress.test_array_int_out).must_be :==, [0, 1, 2, 3, 4]
3224
- end
3225
-
3226
- it "has a working function #test_array_struct_in_full" do
3227
- skip_below "1.59.4"
3228
- # FIXME: Allow passing field values to .new
3229
- arr = [Regress::TestStructA.new.tap { |it| it.some_int = 201 },
3230
- Regress::TestStructA.new.tap { |it| it.some_int = 202 }]
3231
- Regress.test_array_struct_in_full(arr)
3232
- end
3233
-
3234
- it "has a working function #test_array_struct_in_none" do
3235
- skip_below "1.59.4"
3236
- # FIXME: Allow passing field values to .new
3237
- arr = [Regress::TestStructA.new.tap { |it| it.some_int = 301 },
3238
- Regress::TestStructA.new.tap { |it| it.some_int = 302 },
3239
- Regress::TestStructA.new.tap { |it| it.some_int = 303 }]
3240
- Regress.test_array_struct_in_none(arr)
3241
- end
3242
-
3243
- it "has a working function #test_array_struct_out" do
3244
- skip_below "1.47.92"
3245
- result = Regress.test_array_struct_out
3246
- _(result.map(&:some_int)).must_equal [22, 33, 44]
3247
- end
3248
-
3249
- it "has a working function #test_array_struct_out_caller_alloc" do
3250
- skip_below "1.59.4"
3251
- skip "Not implemented yet"
3252
- result = Regress.test_array_struct_out_caller_alloc 3
3253
- _(result.map(&:some_int)).must_equal [22, 33, 44]
3254
- end
3255
-
3256
- it "has a working function #test_array_struct_out_container" do
3257
- skip_below "1.59.4"
3258
- result = Regress.test_array_struct_out_container
3259
- _(result.map(&:some_int)).must_equal [11, 13, 17, 19, 23]
3260
- end
3261
-
3262
- it "has a working function #test_array_struct_out_full_fixed" do
3263
- skip_below "1.59.4"
3264
- result = Regress.test_array_struct_out_full_fixed
3265
- _(result.map(&:some_int)).must_equal [2, 3, 5, 7]
3266
- end
3267
-
3268
- it "has a working function #test_array_struct_out_none" do
3269
- skip_below "1.59.4"
3270
- result = Regress.test_array_struct_out_none
3271
- _(result.map(&:some_int)).must_equal [111, 222, 333]
3272
- end
3273
-
3274
- it "has a working function #test_async_ready_callback" do
3275
- main_loop = GLib::MainLoop.new nil, false
3276
-
3277
- a = 1
3278
- Regress.test_async_ready_callback do
3279
- main_loop.quit
3280
- a = 2
3281
- end
3282
-
3283
- main_loop.run
3284
-
3285
- assert_equal 2, a
3286
- end
3287
-
3288
- it "has a working function #test_boolean" do
3289
- assert_equal false, Regress.test_boolean(false)
3290
- assert_equal true, Regress.test_boolean(true)
3291
- end
3292
-
3293
- it "has a working function #test_boolean_false" do
3294
- assert_equal false, Regress.test_boolean_false(false)
3295
- end
3296
-
3297
- it "has a working function #test_boolean_true" do
3298
- assert_equal true, Regress.test_boolean_true(true)
3299
- end
3300
-
3301
- it "has a working function #test_boxeds_not_a_method" do
3302
- boxed = Regress::TestBoxed.new_alternative_constructor1 123
3303
- Regress.test_boxeds_not_a_method boxed
3304
- pass
3305
- end
3306
-
3307
- it "has a working function #test_boxeds_not_a_static" do
3308
- Regress.test_boxeds_not_a_static
3309
- pass
3310
- end
3311
-
3312
- it "has a working function #test_cairo_context_full_return" do
3313
- ct = Regress.test_cairo_context_full_return
3314
- assert_instance_of Cairo::Context, ct
3315
- end
3316
-
3317
- it "has a working function #test_cairo_context_none_in" do
3318
- ct = Regress.test_cairo_context_full_return
3319
- Regress.test_cairo_context_none_in ct
3320
- end
3321
-
3322
- it "has a working function #test_cairo_surface_full_out" do
3323
- cs = Regress.test_cairo_surface_full_out
3324
- assert_instance_of Cairo::Surface, cs
3325
- end
3326
-
3327
- it "has a working function #test_cairo_surface_full_return" do
3328
- cs = Regress.test_cairo_surface_full_return
3329
- assert_instance_of Cairo::Surface, cs
3330
- end
3331
-
3332
- it "has a working function #test_cairo_surface_none_in" do
3333
- cs = Regress.test_cairo_surface_full_return
3334
- Regress.test_cairo_surface_none_in cs
3335
- end
3336
-
3337
- it "has a working function #test_cairo_surface_none_return" do
3338
- cs = Regress.test_cairo_surface_none_return
3339
- assert_instance_of Cairo::Surface, cs
3340
- end
3341
-
3342
- it "has a working function #test_callback" do
3343
- result = Regress.test_callback { 5 }
3344
- assert_equal 5, result
3345
- end
3346
-
3347
- it "has a working function #test_callback_async" do
3348
- a = 1
3349
- stored_proc = nil
3350
- Regress.test_callback_async { |user_data| stored_proc = user_data; a = 2 }
3351
- result = Regress.test_callback_thaw_async
3352
- _(a).must_equal 2
3353
- _(stored_proc).wont_be_nil
3354
- _(result).must_equal 2
3355
- # TODO: See when we can clean up the stored callback for async callbacks.
3356
- stored_id = stored_proc.object_id
3357
- _(GirFFI::CallbackBase::CALLBACKS[stored_id].object_id).must_equal stored_id
3358
- end
3359
-
3360
- it "has a working function #test_callback_destroy_notify" do
3361
- a = 1
3362
- stored_proc = nil
3363
- r1 = Regress.test_callback_destroy_notify { |user_data| stored_proc = user_data; a = 2 }
3364
- _(a).must_equal 2
3365
- stored_id = stored_proc.object_id
3366
- _(GirFFI::CallbackBase::CALLBACKS[stored_id].object_id).must_equal stored_id
3367
-
3368
- a = 3
3369
- r2 = Regress.test_callback_thaw_notifications
3370
- _(a).must_equal 2
3371
- _(r1).must_equal r2
3372
- _(GirFFI::CallbackBase::CALLBACKS[stored_id]).must_be_nil
3373
- end
3374
-
3375
- it "has a working function #test_callback_destroy_notify_no_user_data" do
3376
- callback_times_called = 0
3377
- b = :not_nil
3378
-
3379
- result = Regress.test_callback_destroy_notify_no_user_data do |user_data|
3380
- callback_times_called += 1
3381
- b = user_data
3382
- callback_times_called * 5
3383
- end
3384
-
3385
- _(callback_times_called).must_equal 1
3386
- _(result).must_equal 5
3387
- _(b).must_be_nil
3388
-
3389
- result = Regress.test_callback_thaw_notifications
3390
-
3391
- _(callback_times_called).must_equal 2
3392
- _(result).must_equal 10
3393
- _(b).must_be_nil
3394
- end
3395
-
3396
- it "has a working function #test_callback_return_full" do
3397
- obj = Regress::TestObj.constructor
3398
- Regress.test_callback_return_full { obj }
3399
- _(object_ref_count(obj)).must_equal 1
3400
- end
3401
-
3402
- it "has a working function #test_callback_thaw_async" do
3403
- invoked = []
3404
- Regress.test_callback_async { invoked << 1; 1 }
3405
- Regress.test_callback_async { invoked << 2; 2 }
3406
- Regress.test_callback_async { invoked << 3; 3 }
3407
- result = Regress.test_callback_thaw_async
3408
- _(invoked).must_equal [3, 2, 1]
3409
- _(result).must_equal 1
3410
- end
3411
-
3412
- it "has a working function #test_callback_thaw_notifications" do
3413
- Regress.test_callback_destroy_notify { 42 }
3414
- Regress.test_callback_destroy_notify { 24 }
3415
- result = Regress.test_callback_thaw_notifications
3416
- _(result).must_equal 66
3417
- end
3418
-
3419
- it "has a working function #test_callback_user_data" do
3420
- stored_id = nil
3421
- result = Regress.test_callback_user_data { |u| stored_id = u; 5 }
3422
- # TODO: Ensure that the key stored_id is no longer in the callback store
3423
- _(stored_id).wont_be_nil
3424
- _(result).must_equal 5
3425
- end
3426
-
3427
- it "has a working function #test_closure" do
3428
- c = GObject::RubyClosure.new { 5235 }
3429
- r = Regress.test_closure c
3430
- assert_equal 5235, r
3431
- end
3432
-
3433
- it "has a working function #test_closure_one_arg" do
3434
- c = GObject::RubyClosure.new { |a| a * 2 }
3435
- r = Regress.test_closure_one_arg c, 2
3436
- assert_equal 4, r
3437
- end
3438
-
3439
- it "has a working function #test_closure_variant" do
3440
- arg = GLib::Variant.new_string "foo"
3441
-
3442
- # TODO: Convert proc to RubyClosure automatically
3443
- closure = GObject::RubyClosure.new do |variant|
3444
- str = variant.get_string
3445
- if str == "foo"
3446
- GLib::Variant.new_int32 40
3447
- else
3448
- GLib::Variant.new_string "bar"
3449
- end
3450
- end
3451
-
3452
- result = Regress.test_closure_variant closure, arg
3453
-
3454
- _(result.get_int32).must_equal 40
3455
- end
3456
-
3457
- it "has a working function #test_create_fundamental_hidden_class_instance" do
3458
- skip_below "1.51.2"
3459
- instance = Regress.test_create_fundamental_hidden_class_instance
3460
- _(instance).must_be_kind_of Regress::TestFundamentalObject
3461
- g_type = instance.object_class.g_type
3462
- _(GObject.type_name(g_type)).must_equal "RegressTestFundamentalHiddenSubObject"
3463
- end
3464
-
3465
- it "has a working function #test_date_in_gvalue" do
3466
- date = Regress.test_date_in_gvalue
3467
- assert_equal [1984, :december, 5],
3468
- [date.get_year, date.get_month, date.get_day]
3469
- end
3470
-
3471
- it "has a working function #test_def_error_quark" do
3472
- quark = Regress.test_def_error_quark
3473
- _(GLib.quark_to_string(quark)).must_equal "regress-test-def-error"
3474
- end
3475
-
3476
- it "has a working function #test_double" do
3477
- r = Regress.test_double 5435.32
3478
- assert_equal 5435.32, r
3479
- end
3480
-
3481
- it "has a working function #test_enum_param" do
3482
- r = Regress.test_enum_param :value3
3483
- assert_equal "value3", r
3484
- end
3485
-
3486
- it "has a working function #test_error_quark" do
3487
- quark = Regress.test_error_quark
3488
- _(GLib.quark_to_string(quark)).must_equal "regress-test-error"
3489
- end
3490
-
3491
- it "has a working function #test_filename_return" do
3492
- arr = Regress.test_filename_return
3493
- _(arr).must_be :==, ["åäö", "/etc/fstab"]
3494
- end
3495
-
3496
- it "has a working function #test_float" do
3497
- r = Regress.test_float 5435.32
3498
- assert_in_delta 5435.32, r, 0.001
3499
- end
3500
-
3501
- it "has a working function #test_garray_container_return" do
3502
- arr = Regress.test_garray_container_return
3503
- _(arr).must_be_instance_of GLib::PtrArray
3504
- _(arr.len).must_equal 1
3505
- _(arr.to_a).must_equal ["regress"]
3506
- end
3507
-
3508
- it "has a working function #test_garray_full_return" do
3509
- result = Regress.test_garray_full_return
3510
- _(result.to_a).must_equal ["regress"]
3511
- end
3512
-
3513
- it "has a working function #test_gerror_callback" do
3514
- result = nil
3515
- Regress.test_gerror_callback { |err| result = err.message }
3516
- _(result).must_equal "regression test error"
3517
- end
3518
-
3519
- it "has a working function #test_ghash_container_return" do
3520
- hash = Regress.test_ghash_container_return
3521
- _(hash).must_be_instance_of GLib::HashTable
3522
- _(hash.to_hash).must_equal("foo" => "bar",
3523
- "baz" => "bat",
3524
- "qux" => "quux")
3525
- end
3526
-
3527
- it "has a working function #test_ghash_everything_return" do
3528
- ghash = Regress.test_ghash_everything_return
3529
- _(ghash.to_hash).must_be :==, "foo" => "bar",
3530
- "baz" => "bat",
3531
- "qux" => "quux"
3532
- end
3533
-
3534
- it "has a working function #test_ghash_gvalue_in" do
3535
- hash_table = Regress.test_ghash_gvalue_return
3536
- Regress.test_ghash_gvalue_in hash_table
3537
- end
3538
-
3539
- it "has a working function #test_ghash_gvalue_return" do
3540
- result = Regress.test_ghash_gvalue_return
3541
- hash = result.to_hash
3542
-
3543
- has_enum_and_flag_keys = hash.key?("flags")
3544
-
3545
- _(hash["integer"].get_value).must_equal 12
3546
- _(hash["boolean"].get_value).must_equal true
3547
- _(hash["string"].get_value).must_equal "some text"
3548
- _(hash["strings"].get_value.to_a).must_equal %w(first second third)
3549
-
3550
- if has_enum_and_flag_keys
3551
- _(hash["flags"].get_value).must_equal flag1: true, flag3: true
3552
- _(hash["enum"].get_value).must_equal :value2
3553
- end
3554
-
3555
- expected_keys = if has_enum_and_flag_keys
3556
- %w(boolean enum flags integer string strings)
3557
- else
3558
- %w(boolean integer string strings)
3559
- end
3560
-
3561
- _(hash.keys.sort).must_equal expected_keys
3562
- end
3563
-
3564
- it "has a working function #test_ghash_nested_everything_return" do
3565
- result = Regress.test_ghash_nested_everything_return
3566
- hash = result.to_hash
3567
- _(hash.keys).must_equal ["wibble"]
3568
- _(hash["wibble"].to_hash).must_equal("foo" => "bar",
3569
- "baz" => "bat",
3570
- "qux" => "quux")
3571
- end
3572
-
3573
- it "has a working function #test_ghash_nested_everything_return2" do
3574
- result = Regress.test_ghash_nested_everything_return2
3575
- hash = result.to_hash
3576
- _(hash.keys).must_equal ["wibble"]
3577
- _(hash["wibble"].to_hash).must_equal("foo" => "bar",
3578
- "baz" => "bat",
3579
- "qux" => "quux")
3580
- end
3581
-
3582
- it "has a working function #test_ghash_nothing_in" do
3583
- Regress.test_ghash_nothing_in("foo" => "bar",
3584
- "baz" => "bat",
3585
- "qux" => "quux")
3586
- end
3587
-
3588
- it "has a working function #test_ghash_nothing_in2" do
3589
- Regress.test_ghash_nothing_in2("foo" => "bar",
3590
- "baz" => "bat",
3591
- "qux" => "quux")
3592
- end
3593
-
3594
- it "has a working function #test_ghash_nothing_return" do
3595
- ghash = Regress.test_ghash_nothing_return
3596
- _(ghash.to_hash).must_be :==, "foo" => "bar",
3597
- "baz" => "bat",
3598
- "qux" => "quux"
3599
- end
3600
-
3601
- it "has a working function #test_ghash_nothing_return2" do
3602
- ghash = Regress.test_ghash_nothing_return2
3603
- _(ghash.to_hash).must_be :==, "foo" => "bar",
3604
- "baz" => "bat",
3605
- "qux" => "quux"
3606
- end
3607
-
3608
- it "has a working function #test_ghash_null_in" do
3609
- Regress.test_ghash_null_in(nil)
3610
- end
3611
-
3612
- it "has a working function #test_ghash_null_out" do
3613
- ghash = Regress.test_ghash_null_out
3614
- _(ghash).must_be_nil
3615
- end
3616
-
3617
- it "has a working function #test_ghash_null_return" do
3618
- ghash = Regress.test_ghash_null_return
3619
- _(ghash).must_be_nil
3620
- end
3621
-
3622
- it "has a working function #test_glist_container_return" do
3623
- list = Regress.test_glist_container_return
3624
- assert_instance_of GLib::List, list
3625
- _(list).must_be :==, %w(1 2 3)
3626
- end
3627
-
3628
- it "has a working function #test_glist_everything_return" do
3629
- list = Regress.test_glist_everything_return
3630
- _(list).must_be :==, %w(1 2 3)
3631
- end
3632
-
3633
- it "has a working function #test_glist_gtype_container_in" do
3634
- Regress.test_glist_gtype_container_in [Regress::TestObj.gtype, Regress::TestSubObj.gtype]
3635
- pass
3636
- end
3637
-
3638
- it "has a working function #test_glist_nothing_in" do
3639
- Regress.test_glist_nothing_in %w(1 2 3)
3640
- pass
3641
- end
3642
-
3643
- it "has a working function #test_glist_nothing_in2" do
3644
- Regress.test_glist_nothing_in2 %w(1 2 3)
3645
- pass
3646
- end
3647
-
3648
- it "has a working function #test_glist_nothing_return" do
3649
- list = Regress.test_glist_nothing_return
3650
- _(list).must_be :==, %w(1 2 3)
3651
- end
3652
-
3653
- it "has a working function #test_glist_nothing_return2" do
3654
- list = Regress.test_glist_nothing_return2
3655
- _(list).must_be :==, %w(1 2 3)
3656
- end
3657
-
3658
- it "has a working function #test_glist_null_in" do
3659
- Regress.test_glist_null_in nil
3660
- pass
3661
- end
3662
-
3663
- it "has a working function #test_glist_null_out" do
3664
- result = Regress.test_glist_null_out
3665
- _(result).must_be_nil
3666
- end
3667
-
3668
- it "has a working function #test_gslist_container_return" do
3669
- slist = Regress.test_gslist_container_return
3670
- assert_instance_of GLib::SList, slist
3671
- _(slist).must_be :==, %w(1 2 3)
3672
- end
3673
-
3674
- it "has a working function #test_gslist_everything_return" do
3675
- slist = Regress.test_gslist_everything_return
3676
- _(slist).must_be :==, %w(1 2 3)
3677
- end
3678
-
3679
- it "has a working function #test_gslist_nothing_in" do
3680
- Regress.test_gslist_nothing_in %w(1 2 3)
3681
- pass
3682
- end
3683
-
3684
- it "has a working function #test_gslist_nothing_in2" do
3685
- Regress.test_gslist_nothing_in2 %w(1 2 3)
3686
- pass
3687
- end
3688
-
3689
- it "has a working function #test_gslist_nothing_return" do
3690
- slist = Regress.test_gslist_nothing_return
3691
- _(slist).must_be :==, %w(1 2 3)
3692
- end
3693
-
3694
- it "has a working function #test_gslist_nothing_return2" do
3695
- slist = Regress.test_gslist_nothing_return2
3696
- _(slist).must_be :==, %w(1 2 3)
3697
- end
3698
-
3699
- it "has a working function #test_gslist_null_in" do
3700
- Regress.test_gslist_null_in nil
3701
- pass
3702
- end
3703
-
3704
- it "has a working function #test_gslist_null_out" do
3705
- result = Regress.test_gslist_null_out
3706
- _(result).must_be_nil
3707
- end
3708
-
3709
- it "has a working function #test_gtype" do
3710
- result = Regress.test_gtype 23
3711
- assert_equal 23, result
3712
- end
3713
-
3714
- it "has a working function #test_gvariant_as" do
3715
- _(Regress.test_gvariant_as.get_strv.to_a).must_equal %w(one two three)
3716
- end
3717
-
3718
- it "has a working function #test_gvariant_asv" do
3719
- result = Regress.test_gvariant_asv
3720
- _(result.n_children).must_equal 2
3721
- _(result.lookup_value("name").get_string).must_equal "foo"
3722
- _(result.lookup_value("timeout").get_int32).must_equal 10
3723
- end
3724
-
3725
- it "has a working function #test_gvariant_i" do
3726
- _(Regress.test_gvariant_i.get_int32).must_equal 1
3727
- end
3728
-
3729
- it "has a working function #test_gvariant_s" do
3730
- _(Regress.test_gvariant_s.get_string).must_equal "one"
3731
- end
3732
-
3733
- it "has a working function #test_gvariant_v" do
3734
- _(Regress.test_gvariant_v.get_variant.get_string).must_equal "contents"
3735
- end
3736
-
3737
- it "has a working function #test_hash_table_callback" do
3738
- value = nil
3739
- Regress.test_hash_table_callback("foo" => 42) { |hash| value = hash }
3740
- _(value.to_hash).must_equal("foo" => 42)
3741
- end
3742
-
3743
- it "has a working function #test_int" do
3744
- result = Regress.test_int 23
3745
- assert_equal 23, result
3746
- end
3747
-
3748
- it "has a working function #test_int16" do
3749
- result = Regress.test_int16 23
3750
- assert_equal 23, result
3751
- end
3752
-
3753
- it "has a working function #test_int32" do
3754
- result = Regress.test_int32 23
3755
- assert_equal 23, result
3756
- end
3757
-
3758
- it "has a working function #test_int64" do
3759
- result = Regress.test_int64 2_300_000_000_000
3760
- assert_equal 2_300_000_000_000, result
3761
- end
3762
-
3763
- it "has a working function #test_int8" do
3764
- result = Regress.test_int8 23
3765
- assert_equal 23, result
3766
- end
3767
-
3768
- it "has a working function #test_int_out_utf8" do
3769
- len = Regress.test_int_out_utf8 "How long?"
3770
- assert_equal 9, len
3771
- end
3772
-
3773
- it "has a working function #test_int_value_arg" do
3774
- gv = GObject::Value.new
3775
- gv.init GObject.type_from_name "gint"
3776
- gv.set_int 343
3777
- result = Regress.test_int_value_arg gv
3778
- assert_equal 343, result
3779
- end
3780
-
3781
- it "has a working function #test_long" do
3782
- long_val = FFI.type_size(:long) == 8 ? 2_300_000_000_000 : 2_000_000_000
3783
- result = Regress.test_long long_val
3784
- assert_equal long_val, result
3785
- end
3786
-
3787
- it "has a working function #test_multi_callback" do
3788
- a = 1
3789
- result = Regress.test_multi_callback do
3790
- a += 1
3791
- 23
3792
- end
3793
- assert_equal 2 * 23, result
3794
- assert_equal 3, a
3795
- end
3796
-
3797
- it "has a working function #test_multi_double_args" do
3798
- one, two = Regress.test_multi_double_args 23.1
3799
- assert_equal 2 * 23.1, one
3800
- assert_equal 3 * 23.1, two
3801
- end
3802
-
3803
- it "has a working function #test_multiline_doc_comments" do
3804
- _(Regress.test_multiline_doc_comments).must_be_nil
3805
- end
3806
-
3807
- it "has a working function #test_nested_parameter" do
3808
- _(Regress.test_nested_parameter(3)).must_be_nil
3809
- end
3810
-
3811
- it "has a working function #test_noptr_callback" do
3812
- skip_below "1.47.1"
3813
- a = 0
3814
- Regress.test_noptr_callback { a = 1 }
3815
- _(a).must_equal 1
3816
- end
3817
-
3818
- it "has a working function #test_null_gerror_callback" do
3819
- value = nil
3820
- Regress.test_owned_gerror_callback { |err| value = err }
3821
- _(value.message).must_equal "regression test owned error"
3822
- end
3823
-
3824
- it "has a working function #test_null_strv_in_gvalue" do
3825
- skip_below "1.53.1"
3826
- result = Regress.test_null_strv_in_gvalue
3827
- _(result.to_a).must_be :empty?
3828
- end
3829
-
3830
- it "has a working function #test_owned_gerror_callback" do
3831
- value = nil
3832
- Regress.test_owned_gerror_callback { |err| value = err }
3833
- _(value.message).must_equal "regression test owned error"
3834
- end
3835
-
3836
- it "has a working function #test_return_allow_none" do
3837
- skip_below "1.47.1"
3838
- result = Regress.test_return_allow_none
3839
- _(result).must_be_nil
3840
- end
3841
-
3842
- it "has a working function #test_return_nullable" do
3843
- skip_below "1.47.1"
3844
- result = Regress.test_return_nullable
3845
- _(result).must_be_nil
3846
- end
3847
-
3848
- it "has a working function #test_short" do
3849
- result = Regress.test_short 23
3850
- assert_equal 23, result
3851
- end
3852
-
3853
- it "has a working function #test_simple_boxed_a_const_return" do
3854
- result = Regress.test_simple_boxed_a_const_return
3855
- assert_equal [5, 6, 7.0], [result.some_int, result.some_int8, result.some_double]
3856
- end
3857
-
3858
- it "has a working function #test_simple_callback" do
3859
- a = 0
3860
- Regress.test_simple_callback { a = 1 }
3861
- assert_equal 1, a
3862
- end
3863
-
3864
- it "has a working function #test_size" do
3865
- assert_equal 2354, Regress.test_size(2354)
3866
- end
3867
-
3868
- it "has a working function #test_ssize" do
3869
- assert_equal(-2_000_000, Regress.test_ssize(-2_000_000))
3870
- end
3871
-
3872
- it "has a working function #test_struct_a_parse" do
3873
- a = Regress.test_struct_a_parse("this string is actually ignored")
3874
- _(a).must_be_instance_of Regress::TestStructA
3875
- _(a.some_int).must_equal 23
3876
- end
3877
-
3878
- it "has a working function #test_strv_in" do
3879
- assert_equal true, Regress.test_strv_in(%w(1 2 3))
3880
- end
3881
-
3882
- it "has a working function #test_strv_in_gvalue" do
3883
- arr = Regress.test_strv_in_gvalue
3884
- _(arr).must_be :==, %w(one two three)
3885
- end
3886
-
3887
- it "has a working function #test_strv_out" do
3888
- arr = Regress.test_strv_out
3889
- _(arr).must_be :==, %w(thanks for all the fish)
3890
- end
3891
-
3892
- it "has a working function #test_strv_out_c" do
3893
- arr = Regress.test_strv_out_c
3894
- _(arr).must_be :==, %w(thanks for all the fish)
3895
- end
3896
-
3897
- it "has a working function #test_strv_out_container" do
3898
- arr = Regress.test_strv_out_container
3899
- _(arr).must_be :==, %w(1 2 3)
3900
- end
3901
-
3902
- it "has a working function #test_strv_outarg" do
3903
- arr = Regress.test_strv_outarg
3904
- _(arr).must_be :==, %w(1 2 3)
3905
- end
3906
-
3907
- it "has a working function #test_timet" do
3908
- # Time rounded to seconds.
3909
- t = Time.at(Time.now.to_i)
3910
- result = Regress.test_timet(t.to_i)
3911
- assert_equal t, Time.at(result)
3912
- end
3913
-
3914
- it "has a working function #test_torture_signature_0" do
3915
- y, z, q = Regress.test_torture_signature_0 86, "foo", 2
3916
- assert_equal [86, 2 * 86, 3 + 2], [y, z, q]
3917
- end
3918
-
3919
- it "has a working function #test_torture_signature_1" do
3920
- ret, y, z, q = Regress.test_torture_signature_1(-21, "hello", 12)
3921
- _([ret, y, z, q]).must_equal [true, -21, 2 * -21, "hello".length + 12]
3922
-
3923
- _(proc { Regress.test_torture_signature_1(-21, "hello", 11) }).
3924
- must_raise GirFFI::GLibError
3925
- end
3926
-
3927
- it "has a working function #test_torture_signature_2" do
3928
- a = 1
3929
- y, z, q = Regress.test_torture_signature_2 244, "foofoo", 31 do |u|
3930
- a = u
3931
- end
3932
- assert_equal [244, 2 * 244, 6 + 31], [y, z, q]
3933
- _(a).must_be_instance_of Regress::TestCallbackUserData
3934
- end
3935
-
3936
- it "has a working function #test_uint" do
3937
- assert_equal 31, Regress.test_uint(31)
3938
- end
3939
-
3940
- it "has a working function #test_uint16" do
3941
- assert_equal 31, Regress.test_uint16(31)
3942
- end
3943
-
3944
- it "has a working function #test_uint32" do
3945
- assert_equal 540_000, Regress.test_uint32(540_000)
3946
- end
3947
-
3948
- it "has a working function #test_uint64" do
3949
- assert_equal 54_000_000_000_000, Regress.test_uint64(54_000_000_000_000)
3950
- end
3951
-
3952
- it "has a working function #test_uint8" do
3953
- assert_equal 31, Regress.test_uint8(31)
3954
- end
3955
-
3956
- it "has a working function #test_ulong" do
3957
- assert_equal 54_000_000_000_000, Regress.test_uint64(54_000_000_000_000)
3958
- end
3959
-
3960
- it "has a working function #test_unconventional_error_quark" do
3961
- result = Regress.test_unconventional_error_quark
3962
- _(GLib.quark_to_string(result)).must_equal "regress-test-other-error"
3963
- end
3964
-
3965
- it "has a working function #test_unichar" do
3966
- assert_equal 120, Regress.test_unichar(120)
3967
- assert_equal 540_000, Regress.test_unichar(540_000)
3968
- end
3969
-
3970
- it "has a working function #test_unsigned_enum_param" do
3971
- assert_equal "value1", Regress.test_unsigned_enum_param(:value1)
3972
- assert_equal "value2", Regress.test_unsigned_enum_param(:value2)
3973
- end
3974
-
3975
- it "has a working function #test_ushort" do
3976
- assert_equal 54_000_000, Regress.test_uint64(54_000_000)
3977
- end
3978
-
3979
- it "has a working function #test_utf8_const_in" do
3980
- Regress.test_utf8_const_in("const \xe2\x99\xa5 utf8")
3981
- pass
3982
- end
3983
-
3984
- it "has a working function #test_utf8_const_return" do
3985
- result = Regress.test_utf8_const_return
3986
- assert_equal "const \xe2\x99\xa5 utf8", result
3987
- end
3988
-
3989
- it "has a working function #test_utf8_inout" do
3990
- result = Regress.test_utf8_inout "const \xe2\x99\xa5 utf8"
3991
- assert_equal "nonconst \xe2\x99\xa5 utf8", result
3992
- end
3993
-
3994
- it "has a working function #test_utf8_nonconst_return" do
3995
- result = Regress.test_utf8_nonconst_return
3996
- assert_equal "nonconst \xe2\x99\xa5 utf8", result
3997
- end
3998
-
3999
- it "has a working function #test_utf8_null_in" do
4000
- Regress.test_utf8_null_in nil
4001
- pass
4002
- end
4003
-
4004
- it "has a working function #test_utf8_null_out" do
4005
- _(Regress.test_utf8_null_out).must_be_nil
4006
- end
4007
-
4008
- it "has a working function #test_utf8_out" do
4009
- result = Regress.test_utf8_out
4010
- assert_equal "nonconst \xe2\x99\xa5 utf8", result
4011
- end
4012
-
4013
- it "has a working function #test_utf8_out_nonconst_return" do
4014
- r, out = Regress.test_utf8_out_nonconst_return
4015
- assert_equal %w(first second), [r, out]
4016
- end
4017
-
4018
- it "has a working function #test_utf8_out_out" do
4019
- out0, out1 = Regress.test_utf8_out_nonconst_return
4020
- assert_equal %w(first second), [out0, out1]
4021
- end
4022
-
4023
- it "has a working function #test_value_return" do
4024
- result = Regress.test_value_return 3423
4025
- _(result).must_equal 3423
4026
- end
4027
-
4028
- it "has a working function #test_versioning" do
4029
- # TODO: Handle deprecation
4030
- Regress.test_versioning
4031
- pass
4032
- end
4033
-
4034
- it "raises an appropriate NoMethodError when a function is not found" do
4035
- result = _(proc { Regress.this_method_does_not_exist }).must_raise(NoMethodError)
4036
- _(result.message).must_match(/^undefined method `this_method_does_not_exist' (for Regress:Module|on Regress \(Module\))$/)
4037
- end
4038
- end