gir_ffi 0.7.7 → 0.7.8
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 +9 -0
- data/lib/ffi-glib/array.rb +1 -1
- data/lib/ffi-glib/error.rb +1 -2
- data/lib/ffi-glib/hash_table.rb +2 -2
- data/lib/ffi-glib/variant.rb +1 -1
- data/lib/ffi-gobject/base.rb +23 -23
- data/lib/ffi-gobject/object.rb +7 -3
- data/lib/ffi-gobject/value.rb +6 -1
- data/lib/ffi-gobject.rb +9 -6
- data/lib/ffi-gobject_introspection/i_base_info.rb +3 -3
- data/lib/ffi-gobject_introspection/i_constant_info.rb +1 -1
- data/lib/ffi-gobject_introspection/i_repository.rb +4 -1
- data/lib/ffi-gobject_introspection/i_type_info.rb +1 -1
- data/lib/ffi-gobject_introspection/i_unresolved_info.rb +7 -0
- data/lib/ffi-gobject_introspection/lib.rb +1 -1
- data/lib/gir_ffi/builders/argument_builder.rb +1 -1
- data/lib/gir_ffi/builders/c_to_ruby_convertor.rb +37 -29
- data/lib/gir_ffi/builders/callback_argument_builder.rb +57 -27
- data/lib/gir_ffi/builders/closure_convertor.rb +12 -8
- data/lib/gir_ffi/builders/closure_to_pointer_convertor.rb +12 -8
- data/lib/gir_ffi/builders/constructor_result_convertor.rb +11 -7
- data/lib/gir_ffi/builders/field_builder.rb +1 -1
- data/lib/gir_ffi/builders/function_builder.rb +1 -1
- data/lib/gir_ffi/builders/mapping_method_builder.rb +1 -1
- data/lib/gir_ffi/builders/marshalling_method_builder.rb +2 -2
- data/lib/gir_ffi/builders/method_template.rb +1 -1
- data/lib/gir_ffi/builders/null_convertor.rb +11 -7
- data/lib/gir_ffi/builders/property_builder.rb +1 -1
- data/lib/gir_ffi/builders/ruby_to_c_convertor.rb +17 -13
- data/lib/gir_ffi/error_argument_info.rb +1 -1
- data/lib/gir_ffi/ffi_ext/pointer.rb +1 -1
- data/lib/gir_ffi/info_ext/i_unresolved_info.rb +12 -0
- data/lib/gir_ffi/info_ext/safe_constant_name.rb +2 -2
- data/lib/gir_ffi/info_ext/safe_function_name.rb +1 -1
- data/lib/gir_ffi/info_ext.rb +1 -0
- data/lib/gir_ffi/module_base.rb +1 -1
- data/lib/gir_ffi/receiver_argument_info.rb +15 -12
- data/lib/gir_ffi/user_data_argument_info.rb +17 -15
- data/lib/gir_ffi/user_data_type_info.rb +14 -12
- data/lib/gir_ffi/version.rb +1 -1
- data/lib/gir_ffi-base/gobject/lib.rb +1 -1
- data/test/base_test_helper.rb +15 -15
- data/test/ffi-glib/array_test.rb +38 -38
- data/test/ffi-glib/byte_array_test.rb +6 -7
- data/test/ffi-glib/bytes_test.rb +9 -9
- data/test/ffi-glib/hash_table_test.rb +26 -23
- data/test/ffi-glib/iconv_test.rb +5 -5
- data/test/ffi-glib/list_test.rb +16 -16
- data/test/ffi-glib/main_loop_test.rb +6 -6
- data/test/ffi-glib/ptr_array_test.rb +45 -45
- data/test/ffi-glib/ruby_closure_test.rb +6 -6
- data/test/ffi-glib/s_list_test.rb +15 -15
- data/test/ffi-glib/strv_test.rb +21 -21
- data/test/ffi-glib/variant_test.rb +4 -4
- data/test/ffi-gobject/gobject_test.rb +35 -35
- data/test/ffi-gobject/object_class_test.rb +1 -1
- data/test/ffi-gobject/object_test.rb +29 -6
- data/test/ffi-gobject/value_test.rb +66 -52
- data/test/ffi-gobject_introspection/i_base_info_test.rb +10 -11
- data/test/ffi-gobject_introspection/i_constant_info_test.rb +6 -6
- data/test/ffi-gobject_introspection/i_enum_info_test.rb +4 -5
- data/test/ffi-gobject_introspection/i_function_info_test.rb +0 -2
- data/test/ffi-gobject_introspection/i_object_info_test.rb +5 -5
- data/test/ffi-gobject_introspection/i_registered_type_info_test.rb +9 -8
- data/test/ffi-gobject_introspection/i_repository_test.rb +16 -16
- data/test/ffi-gobject_introspection/i_type_info_test.rb +16 -2
- data/test/ffi-gobject_introspection/lib_test.rb +2 -2
- data/test/ffi-gobject_test.rb +50 -40
- data/test/gir_ffi/arg_helper_test.rb +5 -5
- data/test/gir_ffi/builder_test.rb +41 -41
- data/test/gir_ffi/builders/argument_builder_test.rb +240 -207
- data/test/gir_ffi/builders/base_argument_builder_test.rb +0 -1
- data/test/gir_ffi/builders/callback_argument_builder_test.rb +81 -15
- data/test/gir_ffi/builders/callback_builder_test.rb +39 -14
- data/test/gir_ffi/builders/callback_return_value_builder_test.rb +41 -33
- data/test/gir_ffi/builders/enum_builder_test.rb +3 -3
- data/test/gir_ffi/builders/field_builder_test.rb +17 -17
- data/test/gir_ffi/builders/function_builder_test.rb +16 -16
- data/test/gir_ffi/builders/interface_builder_test.rb +9 -7
- data/test/gir_ffi/builders/module_builder_test.rb +5 -6
- data/test/gir_ffi/builders/object_builder_test.rb +24 -19
- data/test/gir_ffi/builders/property_builder_test.rb +25 -23
- data/test/gir_ffi/builders/registered_type_builder_test.rb +11 -11
- data/test/gir_ffi/builders/return_value_builder_test.rb +237 -197
- data/test/gir_ffi/builders/signal_closure_builder_test.rb +29 -22
- data/test/gir_ffi/builders/struct_builder_test.rb +10 -10
- data/test/gir_ffi/builders/unintrospectable_builder_test.rb +8 -8
- data/test/gir_ffi/builders/union_builder_test.rb +5 -6
- data/test/gir_ffi/builders/user_defined_builder_test.rb +42 -33
- data/test/gir_ffi/builders/vfunc_builder_test.rb +37 -30
- data/test/gir_ffi/callback_base_test.rb +4 -5
- data/test/gir_ffi/class_base_test.rb +35 -28
- data/test/gir_ffi/error_type_info_test.rb +14 -14
- data/test/gir_ffi/ffi_ext/pointer_test.rb +4 -4
- data/test/gir_ffi/g_type_test.rb +6 -6
- data/test/gir_ffi/in_out_pointer_test.rb +27 -27
- data/test/gir_ffi/in_pointer_test.rb +54 -50
- data/test/gir_ffi/info_ext/i_callable_info_test.rb +8 -7
- data/test/gir_ffi/info_ext/i_callback_info_test.rb +7 -7
- data/test/gir_ffi/info_ext/i_field_info_test.rb +10 -8
- data/test/gir_ffi/info_ext/i_function_info_test.rb +17 -15
- data/test/gir_ffi/info_ext/i_signal_info_test.rb +10 -8
- data/test/gir_ffi/info_ext/i_type_info_test.rb +158 -155
- data/test/gir_ffi/info_ext/i_unresolved_info_test.rb +17 -0
- data/test/gir_ffi/info_ext/safe_constant_name_test.rb +12 -10
- data/test/gir_ffi/info_ext/safe_function_name_test.rb +12 -10
- data/test/gir_ffi/interface_base_test.rb +6 -6
- data/test/gir_ffi/method_stubber_test.rb +16 -13
- data/test/gir_ffi/object_base_test.rb +6 -6
- data/test/gir_ffi/sized_array_test.rb +23 -23
- data/test/gir_ffi/type_map_test.rb +3 -3
- data/test/gir_ffi/unintrospectable_type_info_test.rb +18 -18
- data/test/gir_ffi/user_defined_property_info_test.rb +4 -4
- data/test/gir_ffi/user_defined_type_info_test.rb +16 -16
- data/test/gir_ffi/variable_name_generator_test.rb +6 -6
- data/test/gir_ffi/version_test.rb +1 -1
- data/test/gir_ffi/zero_terminated_test.rb +16 -17
- data/test/gir_ffi-base/glib/boolean_test.rb +13 -13
- data/test/gir_ffi-base/glib/strv_test.rb +11 -11
- data/test/gir_ffi_test.rb +18 -18
- data/test/gir_ffi_test_helper.rb +13 -18
- data/test/integration/derived_classes_test.rb +8 -8
- data/test/integration/generated_gimarshallingtests_test.rb +794 -792
- data/test/integration/generated_gio_test.rb +25 -26
- data/test/integration/generated_glib_test.rb +8 -2
- data/test/integration/generated_gobject_test.rb +16 -9
- data/test/integration/generated_pango_ft2_test.rb +1 -2
- data/test/integration/generated_pango_test.rb +2 -2
- data/test/integration/generated_regress_test.rb +785 -705
- data/test/integration/generated_secret_test.rb +5 -5
- data/test/integration/method_lookup_test.rb +5 -5
- data/test/introspection_test_helper.rb +3 -1
- data/test/minitest/stats_plugin.rb +3 -3
- metadata +6 -3
    
        data/test/ffi-glib/bytes_test.rb
    CHANGED
    
    | @@ -1,22 +1,22 @@ | |
| 1 1 | 
             
            require 'gir_ffi_test_helper'
         | 
| 2 2 |  | 
| 3 3 | 
             
            describe GLib::Bytes do
         | 
| 4 | 
            -
              it  | 
| 4 | 
            +
              it 'can succesfully be created with GLib::Bytes.new' do
         | 
| 5 5 | 
             
                bytes = GLib::Bytes.new [1, 2, 3]
         | 
| 6 6 | 
             
                bytes.must_be_instance_of GLib::Bytes
         | 
| 7 7 | 
             
              end
         | 
| 8 8 |  | 
| 9 | 
            -
              it  | 
| 9 | 
            +
              it 'has a working #get_size method' do
         | 
| 10 10 | 
             
                bytes = GLib::Bytes.new [1, 2, 3]
         | 
| 11 11 | 
             
                bytes.get_size.must_equal 3
         | 
| 12 12 | 
             
              end
         | 
| 13 13 |  | 
| 14 | 
            -
              it  | 
| 14 | 
            +
              it 'has a working #get_data method' do
         | 
| 15 15 | 
             
                bytes = GLib::Bytes.new [1, 2, 3]
         | 
| 16 16 | 
             
                bytes.get_data.to_a.must_equal [1, 2, 3]
         | 
| 17 17 | 
             
              end
         | 
| 18 18 |  | 
| 19 | 
            -
              it  | 
| 19 | 
            +
              it 'has a working #each method' do
         | 
| 20 20 | 
             
                a = []
         | 
| 21 21 | 
             
                bytes = GLib::Bytes.new [1, 2, 3]
         | 
| 22 22 | 
             
                bytes.each do |v|
         | 
| @@ -25,25 +25,25 @@ describe GLib::Bytes do | |
| 25 25 | 
             
                a.must_equal [3, 2, 1]
         | 
| 26 26 | 
             
              end
         | 
| 27 27 |  | 
| 28 | 
            -
              it  | 
| 28 | 
            +
              it 'has a working #to_a method' do
         | 
| 29 29 | 
             
                bytes = GLib::Bytes.new [1, 2, 3]
         | 
| 30 30 | 
             
                bytes.to_a.must_equal [1, 2, 3]
         | 
| 31 31 | 
             
              end
         | 
| 32 32 |  | 
| 33 | 
            -
              describe  | 
| 34 | 
            -
                it  | 
| 33 | 
            +
              describe '.from' do
         | 
| 34 | 
            +
                it 'creates a GLib::Bytes object form an array of small integers' do
         | 
| 35 35 | 
             
                  bytes = GLib::Bytes.from [1, 2, 3]
         | 
| 36 36 | 
             
                  bytes.must_be_instance_of GLib::Bytes
         | 
| 37 37 | 
             
                  bytes.to_a.must_equal [1, 2, 3]
         | 
| 38 38 | 
             
                end
         | 
| 39 39 |  | 
| 40 | 
            -
                it  | 
| 40 | 
            +
                it 'returns its argument if given a GLib::Bytes object' do
         | 
| 41 41 | 
             
                  bytes = GLib::Bytes.new [1, 2, 3]
         | 
| 42 42 | 
             
                  result = GLib::Bytes.from bytes
         | 
| 43 43 | 
             
                  assert result.equal?(bytes)
         | 
| 44 44 | 
             
                end
         | 
| 45 45 |  | 
| 46 | 
            -
                it  | 
| 46 | 
            +
                it 'wraps its argument if given a pointer' do
         | 
| 47 47 | 
             
                  bytes = GLib::Bytes.new [1, 2, 3]
         | 
| 48 48 | 
             
                  ptr = bytes.to_ptr
         | 
| 49 49 | 
             
                  result = GLib::Bytes.from ptr
         | 
| @@ -1,27 +1,27 @@ | |
| 1 1 | 
             
            require 'gir_ffi_test_helper'
         | 
| 2 2 |  | 
| 3 3 | 
             
            describe GLib::HashTable do
         | 
| 4 | 
            -
              it  | 
| 4 | 
            +
              it 'knows its key and value types' do
         | 
| 5 5 | 
             
                hsh = GLib::HashTable.new :gint32, :utf8
         | 
| 6 6 | 
             
                assert_equal :gint32, hsh.key_type
         | 
| 7 7 | 
             
                assert_equal :utf8, hsh.value_type
         | 
| 8 8 | 
             
              end
         | 
| 9 9 |  | 
| 10 | 
            -
              describe  | 
| 11 | 
            -
                it  | 
| 10 | 
            +
              describe '::from' do
         | 
| 11 | 
            +
                it 'creates a GHashTable from a Ruby hash' do
         | 
| 12 12 | 
             
                  hsh = GLib::HashTable.from [:utf8, :gint32],
         | 
| 13 | 
            -
                     | 
| 14 | 
            -
                  assert_equal({ | 
| 13 | 
            +
                    'foo' => 23, 'bar' => 32
         | 
| 14 | 
            +
                  assert_equal({ 'foo' => 23, 'bar' => 32 }, hsh.to_hash)
         | 
| 15 15 | 
             
                end
         | 
| 16 16 |  | 
| 17 | 
            -
                it  | 
| 18 | 
            -
                  hsh = GLib::HashTable.from [:utf8, :gint32],  | 
| 17 | 
            +
                it 'return its argument if given a GHashTable' do
         | 
| 18 | 
            +
                  hsh = GLib::HashTable.from [:utf8, :gint32], 'foo' => 23, 'bar' => 32
         | 
| 19 19 | 
             
                  hsh2 = GLib::HashTable.from [:utf8, :gint32], hsh
         | 
| 20 20 | 
             
                  assert hsh2.equal? hsh
         | 
| 21 21 | 
             
                end
         | 
| 22 22 |  | 
| 23 | 
            -
                it  | 
| 24 | 
            -
                  hsh = GLib::HashTable.from [:utf8, :gint32],  | 
| 23 | 
            +
                it 'wraps its argument if given a pointer' do
         | 
| 24 | 
            +
                  hsh = GLib::HashTable.from [:utf8, :gint32], 'foo' => 23, 'bar' => 32
         | 
| 25 25 | 
             
                  pointer = hsh.to_ptr
         | 
| 26 26 | 
             
                  assert_instance_of FFI::Pointer, pointer
         | 
| 27 27 | 
             
                  hsh2 = GLib::HashTable.from [:utf8, :gint32], pointer
         | 
| @@ -31,33 +31,36 @@ describe GLib::HashTable do | |
| 31 31 | 
             
                end
         | 
| 32 32 | 
             
              end
         | 
| 33 33 |  | 
| 34 | 
            -
              it  | 
| 34 | 
            +
              it 'allows key-value pairs to be inserted' do
         | 
| 35 35 | 
             
                h = GLib::HashTable.new :utf8, :utf8
         | 
| 36 | 
            -
                h.insert  | 
| 37 | 
            -
                h.to_hash.must_equal  | 
| 36 | 
            +
                h.insert 'foo', 'bar'
         | 
| 37 | 
            +
                h.to_hash.must_equal 'foo' => 'bar'
         | 
| 38 38 | 
             
              end
         | 
| 39 39 |  | 
| 40 | 
            -
              it  | 
| 41 | 
            -
                GLib::HashTable.must_include Enumerable | 
| 40 | 
            +
              it 'includes Enumerable' do
         | 
| 41 | 
            +
                GLib::HashTable.must_include Enumerable
         | 
| 42 42 | 
             
              end
         | 
| 43 43 |  | 
| 44 | 
            -
              describe  | 
| 44 | 
            +
              describe 'a HashTable provided by the system' do
         | 
| 45 45 | 
             
                before do
         | 
| 46 46 | 
             
                  GirFFI.setup :Regress
         | 
| 47 47 | 
             
                  @hash = Regress.test_ghash_container_return
         | 
| 48 48 | 
             
                end
         | 
| 49 49 |  | 
| 50 | 
            -
                it  | 
| 50 | 
            +
                it 'has a working #each method' do
         | 
| 51 51 | 
             
                  a = {}
         | 
| 52 | 
            -
                  @hash.each {|k, v| a[k] = v}
         | 
| 53 | 
            -
                  a.must_be :==, | 
| 54 | 
            -
                     | 
| 52 | 
            +
                  @hash.each { |k, v| a[k] = v }
         | 
| 53 | 
            +
                  a.must_be :==,
         | 
| 54 | 
            +
                    'foo' => 'bar',
         | 
| 55 | 
            +
                    'baz' => 'bat',
         | 
| 56 | 
            +
                    'qux' => 'quux'
         | 
| 55 57 | 
             
                end
         | 
| 56 58 |  | 
| 57 | 
            -
                it  | 
| 58 | 
            -
                  @hash.to_hash.must_be :==, | 
| 59 | 
            -
                     | 
| 59 | 
            +
                it 'has a working #to_hash method' do
         | 
| 60 | 
            +
                  @hash.to_hash.must_be :==,
         | 
| 61 | 
            +
                    'foo' => 'bar',
         | 
| 62 | 
            +
                    'baz' => 'bat',
         | 
| 63 | 
            +
                    'qux' => 'quux'
         | 
| 60 64 | 
             
                end
         | 
| 61 65 | 
             
              end
         | 
| 62 66 | 
             
            end
         | 
| 63 | 
            -
             | 
    
        data/test/ffi-glib/iconv_test.rb
    CHANGED
    
    | @@ -1,16 +1,16 @@ | |
| 1 1 | 
             
            require 'gir_ffi_test_helper'
         | 
| 2 2 |  | 
| 3 3 | 
             
            describe GLib::IConv do
         | 
| 4 | 
            -
              describe  | 
| 5 | 
            -
                it  | 
| 6 | 
            -
                  instance = GLib::IConv.open( | 
| 4 | 
            +
              describe '.open' do
         | 
| 5 | 
            +
                it 'creates a new instance of GLib::Iconv' do
         | 
| 6 | 
            +
                  instance = GLib::IConv.open('ascii', 'utf-8')
         | 
| 7 7 | 
             
                  instance.must_be_instance_of GLib::IConv
         | 
| 8 8 | 
             
                end
         | 
| 9 9 | 
             
              end
         | 
| 10 10 |  | 
| 11 | 
            -
              let(:instance) { GLib::IConv.open( | 
| 11 | 
            +
              let(:instance) { GLib::IConv.open('ascii', 'utf-8') }
         | 
| 12 12 |  | 
| 13 | 
            -
              describe  | 
| 13 | 
            +
              describe '#setup_and_call' do
         | 
| 14 14 | 
             
                it "works for the method called ''" do
         | 
| 15 15 | 
             
                  instance.setup_and_call :'', [nil, nil, nil, nil]
         | 
| 16 16 | 
             
                end
         | 
    
        data/test/ffi-glib/list_test.rb
    CHANGED
    
    | @@ -1,25 +1,25 @@ | |
| 1 1 | 
             
            require 'gir_ffi_test_helper'
         | 
| 2 2 |  | 
| 3 3 | 
             
            describe GLib::List do
         | 
| 4 | 
            -
              it  | 
| 4 | 
            +
              it 'knows its element type' do
         | 
| 5 5 | 
             
                arr = GLib::List.new :gint32
         | 
| 6 6 | 
             
                assert_equal :gint32, arr.element_type
         | 
| 7 7 | 
             
              end
         | 
| 8 8 |  | 
| 9 | 
            -
              describe  | 
| 10 | 
            -
                it  | 
| 9 | 
            +
              describe '#append' do
         | 
| 10 | 
            +
                it 'appends integer values' do
         | 
| 11 11 | 
             
                  lst = GLib::List.new :gint32
         | 
| 12 12 | 
             
                  res = lst.append 1
         | 
| 13 13 | 
             
                  assert_equal 1, res.data
         | 
| 14 14 | 
             
                end
         | 
| 15 15 |  | 
| 16 | 
            -
                it  | 
| 16 | 
            +
                it 'appends string values' do
         | 
| 17 17 | 
             
                  lst = GLib::List.new :utf8
         | 
| 18 | 
            -
                  res = lst.append  | 
| 19 | 
            -
                  assert_equal  | 
| 18 | 
            +
                  res = lst.append 'bla'
         | 
| 19 | 
            +
                  assert_equal 'bla', res.data
         | 
| 20 20 | 
             
                end
         | 
| 21 21 |  | 
| 22 | 
            -
                it  | 
| 22 | 
            +
                it 'appends multiple values into a single list' do
         | 
| 23 23 | 
             
                  lst = GLib::List.new :gint32
         | 
| 24 24 |  | 
| 25 25 | 
             
                  lst = lst.append 1
         | 
| @@ -31,19 +31,19 @@ describe GLib::List do | |
| 31 31 | 
             
                end
         | 
| 32 32 | 
             
              end
         | 
| 33 33 |  | 
| 34 | 
            -
              describe  | 
| 35 | 
            -
                it  | 
| 34 | 
            +
              describe '::from' do
         | 
| 35 | 
            +
                it 'creates a GList from a Ruby array' do
         | 
| 36 36 | 
             
                  lst = GLib::List.from :gint32, [3, 2, 1]
         | 
| 37 37 | 
             
                  assert_equal [3, 2, 1], lst.to_a
         | 
| 38 38 | 
             
                end
         | 
| 39 39 |  | 
| 40 | 
            -
                it  | 
| 40 | 
            +
                it 'return its argument if given a GList' do
         | 
| 41 41 | 
             
                  lst = GLib::List.from :gint32, [3, 2, 1]
         | 
| 42 42 | 
             
                  lst2 = GLib::List.from :gint32, lst
         | 
| 43 43 | 
             
                  assert lst2.equal? lst
         | 
| 44 44 | 
             
                end
         | 
| 45 45 |  | 
| 46 | 
            -
                it  | 
| 46 | 
            +
                it 'wraps its argument if given a pointer' do
         | 
| 47 47 | 
             
                  lst = GLib::List.from :gint32, [3, 2, 1]
         | 
| 48 48 | 
             
                  pointer = lst.to_ptr
         | 
| 49 49 | 
             
                  assert_instance_of FFI::Pointer, pointer
         | 
| @@ -54,27 +54,27 @@ describe GLib::List do | |
| 54 54 | 
             
                end
         | 
| 55 55 | 
             
              end
         | 
| 56 56 |  | 
| 57 | 
            -
              describe  | 
| 58 | 
            -
                it  | 
| 57 | 
            +
              describe '#==' do
         | 
| 58 | 
            +
                it 'returns true when comparing to an array with the same elements' do
         | 
| 59 59 | 
             
                  list = GLib::List.from :gint32, [1, 2, 3]
         | 
| 60 60 |  | 
| 61 61 | 
             
                  list.must_be :==, [1, 2, 3]
         | 
| 62 62 | 
             
                end
         | 
| 63 63 |  | 
| 64 | 
            -
                it  | 
| 64 | 
            +
                it 'returns false when comparing to an array with different elements' do
         | 
| 65 65 | 
             
                  list = GLib::List.from :gint32, [1, 2, 3]
         | 
| 66 66 |  | 
| 67 67 | 
             
                  list.wont_be :==, [1, 2]
         | 
| 68 68 | 
             
                end
         | 
| 69 69 |  | 
| 70 | 
            -
                it  | 
| 70 | 
            +
                it 'returns true when comparing to a list with the same elements' do
         | 
| 71 71 | 
             
                  list = GLib::List.from :gint32, [1, 2, 3]
         | 
| 72 72 | 
             
                  other = GLib::List.from :gint32, [1, 2, 3]
         | 
| 73 73 |  | 
| 74 74 | 
             
                  list.must_be :==, other
         | 
| 75 75 | 
             
                end
         | 
| 76 76 |  | 
| 77 | 
            -
                it  | 
| 77 | 
            +
                it 'returns false when comparing to a list with different elements' do
         | 
| 78 78 | 
             
                  list = GLib::List.from :gint32, [1, 2, 3]
         | 
| 79 79 | 
             
                  other = GLib::List.from :gint32, [1, 2]
         | 
| 80 80 |  | 
| @@ -1,8 +1,8 @@ | |
| 1 1 | 
             
            require 'gir_ffi_test_helper'
         | 
| 2 2 |  | 
| 3 3 | 
             
            describe GLib::MainLoop do
         | 
| 4 | 
            -
              describe  | 
| 5 | 
            -
                it  | 
| 4 | 
            +
              describe '#run' do
         | 
| 5 | 
            +
                it 'allows other threads to run' do
         | 
| 6 6 | 
             
                  main_loop = GLib::MainLoop.new nil, false
         | 
| 7 7 |  | 
| 8 8 | 
             
                  a = []
         | 
| @@ -12,16 +12,16 @@ describe GLib::MainLoop do | |
| 12 12 |  | 
| 13 13 | 
             
                  slow_thread = Thread.new do
         | 
| 14 14 | 
             
                    sleep 0.001
         | 
| 15 | 
            -
                    a <<  | 
| 15 | 
            +
                    a << 'During run'
         | 
| 16 16 | 
             
                  end
         | 
| 17 17 |  | 
| 18 | 
            -
                  a <<  | 
| 18 | 
            +
                  a << 'Before run'
         | 
| 19 19 | 
             
                  main_loop.run
         | 
| 20 | 
            -
                  a <<  | 
| 20 | 
            +
                  a << 'After run'
         | 
| 21 21 |  | 
| 22 22 | 
             
                  slow_thread.join
         | 
| 23 23 |  | 
| 24 | 
            -
                  a.last.must_equal  | 
| 24 | 
            +
                  a.last.must_equal 'After run'
         | 
| 25 25 | 
             
                end
         | 
| 26 26 | 
             
              end
         | 
| 27 27 | 
             
            end
         | 
| @@ -1,108 +1,108 @@ | |
| 1 1 | 
             
            require 'gir_ffi_test_helper'
         | 
| 2 2 |  | 
| 3 3 | 
             
            describe GLib::PtrArray do
         | 
| 4 | 
            -
              it  | 
| 4 | 
            +
              it 'knows its element type' do
         | 
| 5 5 | 
             
                arr = GLib::PtrArray.new :utf8
         | 
| 6 6 | 
             
                assert_equal :utf8, arr.element_type
         | 
| 7 7 | 
             
              end
         | 
| 8 8 |  | 
| 9 | 
            -
              describe  | 
| 10 | 
            -
                it  | 
| 9 | 
            +
              describe '::add' do
         | 
| 10 | 
            +
                it 'correctly takes the type into account' do
         | 
| 11 11 | 
             
                  arr = GLib::PtrArray.new :utf8
         | 
| 12 | 
            -
                  str =  | 
| 12 | 
            +
                  str = 'test'
         | 
| 13 13 | 
             
                  GLib::PtrArray.add arr, str
         | 
| 14 14 |  | 
| 15 15 | 
             
                  assert_equal str, arr.pdata.read_pointer.read_string
         | 
| 16 16 | 
             
                end
         | 
| 17 17 | 
             
              end
         | 
| 18 18 |  | 
| 19 | 
            -
              describe  | 
| 20 | 
            -
                it  | 
| 19 | 
            +
              describe '#each' do
         | 
| 20 | 
            +
                it 'works normally' do
         | 
| 21 21 | 
             
                  arr = GLib::PtrArray.new :utf8
         | 
| 22 22 |  | 
| 23 | 
            -
                  GLib::PtrArray.add arr,  | 
| 24 | 
            -
                  GLib::PtrArray.add arr,  | 
| 25 | 
            -
                  GLib::PtrArray.add arr,  | 
| 23 | 
            +
                  GLib::PtrArray.add arr, 'test1'
         | 
| 24 | 
            +
                  GLib::PtrArray.add arr, 'test2'
         | 
| 25 | 
            +
                  GLib::PtrArray.add arr, 'test3'
         | 
| 26 26 |  | 
| 27 27 | 
             
                  a = []
         | 
| 28 | 
            -
                  arr.each {|v| a << v}
         | 
| 28 | 
            +
                  arr.each { |v| a << v }
         | 
| 29 29 |  | 
| 30 | 
            -
                  assert_equal  | 
| 30 | 
            +
                  assert_equal %w(test1 test2 test3), a
         | 
| 31 31 | 
             
                end
         | 
| 32 32 |  | 
| 33 | 
            -
                it  | 
| 33 | 
            +
                it 'works when exiting the loop prematurely' do
         | 
| 34 34 | 
             
                  arr = GLib::PtrArray.new :utf8
         | 
| 35 35 |  | 
| 36 | 
            -
                  GLib::PtrArray.add arr,  | 
| 37 | 
            -
                  GLib::PtrArray.add arr,  | 
| 38 | 
            -
                  GLib::PtrArray.add arr,  | 
| 36 | 
            +
                  GLib::PtrArray.add arr, 'test1'
         | 
| 37 | 
            +
                  GLib::PtrArray.add arr, 'test2'
         | 
| 38 | 
            +
                  GLib::PtrArray.add arr, 'test3'
         | 
| 39 39 |  | 
| 40 40 | 
             
                  a = []
         | 
| 41 41 | 
             
                  arr.each do |v|
         | 
| 42 42 | 
             
                    a << v
         | 
| 43 | 
            -
                    break if v ==  | 
| 43 | 
            +
                    break if v == 'test2'
         | 
| 44 44 | 
             
                  end
         | 
| 45 45 |  | 
| 46 | 
            -
                  assert_equal  | 
| 46 | 
            +
                  assert_equal %w(test1 test2), a
         | 
| 47 47 | 
             
                end
         | 
| 48 48 | 
             
              end
         | 
| 49 49 |  | 
| 50 | 
            -
              it  | 
| 50 | 
            +
              it 'includes Enumerable' do
         | 
| 51 51 | 
             
                GLib::PtrArray.must_include Enumerable
         | 
| 52 52 | 
             
              end
         | 
| 53 53 |  | 
| 54 | 
            -
              it  | 
| 54 | 
            +
              it 'has a working #to_a method' do
         | 
| 55 55 | 
             
                arr = GLib::PtrArray.new :utf8
         | 
| 56 56 |  | 
| 57 | 
            -
                GLib::PtrArray.add arr,  | 
| 58 | 
            -
                GLib::PtrArray.add arr,  | 
| 59 | 
            -
                GLib::PtrArray.add arr,  | 
| 57 | 
            +
                GLib::PtrArray.add arr, 'test1'
         | 
| 58 | 
            +
                GLib::PtrArray.add arr, 'test2'
         | 
| 59 | 
            +
                GLib::PtrArray.add arr, 'test3'
         | 
| 60 60 |  | 
| 61 | 
            -
                assert_equal  | 
| 61 | 
            +
                assert_equal %w(test1 test2 test3), arr.to_a
         | 
| 62 62 | 
             
              end
         | 
| 63 63 |  | 
| 64 | 
            -
              it  | 
| 64 | 
            +
              it 'has #add as an instance method too' do
         | 
| 65 65 | 
             
                arr = GLib::PtrArray.new :utf8
         | 
| 66 | 
            -
                arr.add  | 
| 67 | 
            -
                assert_equal [ | 
| 66 | 
            +
                arr.add 'test1'
         | 
| 67 | 
            +
                assert_equal ['test1'], arr.to_a
         | 
| 68 68 | 
             
              end
         | 
| 69 69 |  | 
| 70 | 
            -
              describe  | 
| 71 | 
            -
                it  | 
| 72 | 
            -
                  arr = GLib::PtrArray.from :utf8,  | 
| 70 | 
            +
              describe '#==' do
         | 
| 71 | 
            +
                it 'returns true when comparing to an array with the same elements' do
         | 
| 72 | 
            +
                  arr = GLib::PtrArray.from :utf8, %w(1 2 3)
         | 
| 73 73 |  | 
| 74 | 
            -
                  arr.must_be :==,  | 
| 74 | 
            +
                  arr.must_be :==, %w(1 2 3)
         | 
| 75 75 | 
             
                end
         | 
| 76 76 |  | 
| 77 | 
            -
                it  | 
| 78 | 
            -
                  arr = GLib::PtrArray.from :utf8,  | 
| 77 | 
            +
                it 'returns false when comparing to an array with different elements' do
         | 
| 78 | 
            +
                  arr = GLib::PtrArray.from :utf8, %w(1 2 3)
         | 
| 79 79 |  | 
| 80 | 
            -
                  arr.wont_be :==,  | 
| 80 | 
            +
                  arr.wont_be :==, %w(1 2)
         | 
| 81 81 | 
             
                end
         | 
| 82 82 |  | 
| 83 | 
            -
                it  | 
| 84 | 
            -
                  arr = GLib::PtrArray.from :utf8,  | 
| 85 | 
            -
                  other = GLib::PtrArray.from :utf8,  | 
| 83 | 
            +
                it 'returns true when comparing to a GPtrArray with the same elements' do
         | 
| 84 | 
            +
                  arr = GLib::PtrArray.from :utf8, %w(1 2 3)
         | 
| 85 | 
            +
                  other = GLib::PtrArray.from :utf8, %w(1 2 3)
         | 
| 86 86 |  | 
| 87 87 | 
             
                  arr.must_be :==, other
         | 
| 88 88 | 
             
                end
         | 
| 89 89 |  | 
| 90 | 
            -
                it  | 
| 91 | 
            -
                  arr = GLib::PtrArray.from :utf8,  | 
| 92 | 
            -
                  other = GLib::PtrArray.from :utf8,  | 
| 90 | 
            +
                it 'returns false when comparing to a GPtrArray with different elements' do
         | 
| 91 | 
            +
                  arr = GLib::PtrArray.from :utf8, %w(1 2 3)
         | 
| 92 | 
            +
                  other = GLib::PtrArray.from :utf8, %w(1 2)
         | 
| 93 93 |  | 
| 94 94 | 
             
                  arr.wont_be :==, other
         | 
| 95 95 | 
             
                end
         | 
| 96 96 | 
             
              end
         | 
| 97 97 |  | 
| 98 | 
            -
              describe  | 
| 99 | 
            -
                it  | 
| 100 | 
            -
                  arr = GLib::PtrArray.from :utf8,  | 
| 101 | 
            -
                  arr.index(1).must_equal  | 
| 98 | 
            +
              describe '#index' do
         | 
| 99 | 
            +
                it 'returns the correct element' do
         | 
| 100 | 
            +
                  arr = GLib::PtrArray.from :utf8, %w(1 2 3)
         | 
| 101 | 
            +
                  arr.index(1).must_equal '2'
         | 
| 102 102 | 
             
                end
         | 
| 103 103 |  | 
| 104 | 
            -
                it  | 
| 105 | 
            -
                  arr = GLib::PtrArray.from :utf8,  | 
| 104 | 
            +
                it 'raises an error if the index is out of bounds' do
         | 
| 105 | 
            +
                  arr = GLib::PtrArray.from :utf8, %w(1 2 3)
         | 
| 106 106 | 
             
                  proc { arr.index(16) }.must_raise IndexError
         | 
| 107 107 | 
             
                  proc { arr.index(-1) }.must_raise IndexError
         | 
| 108 108 | 
             
                end
         | 
| @@ -1,18 +1,18 @@ | |
| 1 1 | 
             
            require 'gir_ffi_test_helper'
         | 
| 2 2 |  | 
| 3 3 | 
             
            describe GObject::RubyClosure do
         | 
| 4 | 
            -
              it  | 
| 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 | 
            -
              it  | 
| 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 | 
            -
              it  | 
| 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)
         | 
| @@ -20,7 +20,7 @@ describe GObject::RubyClosure do | |
| 20 20 | 
             
                assert_equal 2, a
         | 
| 21 21 | 
             
              end
         | 
| 22 22 |  | 
| 23 | 
            -
              describe  | 
| 23 | 
            +
              describe 'its #marshaller singleton method' do
         | 
| 24 24 | 
             
                it "invokes its closure argument's block" do
         | 
| 25 25 | 
             
                  a = 0
         | 
| 26 26 | 
             
                  c = GObject::RubyClosure.new { a = 2 }
         | 
| @@ -28,7 +28,7 @@ describe GObject::RubyClosure do | |
| 28 28 | 
             
                  assert_equal 2, a
         | 
| 29 29 | 
             
                end
         | 
| 30 30 |  | 
| 31 | 
            -
                it  | 
| 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)
         | 
| @@ -44,7 +44,7 @@ describe GObject::RubyClosure do | |
| 44 44 | 
             
                end
         | 
| 45 45 | 
             
              end
         | 
| 46 46 |  | 
| 47 | 
            -
              it  | 
| 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)
         | 
| @@ -1,25 +1,25 @@ | |
| 1 1 | 
             
            require 'gir_ffi_test_helper'
         | 
| 2 2 |  | 
| 3 3 | 
             
            describe GLib::SList do
         | 
| 4 | 
            -
              it  | 
| 4 | 
            +
              it 'knows its element type' do
         | 
| 5 5 | 
             
                arr = GLib::SList.new :gint32
         | 
| 6 6 | 
             
                assert_equal :gint32, arr.element_type
         | 
| 7 7 | 
             
              end
         | 
| 8 8 |  | 
| 9 | 
            -
              describe  | 
| 10 | 
            -
                it  | 
| 9 | 
            +
              describe '#prepend' do
         | 
| 10 | 
            +
                it 'prepends integer values' do
         | 
| 11 11 | 
             
                  lst = GLib::SList.new :gint32
         | 
| 12 12 | 
             
                  res = lst.prepend 1
         | 
| 13 13 | 
             
                  assert_equal 1, res.data
         | 
| 14 14 | 
             
                end
         | 
| 15 15 |  | 
| 16 | 
            -
                it  | 
| 16 | 
            +
                it 'prepends string values' do
         | 
| 17 17 | 
             
                  lst = GLib::SList.new :utf8
         | 
| 18 | 
            -
                  res = lst.prepend  | 
| 19 | 
            -
                  assert_equal  | 
| 18 | 
            +
                  res = lst.prepend 'bla'
         | 
| 19 | 
            +
                  assert_equal 'bla', res.data
         | 
| 20 20 | 
             
                end
         | 
| 21 21 |  | 
| 22 | 
            -
                it  | 
| 22 | 
            +
                it 'prepends multiple values into a single list' do
         | 
| 23 23 | 
             
                  lst = GLib::SList.new :gint32
         | 
| 24 24 |  | 
| 25 25 | 
             
                  res = lst.prepend 1
         | 
| @@ -31,40 +31,40 @@ describe GLib::SList do | |
| 31 31 | 
             
                end
         | 
| 32 32 | 
             
              end
         | 
| 33 33 |  | 
| 34 | 
            -
              describe  | 
| 35 | 
            -
                it  | 
| 34 | 
            +
              describe '::from' do
         | 
| 35 | 
            +
                it 'creates a GSList from a Ruby array' do
         | 
| 36 36 | 
             
                  lst = GLib::SList.from :gint32, [3, 2, 1]
         | 
| 37 37 | 
             
                  assert_equal [3, 2, 1], lst.to_a
         | 
| 38 38 | 
             
                end
         | 
| 39 39 |  | 
| 40 | 
            -
                it  | 
| 40 | 
            +
                it 'return its argument if given a GSList' do
         | 
| 41 41 | 
             
                  lst = GLib::SList.from :gint32, [3, 2, 1]
         | 
| 42 42 | 
             
                  lst2 = GLib::SList.from :gint32, lst
         | 
| 43 43 | 
             
                  assert_equal lst, lst2
         | 
| 44 44 | 
             
                end
         | 
| 45 45 | 
             
              end
         | 
| 46 46 |  | 
| 47 | 
            -
              describe  | 
| 48 | 
            -
                it  | 
| 47 | 
            +
              describe '#==' do
         | 
| 48 | 
            +
                it 'returns true when comparing to an array with the same elements' do
         | 
| 49 49 | 
             
                  list = GLib::SList.from :gint32, [1, 2, 3]
         | 
| 50 50 |  | 
| 51 51 | 
             
                  list.must_be :==, [1, 2, 3]
         | 
| 52 52 | 
             
                end
         | 
| 53 53 |  | 
| 54 | 
            -
                it  | 
| 54 | 
            +
                it 'returns false when comparing to an array with different elements' do
         | 
| 55 55 | 
             
                  list = GLib::SList.from :gint32, [1, 2, 3]
         | 
| 56 56 |  | 
| 57 57 | 
             
                  list.wont_be :==, [1, 2]
         | 
| 58 58 | 
             
                end
         | 
| 59 59 |  | 
| 60 | 
            -
                it  | 
| 60 | 
            +
                it 'returns true when comparing to a list with the same elements' do
         | 
| 61 61 | 
             
                  list = GLib::SList.from :gint32, [1, 2, 3]
         | 
| 62 62 | 
             
                  other = GLib::SList.from :gint32, [1, 2, 3]
         | 
| 63 63 |  | 
| 64 64 | 
             
                  list.must_be :==, other
         | 
| 65 65 | 
             
                end
         | 
| 66 66 |  | 
| 67 | 
            -
                it  | 
| 67 | 
            +
                it 'returns false when comparing to a list with different elements' do
         | 
| 68 68 | 
             
                  list = GLib::SList.from :gint32, [1, 2, 3]
         | 
| 69 69 | 
             
                  other = GLib::SList.from :gint32, [1, 2]
         | 
| 70 70 |  | 
    
        data/test/ffi-glib/strv_test.rb
    CHANGED
    
    | @@ -1,21 +1,21 @@ | |
| 1 1 | 
             
            require 'base_test_helper'
         | 
| 2 2 |  | 
| 3 3 | 
             
            describe GLib::Strv do
         | 
| 4 | 
            -
              describe  | 
| 5 | 
            -
                it  | 
| 6 | 
            -
                  strv = GLib::Strv.from  | 
| 4 | 
            +
              describe '::from' do
         | 
| 5 | 
            +
                it 'creates a Strv from a Ruby array' do
         | 
| 6 | 
            +
                  strv = GLib::Strv.from %w(1 2 3)
         | 
| 7 7 | 
             
                  strv.must_be_instance_of GLib::Strv
         | 
| 8 | 
            -
                  strv.to_a.must_equal  | 
| 8 | 
            +
                  strv.to_a.must_equal %w(1 2 3)
         | 
| 9 9 | 
             
                end
         | 
| 10 10 |  | 
| 11 | 
            -
                it  | 
| 12 | 
            -
                  strv = GLib::Strv.from  | 
| 11 | 
            +
                it 'return its argument if given a Strv' do
         | 
| 12 | 
            +
                  strv = GLib::Strv.from %w(1 2 3)
         | 
| 13 13 | 
             
                  strv2 = GLib::Strv.from strv
         | 
| 14 14 | 
             
                  assert strv2.equal? strv
         | 
| 15 15 | 
             
                end
         | 
| 16 16 |  | 
| 17 | 
            -
                it  | 
| 18 | 
            -
                  strv = GLib::Strv.from  | 
| 17 | 
            +
                it 'wraps its argument if given a pointer' do
         | 
| 18 | 
            +
                  strv = GLib::Strv.from %w(1 2 3)
         | 
| 19 19 |  | 
| 20 20 | 
             
                  pointer = strv.to_ptr
         | 
| 21 21 | 
             
                  pointer.must_be_kind_of FFI::Pointer
         | 
| @@ -28,29 +28,29 @@ describe GLib::Strv do | |
| 28 28 | 
             
                end
         | 
| 29 29 | 
             
              end
         | 
| 30 30 |  | 
| 31 | 
            -
              describe  | 
| 32 | 
            -
                it  | 
| 33 | 
            -
                  strv = GLib::Strv.from  | 
| 31 | 
            +
              describe '#==' do
         | 
| 32 | 
            +
                it 'returns true when comparing to an array with the same elements' do
         | 
| 33 | 
            +
                  strv = GLib::Strv.from %w(1 2 3)
         | 
| 34 34 |  | 
| 35 | 
            -
                  strv.must_be :==,  | 
| 35 | 
            +
                  strv.must_be :==, %w(1 2 3)
         | 
| 36 36 | 
             
                end
         | 
| 37 37 |  | 
| 38 | 
            -
                it  | 
| 39 | 
            -
                  strv = GLib::Strv.from  | 
| 38 | 
            +
                it 'returns false when comparing to an array with different elements' do
         | 
| 39 | 
            +
                  strv = GLib::Strv.from %w(1 2 3)
         | 
| 40 40 |  | 
| 41 | 
            -
                  strv.wont_be :==,  | 
| 41 | 
            +
                  strv.wont_be :==, %w(1 2)
         | 
| 42 42 | 
             
                end
         | 
| 43 43 |  | 
| 44 | 
            -
                it  | 
| 45 | 
            -
                  strv = GLib::Strv.from  | 
| 46 | 
            -
                  other = GLib::Strv.from  | 
| 44 | 
            +
                it 'returns true when comparing to a strv with the same elements' do
         | 
| 45 | 
            +
                  strv = GLib::Strv.from %w(1 2 3)
         | 
| 46 | 
            +
                  other = GLib::Strv.from %w(1 2 3)
         | 
| 47 47 |  | 
| 48 48 | 
             
                  strv.must_be :==, other
         | 
| 49 49 | 
             
                end
         | 
| 50 50 |  | 
| 51 | 
            -
                it  | 
| 52 | 
            -
                  strv = GLib::Strv.from  | 
| 53 | 
            -
                  other = GLib::Strv.from  | 
| 51 | 
            +
                it 'returns false when comparing to a strv with different elements' do
         | 
| 52 | 
            +
                  strv = GLib::Strv.from %w(1 2 3)
         | 
| 53 | 
            +
                  other = GLib::Strv.from %w(1 2)
         | 
| 54 54 |  | 
| 55 55 | 
             
                  strv.wont_be :==, other
         | 
| 56 56 | 
             
                end
         |