gir_ffi 0.15.3 → 0.15.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/Changelog.md +15 -0
- data/README.md +5 -6
- data/TODO.md +14 -35
- data/docs/Documentation.md +6 -0
- data/docs/Subclassing.md +38 -0
- data/lib/ffi-glib.rb +8 -3
- data/lib/ffi-glib/byte_array.rb +2 -1
- data/lib/ffi-glib/destroy_notify.rb +2 -2
- data/lib/ffi-glib/hash_table.rb +1 -2
- data/lib/ffi-glib/list.rb +11 -5
- data/lib/ffi-glib/list_methods.rb +12 -0
- data/lib/ffi-glib/s_list.rb +10 -4
- data/lib/ffi-gobject.rb +0 -3
- data/lib/ffi-gobject/object.rb +77 -73
- data/lib/ffi-gobject/object_class.rb +1 -1
- data/lib/ffi-gobject/value.rb +107 -108
- data/lib/ffi-gobject_introspection/i_base_info.rb +20 -19
- data/lib/gir_ffi-base/gobject/lib.rb +4 -0
- data/lib/gir_ffi/array_element_convertor.rb +1 -2
- data/lib/gir_ffi/boxed_base.rb +1 -5
- data/lib/gir_ffi/builder.rb +1 -1
- data/lib/gir_ffi/builder_helper.rb +7 -4
- data/lib/gir_ffi/builders/base_argument_builder.rb +2 -2
- data/lib/gir_ffi/builders/base_method_builder.rb +1 -1
- data/lib/gir_ffi/builders/base_type_builder.rb +1 -1
- data/lib/gir_ffi/builders/callback_argument_builder.rb +2 -0
- data/lib/gir_ffi/builders/callback_builder.rb +14 -12
- data/lib/gir_ffi/builders/callback_return_value_builder.rb +4 -6
- data/lib/gir_ffi/builders/class_struct_builder.rb +24 -0
- data/lib/gir_ffi/builders/enum_builder.rb +3 -3
- data/lib/gir_ffi/builders/interface_builder.rb +3 -1
- data/lib/gir_ffi/builders/mapping_method_builder.rb +1 -1
- data/lib/gir_ffi/builders/marshalling_method_builder.rb +5 -2
- data/lib/gir_ffi/builders/method_template.rb +4 -4
- data/lib/gir_ffi/builders/null_argument_builder.rb +0 -2
- data/lib/gir_ffi/builders/null_return_value_builder.rb +0 -2
- data/lib/gir_ffi/builders/object_builder.rb +16 -6
- data/lib/gir_ffi/builders/property_builder.rb +1 -2
- data/lib/gir_ffi/builders/signal_closure_builder.rb +3 -5
- data/lib/gir_ffi/builders/struct_builder.rb +5 -5
- data/lib/gir_ffi/builders/user_defined_builder.rb +8 -1
- data/lib/gir_ffi/builders/vfunc_argument_builder.rb +1 -1
- data/lib/gir_ffi/callback_base.rb +3 -3
- data/lib/gir_ffi/core.rb +17 -2
- data/lib/gir_ffi/glib_error.rb +1 -2
- data/lib/gir_ffi/in_pointer.rb +7 -0
- data/lib/gir_ffi/object_base.rb +27 -0
- data/lib/gir_ffi/return_value_info.rb +1 -2
- data/lib/gir_ffi/struct_base.rb +1 -9
- data/lib/gir_ffi/struct_like_base.rb +9 -5
- data/lib/gir_ffi/unintrospectable_type_info.rb +1 -1
- data/lib/gir_ffi/union_base.rb +1 -9
- data/lib/gir_ffi/user_defined_object_info.rb +3 -2
- data/lib/gir_ffi/version.rb +1 -1
- data/lib/gir_ffi/vfunc_implementation.rb +1 -0
- metadata +86 -136
- data/Gemfile +0 -14
- data/Rakefile +0 -9
- data/tasks/test.rake +0 -204
- data/test/base_test_helper.rb +0 -70
- data/test/ffi-glib/array_test.rb +0 -203
- data/test/ffi-glib/byte_array_test.rb +0 -28
- data/test/ffi-glib/bytes_test.rb +0 -61
- data/test/ffi-glib/closure_test.rb +0 -38
- data/test/ffi-glib/destroy_notify_test.rb +0 -18
- data/test/ffi-glib/hash_table_test.rb +0 -68
- data/test/ffi-glib/list_test.rb +0 -86
- data/test/ffi-glib/main_loop_test.rb +0 -53
- data/test/ffi-glib/ptr_array_test.rb +0 -112
- data/test/ffi-glib/ruby_closure_test.rb +0 -62
- data/test/ffi-glib/s_list_test.rb +0 -76
- data/test/ffi-glib/strv_test.rb +0 -60
- data/test/ffi-glib/variant_test.rb +0 -12
- data/test/ffi-gobject/gobject_test.rb +0 -76
- data/test/ffi-gobject/object_class_test.rb +0 -31
- data/test/ffi-gobject/object_test.rb +0 -123
- data/test/ffi-gobject/param_spec_test.rb +0 -32
- data/test/ffi-gobject/value_test.rb +0 -390
- data/test/ffi-gobject_introspection/gobject_type_init_test.rb +0 -26
- data/test/ffi-gobject_introspection/i_base_info_test.rb +0 -52
- data/test/ffi-gobject_introspection/i_constant_info_test.rb +0 -29
- data/test/ffi-gobject_introspection/i_enum_info_test.rb +0 -18
- data/test/ffi-gobject_introspection/i_function_info_test.rb +0 -6
- data/test/ffi-gobject_introspection/i_interface_info_test.rb +0 -23
- data/test/ffi-gobject_introspection/i_object_info_test.rb +0 -49
- data/test/ffi-gobject_introspection/i_property_info_test.rb +0 -47
- data/test/ffi-gobject_introspection/i_registered_type_info_test.rb +0 -27
- data/test/ffi-gobject_introspection/i_repository_test.rb +0 -81
- data/test/ffi-gobject_introspection/i_struct_info_test.rb +0 -23
- data/test/ffi-gobject_introspection/i_type_info_test.rb +0 -30
- data/test/ffi-gobject_introspection/i_union_info_test.rb +0 -17
- data/test/ffi-gobject_introspection/i_vfunc_info_test.rb +0 -41
- data/test/ffi-gobject_introspection/lib_test.rb +0 -13
- data/test/ffi-gobject_introspection/strv_test.rb +0 -46
- data/test/ffi-gobject_test.rb +0 -153
- data/test/gir_ffi/allocation_helper_test.rb +0 -36
- data/test/gir_ffi/arg_helper_test.rb +0 -146
- data/test/gir_ffi/boolean_test.rb +0 -43
- data/test/gir_ffi/boxed_base_test.rb +0 -65
- data/test/gir_ffi/builder_test.rb +0 -168
- data/test/gir_ffi/builders/argument_builder_test.rb +0 -691
- data/test/gir_ffi/builders/base_argument_builder_test.rb +0 -6
- data/test/gir_ffi/builders/callback_argument_builder_test.rb +0 -130
- data/test/gir_ffi/builders/callback_builder_test.rb +0 -117
- data/test/gir_ffi/builders/callback_return_value_builder_test.rb +0 -84
- data/test/gir_ffi/builders/constant_builder_test.rb +0 -6
- data/test/gir_ffi/builders/constructor_builder_test.rb +0 -39
- data/test/gir_ffi/builders/enum_builder_test.rb +0 -23
- data/test/gir_ffi/builders/field_builder_test.rb +0 -140
- data/test/gir_ffi/builders/function_builder_test.rb +0 -570
- data/test/gir_ffi/builders/initializer_builder_test.rb +0 -56
- data/test/gir_ffi/builders/interface_builder_test.rb +0 -32
- data/test/gir_ffi/builders/module_builder_test.rb +0 -43
- data/test/gir_ffi/builders/object_builder_test.rb +0 -98
- data/test/gir_ffi/builders/property_builder_test.rb +0 -161
- data/test/gir_ffi/builders/registered_type_builder_test.rb +0 -54
- data/test/gir_ffi/builders/return_value_builder_test.rb +0 -444
- data/test/gir_ffi/builders/signal_closure_builder_test.rb +0 -199
- data/test/gir_ffi/builders/struct_builder_test.rb +0 -96
- data/test/gir_ffi/builders/unintrospectable_boxed_builder_test.rb +0 -29
- data/test/gir_ffi/builders/unintrospectable_builder_test.rb +0 -84
- data/test/gir_ffi/builders/union_builder_test.rb +0 -28
- data/test/gir_ffi/builders/user_defined_builder_test.rb +0 -528
- data/test/gir_ffi/builders/vfunc_argument_builder_test.rb +0 -107
- data/test/gir_ffi/builders/vfunc_builder_test.rb +0 -245
- data/test/gir_ffi/callback_base_test.rb +0 -22
- data/test/gir_ffi/class_base_test.rb +0 -171
- data/test/gir_ffi/core_test.rb +0 -99
- data/test/gir_ffi/enum_base_test.rb +0 -43
- data/test/gir_ffi/error_type_info_test.rb +0 -50
- data/test/gir_ffi/ffi_ext/pointer_test.rb +0 -22
- data/test/gir_ffi/g_type_test.rb +0 -31
- data/test/gir_ffi/in_pointer_test.rb +0 -203
- data/test/gir_ffi/info_ext/i_callable_info_test.rb +0 -26
- data/test/gir_ffi/info_ext/i_callback_info_test.rb +0 -22
- data/test/gir_ffi/info_ext/i_field_info_test.rb +0 -37
- data/test/gir_ffi/info_ext/i_function_info_test.rb +0 -74
- data/test/gir_ffi/info_ext/i_signal_info_test.rb +0 -32
- data/test/gir_ffi/info_ext/i_type_info_test.rb +0 -712
- data/test/gir_ffi/info_ext/i_unresolved_info_test.rb +0 -19
- data/test/gir_ffi/info_ext/safe_constant_name_test.rb +0 -26
- data/test/gir_ffi/info_ext/safe_function_name_test.rb +0 -26
- data/test/gir_ffi/interface_base_test.rb +0 -20
- data/test/gir_ffi/method_stubber_test.rb +0 -67
- data/test/gir_ffi/object_base_test.rb +0 -64
- data/test/gir_ffi/object_store_test.rb +0 -41
- data/test/gir_ffi/receiver_argument_info_test.rb +0 -33
- data/test/gir_ffi/sized_array_test.rb +0 -206
- data/test/gir_ffi/struct_base_test.rb +0 -23
- data/test/gir_ffi/struct_like_base_test.rb +0 -167
- data/test/gir_ffi/type_map_test.rb +0 -17
- data/test/gir_ffi/unintrospectable_type_info_test.rb +0 -121
- data/test/gir_ffi/union_base_test.rb +0 -23
- data/test/gir_ffi/user_defined_object_info_test.rb +0 -119
- data/test/gir_ffi/user_defined_property_info_test.rb +0 -39
- data/test/gir_ffi/variable_name_generator_test.rb +0 -18
- data/test/gir_ffi/version_test.rb +0 -9
- data/test/gir_ffi/zero_terminated_test.rb +0 -108
- data/test/gir_ffi_test_helper.rb +0 -84
- data/test/integration/callback_exceptions_test.rb +0 -59
- data/test/integration/derived_classes_test.rb +0 -54
- data/test/integration/generated_everything_test.rb +0 -453
- data/test/integration/generated_gimarshallingtests_test.rb +0 -3109
- data/test/integration/generated_gio_test.rb +0 -116
- data/test/integration/generated_glib_test.rb +0 -10
- data/test/integration/generated_gobject_test.rb +0 -124
- data/test/integration/generated_gst_test.rb +0 -38
- data/test/integration/generated_gtk_source_test.rb +0 -21
- data/test/integration/generated_gtop_test.rb +0 -22
- data/test/integration/generated_pango_ft2_test.rb +0 -17
- data/test/integration/generated_pango_test.rb +0 -24
- data/test/integration/generated_regress_test.rb +0 -4076
- data/test/integration/generated_secret_test.rb +0 -14
- data/test/integration/generated_utility_test.rb +0 -174
- data/test/integration/generated_warnlib_test.rb +0 -45
- data/test/integration/method_lookup_test.rb +0 -34
- data/test/introspection_test_helper.rb +0 -94
- data/test/lib/Makefile.am +0 -110
- data/test/lib/autogen.sh +0 -4
- data/test/lib/configure.ac +0 -34
- data/test/lib/m4/jhflags.m4 +0 -21
- data/test/minitest/stats_plugin.rb +0 -30
data/test/ffi-glib/list_test.rb
DELETED
@@ -1,86 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
require "gir_ffi_test_helper"
|
4
|
-
|
5
|
-
describe GLib::List do
|
6
|
-
it "knows its element type" do
|
7
|
-
arr = GLib::List.new :gint32
|
8
|
-
assert_equal :gint32, arr.element_type
|
9
|
-
end
|
10
|
-
|
11
|
-
describe "#append" do
|
12
|
-
it "appends integer values" do
|
13
|
-
lst = GLib::List.new :gint32
|
14
|
-
res = lst.append 1
|
15
|
-
assert_equal 1, res.data
|
16
|
-
end
|
17
|
-
|
18
|
-
it "appends string values" do
|
19
|
-
lst = GLib::List.new :utf8
|
20
|
-
res = lst.append "bla"
|
21
|
-
assert_equal "bla", res.data
|
22
|
-
end
|
23
|
-
|
24
|
-
it "appends multiple values into a single list" do
|
25
|
-
lst = GLib::List.new :gint32
|
26
|
-
|
27
|
-
lst = lst.append 1
|
28
|
-
lst = lst.append 2
|
29
|
-
|
30
|
-
assert_equal 1, lst.data
|
31
|
-
nxt = lst.next
|
32
|
-
assert_equal 2, nxt.data
|
33
|
-
end
|
34
|
-
end
|
35
|
-
|
36
|
-
describe "::from" do
|
37
|
-
it "creates a GList from a Ruby array" do
|
38
|
-
lst = GLib::List.from :gint32, [3, 2, 1]
|
39
|
-
assert_equal [3, 2, 1], lst.to_a
|
40
|
-
end
|
41
|
-
|
42
|
-
it "return its argument if given a GList" do
|
43
|
-
lst = GLib::List.from :gint32, [3, 2, 1]
|
44
|
-
lst2 = GLib::List.from :gint32, lst
|
45
|
-
assert lst2.equal? lst
|
46
|
-
end
|
47
|
-
|
48
|
-
it "wraps its argument if given a pointer" do
|
49
|
-
lst = GLib::List.from :gint32, [3, 2, 1]
|
50
|
-
pointer = lst.to_ptr
|
51
|
-
assert_instance_of FFI::Pointer, pointer
|
52
|
-
lst2 = GLib::List.from :gint32, pointer
|
53
|
-
assert_instance_of GLib::List, lst2
|
54
|
-
refute lst2.equal? lst
|
55
|
-
_(lst2.to_a).must_equal lst.to_a
|
56
|
-
end
|
57
|
-
end
|
58
|
-
|
59
|
-
describe "#==" do
|
60
|
-
it "returns true when comparing to an array with the same elements" do
|
61
|
-
list = GLib::List.from :gint32, [1, 2, 3]
|
62
|
-
|
63
|
-
_(list).must_be :==, [1, 2, 3]
|
64
|
-
end
|
65
|
-
|
66
|
-
it "returns false when comparing to an array with different elements" do
|
67
|
-
list = GLib::List.from :gint32, [1, 2, 3]
|
68
|
-
|
69
|
-
_(list).wont_be :==, [1, 2]
|
70
|
-
end
|
71
|
-
|
72
|
-
it "returns true when comparing to a list with the same elements" do
|
73
|
-
list = GLib::List.from :gint32, [1, 2, 3]
|
74
|
-
other = GLib::List.from :gint32, [1, 2, 3]
|
75
|
-
|
76
|
-
_(list).must_be :==, other
|
77
|
-
end
|
78
|
-
|
79
|
-
it "returns false when comparing to a list with different elements" do
|
80
|
-
list = GLib::List.from :gint32, [1, 2, 3]
|
81
|
-
other = GLib::List.from :gint32, [1, 2]
|
82
|
-
|
83
|
-
_(list).wont_be :==, other
|
84
|
-
end
|
85
|
-
end
|
86
|
-
end
|
@@ -1,53 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
require "gir_ffi_test_helper"
|
4
|
-
|
5
|
-
class MainLoopTestException < RuntimeError; end
|
6
|
-
|
7
|
-
describe GLib::MainLoop do
|
8
|
-
describe "#run" do
|
9
|
-
it "allows other threads to run" do
|
10
|
-
main_loop = GLib::MainLoop.new nil, false
|
11
|
-
|
12
|
-
a = []
|
13
|
-
GLib.timeout_add GLib::PRIORITY_DEFAULT, 150 do
|
14
|
-
main_loop.quit
|
15
|
-
end
|
16
|
-
|
17
|
-
slow_thread = Thread.new do
|
18
|
-
sleep 0.001
|
19
|
-
a << "During run"
|
20
|
-
end
|
21
|
-
|
22
|
-
a << "Before run"
|
23
|
-
main_loop.run
|
24
|
-
a << "After run"
|
25
|
-
|
26
|
-
slow_thread.join
|
27
|
-
|
28
|
-
_(a).must_equal ["Before run", "During run", "After run"]
|
29
|
-
end
|
30
|
-
|
31
|
-
it "raises and quits on exceptions in callbacks" do
|
32
|
-
main_loop = GLib::MainLoop.new nil, false
|
33
|
-
|
34
|
-
a = "expected"
|
35
|
-
|
36
|
-
# This timeout shouldn't get called
|
37
|
-
guard = GLib.timeout_add GLib::PRIORITY_DEFAULT, 150 do
|
38
|
-
a = "unexpected"
|
39
|
-
main_loop.quit
|
40
|
-
end
|
41
|
-
|
42
|
-
GLib.timeout_add GLib::PRIORITY_DEFAULT, 10 do
|
43
|
-
raise MainLoopTestException
|
44
|
-
end
|
45
|
-
|
46
|
-
_(-> { main_loop.run }).must_raise MainLoopTestException
|
47
|
-
_(a).must_equal "expected"
|
48
|
-
|
49
|
-
# Clean up uncalled timeout
|
50
|
-
GLib.source_remove guard
|
51
|
-
end
|
52
|
-
end
|
53
|
-
end
|
@@ -1,112 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
require "gir_ffi_test_helper"
|
4
|
-
|
5
|
-
describe GLib::PtrArray do
|
6
|
-
it "knows its element type" do
|
7
|
-
arr = GLib::PtrArray.new :utf8
|
8
|
-
assert_equal :utf8, arr.element_type
|
9
|
-
end
|
10
|
-
|
11
|
-
describe "::add" do
|
12
|
-
it "correctly takes the type into account" do
|
13
|
-
arr = GLib::PtrArray.new :utf8
|
14
|
-
str = "test"
|
15
|
-
GLib::PtrArray.add arr, str
|
16
|
-
|
17
|
-
assert_equal str, arr.pdata.read_pointer.read_string
|
18
|
-
end
|
19
|
-
end
|
20
|
-
|
21
|
-
describe "#each" do
|
22
|
-
it "works normally" do
|
23
|
-
arr = GLib::PtrArray.new :utf8
|
24
|
-
|
25
|
-
GLib::PtrArray.add arr, "test1"
|
26
|
-
GLib::PtrArray.add arr, "test2"
|
27
|
-
GLib::PtrArray.add arr, "test3"
|
28
|
-
|
29
|
-
a = []
|
30
|
-
arr.each { |v| a << v }
|
31
|
-
|
32
|
-
assert_equal %w(test1 test2 test3), a
|
33
|
-
end
|
34
|
-
|
35
|
-
it "works when exiting the loop prematurely" do
|
36
|
-
arr = GLib::PtrArray.new :utf8
|
37
|
-
|
38
|
-
GLib::PtrArray.add arr, "test1"
|
39
|
-
GLib::PtrArray.add arr, "test2"
|
40
|
-
GLib::PtrArray.add arr, "test3"
|
41
|
-
|
42
|
-
a = []
|
43
|
-
arr.each do |v|
|
44
|
-
a << v
|
45
|
-
break if v == "test2"
|
46
|
-
end
|
47
|
-
|
48
|
-
assert_equal %w(test1 test2), a
|
49
|
-
end
|
50
|
-
end
|
51
|
-
|
52
|
-
it "includes Enumerable" do
|
53
|
-
_(GLib::PtrArray).must_include Enumerable
|
54
|
-
end
|
55
|
-
|
56
|
-
it "has a working #to_a method" do
|
57
|
-
arr = GLib::PtrArray.new :utf8
|
58
|
-
|
59
|
-
GLib::PtrArray.add arr, "test1"
|
60
|
-
GLib::PtrArray.add arr, "test2"
|
61
|
-
GLib::PtrArray.add arr, "test3"
|
62
|
-
|
63
|
-
assert_equal %w(test1 test2 test3), arr.to_a
|
64
|
-
end
|
65
|
-
|
66
|
-
it "has #add as an instance method too" do
|
67
|
-
arr = GLib::PtrArray.new :utf8
|
68
|
-
arr.add "test1"
|
69
|
-
assert_equal ["test1"], arr.to_a
|
70
|
-
end
|
71
|
-
|
72
|
-
describe "#==" do
|
73
|
-
it "returns true when comparing to an array with the same elements" do
|
74
|
-
arr = GLib::PtrArray.from :utf8, %w(1 2 3)
|
75
|
-
|
76
|
-
_(arr).must_be :==, %w(1 2 3)
|
77
|
-
end
|
78
|
-
|
79
|
-
it "returns false when comparing to an array with different elements" do
|
80
|
-
arr = GLib::PtrArray.from :utf8, %w(1 2 3)
|
81
|
-
|
82
|
-
_(arr).wont_be :==, %w(1 2)
|
83
|
-
end
|
84
|
-
|
85
|
-
it "returns true when comparing to a GPtrArray with the same elements" do
|
86
|
-
arr = GLib::PtrArray.from :utf8, %w(1 2 3)
|
87
|
-
other = GLib::PtrArray.from :utf8, %w(1 2 3)
|
88
|
-
|
89
|
-
_(arr).must_be :==, other
|
90
|
-
end
|
91
|
-
|
92
|
-
it "returns false when comparing to a GPtrArray with different elements" do
|
93
|
-
arr = GLib::PtrArray.from :utf8, %w(1 2 3)
|
94
|
-
other = GLib::PtrArray.from :utf8, %w(1 2)
|
95
|
-
|
96
|
-
_(arr).wont_be :==, other
|
97
|
-
end
|
98
|
-
end
|
99
|
-
|
100
|
-
describe "#index" do
|
101
|
-
it "returns the correct element" do
|
102
|
-
arr = GLib::PtrArray.from :utf8, %w(1 2 3)
|
103
|
-
_(arr.index(1)).must_equal "2"
|
104
|
-
end
|
105
|
-
|
106
|
-
it "raises an error if the index is out of bounds" do
|
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
|
110
|
-
end
|
111
|
-
end
|
112
|
-
end
|
@@ -1,62 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
require "gir_ffi_test_helper"
|
4
|
-
|
5
|
-
describe GObject::RubyClosure do
|
6
|
-
describe ".new" do
|
7
|
-
it "takes a mandatory block argument" do
|
8
|
-
assert_raises ArgumentError do
|
9
|
-
GObject::RubyClosure.new
|
10
|
-
end
|
11
|
-
end
|
12
|
-
|
13
|
-
it "returns a kind of Closure" do
|
14
|
-
c = GObject::RubyClosure.new {}
|
15
|
-
assert_kind_of GObject::Closure, c
|
16
|
-
end
|
17
|
-
end
|
18
|
-
|
19
|
-
describe ".wrap" do
|
20
|
-
it "returns a fully functional object that can invoke the original block" do
|
21
|
-
a = 0
|
22
|
-
c = GObject::RubyClosure.new { a = 2 }
|
23
|
-
c2 = GObject::RubyClosure.wrap(c.to_ptr)
|
24
|
-
c2.invoke_block
|
25
|
-
assert_equal 2, a
|
26
|
-
end
|
27
|
-
end
|
28
|
-
|
29
|
-
describe ".marshaller" do
|
30
|
-
it "invokes its closure argument's block" do
|
31
|
-
a = 0
|
32
|
-
c = GObject::RubyClosure.new { a = 2 }
|
33
|
-
GObject::RubyClosure.marshaller(c, nil, nil, nil, nil)
|
34
|
-
assert_equal 2, a
|
35
|
-
end
|
36
|
-
|
37
|
-
it "works when its closure argument is a GObject::Closure" do
|
38
|
-
a = 0
|
39
|
-
c = GObject::RubyClosure.new { a = 2 }
|
40
|
-
c2 = GObject::Closure.wrap(c.to_ptr)
|
41
|
-
GObject::RubyClosure.marshaller(c2, nil, nil, nil, nil)
|
42
|
-
assert_equal 2, a
|
43
|
-
end
|
44
|
-
|
45
|
-
it "stores the closure's return value in the proper gvalue" do
|
46
|
-
c = GObject::RubyClosure.new { 2 }
|
47
|
-
gv = GObject::Value.new.init GObject::TYPE_INT
|
48
|
-
GObject::RubyClosure.marshaller(c, gv, nil, nil, nil)
|
49
|
-
assert_equal 2, gv.get_value
|
50
|
-
end
|
51
|
-
end
|
52
|
-
|
53
|
-
describe "#invoke" do
|
54
|
-
it "invokes the ruby block" do
|
55
|
-
a = 0
|
56
|
-
c = GObject::RubyClosure.new { a = 2 }
|
57
|
-
c2 = GObject::Closure.wrap(c.to_ptr)
|
58
|
-
c2.invoke nil, []
|
59
|
-
assert_equal 2, a
|
60
|
-
end
|
61
|
-
end
|
62
|
-
end
|
@@ -1,76 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
require "gir_ffi_test_helper"
|
4
|
-
|
5
|
-
describe GLib::SList do
|
6
|
-
it "knows its element type" do
|
7
|
-
arr = GLib::SList.new :gint32
|
8
|
-
assert_equal :gint32, arr.element_type
|
9
|
-
end
|
10
|
-
|
11
|
-
describe "#prepend" do
|
12
|
-
it "prepends integer values" do
|
13
|
-
lst = GLib::SList.new :gint32
|
14
|
-
res = lst.prepend 1
|
15
|
-
assert_equal 1, res.data
|
16
|
-
end
|
17
|
-
|
18
|
-
it "prepends string values" do
|
19
|
-
lst = GLib::SList.new :utf8
|
20
|
-
res = lst.prepend "bla"
|
21
|
-
assert_equal "bla", res.data
|
22
|
-
end
|
23
|
-
|
24
|
-
it "prepends multiple values into a single list" do
|
25
|
-
lst = GLib::SList.new :gint32
|
26
|
-
|
27
|
-
res = lst.prepend 1
|
28
|
-
res2 = res.prepend 2
|
29
|
-
|
30
|
-
assert_equal 2, res2.data
|
31
|
-
assert_equal 1, res.data
|
32
|
-
assert_equal res.to_ptr, res2.next.to_ptr
|
33
|
-
end
|
34
|
-
end
|
35
|
-
|
36
|
-
describe "::from" do
|
37
|
-
it "creates a GSList from a Ruby array" do
|
38
|
-
lst = GLib::SList.from :gint32, [3, 2, 1]
|
39
|
-
assert_equal [3, 2, 1], lst.to_a
|
40
|
-
end
|
41
|
-
|
42
|
-
it "return its argument if given a GSList" do
|
43
|
-
lst = GLib::SList.from :gint32, [3, 2, 1]
|
44
|
-
lst2 = GLib::SList.from :gint32, lst
|
45
|
-
assert_equal lst, lst2
|
46
|
-
end
|
47
|
-
end
|
48
|
-
|
49
|
-
describe "#==" do
|
50
|
-
it "returns true when comparing to an array with the same elements" do
|
51
|
-
list = GLib::SList.from :gint32, [1, 2, 3]
|
52
|
-
|
53
|
-
_(list).must_be :==, [1, 2, 3]
|
54
|
-
end
|
55
|
-
|
56
|
-
it "returns false when comparing to an array with different elements" do
|
57
|
-
list = GLib::SList.from :gint32, [1, 2, 3]
|
58
|
-
|
59
|
-
_(list).wont_be :==, [1, 2]
|
60
|
-
end
|
61
|
-
|
62
|
-
it "returns true when comparing to a list with the same elements" do
|
63
|
-
list = GLib::SList.from :gint32, [1, 2, 3]
|
64
|
-
other = GLib::SList.from :gint32, [1, 2, 3]
|
65
|
-
|
66
|
-
_(list).must_be :==, other
|
67
|
-
end
|
68
|
-
|
69
|
-
it "returns false when comparing to a list with different elements" do
|
70
|
-
list = GLib::SList.from :gint32, [1, 2, 3]
|
71
|
-
other = GLib::SList.from :gint32, [1, 2]
|
72
|
-
|
73
|
-
_(list).wont_be :==, other
|
74
|
-
end
|
75
|
-
end
|
76
|
-
end
|
data/test/ffi-glib/strv_test.rb
DELETED
@@ -1,60 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
require "base_test_helper"
|
4
|
-
|
5
|
-
describe GLib::Strv do
|
6
|
-
describe "::from" do
|
7
|
-
it "creates a Strv from a Ruby array" do
|
8
|
-
strv = GLib::Strv.from %w(1 2 3)
|
9
|
-
_(strv).must_be_instance_of GLib::Strv
|
10
|
-
_(strv.to_a).must_equal %w(1 2 3)
|
11
|
-
end
|
12
|
-
|
13
|
-
it "return its argument if given a Strv" do
|
14
|
-
strv = GLib::Strv.from %w(1 2 3)
|
15
|
-
strv2 = GLib::Strv.from strv
|
16
|
-
assert strv2.equal? strv
|
17
|
-
end
|
18
|
-
|
19
|
-
it "wraps its argument if given a pointer" do
|
20
|
-
strv = GLib::Strv.from %w(1 2 3)
|
21
|
-
|
22
|
-
pointer = strv.to_ptr
|
23
|
-
_(pointer).must_be_kind_of FFI::Pointer
|
24
|
-
|
25
|
-
strv2 = GLib::Strv.from pointer
|
26
|
-
|
27
|
-
_(strv2).must_be_kind_of GLib::Strv
|
28
|
-
refute strv2.equal? strv
|
29
|
-
_(strv2.to_a).must_equal strv.to_a
|
30
|
-
end
|
31
|
-
end
|
32
|
-
|
33
|
-
describe "#==" do
|
34
|
-
it "returns true when comparing to an array with the same elements" do
|
35
|
-
strv = GLib::Strv.from %w(1 2 3)
|
36
|
-
|
37
|
-
_(strv).must_be :==, %w(1 2 3)
|
38
|
-
end
|
39
|
-
|
40
|
-
it "returns false when comparing to an array with different elements" do
|
41
|
-
strv = GLib::Strv.from %w(1 2 3)
|
42
|
-
|
43
|
-
_(strv).wont_be :==, %w(1 2)
|
44
|
-
end
|
45
|
-
|
46
|
-
it "returns true when comparing to a strv with the same elements" do
|
47
|
-
strv = GLib::Strv.from %w(1 2 3)
|
48
|
-
other = GLib::Strv.from %w(1 2 3)
|
49
|
-
|
50
|
-
_(strv).must_be :==, other
|
51
|
-
end
|
52
|
-
|
53
|
-
it "returns false when comparing to a strv with different elements" do
|
54
|
-
strv = GLib::Strv.from %w(1 2 3)
|
55
|
-
other = GLib::Strv.from %w(1 2)
|
56
|
-
|
57
|
-
_(strv).wont_be :==, other
|
58
|
-
end
|
59
|
-
end
|
60
|
-
end
|