gir_ffi 0.14.1 → 0.15.4

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