gir_ffi 0.6.6 → 0.6.7

Sign up to get free protection for your applications and to get access to all the features.
Files changed (166) hide show
  1. data/History.txt +14 -0
  2. data/TODO.rdoc +23 -5
  3. data/lib/ffi-glib/array.rb +14 -15
  4. data/lib/ffi-glib/container_class_methods.rb +0 -1
  5. data/lib/ffi-glib/hash_table.rb +3 -4
  6. data/lib/ffi-glib/ptr_array.rb +12 -4
  7. data/lib/ffi-glib/sized_array.rb +27 -7
  8. data/lib/ffi-gobject.rb +14 -15
  9. data/lib/ffi-gobject/closure.rb +1 -1
  10. data/lib/ffi-gobject/object.rb +40 -15
  11. data/lib/ffi-gobject/ruby_closure.rb +0 -1
  12. data/lib/ffi-gobject/value.rb +45 -21
  13. data/lib/ffi-gobject_introspection/i_arg_info.rb +4 -0
  14. data/lib/ffi-gobject_introspection/i_base_info.rb +42 -2
  15. data/lib/ffi-gobject_introspection/i_callable_info.rb +8 -0
  16. data/lib/ffi-gobject_introspection/i_enum_info.rb +1 -4
  17. data/lib/ffi-gobject_introspection/i_interface_info.rb +1 -0
  18. data/lib/ffi-gobject_introspection/i_object_info.rb +2 -0
  19. data/lib/ffi-gobject_introspection/i_repository.rb +2 -3
  20. data/lib/ffi-gobject_introspection/i_struct_info.rb +3 -8
  21. data/lib/ffi-gobject_introspection/lib.rb +3 -0
  22. data/lib/gir_ffi-base.rb +3 -1
  23. data/lib/gir_ffi-base/gir_ffi/struct.rb +27 -0
  24. data/lib/gir_ffi-base/glib/boolean.rb +13 -1
  25. data/lib/gir_ffi-base/gobject.rb +7 -0
  26. data/lib/gir_ffi-base/gobject/lib.rb +0 -2
  27. data/lib/gir_ffi.rb +1 -3
  28. data/lib/gir_ffi/arg_helper.rb +4 -85
  29. data/lib/gir_ffi/builder.rb +5 -5
  30. data/lib/gir_ffi/builder_helper.rb +7 -0
  31. data/lib/gir_ffi/builders/argument_builder.rb +132 -0
  32. data/lib/gir_ffi/{base_argument_builder.rb → builders/base_argument_builder.rb} +32 -41
  33. data/lib/gir_ffi/builders/base_type_builder.rb +47 -0
  34. data/lib/gir_ffi/builders/callback_builder.rb +38 -0
  35. data/lib/gir_ffi/builders/constant_builder.rb +18 -0
  36. data/lib/gir_ffi/builders/enum_builder.rb +62 -0
  37. data/lib/gir_ffi/builders/error_argument_builder.rb +18 -0
  38. data/lib/gir_ffi/builders/field_builder.rb +94 -0
  39. data/lib/gir_ffi/builders/function_builder.rb +123 -0
  40. data/lib/gir_ffi/builders/interface_builder.rb +29 -0
  41. data/lib/gir_ffi/builders/mapping_method_builder.rb +88 -0
  42. data/lib/gir_ffi/builders/module_builder.rb +124 -0
  43. data/lib/gir_ffi/{null_argument_builder.rb → builders/null_argument_builder.rb} +0 -0
  44. data/lib/gir_ffi/builders/null_builder.rb +11 -0
  45. data/lib/gir_ffi/builders/object_builder.rb +123 -0
  46. data/lib/gir_ffi/{builder/property.rb → builders/property_builder.rb} +0 -0
  47. data/lib/gir_ffi/builders/registered_type_builder.rb +50 -0
  48. data/lib/gir_ffi/builders/return_value_builder.rb +68 -0
  49. data/lib/gir_ffi/builders/signal_builder.rb +91 -0
  50. data/lib/gir_ffi/builders/struct_builder.rb +35 -0
  51. data/lib/gir_ffi/builders/type_builder.rb +40 -0
  52. data/lib/gir_ffi/builders/unintrospectable_builder.rb +35 -0
  53. data/lib/gir_ffi/builders/union_builder.rb +34 -0
  54. data/lib/gir_ffi/builders/user_defined_builder.rb +103 -0
  55. data/lib/gir_ffi/builders/with_layout.rb +55 -0
  56. data/lib/gir_ffi/builders/with_methods.rb +44 -0
  57. data/lib/gir_ffi/callback_base.rb +31 -0
  58. data/lib/gir_ffi/class_base.rb +16 -10
  59. data/lib/gir_ffi/enum_base.rb +8 -4
  60. data/lib/gir_ffi/ffi_ext/pointer.rb +19 -2
  61. data/lib/gir_ffi/in_out_pointer.rb +38 -39
  62. data/lib/gir_ffi/in_pointer.rb +33 -18
  63. data/lib/gir_ffi/info_ext.rb +0 -4
  64. data/lib/gir_ffi/info_ext/i_arg_info.rb +0 -18
  65. data/lib/gir_ffi/info_ext/i_callable_info.rb +2 -1
  66. data/lib/gir_ffi/info_ext/i_registered_type_info.rb +6 -8
  67. data/lib/gir_ffi/info_ext/i_signal_info.rb +6 -21
  68. data/lib/gir_ffi/info_ext/i_type_info.rb +54 -29
  69. data/lib/gir_ffi/info_ext/safe_constant_name.rb +8 -1
  70. data/lib/gir_ffi/interface_base.rb +1 -1
  71. data/lib/gir_ffi/module_base.rb +5 -1
  72. data/lib/gir_ffi/object_base.rb +5 -1
  73. data/lib/gir_ffi/setter_argument_info.rb +4 -0
  74. data/lib/gir_ffi/signal_base.rb +21 -0
  75. data/lib/gir_ffi/struct_base.rb +24 -0
  76. data/lib/gir_ffi/type_base.rb +11 -0
  77. data/lib/gir_ffi/type_map.rb +4 -2
  78. data/lib/gir_ffi/union_base.rb +24 -0
  79. data/lib/gir_ffi/version.rb +1 -1
  80. data/tasks/test.rake +73 -7
  81. data/test/base_test_helper.rb +3 -19
  82. data/test/ffi-glib/array_test.rb +6 -0
  83. data/test/ffi-glib/ptr_array_test.rb +13 -0
  84. data/test/ffi-glib/ruby_closure_test.rb +7 -7
  85. data/test/ffi-glib/sized_array_test.rb +2 -2
  86. data/test/ffi-gobject/gobject_test.rb +3 -12
  87. data/test/ffi-gobject/object_test.rb +33 -2
  88. data/test/ffi-gobject/value_test.rb +114 -1
  89. data/test/ffi-gobject_introspection/i_enum_info_test.rb +2 -2
  90. data/test/ffi-gobject_introspection/i_object_info_test.rb +3 -3
  91. data/test/ffi-gobject_introspection/i_repository_test.rb +26 -21
  92. data/test/ffi-gobject_test.rb +14 -14
  93. data/test/gir_ffi-base/glib/boolean_test.rb +6 -0
  94. data/test/gir_ffi/arg_helper_test.rb +2 -122
  95. data/test/gir_ffi/builder_test.rb +67 -204
  96. data/test/gir_ffi/{argument_builder_test.rb → builders/argument_builder_test.rb} +230 -108
  97. data/test/gir_ffi/builders/base_argument_builder_test.rb +5 -0
  98. data/test/gir_ffi/builders/callback_builder_test.rb +50 -0
  99. data/test/gir_ffi/builders/constant_builder_test.rb +4 -0
  100. data/test/gir_ffi/{builder/type/enum_test.rb → builders/enum_builder_test.rb} +2 -3
  101. data/test/gir_ffi/builders/field_builder_test.rb +94 -0
  102. data/test/gir_ffi/{function_builder_test.rb → builders/function_builder_test.rb} +43 -24
  103. data/test/gir_ffi/{builder/type/interface_test.rb → builders/interface_builder_test.rb} +2 -2
  104. data/test/gir_ffi/{builder/module_test.rb → builders/module_builder_test.rb} +12 -13
  105. data/test/gir_ffi/{builder/type/object_test.rb → builders/object_builder_test.rb} +9 -9
  106. data/test/gir_ffi/{return_value_builder_test.rb → builders/return_value_builder_test.rb} +94 -58
  107. data/test/gir_ffi/builders/signal_builder_test.rb +62 -0
  108. data/test/gir_ffi/{builder/type/struct_test.rb → builders/struct_builder_test.rb} +36 -19
  109. data/test/gir_ffi/{builder/type/unintrospectable_test.rb → builders/unintrospectable_builder_test.rb} +3 -3
  110. data/test/gir_ffi/builders/union_builder_test.rb +29 -0
  111. data/test/gir_ffi/{builder/type/user_defined_test.rb → builders/user_defined_builder_test.rb} +2 -2
  112. data/test/gir_ffi/callback_base_test.rb +11 -0
  113. data/test/gir_ffi/class_base_test.rb +22 -22
  114. data/test/gir_ffi/ffi_ext/pointer_test.rb +18 -0
  115. data/test/gir_ffi/in_out_pointer_test.rb +0 -7
  116. data/test/gir_ffi/in_pointer_test.rb +27 -3
  117. data/test/gir_ffi/info_ext/i_signal_info_test.rb +16 -44
  118. data/test/gir_ffi/info_ext/i_type_info_test.rb +315 -74
  119. data/test/gir_ffi/info_ext/safe_constant_name_test.rb +6 -0
  120. data/test/gir_ffi/interface_base_test.rb +3 -5
  121. data/test/gir_ffi/object_base_test.rb +10 -6
  122. data/test/gir_ffi/type_map_test.rb +2 -2
  123. data/test/gir_ffi/unintrospectable_type_info_test.rb +2 -2
  124. data/test/gir_ffi_test_helper.rb +12 -4
  125. data/test/integration/generated_gimarshallingtests_test.rb +436 -76
  126. data/test/integration/generated_gio_test.rb +5 -11
  127. data/test/integration/generated_gobject_test.rb +8 -0
  128. data/test/integration/generated_regress_test.rb +755 -309
  129. data/test/integration/generated_secret_test.rb +2 -1
  130. metadata +73 -72
  131. data/lib/ffi-gobject/ruby_style.rb +0 -23
  132. data/lib/gir_ffi/argument_builder.rb +0 -154
  133. data/lib/gir_ffi/builder/field.rb +0 -60
  134. data/lib/gir_ffi/builder/module.rb +0 -127
  135. data/lib/gir_ffi/builder/type.rb +0 -39
  136. data/lib/gir_ffi/builder/type/base.rb +0 -48
  137. data/lib/gir_ffi/builder/type/callback.rb +0 -30
  138. data/lib/gir_ffi/builder/type/constant.rb +0 -22
  139. data/lib/gir_ffi/builder/type/enum.rb +0 -66
  140. data/lib/gir_ffi/builder/type/interface.rb +0 -33
  141. data/lib/gir_ffi/builder/type/object.rb +0 -134
  142. data/lib/gir_ffi/builder/type/registered_type.rb +0 -62
  143. data/lib/gir_ffi/builder/type/struct.rb +0 -34
  144. data/lib/gir_ffi/builder/type/unintrospectable.rb +0 -39
  145. data/lib/gir_ffi/builder/type/union.rb +0 -34
  146. data/lib/gir_ffi/builder/type/user_defined.rb +0 -107
  147. data/lib/gir_ffi/builder/type/with_layout.rb +0 -62
  148. data/lib/gir_ffi/builder/type/with_methods.rb +0 -64
  149. data/lib/gir_ffi/callback.rb +0 -72
  150. data/lib/gir_ffi/callback_helper.rb +0 -11
  151. data/lib/gir_ffi/error_argument_builder.rb +0 -17
  152. data/lib/gir_ffi/function_builder.rb +0 -112
  153. data/lib/gir_ffi/info_ext/i_enum_info.rb +0 -11
  154. data/lib/gir_ffi/info_ext/i_object_info.rb +0 -11
  155. data/lib/gir_ffi/info_ext/i_struct_info.rb +0 -11
  156. data/lib/gir_ffi/info_ext/i_union_info.rb +0 -12
  157. data/lib/gir_ffi/return_value_builder.rb +0 -81
  158. data/test/ffi-gobject/ruby_style_test.rb +0 -38
  159. data/test/gir_ffi/base_argument_builder_test.rb +0 -13
  160. data/test/gir_ffi/builder/type/callback_test.rb +0 -6
  161. data/test/gir_ffi/builder/type/constant_test.rb +0 -4
  162. data/test/gir_ffi/builder/type/union_test.rb +0 -12
  163. data/test/gir_ffi/callback_helper_test.rb +0 -10
  164. data/test/gir_ffi/callback_test.rb +0 -49
  165. data/test/gir_ffi/info_ext/i_arg_info_test.rb +0 -39
  166. data/test/gir_ffi/info_ext/i_object_info_test.rb +0 -14
@@ -1,3 +1,3 @@
1
1
  module GirFFI
2
- VERSION = "0.6.6"
2
+ VERSION = "0.6.7"
3
3
  end
data/tasks/test.rake CHANGED
@@ -9,15 +9,21 @@ class Listener
9
9
 
10
10
  def initialize
11
11
  @inside_class = false
12
+ @stack = []
13
+ @skip_state = []
12
14
  end
13
15
 
14
16
  attr_accessor :result
15
17
  attr_accessor :namespace
16
18
 
17
19
  def tag_start name, attrs
18
- return if attrs['disguised'] == '1'
19
- return if attrs['introspectable'] == '0'
20
- return if attrs['glib:is-gtype-struct-for']
20
+ @stack.push [name, attrs]
21
+ if @skip_state.last || skippable?(attrs)
22
+ @skip_state.push true
23
+ return
24
+ else
25
+ @skip_state.push false
26
+ end
21
27
 
22
28
  obj_name = attrs['name']
23
29
  case name
@@ -25,26 +31,86 @@ class Listener
25
31
  result.puts " it \"has the constant #{obj_name}\" do"
26
32
  when "record", "class", "enumeration", "bitfield", "interface", "union"
27
33
  result.puts " describe \"#{namespace}::#{obj_name}\" do"
28
- @inside_class = true
34
+ @inside_class = name
29
35
  when "constructor"
30
36
  result.puts " it \"creates an instance using ##{obj_name}\" do"
37
+ when "field"
38
+ if @inside_class != 'class'
39
+ if attrs['private'] == "1"
40
+ result.puts " it \"has a private field #{obj_name}\" do"
41
+ elsif attrs['writable'] == "1"
42
+ result.puts " it \"has a writable field #{obj_name}\" do"
43
+ else
44
+ result.puts " it \"has a read-only field #{obj_name}\" do"
45
+ end
46
+ end
31
47
  when "function", "method"
32
48
  spaces = @inside_class ? " " : ""
33
49
  result.puts " #{spaces}it \"has a working #{name} ##{obj_name}\" do"
34
50
  when "member"
35
51
  result.puts " it \"has the member :#{obj_name}\" do"
36
- when "type", "return-value", "parameters", "parameter", "doc", "array"
52
+ when "namespace"
53
+ result.puts "describe #{obj_name} do"
54
+ when "property"
55
+ accessor_name = obj_name.gsub(/-/, '_')
56
+ result.puts " describe \"its '#{obj_name}' property\" do"
57
+ result.puts " it \"can be retrieved with #get_property\" do"
58
+ result.puts " end"
59
+ result.puts " it \"can be retrieved with ##{accessor_name}\" do"
60
+ result.puts " end"
61
+ if attrs['writable'] == '1'
62
+ result.puts " it \"can be set with #set_property\" do"
63
+ result.puts " end"
64
+ result.puts " it \"can be set with ##{accessor_name}=\" do"
65
+ result.puts " end"
66
+ end
67
+ when "glib:signal"
68
+ result.puts " it \"handles the '#{obj_name}' signal\" do"
69
+ when "type", "alias", "return-value", "parameters",
70
+ "instance-parameter", "parameter", "doc", "array",
71
+ "repository", "include", "package"
72
+ # Not printed"
37
73
  else
38
- puts "Skipping #{name}"
74
+ puts "Skipping #{name}: #{attrs}"
39
75
  end
40
76
  end
41
77
 
42
78
  def tag_end name
79
+ org_name, _ = *@stack.pop
80
+ skipping = @skip_state.pop
81
+ raise "Expected #{org_name}, got #{name}" if org_name != name
82
+ return if skipping
83
+
43
84
  case name
44
- when "record", "class", "enumeration", "bitfield", "interface", "union"
85
+ when "constant"
86
+ result.puts " end"
87
+ when "record", "class", "enumeration", "bitfield",
88
+ "interface", "union"
89
+ result.puts " end"
45
90
  @inside_class = false
91
+ when "function", "method"
92
+ if @inside_class
93
+ result.puts " end"
94
+ else
95
+ result.puts " end"
96
+ end
97
+ when "constructor", "member", "property", "glib:signal"
98
+ result.puts " end"
99
+ when "field"
100
+ if @inside_class != 'class'
101
+ result.puts " end"
102
+ end
103
+ when "namespace"
104
+ result.puts "end"
46
105
  end
47
106
  end
107
+
108
+ def skippable? attrs
109
+ return true if attrs['disguised'] == '1'
110
+ return true if attrs['introspectable'] == '0'
111
+ return true if attrs['glib:is-gtype-struct-for']
112
+ false
113
+ end
48
114
  end
49
115
 
50
116
  namespace :test do
@@ -4,7 +4,9 @@ end
4
4
 
5
5
  if RUBY_VERSION >= "1.9"
6
6
  require 'simplecov'
7
- SimpleCov.start
7
+ SimpleCov.start do
8
+ add_filter "/test/"
9
+ end
8
10
  end
9
11
 
10
12
  require 'minitest/autorun'
@@ -37,15 +39,6 @@ Thread.abort_on_exception = true
37
39
  class Minitest::Test
38
40
  include RR::Adapters::TestUnit
39
41
 
40
- def assert_nothing_raised
41
- yield
42
- assert true
43
- end
44
-
45
- def assert_not_nil it
46
- refute_nil it
47
- end
48
-
49
42
  def assert_defines_singleton_method klass, method, msg = nil
50
43
  method = method.to_sym
51
44
  methods = klass.singleton_methods(false).map { |name| name.to_sym }
@@ -84,12 +77,3 @@ class Minitest::Test
84
77
  refute_includes methods, method, msg
85
78
  end
86
79
  end
87
-
88
- class Minitest::Spec
89
- class << self
90
- alias :setup :before
91
- alias :teardown :after
92
- alias :should :it
93
- alias :context :describe
94
- end
95
- end
@@ -146,5 +146,11 @@ describe GLib::Array do
146
146
  arr = GLib::Array.from GObject::EnumValue, vals
147
147
  arr.index(1).value.must_equal 2
148
148
  end
149
+
150
+ it "raises an error if the index is out of bounds" do
151
+ arr = GLib::Array.from :gint32, [1, 2, 3]
152
+ lambda { arr.index(16) }.must_raise IndexError
153
+ lambda { arr.index(-1) }.must_raise IndexError
154
+ end
149
155
  end
150
156
  end
@@ -94,4 +94,17 @@ describe GLib::PtrArray do
94
94
  arr.wont_be :==, other
95
95
  end
96
96
  end
97
+
98
+ describe "#index" do
99
+ it "returns the correct element" do
100
+ arr = GLib::PtrArray.from :utf8, ["1", "2", "3"]
101
+ arr.index(1).must_equal "2"
102
+ end
103
+
104
+ it "raises an error if the index is out of bounds" do
105
+ arr = GLib::PtrArray.from :utf8, ["1", "2", "3"]
106
+ lambda { arr.index(16) }.must_raise IndexError
107
+ lambda { arr.index(-1) }.must_raise IndexError
108
+ end
109
+ end
97
110
  end
@@ -1,18 +1,18 @@
1
1
  require 'gir_ffi_test_helper'
2
2
 
3
3
  describe GObject::RubyClosure do
4
- should "have a constructor with a mandatory block argument" do
4
+ it "has a constructor with a mandatory block argument" do
5
5
  assert_raises ArgumentError do
6
6
  GObject::RubyClosure.new
7
7
  end
8
8
  end
9
9
 
10
- should "be a kind of Closure" do
10
+ it "is a kind of Closure" do
11
11
  c = GObject::RubyClosure.new {}
12
12
  assert_kind_of GObject::Closure, c
13
13
  end
14
14
 
15
- should "be able to retrieve its block from its struct" do
15
+ it "is able to retrieve its block from its struct" do
16
16
  a = 0
17
17
  c = GObject::RubyClosure.new { a = 2 }
18
18
  c2 = GObject::RubyClosure.wrap(c.to_ptr)
@@ -21,14 +21,14 @@ describe GObject::RubyClosure do
21
21
  end
22
22
 
23
23
  describe "its #marshaller singleton method" do
24
- should "invoke its closure argument's block" do
24
+ it "invokes its closure argument's block" do
25
25
  a = 0
26
26
  c = GObject::RubyClosure.new { a = 2 }
27
27
  GObject::RubyClosure.marshaller(c, nil, 0, nil, nil, nil)
28
28
  assert_equal 2, a
29
29
  end
30
30
 
31
- should "work when its closure argument is a GObject::Closure" do
31
+ it "works when its closure argument is a GObject::Closure" do
32
32
  a = 0
33
33
  c = GObject::RubyClosure.new { a = 2 }
34
34
  c2 = GObject::Closure.wrap(c.to_ptr)
@@ -36,7 +36,7 @@ describe GObject::RubyClosure do
36
36
  assert_equal 2, a
37
37
  end
38
38
 
39
- should "store the closure's return value in the proper gvalue" do
39
+ it "stores the closure's return value in the proper gvalue" do
40
40
  c = GObject::RubyClosure.new { 2 }
41
41
  gv = GObject::Value.new
42
42
  GObject::RubyClosure.marshaller(c, gv, 0, nil, nil, nil)
@@ -44,7 +44,7 @@ describe GObject::RubyClosure do
44
44
  end
45
45
  end
46
46
 
47
- should "have GObject::Closure#invoke call its block" do
47
+ it "has GObject::Closure#invoke call its block" do
48
48
  a = 0
49
49
  c = GObject::RubyClosure.new { a = 2 }
50
50
  c2 = GObject::Closure.wrap(c.to_ptr)
@@ -36,7 +36,7 @@ describe GLib::SizedArray do
36
36
  end
37
37
 
38
38
  describe "::from" do
39
- context "from a Ruby array" do
39
+ describe "from a Ruby array" do
40
40
  it "creates a GLib::SizedArray with the same elements" do
41
41
  arr = GLib::SizedArray.from :gint32, 3, [3, 2, 1]
42
42
  arr.must_be_instance_of GLib::SizedArray
@@ -53,7 +53,7 @@ describe GLib::SizedArray do
53
53
  end
54
54
  end
55
55
 
56
- context "from a GLib::SizedArray" do
56
+ describe "from a GLib::SizedArray" do
57
57
  it "return its argument" do
58
58
  arr = GLib::SizedArray.from :gint32, 3, [3, 2, 1]
59
59
  arr2 = GLib::SizedArray.from :gint32, 3, arr
@@ -5,19 +5,10 @@ require 'ffi-gobject'
5
5
  GirFFI.setup :GIMarshallingTests
6
6
 
7
7
  describe GObject do
8
- it "has type_init as a public method" do
9
- assert GObject.respond_to?('type_init')
10
- end
11
-
12
- it "does not have g_type_init as a public method" do
13
- assert GObject.respond_to?('g_type_init') == false
14
- end
15
-
16
- context "::type_init" do
8
+ describe ".type_init" do
17
9
  it "does not raise an error" do
18
- assert_nothing_raised do
19
- GObject.type_init
20
- end
10
+ GObject.type_init
11
+ pass
21
12
  end
22
13
  end
23
14
 
@@ -8,9 +8,40 @@ describe GObject::Object do
8
8
  assert_equal 1,
9
9
  GObject::Object.instance_method("get_property").arity
10
10
  end
11
+ end
12
+
13
+ describe "automatic accessor methods" do
14
+ class AccessorTest < GObject::Object
15
+ def get_x
16
+ @x
17
+ end
18
+ def set_x(val)
19
+ @x = val
20
+ end
21
+ end
22
+
23
+ subject { AccessorTest.new GObject::TYPE_OBJECT, nil }
24
+
25
+ it 'reads x by calling get_x' do
26
+ subject.set_x(1)
27
+ assert_equal 1, subject.x
28
+ end
29
+
30
+ it 'writes x by calling set_x' do
31
+ subject.x = 2
32
+ assert_equal 2, subject.x
33
+ end
34
+ end
35
+
36
+ describe "#signal_connect" do
37
+ subject { GObject::Object.new GObject::TYPE_OBJECT, nil }
38
+ it 'delegates to GObject' do
39
+ mock(GObject).signal_connect(subject, 'some-event')
40
+ subject.signal_connect('some-event') do
41
+ nothing
42
+ end
11
43
 
12
- it 'includes GObject::RubyStyle' do
13
- assert GObject::Object.included_modules.include?(GObject::RubyStyle)
44
+ RR.verify
14
45
  end
15
46
  end
16
47
  end
@@ -43,12 +43,69 @@ describe GObject::Value do
43
43
  end
44
44
 
45
45
  describe "#set_value" do
46
- it "handles :int64" do
46
+ it "handles char values" do
47
+ value = 83
48
+ gv = GObject::Value.for_g_type GObject::TYPE_CHAR
49
+ gv.set_value value
50
+ gv.get_char.must_equal value
51
+ end
52
+
53
+ it "handles GType values" do
54
+ value = GObject::TYPE_STRING
55
+ gv = GObject::Value.for_g_type GObject::TYPE_GTYPE
56
+ gv.set_value value
57
+ gv.get_gtype.must_equal value
58
+ end
59
+
60
+ it "handles int64 values" do
47
61
  value = 0x1234_5678_9012_3456
48
62
  gv = GObject::Value.for_g_type GObject::TYPE_INT64
49
63
  gv.set_value value
50
64
  gv.get_int64.must_equal value
51
65
  end
66
+
67
+ it "handles long values" do
68
+ value = 0x1234_5678_9012_3456
69
+ gv = GObject::Value.for_g_type GObject::TYPE_LONG
70
+ gv.set_value value
71
+ gv.get_long.must_equal value
72
+ end
73
+
74
+ it "handles uchar values" do
75
+ value = 83
76
+ gv = GObject::Value.for_g_type GObject::TYPE_UCHAR
77
+ gv.set_value value
78
+ gv.get_uchar.must_equal value
79
+ end
80
+
81
+ it "handles uint values" do
82
+ value = 0x1234_5678
83
+ gv = GObject::Value.for_g_type GObject::TYPE_UINT
84
+ gv.set_value value
85
+ gv.get_uint.must_equal value
86
+ end
87
+
88
+ it "handles uint64 values" do
89
+ value = 0x1234_5678_9012_3456
90
+ gv = GObject::Value.for_g_type GObject::TYPE_UINT64
91
+ gv.set_value value
92
+ gv.get_uint64.must_equal value
93
+ end
94
+
95
+ it "handles ulong values" do
96
+ value = 0x1234_5678_9012_3456
97
+ gv = GObject::Value.for_g_type GObject::TYPE_ULONG
98
+ gv.set_value value
99
+ gv.get_ulong.must_equal value
100
+ end
101
+
102
+ it "handles variant values" do
103
+ value = GLib::Variant.new_string("Foo")
104
+ gv = GObject::Value.for_g_type GObject::TYPE_VARIANT
105
+ gv.set_value value
106
+ gv.get_variant.must_equal value
107
+ end
108
+
52
109
  end
53
110
 
54
111
  describe "#get_value" do
@@ -64,6 +121,20 @@ describe GObject::Value do
64
121
  assert_equal true, result
65
122
  end
66
123
 
124
+ it "unwraps a char" do
125
+ value = 3
126
+ gv = GObject::Value.for_g_type GObject::TYPE_CHAR
127
+ gv.set_char value
128
+ gv.get_value.must_equal value
129
+ end
130
+
131
+ it "unwraps a GType" do
132
+ value = GObject::TYPE_STRING
133
+ gv = GObject::Value.for_g_type GObject::TYPE_GTYPE
134
+ gv.set_gtype value
135
+ gv.get_value.must_equal value
136
+ end
137
+
67
138
  it "unwraps an int64" do
68
139
  value = 0x1234_5678_9012_3456
69
140
  gv = GObject::Value.for_g_type GObject::TYPE_INT64
@@ -71,6 +142,48 @@ describe GObject::Value do
71
142
  gv.get_value.must_equal value
72
143
  end
73
144
 
145
+ it "unwraps a long" do
146
+ value = 0x1234_5678_9012_3456
147
+ gv = GObject::Value.for_g_type GObject::TYPE_LONG
148
+ gv.set_long value
149
+ gv.get_value.must_equal value
150
+ end
151
+
152
+ it "unwraps an uchar" do
153
+ value = 3
154
+ gv = GObject::Value.for_g_type GObject::TYPE_UCHAR
155
+ gv.set_uchar value
156
+ gv.get_value.must_equal value
157
+ end
158
+
159
+ it "unwraps an uint" do
160
+ value = 0x1234_5678
161
+ gv = GObject::Value.for_g_type GObject::TYPE_UINT
162
+ gv.set_uint value
163
+ gv.get_value.must_equal value
164
+ end
165
+
166
+ it "unwraps an uint64" do
167
+ value = 0x1234_5678_9012_3456
168
+ gv = GObject::Value.for_g_type GObject::TYPE_UINT64
169
+ gv.set_uint64 value
170
+ gv.get_value.must_equal value
171
+ end
172
+
173
+ it "unwraps a ulong" do
174
+ value = 0x1234_5678_9012_3456
175
+ gv = GObject::Value.for_g_type GObject::TYPE_ULONG
176
+ gv.set_ulong value
177
+ gv.get_value.must_equal value
178
+ end
179
+
180
+ it "unwraps a variant" do
181
+ value = GLib::Variant.new_string("Foo")
182
+ gv = GObject::Value.for_g_type GObject::TYPE_VARIANT
183
+ gv.set_variant value
184
+ gv.get_value.must_equal value
185
+ end
186
+
74
187
  it "works with a ByteArray" do
75
188
  ba = GLib::ByteArray.new.append("some bytes")
76
189
  v = GObject::Value.for_g_type GObject.type_from_name("GByteArray")