gir_ffi 0.14.1 → 0.15.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Changelog.md +21 -0
- data/Gemfile +6 -4
- data/README.md +4 -4
- data/Rakefile +5 -5
- data/lib/ffi-glib/array.rb +14 -4
- data/lib/ffi-glib/byte_array.rb +7 -2
- data/lib/ffi-glib/container_class_methods.rb +1 -1
- data/lib/ffi-glib/error.rb +1 -1
- data/lib/ffi-glib/hash_table.rb +3 -3
- data/lib/ffi-glib/list.rb +1 -1
- data/lib/ffi-glib/list_methods.rb +1 -1
- data/lib/ffi-glib/main_loop.rb +3 -3
- data/lib/ffi-glib/ptr_array.rb +30 -8
- data/lib/ffi-glib/s_list.rb +1 -1
- data/lib/ffi-glib/variant.rb +1 -1
- data/lib/ffi-glib.rb +16 -16
- data/lib/ffi-gobject/object.rb +23 -32
- data/lib/ffi-gobject/param_spec.rb +1 -1
- data/lib/ffi-gobject/ruby_closure.rb +2 -2
- data/lib/ffi-gobject/value.rb +37 -28
- data/lib/ffi-gobject.rb +13 -13
- data/lib/ffi-gobject_introspection/gobject_type_init.rb +2 -2
- data/lib/ffi-gobject_introspection/i_arg_info.rb +2 -2
- data/lib/ffi-gobject_introspection/i_base_info.rb +27 -17
- data/lib/ffi-gobject_introspection/i_callable_info.rb +4 -4
- data/lib/ffi-gobject_introspection/i_constant_info.rb +2 -2
- data/lib/ffi-gobject_introspection/i_enum_info.rb +1 -0
- data/lib/ffi-gobject_introspection/i_field_info.rb +1 -1
- data/lib/ffi-gobject_introspection/i_function_info.rb +1 -1
- data/lib/ffi-gobject_introspection/i_interface_info.rb +1 -1
- data/lib/ffi-gobject_introspection/i_object_info.rb +2 -2
- data/lib/ffi-gobject_introspection/i_property_info.rb +2 -2
- data/lib/ffi-gobject_introspection/i_repository.rb +9 -6
- data/lib/ffi-gobject_introspection/i_struct_info.rb +2 -1
- data/lib/ffi-gobject_introspection/i_type_info.rb +13 -7
- data/lib/ffi-gobject_introspection/i_unresolved_info.rb +1 -1
- data/lib/ffi-gobject_introspection/i_vfunc_info.rb +1 -1
- data/lib/ffi-gobject_introspection/lib.rb +30 -19
- data/lib/ffi-gobject_introspection/strv.rb +1 -1
- data/lib/ffi-gobject_introspection.rb +20 -20
- data/lib/gir_ffi/allocation_helper.rb +1 -1
- data/lib/gir_ffi/arg_helper.rb +4 -4
- data/lib/gir_ffi/{in_out_pointer.rb → array_element_convertor.rb} +16 -23
- data/lib/gir_ffi/boolean.rb +1 -1
- data/lib/gir_ffi/boxed_base.rb +1 -1
- data/lib/gir_ffi/builder.rb +18 -10
- data/lib/gir_ffi/builders/argument_builder.rb +17 -17
- data/lib/gir_ffi/builders/base_argument_builder.rb +1 -0
- data/lib/gir_ffi/builders/base_method_builder.rb +7 -7
- data/lib/gir_ffi/builders/base_return_value_builder.rb +1 -1
- data/lib/gir_ffi/builders/base_type_builder.rb +1 -1
- data/lib/gir_ffi/builders/c_to_ruby_convertor.rb +5 -5
- data/lib/gir_ffi/builders/callback_argument_builder.rb +8 -8
- data/lib/gir_ffi/builders/callback_builder.rb +3 -3
- data/lib/gir_ffi/builders/callback_return_value_builder.rb +2 -2
- data/lib/gir_ffi/builders/closure_argument_builder.rb +1 -1
- data/lib/gir_ffi/builders/closure_return_value_builder.rb +1 -1
- data/lib/gir_ffi/builders/constant_builder.rb +1 -1
- data/lib/gir_ffi/builders/constructor_builder.rb +9 -9
- data/lib/gir_ffi/builders/enum_builder.rb +2 -2
- data/lib/gir_ffi/builders/field_builder.rb +16 -15
- data/lib/gir_ffi/builders/flags_builder.rb +2 -2
- data/lib/gir_ffi/builders/full_c_to_ruby_convertor.rb +1 -1
- data/lib/gir_ffi/builders/function_builder.rb +11 -5
- data/lib/gir_ffi/builders/initializer_builder.rb +3 -3
- data/lib/gir_ffi/builders/initializer_return_value_builder.rb +2 -2
- data/lib/gir_ffi/builders/interface_builder.rb +2 -2
- data/lib/gir_ffi/builders/mapping_method_builder.rb +9 -9
- data/lib/gir_ffi/builders/marshalling_method_builder.rb +7 -7
- data/lib/gir_ffi/builders/method_template.rb +1 -1
- data/lib/gir_ffi/builders/module_builder.rb +4 -6
- data/lib/gir_ffi/builders/object_builder.rb +6 -6
- data/lib/gir_ffi/builders/property_argument_builder.rb +1 -1
- data/lib/gir_ffi/builders/property_builder.rb +13 -12
- data/lib/gir_ffi/builders/property_return_value_builder.rb +1 -1
- data/lib/gir_ffi/builders/registered_type_builder.rb +14 -5
- data/lib/gir_ffi/builders/return_value_builder.rb +4 -4
- data/lib/gir_ffi/builders/ruby_to_c_convertor.rb +6 -6
- data/lib/gir_ffi/builders/signal_closure_builder.rb +2 -2
- data/lib/gir_ffi/builders/struct_builder.rb +4 -4
- data/lib/gir_ffi/builders/struct_like.rb +1 -1
- data/lib/gir_ffi/builders/type_builder.rb +12 -12
- data/lib/gir_ffi/builders/unintrospectable_boxed_builder.rb +2 -2
- data/lib/gir_ffi/builders/unintrospectable_builder.rb +2 -2
- data/lib/gir_ffi/builders/union_builder.rb +4 -4
- data/lib/gir_ffi/builders/user_defined_builder.rb +2 -2
- data/lib/gir_ffi/builders/vfunc_argument_builder.rb +1 -1
- data/lib/gir_ffi/builders/vfunc_builder.rb +6 -6
- data/lib/gir_ffi/builders/with_layout.rb +2 -2
- data/lib/gir_ffi/callback_base.rb +1 -1
- data/lib/gir_ffi/class_base.rb +5 -5
- data/lib/gir_ffi/core.rb +19 -20
- data/lib/gir_ffi/enum_base.rb +1 -1
- data/lib/gir_ffi/enum_like_base.rb +2 -2
- data/lib/gir_ffi/error_argument_info.rb +2 -2
- data/lib/gir_ffi/error_type_info.rb +1 -1
- data/lib/gir_ffi/ffi_ext/pointer.rb +1 -1
- data/lib/gir_ffi/ffi_ext.rb +1 -1
- data/lib/gir_ffi/flags_base.rb +1 -1
- data/lib/gir_ffi/in_pointer.rb +10 -0
- data/lib/gir_ffi/info_ext/full_type_name.rb +3 -3
- data/lib/gir_ffi/info_ext/i_arg_info.rb +1 -1
- data/lib/gir_ffi/info_ext/i_callable_info.rb +1 -1
- data/lib/gir_ffi/info_ext/i_callback_info.rb +1 -1
- data/lib/gir_ffi/info_ext/i_field_info.rb +1 -1
- data/lib/gir_ffi/info_ext/i_function_info.rb +1 -1
- data/lib/gir_ffi/info_ext/i_property_info.rb +2 -2
- data/lib/gir_ffi/info_ext/i_registered_type_info.rb +4 -5
- data/lib/gir_ffi/info_ext/i_signal_info.rb +7 -3
- data/lib/gir_ffi/info_ext/i_type_info.rb +48 -26
- data/lib/gir_ffi/info_ext/i_unresolved_info.rb +1 -1
- data/lib/gir_ffi/info_ext/i_value_info.rb +2 -2
- data/lib/gir_ffi/info_ext/i_vfunc_info.rb +2 -2
- data/lib/gir_ffi/info_ext/safe_constant_name.rb +8 -8
- data/lib/gir_ffi/info_ext/safe_function_name.rb +2 -2
- data/lib/gir_ffi/info_ext.rb +15 -15
- data/lib/gir_ffi/interface_base.rb +3 -3
- data/lib/gir_ffi/lib_c.rb +1 -1
- data/lib/gir_ffi/method_stubber.rb +1 -1
- data/lib/gir_ffi/module_base.rb +1 -1
- data/lib/gir_ffi/object_base.rb +3 -4
- data/lib/gir_ffi/receiver_argument_info.rb +1 -1
- data/lib/gir_ffi/receiver_type_info.rb +2 -2
- data/lib/gir_ffi/registered_type_base.rb +1 -1
- data/lib/gir_ffi/sized_array.rb +4 -2
- data/lib/gir_ffi/struct.rb +1 -1
- data/lib/gir_ffi/struct_base.rb +1 -1
- data/lib/gir_ffi/type_map.rb +2 -23
- data/lib/gir_ffi/unintrospectable_boxed_info.rb +2 -2
- data/lib/gir_ffi/unintrospectable_type_info.rb +1 -1
- data/lib/gir_ffi/union.rb +1 -1
- data/lib/gir_ffi/union_base.rb +1 -1
- data/lib/gir_ffi/user_defined_object_info.rb +6 -2
- data/lib/gir_ffi/user_defined_property_info.rb +33 -33
- data/lib/gir_ffi/version.rb +1 -1
- data/lib/gir_ffi-base/gobject/lib.rb +3 -2
- data/lib/gir_ffi-base/gobject.rb +26 -25
- data/lib/gir_ffi-base.rb +1 -1
- data/lib/gir_ffi.rb +3 -3
- data/tasks/test.rake +3 -2
- data/test/base_test_helper.rb +16 -9
- data/test/ffi-glib/array_test.rb +71 -56
- data/test/ffi-glib/byte_array_test.rb +13 -7
- data/test/ffi-glib/bytes_test.rb +24 -19
- data/test/ffi-glib/closure_test.rb +11 -11
- data/test/ffi-glib/destroy_notify_test.rb +6 -6
- data/test/ffi-glib/hash_table_test.rb +27 -27
- data/test/ffi-glib/list_test.rb +22 -22
- data/test/ffi-glib/main_loop_test.rb +12 -12
- data/test/ffi-glib/ptr_array_test.rb +39 -39
- data/test/ffi-glib/ruby_closure_test.rb +10 -10
- data/test/ffi-glib/s_list_test.rb +20 -20
- data/test/ffi-glib/strv_test.rb +19 -19
- data/test/ffi-glib/variant_test.rb +5 -5
- data/test/ffi-gobject/gobject_test.rb +48 -44
- data/test/ffi-gobject/object_class_test.rb +8 -8
- data/test/ffi-gobject/object_test.rb +49 -67
- data/test/ffi-gobject/param_spec_test.rb +12 -12
- data/test/ffi-gobject/value_test.rb +145 -125
- data/test/ffi-gobject_introspection/gobject_type_init_test.rb +8 -8
- data/test/ffi-gobject_introspection/i_base_info_test.rb +15 -16
- data/test/ffi-gobject_introspection/i_constant_info_test.rb +9 -13
- data/test/ffi-gobject_introspection/i_enum_info_test.rb +7 -7
- data/test/ffi-gobject_introspection/i_function_info_test.rb +1 -1
- data/test/ffi-gobject_introspection/i_interface_info_test.rb +10 -10
- data/test/ffi-gobject_introspection/i_object_info_test.rb +23 -23
- data/test/ffi-gobject_introspection/i_property_info_test.rb +19 -19
- data/test/ffi-gobject_introspection/i_registered_type_info_test.rb +10 -10
- data/test/ffi-gobject_introspection/i_repository_test.rb +31 -31
- data/test/ffi-gobject_introspection/i_struct_info_test.rb +10 -10
- data/test/ffi-gobject_introspection/i_type_info_test.rb +12 -15
- data/test/ffi-gobject_introspection/i_union_info_test.rb +7 -7
- data/test/ffi-gobject_introspection/i_vfunc_info_test.rb +16 -16
- data/test/ffi-gobject_introspection/lib_test.rb +3 -3
- data/test/ffi-gobject_introspection/strv_test.rb +9 -9
- data/test/ffi-gobject_test.rb +44 -44
- data/test/gir_ffi/allocation_helper_test.rb +13 -13
- data/test/gir_ffi/arg_helper_test.rb +63 -64
- data/test/gir_ffi/boolean_test.rb +20 -20
- data/test/gir_ffi/boxed_base_test.rb +18 -18
- data/test/gir_ffi/builder_test.rb +115 -93
- data/test/gir_ffi/builders/argument_builder_test.rb +280 -286
- data/test/gir_ffi/builders/base_argument_builder_test.rb +1 -1
- data/test/gir_ffi/builders/callback_argument_builder_test.rb +53 -56
- data/test/gir_ffi/builders/callback_builder_test.rb +71 -72
- data/test/gir_ffi/builders/callback_return_value_builder_test.rb +36 -40
- data/test/gir_ffi/builders/constant_builder_test.rb +1 -1
- data/test/gir_ffi/builders/constructor_builder_test.rb +10 -10
- data/test/gir_ffi/builders/enum_builder_test.rb +10 -10
- data/test/gir_ffi/builders/field_builder_test.rb +42 -42
- data/test/gir_ffi/builders/function_builder_test.rb +236 -224
- data/test/gir_ffi/builders/initializer_builder_test.rb +14 -14
- data/test/gir_ffi/builders/interface_builder_test.rb +9 -9
- data/test/gir_ffi/builders/module_builder_test.rb +18 -18
- data/test/gir_ffi/builders/object_builder_test.rb +38 -38
- data/test/gir_ffi/builders/property_builder_test.rb +91 -94
- data/test/gir_ffi/builders/registered_type_builder_test.rb +35 -11
- data/test/gir_ffi/builders/return_value_builder_test.rb +215 -222
- data/test/gir_ffi/builders/signal_closure_builder_test.rb +122 -113
- data/test/gir_ffi/builders/struct_builder_test.rb +32 -32
- data/test/gir_ffi/builders/unintrospectable_boxed_builder_test.rb +8 -14
- data/test/gir_ffi/builders/unintrospectable_builder_test.rb +23 -23
- data/test/gir_ffi/builders/union_builder_test.rb +12 -15
- data/test/gir_ffi/builders/user_defined_builder_test.rb +147 -147
- data/test/gir_ffi/builders/vfunc_argument_builder_test.rb +40 -40
- data/test/gir_ffi/builders/vfunc_builder_test.rb +145 -157
- data/test/gir_ffi/callback_base_test.rb +9 -9
- data/test/gir_ffi/class_base_test.rb +49 -51
- data/test/gir_ffi/core_test.rb +32 -32
- data/test/gir_ffi/enum_base_test.rb +19 -19
- data/test/gir_ffi/error_type_info_test.rb +23 -23
- data/test/gir_ffi/ffi_ext/pointer_test.rb +5 -5
- data/test/gir_ffi/g_type_test.rb +11 -11
- data/test/gir_ffi/in_pointer_test.rb +70 -50
- data/test/gir_ffi/info_ext/i_callable_info_test.rb +5 -5
- data/test/gir_ffi/info_ext/i_callback_info_test.rb +4 -4
- data/test/gir_ffi/info_ext/i_field_info_test.rb +6 -6
- data/test/gir_ffi/info_ext/i_function_info_test.rb +17 -17
- data/test/gir_ffi/info_ext/i_signal_info_test.rb +8 -8
- data/test/gir_ffi/info_ext/i_type_info_test.rb +229 -215
- data/test/gir_ffi/info_ext/i_unresolved_info_test.rb +4 -4
- data/test/gir_ffi/info_ext/safe_constant_name_test.rb +8 -8
- data/test/gir_ffi/info_ext/safe_function_name_test.rb +8 -8
- data/test/gir_ffi/interface_base_test.rb +8 -8
- data/test/gir_ffi/method_stubber_test.rb +19 -19
- data/test/gir_ffi/object_base_test.rb +19 -19
- data/test/gir_ffi/object_store_test.rb +13 -13
- data/test/gir_ffi/receiver_argument_info_test.rb +15 -15
- data/test/gir_ffi/sized_array_test.rb +68 -68
- data/test/gir_ffi/struct_base_test.rb +8 -8
- data/test/gir_ffi/struct_like_base_test.rb +64 -64
- data/test/gir_ffi/type_map_test.rb +6 -6
- data/test/gir_ffi/unintrospectable_type_info_test.rb +33 -33
- data/test/gir_ffi/union_base_test.rb +8 -8
- data/test/gir_ffi/user_defined_object_info_test.rb +34 -34
- data/test/gir_ffi/user_defined_property_info_test.rb +16 -16
- data/test/gir_ffi/variable_name_generator_test.rb +8 -8
- data/test/gir_ffi/version_test.rb +4 -4
- data/test/gir_ffi/zero_terminated_test.rb +34 -34
- data/test/gir_ffi_test_helper.rb +3 -3
- data/test/integration/callback_exceptions_test.rb +17 -21
- data/test/integration/derived_classes_test.rb +13 -13
- data/test/integration/generated_everything_test.rb +224 -224
- data/test/integration/generated_gimarshallingtests_test.rb +1118 -1017
- data/test/integration/generated_gio_test.rb +36 -36
- data/test/integration/generated_glib_test.rb +4 -6
- data/test/integration/generated_gobject_test.rb +43 -35
- data/test/integration/generated_gst_test.rb +16 -16
- data/test/integration/generated_gtk_source_test.rb +22 -17
- data/test/integration/generated_gtop_test.rb +8 -15
- data/test/integration/generated_pango_ft2_test.rb +2 -2
- data/test/integration/generated_pango_test.rb +4 -4
- data/test/integration/generated_regress_test.rb +1809 -1621
- data/test/integration/generated_secret_test.rb +8 -11
- data/test/integration/generated_utility_test.rb +81 -81
- data/test/integration/generated_warnlib_test.rb +13 -19
- data/test/integration/method_lookup_test.rb +6 -6
- data/test/introspection_test_helper.rb +48 -7
- data/test/minitest/stats_plugin.rb +1 -1
- metadata +11 -28
- data/lib/ffi-glib/array_methods.rb +0 -16
- data/test/gir_ffi/in_out_pointer_test.rb +0 -56
@@ -1,18 +1,18 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
require
|
3
|
+
require "gir_ffi_test_helper"
|
4
4
|
|
5
5
|
describe GLib::DestroyNotify do
|
6
|
-
describe
|
7
|
-
it
|
8
|
-
dummy_proc =
|
6
|
+
describe ".default" do
|
7
|
+
it "removes the passed-in key from the callback store" do
|
8
|
+
dummy_proc = "some-callback"
|
9
9
|
GirFFI::CallbackBase.store_callback dummy_proc
|
10
|
-
GirFFI::CallbackBase::CALLBACKS[dummy_proc.object_id].wont_be_nil
|
10
|
+
_(GirFFI::CallbackBase::CALLBACKS[dummy_proc.object_id]).wont_be_nil
|
11
11
|
|
12
12
|
user_data = GirFFI::ArgHelper.store dummy_proc
|
13
13
|
GLib::DestroyNotify.default.call user_data
|
14
14
|
|
15
|
-
GirFFI::CallbackBase::CALLBACKS[dummy_proc.object_id].must_be_nil
|
15
|
+
_(GirFFI::CallbackBase::CALLBACKS[dummy_proc.object_id]).must_be_nil
|
16
16
|
end
|
17
17
|
end
|
18
18
|
end
|
@@ -1,68 +1,68 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
require
|
3
|
+
require "gir_ffi_test_helper"
|
4
4
|
|
5
5
|
describe GLib::HashTable do
|
6
|
-
it
|
6
|
+
it "knows its key and value types" do
|
7
7
|
hsh = GLib::HashTable.new :gint32, :utf8
|
8
8
|
assert_equal :gint32, hsh.key_type
|
9
9
|
assert_equal :utf8, hsh.value_type
|
10
10
|
end
|
11
11
|
|
12
|
-
describe
|
13
|
-
it
|
12
|
+
describe "::from" do
|
13
|
+
it "creates a GHashTable from a Ruby hash" do
|
14
14
|
hsh = GLib::HashTable.from [:utf8, :gint32],
|
15
|
-
|
16
|
-
assert_equal({
|
15
|
+
"foo" => 23, "bar" => 32
|
16
|
+
assert_equal({ "foo" => 23, "bar" => 32 }, hsh.to_hash)
|
17
17
|
end
|
18
18
|
|
19
|
-
it
|
20
|
-
hsh = GLib::HashTable.from [:utf8, :gint32],
|
19
|
+
it "return its argument if given a GHashTable" do
|
20
|
+
hsh = GLib::HashTable.from [:utf8, :gint32], "foo" => 23, "bar" => 32
|
21
21
|
hsh2 = GLib::HashTable.from [:utf8, :gint32], hsh
|
22
22
|
assert hsh2.equal? hsh
|
23
23
|
end
|
24
24
|
|
25
|
-
it
|
26
|
-
hsh = GLib::HashTable.from [:utf8, :gint32],
|
25
|
+
it "wraps its argument if given a pointer" do
|
26
|
+
hsh = GLib::HashTable.from [:utf8, :gint32], "foo" => 23, "bar" => 32
|
27
27
|
pointer = hsh.to_ptr
|
28
28
|
assert_instance_of FFI::Pointer, pointer
|
29
29
|
hsh2 = GLib::HashTable.from [:utf8, :gint32], pointer
|
30
30
|
assert_instance_of GLib::HashTable, hsh2
|
31
31
|
refute hsh2.equal? hsh
|
32
|
-
hsh2.to_hash.must_equal hsh.to_hash
|
32
|
+
_(hsh2.to_hash).must_equal hsh.to_hash
|
33
33
|
end
|
34
34
|
end
|
35
35
|
|
36
|
-
it
|
36
|
+
it "allows key-value pairs to be inserted" do
|
37
37
|
h = GLib::HashTable.new :utf8, :utf8
|
38
|
-
h.insert
|
39
|
-
h.to_hash.must_equal
|
38
|
+
h.insert "foo", "bar"
|
39
|
+
_(h.to_hash).must_equal "foo" => "bar"
|
40
40
|
end
|
41
41
|
|
42
|
-
it
|
43
|
-
GLib::HashTable.must_include Enumerable
|
42
|
+
it "includes Enumerable" do
|
43
|
+
_(GLib::HashTable).must_include Enumerable
|
44
44
|
end
|
45
45
|
|
46
|
-
describe
|
46
|
+
describe "a HashTable provided by the system" do
|
47
47
|
before do
|
48
48
|
GirFFI.setup :Regress
|
49
49
|
@hash = Regress.test_ghash_container_return
|
50
50
|
end
|
51
51
|
|
52
|
-
it
|
52
|
+
it "has a working #each method" do
|
53
53
|
a = {}
|
54
54
|
@hash.each { |k, v| a[k] = v }
|
55
|
-
a.must_be :==,
|
56
|
-
|
57
|
-
|
58
|
-
|
55
|
+
_(a).must_be :==,
|
56
|
+
"foo" => "bar",
|
57
|
+
"baz" => "bat",
|
58
|
+
"qux" => "quux"
|
59
59
|
end
|
60
60
|
|
61
|
-
it
|
62
|
-
@hash.to_hash.must_be :==,
|
63
|
-
|
64
|
-
|
65
|
-
|
61
|
+
it "has a working #to_hash method" do
|
62
|
+
_(@hash.to_hash).must_be :==,
|
63
|
+
"foo" => "bar",
|
64
|
+
"baz" => "bat",
|
65
|
+
"qux" => "quux"
|
66
66
|
end
|
67
67
|
end
|
68
68
|
end
|
data/test/ffi-glib/list_test.rb
CHANGED
@@ -1,27 +1,27 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
require
|
3
|
+
require "gir_ffi_test_helper"
|
4
4
|
|
5
5
|
describe GLib::List do
|
6
|
-
it
|
6
|
+
it "knows its element type" do
|
7
7
|
arr = GLib::List.new :gint32
|
8
8
|
assert_equal :gint32, arr.element_type
|
9
9
|
end
|
10
10
|
|
11
|
-
describe
|
12
|
-
it
|
11
|
+
describe "#append" do
|
12
|
+
it "appends integer values" do
|
13
13
|
lst = GLib::List.new :gint32
|
14
14
|
res = lst.append 1
|
15
15
|
assert_equal 1, res.data
|
16
16
|
end
|
17
17
|
|
18
|
-
it
|
18
|
+
it "appends string values" do
|
19
19
|
lst = GLib::List.new :utf8
|
20
|
-
res = lst.append
|
21
|
-
assert_equal
|
20
|
+
res = lst.append "bla"
|
21
|
+
assert_equal "bla", res.data
|
22
22
|
end
|
23
23
|
|
24
|
-
it
|
24
|
+
it "appends multiple values into a single list" do
|
25
25
|
lst = GLib::List.new :gint32
|
26
26
|
|
27
27
|
lst = lst.append 1
|
@@ -33,54 +33,54 @@ describe GLib::List do
|
|
33
33
|
end
|
34
34
|
end
|
35
35
|
|
36
|
-
describe
|
37
|
-
it
|
36
|
+
describe "::from" do
|
37
|
+
it "creates a GList from a Ruby array" do
|
38
38
|
lst = GLib::List.from :gint32, [3, 2, 1]
|
39
39
|
assert_equal [3, 2, 1], lst.to_a
|
40
40
|
end
|
41
41
|
|
42
|
-
it
|
42
|
+
it "return its argument if given a GList" do
|
43
43
|
lst = GLib::List.from :gint32, [3, 2, 1]
|
44
44
|
lst2 = GLib::List.from :gint32, lst
|
45
45
|
assert lst2.equal? lst
|
46
46
|
end
|
47
47
|
|
48
|
-
it
|
48
|
+
it "wraps its argument if given a pointer" do
|
49
49
|
lst = GLib::List.from :gint32, [3, 2, 1]
|
50
50
|
pointer = lst.to_ptr
|
51
51
|
assert_instance_of FFI::Pointer, pointer
|
52
52
|
lst2 = GLib::List.from :gint32, pointer
|
53
53
|
assert_instance_of GLib::List, lst2
|
54
54
|
refute lst2.equal? lst
|
55
|
-
lst2.to_a.must_equal lst.to_a
|
55
|
+
_(lst2.to_a).must_equal lst.to_a
|
56
56
|
end
|
57
57
|
end
|
58
58
|
|
59
|
-
describe
|
60
|
-
it
|
59
|
+
describe "#==" do
|
60
|
+
it "returns true when comparing to an array with the same elements" do
|
61
61
|
list = GLib::List.from :gint32, [1, 2, 3]
|
62
62
|
|
63
|
-
list.must_be :==, [1, 2, 3]
|
63
|
+
_(list).must_be :==, [1, 2, 3]
|
64
64
|
end
|
65
65
|
|
66
|
-
it
|
66
|
+
it "returns false when comparing to an array with different elements" do
|
67
67
|
list = GLib::List.from :gint32, [1, 2, 3]
|
68
68
|
|
69
|
-
list.wont_be :==, [1, 2]
|
69
|
+
_(list).wont_be :==, [1, 2]
|
70
70
|
end
|
71
71
|
|
72
|
-
it
|
72
|
+
it "returns true when comparing to a list with the same elements" do
|
73
73
|
list = GLib::List.from :gint32, [1, 2, 3]
|
74
74
|
other = GLib::List.from :gint32, [1, 2, 3]
|
75
75
|
|
76
|
-
list.must_be :==, other
|
76
|
+
_(list).must_be :==, other
|
77
77
|
end
|
78
78
|
|
79
|
-
it
|
79
|
+
it "returns false when comparing to a list with different elements" do
|
80
80
|
list = GLib::List.from :gint32, [1, 2, 3]
|
81
81
|
other = GLib::List.from :gint32, [1, 2]
|
82
82
|
|
83
|
-
list.wont_be :==, other
|
83
|
+
_(list).wont_be :==, other
|
84
84
|
end
|
85
85
|
end
|
86
86
|
end
|
@@ -1,12 +1,12 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
require
|
3
|
+
require "gir_ffi_test_helper"
|
4
4
|
|
5
5
|
class MainLoopTestException < RuntimeError; end
|
6
6
|
|
7
7
|
describe GLib::MainLoop do
|
8
|
-
describe
|
9
|
-
it
|
8
|
+
describe "#run" do
|
9
|
+
it "allows other threads to run" do
|
10
10
|
main_loop = GLib::MainLoop.new nil, false
|
11
11
|
|
12
12
|
a = []
|
@@ -16,26 +16,26 @@ describe GLib::MainLoop do
|
|
16
16
|
|
17
17
|
slow_thread = Thread.new do
|
18
18
|
sleep 0.001
|
19
|
-
a <<
|
19
|
+
a << "During run"
|
20
20
|
end
|
21
21
|
|
22
|
-
a <<
|
22
|
+
a << "Before run"
|
23
23
|
main_loop.run
|
24
|
-
a <<
|
24
|
+
a << "After run"
|
25
25
|
|
26
26
|
slow_thread.join
|
27
27
|
|
28
|
-
a.must_equal [
|
28
|
+
_(a).must_equal ["Before run", "During run", "After run"]
|
29
29
|
end
|
30
30
|
|
31
|
-
it
|
31
|
+
it "raises and quits on exceptions in callbacks" do
|
32
32
|
main_loop = GLib::MainLoop.new nil, false
|
33
33
|
|
34
|
-
a =
|
34
|
+
a = "expected"
|
35
35
|
|
36
36
|
# This timeout shouldn't get called
|
37
37
|
guard = GLib.timeout_add GLib::PRIORITY_DEFAULT, 150 do
|
38
|
-
a =
|
38
|
+
a = "unexpected"
|
39
39
|
main_loop.quit
|
40
40
|
end
|
41
41
|
|
@@ -43,8 +43,8 @@ describe GLib::MainLoop do
|
|
43
43
|
raise MainLoopTestException
|
44
44
|
end
|
45
45
|
|
46
|
-
-> { main_loop.run }.must_raise MainLoopTestException
|
47
|
-
a.must_equal
|
46
|
+
_(-> { main_loop.run }).must_raise MainLoopTestException
|
47
|
+
_(a).must_equal "expected"
|
48
48
|
|
49
49
|
# Clean up uncalled timeout
|
50
50
|
GLib.source_remove guard
|
@@ -1,30 +1,30 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
require
|
3
|
+
require "gir_ffi_test_helper"
|
4
4
|
|
5
5
|
describe GLib::PtrArray do
|
6
|
-
it
|
6
|
+
it "knows its element type" do
|
7
7
|
arr = GLib::PtrArray.new :utf8
|
8
8
|
assert_equal :utf8, arr.element_type
|
9
9
|
end
|
10
10
|
|
11
|
-
describe
|
12
|
-
it
|
11
|
+
describe "::add" do
|
12
|
+
it "correctly takes the type into account" do
|
13
13
|
arr = GLib::PtrArray.new :utf8
|
14
|
-
str =
|
14
|
+
str = "test"
|
15
15
|
GLib::PtrArray.add arr, str
|
16
16
|
|
17
17
|
assert_equal str, arr.pdata.read_pointer.read_string
|
18
18
|
end
|
19
19
|
end
|
20
20
|
|
21
|
-
describe
|
22
|
-
it
|
21
|
+
describe "#each" do
|
22
|
+
it "works normally" do
|
23
23
|
arr = GLib::PtrArray.new :utf8
|
24
24
|
|
25
|
-
GLib::PtrArray.add arr,
|
26
|
-
GLib::PtrArray.add arr,
|
27
|
-
GLib::PtrArray.add arr,
|
25
|
+
GLib::PtrArray.add arr, "test1"
|
26
|
+
GLib::PtrArray.add arr, "test2"
|
27
|
+
GLib::PtrArray.add arr, "test3"
|
28
28
|
|
29
29
|
a = []
|
30
30
|
arr.each { |v| a << v }
|
@@ -32,81 +32,81 @@ describe GLib::PtrArray do
|
|
32
32
|
assert_equal %w(test1 test2 test3), a
|
33
33
|
end
|
34
34
|
|
35
|
-
it
|
35
|
+
it "works when exiting the loop prematurely" do
|
36
36
|
arr = GLib::PtrArray.new :utf8
|
37
37
|
|
38
|
-
GLib::PtrArray.add arr,
|
39
|
-
GLib::PtrArray.add arr,
|
40
|
-
GLib::PtrArray.add arr,
|
38
|
+
GLib::PtrArray.add arr, "test1"
|
39
|
+
GLib::PtrArray.add arr, "test2"
|
40
|
+
GLib::PtrArray.add arr, "test3"
|
41
41
|
|
42
42
|
a = []
|
43
43
|
arr.each do |v|
|
44
44
|
a << v
|
45
|
-
break if v ==
|
45
|
+
break if v == "test2"
|
46
46
|
end
|
47
47
|
|
48
48
|
assert_equal %w(test1 test2), a
|
49
49
|
end
|
50
50
|
end
|
51
51
|
|
52
|
-
it
|
53
|
-
GLib::PtrArray.must_include Enumerable
|
52
|
+
it "includes Enumerable" do
|
53
|
+
_(GLib::PtrArray).must_include Enumerable
|
54
54
|
end
|
55
55
|
|
56
|
-
it
|
56
|
+
it "has a working #to_a method" do
|
57
57
|
arr = GLib::PtrArray.new :utf8
|
58
58
|
|
59
|
-
GLib::PtrArray.add arr,
|
60
|
-
GLib::PtrArray.add arr,
|
61
|
-
GLib::PtrArray.add arr,
|
59
|
+
GLib::PtrArray.add arr, "test1"
|
60
|
+
GLib::PtrArray.add arr, "test2"
|
61
|
+
GLib::PtrArray.add arr, "test3"
|
62
62
|
|
63
63
|
assert_equal %w(test1 test2 test3), arr.to_a
|
64
64
|
end
|
65
65
|
|
66
|
-
it
|
66
|
+
it "has #add as an instance method too" do
|
67
67
|
arr = GLib::PtrArray.new :utf8
|
68
|
-
arr.add
|
69
|
-
assert_equal [
|
68
|
+
arr.add "test1"
|
69
|
+
assert_equal ["test1"], arr.to_a
|
70
70
|
end
|
71
71
|
|
72
|
-
describe
|
73
|
-
it
|
72
|
+
describe "#==" do
|
73
|
+
it "returns true when comparing to an array with the same elements" do
|
74
74
|
arr = GLib::PtrArray.from :utf8, %w(1 2 3)
|
75
75
|
|
76
|
-
arr.must_be :==, %w(1 2 3)
|
76
|
+
_(arr).must_be :==, %w(1 2 3)
|
77
77
|
end
|
78
78
|
|
79
|
-
it
|
79
|
+
it "returns false when comparing to an array with different elements" do
|
80
80
|
arr = GLib::PtrArray.from :utf8, %w(1 2 3)
|
81
81
|
|
82
|
-
arr.wont_be :==, %w(1 2)
|
82
|
+
_(arr).wont_be :==, %w(1 2)
|
83
83
|
end
|
84
84
|
|
85
|
-
it
|
85
|
+
it "returns true when comparing to a GPtrArray with the same elements" do
|
86
86
|
arr = GLib::PtrArray.from :utf8, %w(1 2 3)
|
87
87
|
other = GLib::PtrArray.from :utf8, %w(1 2 3)
|
88
88
|
|
89
|
-
arr.must_be :==, other
|
89
|
+
_(arr).must_be :==, other
|
90
90
|
end
|
91
91
|
|
92
|
-
it
|
92
|
+
it "returns false when comparing to a GPtrArray with different elements" do
|
93
93
|
arr = GLib::PtrArray.from :utf8, %w(1 2 3)
|
94
94
|
other = GLib::PtrArray.from :utf8, %w(1 2)
|
95
95
|
|
96
|
-
arr.wont_be :==, other
|
96
|
+
_(arr).wont_be :==, other
|
97
97
|
end
|
98
98
|
end
|
99
99
|
|
100
|
-
describe
|
101
|
-
it
|
100
|
+
describe "#index" do
|
101
|
+
it "returns the correct element" do
|
102
102
|
arr = GLib::PtrArray.from :utf8, %w(1 2 3)
|
103
|
-
arr.index(1).must_equal
|
103
|
+
_(arr.index(1)).must_equal "2"
|
104
104
|
end
|
105
105
|
|
106
|
-
it
|
106
|
+
it "raises an error if the index is out of bounds" do
|
107
107
|
arr = GLib::PtrArray.from :utf8, %w(1 2 3)
|
108
|
-
proc { arr.index(16) }.must_raise IndexError
|
109
|
-
proc { arr.index(-1) }.must_raise IndexError
|
108
|
+
_(proc { arr.index(16) }).must_raise IndexError
|
109
|
+
_(proc { arr.index(-1) }).must_raise IndexError
|
110
110
|
end
|
111
111
|
end
|
112
112
|
end
|
@@ -1,23 +1,23 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
require
|
3
|
+
require "gir_ffi_test_helper"
|
4
4
|
|
5
5
|
describe GObject::RubyClosure do
|
6
|
-
describe
|
7
|
-
it
|
6
|
+
describe ".new" do
|
7
|
+
it "takes a mandatory block argument" do
|
8
8
|
assert_raises ArgumentError do
|
9
9
|
GObject::RubyClosure.new
|
10
10
|
end
|
11
11
|
end
|
12
12
|
|
13
|
-
it
|
13
|
+
it "returns a kind of Closure" do
|
14
14
|
c = GObject::RubyClosure.new {}
|
15
15
|
assert_kind_of GObject::Closure, c
|
16
16
|
end
|
17
17
|
end
|
18
18
|
|
19
|
-
describe
|
20
|
-
it
|
19
|
+
describe ".wrap" do
|
20
|
+
it "returns a fully functional object that can invoke the original block" do
|
21
21
|
a = 0
|
22
22
|
c = GObject::RubyClosure.new { a = 2 }
|
23
23
|
c2 = GObject::RubyClosure.wrap(c.to_ptr)
|
@@ -26,7 +26,7 @@ describe GObject::RubyClosure do
|
|
26
26
|
end
|
27
27
|
end
|
28
28
|
|
29
|
-
describe
|
29
|
+
describe ".marshaller" do
|
30
30
|
it "invokes its closure argument's block" do
|
31
31
|
a = 0
|
32
32
|
c = GObject::RubyClosure.new { a = 2 }
|
@@ -34,7 +34,7 @@ describe GObject::RubyClosure do
|
|
34
34
|
assert_equal 2, a
|
35
35
|
end
|
36
36
|
|
37
|
-
it
|
37
|
+
it "works when its closure argument is a GObject::Closure" do
|
38
38
|
a = 0
|
39
39
|
c = GObject::RubyClosure.new { a = 2 }
|
40
40
|
c2 = GObject::Closure.wrap(c.to_ptr)
|
@@ -50,8 +50,8 @@ describe GObject::RubyClosure do
|
|
50
50
|
end
|
51
51
|
end
|
52
52
|
|
53
|
-
describe
|
54
|
-
it
|
53
|
+
describe "#invoke" do
|
54
|
+
it "invokes the ruby block" do
|
55
55
|
a = 0
|
56
56
|
c = GObject::RubyClosure.new { a = 2 }
|
57
57
|
c2 = GObject::Closure.wrap(c.to_ptr)
|