gir_ffi 0.15.3 → 0.15.4

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