gir_ffi 0.14.1 → 0.15.4

Sign up to get free protection for your applications and to get access to all the features.
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,2995 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require 'gir_ffi_test_helper'
4
-
5
- require 'gir_ffi'
6
-
7
- GirFFI.setup :GIMarshallingTests
8
-
9
- # Tests generated methods and functions in the GIMarshallingTests namespace.
10
- describe GIMarshallingTests do
11
- let(:derived_klass) do
12
- Object.const_set("DerivedClass#{Sequence.next}",
13
- Class.new(GIMarshallingTests::Object))
14
- end
15
-
16
- def make_derived_instance
17
- GirFFI.define_type derived_klass do |info|
18
- yield info if block_given?
19
- end
20
- derived_klass.new
21
- end
22
-
23
- describe 'GIMarshallingTests::BoxedStruct' do
24
- let(:instance) { GIMarshallingTests::BoxedStruct.new }
25
-
26
- it 'has a writable field long_' do
27
- instance.long_ = 42
28
- assert_equal 42, instance.long_
29
- instance.long_ = 43
30
- assert_equal 43, instance.long_
31
- end
32
-
33
- it 'has a writable field string_' do
34
- skip unless get_field_introspection_data('GIMarshallingTests', 'BoxedStruct', 'string_')
35
- instance.string_ = 'foobar'
36
- instance.string_.must_equal 'foobar'
37
- end
38
-
39
- it 'has a writable field g_strv' do
40
- instance.g_strv.must_be :==, []
41
- instance.g_strv = %w(foo bar)
42
- instance.g_strv.must_be :==, %w(foo bar)
43
- end
44
-
45
- it 'creates an instance using #new' do
46
- bx = GIMarshallingTests::BoxedStruct.new
47
- assert_instance_of GIMarshallingTests::BoxedStruct, bx
48
- bx.struct.must_be :owned?
49
- end
50
-
51
- it 'has a working method #inv' do
52
- instance.long_ = 42
53
- instance.inv
54
- pass
55
- end
56
-
57
- it 'has a working function #inout' do
58
- bx = GIMarshallingTests::BoxedStruct.new
59
- bx.long_ = 42
60
- bx.struct.must_be :owned?
61
-
62
- res = GIMarshallingTests::BoxedStruct.inout bx
63
- bx.struct.must_be :owned?
64
- res.struct.must_be :owned?
65
-
66
- assert_equal 0, res.long_
67
- end
68
-
69
- it 'has a working function #out' do
70
- res = GIMarshallingTests::BoxedStruct.out
71
- res.struct.must_be :owned?
72
- assert_equal 42, res.long_
73
- end
74
-
75
- it 'has a working function #returnv' do
76
- res = GIMarshallingTests::BoxedStruct.returnv
77
- res.struct.must_be :owned?
78
- assert_equal 42, res.long_
79
- res.g_strv.must_be :==, %w(0 1 2)
80
- end
81
- end
82
-
83
- it 'has the constant CONSTANT_GERROR_CODE' do
84
- assert_equal 5, GIMarshallingTests::CONSTANT_GERROR_CODE
85
- end
86
-
87
- it 'has the constant CONSTANT_GERROR_DEBUG_MESSAGE' do
88
- GIMarshallingTests::CONSTANT_GERROR_DEBUG_MESSAGE.must_equal(
89
- 'we got an error, life is shit')
90
- end
91
-
92
- it 'has the constant CONSTANT_GERROR_DOMAIN' do
93
- assert_equal 'gi-marshalling-tests-gerror-domain',
94
- GIMarshallingTests::CONSTANT_GERROR_DOMAIN
95
- end
96
-
97
- it 'has the constant CONSTANT_GERROR_MESSAGE' do
98
- assert_equal 'gi-marshalling-tests-gerror-message',
99
- GIMarshallingTests::CONSTANT_GERROR_MESSAGE
100
- end
101
-
102
- it 'has the constant CONSTANT_NUMBER' do
103
- assert_equal 42, GIMarshallingTests::CONSTANT_NUMBER
104
- end
105
-
106
- it 'has the constant CONSTANT_UTF8' do
107
- assert_equal 'const ♥ utf8', GIMarshallingTests::CONSTANT_UTF8
108
- end
109
-
110
- describe 'GIMarshallingTests::Enum' do
111
- it 'has the member :value1' do
112
- assert_equal 0, GIMarshallingTests::Enum[:value1]
113
- end
114
-
115
- it 'has the member :value2' do
116
- assert_equal 1, GIMarshallingTests::Enum[:value2]
117
- end
118
-
119
- it 'has the member :value3' do
120
- assert_equal 42, GIMarshallingTests::Enum[:value3]
121
- end
122
- end
123
-
124
- describe 'GIMarshallingTests::Flags' do
125
- it 'has the member :value1' do
126
- assert_equal 1, GIMarshallingTests::Flags[:value1]
127
- end
128
-
129
- it 'has the member :value2' do
130
- assert_equal 2, GIMarshallingTests::Flags[:value2]
131
- end
132
-
133
- it 'has the member :value3' do
134
- assert_equal 4, GIMarshallingTests::Flags[:value3]
135
- end
136
-
137
- it 'has the member :mask' do
138
- assert_equal 3, GIMarshallingTests::Flags[:mask]
139
- end
140
-
141
- it 'has the member :mask2' do
142
- assert_equal 3, GIMarshallingTests::Flags[:mask2]
143
- end
144
-
145
- it 'has a working function #in' do
146
- GIMarshallingTests::Flags.in value2: true
147
- end
148
-
149
- it 'has a working function #in_zero' do
150
- GIMarshallingTests::Flags.in_zero 0
151
- end
152
-
153
- it 'has a working function #inout' do
154
- result = GIMarshallingTests::Flags.inout value2: true
155
- result.must_equal(value1: true)
156
- end
157
-
158
- it 'has a working function #out' do
159
- result = GIMarshallingTests::Flags.out
160
- result.must_equal(value2: true)
161
- end
162
-
163
- it 'has a working function #returnv' do
164
- result = GIMarshallingTests::Flags.returnv
165
- result.must_equal(value2: true)
166
- end
167
- end
168
-
169
- describe 'GIMarshallingTests::GEnum' do
170
- it 'has the member :value1' do
171
- assert_equal 0, GIMarshallingTests::GEnum[:value1]
172
- end
173
-
174
- it 'has the member :value2' do
175
- assert_equal 1, GIMarshallingTests::GEnum[:value2]
176
- end
177
-
178
- it 'has the member :value3' do
179
- assert_equal 42, GIMarshallingTests::GEnum[:value3]
180
- end
181
-
182
- it 'has a working function #in' do
183
- GIMarshallingTests::GEnum.in :value3
184
- end
185
-
186
- it 'has a working function #inout' do
187
- result = GIMarshallingTests::GEnum.inout :value3
188
- result.must_equal :value1
189
- end
190
-
191
- it 'has a working function #out' do
192
- result = GIMarshallingTests::GEnum.out
193
- result.must_equal :value3
194
- end
195
-
196
- it 'has a working function #returnv' do
197
- result = GIMarshallingTests::GEnum.returnv
198
- result.must_equal :value3
199
- end
200
- end
201
-
202
- describe 'GIMarshallingTests::Interface' do
203
- it 'has a working method #test_int8_in' do
204
- derived_klass.class_eval { include GIMarshallingTests::Interface }
205
- derived_instance = make_derived_instance do |info|
206
- info.install_vfunc_implementation :test_int8_in, proc { |obj, in_| obj.int = in_ }
207
- end
208
- derived_instance.test_int8_in 8
209
- derived_instance.int.must_equal 8
210
- end
211
- end
212
-
213
- describe 'GIMarshallingTests::Interface2' do
214
- it 'must be tested for clashes with Interface' do
215
- skip 'Needs more work to determine desired behavior'
216
- end
217
- end
218
-
219
- describe 'GIMarshallingTests::Interface3' do
220
- it 'has a working method #test_variant_array_in' do
221
- skip unless get_introspection_data 'GIMarshallingTests', 'Interface3'
222
- derived_klass.class_eval { include GIMarshallingTests::Interface3 }
223
- derived_instance = make_derived_instance do |info|
224
- info.install_vfunc_implementation :test_variant_array_in, proc { |obj, in_|
225
- obj.int = in_.to_a.first.get_byte
226
- }
227
- end
228
- derived_instance.test_variant_array_in [GLib::Variant.new_byte(42)]
229
- derived_instance.int.must_equal 42
230
- end
231
- end
232
-
233
- describe 'GIMarshallingTests::InterfaceImpl' do
234
- before do
235
- skip unless get_introspection_data 'GIMarshallingTests', 'InterfaceImpl'
236
- end
237
-
238
- it 'has a working method #get_as_interface' do
239
- obj = GIMarshallingTests::InterfaceImpl.new []
240
- result = obj.get_as_interface
241
- result.must_be_kind_of GIMarshallingTests::Interface
242
- end
243
- end
244
-
245
- describe 'GIMarshallingTests::NestedStruct' do
246
- let(:instance) { GIMarshallingTests::NestedStruct.new }
247
- it 'has a writable field simple_struct' do
248
- assert_instance_of GIMarshallingTests::SimpleStruct,
249
- instance.simple_struct
250
- new_struct = GIMarshallingTests::SimpleStruct.new
251
- new_struct.int8 = 42
252
- instance.simple_struct = new_struct
253
- instance.simple_struct.int8.must_equal 42
254
- end
255
- end
256
-
257
- describe 'GIMarshallingTests::NoTypeFlags' do
258
- it 'has the member :value1' do
259
- assert_equal 1, GIMarshallingTests::NoTypeFlags[:value1]
260
- end
261
- it 'has the member :value2' do
262
- assert_equal 2, GIMarshallingTests::NoTypeFlags[:value2]
263
- end
264
- it 'has the member :value3' do
265
- assert_equal 4, GIMarshallingTests::NoTypeFlags[:value3]
266
- end
267
- it 'has the member :mask' do
268
- assert_equal 3, GIMarshallingTests::NoTypeFlags[:mask]
269
- end
270
- it 'has the member :mask2' do
271
- assert_equal 3, GIMarshallingTests::NoTypeFlags[:mask2]
272
- end
273
- end
274
-
275
- describe 'GIMarshallingTests::NotSimpleStruct' do
276
- let(:instance) { GIMarshallingTests::NotSimpleStruct.new }
277
-
278
- it 'has a writable field pointer' do
279
- instance.pointer.must_be_nil
280
- nested = GIMarshallingTests::NestedStruct.new
281
- nested.simple_struct.int8 = 23
282
- instance.pointer = nested
283
- instance.pointer.simple_struct.int8.must_equal 23
284
- end
285
- end
286
-
287
- it 'has the constant OVERRIDES_CONSTANT' do
288
- assert_equal 42, GIMarshallingTests::OVERRIDES_CONSTANT
289
- end
290
-
291
- describe 'GIMarshallingTests::Object' do
292
- it 'creates an instance using #new' do
293
- ob = GIMarshallingTests::Object.new 42
294
- assert_instance_of GIMarshallingTests::Object, ob
295
- assert_equal 42, ob.int
296
- end
297
-
298
- it 'fails to create an instance using #new_fail' do
299
- skip unless get_method_introspection_data('GIMarshallingTests', 'Object', 'new_fail')
300
- proc { GIMarshallingTests::Object.new_fail 42 }.must_raise GirFFI::GLibError
301
- end
302
-
303
- it 'has a working function #full_inout' do
304
- ob = GIMarshallingTests::Object.new 42
305
- object_ref_count(ob).must_equal 1
306
-
307
- res = GIMarshallingTests::Object.full_inout ob
308
-
309
- object_ref_count(ob).must_equal 1
310
- object_ref_count(res).must_equal 1
311
-
312
- res.must_be_instance_of GIMarshallingTests::Object
313
- res.int.must_equal 0
314
- end
315
-
316
- it 'has a working function #full_out' do
317
- res = GIMarshallingTests::Object.full_out
318
- res.must_be_instance_of GIMarshallingTests::Object
319
- object_ref_count(res).must_equal 1
320
- end
321
-
322
- it 'has a working function #full_return' do
323
- res = GIMarshallingTests::Object.full_return
324
- res.must_be_instance_of GIMarshallingTests::Object
325
- object_ref_count(res).must_equal 1
326
- end
327
-
328
- it 'has a working function #none_inout' do
329
- ob = GIMarshallingTests::Object.new 42
330
- object_ref_count(ob).must_equal 1
331
-
332
- res = GIMarshallingTests::Object.none_inout ob
333
-
334
- object_ref_count(ob).must_equal 1
335
- object_ref_count(res).must_equal 2
336
-
337
- res.must_be_instance_of GIMarshallingTests::Object
338
- ob.int.must_equal 42
339
- res.int.must_equal 0
340
- end
341
-
342
- it 'has a working function #none_out' do
343
- res = GIMarshallingTests::Object.none_out
344
- res.must_be_instance_of GIMarshallingTests::Object
345
- object_ref_count(res).must_equal 2
346
- end
347
-
348
- it 'has a working function #none_return' do
349
- res = GIMarshallingTests::Object.none_return
350
- res.must_be_instance_of GIMarshallingTests::Object
351
- object_ref_count(res).must_equal 2
352
- end
353
-
354
- it 'has a working function #static_method' do
355
- GIMarshallingTests::Object.static_method
356
- pass
357
- end
358
-
359
- let(:instance) { GIMarshallingTests::Object.new 42 }
360
-
361
- it 'has a working method #call_vfunc_with_callback' do
362
- skip unless get_method_introspection_data('GIMarshallingTests', 'Object',
363
- 'call_vfunc_with_callback')
364
- cb = nil
365
- user_data = nil
366
- result = nil
367
-
368
- derived_instance = make_derived_instance do |info|
369
- info.install_vfunc_implementation :vfunc_with_callback, proc { |_obj, callback, callback_data|
370
- cb = callback
371
- user_data = callback_data.address
372
- result = callback.call(42, callback_data)
373
- }
374
- end
375
- derived_instance.call_vfunc_with_callback
376
-
377
- user_data.must_equal 0xdeadbeef
378
- # TODO: Change implementation of CallbackBase so that this becomes an
379
- # instance of GIMarshallingTests::CallbackIntInt
380
- cb.must_be_instance_of FFI::Function
381
- result.must_equal 42
382
- end
383
-
384
- it 'has a working method #full_in' do
385
- skip 'This function is defined in the header but not implemented'
386
- end
387
-
388
- it 'has a working method #get_ref_info_for_vfunc_in_object_transfer_full' do
389
- skip unless get_vfunc_introspection_data('GIMarshallingTests', 'Object',
390
- 'vfunc_in_object_transfer_full')
391
- obj = nil
392
- derived_instance = make_derived_instance do |info|
393
- info.install_vfunc_implementation :vfunc_in_object_transfer_full, proc { |_this, object|
394
- obj = object
395
- }
396
- end
397
- result = derived_instance.
398
- get_ref_info_for_vfunc_in_object_transfer_full GIMarshallingTests::Object.gtype
399
- result.must_equal [1, false]
400
- obj.must_be_instance_of GIMarshallingTests::Object
401
- end
402
-
403
- it 'has a working method #get_ref_info_for_vfunc_in_object_transfer_none' do
404
- skip unless get_vfunc_introspection_data('GIMarshallingTests', 'Object',
405
- 'vfunc_in_object_transfer_none')
406
- obj = nil
407
- derived_instance = make_derived_instance do |info|
408
- info.install_vfunc_implementation :vfunc_in_object_transfer_none, proc { |_this, object|
409
- obj = object
410
- }
411
- end
412
- result = derived_instance.
413
- get_ref_info_for_vfunc_in_object_transfer_none GIMarshallingTests::Object.gtype
414
- object_ref_count(obj).must_be :>, 0
415
- result.must_equal [2, false]
416
- obj.must_be_instance_of GIMarshallingTests::Object
417
- end
418
-
419
- it 'has a working method #get_ref_info_for_vfunc_out_object_transfer_full' do
420
- skip unless get_vfunc_introspection_data('GIMarshallingTests', 'Object',
421
- 'vfunc_out_object_transfer_full')
422
- obj = nil
423
- derived_instance = make_derived_instance do |info|
424
- info.install_vfunc_implementation :vfunc_out_object_transfer_full, proc { |_obj|
425
- obj = GIMarshallingTests::Object.new(42)
426
- }
427
- end
428
- result = derived_instance.get_ref_info_for_vfunc_out_object_transfer_full
429
- object_ref_count(obj).must_be :>, 0
430
- # TODO: Check desired result
431
- result.must_equal [2, false]
432
- end
433
-
434
- it 'has a working method #get_ref_info_for_vfunc_out_object_transfer_none' do
435
- skip unless get_vfunc_introspection_data('GIMarshallingTests', 'Object',
436
- 'vfunc_out_object_transfer_none')
437
- derived_instance = make_derived_instance do |info|
438
- info.install_vfunc_implementation :vfunc_out_object_transfer_none, proc { |_obj|
439
- GIMarshallingTests::Object.new 42
440
- }
441
- end
442
- result = derived_instance.get_ref_info_for_vfunc_out_object_transfer_none
443
- result.must_equal [1, false]
444
- end
445
-
446
- it 'has a working method #get_ref_info_for_vfunc_return_object_transfer_full' do
447
- skip unless get_vfunc_introspection_data('GIMarshallingTests', 'Object',
448
- 'vfunc_return_object_transfer_full')
449
- derived_instance = make_derived_instance do |info|
450
- info.install_vfunc_implementation :vfunc_return_object_transfer_full, proc { |_obj|
451
- GIMarshallingTests::Object.new 42
452
- }
453
- end
454
- result = derived_instance.get_ref_info_for_vfunc_return_object_transfer_full
455
- result.must_equal [2, false]
456
- end
457
-
458
- it 'has a working method #get_ref_info_for_vfunc_return_object_transfer_none' do
459
- skip unless get_vfunc_introspection_data('GIMarshallingTests', 'Object',
460
- 'vfunc_return_object_transfer_none')
461
- derived_instance = make_derived_instance do |info|
462
- info.install_vfunc_implementation :vfunc_return_object_transfer_none, proc { |_obj|
463
- GIMarshallingTests::Object.new 42
464
- }
465
- end
466
- result = derived_instance.get_ref_info_for_vfunc_return_object_transfer_none
467
- result.must_equal [1, false]
468
- end
469
-
470
- it 'has a working method #int8_in' do
471
- derived_instance = make_derived_instance do |info|
472
- info.install_vfunc_implementation :method_int8_in, proc { |obj, in_| obj.int = in_ }
473
- end
474
- derived_instance.int8_in 23
475
- derived_instance.int.must_equal 23
476
- end
477
-
478
- it 'has a working method #int8_out' do
479
- # GLib minor version and GObjectIntrospection minor version should be in sync
480
- skip 'Introspection data is not generated correctly' if GLib::MINOR_VERSION < 42
481
-
482
- derived_instance = make_derived_instance do |info|
483
- info.install_vfunc_implementation :method_int8_out, proc { |_obj| 42 }
484
- end
485
-
486
- derived_instance.int8_out.must_equal 42
487
- end
488
-
489
- it 'has a working method #method' do
490
- instance.method
491
- pass
492
- end
493
-
494
- it 'has a working method #method_array_in' do
495
- instance.method_array_in [-1, 0, 1, 2]
496
- pass
497
- end
498
-
499
- it 'has a working method #method_array_inout' do
500
- res = instance.method_array_inout [-1, 0, 1, 2]
501
- res.must_be :==, [-2, -1, 0, 1, 2]
502
- end
503
-
504
- it 'has a working method #method_array_out' do
505
- res = instance.method_array_out
506
- res.must_be :==, [-1, 0, 1, 2]
507
- end
508
-
509
- it 'has a working method #method_array_return' do
510
- res = instance.method_array_return
511
- res.must_be :==, [-1, 0, 1, 2]
512
- end
513
-
514
- it 'has a working method #method_int8_arg_and_out_callee' do
515
- skip unless get_method_introspection_data('GIMarshallingTests', 'Object',
516
- 'method_int8_arg_and_out_callee')
517
- derived_instance = make_derived_instance do |info|
518
- info.install_vfunc_implementation :method_int8_arg_and_out_callee, proc { |_obj, arg|
519
- 2 * arg
520
- }
521
- end
522
- result = derived_instance.method_int8_arg_and_out_callee 32
523
- result.must_equal 64
524
- end
525
-
526
- it 'has a working method #method_int8_arg_and_out_caller' do
527
- skip unless get_method_introspection_data('GIMarshallingTests', 'Object',
528
- 'method_int8_arg_and_out_caller')
529
- derived_instance = make_derived_instance do |info|
530
- info.install_vfunc_implementation :method_int8_arg_and_out_caller, proc { |_obj, arg|
531
- 2 * arg
532
- }
533
- end
534
- result = derived_instance.method_int8_arg_and_out_caller 32
535
- result.must_equal 64
536
- end
537
-
538
- it 'has a working method #method_int8_in' do
539
- derived_instance = make_derived_instance do |info|
540
- info.install_vfunc_implementation :method_int8_in, proc { |obj, in_| obj.int = in_ }
541
- end
542
- derived_instance.method_int8_in 108
543
- derived_instance.int.must_equal 108
544
- end
545
-
546
- it 'has a working method #method_int8_out' do
547
- derived_instance = make_derived_instance do |info|
548
- info.install_vfunc_implementation :method_int8_out, proc { |_obj| 42 }
549
- end
550
- derived_instance.method_int8_out.must_equal 42
551
- end
552
-
553
- it 'has a working method #method_str_arg_out_ret' do
554
- skip unless get_vfunc_introspection_data('GIMarshallingTests', 'Object',
555
- 'method_str_arg_out_ret')
556
- derived_instance = make_derived_instance do |info|
557
- info.install_vfunc_implementation :method_str_arg_out_ret, proc { |_obj, arg| [arg, 42] }
558
- end
559
- derived_instance.method_str_arg_out_ret('foo').must_equal ['foo', 42]
560
- end
561
-
562
- it 'has a working method #method_variant_array_in' do
563
- skip 'This function is defined in the header but not implemented'
564
- end
565
-
566
- it 'has a working method #method_with_default_implementation' do
567
- instance.method_with_default_implementation 104
568
- assert_equal 104, instance.int
569
- end
570
-
571
- it 'has a working method #none_in' do
572
- instance.none_in
573
- pass
574
- end
575
-
576
- it 'has a working method #overridden_method' do
577
- instance.set_property('int', 0)
578
- instance.overridden_method
579
- pass
580
- end
581
-
582
- it 'has a working method #vfunc_array_out_parameter' do
583
- skip unless get_vfunc_introspection_data('GIMarshallingTests', 'Object',
584
- 'vfunc_array_out_parameter')
585
- derived_instance = make_derived_instance do |info|
586
- info.install_vfunc_implementation :vfunc_array_out_parameter, proc { |_obj|
587
- [1.1, 2.2, 3.3]
588
- }
589
- end
590
- result = derived_instance.vfunc_array_out_parameter
591
- arr = result.to_a
592
- arr.length.must_equal 3
593
- arr[0].must_be_close_to 1.1
594
- arr[1].must_be_close_to 2.2
595
- arr[2].must_be_close_to 3.3
596
- end
597
-
598
- it 'has a working method #vfunc_caller_allocated_out_parameter' do
599
- skip unless get_vfunc_introspection_data('GIMarshallingTests', 'Object',
600
- 'vfunc_caller_allocated_out_parameter')
601
- derived_instance = make_derived_instance do |info|
602
- info.install_vfunc_implementation :vfunc_caller_allocated_out_parameter, proc { |_obj|
603
- 'Hello!'
604
- }
605
- end
606
- result = derived_instance.vfunc_caller_allocated_out_parameter
607
- result.must_equal 'Hello!'
608
- end
609
-
610
- it 'has a working method #vfunc_meth_with_error' do
611
- derived_instance = make_derived_instance do |info|
612
- info.install_vfunc_implementation :vfunc_meth_with_err, proc { |_object, x|
613
- raise 'This is not the answer!' unless x == 42
614
-
615
- true
616
- }
617
- end
618
- result = derived_instance.vfunc_meth_with_error 42
619
- result.must_equal true
620
-
621
- err = proc { derived_instance.vfunc_meth_with_error(21) }.
622
- must_raise GirFFI::GLibError
623
- err.message.must_equal 'This is not the answer!'
624
- err.domain.must_equal 'gir_ffi'
625
- err.code.must_equal 0
626
- end
627
-
628
- it 'has a working method #vfunc_multiple_out_parameters' do
629
- derived_instance = make_derived_instance do |info|
630
- info.install_vfunc_implementation(
631
- :vfunc_multiple_out_parameters,
632
- proc { |*_args| [42.1, -142.3] })
633
- end
634
- result = derived_instance.vfunc_multiple_out_parameters
635
- result[0].must_be_close_to 42.1
636
- result[1].must_be_close_to(-142.3)
637
- end
638
-
639
- it 'has a working method #vfunc_one_out_parameter' do
640
- derived_instance = make_derived_instance do |info|
641
- info.install_vfunc_implementation(
642
- :vfunc_one_out_parameter,
643
- proc { |*_args| 23.4 })
644
- end
645
- derived_instance.vfunc_one_out_parameter.
646
- must_be_within_epsilon 23.4
647
- end
648
-
649
- it 'has a working method #vfunc_out_enum' do
650
- skip unless get_vfunc_introspection_data('GIMarshallingTests', 'Object',
651
- 'vfunc_out_enum')
652
- derived_instance = make_derived_instance do |info|
653
- info.install_vfunc_implementation :vfunc_out_enum, proc { |_obj| :value2 }
654
- end
655
- derived_instance.vfunc_out_enum.must_equal :value2
656
- end
657
-
658
- it 'has a working method #vfunc_return_enum' do
659
- skip unless get_vfunc_introspection_data('GIMarshallingTests', 'Object',
660
- 'vfunc_return_enum')
661
- derived_instance = make_derived_instance do |info|
662
- info.install_vfunc_implementation :vfunc_return_enum, proc { |_obj| :value2 }
663
- end
664
- derived_instance.vfunc_return_enum.must_equal :value2
665
- end
666
-
667
- it 'has a working method #vfunc_return_value_and_multiple_out_parameters' do
668
- derived_instance = make_derived_instance do |info|
669
- info.install_vfunc_implementation(
670
- :vfunc_return_value_and_multiple_out_parameters,
671
- proc { |*_args| [42, -142, 3] })
672
- end
673
- derived_instance.vfunc_return_value_and_multiple_out_parameters.
674
- must_equal [42, -142, 3]
675
- end
676
-
677
- it 'has a working method #vfunc_return_value_and_one_out_parameter' do
678
- derived_instance = make_derived_instance do |info|
679
- info.install_vfunc_implementation(
680
- :vfunc_return_value_and_one_out_parameter,
681
- proc { |*_args| [42, -142] })
682
- end
683
- derived_instance.vfunc_return_value_and_one_out_parameter.
684
- must_equal [42, -142]
685
- end
686
-
687
- it 'has a working method #vfunc_return_value_only' do
688
- derived_instance = make_derived_instance do |info|
689
- info.install_vfunc_implementation :vfunc_return_value_only, proc { |_obj| 0x1234_5678 }
690
- end
691
- result = derived_instance.vfunc_return_value_only
692
- result.must_equal 0x1234_5678
693
- end
694
-
695
- it 'has a working method #vfunc_with_callback' do
696
- skip unless get_method_introspection_data('GIMarshallingTests', 'Object',
697
- 'vfunc_with_callback')
698
-
699
- result = 1
700
-
701
- derived_instance = make_derived_instance do |info|
702
- info.install_vfunc_implementation :vfunc_with_callback, proc { |_obj, callback, callback_data|
703
- callback.call(42, callback_data)
704
- }
705
- end
706
-
707
- derived_instance.vfunc_with_callback { |val, user_data| result = val + user_data }
708
-
709
- # The current implementation of the vfunc_with_callback method currently
710
- # doesn't actually call the virtual function vfunc_with_callback.
711
- result.must_equal 1
712
- result.wont_equal 42 + 23
713
- end
714
-
715
- describe "its 'int' property" do
716
- it 'can be retrieved with #get_property' do
717
- assert_equal 42, instance.get_property('int')
718
- end
719
- it 'can be retrieved with #int' do
720
- assert_equal 42, instance.int
721
- end
722
- it 'can be set with #set_property' do
723
- instance.set_property('int', 13)
724
- assert_equal 13, instance.get_property('int')
725
- end
726
- it 'can be set with #int=' do
727
- instance.int = 1
728
- assert_equal 1, instance.int
729
- end
730
- end
731
- end
732
-
733
- describe 'GIMarshallingTests::OverridesObject' do
734
- it 'creates an instance using #new' do
735
- ob = GIMarshallingTests::OverridesObject.new
736
- assert_instance_of GIMarshallingTests::OverridesObject, ob
737
- end
738
-
739
- it 'has a working function #returnv' do
740
- ob = GIMarshallingTests::OverridesObject.returnv
741
- assert_instance_of GIMarshallingTests::OverridesObject, ob
742
- end
743
-
744
- let(:instance) { GIMarshallingTests::OverridesObject.new }
745
-
746
- it 'has a working method #method' do
747
- result = instance.method
748
- result.must_equal 42
749
- end
750
-
751
- it 'does not have accessors for its parent instance' do
752
- instance.wont_respond_to :parent_instance
753
- instance.wont_respond_to :parent_instance=
754
- end
755
- end
756
-
757
- describe 'GIMarshallingTests::OverridesStruct' do
758
- let(:instance) { GIMarshallingTests::OverridesStruct.new }
759
-
760
- it 'has a writable field long_' do
761
- instance.long_ = 43
762
- instance.long_.must_equal 43
763
- end
764
-
765
- it 'creates an instance using #new' do
766
- ob = GIMarshallingTests::OverridesStruct.new
767
- assert_instance_of GIMarshallingTests::OverridesStruct, ob
768
- end
769
-
770
- it 'has a working method #method' do
771
- instance.method.must_equal 42
772
- end
773
-
774
- it 'has a working function #returnv' do
775
- ob = GIMarshallingTests::OverridesStruct.returnv
776
- assert_instance_of GIMarshallingTests::OverridesStruct, ob
777
- end
778
- end
779
-
780
- describe 'GIMarshallingTests::PointerStruct' do
781
- it 'creates an instance using #new' do
782
- ps = GIMarshallingTests::PointerStruct.new
783
- assert_instance_of GIMarshallingTests::PointerStruct, ps
784
- end
785
-
786
- let(:instance) { GIMarshallingTests::PointerStruct.new }
787
-
788
- it 'has a writable field long_' do
789
- assert_equal 0, instance.long_
790
- instance.long_ = 1056
791
- assert_equal 1056, instance.long_
792
- end
793
-
794
- it 'has a working method #inv' do
795
- instance.long_ = 42
796
- instance.inv
797
- pass
798
- end
799
-
800
- it 'has a working function #returnv' do
801
- ob = GIMarshallingTests::PointerStruct.returnv
802
- assert_instance_of GIMarshallingTests::PointerStruct, ob
803
- end
804
- end
805
-
806
- describe 'GIMarshallingTests::PropertiesObject' do
807
- it 'creates an instance using #new' do
808
- ob = GIMarshallingTests::PropertiesObject.new
809
- assert_instance_of GIMarshallingTests::PropertiesObject, ob
810
- end
811
-
812
- let(:instance) { GIMarshallingTests::PropertiesObject.new }
813
-
814
- describe "its 'some-boolean' property" do
815
- it 'can be retrieved with #get_property' do
816
- instance.get_property('some-boolean').must_equal false
817
- end
818
-
819
- it 'can be retrieved with #some_boolean' do
820
- instance.some_boolean.must_equal false
821
- end
822
-
823
- it 'can be set with #set_property' do
824
- instance.set_property('some-boolean', true)
825
- instance.get_property('some-boolean').must_equal true
826
- end
827
-
828
- it 'can be set with #some_boolean=' do
829
- instance.some_boolean = true
830
- instance.get_property('some-boolean').must_equal true
831
- end
832
- end
833
-
834
- describe "its 'some-boxed-glist' property" do
835
- before do
836
- skip unless get_property_introspection_data('GIMarshallingTests',
837
- 'PropertiesObject',
838
- 'some-boxed-glist')
839
- end
840
-
841
- it 'can be retrieved with #get_property' do
842
- instance.get_property('some-boxed-glist').must_be_nil
843
- end
844
-
845
- it 'can be retrieved with #some_boxed_glist' do
846
- instance.some_boxed_glist.must_be_nil
847
- end
848
-
849
- it 'can be set with #set_property_extended' do
850
- instance.set_property_extended('some-boxed-glist', [1, 2, 3])
851
- instance.some_boxed_glist.to_a.must_equal [1, 2, 3]
852
- end
853
-
854
- it 'can be set with #some_boxed_glist=' do
855
- instance.some_boxed_glist = [1, 2, 3]
856
- instance.some_boxed_glist.to_a.must_equal [1, 2, 3]
857
- instance.get_property_extended('some-boxed-glist').to_a.must_equal [1, 2, 3]
858
- end
859
- end
860
-
861
- describe "its 'some-boxed-struct' property" do
862
- before do
863
- skip unless get_property_introspection_data('GIMarshallingTests',
864
- 'PropertiesObject',
865
- 'some-boxed-struct')
866
- end
867
-
868
- it 'can be retrieved with #get_property' do
869
- instance.get_property('some-boxed-struct').must_be_nil
870
- end
871
-
872
- it 'can be retrieved with #some_boxed_struct' do
873
- instance.some_boxed_struct.must_be_nil
874
- end
875
-
876
- it 'can be set with #set_property' do
877
- boxed = GIMarshallingTests::BoxedStruct.new
878
- boxed.long_ = 42
879
- instance.set_property('some-boxed-struct', boxed)
880
- instance.get_property('some-boxed-struct').long_.must_equal 42
881
- end
882
-
883
- it 'can be set with #some_boxed_struct=' do
884
- boxed = GIMarshallingTests::BoxedStruct.new
885
- boxed.long_ = 43
886
- instance.some_boxed_struct = boxed
887
- instance.some_boxed_struct.long_.must_equal 43
888
- end
889
- end
890
-
891
- describe "its 'some-char' property" do
892
- it 'can be retrieved with #get_property' do
893
- instance.get_property('some-char').must_equal 0
894
- end
895
-
896
- it 'can be retrieved with #some_char' do
897
- instance.some_char.must_equal 0
898
- end
899
-
900
- it 'can be set with #set_property' do
901
- instance.set_property 'some-char', 42
902
- instance.get_property('some-char').must_equal 42
903
- end
904
-
905
- it 'can be set with #some_char=' do
906
- instance.some_char = 43
907
- instance.some_char.must_equal 43
908
- end
909
- end
910
-
911
- describe "its 'some-double' property" do
912
- it 'can be retrieved with #get_property' do
913
- instance.get_property('some-double').must_equal 0.0
914
- end
915
-
916
- it 'can be retrieved with #some_double' do
917
- instance.some_double.must_equal 0.0
918
- end
919
-
920
- it 'can be set with #set_property' do
921
- instance.set_property('some-double', 3.14)
922
- instance.get_property('some-double').must_equal 3.14
923
- end
924
-
925
- it 'can be set with #some_double=' do
926
- instance.some_double = 3.14
927
- instance.some_double.must_equal 3.14
928
- end
929
- end
930
-
931
- describe "its 'some-float' property" do
932
- it 'can be retrieved with #get_property' do
933
- instance.get_property('some-float').must_equal 0.0
934
- end
935
-
936
- it 'can be retrieved with #some_float' do
937
- instance.some_float.must_equal 0.0
938
- end
939
-
940
- it 'can be set with #set_property' do
941
- instance.set_property('some-float', 3.14)
942
- instance.get_property('some-float').must_be_close_to 3.14
943
- end
944
-
945
- it 'can be set with #some_float=' do
946
- instance.some_float = 3.14
947
- instance.some_float.must_be_close_to 3.14
948
- end
949
- end
950
-
951
- describe "its 'some-int' property" do
952
- it 'can be retrieved with #get_property' do
953
- instance.get_property('some-int').must_equal 0
954
- end
955
-
956
- it 'can be retrieved with #some_int' do
957
- instance.some_int.must_equal 0
958
- end
959
-
960
- it 'can be set with #set_property' do
961
- instance.set_property 'some-int', 4242
962
- instance.get_property('some-int').must_equal 4242
963
- end
964
-
965
- it 'can be set with #some_int=' do
966
- instance.some_int = 4243
967
- instance.some_int.must_equal 4243
968
- end
969
- end
970
-
971
- describe "its 'some-int64' property" do
972
- it 'can be retrieved with #get_property' do
973
- instance.get_property('some-int64').must_equal 0
974
- end
975
-
976
- it 'can be retrieved with #some_int64' do
977
- instance.some_int64.must_equal 0
978
- end
979
-
980
- it 'can be set with #set_property' do
981
- instance.set_property 'some-int64', 42_000_000_000_000
982
- instance.get_property('some-int64').must_equal 42_000_000_000_000
983
- end
984
-
985
- it 'can be set with #some_int64=' do
986
- instance.some_int64 = 43_000_000_000_000
987
- instance.some_int64.must_equal 43_000_000_000_000
988
- end
989
- end
990
-
991
- describe "its 'some-long' property" do
992
- it 'can be retrieved with #get_property' do
993
- instance.get_property('some-long').must_equal 0
994
- end
995
-
996
- it 'can be retrieved with #some_long' do
997
- instance.some_long.must_equal 0
998
- end
999
-
1000
- it 'can be set with #set_property' do
1001
- instance.set_property 'some-long', 4242
1002
- instance.get_property('some-long').must_equal 4242
1003
- end
1004
-
1005
- it 'can be set with #some_long=' do
1006
- instance.some_long = 4243
1007
- instance.some_long.must_equal 4243
1008
- end
1009
- end
1010
-
1011
- describe "its 'some-object' property" do
1012
- before do
1013
- skip unless get_property_introspection_data('GIMarshallingTests',
1014
- 'PropertiesObject',
1015
- 'some-object')
1016
- end
1017
-
1018
- it 'can be retrieved with #get_property' do
1019
- instance.get_property('some-object').must_be_nil
1020
- end
1021
-
1022
- it 'can be retrieved with #some_object' do
1023
- instance.some_object.must_be_nil
1024
- end
1025
-
1026
- it 'can be set with #set_property' do
1027
- ob = GIMarshallingTests::Object.new 42
1028
- instance.set_property 'some-object', ob
1029
- instance.get_property('some-object').must_equal ob
1030
- end
1031
-
1032
- it 'can be set with #some_object=' do
1033
- ob = GIMarshallingTests::Object.new 42
1034
- instance.some_object = ob
1035
- instance.some_object.must_equal ob
1036
- end
1037
- end
1038
-
1039
- describe "its 'some-strv' property" do
1040
- before do
1041
- skip unless get_property_introspection_data('GIMarshallingTests',
1042
- 'PropertiesObject',
1043
- 'some-strv')
1044
- end
1045
-
1046
- it 'can be retrieved with #get_property' do
1047
- instance.get_property('some-strv').must_be :==, []
1048
- end
1049
-
1050
- it 'can be retrieved with #some_strv' do
1051
- instance.some_strv.must_be :==, []
1052
- end
1053
-
1054
- it 'can be set with #set_property_extended' do
1055
- instance.set_property_extended('some-strv', %w(foo bar))
1056
- instance.get_property('some-strv').must_be :==, %w(foo bar)
1057
- end
1058
-
1059
- it 'can be set with #some_strv=' do
1060
- instance.some_strv = %w(foo bar)
1061
- instance.some_strv.must_be :==, %w(foo bar)
1062
- end
1063
- end
1064
-
1065
- describe "its 'some-uchar' property" do
1066
- it 'can be retrieved with #get_property' do
1067
- instance.get_property('some-uchar').must_equal 0
1068
- end
1069
-
1070
- it 'can be retrieved with #some_uchar' do
1071
- instance.some_uchar.must_equal 0
1072
- end
1073
-
1074
- it 'can be set with #set_property' do
1075
- instance.set_property 'some-uchar', 42
1076
- instance.get_property('some-uchar').must_equal 42
1077
- end
1078
-
1079
- it 'can be set with #some_uchar=' do
1080
- instance.some_uchar = 43
1081
- instance.some_uchar.must_equal 43
1082
- end
1083
- end
1084
-
1085
- describe "its 'some-uint' property" do
1086
- it 'can be retrieved with #get_property' do
1087
- instance.get_property('some-uint').must_equal 0
1088
- end
1089
-
1090
- it 'can be retrieved with #some_uint' do
1091
- instance.some_uint.must_equal 0
1092
- end
1093
-
1094
- it 'can be set with #set_property' do
1095
- instance.set_property 'some-uint', 4242
1096
- instance.get_property('some-uint').must_equal 4242
1097
- end
1098
-
1099
- it 'can be set with #some_uint=' do
1100
- instance.some_uint = 4243
1101
- instance.some_uint.must_equal 4243
1102
- end
1103
- end
1104
-
1105
- describe "its 'some-uint64' property" do
1106
- it 'can be retrieved with #get_property' do
1107
- instance.get_property('some-uint64').must_equal 0
1108
- end
1109
-
1110
- it 'can be retrieved with #some_uint64' do
1111
- instance.some_uint64.must_equal 0
1112
- end
1113
-
1114
- it 'can be set with #set_property' do
1115
- instance.set_property 'some-uint64', 42_000_000_000_000
1116
- instance.get_property('some-uint64').must_equal 42_000_000_000_000
1117
- end
1118
-
1119
- it 'can be set with #some_uint64=' do
1120
- instance.some_uint64 = 43_000_000_000_000
1121
- instance.some_uint64.must_equal 43_000_000_000_000
1122
- end
1123
- end
1124
-
1125
- describe "its 'some-ulong' property" do
1126
- it 'can be retrieved with #get_property' do
1127
- instance.get_property('some-ulong').must_equal 0
1128
- end
1129
-
1130
- it 'can be retrieved with #some_ulong' do
1131
- instance.some_ulong.must_equal 0
1132
- end
1133
-
1134
- it 'can be set with #set_property' do
1135
- instance.set_property 'some-ulong', 4242
1136
- instance.get_property('some-ulong').must_equal 4242
1137
- end
1138
-
1139
- it 'can be set with #some_ulong=' do
1140
- instance.some_ulong = 4243
1141
- instance.some_ulong.must_equal 4243
1142
- end
1143
- end
1144
-
1145
- describe "its 'some-variant' property" do
1146
- before do
1147
- skip unless get_property_introspection_data('GIMarshallingTests',
1148
- 'PropertiesObject',
1149
- 'some-variant')
1150
- end
1151
-
1152
- it 'can be retrieved with #get_property' do
1153
- instance.get_property('some-variant').must_be_nil
1154
- end
1155
-
1156
- it 'can be retrieved with #some_variant' do
1157
- instance.some_variant.must_be_nil
1158
- end
1159
-
1160
- it 'can be set with #set_property' do
1161
- value = GLib::Variant.new_string('Foo')
1162
- instance.set_property 'some-variant', value
1163
- instance.get_property('some-variant').must_equal value
1164
- end
1165
-
1166
- it 'can be set with #some_variant=' do
1167
- value = GLib::Variant.new_string('Foo')
1168
- instance.some_variant = value
1169
- instance.some_variant.must_equal value
1170
- end
1171
- end
1172
- end
1173
-
1174
- describe 'GIMarshallingTests::SecondEnum' do
1175
- it 'has the member :secondvalue1' do
1176
- assert_equal 0, GIMarshallingTests::SecondEnum[:secondvalue1]
1177
- end
1178
- it 'has the member :secondvalue2' do
1179
- assert_equal 1, GIMarshallingTests::SecondEnum[:secondvalue2]
1180
- end
1181
- end
1182
-
1183
- describe 'GIMarshallingTests::SimpleStruct' do
1184
- it 'creates an instance using #new' do
1185
- ss = GIMarshallingTests::SimpleStruct.new
1186
- assert_instance_of GIMarshallingTests::SimpleStruct, ss
1187
- end
1188
-
1189
- let(:instance) { GIMarshallingTests::SimpleStruct.new }
1190
-
1191
- it 'has a writable field long_' do
1192
- instance.long_.must_equal 0
1193
- instance.long_ = 1056
1194
- instance.long_.must_equal 1056
1195
- end
1196
-
1197
- it 'has a writable field int8' do
1198
- instance.int8.must_equal 0
1199
- instance.int8 = -43
1200
- instance.int8.must_equal(-43)
1201
- end
1202
-
1203
- it 'has a working method #inv' do
1204
- instance.long_ = 6
1205
- instance.int8 = 7
1206
- instance.inv
1207
- pass
1208
- end
1209
-
1210
- it 'has a working method #method' do
1211
- instance.long_ = 6
1212
- instance.int8 = 7
1213
- instance.method
1214
- pass
1215
- end
1216
-
1217
- it 'has a working function #returnv' do
1218
- ss = GIMarshallingTests::SimpleStruct.returnv
1219
- assert_instance_of GIMarshallingTests::SimpleStruct, ss
1220
- end
1221
- end
1222
-
1223
- describe 'GIMarshallingTests::SubObject' do
1224
- it 'creates an instance using #new' do
1225
- so = GIMarshallingTests::SubObject.new
1226
- so.must_be_instance_of GIMarshallingTests::SubObject
1227
- GObject.type_name_from_instance(so).
1228
- must_equal 'GIMarshallingTestsSubObject'
1229
- end
1230
-
1231
- let(:instance) { GIMarshallingTests::SubObject.new }
1232
-
1233
- it 'has a working method #overwritten_method' do
1234
- instance.overwritten_method
1235
- pass
1236
- end
1237
-
1238
- it 'has a working method #sub_method' do
1239
- instance.sub_method
1240
- pass
1241
- end
1242
-
1243
- it 'does not have accessors for its parent instance' do
1244
- instance.wont_respond_to :parent_instance
1245
- instance.wont_respond_to :parent_instance=
1246
- end
1247
- end
1248
-
1249
- describe 'GIMarshallingTests::SubSubObject' do
1250
- it 'creates an instance using #new' do
1251
- so = GIMarshallingTests::SubSubObject.new
1252
- assert_instance_of GIMarshallingTests::SubSubObject, so
1253
- GObject.type_name_from_instance(so).
1254
- must_equal 'GIMarshallingTestsSubSubObject'
1255
- end
1256
-
1257
- let(:instance) { GIMarshallingTests::SubSubObject.new }
1258
-
1259
- it 'does not have accessors for its parent instance' do
1260
- instance.wont_respond_to :parent_instance
1261
- instance.wont_respond_to :parent_instance=
1262
- end
1263
- end
1264
-
1265
- describe 'GIMarshallingTests::Union' do
1266
- it 'creates an instance with #new' do
1267
- u = GIMarshallingTests::Union.new
1268
- assert_instance_of GIMarshallingTests::Union, u
1269
- end
1270
-
1271
- let(:instance) { GIMarshallingTests::Union.new }
1272
-
1273
- it 'has a writable field long_' do
1274
- assert_equal 0, instance.long_
1275
- instance.long_ = 1056
1276
- assert_equal 1056, instance.long_
1277
- end
1278
-
1279
- it 'has a working method #inv' do
1280
- instance.long_ = 42
1281
- instance.inv
1282
- pass
1283
- end
1284
-
1285
- it 'has a working method #method' do
1286
- instance.long_ = 42
1287
- instance.method
1288
- pass
1289
- end
1290
-
1291
- it 'has a working function #inout' do
1292
- skip 'This function is defined in the header but not implemented'
1293
- end
1294
-
1295
- it 'has a working function #out' do
1296
- skip 'This function is defined in the header but not implemented'
1297
- end
1298
-
1299
- it 'has a working function #returnv' do
1300
- u = GIMarshallingTests::Union.returnv
1301
- assert_instance_of GIMarshallingTests::Union, u
1302
- end
1303
- end
1304
-
1305
- it 'has a working function #array_enum_in' do
1306
- GIMarshallingTests.array_enum_in [:value1, :value2, :value3]
1307
- end
1308
-
1309
- it 'has a working function #array_fixed_inout' do
1310
- res = GIMarshallingTests.array_fixed_inout [-1, 0, 1, 2]
1311
- res.must_be :==, [2, 1, 0, -1]
1312
- end
1313
-
1314
- it 'has a working function #array_fixed_int_in' do
1315
- GIMarshallingTests.array_fixed_int_in [-1, 0, 1, 2]
1316
- pass
1317
- end
1318
-
1319
- it 'has a working function #array_fixed_int_return' do
1320
- res = GIMarshallingTests.array_fixed_int_return
1321
- res.must_be :==, [-1, 0, 1, 2]
1322
- end
1323
-
1324
- it 'has a working function #array_fixed_out' do
1325
- res = GIMarshallingTests.array_fixed_out
1326
- res.must_be :==, [-1, 0, 1, 2]
1327
- end
1328
-
1329
- it 'has a working function #array_fixed_out_struct' do
1330
- res = GIMarshallingTests.array_fixed_out_struct
1331
- assert_equal [[7, 6], [6, 7]], res.map { |s| [s.long_, s.int8] }
1332
- end
1333
-
1334
- it 'has a working function #array_fixed_short_in' do
1335
- GIMarshallingTests.array_fixed_short_in [-1, 0, 1, 2]
1336
- pass
1337
- end
1338
-
1339
- it 'has a working function #array_fixed_short_return' do
1340
- res = GIMarshallingTests.array_fixed_short_return
1341
- res.must_be :==, [-1, 0, 1, 2]
1342
- end
1343
-
1344
- it 'has a working function #array_gvariant_container_in' do
1345
- v1 = GLib::Variant.new_int32(27)
1346
- v2 = GLib::Variant.new_string('Hello')
1347
- result = GIMarshallingTests.array_gvariant_container_in [v1, v2]
1348
- arr = result.to_a
1349
- arr.size.must_equal 2
1350
- arr[0].get_int32.must_equal 27
1351
- arr[1].get_string.must_equal 'Hello'
1352
- end
1353
-
1354
- it 'has a working function #array_gvariant_full_in' do
1355
- v1 = GLib::Variant.new_int32(27)
1356
- v2 = GLib::Variant.new_string('Hello')
1357
- result = GIMarshallingTests.array_gvariant_full_in [v1, v2]
1358
- arr = result.to_a
1359
- arr.size.must_equal 2
1360
- arr[0].get_int32.must_equal 27
1361
- arr[1].get_string.must_equal 'Hello'
1362
- end
1363
-
1364
- it 'has a working function #array_gvariant_none_in' do
1365
- v1 = GLib::Variant.new_int32(27)
1366
- v2 = GLib::Variant.new_string('Hello')
1367
- result = GIMarshallingTests.array_gvariant_none_in [v1, v2]
1368
- arr = result.to_a
1369
- arr.size.must_equal 2
1370
- arr[0].get_int32.must_equal 27
1371
- arr[1].get_string.must_equal 'Hello'
1372
- end
1373
-
1374
- it 'has a working function #array_in' do
1375
- GIMarshallingTests.array_in [-1, 0, 1, 2]
1376
- pass
1377
- end
1378
-
1379
- it 'has a working function #array_in_guint64_len' do
1380
- GIMarshallingTests.array_in_guint64_len [-1, 0, 1, 2]
1381
- pass
1382
- end
1383
-
1384
- it 'has a working function #array_in_guint8_len' do
1385
- GIMarshallingTests.array_in_guint8_len [-1, 0, 1, 2]
1386
- pass
1387
- end
1388
-
1389
- it 'has a working function #array_in_len_before' do
1390
- GIMarshallingTests.array_in_len_before [-1, 0, 1, 2]
1391
- pass
1392
- end
1393
-
1394
- it 'has a working function #array_in_len_zero_terminated' do
1395
- GIMarshallingTests.array_in_len_zero_terminated [-1, 0, 1, 2]
1396
- pass
1397
- end
1398
-
1399
- it 'has a working function #array_in_nonzero_nonlen' do
1400
- skip unless get_introspection_data 'GIMarshallingTests', 'array_in_nonzero_nonlen'
1401
- GIMarshallingTests.array_in_nonzero_nonlen 1, 'abcd'.bytes.to_a
1402
- pass
1403
- end
1404
-
1405
- it 'has a working function #array_in_utf8_two_in' do
1406
- skip unless get_introspection_data 'GIMarshallingTests', 'array_in_utf8_two_in'
1407
- GIMarshallingTests.array_in_utf8_two_in [-1, 0, 1, 2], '1', '2'
1408
- pass
1409
- end
1410
-
1411
- it 'has a working function #array_in_utf8_two_in_out_of_order' do
1412
- skip unless get_introspection_data 'GIMarshallingTests', 'array_in_utf8_two_in_out_of_order'
1413
- GIMarshallingTests.array_in_utf8_two_in_out_of_order '1', [-1, 0, 1, 2], '2'
1414
- pass
1415
- end
1416
-
1417
- it 'has a working function #array_inout' do
1418
- res = GIMarshallingTests.array_inout [-1, 0, 1, 2]
1419
- res.must_be :==, [-2, -1, 0, 1, 2]
1420
- end
1421
-
1422
- it 'has a working function #array_inout_etc' do
1423
- arr, sum = GIMarshallingTests.array_inout_etc 42, [-1, 0, 1, 2], 24
1424
- arr.must_be :==, [42, -1, 0, 1, 24]
1425
- sum.must_equal 42 + 24
1426
- end
1427
-
1428
- it 'has a working function #array_out' do
1429
- res = GIMarshallingTests.array_out
1430
- res.must_be :==, [-1, 0, 1, 2]
1431
- end
1432
-
1433
- it 'has a working function #array_out_etc' do
1434
- arr, sum = GIMarshallingTests.array_out_etc 42, 24
1435
- arr.must_be :==, [42, 0, 1, 24]
1436
- sum.must_equal 42 + 24
1437
- end
1438
-
1439
- it 'has a working function #array_return' do
1440
- res = GIMarshallingTests.array_return
1441
- res.must_be :==, [-1, 0, 1, 2]
1442
- end
1443
-
1444
- it 'has a working function #array_return_etc' do
1445
- arr, sum = GIMarshallingTests.array_return_etc 42, 24
1446
- arr.must_be :==, [42, 0, 1, 24]
1447
- sum.must_equal 42 + 24
1448
- end
1449
-
1450
- it 'has a working function #array_simple_struct_in' do
1451
- arr = [1, 2, 3].map do |val|
1452
- GIMarshallingTests::SimpleStruct.new.tap { |struct| struct.long_ = val }
1453
- end
1454
- GIMarshallingTests.array_simple_struct_in arr
1455
- end
1456
-
1457
- it 'has a working function #array_string_in' do
1458
- GIMarshallingTests.array_string_in %w(foo bar)
1459
- pass
1460
- end
1461
-
1462
- it 'has a working function #array_struct_in' do
1463
- arr = [1, 2, 3].map do |val|
1464
- GIMarshallingTests::BoxedStruct.new.tap { |struct| struct.long_ = val }
1465
- end
1466
- GIMarshallingTests.array_struct_in arr
1467
- end
1468
-
1469
- it 'has a working function #array_struct_take_in' do
1470
- arr = [1, 2, 3].map do |val|
1471
- GIMarshallingTests::BoxedStruct.new.tap { |struct| struct.long_ = val }
1472
- end
1473
- # NOTE: This copies values so arr's elements stay valid
1474
- GIMarshallingTests.array_struct_take_in arr
1475
-
1476
- arr.map(&:long_).must_equal [1, 2, 3]
1477
- end
1478
-
1479
- it 'has a working function #array_struct_value_in' do
1480
- skip unless get_introspection_data 'GIMarshallingTests', 'array_struct_value_in'
1481
- arr = [1, 2, 3].map do |val|
1482
- GIMarshallingTests::BoxedStruct.new.tap { |struct| struct.long_ = val }
1483
- end
1484
- GIMarshallingTests.array_struct_value_in arr
1485
- end
1486
-
1487
- it 'has a working function #array_uint8_in' do
1488
- arr = 'abcd'.bytes.to_a
1489
- GIMarshallingTests.array_uint8_in arr
1490
- pass
1491
- end
1492
-
1493
- it 'has a working function #array_zero_terminated_in' do
1494
- GIMarshallingTests.array_zero_terminated_in %w(0 1 2)
1495
- pass
1496
- end
1497
-
1498
- it 'has a working function #array_zero_terminated_inout' do
1499
- res = GIMarshallingTests.array_zero_terminated_inout %w(0 1 2)
1500
- res.must_be :==, ['-1', '0', '1', '2']
1501
- end
1502
-
1503
- it 'has a working function #array_zero_terminated_out' do
1504
- res = GIMarshallingTests.array_zero_terminated_out
1505
- res.must_be :==, %w(0 1 2)
1506
- end
1507
-
1508
- it 'has a working function #array_zero_terminated_return' do
1509
- res = GIMarshallingTests.array_zero_terminated_return
1510
- res.must_be :==, %w(0 1 2)
1511
- end
1512
-
1513
- it 'has a working function #array_zero_terminated_return_null' do
1514
- res = GIMarshallingTests.array_zero_terminated_return_null
1515
- res.must_be :==, []
1516
- end
1517
-
1518
- it 'has a working function #array_zero_terminated_return_struct' do
1519
- res = GIMarshallingTests.array_zero_terminated_return_struct
1520
- res.to_a.map(&:long_).must_equal [42, 43, 44]
1521
- end
1522
-
1523
- it 'has a working function #boolean_in_false' do
1524
- GIMarshallingTests.boolean_in_false false
1525
- pass
1526
- end
1527
-
1528
- it 'has a working function #boolean_in_true' do
1529
- GIMarshallingTests.boolean_in_true true
1530
- pass
1531
- end
1532
-
1533
- it 'has a working function #boolean_inout_false_true' do
1534
- res = GIMarshallingTests.boolean_inout_false_true false
1535
- res.must_equal true
1536
- end
1537
-
1538
- it 'has a working function #boolean_inout_true_false' do
1539
- res = GIMarshallingTests.boolean_inout_true_false true
1540
- res.must_equal false
1541
- end
1542
-
1543
- it 'has a working function #boolean_out_false' do
1544
- res = GIMarshallingTests.boolean_out_false
1545
- res.must_equal false
1546
- end
1547
-
1548
- it 'has a working function #boolean_out_true' do
1549
- res = GIMarshallingTests.boolean_out_true
1550
- res.must_equal true
1551
- end
1552
-
1553
- it 'has a working function #boolean_return_false' do
1554
- res = GIMarshallingTests.boolean_return_false
1555
- res.must_equal false
1556
- end
1557
-
1558
- it 'has a working function #boolean_return_true' do
1559
- res = GIMarshallingTests.boolean_return_true
1560
- res.must_equal true
1561
- end
1562
-
1563
- it 'has a working function #boxed_struct_inout' do
1564
- bx = GIMarshallingTests::BoxedStruct.new
1565
- bx.long_ = 42
1566
- res = GIMarshallingTests.boxed_struct_inout bx
1567
- res.long_.must_equal 0
1568
- end
1569
-
1570
- it 'has a working function #boxed_struct_out' do
1571
- res = GIMarshallingTests.boxed_struct_out
1572
- res.long_.must_equal 42
1573
- end
1574
-
1575
- it 'has a working function #boxed_struct_returnv' do
1576
- res = GIMarshallingTests.boxed_struct_returnv
1577
- res.long_.must_equal 42
1578
- res.g_strv.must_be :==, %w(0 1 2)
1579
- end
1580
-
1581
- it 'has a working function #bytearray_full_return' do
1582
- ret = GIMarshallingTests.bytearray_full_return
1583
- assert_instance_of GLib::ByteArray, ret
1584
- assert_includes(
1585
- ['0123'.bytes.to_a, "\x001\xFF3".bytes.to_a],
1586
- ret.to_string.bytes.to_a)
1587
- end
1588
-
1589
- it 'has a working function #bytearray_none_in' do
1590
- val = GIMarshallingTests.bytearray_full_return.to_string
1591
- ba = GLib::ByteArray.new
1592
- ba = ba.append val
1593
- GIMarshallingTests.bytearray_none_in ba
1594
- pass
1595
- end
1596
-
1597
- it 'has a working function #callback_multiple_out_parameters' do
1598
- result = GIMarshallingTests.callback_multiple_out_parameters do |*_args|
1599
- [12.0, 13.0]
1600
- end
1601
- result.must_equal [12.0, 13.0]
1602
- end
1603
-
1604
- it 'has a working function #callback_one_out_parameter' do
1605
- result = GIMarshallingTests.callback_one_out_parameter { 42.0 }
1606
- result.must_equal 42.0
1607
- end
1608
-
1609
- it 'has a working function #callback_owned_boxed' do
1610
- skip unless get_introspection_data 'GIMarshallingTests', 'callback_owned_boxed'
1611
- a = nil
1612
-
1613
- callback = proc { |box, _callback_data| a = box.long_ * 2 }
1614
-
1615
- result = GIMarshallingTests.callback_owned_boxed(&callback)
1616
- result.must_equal 1
1617
- a.must_equal 2
1618
-
1619
- result = GIMarshallingTests.callback_owned_boxed(&callback)
1620
- result.must_equal 2
1621
- a.must_equal 4
1622
- end
1623
-
1624
- it 'has a working function #callback_return_value_and_multiple_out_parameters' do
1625
- result = GIMarshallingTests.callback_return_value_and_multiple_out_parameters do |*_args|
1626
- [42, -142, 3]
1627
- end
1628
- result.must_equal [42, -142, 3]
1629
- end
1630
-
1631
- it 'has a working function #callback_return_value_and_one_out_parameter' do
1632
- result = GIMarshallingTests.callback_return_value_and_one_out_parameter do |*_args|
1633
- [42, -142]
1634
- end
1635
- result.must_equal [42, -142]
1636
- end
1637
-
1638
- it 'has a working function #callback_return_value_only' do
1639
- result = GIMarshallingTests.callback_return_value_only { 42 }
1640
- result.must_equal 42
1641
- end
1642
-
1643
- it 'has a working function #double_in' do
1644
- GIMarshallingTests.double_in Float::MAX
1645
- pass
1646
- end
1647
-
1648
- it 'has a working function #double_inout' do
1649
- ret = GIMarshallingTests.double_inout Float::MAX
1650
- assert_in_epsilon 2.225e-308, ret
1651
- end
1652
-
1653
- it 'has a working function #double_out' do
1654
- ret = GIMarshallingTests.double_out
1655
- ret.must_equal Float::MAX
1656
- end
1657
-
1658
- it 'has a working function #double_return' do
1659
- ret = GIMarshallingTests.double_return
1660
- ret.must_equal Float::MAX
1661
- end
1662
-
1663
- it 'has a working function #enum_in' do
1664
- GIMarshallingTests.enum_in :value3
1665
- pass
1666
- end
1667
-
1668
- it 'has a working function #enum_inout' do
1669
- e = GIMarshallingTests.enum_inout :value3
1670
- e.must_equal :value1
1671
- end
1672
-
1673
- it 'has a working function #enum_out' do
1674
- e = GIMarshallingTests.enum_out
1675
- e.must_equal :value3
1676
- end
1677
-
1678
- it 'has a working function #enum_returnv' do
1679
- e = GIMarshallingTests.enum_returnv
1680
- e.must_equal :value3
1681
- end
1682
-
1683
- it 'has a working function #filename_list_return' do
1684
- fl = GIMarshallingTests.filename_list_return
1685
- fl.must_be_nil
1686
- end
1687
-
1688
- it 'has a working function #flags_in' do
1689
- GIMarshallingTests.flags_in value2: true
1690
- pass
1691
- end
1692
-
1693
- it 'has a working function #flags_in_zero' do
1694
- GIMarshallingTests.flags_in_zero 0
1695
- pass
1696
- end
1697
-
1698
- it 'has a working function #flags_inout' do
1699
- res = GIMarshallingTests.flags_inout value2: true
1700
- res.must_equal(value1: true)
1701
- end
1702
-
1703
- it 'has a working function #flags_out' do
1704
- res = GIMarshallingTests.flags_out
1705
- res.must_equal(value2: true)
1706
- end
1707
-
1708
- it 'has a working function #flags_returnv' do
1709
- res = GIMarshallingTests.flags_returnv
1710
- res.must_equal(value2: true)
1711
- end
1712
-
1713
- it 'has a working function #float_in' do
1714
- # float_return returns MAX_FLT
1715
- flt = GIMarshallingTests.float_return
1716
- GIMarshallingTests.float_in flt
1717
- pass
1718
- end
1719
-
1720
- it 'has a working function #float_inout' do
1721
- # float_return returns MAX_FLT
1722
- flt = GIMarshallingTests.float_return
1723
- res = GIMarshallingTests.float_inout flt
1724
- assert_in_epsilon 1.175e-38, res
1725
- end
1726
-
1727
- it 'has a working function #float_out' do
1728
- flt = GIMarshallingTests.float_out
1729
- assert_in_epsilon 3.402e+38, flt
1730
- end
1731
-
1732
- it 'has a working function #float_return' do
1733
- flt = GIMarshallingTests.float_return
1734
- assert_in_epsilon 3.402e+38, flt
1735
- end
1736
-
1737
- it 'has a working function #garray_int_none_in' do
1738
- arr = [-1, 0, 1, 2]
1739
- GIMarshallingTests.garray_int_none_in arr
1740
- pass
1741
- end
1742
-
1743
- it 'has a working function #garray_int_none_return' do
1744
- arr = GIMarshallingTests.garray_int_none_return
1745
- arr.must_be :==, [-1, 0, 1, 2]
1746
- end
1747
-
1748
- it 'has a working function #garray_uint64_none_in' do
1749
- skip unless get_introspection_data 'GIMarshallingTests', 'garray_uint64_none_in'
1750
- GIMarshallingTests.garray_uint64_none_in [0, 0xffff_ffff_ffff_ffff]
1751
- pass
1752
- end
1753
-
1754
- it 'has a working function #garray_uint64_none_return' do
1755
- skip unless get_introspection_data 'GIMarshallingTests', 'garray_uint64_none_return'
1756
- res = GIMarshallingTests.garray_uint64_none_return
1757
- res.must_be :==, [0, 0xffff_ffff_ffff_ffff]
1758
- end
1759
-
1760
- it 'has a working function #garray_utf8_container_inout' do
1761
- res = GIMarshallingTests.garray_utf8_container_inout %w(0 1 2)
1762
- res.must_be :==, ['-2', '-1', '0', '1']
1763
- end
1764
-
1765
- it 'has a working function #garray_utf8_container_out' do
1766
- res = GIMarshallingTests.garray_utf8_container_out
1767
- res.must_be :==, %w(0 1 2)
1768
- end
1769
-
1770
- it 'has a working function #garray_utf8_container_return' do
1771
- res = GIMarshallingTests.garray_utf8_container_return
1772
- res.must_be :==, %w(0 1 2)
1773
- end
1774
-
1775
- it 'has a working function #garray_utf8_full_inout' do
1776
- arr = %w(0 1 2)
1777
- res = GIMarshallingTests.garray_utf8_full_inout arr
1778
- res.must_be :==, ['-2', '-1', '0', '1']
1779
- end
1780
-
1781
- it 'has a working function #garray_utf8_full_out' do
1782
- res = GIMarshallingTests.garray_utf8_full_out
1783
- res.must_be :==, %w(0 1 2)
1784
- end
1785
-
1786
- it 'has a working function #garray_utf8_full_out_caller_allocated' do
1787
- skip unless get_introspection_data 'GIMarshallingTests',
1788
- 'garray_utf8_full_out_caller_allocated'
1789
- res = GIMarshallingTests.garray_utf8_full_out_caller_allocated
1790
- res.must_be :==, %w(0 1 2)
1791
- end
1792
-
1793
- it 'has a working function #garray_utf8_full_return' do
1794
- res = GIMarshallingTests.garray_utf8_full_return
1795
- res.must_be :==, %w(0 1 2)
1796
- end
1797
-
1798
- it 'has a working function #garray_utf8_none_in' do
1799
- arr = %w(0 1 2)
1800
- GIMarshallingTests.garray_utf8_none_in arr
1801
- pass
1802
- end
1803
-
1804
- it 'has a working function #garray_utf8_none_inout' do
1805
- arr = %w(0 1 2)
1806
- res = GIMarshallingTests.garray_utf8_none_inout arr
1807
- res.must_be :==, ['-2', '-1', '0', '1']
1808
- end
1809
-
1810
- it 'has a working function #garray_utf8_none_out' do
1811
- res = GIMarshallingTests.garray_utf8_none_out
1812
- res.must_be :==, %w(0 1 2)
1813
- end
1814
-
1815
- it 'has a working function #garray_utf8_none_return' do
1816
- res = GIMarshallingTests.garray_utf8_none_return
1817
- res.must_be :==, %w(0 1 2)
1818
- end
1819
-
1820
- it 'has a working function #gbytes_full_return' do
1821
- skip unless get_introspection_data 'GIMarshallingTests', 'gbytes_full_return'
1822
- res = GIMarshallingTests.gbytes_full_return
1823
- res.to_a.must_equal [0, 49, 0xFF, 51]
1824
- end
1825
-
1826
- it 'has a working function #gbytes_none_in' do
1827
- skip unless get_introspection_data 'GIMarshallingTests', 'gbytes_none_in'
1828
- GIMarshallingTests.gbytes_none_in [0, 49, 0xFF, 51]
1829
- pass
1830
- end
1831
-
1832
- it 'has a working function #gclosure_in' do
1833
- cl = GObject::RubyClosure.new { 42 }
1834
- GIMarshallingTests.gclosure_in cl
1835
- pass
1836
- end
1837
-
1838
- it 'has a working function #gclosure_return' do
1839
- cl = GIMarshallingTests.gclosure_return
1840
- gv = GObject::Value.wrap_ruby_value 0
1841
- result = cl.invoke gv, []
1842
- gv.get_value.must_equal 42
1843
- result.must_equal 42
1844
- end
1845
-
1846
- it 'has a working function #genum_in' do
1847
- GIMarshallingTests.genum_in :value3
1848
- pass
1849
- end
1850
-
1851
- it 'has a working function #genum_inout' do
1852
- res = GIMarshallingTests.genum_inout :value3
1853
- res.must_equal :value1
1854
- end
1855
-
1856
- it 'has a working function #genum_out' do
1857
- res = GIMarshallingTests.genum_out
1858
- res.must_equal :value3
1859
- end
1860
-
1861
- it 'has a working function #genum_returnv' do
1862
- res = GIMarshallingTests.genum_returnv
1863
- res.must_equal :value3
1864
- end
1865
-
1866
- it 'has a working function #gerror' do
1867
- begin
1868
- GIMarshallingTests.gerror
1869
- flunk 'Error should have been raised'
1870
- rescue GirFFI::GLibError => e
1871
- e.message.must_equal GIMarshallingTests::CONSTANT_GERROR_MESSAGE
1872
- e.domain.must_equal GIMarshallingTests::CONSTANT_GERROR_DOMAIN
1873
- e.code.must_equal GIMarshallingTests::CONSTANT_GERROR_CODE
1874
- end
1875
- end
1876
-
1877
- it 'has a working function #gerror_array_in' do
1878
- begin
1879
- GIMarshallingTests.gerror_array_in [1, 2, 3]
1880
- flunk 'Error should have been raised'
1881
- rescue GirFFI::GLibError => e
1882
- e.message.must_equal GIMarshallingTests::CONSTANT_GERROR_MESSAGE
1883
- e.domain.must_equal GIMarshallingTests::CONSTANT_GERROR_DOMAIN
1884
- e.code.must_equal GIMarshallingTests::CONSTANT_GERROR_CODE
1885
- end
1886
- end
1887
-
1888
- it 'has a working function #gerror_out' do
1889
- error, debug = GIMarshallingTests.gerror_out
1890
- debug.must_equal GIMarshallingTests::CONSTANT_GERROR_DEBUG_MESSAGE
1891
- error.message.must_equal GIMarshallingTests::CONSTANT_GERROR_MESSAGE
1892
- end
1893
-
1894
- it 'has a working function #gerror_out_transfer_none' do
1895
- error, debug = GIMarshallingTests.gerror_out_transfer_none
1896
- debug.must_equal GIMarshallingTests::CONSTANT_GERROR_DEBUG_MESSAGE
1897
- error.message.must_equal GIMarshallingTests::CONSTANT_GERROR_MESSAGE
1898
- end
1899
-
1900
- it 'has a working function #gerror_return' do
1901
- error = GIMarshallingTests.gerror_return
1902
- error.message.must_equal GIMarshallingTests::CONSTANT_GERROR_MESSAGE
1903
- end
1904
-
1905
- it 'has a working function #ghashtable_int_none_in' do
1906
- GIMarshallingTests.ghashtable_int_none_in(
1907
- -1 => 1, 0 => 0, 1 => -1, 2 => -2)
1908
- end
1909
-
1910
- it 'has a working function #ghashtable_int_none_return' do
1911
- gh = GIMarshallingTests.ghashtable_int_none_return
1912
- assert_equal({ -1 => 1, 0 => 0, 1 => -1, 2 => -2 }, gh.to_hash)
1913
- end
1914
-
1915
- it 'has a working function #ghashtable_utf8_container_in' do
1916
- skip 'This function is defined in the header but not implemented'
1917
- end
1918
-
1919
- it 'has a working function #ghashtable_utf8_container_inout' do
1920
- hsh = { '-1' => '1', '0' => '0', '1' => '-1', '2' => '-2' }
1921
- res = GIMarshallingTests.ghashtable_utf8_container_inout hsh
1922
- assert_equal({ '-1' => '1', '0' => '0', '1' => '1' }, res.to_hash)
1923
- end
1924
-
1925
- it 'has a working function #ghashtable_utf8_container_out' do
1926
- res = GIMarshallingTests.ghashtable_utf8_container_out
1927
- assert_equal({ '-1' => '1', '0' => '0', '1' => '-1', '2' => '-2' },
1928
- res.to_hash)
1929
- end
1930
-
1931
- it 'has a working function #ghashtable_utf8_container_return' do
1932
- res = GIMarshallingTests.ghashtable_utf8_container_return
1933
- assert_equal({ '-1' => '1', '0' => '0', '1' => '-1', '2' => '-2' },
1934
- res.to_hash)
1935
- end
1936
-
1937
- it 'has a working function #ghashtable_utf8_full_in' do
1938
- skip 'This function is defined in the header but not implemented'
1939
- end
1940
-
1941
- it 'has a working function #ghashtable_utf8_full_inout' do
1942
- hsh = { '-1' => '1', '0' => '0', '1' => '-1', '2' => '-2' }
1943
- res = GIMarshallingTests.ghashtable_utf8_full_inout hsh
1944
- assert_equal({ '-1' => '1', '0' => '0', '1' => '1' }, res.to_hash)
1945
- end
1946
-
1947
- it 'has a working function #ghashtable_utf8_full_out' do
1948
- res = GIMarshallingTests.ghashtable_utf8_full_out
1949
- assert_equal({ '-1' => '1', '0' => '0', '1' => '-1', '2' => '-2' },
1950
- res.to_hash)
1951
- end
1952
-
1953
- it 'has a working function #ghashtable_utf8_full_return' do
1954
- res = GIMarshallingTests.ghashtable_utf8_full_return
1955
- assert_equal({ '-1' => '1', '0' => '0', '1' => '-1', '2' => '-2' },
1956
- res.to_hash)
1957
- end
1958
-
1959
- it 'has a working function #ghashtable_utf8_none_in' do
1960
- hsh = { '-1' => '1', '0' => '0', '1' => '-1', '2' => '-2' }
1961
- GIMarshallingTests.ghashtable_utf8_none_in hsh
1962
- pass
1963
- end
1964
-
1965
- it 'has a working function #ghashtable_utf8_none_inout' do
1966
- hsh = { '-1' => '1', '0' => '0', '1' => '-1', '2' => '-2' }
1967
- res = GIMarshallingTests.ghashtable_utf8_none_inout hsh
1968
- assert_equal({ '-1' => '1', '0' => '0', '1' => '1' }, res.to_hash)
1969
- end
1970
-
1971
- it 'has a working function #ghashtable_utf8_none_out' do
1972
- res = GIMarshallingTests.ghashtable_utf8_none_out
1973
- assert_equal({ '-1' => '1', '0' => '0', '1' => '-1', '2' => '-2' },
1974
- res.to_hash)
1975
- end
1976
-
1977
- it 'has a working function #ghashtable_utf8_none_return' do
1978
- res = GIMarshallingTests.ghashtable_utf8_none_return
1979
- assert_equal({ '-1' => '1', '0' => '0', '1' => '-1', '2' => '-2' },
1980
- res.to_hash)
1981
- end
1982
-
1983
- it 'has a working function #glist_int_none_in' do
1984
- GIMarshallingTests.glist_int_none_in [-1, 0, 1, 2]
1985
- pass
1986
- end
1987
-
1988
- it 'has a working function #glist_int_none_return' do
1989
- res = GIMarshallingTests.glist_int_none_return
1990
- res.must_be :==, [-1, 0, 1, 2]
1991
- end
1992
-
1993
- it 'has a working function #glist_uint32_none_in' do
1994
- skip unless get_introspection_data 'GIMarshallingTests', 'glist_uint32_none_in'
1995
- GIMarshallingTests.glist_uint32_none_in [0, 0xffff_ffff]
1996
- pass
1997
- end
1998
-
1999
- it 'has a working function #glist_uint32_none_return' do
2000
- skip unless get_introspection_data 'GIMarshallingTests', 'glist_uint32_none_return'
2001
- res = GIMarshallingTests.glist_uint32_none_return
2002
- res.must_be :==, [0, 0xffff_ffff]
2003
- end
2004
-
2005
- it 'has a working function #glist_utf8_container_inout' do
2006
- res = GIMarshallingTests.glist_utf8_container_inout %w(0 1 2)
2007
- res.must_be :==, ['-2', '-1', '0', '1']
2008
- end
2009
-
2010
- it 'has a working function #glist_utf8_container_out' do
2011
- res = GIMarshallingTests.glist_utf8_container_out
2012
- res.must_be :==, %w(0 1 2)
2013
- end
2014
-
2015
- it 'has a working function #glist_utf8_container_return' do
2016
- res = GIMarshallingTests.glist_utf8_container_return
2017
- res.must_be :==, %w(0 1 2)
2018
- end
2019
-
2020
- it 'has a working function #glist_utf8_full_inout' do
2021
- res = GIMarshallingTests.glist_utf8_full_inout %w(0 1 2)
2022
- res.must_be :==, ['-2', '-1', '0', '1']
2023
- end
2024
-
2025
- it 'has a working function #glist_utf8_full_out' do
2026
- res = GIMarshallingTests.glist_utf8_full_out
2027
- res.must_be :==, %w(0 1 2)
2028
- end
2029
-
2030
- it 'has a working function #glist_utf8_full_return' do
2031
- res = GIMarshallingTests.glist_utf8_full_return
2032
- res.must_be :==, %w(0 1 2)
2033
- end
2034
-
2035
- it 'has a working function #glist_utf8_none_in' do
2036
- GIMarshallingTests.glist_utf8_none_in %w(0 1 2)
2037
- end
2038
-
2039
- it 'has a working function #glist_utf8_none_inout' do
2040
- res = GIMarshallingTests.glist_utf8_none_inout %w(0 1 2)
2041
- res.must_be :==, ['-2', '-1', '0', '1']
2042
- end
2043
-
2044
- it 'has a working function #glist_utf8_none_out' do
2045
- res = GIMarshallingTests.glist_utf8_none_out
2046
- res.must_be :==, %w(0 1 2)
2047
- end
2048
-
2049
- it 'has a working function #glist_utf8_none_return' do
2050
- res = GIMarshallingTests.glist_utf8_none_return
2051
- res.must_be :==, %w(0 1 2)
2052
- end
2053
-
2054
- it 'has a working function #gptrarray_utf8_container_inout' do
2055
- res = GIMarshallingTests.gptrarray_utf8_container_inout %w(0 1 2)
2056
- res.must_be :==, ['-2', '-1', '0', '1']
2057
- end
2058
-
2059
- it 'has a working function #gptrarray_utf8_container_out' do
2060
- res = GIMarshallingTests.gptrarray_utf8_container_out
2061
- res.must_be :==, %w(0 1 2)
2062
- end
2063
-
2064
- it 'has a working function #gptrarray_utf8_container_return' do
2065
- res = GIMarshallingTests.gptrarray_utf8_container_return
2066
- res.must_be :==, %w(0 1 2)
2067
- end
2068
-
2069
- it 'has a working function #gptrarray_utf8_full_inout' do
2070
- res = GIMarshallingTests.gptrarray_utf8_full_inout %w(0 1 2)
2071
- res.must_be :==, ['-2', '-1', '0', '1']
2072
- end
2073
-
2074
- it 'has a working function #gptrarray_utf8_full_out' do
2075
- res = GIMarshallingTests.gptrarray_utf8_full_out
2076
- res.must_be :==, %w(0 1 2)
2077
- end
2078
-
2079
- it 'has a working function #gptrarray_utf8_full_return' do
2080
- res = GIMarshallingTests.gptrarray_utf8_full_return
2081
- res.must_be :==, %w(0 1 2)
2082
- end
2083
-
2084
- it 'has a working function #gptrarray_utf8_none_in' do
2085
- GIMarshallingTests.gptrarray_utf8_none_in %w(0 1 2)
2086
- end
2087
-
2088
- it 'has a working function #gptrarray_utf8_none_inout' do
2089
- res = GIMarshallingTests.gptrarray_utf8_none_inout %w(0 1 2)
2090
- res.must_be :==, ['-2', '-1', '0', '1']
2091
- end
2092
-
2093
- it 'has a working function #gptrarray_utf8_none_out' do
2094
- res = GIMarshallingTests.gptrarray_utf8_none_out
2095
- res.must_be :==, %w(0 1 2)
2096
- end
2097
-
2098
- it 'has a working function #gptrarray_utf8_none_return' do
2099
- res = GIMarshallingTests.gptrarray_utf8_none_return
2100
- res.must_be :==, %w(0 1 2)
2101
- end
2102
-
2103
- it 'has a working function #gslist_int_none_in' do
2104
- GIMarshallingTests.gslist_int_none_in [-1, 0, 1, 2]
2105
- pass
2106
- end
2107
-
2108
- it 'has a working function #gslist_int_none_return' do
2109
- res = GIMarshallingTests.gslist_int_none_return
2110
- res.must_be :==, [-1, 0, 1, 2]
2111
- end
2112
-
2113
- it 'has a working function #gslist_utf8_container_inout' do
2114
- res = GIMarshallingTests.gslist_utf8_container_inout %w(0 1 2)
2115
- res.must_be :==, ['-2', '-1', '0', '1']
2116
- end
2117
-
2118
- it 'has a working function #gslist_utf8_container_out' do
2119
- res = GIMarshallingTests.gslist_utf8_container_out
2120
- res.must_be :==, %w(0 1 2)
2121
- end
2122
-
2123
- it 'has a working function #gslist_utf8_container_return' do
2124
- res = GIMarshallingTests.gslist_utf8_container_return
2125
- res.must_be :==, %w(0 1 2)
2126
- end
2127
-
2128
- it 'has a working function #gslist_utf8_full_inout' do
2129
- res = GIMarshallingTests.gslist_utf8_full_inout %w(0 1 2)
2130
- res.must_be :==, ['-2', '-1', '0', '1']
2131
- end
2132
-
2133
- it 'has a working function #gslist_utf8_full_out' do
2134
- res = GIMarshallingTests.gslist_utf8_full_out
2135
- res.must_be :==, %w(0 1 2)
2136
- end
2137
-
2138
- it 'has a working function #gslist_utf8_full_return' do
2139
- res = GIMarshallingTests.gslist_utf8_full_return
2140
- res.must_be :==, %w(0 1 2)
2141
- end
2142
-
2143
- it 'has a working function #gslist_utf8_none_in' do
2144
- GIMarshallingTests.gslist_utf8_none_in %w(0 1 2)
2145
- pass
2146
- end
2147
-
2148
- it 'has a working function #gslist_utf8_none_inout' do
2149
- res = GIMarshallingTests.gslist_utf8_none_inout %w(0 1 2)
2150
- res.must_be :==, ['-2', '-1', '0', '1']
2151
- end
2152
-
2153
- it 'has a working function #gslist_utf8_none_out' do
2154
- res = GIMarshallingTests.gslist_utf8_none_out
2155
- res.must_be :==, %w(0 1 2)
2156
- end
2157
-
2158
- it 'has a working function #gslist_utf8_none_return' do
2159
- res = GIMarshallingTests.gslist_utf8_none_return
2160
- res.must_be :==, %w(0 1 2)
2161
- end
2162
-
2163
- it 'has a working function #gstrv_in' do
2164
- GIMarshallingTests.gstrv_in %w(0 1 2)
2165
- pass
2166
- end
2167
-
2168
- it 'has a working function #gstrv_inout' do
2169
- res = GIMarshallingTests.gstrv_inout %w(0 1 2)
2170
- res.must_be :==, ['-1', '0', '1', '2']
2171
- end
2172
-
2173
- it 'has a working function #gstrv_out' do
2174
- res = GIMarshallingTests.gstrv_out
2175
- res.must_be :==, %w(0 1 2)
2176
- end
2177
-
2178
- it 'has a working function #gstrv_return' do
2179
- res = GIMarshallingTests.gstrv_return
2180
- res.must_be :==, %w(0 1 2)
2181
- end
2182
-
2183
- it 'has a working function #gtype_in' do
2184
- GIMarshallingTests.gtype_in GObject::TYPE_NONE
2185
- pass
2186
- end
2187
-
2188
- it 'has a working function #gtype_inout' do
2189
- res = GIMarshallingTests.gtype_inout GObject::TYPE_NONE
2190
- res.must_equal GObject::TYPE_INT
2191
- end
2192
-
2193
- it 'has a working function #gtype_out' do
2194
- res = GIMarshallingTests.gtype_out
2195
- res.must_equal GObject::TYPE_NONE
2196
- end
2197
-
2198
- it 'has a working function #gtype_return' do
2199
- res = GIMarshallingTests.gtype_return
2200
- res.must_equal GObject::TYPE_NONE
2201
- end
2202
-
2203
- it 'has a working function #gtype_string_in' do
2204
- GIMarshallingTests.gtype_string_in GObject::TYPE_STRING
2205
- pass
2206
- end
2207
-
2208
- it 'has a working function #gtype_string_out' do
2209
- res = GIMarshallingTests.gtype_string_out
2210
- res.must_equal GObject::TYPE_STRING
2211
- end
2212
-
2213
- it 'has a working function #gtype_string_return' do
2214
- res = GIMarshallingTests.gtype_string_return
2215
- res.must_equal GObject::TYPE_STRING
2216
- end
2217
-
2218
- it 'has a working function #gvalue_flat_array' do
2219
- GIMarshallingTests.gvalue_flat_array [42, '42', true]
2220
- pass
2221
- end
2222
-
2223
- it 'has a working function #gvalue_flat_array_round_trip' do
2224
- result = GIMarshallingTests.gvalue_flat_array_round_trip 42, '42', true
2225
- arr = result.to_a
2226
- arr[0].get_value.must_equal 42
2227
- arr[1].get_value.must_equal '42'
2228
- arr[2].get_value.must_equal true
2229
- end
2230
-
2231
- it 'has a working function #gvalue_in' do
2232
- GIMarshallingTests.gvalue_in GObject::Value.wrap_ruby_value(42)
2233
- GIMarshallingTests.gvalue_in 42
2234
- pass
2235
- end
2236
-
2237
- it 'has a working function #gvalue_in_enum' do
2238
- gv = GObject::Value.new
2239
- gv.init GIMarshallingTests::GEnum.gtype
2240
- gv.set_enum GIMarshallingTests::GEnum[:value3]
2241
- GIMarshallingTests.gvalue_in_enum gv
2242
- pass
2243
- end
2244
-
2245
- it 'has a working function #gvalue_in_with_modification' do
2246
- skip unless get_introspection_data 'GIMarshallingTests', 'gvalue_in_with_modification'
2247
- gv = GObject::Value.wrap_ruby_value(42)
2248
- GIMarshallingTests.gvalue_in_with_modification gv
2249
- gv.get_value.must_equal 24
2250
- end
2251
-
2252
- it 'has a working function #gvalue_in_with_type' do
2253
- gv = GObject::Value.new
2254
- gv.init GIMarshallingTests::SubSubObject.gtype
2255
- GIMarshallingTests.gvalue_in_with_type gv, GIMarshallingTests::Object.gtype
2256
- end
2257
-
2258
- it 'has a working function #gvalue_inout' do
2259
- res = GIMarshallingTests.gvalue_inout GObject::Value.wrap_ruby_value(42)
2260
- res.must_equal '42'
2261
-
2262
- res = GIMarshallingTests.gvalue_inout 42
2263
- res.must_equal '42'
2264
- end
2265
-
2266
- it 'has a working function #gvalue_int64_in' do
2267
- skip unless get_introspection_data 'GIMarshallingTests', 'gvalue_int64_in'
2268
- gv = GObject::Value.new
2269
- gv.init GObject::TYPE_INT64
2270
- gv.set_value 0x7fff_ffff_ffff_ffff
2271
- GIMarshallingTests.gvalue_int64_in gv
2272
- pass
2273
- end
2274
-
2275
- it 'has a working function #gvalue_int64_out' do
2276
- skip unless get_introspection_data 'GIMarshallingTests', 'gvalue_int64_out'
2277
- gv = GIMarshallingTests.gvalue_int64_out
2278
- gv.must_equal 0x7fff_ffff_ffff_ffff
2279
- end
2280
-
2281
- it 'has a working function #gvalue_out' do
2282
- res = GIMarshallingTests.gvalue_out
2283
- res.must_equal 42
2284
- end
2285
-
2286
- it 'has a working function #gvalue_out_caller_allocates' do
2287
- skip unless get_introspection_data 'GIMarshallingTests', 'gvalue_out_caller_allocates'
2288
- res = GIMarshallingTests.gvalue_out_caller_allocates
2289
- res.must_equal 42
2290
- end
2291
-
2292
- it 'has a working function #gvalue_return' do
2293
- res = GIMarshallingTests.gvalue_return
2294
- res.must_equal 42
2295
- end
2296
-
2297
- it 'has a working function #init_function' do
2298
- res, arr = GIMarshallingTests.init_function %w(foo bar baz)
2299
- res.must_equal true
2300
- arr.must_be :==, %w(foo bar)
2301
- end
2302
-
2303
- it 'has a working function #int16_in_max' do
2304
- GIMarshallingTests.int16_in_max 0x7fff
2305
- pass
2306
- end
2307
-
2308
- it 'has a working function #int16_in_min' do
2309
- GIMarshallingTests.int16_in_min(-0x8000)
2310
- pass
2311
- end
2312
-
2313
- it 'has a working function #int16_inout_max_min' do
2314
- res = GIMarshallingTests.int16_inout_max_min 0x7fff
2315
- assert_equal res, -0x8000
2316
- end
2317
-
2318
- it 'has a working function #int16_inout_min_max' do
2319
- res = GIMarshallingTests.int16_inout_min_max(-0x8000)
2320
- assert_equal 0x7fff, res
2321
- end
2322
-
2323
- it 'has a working function #int16_out_max' do
2324
- res = GIMarshallingTests.int16_out_max
2325
- assert_equal 0x7fff, res
2326
- end
2327
-
2328
- it 'has a working function #int16_out_min' do
2329
- res = GIMarshallingTests.int16_out_min
2330
- assert_equal(-0x8000, res)
2331
- end
2332
-
2333
- it 'has a working function #int16_return_max' do
2334
- res = GIMarshallingTests.int16_return_max
2335
- assert_equal 0x7fff, res
2336
- end
2337
-
2338
- it 'has a working function #int16_return_min' do
2339
- res = GIMarshallingTests.int16_return_min
2340
- assert_equal(-0x8000, res)
2341
- end
2342
-
2343
- it 'has a working function #int32_in_max' do
2344
- GIMarshallingTests.int32_in_max 0x7fffffff
2345
- pass
2346
- end
2347
-
2348
- it 'has a working function #int32_in_min' do
2349
- GIMarshallingTests.int32_in_min(-0x80000000)
2350
- pass
2351
- end
2352
-
2353
- it 'has a working function #int32_inout_max_min' do
2354
- res = GIMarshallingTests.int32_inout_max_min 0x7fffffff
2355
- assert_equal(-0x80000000, res)
2356
- end
2357
-
2358
- it 'has a working function #int32_inout_min_max' do
2359
- res = GIMarshallingTests.int32_inout_min_max(-0x80000000)
2360
- assert_equal 0x7fffffff, res
2361
- end
2362
-
2363
- it 'has a working function #int32_out_max' do
2364
- res = GIMarshallingTests.int32_out_max
2365
- assert_equal 0x7fffffff, res
2366
- end
2367
-
2368
- it 'has a working function #int32_out_min' do
2369
- res = GIMarshallingTests.int32_out_min
2370
- assert_equal(-0x80000000, res)
2371
- end
2372
-
2373
- it 'has a working function #int32_return_max' do
2374
- res = GIMarshallingTests.int32_return_max
2375
- assert_equal 0x7fffffff, res
2376
- end
2377
-
2378
- it 'has a working function #int32_return_min' do
2379
- res = GIMarshallingTests.int32_return_min
2380
- assert_equal(-0x80000000, res)
2381
- end
2382
-
2383
- it 'has a working function #int64_in_max' do
2384
- GIMarshallingTests.int64_in_max 0x7fffffffffffffff
2385
- pass
2386
- end
2387
-
2388
- it 'has a working function #int64_in_min' do
2389
- GIMarshallingTests.int64_in_min(-0x8000000000000000)
2390
- pass
2391
- end
2392
-
2393
- it 'has a working function #int64_inout_max_min' do
2394
- res = GIMarshallingTests.int64_inout_max_min 0x7fffffffffffffff
2395
- assert_equal(-0x8000000000000000, res)
2396
- end
2397
-
2398
- it 'has a working function #int64_inout_min_max' do
2399
- res = GIMarshallingTests.int64_inout_min_max(-0x8000000000000000)
2400
- assert_equal 0x7fffffffffffffff, res
2401
- end
2402
-
2403
- it 'has a working function #int64_out_max' do
2404
- res = GIMarshallingTests.int64_out_max
2405
- assert_equal 0x7fffffffffffffff, res
2406
- end
2407
-
2408
- it 'has a working function #int64_out_min' do
2409
- res = GIMarshallingTests.int64_out_min
2410
- assert_equal(-0x8000000000000000, res)
2411
- end
2412
-
2413
- it 'has a working function #int64_return_max' do
2414
- res = GIMarshallingTests.int64_return_max
2415
- assert_equal 0x7fffffffffffffff, res
2416
- end
2417
-
2418
- it 'has a working function #int64_return_min' do
2419
- res = GIMarshallingTests.int64_return_min
2420
- assert_equal(-0x8000000000000000, res)
2421
- end
2422
-
2423
- it 'has a working function #int8_in_max' do
2424
- GIMarshallingTests.int8_in_max 0x7f
2425
- pass
2426
- end
2427
-
2428
- it 'has a working function #int8_in_min' do
2429
- GIMarshallingTests.int8_in_min(-0x80)
2430
- pass
2431
- end
2432
-
2433
- it 'has a working function #int8_inout_max_min' do
2434
- res = GIMarshallingTests.int8_inout_max_min 0x7f
2435
- assert_equal(-0x80, res)
2436
- end
2437
-
2438
- it 'has a working function #int8_inout_min_max' do
2439
- res = GIMarshallingTests.int8_inout_min_max(-0x80)
2440
- assert_equal 0x7f, res
2441
- end
2442
-
2443
- it 'has a working function #int8_out_max' do
2444
- res = GIMarshallingTests.int8_out_max
2445
- assert_equal 0x7f, res
2446
- end
2447
-
2448
- it 'has a working function #int8_out_min' do
2449
- res = GIMarshallingTests.int8_out_min
2450
- assert_equal(-0x80, res)
2451
- end
2452
-
2453
- it 'has a working function #int8_return_max' do
2454
- res = GIMarshallingTests.int8_return_max
2455
- assert_equal 0x7f, res
2456
- end
2457
-
2458
- it 'has a working function #int8_return_min' do
2459
- res = GIMarshallingTests.int8_return_min
2460
- assert_equal(-0x80, res)
2461
- end
2462
-
2463
- it 'has a working function #int_in_max' do
2464
- GIMarshallingTests.int_in_max 0x7fffffff
2465
- pass
2466
- end
2467
-
2468
- it 'has a working function #int_in_min' do
2469
- GIMarshallingTests.int_in_min(-0x80000000)
2470
- pass
2471
- end
2472
-
2473
- it 'has a working function #int_inout_max_min' do
2474
- res = GIMarshallingTests.int_inout_max_min 0x7fffffff
2475
- assert_equal(-0x80000000, res)
2476
- end
2477
-
2478
- it 'has a working function #int_inout_min_max' do
2479
- res = GIMarshallingTests.int_inout_min_max(-0x80000000)
2480
- assert_equal 0x7fffffff, res
2481
- end
2482
-
2483
- it 'has a working function #int_one_in_utf8_two_in_one_allows_none' do
2484
- skip unless get_introspection_data('GIMarshallingTests',
2485
- 'int_one_in_utf8_two_in_one_allows_none')
2486
- GIMarshallingTests.int_one_in_utf8_two_in_one_allows_none 1, '2', '3'
2487
- GIMarshallingTests.int_one_in_utf8_two_in_one_allows_none 1, nil, '3'
2488
- pass
2489
- end
2490
-
2491
- it 'has a working function #int_out_max' do
2492
- res = GIMarshallingTests.int_out_max
2493
- assert_equal 0x7fffffff, res
2494
- end
2495
-
2496
- it 'has a working function #int_out_min' do
2497
- res = GIMarshallingTests.int_out_min
2498
- assert_equal(-0x80000000, res)
2499
- end
2500
-
2501
- it 'has a working function #int_out_out' do
2502
- res = GIMarshallingTests.int_out_out
2503
- assert_equal [6, 7], res
2504
- end
2505
-
2506
- it 'has a working function #int_return_max' do
2507
- res = GIMarshallingTests.int_return_max
2508
- assert_equal 0x7fffffff, res
2509
- end
2510
-
2511
- it 'has a working function #int_return_min' do
2512
- res = GIMarshallingTests.int_return_min
2513
- assert_equal(-0x80000000, res)
2514
- end
2515
-
2516
- it 'has a working function #int_return_out' do
2517
- res = GIMarshallingTests.int_return_out
2518
- assert_equal [6, 7], res
2519
- end
2520
-
2521
- it 'has a working function #int_three_in_three_out' do
2522
- res = GIMarshallingTests.int_three_in_three_out 4, 5, 6
2523
- assert_equal [4, 5, 6], res
2524
- end
2525
-
2526
- it 'has a working function #int_two_in_utf8_two_in_with_allow_none' do
2527
- skip unless get_introspection_data('GIMarshallingTests',
2528
- 'int_two_in_utf8_two_in_with_allow_none')
2529
- GIMarshallingTests.int_two_in_utf8_two_in_with_allow_none 1, 2, '3', '4'
2530
- GIMarshallingTests.int_two_in_utf8_two_in_with_allow_none 1, 2, nil, nil
2531
- pass
2532
- end
2533
-
2534
- it 'has a working function #long_in_max' do
2535
- GIMarshallingTests.long_in_max max_long
2536
- pass
2537
- end
2538
-
2539
- it 'has a working function #long_in_min' do
2540
- GIMarshallingTests.long_in_min min_long
2541
- pass
2542
- end
2543
-
2544
- it 'has a working function #long_inout_max_min' do
2545
- res = GIMarshallingTests.long_inout_max_min max_long
2546
- assert_equal min_long, res
2547
- end
2548
-
2549
- it 'has a working function #long_inout_min_max' do
2550
- res = GIMarshallingTests.long_inout_min_max min_long
2551
- assert_equal max_long, res
2552
- end
2553
-
2554
- it 'has a working function #long_out_max' do
2555
- res = GIMarshallingTests.long_out_max
2556
- assert_equal max_long, res
2557
- end
2558
-
2559
- it 'has a working function #long_out_min' do
2560
- res = GIMarshallingTests.long_out_min
2561
- assert_equal min_long, res
2562
- end
2563
-
2564
- it 'has a working function #long_return_max' do
2565
- res = GIMarshallingTests.long_return_max
2566
- assert_equal max_long, res
2567
- end
2568
-
2569
- it 'has a working function #long_return_min' do
2570
- res = GIMarshallingTests.long_return_min
2571
- assert_equal min_long, res
2572
- end
2573
-
2574
- it 'has a working function #multi_array_key_value_in' do
2575
- keys = %w(one two three)
2576
- values = [1, 2, 3].map { |val| GObject::Value.wrap_ruby_value val }
2577
- GIMarshallingTests.multi_array_key_value_in keys, values
2578
- end
2579
-
2580
- it 'has a working function #no_type_flags_in' do
2581
- GIMarshallingTests.no_type_flags_in value2: true
2582
- pass
2583
- end
2584
-
2585
- it 'has a working function #no_type_flags_in_zero' do
2586
- GIMarshallingTests.no_type_flags_in_zero 0
2587
- pass
2588
- end
2589
-
2590
- it 'has a working function #no_type_flags_inout' do
2591
- res = GIMarshallingTests.no_type_flags_inout value2: true
2592
- res.must_equal(value1: true)
2593
- end
2594
-
2595
- it 'has a working function #no_type_flags_out' do
2596
- res = GIMarshallingTests.no_type_flags_out
2597
- res.must_equal(value2: true)
2598
- end
2599
-
2600
- it 'has a working function #no_type_flags_returnv' do
2601
- res = GIMarshallingTests.no_type_flags_returnv
2602
- res.must_equal(value2: true)
2603
- end
2604
-
2605
- it 'has a working function #overrides_struct_returnv' do
2606
- res = GIMarshallingTests.overrides_struct_returnv
2607
- res.must_be_instance_of GIMarshallingTests::OverridesStruct
2608
- end
2609
-
2610
- it 'has a working function #param_spec_in_bool' do
2611
- # GLib minor version and GObjectIntrospection minor version should be in sync
2612
- skip 'param_spec_in_bool tests the wrong type' if GLib::MINOR_VERSION < 42
2613
-
2614
- ps = GObject.param_spec_boolean 'mybool', 'nick', 'blurb', true, :readable
2615
- GIMarshallingTests.param_spec_in_bool ps
2616
- pass
2617
- end
2618
-
2619
- it 'has a working function #param_spec_out' do
2620
- skip unless get_introspection_data 'GIMarshallingTests', 'param_spec_out'
2621
- res = GIMarshallingTests.param_spec_out
2622
- res.value_type.must_equal GObject::TYPE_STRING
2623
- res.get_name.must_equal 'test-param'
2624
- end
2625
-
2626
- it 'has a working function #param_spec_return' do
2627
- skip unless get_introspection_data 'GIMarshallingTests', 'param_spec_return'
2628
- res = GIMarshallingTests.param_spec_return
2629
- res.value_type.must_equal GObject::TYPE_STRING
2630
- res.get_name.must_equal 'test-param'
2631
- end
2632
-
2633
- it 'has a working function #pointer_in_return' do
2634
- ptr = FFI::MemoryPointer.new 1
2635
- res = GIMarshallingTests.pointer_in_return ptr
2636
- assert_equal ptr.address, res.address
2637
- end
2638
-
2639
- it 'has a working function #pointer_struct_get_type' do
2640
- res = GIMarshallingTests.pointer_struct_get_type
2641
- gtype = GObject.type_from_name 'GIMarshallingTestsPointerStruct'
2642
- assert_equal gtype, res
2643
- end
2644
-
2645
- it 'has a working function #pointer_struct_returnv' do
2646
- res = GIMarshallingTests.pointer_struct_returnv
2647
- assert_instance_of GIMarshallingTests::PointerStruct, res
2648
- assert_equal 42, res.long_
2649
- end
2650
-
2651
- it 'has a working function #return_gvalue_flat_array' do
2652
- result = GIMarshallingTests.return_gvalue_flat_array
2653
- arr = result.to_a
2654
- arr[0].get_value.must_equal 42
2655
- arr[1].get_value.must_equal '42'
2656
- arr[2].get_value.must_equal true
2657
- end
2658
-
2659
- it 'has a working function #short_in_max' do
2660
- GIMarshallingTests.short_in_max 0x7fff
2661
- pass
2662
- end
2663
-
2664
- it 'has a working function #short_in_min' do
2665
- GIMarshallingTests.short_in_min(-0x8000)
2666
- pass
2667
- end
2668
-
2669
- it 'has a working function #short_inout_max_min' do
2670
- res = GIMarshallingTests.short_inout_max_min 0x7fff
2671
- assert_equal(-0x8000, res)
2672
- end
2673
-
2674
- it 'has a working function #short_inout_min_max' do
2675
- res = GIMarshallingTests.short_inout_min_max(-0x8000)
2676
- assert_equal 0x7fff, res
2677
- end
2678
-
2679
- it 'has a working function #short_out_max' do
2680
- res = GIMarshallingTests.short_out_max
2681
- assert_equal 0x7fff, res
2682
- end
2683
-
2684
- it 'has a working function #short_out_min' do
2685
- res = GIMarshallingTests.short_out_min
2686
- assert_equal(-0x8000, res)
2687
- end
2688
-
2689
- it 'has a working function #short_return_max' do
2690
- res = GIMarshallingTests.short_return_max
2691
- assert_equal 0x7fff, res
2692
- end
2693
-
2694
- it 'has a working function #short_return_min' do
2695
- res = GIMarshallingTests.short_return_min
2696
- assert_equal(-0x8000, res)
2697
- end
2698
-
2699
- it 'has a working function #simple_struct_returnv' do
2700
- res = GIMarshallingTests.simple_struct_returnv
2701
- assert_instance_of GIMarshallingTests::SimpleStruct, res
2702
- assert_equal 6, res.long_
2703
- assert_equal 7, res.int8
2704
- end
2705
-
2706
- it 'has a working function #size_in' do
2707
- GIMarshallingTests.size_in max_size_t
2708
- end
2709
-
2710
- it 'has a working function #size_inout' do
2711
- res = GIMarshallingTests.size_inout max_size_t
2712
- assert_equal 0, res
2713
- end
2714
-
2715
- it 'has a working function #size_out' do
2716
- res = GIMarshallingTests.size_out
2717
- assert_equal max_size_t, res
2718
- end
2719
-
2720
- it 'has a working function #size_return' do
2721
- res = GIMarshallingTests.size_return
2722
- assert_equal max_size_t, res
2723
- end
2724
-
2725
- it 'has a working function #ssize_in_max' do
2726
- GIMarshallingTests.ssize_in_max max_ssize_t
2727
- pass
2728
- end
2729
-
2730
- it 'has a working function #ssize_in_min' do
2731
- GIMarshallingTests.ssize_in_min min_ssize_t
2732
- pass
2733
- end
2734
-
2735
- it 'has a working function #ssize_inout_max_min' do
2736
- res = GIMarshallingTests.ssize_inout_max_min max_ssize_t
2737
- assert_equal min_ssize_t, res
2738
- end
2739
-
2740
- it 'has a working function #ssize_inout_min_max' do
2741
- res = GIMarshallingTests.ssize_inout_min_max min_ssize_t
2742
- assert_equal max_ssize_t, res
2743
- end
2744
-
2745
- it 'has a working function #ssize_out_max' do
2746
- res = GIMarshallingTests.ssize_out_max
2747
- assert_equal max_ssize_t, res
2748
- end
2749
-
2750
- it 'has a working function #ssize_out_min' do
2751
- res = GIMarshallingTests.ssize_out_min
2752
- assert_equal min_ssize_t, res
2753
- end
2754
-
2755
- it 'has a working function #ssize_return_max' do
2756
- res = GIMarshallingTests.ssize_return_max
2757
- assert_equal max_ssize_t, res
2758
- end
2759
-
2760
- it 'has a working function #ssize_return_min' do
2761
- res = GIMarshallingTests.ssize_return_min
2762
- assert_equal min_ssize_t, res
2763
- end
2764
-
2765
- it 'has a working function #test_interface_test_int8_in' do
2766
- derived_klass.class_eval { include GIMarshallingTests::Interface }
2767
- instance = make_derived_instance do |info|
2768
- info.install_vfunc_implementation :test_int8_in, proc { |obj, in_| obj.int = in_ }
2769
- end
2770
- instance.int.must_equal 0
2771
- GIMarshallingTests.test_interface_test_int8_in instance, 8
2772
- instance.int.must_equal 8
2773
- end
2774
-
2775
- it 'has a working function #time_t_in' do
2776
- GIMarshallingTests.time_t_in 1_234_567_890
2777
- pass
2778
- end
2779
-
2780
- it 'has a working function #time_t_inout' do
2781
- res = GIMarshallingTests.time_t_inout 1_234_567_890
2782
- assert_equal 0, res
2783
- end
2784
-
2785
- it 'has a working function #time_t_out' do
2786
- res = GIMarshallingTests.time_t_out
2787
- assert_equal 1_234_567_890, res
2788
- end
2789
-
2790
- it 'has a working function #time_t_return' do
2791
- res = GIMarshallingTests.time_t_return
2792
- assert_equal 1_234_567_890, res
2793
- end
2794
-
2795
- it 'has a working function #uint16_in' do
2796
- GIMarshallingTests.uint16_in 0xffff
2797
- pass
2798
- end
2799
-
2800
- it 'has a working function #uint16_inout' do
2801
- res = GIMarshallingTests.uint16_inout 0xffff
2802
- assert_equal 0, res
2803
- end
2804
-
2805
- it 'has a working function #uint16_out' do
2806
- res = GIMarshallingTests.uint16_out
2807
- assert_equal 0xffff, res
2808
- end
2809
-
2810
- it 'has a working function #uint16_return' do
2811
- res = GIMarshallingTests.uint16_return
2812
- assert_equal 0xffff, res
2813
- end
2814
-
2815
- it 'has a working function #uint32_in' do
2816
- GIMarshallingTests.uint32_in 0xffffffff
2817
- end
2818
-
2819
- it 'has a working function #uint32_inout' do
2820
- res = GIMarshallingTests.uint32_inout 0xffffffff
2821
- assert_equal 0, res
2822
- end
2823
-
2824
- it 'has a working function #uint32_out' do
2825
- res = GIMarshallingTests.uint32_out
2826
- assert_equal 0xffffffff, res
2827
- end
2828
-
2829
- it 'has a working function #uint32_return' do
2830
- res = GIMarshallingTests.uint32_return
2831
- assert_equal 0xffffffff, res
2832
- end
2833
-
2834
- it 'has a working function #uint64_in' do
2835
- GIMarshallingTests.uint64_in 0xffff_ffff_ffff_ffff
2836
- pass
2837
- end
2838
-
2839
- it 'has a working function #uint64_inout' do
2840
- res = GIMarshallingTests.uint64_inout 0xffff_ffff_ffff_ffff
2841
- assert_equal 0, res
2842
- end
2843
-
2844
- it 'has a working function #uint64_out' do
2845
- res = GIMarshallingTests.uint64_out
2846
- assert_equal 0xffff_ffff_ffff_ffff, res
2847
- end
2848
-
2849
- it 'has a working function #uint64_return' do
2850
- res = GIMarshallingTests.uint64_return
2851
- assert_equal 0xffff_ffff_ffff_ffff, res
2852
- end
2853
-
2854
- it 'has a working function #uint8_in' do
2855
- GIMarshallingTests.uint8_in 0xff
2856
- end
2857
-
2858
- it 'has a working function #uint8_inout' do
2859
- res = GIMarshallingTests.uint8_inout 0xff
2860
- assert_equal 0, res
2861
- end
2862
-
2863
- it 'has a working function #uint8_out' do
2864
- res = GIMarshallingTests.uint8_out
2865
- assert_equal 0xff, res
2866
- end
2867
-
2868
- it 'has a working function #uint8_return' do
2869
- res = GIMarshallingTests.uint8_return
2870
- assert_equal 0xff, res
2871
- end
2872
-
2873
- it 'has a working function #uint_in' do
2874
- GIMarshallingTests.uint_in max_uint
2875
- pass
2876
- end
2877
-
2878
- it 'has a working function #uint_inout' do
2879
- res = GIMarshallingTests.uint_inout max_uint
2880
- assert_equal 0, res
2881
- end
2882
-
2883
- it 'has a working function #uint_out' do
2884
- res = GIMarshallingTests.uint_out
2885
- assert_equal max_uint, res
2886
- end
2887
-
2888
- it 'has a working function #uint_return' do
2889
- res = GIMarshallingTests.uint_return
2890
- assert_equal max_uint, res
2891
- end
2892
-
2893
- it 'has a working function #ulong_in' do
2894
- GIMarshallingTests.ulong_in max_ulong
2895
- end
2896
-
2897
- it 'has a working function #ulong_inout' do
2898
- res = GIMarshallingTests.ulong_inout max_ulong
2899
- assert_equal 0, res
2900
- end
2901
-
2902
- it 'has a working function #ulong_out' do
2903
- res = GIMarshallingTests.ulong_out
2904
- assert_equal max_ulong, res
2905
- end
2906
-
2907
- it 'has a working function #ulong_return' do
2908
- res = GIMarshallingTests.ulong_return
2909
- assert_equal max_ulong, res
2910
- end
2911
-
2912
- it 'has a working function #union_inout' do
2913
- skip 'This function is defined in the header but not implemented'
2914
- end
2915
-
2916
- it 'has a working function #union_out' do
2917
- skip 'This function is defined in the header but not implemented'
2918
- end
2919
-
2920
- it 'has a working function #union_returnv' do
2921
- res = GIMarshallingTests.union_returnv
2922
- assert_instance_of GIMarshallingTests::Union, res
2923
- assert_equal 42, res.long_
2924
- end
2925
-
2926
- it 'has a working function #ushort_in' do
2927
- GIMarshallingTests.ushort_in max_ushort
2928
- pass
2929
- end
2930
-
2931
- it 'has a working function #ushort_inout' do
2932
- res = GIMarshallingTests.ushort_inout max_ushort
2933
- assert_equal 0, res
2934
- end
2935
-
2936
- it 'has a working function #ushort_out' do
2937
- res = GIMarshallingTests.ushort_out
2938
- assert_equal max_ushort, res
2939
- end
2940
-
2941
- it 'has a working function #ushort_return' do
2942
- res = GIMarshallingTests.ushort_return
2943
- assert_equal max_ushort, res
2944
- end
2945
-
2946
- it 'has a working function #utf8_as_uint8array_in' do
2947
- skip unless get_introspection_data 'GIMarshallingTests', 'utf8_as_uint8array_in'
2948
- GIMarshallingTests.utf8_as_uint8array_in GIMarshallingTests::CONSTANT_UTF8.bytes.to_a
2949
- pass
2950
- end
2951
-
2952
- it 'has a working function #utf8_dangling_out' do
2953
- res = GIMarshallingTests.utf8_dangling_out
2954
- assert_nil res
2955
- end
2956
-
2957
- it 'has a working function #utf8_full_in' do
2958
- skip 'This function is defined in the header but not implemented'
2959
- end
2960
-
2961
- it 'has a working function #utf8_full_inout' do
2962
- res = GIMarshallingTests.utf8_full_inout 'const ♥ utf8'
2963
- assert_equal '', res
2964
- end
2965
-
2966
- it 'has a working function #utf8_full_out' do
2967
- res = GIMarshallingTests.utf8_full_out
2968
- assert_equal 'const ♥ utf8', res
2969
- end
2970
-
2971
- it 'has a working function #utf8_full_return' do
2972
- res = GIMarshallingTests.utf8_full_return
2973
- assert_equal 'const ♥ utf8', res
2974
- end
2975
-
2976
- it 'has a working function #utf8_none_in' do
2977
- GIMarshallingTests.utf8_none_in 'const ♥ utf8'
2978
- pass
2979
- end
2980
-
2981
- it 'has a working function #utf8_none_inout' do
2982
- res = GIMarshallingTests.utf8_none_inout 'const ♥ utf8'
2983
- assert_equal '', res
2984
- end
2985
-
2986
- it 'has a working function #utf8_none_out' do
2987
- res = GIMarshallingTests.utf8_none_out
2988
- assert_equal 'const ♥ utf8', res
2989
- end
2990
-
2991
- it 'has a working function #utf8_none_return' do
2992
- res = GIMarshallingTests.utf8_none_return
2993
- assert_equal 'const ♥ utf8', res
2994
- end
2995
- end