From e79b14b465a9b19366865b60b1e83b95c484a73f Mon Sep 17 00:00:00 2001 From: Matijs van Zuijlen Date: Wed, 26 Nov 2014 14:38:30 +0100 Subject: [PATCH] Autocorrect StringLiterals offenses --- .rubocop_todo.yml | 6 - Gemfile | 4 +- lib/ffi-glib/array.rb | 2 +- lib/ffi-glib/error.rb | 2 +- lib/ffi-glib/hash_table.rb | 4 +- lib/ffi-glib/variant.rb | 2 +- lib/ffi-gobject.rb | 2 +- lib/ffi-gobject/base.rb | 46 +- lib/ffi-gobject/object.rb | 6 +- lib/ffi-gobject_introspection/i_base_info.rb | 6 +- .../i_constant_info.rb | 2 +- lib/ffi-gobject_introspection/i_type_info.rb | 2 +- lib/ffi-gobject_introspection/lib.rb | 2 +- lib/gir_ffi-base/gobject/lib.rb | 2 +- lib/gir_ffi/builders/argument_builder.rb | 2 +- lib/gir_ffi/builders/c_to_ruby_convertor.rb | 2 +- .../builders/callback_argument_builder.rb | 4 +- lib/gir_ffi/builders/field_builder.rb | 2 +- lib/gir_ffi/builders/function_builder.rb | 2 +- .../builders/mapping_method_builder.rb | 2 +- .../builders/marshalling_method_builder.rb | 2 +- lib/gir_ffi/builders/method_template.rb | 2 +- lib/gir_ffi/builders/property_builder.rb | 2 +- lib/gir_ffi/builders/ruby_to_c_convertor.rb | 2 +- lib/gir_ffi/error_argument_info.rb | 2 +- lib/gir_ffi/ffi_ext/pointer.rb | 2 +- lib/gir_ffi/info_ext/safe_constant_name.rb | 4 +- lib/gir_ffi/info_ext/safe_function_name.rb | 2 +- lib/gir_ffi/receiver_argument_info.rb | 2 +- lib/gir_ffi/user_data_argument_info.rb | 2 +- lib/gir_ffi/version.rb | 2 +- test/base_test_helper.rb | 6 +- test/ffi-glib/array_test.rb | 68 +- test/ffi-glib/byte_array_test.rb | 12 +- test/ffi-glib/bytes_test.rb | 18 +- test/ffi-glib/hash_table_test.rb | 44 +- test/ffi-glib/iconv_test.rb | 10 +- test/ffi-glib/list_test.rb | 32 +- test/ffi-glib/main_loop_test.rb | 12 +- test/ffi-glib/ptr_array_test.rb | 62 +- test/ffi-glib/ruby_closure_test.rb | 12 +- test/ffi-glib/s_list_test.rb | 30 +- test/ffi-glib/strv_test.rb | 18 +- test/ffi-glib/variant_test.rb | 8 +- test/ffi-gobject/gobject_test.rb | 70 +- test/ffi-gobject/object_class_test.rb | 2 +- test/ffi-gobject/object_test.rb | 10 +- test/ffi-gobject/value_test.rb | 104 +- .../i_base_info_test.rb | 18 +- .../i_constant_info_test.rb | 12 +- .../i_enum_info_test.rb | 8 +- .../i_object_info_test.rb | 10 +- .../i_registered_type_info_test.rb | 10 +- .../i_repository_test.rb | 30 +- .../i_type_info_test.rb | 8 +- test/ffi-gobject_introspection/lib_test.rb | 4 +- test/ffi-gobject_test.rb | 76 +- test/gir_ffi-base/glib/boolean_test.rb | 26 +- test/gir_ffi-base/glib/strv_test.rb | 14 +- test/gir_ffi/arg_helper_test.rb | 10 +- test/gir_ffi/builder_test.rb | 78 +- .../gir_ffi/builders/argument_builder_test.rb | 390 ++--- .../callback_argument_builder_test.rb | 70 +- .../gir_ffi/builders/callback_builder_test.rb | 36 +- .../callback_return_value_builder_test.rb | 62 +- test/gir_ffi/builders/enum_builder_test.rb | 6 +- test/gir_ffi/builders/field_builder_test.rb | 34 +- .../gir_ffi/builders/function_builder_test.rb | 32 +- .../builders/interface_builder_test.rb | 10 +- test/gir_ffi/builders/module_builder_test.rb | 10 +- test/gir_ffi/builders/object_builder_test.rb | 26 +- .../gir_ffi/builders/property_builder_test.rb | 44 +- .../builders/registered_type_builder_test.rb | 22 +- .../builders/return_value_builder_test.rb | 388 ++--- .../builders/signal_closure_builder_test.rb | 44 +- test/gir_ffi/builders/struct_builder_test.rb | 16 +- .../builders/unintrospectable_builder_test.rb | 16 +- test/gir_ffi/builders/union_builder_test.rb | 10 +- .../builders/user_defined_builder_test.rb | 38 +- test/gir_ffi/builders/vfunc_builder_test.rb | 60 +- test/gir_ffi/callback_base_test.rb | 8 +- test/gir_ffi/class_base_test.rb | 50 +- test/gir_ffi/error_type_info_test.rb | 28 +- test/gir_ffi/ffi_ext/pointer_test.rb | 8 +- test/gir_ffi/g_type_test.rb | 12 +- test/gir_ffi/in_out_pointer_test.rb | 54 +- test/gir_ffi/in_pointer_test.rb | 82 +- test/gir_ffi/info_ext/i_callable_info_test.rb | 6 +- test/gir_ffi/info_ext/i_callback_info_test.rb | 4 +- test/gir_ffi/info_ext/i_field_info_test.rb | 10 +- test/gir_ffi/info_ext/i_function_info_test.rb | 22 +- test/gir_ffi/info_ext/i_signal_info_test.rb | 8 +- test/gir_ffi/info_ext/i_type_info_test.rb | 278 ++-- .../info_ext/i_unresolved_info_test.rb | 4 +- .../info_ext/safe_constant_name_test.rb | 14 +- .../info_ext/safe_function_name_test.rb | 14 +- test/gir_ffi/interface_base_test.rb | 12 +- test/gir_ffi/method_stubber_test.rb | 26 +- test/gir_ffi/object_base_test.rb | 12 +- test/gir_ffi/sized_array_test.rb | 40 +- test/gir_ffi/type_map_test.rb | 6 +- .../unintrospectable_type_info_test.rb | 32 +- .../user_defined_property_info_test.rb | 8 +- test/gir_ffi/user_defined_type_info_test.rb | 32 +- test/gir_ffi/variable_name_generator_test.rb | 12 +- test/gir_ffi/version_test.rb | 2 +- test/gir_ffi/zero_terminated_test.rb | 30 +- test/gir_ffi_test.rb | 36 +- test/gir_ffi_test_helper.rb | 2 +- test/integration/derived_classes_test.rb | 14 +- .../generated_gimarshallingtests_test.rb | 1386 ++++++++--------- test/integration/generated_gio_test.rb | 48 +- test/integration/generated_glib_test.rb | 6 +- test/integration/generated_gobject_test.rb | 18 +- test/integration/generated_pango_ft2_test.rb | 2 +- test/integration/generated_pango_test.rb | 2 +- test/integration/generated_regress_test.rb | 1282 +++++++-------- test/integration/generated_secret_test.rb | 10 +- test/integration/method_lookup_test.rb | 10 +- test/minitest/stats_plugin.rb | 2 +- 120 files changed, 2944 insertions(+), 2950 deletions(-) diff --git a/.rubocop_todo.yml b/.rubocop_todo.yml index ea391c7c7..110d468db 100644 --- a/.rubocop_todo.yml +++ b/.rubocop_todo.yml @@ -27,9 +27,3 @@ Metrics/MethodLength: # Configuration parameters: EnforcedStyle, SupportedStyles. Style/ClassAndModuleChildren: Enabled: false - -# Offense count: 3235 -# Cop supports --auto-correct. -# Configuration parameters: EnforcedStyle, SupportedStyles. -Style/StringLiterals: - Enabled: false diff --git a/Gemfile b/Gemfile index 8eb345e9d..9d631e1a1 100644 --- a/Gemfile +++ b/Gemfile @@ -1,9 +1,9 @@ -source "https://rubygems.org" +source 'https://rubygems.org' # The gem's dependencies are specified in gir_ffi.gemspec gemspec -if ENV["CI"] +if ENV['CI'] gem 'coveralls', type: :development, platform: :mri else gem 'simplecov', '~> 0.9.0', type: :development, platform: :mri diff --git a/lib/ffi-glib/array.rb b/lib/ffi-glib/array.rb index 21d7c8833..1646a5f68 100644 --- a/lib/ffi-glib/array.rb +++ b/lib/ffi-glib/array.rb @@ -77,7 +77,7 @@ def calculated_element_size def check_element_size_match unless calculated_element_size == get_element_size - warn "WARNING: Element sizes do not match" + warn 'WARNING: Element sizes do not match' end end diff --git a/lib/ffi-glib/error.rb b/lib/ffi-glib/error.rb index 60191d7e1..f5f297821 100644 --- a/lib/ffi-glib/error.rb +++ b/lib/ffi-glib/error.rb @@ -4,7 +4,7 @@ module GLib # Overrides for GError, used by GLib for handling non-fatal errors. class Error # TODO: Auto-convert strings and symbols to quarks - GIR_FFI_DOMAIN = GLib.quark_from_string("gir_ffi") + GIR_FFI_DOMAIN = GLib.quark_from_string('gir_ffi') def self.from_exception ex new_literal GIR_FFI_DOMAIN, 0, ex.message diff --git a/lib/ffi-glib/hash_table.rb b/lib/ffi-glib/hash_table.rb index d6c25fb19..1ea652af2 100644 --- a/lib/ffi-glib/hash_table.rb +++ b/lib/ffi-glib/hash_table.rb @@ -56,7 +56,7 @@ def self.hash_function_for keytype when :utf8 FFI::Function.new(:uint, [:pointer], - find_support_function("g_str_hash")) + find_support_function('g_str_hash')) else nil end @@ -67,7 +67,7 @@ def self.equality_function_for keytype when :utf8 FFI::Function.new(:int, [:pointer, :pointer], - find_support_function("g_str_equal")) + find_support_function('g_str_equal')) else nil end diff --git a/lib/ffi-glib/variant.rb b/lib/ffi-glib/variant.rb index 599ab0ba3..c75c8ee98 100644 --- a/lib/ffi-glib/variant.rb +++ b/lib/ffi-glib/variant.rb @@ -3,7 +3,7 @@ module GLib # Overrides for GVariant, GLib's variant data type. class Variant - setup_instance_method "get_string" + setup_instance_method 'get_string' def get_string_with_override get_string_without_override.first diff --git a/lib/ffi-gobject.rb b/lib/ffi-gobject.rb index 809d09544..033d11fee 100644 --- a/lib/ffi-gobject.rb +++ b/lib/ffi-gobject.rb @@ -55,7 +55,7 @@ def self.signal_emit object, detailed_signal, *args end def self.signal_connect object, detailed_signal, data = nil, &block - raise ArgumentError, "Block needed" unless block_given? + raise ArgumentError, 'Block needed' unless block_given? signal_name, _ = detailed_signal.split('::') sig_info = object.class.find_signal signal_name diff --git a/lib/ffi-gobject/base.rb b/lib/ffi-gobject/base.rb index 2990c0dd1..0a51ea3fc 100644 --- a/lib/ffi-gobject/base.rb +++ b/lib/ffi-gobject/base.rb @@ -1,26 +1,26 @@ # Preload type contants module GObject - TYPE_INVALID = type_from_name("invalid") - TYPE_NONE = type_from_name("void") - TYPE_INTERFACE = type_from_name("GInterface") - TYPE_CHAR = type_from_name("gchar") - TYPE_UCHAR = type_from_name("guchar") - TYPE_BOOLEAN = type_from_name("gboolean") - TYPE_INT = type_from_name("gint") - TYPE_UINT = type_from_name("guint") - TYPE_LONG = type_from_name("glong") - TYPE_ULONG = type_from_name("gulong") - TYPE_INT64 = type_from_name("gint64") - TYPE_UINT64 = type_from_name("guint64") - TYPE_ENUM = type_from_name("GEnum") - TYPE_FLAGS = type_from_name("GFlags") - TYPE_FLOAT = type_from_name("gfloat") - TYPE_DOUBLE = type_from_name("gdouble") - TYPE_STRING = type_from_name("gchararray") - TYPE_POINTER = type_from_name("gpointer") - TYPE_BOXED = type_from_name("GBoxed") - TYPE_PARAM = type_from_name("GParam") - TYPE_OBJECT = type_from_name("GObject") - TYPE_GTYPE = type_from_name("GType") - TYPE_VARIANT = type_from_name("GVariant") + TYPE_INVALID = type_from_name('invalid') + TYPE_NONE = type_from_name('void') + TYPE_INTERFACE = type_from_name('GInterface') + TYPE_CHAR = type_from_name('gchar') + TYPE_UCHAR = type_from_name('guchar') + TYPE_BOOLEAN = type_from_name('gboolean') + TYPE_INT = type_from_name('gint') + TYPE_UINT = type_from_name('guint') + TYPE_LONG = type_from_name('glong') + TYPE_ULONG = type_from_name('gulong') + TYPE_INT64 = type_from_name('gint64') + TYPE_UINT64 = type_from_name('guint64') + TYPE_ENUM = type_from_name('GEnum') + TYPE_FLAGS = type_from_name('GFlags') + TYPE_FLOAT = type_from_name('gfloat') + TYPE_DOUBLE = type_from_name('gdouble') + TYPE_STRING = type_from_name('gchararray') + TYPE_POINTER = type_from_name('gpointer') + TYPE_BOXED = type_from_name('GBoxed') + TYPE_PARAM = type_from_name('GParam') + TYPE_OBJECT = type_from_name('GObject') + TYPE_GTYPE = type_from_name('GType') + TYPE_VARIANT = type_from_name('GVariant') end diff --git a/lib/ffi-gobject/object.rb b/lib/ffi-gobject/object.rb index 590a3883c..7dca9a3a2 100644 --- a/lib/ffi-gobject/object.rb +++ b/lib/ffi-gobject/object.rb @@ -3,7 +3,7 @@ module GObject # Overrides for GObject, GObject's generic base class. class Object - setup_method "new" + setup_method 'new' # TODO: Generate accessor methods from GIR at class definition time def method_missing method, *args @@ -20,8 +20,8 @@ def signal_connect event, data = nil, &block GObject.signal_connect(self, event, data, &block) end - setup_instance_method "get_property" - setup_instance_method "set_property" + setup_instance_method 'get_property' + setup_instance_method 'set_property' def get_property_extended property_name gvalue = get_property property_name diff --git a/lib/ffi-gobject_introspection/i_base_info.rb b/lib/ffi-gobject_introspection/i_base_info.rb index e97840675..57016412c 100644 --- a/lib/ffi-gobject_introspection/i_base_info.rb +++ b/lib/ffi-gobject_introspection/i_base_info.rb @@ -3,7 +3,7 @@ module GObjectIntrospection # Decendant types will be implemented as needed. class IBaseInfo def initialize ptr, lib = Lib - raise ArgumentError, "ptr must not be null" if ptr.null? + raise ArgumentError, 'ptr must not be null' if ptr.null? unless defined?(RUBY_ENGINE) && RUBY_ENGINE == 'rbx' ObjectSpace.define_finalizer self, self.class.make_finalizer(lib, ptr) @@ -39,7 +39,7 @@ def to_ptr def self.build_array_method method, single = nil method = method.to_s single ||= method.to_s[0..-2] - count = method.sub(/^(get_)?/, "\\1n_") + count = method.sub(/^(get_)?/, '\\1n_') class_eval <<-CODE def #{method} (0..(#{count} - 1)).map do |i| @@ -67,7 +67,7 @@ def #{method} # def self.build_finder_method method, counter = nil, fetcher = nil method = method.to_s - single = method.sub(/^find_/, "") + single = method.sub(/^find_/, '') counter ||= "n_#{single}s" fetcher ||= "#{single}" class_eval <<-CODE diff --git a/lib/ffi-gobject_introspection/i_constant_info.rb b/lib/ffi-gobject_introspection/i_constant_info.rb index 790401551..5518e50ed 100644 --- a/lib/ffi-gobject_introspection/i_constant_info.rb +++ b/lib/ffi-gobject_introspection/i_constant_info.rb @@ -18,7 +18,7 @@ class IConstantInfo < IBaseInfo def value case type_tag when :utf8 - raw_value.force_encoding("utf-8") + raw_value.force_encoding('utf-8') when :gboolean raw_value != 0 else diff --git a/lib/ffi-gobject_introspection/i_type_info.rb b/lib/ffi-gobject_introspection/i_type_info.rb index 927624158..9d05fee33 100644 --- a/lib/ffi-gobject_introspection/i_type_info.rb +++ b/lib/ffi-gobject_introspection/i_type_info.rb @@ -36,7 +36,7 @@ def zero_terminated? end def name - raise "Should not call this for ITypeInfo" + raise 'Should not call this for ITypeInfo' end end end diff --git a/lib/ffi-gobject_introspection/lib.rb b/lib/ffi-gobject_introspection/lib.rb index faa693cd8..db3fae70f 100644 --- a/lib/ffi-gobject_introspection/lib.rb +++ b/lib/ffi-gobject_introspection/lib.rb @@ -4,7 +4,7 @@ module GObjectIntrospection # Module for attaching functions from the girepository library module Lib extend FFI::Library - ffi_lib "girepository-1.0" + ffi_lib 'girepository-1.0' # IRepository enum :IRepositoryLoadFlags, [:LAZY, (1 << 0)] diff --git a/lib/gir_ffi-base/gobject/lib.rb b/lib/gir_ffi-base/gobject/lib.rb index 3d97ba7fd..c2d493c57 100644 --- a/lib/gir_ffi-base/gobject/lib.rb +++ b/lib/gir_ffi-base/gobject/lib.rb @@ -2,7 +2,7 @@ module GObject # Module for attaching functions from the gobject library module Lib extend FFI::Library - ffi_lib "gobject-2.0" + ffi_lib 'gobject-2.0' attach_function :g_type_init, [], :void end end diff --git a/lib/gir_ffi/builders/argument_builder.rb b/lib/gir_ffi/builders/argument_builder.rb index ebbb1ff94..cc2d3c64c 100644 --- a/lib/gir_ffi/builders/argument_builder.rb +++ b/lib/gir_ffi/builders/argument_builder.rb @@ -141,7 +141,7 @@ def caller_allocated_object? def ingoing_convertor if skipped? - NullConvertor.new("0") + NullConvertor.new('0') elsif closure? ClosureToPointerConvertor.new(name) elsif @type_info.needs_ruby_to_c_conversion_for_functions? diff --git a/lib/gir_ffi/builders/c_to_ruby_convertor.rb b/lib/gir_ffi/builders/c_to_ruby_convertor.rb index 77df71e90..2722b9af7 100644 --- a/lib/gir_ffi/builders/c_to_ruby_convertor.rb +++ b/lib/gir_ffi/builders/c_to_ruby_convertor.rb @@ -22,7 +22,7 @@ def conversion_arguments if @type_info.flattened_tag == :c "#{@type_info.element_type.inspect}, #{array_size}, #{@argument_name}" else - @type_info.extra_conversion_arguments.map(&:inspect).push(@argument_name).join(", ") + @type_info.extra_conversion_arguments.map(&:inspect).push(@argument_name).join(', ') end end diff --git a/lib/gir_ffi/builders/callback_argument_builder.rb b/lib/gir_ffi/builders/callback_argument_builder.rb index f0fec1f44..ddaff38d6 100644 --- a/lib/gir_ffi/builders/callback_argument_builder.rb +++ b/lib/gir_ffi/builders/callback_argument_builder.rb @@ -44,7 +44,7 @@ def pre_conversion when :inout [out_parameter_preparation, ingoing_pre_conversion] when :error - [out_parameter_preparation, "begin"] + [out_parameter_preparation, 'begin'] end end @@ -56,7 +56,7 @@ def post_conversion [ "rescue => #{result_name}", outgoing_post_conversion, - "end" + 'end' ] else [] diff --git a/lib/gir_ffi/builders/field_builder.rb b/lib/gir_ffi/builders/field_builder.rb index 1b8c07fc6..3007e0795 100644 --- a/lib/gir_ffi/builders/field_builder.rb +++ b/lib/gir_ffi/builders/field_builder.rb @@ -86,7 +86,7 @@ def field_type end def field_argument_info - @field_argument_info ||= FieldArgumentInfo.new "value", field_type + @field_argument_info ||= FieldArgumentInfo.new 'value', field_type end def return_value_builder diff --git a/lib/gir_ffi/builders/function_builder.rb b/lib/gir_ffi/builders/function_builder.rb index a1d3db9c5..8f07d4403 100644 --- a/lib/gir_ffi/builders/function_builder.rb +++ b/lib/gir_ffi/builders/function_builder.rb @@ -71,7 +71,7 @@ def error_argument vargen def function_call_arguments ca = @argument_builder_collection.call_argument_names - ca.unshift "self" if @info.method? + ca.unshift 'self' if @info.method? ca end end diff --git a/lib/gir_ffi/builders/mapping_method_builder.rb b/lib/gir_ffi/builders/mapping_method_builder.rb index 1be81fc3d..fe510badb 100644 --- a/lib/gir_ffi/builders/mapping_method_builder.rb +++ b/lib/gir_ffi/builders/mapping_method_builder.rb @@ -35,7 +35,7 @@ def method_definition end def method_name - "call_with_argument_mapping" + 'call_with_argument_mapping' end def method_arguments diff --git a/lib/gir_ffi/builders/marshalling_method_builder.rb b/lib/gir_ffi/builders/marshalling_method_builder.rb index c6945fb1b..10e9efe76 100644 --- a/lib/gir_ffi/builders/marshalling_method_builder.rb +++ b/lib/gir_ffi/builders/marshalling_method_builder.rb @@ -31,7 +31,7 @@ def method_definition end def method_name - "marshaller" + 'marshaller' end def method_arguments diff --git a/lib/gir_ffi/builders/method_template.rb b/lib/gir_ffi/builders/method_template.rb index e3c98f4d8..cacb02d9a 100644 --- a/lib/gir_ffi/builders/method_template.rb +++ b/lib/gir_ffi/builders/method_template.rb @@ -66,7 +66,7 @@ def result def result_name_list @result_name_list ||= - @argument_builder_collection.capture_variable_names.join(", ") + @argument_builder_collection.capture_variable_names.join(', ') end def capturing_invocation diff --git a/lib/gir_ffi/builders/property_builder.rb b/lib/gir_ffi/builders/property_builder.rb index 1710c4548..8956cb20d 100644 --- a/lib/gir_ffi/builders/property_builder.rb +++ b/lib/gir_ffi/builders/property_builder.rb @@ -109,7 +109,7 @@ def type_info end def argument_info - @argument_info ||= FieldArgumentInfo.new("value", type_info) + @argument_info ||= FieldArgumentInfo.new('value', type_info) end def container_class diff --git a/lib/gir_ffi/builders/ruby_to_c_convertor.rb b/lib/gir_ffi/builders/ruby_to_c_convertor.rb index b54a437c1..42bb889a5 100644 --- a/lib/gir_ffi/builders/ruby_to_c_convertor.rb +++ b/lib/gir_ffi/builders/ruby_to_c_convertor.rb @@ -12,6 +12,6 @@ def conversion end def conversion_arguments name - @type_info.extra_conversion_arguments.map(&:inspect).push(name).join(", ") + @type_info.extra_conversion_arguments.map(&:inspect).push(name).join(', ') end end diff --git a/lib/gir_ffi/error_argument_info.rb b/lib/gir_ffi/error_argument_info.rb index b5e7ff7a8..9fec01359 100644 --- a/lib/gir_ffi/error_argument_info.rb +++ b/lib/gir_ffi/error_argument_info.rb @@ -16,7 +16,7 @@ def argument_type end def name - "_error" + '_error' end def closure diff --git a/lib/gir_ffi/ffi_ext/pointer.rb b/lib/gir_ffi/ffi_ext/pointer.rb index 091277aea..ea18fd2b4 100644 --- a/lib/gir_ffi/ffi_ext/pointer.rb +++ b/lib/gir_ffi/ffi_ext/pointer.rb @@ -21,7 +21,7 @@ def to_object end def to_utf8 - null? ? nil : read_string.force_encoding("utf-8") + null? ? nil : read_string.force_encoding('utf-8') end end end diff --git a/lib/gir_ffi/info_ext/safe_constant_name.rb b/lib/gir_ffi/info_ext/safe_constant_name.rb index af771aaf2..fdd3f9ab8 100644 --- a/lib/gir_ffi/info_ext/safe_constant_name.rb +++ b/lib/gir_ffi/info_ext/safe_constant_name.rb @@ -5,8 +5,8 @@ module SafeConstantName def safe_name name.tr('-', '_').gsub(/^./) do |char| case char - when "_" - "Private___" + when '_' + 'Private___' else char.upcase end diff --git a/lib/gir_ffi/info_ext/safe_function_name.rb b/lib/gir_ffi/info_ext/safe_function_name.rb index e824b50d9..d7c0fa003 100644 --- a/lib/gir_ffi/info_ext/safe_function_name.rb +++ b/lib/gir_ffi/info_ext/safe_function_name.rb @@ -4,7 +4,7 @@ module InfoExt module SafeFunctionName def safe_name name = self.name - return "_" if name.empty? + return '_' if name.empty? name end end diff --git a/lib/gir_ffi/receiver_argument_info.rb b/lib/gir_ffi/receiver_argument_info.rb index fed159a44..f3991031a 100644 --- a/lib/gir_ffi/receiver_argument_info.rb +++ b/lib/gir_ffi/receiver_argument_info.rb @@ -12,6 +12,6 @@ def direction end def name - "_instance" + '_instance' end end diff --git a/lib/gir_ffi/user_data_argument_info.rb b/lib/gir_ffi/user_data_argument_info.rb index 3360a5b68..e310bf006 100644 --- a/lib/gir_ffi/user_data_argument_info.rb +++ b/lib/gir_ffi/user_data_argument_info.rb @@ -16,6 +16,6 @@ def skip? end def name - "_user_data" + '_user_data' end end diff --git a/lib/gir_ffi/version.rb b/lib/gir_ffi/version.rb index 52cca4eaf..971ef2f5d 100644 --- a/lib/gir_ffi/version.rb +++ b/lib/gir_ffi/version.rb @@ -1,4 +1,4 @@ # Current GirFFI version module GirFFI - VERSION = "0.7.7" + VERSION = '0.7.7' end diff --git a/test/base_test_helper.rb b/test/base_test_helper.rb index 0672259e0..c8492de92 100644 --- a/test/base_test_helper.rb +++ b/test/base_test_helper.rb @@ -3,7 +3,7 @@ begin require 'simplecov' SimpleCov.start do - add_filter "/test/" + add_filter '/test/' end rescue LoadError end @@ -26,9 +26,9 @@ module GObjectIntrospection class IRepository def shared_library_with_regress namespace case namespace - when "Regress" + when 'Regress' return File.join(File.dirname(__FILE__), 'lib', 'libregress.so') - when "GIMarshallingTests" + when 'GIMarshallingTests' return File.join(File.dirname(__FILE__), 'lib', 'libgimarshallingtests.so') else return shared_library_without_regress namespace diff --git a/test/ffi-glib/array_test.rb b/test/ffi-glib/array_test.rb index 97f2beb40..e8c6e1575 100644 --- a/test/ffi-glib/array_test.rb +++ b/test/ffi-glib/array_test.rb @@ -1,32 +1,32 @@ require 'gir_ffi_test_helper' describe GLib::Array do - it "knows its element type" do + it 'knows its element type' do arr = GLib::Array.new :gint32 assert_equal :gint32, arr.element_type end - describe "#append_vals" do + describe '#append_vals' do before do @arr = GLib::Array.new :gint32 @result = @arr.append_vals [1, 2, 3] end - it "appends values" do + it 'appends values' do assert_equal 3, @arr.len end - it "returns self" do + it 'returns self' do assert_equal @result, @arr end end - describe "#each" do + describe '#each' do before do @arr = GLib::Array.new(:gint32).append_vals [1, 2, 3] end - it "iterates over the values" do + it 'iterates over the values' do a = [] @arr.each { |v| a << v } @@ -34,8 +34,8 @@ end end - describe "::wrap" do - it "wraps a pointer, taking the element type as the first argument" do + describe '::wrap' do + it 'wraps a pointer, taking the element type as the first argument' do arr = GLib::Array.new :gint32 arr.append_vals [1, 2, 3] arr2 = GLib::Array.wrap :gint32, arr.to_ptr @@ -48,7 +48,7 @@ proc { GLib::Array.wrap :gint8, arr.to_ptr }.must_output nil, /sizes do not match/ end - it "handles a struct as the element type" do + it 'handles a struct as the element type' do vals = [1, 2, 3].map { |i| GObject::EnumValue.new.tap { |ev| ev.value = i } } arr = GLib::Array.new GObject::EnumValue arr.append_vals vals @@ -57,35 +57,35 @@ end end - it "includes Enumerable" do + it 'includes Enumerable' do GLib::Array.must_include Enumerable end - it "has a working #to_a method" do + it 'has a working #to_a method' do arr = GLib::Array.new :gint32 arr.append_vals [1, 2, 3] assert_equal [1, 2, 3], arr.to_a end - describe ".from" do - it "creates a GArray from an array of :gint32" do + describe '.from' do + it 'creates a GArray from an array of :gint32' do arr = GLib::Array.from :gint32, [3, 2, 1] arr.data_ptr.read_array_of_int32(3).must_equal [3, 2, 1] end - it "creates a GArray from an array of :gboolean" do + it 'creates a GArray from an array of :gboolean' do arr = GLib::Array.from :gboolean, [true, false, true] arr.data_ptr.read_array_of_int(3).must_equal [1, 0, 1] end - it "return its argument if given a GArray" do + it 'return its argument if given a GArray' do arr = GLib::Array.new :gint32 arr.append_vals [3, 2, 1] arr2 = GLib::Array.from :gint32, arr assert arr2.equal? arr end - it "wraps its argument if given a pointer" do + it 'wraps its argument if given a pointer' do arr = GLib::Array.new :gint32 arr.append_vals [3, 2, 1] pointer = arr.to_ptr @@ -97,27 +97,27 @@ end end - describe "#==" do - it "returns true when comparing to an array with the same elements" do + describe '#==' do + it 'returns true when comparing to an array with the same elements' do arr = GLib::Array.from :gint32, [1, 2, 3] arr.must_be :==, [1, 2, 3] end - it "returns false when comparing to an array with different elements" do + it 'returns false when comparing to an array with different elements' do arr = GLib::Array.from :gint32, [1, 2, 3] arr.wont_be :==, [1, 2] end - it "returns true when comparing to a GArray with the same elements" do + it 'returns true when comparing to a GArray with the same elements' do arr = GLib::Array.from :gint32, [1, 2, 3] other = GLib::Array.from :gint32, [1, 2, 3] arr.must_be :==, other end - it "returns false when comparing to a GArray with different elements" do + it 'returns false when comparing to a GArray with different elements' do arr = GLib::Array.from :gint32, [1, 2, 3] other = GLib::Array.from :gint32, [1, 2] @@ -125,56 +125,56 @@ end end - describe "#index" do - it "returns the proper element for an array of :gint32" do + describe '#index' do + it 'returns the proper element for an array of :gint32' do arr = GLib::Array.from :gint32, [1, 2, 3] arr.index(2).must_equal 3 end - it "returns the proper element for an array of :utf8" do + it 'returns the proper element for an array of :utf8' do arr = GLib::Array.from :utf8, %w(a b c) - arr.index(1).must_equal "b" + arr.index(1).must_equal 'b' end - it "returns the proper element for an array of :gboolean" do + it 'returns the proper element for an array of :gboolean' do arr = GLib::Array.from :gboolean, [true, false, true] arr.index(1).must_equal false end - it "returns the proper element for an array of struct" do + it 'returns the proper element for an array of struct' do vals = [1, 2, 3].map { |i| GObject::EnumValue.new.tap { |ev| ev.value = i } } arr = GLib::Array.from GObject::EnumValue, vals arr.index(1).value.must_equal 2 end - it "raises an error if the index is out of bounds" do + it 'raises an error if the index is out of bounds' do arr = GLib::Array.from :gint32, [1, 2, 3] proc { arr.index(16) }.must_raise IndexError proc { arr.index(-1) }.must_raise IndexError end end - describe "#reset_typespec" do - describe "when it needs to guess the type" do - it "guesses :uint8 for size 1" do + describe '#reset_typespec' do + describe 'when it needs to guess the type' do + it 'guesses :uint8 for size 1' do arr = GLib::Array.from :int8, [1, 2, 3] arr.reset_typespec arr.element_type.must_equal :uint8 end - it "guesses :uint16 for size 2" do + it 'guesses :uint16 for size 2' do arr = GLib::Array.from :int16, [1, 2, 3] arr.reset_typespec arr.element_type.must_equal :uint16 end - it "guesses :uint32 for size 4" do + it 'guesses :uint32 for size 4' do arr = GLib::Array.from :int32, [1, 2, 3] arr.reset_typespec arr.element_type.must_equal :uint32 end - it "guesses :uint64 for size 8" do + it 'guesses :uint64 for size 8' do arr = GLib::Array.from :int64, [1, 2, 3] arr.reset_typespec arr.element_type.must_equal :uint64 diff --git a/test/ffi-glib/byte_array_test.rb b/test/ffi-glib/byte_array_test.rb index 6b3d22e1c..101f95051 100644 --- a/test/ffi-glib/byte_array_test.rb +++ b/test/ffi-glib/byte_array_test.rb @@ -1,20 +1,20 @@ require 'gir_ffi_test_helper' describe GLib::ByteArray do - it "can succesfully be created with GLib::ByteArray.new" do + it 'can succesfully be created with GLib::ByteArray.new' do ba = GLib::ByteArray.new assert_instance_of GLib::ByteArray, ba end - it "allows strings to be appended to it" do + it 'allows strings to be appended to it' do ba = GLib::ByteArray.new - ba.append "abdc" + ba.append 'abdc' pass end - it "has a working #to_string method" do + it 'has a working #to_string method' do ba = GLib::ByteArray.new - ba = ba.append "abdc" - assert_equal "abdc", ba.to_string + ba = ba.append 'abdc' + assert_equal 'abdc', ba.to_string end end diff --git a/test/ffi-glib/bytes_test.rb b/test/ffi-glib/bytes_test.rb index 6906ef998..0c8119389 100644 --- a/test/ffi-glib/bytes_test.rb +++ b/test/ffi-glib/bytes_test.rb @@ -1,22 +1,22 @@ require 'gir_ffi_test_helper' describe GLib::Bytes do - it "can succesfully be created with GLib::Bytes.new" do + it 'can succesfully be created with GLib::Bytes.new' do bytes = GLib::Bytes.new [1, 2, 3] bytes.must_be_instance_of GLib::Bytes end - it "has a working #get_size method" do + it 'has a working #get_size method' do bytes = GLib::Bytes.new [1, 2, 3] bytes.get_size.must_equal 3 end - it "has a working #get_data method" do + it 'has a working #get_data method' do bytes = GLib::Bytes.new [1, 2, 3] bytes.get_data.to_a.must_equal [1, 2, 3] end - it "has a working #each method" do + it 'has a working #each method' do a = [] bytes = GLib::Bytes.new [1, 2, 3] bytes.each do |v| @@ -25,25 +25,25 @@ a.must_equal [3, 2, 1] end - it "has a working #to_a method" do + it 'has a working #to_a method' do bytes = GLib::Bytes.new [1, 2, 3] bytes.to_a.must_equal [1, 2, 3] end - describe ".from" do - it "creates a GLib::Bytes object form an array of small integers" do + describe '.from' do + it 'creates a GLib::Bytes object form an array of small integers' do bytes = GLib::Bytes.from [1, 2, 3] bytes.must_be_instance_of GLib::Bytes bytes.to_a.must_equal [1, 2, 3] end - it "returns its argument if given a GLib::Bytes object" do + it 'returns its argument if given a GLib::Bytes object' do bytes = GLib::Bytes.new [1, 2, 3] result = GLib::Bytes.from bytes assert result.equal?(bytes) end - it "wraps its argument if given a pointer" do + it 'wraps its argument if given a pointer' do bytes = GLib::Bytes.new [1, 2, 3] ptr = bytes.to_ptr result = GLib::Bytes.from ptr diff --git a/test/ffi-glib/hash_table_test.rb b/test/ffi-glib/hash_table_test.rb index e1872e22f..e74ddbf4b 100644 --- a/test/ffi-glib/hash_table_test.rb +++ b/test/ffi-glib/hash_table_test.rb @@ -1,27 +1,27 @@ require 'gir_ffi_test_helper' describe GLib::HashTable do - it "knows its key and value types" do + it 'knows its key and value types' do hsh = GLib::HashTable.new :gint32, :utf8 assert_equal :gint32, hsh.key_type assert_equal :utf8, hsh.value_type end - describe "::from" do - it "creates a GHashTable from a Ruby hash" do + describe '::from' do + it 'creates a GHashTable from a Ruby hash' do hsh = GLib::HashTable.from [:utf8, :gint32], - "foo" => 23, "bar" => 32 - assert_equal({ "foo" => 23, "bar" => 32 }, hsh.to_hash) + 'foo' => 23, 'bar' => 32 + assert_equal({ 'foo' => 23, 'bar' => 32 }, hsh.to_hash) end - it "return its argument if given a GHashTable" do - hsh = GLib::HashTable.from [:utf8, :gint32], "foo" => 23, "bar" => 32 + it 'return its argument if given a GHashTable' do + hsh = GLib::HashTable.from [:utf8, :gint32], 'foo' => 23, 'bar' => 32 hsh2 = GLib::HashTable.from [:utf8, :gint32], hsh assert hsh2.equal? hsh end - it "wraps its argument if given a pointer" do - hsh = GLib::HashTable.from [:utf8, :gint32], "foo" => 23, "bar" => 32 + it 'wraps its argument if given a pointer' do + hsh = GLib::HashTable.from [:utf8, :gint32], 'foo' => 23, 'bar' => 32 pointer = hsh.to_ptr assert_instance_of FFI::Pointer, pointer hsh2 = GLib::HashTable.from [:utf8, :gint32], pointer @@ -31,36 +31,36 @@ end end - it "allows key-value pairs to be inserted" do + it 'allows key-value pairs to be inserted' do h = GLib::HashTable.new :utf8, :utf8 - h.insert "foo", "bar" - h.to_hash.must_equal "foo" => "bar" + h.insert 'foo', 'bar' + h.to_hash.must_equal 'foo' => 'bar' end - it "includes Enumerable" do + it 'includes Enumerable' do GLib::HashTable.must_include Enumerable end - describe "a HashTable provided by the system" do + describe 'a HashTable provided by the system' do before do GirFFI.setup :Regress @hash = Regress.test_ghash_container_return end - it "has a working #each method" do + it 'has a working #each method' do a = {} @hash.each { |k, v| a[k] = v } a.must_be :==, - "foo" => "bar", - "baz" => "bat", - "qux" => "quux" + 'foo' => 'bar', + 'baz' => 'bat', + 'qux' => 'quux' end - it "has a working #to_hash method" do + it 'has a working #to_hash method' do @hash.to_hash.must_be :==, - "foo" => "bar", - "baz" => "bat", - "qux" => "quux" + 'foo' => 'bar', + 'baz' => 'bat', + 'qux' => 'quux' end end end diff --git a/test/ffi-glib/iconv_test.rb b/test/ffi-glib/iconv_test.rb index 9f18c7ec3..b7551407c 100644 --- a/test/ffi-glib/iconv_test.rb +++ b/test/ffi-glib/iconv_test.rb @@ -1,16 +1,16 @@ require 'gir_ffi_test_helper' describe GLib::IConv do - describe ".open" do - it "creates a new instance of GLib::Iconv" do - instance = GLib::IConv.open("ascii", "utf-8") + describe '.open' do + it 'creates a new instance of GLib::Iconv' do + instance = GLib::IConv.open('ascii', 'utf-8') instance.must_be_instance_of GLib::IConv end end - let(:instance) { GLib::IConv.open("ascii", "utf-8") } + let(:instance) { GLib::IConv.open('ascii', 'utf-8') } - describe "#setup_and_call" do + describe '#setup_and_call' do it "works for the method called ''" do instance.setup_and_call :'', [nil, nil, nil, nil] end diff --git a/test/ffi-glib/list_test.rb b/test/ffi-glib/list_test.rb index b017dc137..4b99811af 100644 --- a/test/ffi-glib/list_test.rb +++ b/test/ffi-glib/list_test.rb @@ -1,25 +1,25 @@ require 'gir_ffi_test_helper' describe GLib::List do - it "knows its element type" do + it 'knows its element type' do arr = GLib::List.new :gint32 assert_equal :gint32, arr.element_type end - describe "#append" do - it "appends integer values" do + describe '#append' do + it 'appends integer values' do lst = GLib::List.new :gint32 res = lst.append 1 assert_equal 1, res.data end - it "appends string values" do + it 'appends string values' do lst = GLib::List.new :utf8 - res = lst.append "bla" - assert_equal "bla", res.data + res = lst.append 'bla' + assert_equal 'bla', res.data end - it "appends multiple values into a single list" do + it 'appends multiple values into a single list' do lst = GLib::List.new :gint32 lst = lst.append 1 @@ -31,19 +31,19 @@ end end - describe "::from" do - it "creates a GList from a Ruby array" do + describe '::from' do + it 'creates a GList from a Ruby array' do lst = GLib::List.from :gint32, [3, 2, 1] assert_equal [3, 2, 1], lst.to_a end - it "return its argument if given a GList" do + it 'return its argument if given a GList' do lst = GLib::List.from :gint32, [3, 2, 1] lst2 = GLib::List.from :gint32, lst assert lst2.equal? lst end - it "wraps its argument if given a pointer" do + it 'wraps its argument if given a pointer' do lst = GLib::List.from :gint32, [3, 2, 1] pointer = lst.to_ptr assert_instance_of FFI::Pointer, pointer @@ -54,27 +54,27 @@ end end - describe "#==" do - it "returns true when comparing to an array with the same elements" do + describe '#==' do + it 'returns true when comparing to an array with the same elements' do list = GLib::List.from :gint32, [1, 2, 3] list.must_be :==, [1, 2, 3] end - it "returns false when comparing to an array with different elements" do + it 'returns false when comparing to an array with different elements' do list = GLib::List.from :gint32, [1, 2, 3] list.wont_be :==, [1, 2] end - it "returns true when comparing to a list with the same elements" do + it 'returns true when comparing to a list with the same elements' do list = GLib::List.from :gint32, [1, 2, 3] other = GLib::List.from :gint32, [1, 2, 3] list.must_be :==, other end - it "returns false when comparing to a list with different elements" do + it 'returns false when comparing to a list with different elements' do list = GLib::List.from :gint32, [1, 2, 3] other = GLib::List.from :gint32, [1, 2] diff --git a/test/ffi-glib/main_loop_test.rb b/test/ffi-glib/main_loop_test.rb index 2bcb72026..d42b3b432 100644 --- a/test/ffi-glib/main_loop_test.rb +++ b/test/ffi-glib/main_loop_test.rb @@ -1,8 +1,8 @@ require 'gir_ffi_test_helper' describe GLib::MainLoop do - describe "#run" do - it "allows other threads to run" do + describe '#run' do + it 'allows other threads to run' do main_loop = GLib::MainLoop.new nil, false a = [] @@ -12,16 +12,16 @@ slow_thread = Thread.new do sleep 0.001 - a << "During run" + a << 'During run' end - a << "Before run" + a << 'Before run' main_loop.run - a << "After run" + a << 'After run' slow_thread.join - a.last.must_equal "After run" + a.last.must_equal 'After run' end end end diff --git a/test/ffi-glib/ptr_array_test.rb b/test/ffi-glib/ptr_array_test.rb index 546061a7f..0c80ae853 100644 --- a/test/ffi-glib/ptr_array_test.rb +++ b/test/ffi-glib/ptr_array_test.rb @@ -1,28 +1,28 @@ require 'gir_ffi_test_helper' describe GLib::PtrArray do - it "knows its element type" do + it 'knows its element type' do arr = GLib::PtrArray.new :utf8 assert_equal :utf8, arr.element_type end - describe "::add" do - it "correctly takes the type into account" do + describe '::add' do + it 'correctly takes the type into account' do arr = GLib::PtrArray.new :utf8 - str = "test" + str = 'test' GLib::PtrArray.add arr, str assert_equal str, arr.pdata.read_pointer.read_string end end - describe "#each" do - it "works normally" do + describe '#each' do + it 'works normally' do arr = GLib::PtrArray.new :utf8 - GLib::PtrArray.add arr, "test1" - GLib::PtrArray.add arr, "test2" - GLib::PtrArray.add arr, "test3" + GLib::PtrArray.add arr, 'test1' + GLib::PtrArray.add arr, 'test2' + GLib::PtrArray.add arr, 'test3' a = [] arr.each { |v| a << v } @@ -30,64 +30,64 @@ assert_equal %w(test1 test2 test3), a end - it "works when exiting the loop prematurely" do + it 'works when exiting the loop prematurely' do arr = GLib::PtrArray.new :utf8 - GLib::PtrArray.add arr, "test1" - GLib::PtrArray.add arr, "test2" - GLib::PtrArray.add arr, "test3" + GLib::PtrArray.add arr, 'test1' + GLib::PtrArray.add arr, 'test2' + GLib::PtrArray.add arr, 'test3' a = [] arr.each do |v| a << v - break if v == "test2" + break if v == 'test2' end assert_equal %w(test1 test2), a end end - it "includes Enumerable" do + it 'includes Enumerable' do GLib::PtrArray.must_include Enumerable end - it "has a working #to_a method" do + it 'has a working #to_a method' do arr = GLib::PtrArray.new :utf8 - GLib::PtrArray.add arr, "test1" - GLib::PtrArray.add arr, "test2" - GLib::PtrArray.add arr, "test3" + GLib::PtrArray.add arr, 'test1' + GLib::PtrArray.add arr, 'test2' + GLib::PtrArray.add arr, 'test3' assert_equal %w(test1 test2 test3), arr.to_a end - it "has #add as an instance method too" do + it 'has #add as an instance method too' do arr = GLib::PtrArray.new :utf8 - arr.add "test1" - assert_equal ["test1"], arr.to_a + arr.add 'test1' + assert_equal ['test1'], arr.to_a end - describe "#==" do - it "returns true when comparing to an array with the same elements" do + describe '#==' do + it 'returns true when comparing to an array with the same elements' do arr = GLib::PtrArray.from :utf8, %w(1 2 3) arr.must_be :==, %w(1 2 3) end - it "returns false when comparing to an array with different elements" do + it 'returns false when comparing to an array with different elements' do arr = GLib::PtrArray.from :utf8, %w(1 2 3) arr.wont_be :==, %w(1 2) end - it "returns true when comparing to a GPtrArray with the same elements" do + it 'returns true when comparing to a GPtrArray with the same elements' do arr = GLib::PtrArray.from :utf8, %w(1 2 3) other = GLib::PtrArray.from :utf8, %w(1 2 3) arr.must_be :==, other end - it "returns false when comparing to a GPtrArray with different elements" do + it 'returns false when comparing to a GPtrArray with different elements' do arr = GLib::PtrArray.from :utf8, %w(1 2 3) other = GLib::PtrArray.from :utf8, %w(1 2) @@ -95,13 +95,13 @@ end end - describe "#index" do - it "returns the correct element" do + describe '#index' do + it 'returns the correct element' do arr = GLib::PtrArray.from :utf8, %w(1 2 3) - arr.index(1).must_equal "2" + arr.index(1).must_equal '2' end - it "raises an error if the index is out of bounds" do + it 'raises an error if the index is out of bounds' do arr = GLib::PtrArray.from :utf8, %w(1 2 3) proc { arr.index(16) }.must_raise IndexError proc { arr.index(-1) }.must_raise IndexError diff --git a/test/ffi-glib/ruby_closure_test.rb b/test/ffi-glib/ruby_closure_test.rb index 71189ef27..b0dc6027b 100644 --- a/test/ffi-glib/ruby_closure_test.rb +++ b/test/ffi-glib/ruby_closure_test.rb @@ -1,18 +1,18 @@ require 'gir_ffi_test_helper' describe GObject::RubyClosure do - it "has a constructor with a mandatory block argument" do + it 'has a constructor with a mandatory block argument' do assert_raises ArgumentError do GObject::RubyClosure.new end end - it "is a kind of Closure" do + it 'is a kind of Closure' do c = GObject::RubyClosure.new {} assert_kind_of GObject::Closure, c end - it "is able to retrieve its block from its struct" do + it 'is able to retrieve its block from its struct' do a = 0 c = GObject::RubyClosure.new { a = 2 } c2 = GObject::RubyClosure.wrap(c.to_ptr) @@ -20,7 +20,7 @@ assert_equal 2, a end - describe "its #marshaller singleton method" do + describe 'its #marshaller singleton method' do it "invokes its closure argument's block" do a = 0 c = GObject::RubyClosure.new { a = 2 } @@ -28,7 +28,7 @@ assert_equal 2, a end - it "works when its closure argument is a GObject::Closure" do + it 'works when its closure argument is a GObject::Closure' do a = 0 c = GObject::RubyClosure.new { a = 2 } c2 = GObject::Closure.wrap(c.to_ptr) @@ -44,7 +44,7 @@ end end - it "has GObject::Closure#invoke call its block" do + it 'has GObject::Closure#invoke call its block' do a = 0 c = GObject::RubyClosure.new { a = 2 } c2 = GObject::Closure.wrap(c.to_ptr) diff --git a/test/ffi-glib/s_list_test.rb b/test/ffi-glib/s_list_test.rb index f6aabfc88..20beb573f 100644 --- a/test/ffi-glib/s_list_test.rb +++ b/test/ffi-glib/s_list_test.rb @@ -1,25 +1,25 @@ require 'gir_ffi_test_helper' describe GLib::SList do - it "knows its element type" do + it 'knows its element type' do arr = GLib::SList.new :gint32 assert_equal :gint32, arr.element_type end - describe "#prepend" do - it "prepends integer values" do + describe '#prepend' do + it 'prepends integer values' do lst = GLib::SList.new :gint32 res = lst.prepend 1 assert_equal 1, res.data end - it "prepends string values" do + it 'prepends string values' do lst = GLib::SList.new :utf8 - res = lst.prepend "bla" - assert_equal "bla", res.data + res = lst.prepend 'bla' + assert_equal 'bla', res.data end - it "prepends multiple values into a single list" do + it 'prepends multiple values into a single list' do lst = GLib::SList.new :gint32 res = lst.prepend 1 @@ -31,40 +31,40 @@ end end - describe "::from" do - it "creates a GSList from a Ruby array" do + describe '::from' do + it 'creates a GSList from a Ruby array' do lst = GLib::SList.from :gint32, [3, 2, 1] assert_equal [3, 2, 1], lst.to_a end - it "return its argument if given a GSList" do + it 'return its argument if given a GSList' do lst = GLib::SList.from :gint32, [3, 2, 1] lst2 = GLib::SList.from :gint32, lst assert_equal lst, lst2 end end - describe "#==" do - it "returns true when comparing to an array with the same elements" do + describe '#==' do + it 'returns true when comparing to an array with the same elements' do list = GLib::SList.from :gint32, [1, 2, 3] list.must_be :==, [1, 2, 3] end - it "returns false when comparing to an array with different elements" do + it 'returns false when comparing to an array with different elements' do list = GLib::SList.from :gint32, [1, 2, 3] list.wont_be :==, [1, 2] end - it "returns true when comparing to a list with the same elements" do + it 'returns true when comparing to a list with the same elements' do list = GLib::SList.from :gint32, [1, 2, 3] other = GLib::SList.from :gint32, [1, 2, 3] list.must_be :==, other end - it "returns false when comparing to a list with different elements" do + it 'returns false when comparing to a list with different elements' do list = GLib::SList.from :gint32, [1, 2, 3] other = GLib::SList.from :gint32, [1, 2] diff --git a/test/ffi-glib/strv_test.rb b/test/ffi-glib/strv_test.rb index 2215b5559..14b43420f 100644 --- a/test/ffi-glib/strv_test.rb +++ b/test/ffi-glib/strv_test.rb @@ -1,20 +1,20 @@ require 'base_test_helper' describe GLib::Strv do - describe "::from" do - it "creates a Strv from a Ruby array" do + describe '::from' do + it 'creates a Strv from a Ruby array' do strv = GLib::Strv.from %w(1 2 3) strv.must_be_instance_of GLib::Strv strv.to_a.must_equal %w(1 2 3) end - it "return its argument if given a Strv" do + it 'return its argument if given a Strv' do strv = GLib::Strv.from %w(1 2 3) strv2 = GLib::Strv.from strv assert strv2.equal? strv end - it "wraps its argument if given a pointer" do + it 'wraps its argument if given a pointer' do strv = GLib::Strv.from %w(1 2 3) pointer = strv.to_ptr @@ -28,27 +28,27 @@ end end - describe "#==" do - it "returns true when comparing to an array with the same elements" do + describe '#==' do + it 'returns true when comparing to an array with the same elements' do strv = GLib::Strv.from %w(1 2 3) strv.must_be :==, %w(1 2 3) end - it "returns false when comparing to an array with different elements" do + it 'returns false when comparing to an array with different elements' do strv = GLib::Strv.from %w(1 2 3) strv.wont_be :==, %w(1 2) end - it "returns true when comparing to a strv with the same elements" do + it 'returns true when comparing to a strv with the same elements' do strv = GLib::Strv.from %w(1 2 3) other = GLib::Strv.from %w(1 2 3) strv.must_be :==, other end - it "returns false when comparing to a strv with different elements" do + it 'returns false when comparing to a strv with different elements' do strv = GLib::Strv.from %w(1 2 3) other = GLib::Strv.from %w(1 2) diff --git a/test/ffi-glib/variant_test.rb b/test/ffi-glib/variant_test.rb index 0b134bc5a..398466ce2 100644 --- a/test/ffi-glib/variant_test.rb +++ b/test/ffi-glib/variant_test.rb @@ -1,10 +1,10 @@ require 'gir_ffi_test_helper' describe GLib::Variant do - describe "#get_string" do - it "returns just the contained string" do - var = GLib::Variant.new_string("Foo") - var.get_string.must_equal "Foo" + describe '#get_string' do + it 'returns just the contained string' do + var = GLib::Variant.new_string('Foo') + var.get_string.must_equal 'Foo' end end end diff --git a/test/ffi-gobject/gobject_test.rb b/test/ffi-gobject/gobject_test.rb index 71f6df200..04a5dc183 100644 --- a/test/ffi-gobject/gobject_test.rb +++ b/test/ffi-gobject/gobject_test.rb @@ -5,45 +5,45 @@ GirFFI.setup :GIMarshallingTests describe GObject do - describe ".type_init" do - it "does not raise an error" do + describe '.type_init' do + it 'does not raise an error' do GObject.type_init pass end end - it "has constants for the fundamental GTypes" do - assert_equal GObject.type_from_name("invalid"), GObject::TYPE_INVALID + it 'has constants for the fundamental GTypes' do + assert_equal GObject.type_from_name('invalid'), GObject::TYPE_INVALID assert_equal nil, GObject.type_name(GObject::TYPE_INVALID) - assert_equal "void", GObject.type_name(GObject::TYPE_NONE) - assert_equal "GInterface", GObject.type_name(GObject::TYPE_INTERFACE) - assert_equal "gchar", GObject.type_name(GObject::TYPE_CHAR) - assert_equal "guchar", GObject.type_name(GObject::TYPE_UCHAR) - assert_equal "gboolean", GObject.type_name(GObject::TYPE_BOOLEAN) - assert_equal "gint", GObject.type_name(GObject::TYPE_INT) - assert_equal "guint", GObject.type_name(GObject::TYPE_UINT) - assert_equal "glong", GObject.type_name(GObject::TYPE_LONG) - assert_equal "gulong", GObject.type_name(GObject::TYPE_ULONG) - assert_equal "gint64", GObject.type_name(GObject::TYPE_INT64) - assert_equal "guint64", GObject.type_name(GObject::TYPE_UINT64) - assert_equal "GEnum", GObject.type_name(GObject::TYPE_ENUM) - assert_equal "GFlags", GObject.type_name(GObject::TYPE_FLAGS) - assert_equal "gfloat", GObject.type_name(GObject::TYPE_FLOAT) - assert_equal "gdouble", GObject.type_name(GObject::TYPE_DOUBLE) - assert_equal "gchararray", GObject.type_name(GObject::TYPE_STRING) - assert_equal "gpointer", GObject.type_name(GObject::TYPE_POINTER) - assert_equal "GBoxed", GObject.type_name(GObject::TYPE_BOXED) - assert_equal "GParam", GObject.type_name(GObject::TYPE_PARAM) - assert_equal "GObject", GObject.type_name(GObject::TYPE_OBJECT) - assert_equal "GType", GObject.type_name(GObject::TYPE_GTYPE) - assert_equal "GVariant", GObject.type_name(GObject::TYPE_VARIANT) - assert_equal "GStrv", GObject.type_name(GObject::TYPE_STRV) - assert_equal "GHashTable", GObject.type_name(GObject::TYPE_HASH_TABLE) + assert_equal 'void', GObject.type_name(GObject::TYPE_NONE) + assert_equal 'GInterface', GObject.type_name(GObject::TYPE_INTERFACE) + assert_equal 'gchar', GObject.type_name(GObject::TYPE_CHAR) + assert_equal 'guchar', GObject.type_name(GObject::TYPE_UCHAR) + assert_equal 'gboolean', GObject.type_name(GObject::TYPE_BOOLEAN) + assert_equal 'gint', GObject.type_name(GObject::TYPE_INT) + assert_equal 'guint', GObject.type_name(GObject::TYPE_UINT) + assert_equal 'glong', GObject.type_name(GObject::TYPE_LONG) + assert_equal 'gulong', GObject.type_name(GObject::TYPE_ULONG) + assert_equal 'gint64', GObject.type_name(GObject::TYPE_INT64) + assert_equal 'guint64', GObject.type_name(GObject::TYPE_UINT64) + assert_equal 'GEnum', GObject.type_name(GObject::TYPE_ENUM) + assert_equal 'GFlags', GObject.type_name(GObject::TYPE_FLAGS) + assert_equal 'gfloat', GObject.type_name(GObject::TYPE_FLOAT) + assert_equal 'gdouble', GObject.type_name(GObject::TYPE_DOUBLE) + assert_equal 'gchararray', GObject.type_name(GObject::TYPE_STRING) + assert_equal 'gpointer', GObject.type_name(GObject::TYPE_POINTER) + assert_equal 'GBoxed', GObject.type_name(GObject::TYPE_BOXED) + assert_equal 'GParam', GObject.type_name(GObject::TYPE_PARAM) + assert_equal 'GObject', GObject.type_name(GObject::TYPE_OBJECT) + assert_equal 'GType', GObject.type_name(GObject::TYPE_GTYPE) + assert_equal 'GVariant', GObject.type_name(GObject::TYPE_VARIANT) + assert_equal 'GStrv', GObject.type_name(GObject::TYPE_STRV) + assert_equal 'GHashTable', GObject.type_name(GObject::TYPE_HASH_TABLE) end - describe "::object_class_from_instance" do - it "returns a GObject::ObjectClass with the correct GType" do + describe '::object_class_from_instance' do + it 'returns a GObject::ObjectClass with the correct GType' do obj = GIMarshallingTests::OverridesObject.new object_class = GObject.object_class_from_instance obj gtype = object_class.g_type_class.g_type @@ -53,11 +53,11 @@ end end - describe "creating ParamSpecs" do - describe "#param_spec_int" do - it "creates a GObject::ParamSpecInt" do - spec = GObject.param_spec_int("foo", "foo bar", - "The Foo Bar Property", + describe 'creating ParamSpecs' do + describe '#param_spec_int' do + it 'creates a GObject::ParamSpecInt' do + spec = GObject.param_spec_int('foo', 'foo bar', + 'The Foo Bar Property', 10, 20, 15, 3) spec.must_be_instance_of GObject::ParamSpecInt diff --git a/test/ffi-gobject/object_class_test.rb b/test/ffi-gobject/object_class_test.rb index 72f4a85e6..b0efbe192 100644 --- a/test/ffi-gobject/object_class_test.rb +++ b/test/ffi-gobject/object_class_test.rb @@ -3,7 +3,7 @@ require 'ffi-gobject' describe GObject::ObjectClass do - describe "#list_properties" do + describe '#list_properties' do it "returns GIMarshallingTests::OverridesObject's properties" do obj = GIMarshallingTests::OverridesObject.new object_class = GObject.object_class_from_instance obj diff --git a/test/ffi-gobject/object_test.rb b/test/ffi-gobject/object_test.rb index 1253710dd..d2ea4a5e6 100644 --- a/test/ffi-gobject/object_test.rb +++ b/test/ffi-gobject/object_test.rb @@ -3,14 +3,14 @@ require 'ffi-gobject' describe GObject::Object do - describe "#get_property" do - it "is overridden to have arity 1" do + describe '#get_property' do + it 'is overridden to have arity 1' do assert_equal 1, - GObject::Object.instance_method("get_property").arity + GObject::Object.instance_method('get_property').arity end end - describe "automatic accessor methods" do + describe 'automatic accessor methods' do class AccessorTest < GObject::Object def get_x @x @@ -34,7 +34,7 @@ def set_x val end end - describe "#signal_connect" do + describe '#signal_connect' do subject { GObject::Object.new GObject::TYPE_OBJECT, nil } it 'delegates to GObject' do diff --git a/test/ffi-gobject/value_test.rb b/test/ffi-gobject/value_test.rb index de1c2d648..9503bf4e8 100644 --- a/test/ffi-gobject/value_test.rb +++ b/test/ffi-gobject/value_test.rb @@ -3,104 +3,104 @@ GirFFI.setup :Regress describe GObject::Value do - describe "::Struct" do - describe "layout" do + describe '::Struct' do + describe 'layout' do let(:layout) { GObject::Value::Struct.layout } - it "consists of :g_type and :data" do + it 'consists of :g_type and :data' do layout.members.must_equal [:g_type, :data] end - it "has an array as its second element" do + it 'has an array as its second element' do types = layout.fields.map(&:type) types[1].class.must_equal FFI::Type::Array end end end - describe "::wrap_ruby_value" do - it "wraps a boolean false" do + describe '::wrap_ruby_value' do + it 'wraps a boolean false' do gv = GObject::Value.wrap_ruby_value false assert_instance_of GObject::Value, gv assert_equal false, gv.get_boolean end - it "wraps a boolean true" do + it 'wraps a boolean true' do gv = GObject::Value.wrap_ruby_value true assert_instance_of GObject::Value, gv assert_equal true, gv.get_boolean end - it "wraps an Integer" do + it 'wraps an Integer' do gv = GObject::Value.wrap_ruby_value 42 assert_equal 42, gv.get_int end - it "wraps a String" do - gv = GObject::Value.wrap_ruby_value "Some Random String" - assert_equal "Some Random String", gv.get_string + it 'wraps a String' do + gv = GObject::Value.wrap_ruby_value 'Some Random String' + assert_equal 'Some Random String', gv.get_string end end - describe "#set_value" do - it "handles char values" do + describe '#set_value' do + it 'handles char values' do value = 83 gv = GObject::Value.for_g_type GObject::TYPE_CHAR gv.set_value value gv.get_char.must_equal value end - it "handles GType values" do + it 'handles GType values' do value = GObject::TYPE_STRING gv = GObject::Value.for_g_type GObject::TYPE_GTYPE gv.set_value value gv.get_gtype.must_equal value end - it "handles int64 values" do + it 'handles int64 values' do value = 0x1234_5678_9012_3456 gv = GObject::Value.for_g_type GObject::TYPE_INT64 gv.set_value value gv.get_int64.must_equal value end - it "handles long values" do + it 'handles long values' do value = FFI.type_size(:long) == 8 ? 0x1234_5678_9012_3456 : 0x1234_5678 gv = GObject::Value.for_g_type GObject::TYPE_LONG gv.set_value value gv.get_long.must_equal value end - it "handles uchar values" do + it 'handles uchar values' do value = 83 gv = GObject::Value.for_g_type GObject::TYPE_UCHAR gv.set_value value gv.get_uchar.must_equal value end - it "handles uint values" do + it 'handles uint values' do value = 0x1234_5678 gv = GObject::Value.for_g_type GObject::TYPE_UINT gv.set_value value gv.get_uint.must_equal value end - it "handles uint64 values" do + it 'handles uint64 values' do value = 0x1234_5678_9012_3456 gv = GObject::Value.for_g_type GObject::TYPE_UINT64 gv.set_value value gv.get_uint64.must_equal value end - it "handles ulong values" do + it 'handles ulong values' do value = FFI.type_size(:long) == 8 ? 0x1234_5678_9012_3456 : 0x1234_5678 gv = GObject::Value.for_g_type GObject::TYPE_ULONG gv.set_value value gv.get_ulong.must_equal value end - it "handles variant values" do - value = GLib::Variant.new_string("Foo") + it 'handles variant values' do + value = GLib::Variant.new_string('Foo') gv = GObject::Value.for_g_type GObject::TYPE_VARIANT gv.set_value value gv.get_variant.must_equal value @@ -108,108 +108,108 @@ end - describe "#get_value" do - it "unwraps a boolean false" do + describe '#get_value' do + it 'unwraps a boolean false' do gv = GObject::Value.wrap_ruby_value false result = gv.get_value assert_equal false, result end - it "unwraps a boolean true" do + it 'unwraps a boolean true' do gv = GObject::Value.wrap_ruby_value true result = gv.get_value assert_equal true, result end - it "unwraps a char" do + it 'unwraps a char' do value = 3 gv = GObject::Value.for_g_type GObject::TYPE_CHAR gv.set_char value gv.get_value.must_equal value end - it "unwraps an enum value" do + it 'unwraps an enum value' do value = :value2 gv = GObject::Value.for_g_type Regress::TestEnum.get_gtype gv.set_enum Regress::TestEnum[value] gv.get_value.must_equal value end - it "unwraps a flags value" do + it 'unwraps a flags value' do value = Regress::TestFlags[:flag1] | Regress::TestFlags[:flag3] gv = GObject::Value.for_g_type Regress::TestFlags.get_gtype gv.set_flags value gv.get_value.must_equal value end - it "unwraps a GType" do + it 'unwraps a GType' do value = GObject::TYPE_STRING gv = GObject::Value.for_g_type GObject::TYPE_GTYPE gv.set_gtype value gv.get_value.must_equal value end - it "unwraps an int64" do + it 'unwraps an int64' do value = 0x1234_5678_9012_3456 gv = GObject::Value.for_g_type GObject::TYPE_INT64 gv.set_int64 value gv.get_value.must_equal value end - it "unwraps a long" do + it 'unwraps a long' do value = FFI.type_size(:long) == 8 ? 0x1234_5678_9012_3456 : 0x1234_5678 gv = GObject::Value.for_g_type GObject::TYPE_LONG gv.set_long value gv.get_value.must_equal value end - it "unwraps an uchar" do + it 'unwraps an uchar' do value = 3 gv = GObject::Value.for_g_type GObject::TYPE_UCHAR gv.set_uchar value gv.get_value.must_equal value end - it "unwraps an uint" do + it 'unwraps an uint' do value = 0x1234_5678 gv = GObject::Value.for_g_type GObject::TYPE_UINT gv.set_uint value gv.get_value.must_equal value end - it "unwraps an uint64" do + it 'unwraps an uint64' do value = 0x1234_5678_9012_3456 gv = GObject::Value.for_g_type GObject::TYPE_UINT64 gv.set_uint64 value gv.get_value.must_equal value end - it "unwraps a ulong" do + it 'unwraps a ulong' do value = FFI.type_size(:long) == 8 ? 0x1234_5678_9012_3456 : 0x1234_5678 gv = GObject::Value.for_g_type GObject::TYPE_ULONG gv.set_ulong value gv.get_value.must_equal value end - it "unwraps a variant" do - value = GLib::Variant.new_string("Foo") + it 'unwraps a variant' do + value = GLib::Variant.new_string('Foo') gv = GObject::Value.for_g_type GObject::TYPE_VARIANT gv.set_variant value gv.get_value.must_equal value end - it "works with a ByteArray" do - ba = GLib::ByteArray.new.append("some bytes") + it 'works with a ByteArray' do + ba = GLib::ByteArray.new.append('some bytes') v = GObject::Value.for_g_type GObject::TYPE_BYTE_ARRAY v.set_boxed ba result = v.get_value - result.to_string.must_equal "some bytes" + result.to_string.must_equal 'some bytes' result.must_be_kind_of GLib::ByteArray end - it "works with an Array" do + it 'works with an Array' do arr = GLib::Array.from(:uint, [1, 2, 3]) v = GObject::Value.for_g_type GObject::TYPE_ARRAY v.set_boxed arr @@ -221,37 +221,37 @@ end end - describe "::from" do - it "creates a gint GValue from a Ruby Integer" do + describe '::from' do + it 'creates a gint GValue from a Ruby Integer' do gv = GObject::Value.from 21 - gv.current_gtype_name.must_equal "gint" + gv.current_gtype_name.must_equal 'gint' gv.get_value.must_equal 21 end - it "returns its argument if given a GValue" do + it 'returns its argument if given a GValue' do gv = GObject::Value.from 21 gv2 = GObject::Value.from gv - gv2.current_gtype_name.must_equal "gint" + gv2.current_gtype_name.must_equal 'gint' gv2.get_value.must_equal 21 end end - describe "#set_value" do + describe '#set_value' do before do GirFFI.setup :GIMarshallingTests end - it "raises an error when setting an incompatible object type" do + it 'raises an error when setting an incompatible object type' do o = GIMarshallingTests::Object.new 1 v = GObject::Value.new.init(GIMarshallingTests::OverridesObject.get_gtype) proc { v.set_value o }.must_raise ArgumentError end - it "works with a ByteArray" do - ba = GLib::ByteArray.new.append("some bytes") - v = GObject::Value.new.init(GObject.type_from_name("GByteArray")) + it 'works with a ByteArray' do + ba = GLib::ByteArray.new.append('some bytes') + v = GObject::Value.new.init(GObject.type_from_name('GByteArray')) v.set_value ba - v.get_value.to_string.must_equal "some bytes" + v.get_value.to_string.must_equal 'some bytes' end end end diff --git a/test/ffi-gobject_introspection/i_base_info_test.rb b/test/ffi-gobject_introspection/i_base_info_test.rb index 687085242..18ebe8af8 100644 --- a/test/ffi-gobject_introspection/i_base_info_test.rb +++ b/test/ffi-gobject_introspection/i_base_info_test.rb @@ -2,37 +2,37 @@ describe GObjectIntrospection::IBaseInfo do let(:described_class) { GObjectIntrospection::IBaseInfo } - describe "#initialize" do - it "raises an error if a null pointer is passed" do + describe '#initialize' do + it 'raises an error if a null pointer is passed' do mock(ptr = Object.new).null? { true } proc { described_class.new ptr }.must_raise ArgumentError end - it "raises no error if a non-null pointer is passed" do + it 'raises no error if a non-null pointer is passed' do mock(ptr = Object.new).null? { false } described_class.new ptr pass end end - describe "#deprecated?" do + describe '#deprecated?' do let(:deprecated_info) { get_introspection_data 'Regress', 'test_versioning' } let(:other_info) { get_introspection_data 'Regress', 'test_value_return' } - it "returns true for a deprecated item" do + it 'returns true for a deprecated item' do skip unless deprecated_info deprecated_info.must_be :deprecated? end - it "returns false for a non-deprecated item" do + it 'returns false for a non-deprecated item' do other_info.wont_be :deprecated? end end - describe "upon garbage collection" do - it "calls g_base_info_unref" do + describe 'upon garbage collection' do + it 'calls g_base_info_unref' do if defined?(RUBY_ENGINE) && %w(jruby rbx).include?(RUBY_ENGINE) - skip "cannot be reliably tested on JRuby and Rubinius" + skip 'cannot be reliably tested on JRuby and Rubinius' end mock(ptr = Object.new).null? { false } diff --git a/test/ffi-gobject_introspection/i_constant_info_test.rb b/test/ffi-gobject_introspection/i_constant_info_test.rb index 5dcaae2d3..ceef36d1e 100644 --- a/test/ffi-gobject_introspection/i_constant_info_test.rb +++ b/test/ffi-gobject_introspection/i_constant_info_test.rb @@ -1,30 +1,30 @@ require 'introspection_test_helper' describe GObjectIntrospection::IConstantInfo do - describe "for GLib::USEC_PER_SEC, a constant of type :gint32" do + describe 'for GLib::USEC_PER_SEC, a constant of type :gint32' do let(:constant_info) { get_introspection_data 'GLib', 'USEC_PER_SEC' } - it "returns :gint32 as its type" do + it 'returns :gint32 as its type' do assert_equal :gint32, constant_info.constant_type.tag end - it "returns 1_000_000 as its value" do + it 'returns 1_000_000 as its value' do assert_equal 1_000_000, constant_info.value end end - describe "for GLib::SOURCE_CONTINUE, a constant of type :gboolean" do + describe 'for GLib::SOURCE_CONTINUE, a constant of type :gboolean' do let(:constant_info) { get_introspection_data 'GLib', 'SOURCE_CONTINUE' } before do skip unless constant_info end - it "returns :gboolean as its type" do + it 'returns :gboolean as its type' do assert_equal :gboolean, constant_info.constant_type.tag end - it "returns true as its value" do + it 'returns true as its value' do assert_equal true, constant_info.value end end diff --git a/test/ffi-gobject_introspection/i_enum_info_test.rb b/test/ffi-gobject_introspection/i_enum_info_test.rb index c200a85cf..04cd1da1a 100644 --- a/test/ffi-gobject_introspection/i_enum_info_test.rb +++ b/test/ffi-gobject_introspection/i_enum_info_test.rb @@ -1,16 +1,16 @@ require 'introspection_test_helper' describe GObjectIntrospection::IEnumInfo do - describe "#find_method" do + describe '#find_method' do before do gir = GObjectIntrospection::IRepository.default gir.require 'Regress', nil @info = gir.find_by_name 'Regress', 'TestEnum' end - it "finds a method by name" do - result = @info.find_method("param") - result.name.must_equal "param" + it 'finds a method by name' do + result = @info.find_method('param') + result.name.must_equal 'param' end end end diff --git a/test/ffi-gobject_introspection/i_object_info_test.rb b/test/ffi-gobject_introspection/i_object_info_test.rb index f027ebf61..cc6ebb813 100644 --- a/test/ffi-gobject_introspection/i_object_info_test.rb +++ b/test/ffi-gobject_introspection/i_object_info_test.rb @@ -3,14 +3,14 @@ describe GObjectIntrospection::IObjectInfo do let(:object_info) { get_introspection_data('GObject', 'Object') } - describe "#find_vfunc" do - it "finds a vfunc by name" do - object_info.find_vfunc("finalize").wont_be_nil + describe '#find_vfunc' do + it 'finds a vfunc by name' do + object_info.find_vfunc('finalize').wont_be_nil end end - describe "#type_name" do - it "returns the correct name" do + describe '#type_name' do + it 'returns the correct name' do object_info.type_name.must_equal 'GObject' end end diff --git a/test/ffi-gobject_introspection/i_registered_type_info_test.rb b/test/ffi-gobject_introspection/i_registered_type_info_test.rb index 6be3b73e6..1c0cc7e00 100644 --- a/test/ffi-gobject_introspection/i_registered_type_info_test.rb +++ b/test/ffi-gobject_introspection/i_registered_type_info_test.rb @@ -1,23 +1,23 @@ require 'introspection_test_helper' describe GObjectIntrospection::IRegisteredTypeInfo do - describe "#get_type_name" do - describe "for an interface" do + describe '#get_type_name' do + describe 'for an interface' do let(:registered_type_info) { get_introspection_data('GIMarshallingTests', 'Interface') } - it "returns interface name" do + it 'returns interface name' do registered_type_info.type_name.must_equal 'GIMarshallingTestsInterface' end end - describe "for a type that is not an interface" do + describe 'for a type that is not an interface' do let(:registered_type_info) { get_introspection_data('GIMarshallingTests', 'Enum') } - it "returns nil" do + it 'returns nil' do registered_type_info.type_name.must_be_nil end end diff --git a/test/ffi-gobject_introspection/i_repository_test.rb b/test/ffi-gobject_introspection/i_repository_test.rb index b98047880..4ed5ae562 100644 --- a/test/ffi-gobject_introspection/i_repository_test.rb +++ b/test/ffi-gobject_introspection/i_repository_test.rb @@ -1,19 +1,19 @@ require 'introspection_test_helper' describe GObjectIntrospection::IRepository do - describe "an instance" do - it "is not created by calling new()" do + describe 'an instance' do + it 'is not created by calling new()' do assert_raises NoMethodError do GObjectIntrospection::IRepository.new end end - it "is created by calling default()" do + it 'is created by calling default()' do gir = GObjectIntrospection::IRepository.default assert_kind_of GObjectIntrospection::IRepository, gir end - it "is a singleton" do + it 'is a singleton' do gir = GObjectIntrospection::IRepository.default gir2 = GObjectIntrospection::IRepository.default assert_equal gir, gir2 @@ -22,40 +22,40 @@ let(:gir) { GObjectIntrospection::IRepository.default } - describe "#require" do + describe '#require' do it "raises an error if the namespace doesn't exist" do assert_raises RuntimeError do gir.require 'VeryUnlikelyGObjectNamespaceName', nil end end - it "allows version to be nil" do + it 'allows version to be nil' do gir.require 'GObject', nil pass end - it "allows version to be left out" do + it 'allows version to be left out' do gir.require 'GObject' pass end end - describe "#find_by_gtype" do - it "raises an error if 0 is passed as the gtype" do + describe '#find_by_gtype' do + it 'raises an error if 0 is passed as the gtype' do proc { gir.find_by_gtype 0 }.must_raise ArgumentError end end - describe "#n_infos" do - it "yields more than one object for the GObject namespace" do - gir.require 'GObject', "2.0" + describe '#n_infos' do + it 'yields more than one object for the GObject namespace' do + gir.require 'GObject', '2.0' assert_operator gir.n_infos('GObject'), :>, 0 end end - describe "#info" do - it "yields IBaseInfo objects" do - gir.require 'GObject', "2.0" + describe '#info' do + it 'yields IBaseInfo objects' do + gir.require 'GObject', '2.0' assert_kind_of GObjectIntrospection::IBaseInfo, gir.info('GObject', 0) end end diff --git a/test/ffi-gobject_introspection/i_type_info_test.rb b/test/ffi-gobject_introspection/i_type_info_test.rb index 564f8a8dc..d8c87d3b4 100644 --- a/test/ffi-gobject_introspection/i_type_info_test.rb +++ b/test/ffi-gobject_introspection/i_type_info_test.rb @@ -1,13 +1,13 @@ require 'introspection_test_helper' describe GObjectIntrospection::ITypeInfo do - describe "#name?" do + describe '#name?' do let(:object_info) { get_introspection_data('GIMarshallingTests', 'Object') } let(:vfunc_info) { object_info.find_vfunc('vfunc_array_out_parameter') } let(:arg_info) { vfunc_info.args[0] } let(:type_info) { arg_info.argument_type } - it "raises an error" do + it 'raises an error' do skip unless vfunc_info proc { type_info.name @@ -16,12 +16,12 @@ end describe '#interface' do - describe "for unresolvable interface types" do + describe 'for unresolvable interface types' do let(:function_info) { get_introspection_data 'GObject', 'signal_set_va_marshaller' } let(:argument_info) { function_info.args.last } let(:type_info) { argument_info.argument_type } - it "returns an IUnresolvableInfo object" do + it 'returns an IUnresolvableInfo object' do result = type_info.interface result.info_type.must_equal :unresolved result.must_be_kind_of GObjectIntrospection::IUnresolvedInfo diff --git a/test/ffi-gobject_introspection/lib_test.rb b/test/ffi-gobject_introspection/lib_test.rb index ea71c778a..b9a9fe974 100644 --- a/test/ffi-gobject_introspection/lib_test.rb +++ b/test/ffi-gobject_introspection/lib_test.rb @@ -1,8 +1,8 @@ require 'introspection_test_helper' describe GObjectIntrospection::Lib::GIArgument do - describe "its member :v_ssize" do - it "is signed" do + describe 'its member :v_ssize' do + it 'is signed' do gia = GObjectIntrospection::Lib::GIArgument.new gia[:v_int64] = -1 assert_equal(-1, gia[:v_ssize]) diff --git a/test/ffi-gobject_test.rb b/test/ffi-gobject_test.rb index 7c4766390..8de3ecb69 100644 --- a/test/ffi-gobject_test.rb +++ b/test/ffi-gobject_test.rb @@ -5,28 +5,28 @@ GirFFI.setup :Regress end - describe "::signal_emit" do - it "emits a signal" do + describe '::signal_emit' do + it 'emits a signal' do a = 1 o = Regress::TestSubObj.new prc = proc { a = 2 } callback = GObject::Callback.from prc - ::GObject::Lib.g_signal_connect_data o, "test", callback, nil, nil, 0 - GObject.signal_emit o, "test" + ::GObject::Lib.g_signal_connect_data o, 'test', callback, nil, nil, 0 + GObject.signal_emit o, 'test' assert_equal 2, a end - it "handles return values" do + it 'handles return values' do s = Gio::SocketService.new argtypes = [:pointer, :pointer, :pointer, :pointer] callback = FFI::Function.new(:bool, argtypes) { |_a, _b, _c, _d| true } - ::GObject::Lib.g_signal_connect_data s, "incoming", callback, nil, nil, 0 - rv = GObject.signal_emit s, "incoming" + ::GObject::Lib.g_signal_connect_data s, 'incoming', callback, nil, nil, 0 + rv = GObject.signal_emit s, 'incoming' assert_equal true, rv.get_value end - it "passes in extra arguments" do + it 'passes in extra arguments' do o = Regress::TestSubObj.new sb = Regress::TestSimpleBoxedA.new sb.some_int8 = 31 @@ -38,82 +38,82 @@ callback = FFI::Function.new(:void, argtypes) do |_a, b, _c| b2 = b end - ::GObject::Lib.g_signal_connect_data o, "test-with-static-scope-arg", callback, nil, nil, 0 - GObject.signal_emit o, "test-with-static-scope-arg", sb + ::GObject::Lib.g_signal_connect_data o, 'test-with-static-scope-arg', callback, nil, nil, 0 + GObject.signal_emit o, 'test-with-static-scope-arg', sb sb2 = Regress::TestSimpleBoxedA.wrap b2 assert sb.equals(sb2) end - it "allows specifying signal detail" do + it 'allows specifying signal detail' do a = 1 o = Regress::TestSubObj.new callback = FFI::Function.new(:void, [:pointer, :pointer, :pointer]) { a = 2 } - ::GObject::Lib.g_signal_connect_data o, "notify::detail", callback, nil, nil, 0 + ::GObject::Lib.g_signal_connect_data o, 'notify::detail', callback, nil, nil, 0 - GObject.signal_emit o, "notify::detail" + GObject.signal_emit o, 'notify::detail' a.must_equal 2 end end - describe "::signal_connect" do - it "installs a signal handler" do + describe '::signal_connect' do + it 'installs a signal handler' do a = 1 o = Regress::TestSubObj.new - GObject.signal_connect(o, "test") { a = 2 } - GObject.signal_emit o, "test" + GObject.signal_connect(o, 'test') { a = 2 } + GObject.signal_emit o, 'test' assert_equal 2, a end - it "passes user data to handler" do + it 'passes user data to handler' do a = 1 o = Regress::TestSubObj.new - GObject.signal_connect(o, "test", 2) { |_i, d| a = d } - GObject.signal_emit o, "test" + GObject.signal_connect(o, 'test', 2) { |_i, d| a = d } + GObject.signal_emit o, 'test' assert_equal 2, a end - it "passes object to handler" do + it 'passes object to handler' do o = Regress::TestSubObj.new o2 = nil - GObject.signal_connect(o, "test") { |i, _d| o2 = i } - GObject.signal_emit o, "test" + GObject.signal_connect(o, 'test') { |i, _d| o2 = i } + GObject.signal_emit o, 'test' assert_instance_of Regress::TestSubObj, o2 assert_equal o.to_ptr, o2.to_ptr end - it "does not allow connecting an invalid signal" do + it 'does not allow connecting an invalid signal' do o = Regress::TestSubObj.new assert_raises RuntimeError do - GObject.signal_connect(o, "not-really-a-signal") {} + GObject.signal_connect(o, 'not-really-a-signal') {} end end - it "handles return values" do + it 'handles return values' do s = Gio::SocketService.new - GObject.signal_connect(s, "incoming") { true } - rv = GObject.signal_emit s, "incoming" + GObject.signal_connect(s, 'incoming') { true } + rv = GObject.signal_emit s, 'incoming' assert_equal true, rv.get_value end - it "requires a block" do + it 'requires a block' do o = Regress::TestSubObj.new assert_raises ArgumentError do - GObject.signal_connect o, "test" + GObject.signal_connect o, 'test' end end - it "allows specifying signal detail" do + it 'allows specifying signal detail' do a = 1 o = Regress::TestSubObj.new - GObject.signal_connect(o, "notify::detail", 2) { |_i, _, d| a = d } - GObject.signal_emit o, "notify::detail" + GObject.signal_connect(o, 'notify::detail', 2) { |_i, _, d| a = d } + GObject.signal_emit o, 'notify::detail' assert_equal 2, a end - describe "connecting a signal with extra arguments" do + describe 'connecting a signal with extra arguments' do before do @a = nil @b = 2 @@ -122,18 +122,18 @@ sb = Regress::TestSimpleBoxedA.new sb.some_int = 23 - GObject.signal_connect(o, "test-with-static-scope-arg", 2) { |_instance, object, user_data| + GObject.signal_connect(o, 'test-with-static-scope-arg', 2) { |_instance, object, user_data| @a = user_data @b = object } - GObject.signal_emit o, "test-with-static-scope-arg", sb + GObject.signal_emit o, 'test-with-static-scope-arg', sb end - it "passes on the user data argument" do + it 'passes on the user data argument' do assert_equal 2, @a end - it "passes on the extra arguments" do + it 'passes on the extra arguments' do assert_instance_of Regress::TestSimpleBoxedA, @b assert_equal 23, @b.some_int end diff --git a/test/gir_ffi-base/glib/boolean_test.rb b/test/gir_ffi-base/glib/boolean_test.rb index 9da6a1965..3edb4d74a 100644 --- a/test/gir_ffi-base/glib/boolean_test.rb +++ b/test/gir_ffi-base/glib/boolean_test.rb @@ -1,32 +1,32 @@ require 'gir_ffi_test_helper' describe GLib::Boolean do - it "has the same native size as an int" do + it 'has the same native size as an int' do FFI.type_size(GLib::Boolean).must_equal FFI.type_size :int end - describe ".from_native" do - it "converts 0 to false" do - GLib::Boolean.from_native(0, "whatever").must_equal false + describe '.from_native' do + it 'converts 0 to false' do + GLib::Boolean.from_native(0, 'whatever').must_equal false end - it "converts 1 to true" do - GLib::Boolean.from_native(1, "whatever").must_equal true + it 'converts 1 to true' do + GLib::Boolean.from_native(1, 'whatever').must_equal true end end - describe ".to_native" do - it "converts false to 0" do - GLib::Boolean.to_native(false, "whatever").must_equal 0 + describe '.to_native' do + it 'converts false to 0' do + GLib::Boolean.to_native(false, 'whatever').must_equal 0 end - it "converts true to 1" do - GLib::Boolean.to_native(true, "whatever").must_equal 1 + it 'converts true to 1' do + GLib::Boolean.to_native(true, 'whatever').must_equal 1 end end - describe ".size" do - it "returns the correct type size" do + describe '.size' do + it 'returns the correct type size' do GLib::Boolean.size.must_equal FFI.type_size :int end end diff --git a/test/gir_ffi-base/glib/strv_test.rb b/test/gir_ffi-base/glib/strv_test.rb index 55fab79a7..0b31bce12 100644 --- a/test/gir_ffi-base/glib/strv_test.rb +++ b/test/gir_ffi-base/glib/strv_test.rb @@ -1,21 +1,21 @@ require 'base_test_helper' describe GLib::Strv do - it "wraps a pointer" do + it 'wraps a pointer' do strv = GLib::Strv.new :some_pointer assert_equal :some_pointer, strv.to_ptr end - describe "::wrap" do - it "takes a pointer and returns a GLib::Strv wrapping it" do + describe '::wrap' do + it 'takes a pointer and returns a GLib::Strv wrapping it' do strv = GLib::Strv.wrap :some_pointer assert_instance_of GLib::Strv, strv assert_equal :some_pointer, strv.to_ptr end end - describe "#each" do - it "yields each string element" do + describe '#each' do + it 'yields each string element' do ary = %w(one two three) ptrs = ary.map { |a| FFI::MemoryPointer.from_string(a) } ptrs << nil @@ -30,7 +30,7 @@ assert_equal %w(one two three), arr end - it "yields zero times for a Strv wrapping a null pointer" do + it 'yields zero times for a Strv wrapping a null pointer' do strv = GLib::Strv.new FFI::Pointer.new(0) strv.each do |_str| flunk @@ -38,7 +38,7 @@ end end - it "includes Enumerable" do + it 'includes Enumerable' do GLib::Strv.must_include Enumerable end end diff --git a/test/gir_ffi/arg_helper_test.rb b/test/gir_ffi/arg_helper_test.rb index 84816bba2..c912d88ce 100644 --- a/test/gir_ffi/arg_helper_test.rb +++ b/test/gir_ffi/arg_helper_test.rb @@ -1,24 +1,24 @@ require 'gir_ffi_test_helper' describe GirFFI::ArgHelper do - describe ".cast_from_pointer" do - it "handles class types" do + describe '.cast_from_pointer' do + it 'handles class types' do klass = Class.new mock(klass).wrap(:pointer_value) { :wrapped_value } GirFFI::ArgHelper.cast_from_pointer(klass, :pointer_value).must_equal :wrapped_value end - it "handles negative :gint8" do + it 'handles negative :gint8' do ptr = FFI::Pointer.new(-127) GirFFI::ArgHelper.cast_from_pointer(:gint8, ptr).must_equal(-127) end - it "handles positive :gint8" do + it 'handles positive :gint8' do ptr = FFI::Pointer.new(128) GirFFI::ArgHelper.cast_from_pointer(:gint8, ptr).must_equal(128) end - it "handles :guint32" do + it 'handles :guint32' do ptr = FFI::Pointer.new(0xffffffff) GirFFI::ArgHelper.cast_from_pointer(:guint32, ptr).must_equal(0xffffffff) end diff --git a/test/gir_ffi/builder_test.rb b/test/gir_ffi/builder_test.rb index 7e9fbb9a3..f2809487c 100644 --- a/test/gir_ffi/builder_test.rb +++ b/test/gir_ffi/builder_test.rb @@ -6,7 +6,7 @@ let(:gir) { GObjectIntrospection::IRepository.default } describe '.build_class' do - it "does not replace existing classes" do + it 'does not replace existing classes' do oldclass = GObject::Object GirFFI::Builder.build_class get_introspection_data('GObject', 'Object') GObject::Object.must_equal oldclass @@ -15,44 +15,44 @@ describe '.attach_ffi_function' do let(:lib) { Module.new } - it "calls attach_function with the correct types for Regress.test_callback_destroy_notify" do + it 'calls attach_function with the correct types for Regress.test_callback_destroy_notify' do function_info = get_introspection_data 'Regress', 'test_callback_destroy_notify' mock(lib). - attach_function("regress_test_callback_destroy_notify", + attach_function('regress_test_callback_destroy_notify', [Regress::TestCallbackUserData, :pointer, GLib::DestroyNotify], :int32) { true } GirFFI::Builder.attach_ffi_function(lib, function_info) end - it "calls attach_function with the correct types for Regress::TestObj#torture_signature_0" do + it 'calls attach_function with the correct types for Regress::TestObj#torture_signature_0' do info = get_method_introspection_data 'Regress', 'TestObj', 'torture_signature_0' mock(lib). - attach_function("regress_test_obj_torture_signature_0", + attach_function('regress_test_obj_torture_signature_0', [:pointer, :int32, :pointer, :pointer, :pointer, :pointer, :uint32], :void) { true } GirFFI::Builder.attach_ffi_function(lib, info) end - it "calls attach_function with the correct types for Regress::TestObj#instance_method" do + it 'calls attach_function with the correct types for Regress::TestObj#instance_method' do info = get_method_introspection_data 'Regress', 'TestObj', 'instance_method' - mock(lib).attach_function("regress_test_obj_instance_method", + mock(lib).attach_function('regress_test_obj_instance_method', [:pointer], :int32) { true } GirFFI::Builder.attach_ffi_function(lib, info) end - it "calls attach_function with the correct types for Regress.test_array_gint32_in" do + it 'calls attach_function with the correct types for Regress.test_array_gint32_in' do info = get_introspection_data 'Regress', 'test_array_gint32_in' - mock(lib).attach_function("regress_test_array_gint32_in", + mock(lib).attach_function('regress_test_array_gint32_in', [:int32, :pointer], :int32) { true } GirFFI::Builder.attach_ffi_function(lib, info) end end - describe "looking at Regress.test_callback_destroy_notify" do + describe 'looking at Regress.test_callback_destroy_notify' do before do save_module :GObject save_module :Regress @@ -61,7 +61,7 @@ @go = get_introspection_data 'Regress', 'test_callback_destroy_notify' end - it "defines ffi callback types :Callback and :ClosureNotify" do + it 'defines ffi callback types :Callback and :ClosureNotify' do Regress.setup_method 'test_callback_destroy_notify' tcud = Regress::Lib.find_type :TestCallbackUserData dn = GLib::Lib.find_type :DestroyNotify @@ -78,39 +78,39 @@ end end - describe "building Regress::TestBoxed" do + describe 'building Regress::TestBoxed' do before do GirFFI::Builder.build_class get_introspection_data('Regress', 'TestBoxed') end - it "sets up #wrap" do - assert Regress::TestBoxed.respond_to? "wrap" + it 'sets up #wrap' do + assert Regress::TestBoxed.respond_to? 'wrap' end - it "sets up #allocate" do - assert Regress::TestBoxed.respond_to? "allocate" + it 'sets up #allocate' do + assert Regress::TestBoxed.respond_to? 'allocate' end end - describe "built Regress module" do + describe 'built Regress module' do before do save_module :Regress GirFFI::Builder.build_module 'Regress' end - it "autocreates singleton methods" do + it 'autocreates singleton methods' do refute_defines_singleton_method Regress, :test_uint Regress.test_uint 31 assert_defines_singleton_method Regress, :test_uint end - it "autocreates the TestObj class on first access" do + it 'autocreates the TestObj class on first access' do assert !Regress.const_defined?(:TestObj) Regress::TestObj.must_be_instance_of Class assert Regress.const_defined? :TestObj end - it "knows its own module builder" do + it 'knows its own module builder' do Regress.gir_ffi_builder.must_be_instance_of GirFFI::Builders::ModuleBuilder end @@ -119,35 +119,35 @@ end end - describe "having built Regress::TestObj" do + describe 'having built Regress::TestObj' do before do GirFFI::Builder.build_class get_introspection_data('Regress', 'TestObj') end - it "C functions for called instance methods get attached to Regress::Lib" do - o = Regress::TestObj.new_from_file("foo") + it 'C functions for called instance methods get attached to Regress::Lib' do + o = Regress::TestObj.new_from_file('foo') o.instance_method Regress::Lib.must_respond_to :regress_test_obj_instance_method end - it "the built class knows its own GIR info" do + it 'the built class knows its own GIR info' do Regress::TestObj.gir_info.name.must_equal 'TestObj' end - it "the built class knows its own class builder" do + it 'the built class knows its own class builder' do Regress::TestObj.gir_ffi_builder.must_be_instance_of GirFFI::Builders::ObjectBuilder end end - describe "built Regress::TestSubObj" do - it "inherits #set_bare from its superclass" do + describe 'built Regress::TestSubObj' do + it 'inherits #set_bare from its superclass' do o1 = Regress::TestSubObj.new o1.set_bare(nil) pass end - it "overrides #instance_method" do - obj = Regress::TestObj.new_from_file("foo") + it 'overrides #instance_method' do + obj = Regress::TestObj.new_from_file('foo') subobj = Regress::TestSubObj.new obj.instance_method.must_equal(-1) @@ -155,30 +155,30 @@ end end - describe "building Regress::TestSubObj" do + describe 'building Regress::TestSubObj' do before do save_module :Regress GirFFI::Builder.build_class get_introspection_data('Regress', 'TestSubObj') end - it "sets up the Regress namespace" do + it 'sets up the Regress namespace' do assert Regress.const_defined? :Lib assert Regress.respond_to? :gir_ffi_builder assert Regress.const_defined? :GIR_FFI_BUILDER end - it "creates the Regress::Lib module ready to attach functions from the shared library" do + it 'creates the Regress::Lib module ready to attach functions from the shared library' do expected = [gir.shared_library('Regress')] assert_equal expected, Regress::Lib.ffi_libraries.map(&:name) end - it "builds parent classes also" do + it 'builds parent classes also' do assert Regress.const_defined? :TestObj assert Object.const_defined? :GObject assert GObject.const_defined? :Object end - it "sets up the inheritance chain" do + it 'sets up the inheritance chain' do ancestors = Regress::TestSubObj.ancestors assert_equal [ Regress::TestSubObj, @@ -187,7 +187,7 @@ ], ancestors[0..2] end - it "creates a Regress::TestSubObj#to_ptr method" do + it 'creates a Regress::TestSubObj#to_ptr method' do assert Regress::TestSubObj.public_method_defined? :to_ptr end @@ -196,25 +196,25 @@ end end - describe "building Regress" do + describe 'building Regress' do before do save_module :Regress GirFFI::Builder.build_module 'Regress' end - it "creates a Lib module ready to attach functions from the shared library" do + it 'creates a Lib module ready to attach functions from the shared library' do gir = GObjectIntrospection::IRepository.default expected = [gir.shared_library('Regress')] assert_equal expected, Regress::Lib.ffi_libraries.map(&:name) end - it "does not replace existing module" do + it 'does not replace existing module' do oldmodule = Regress GirFFI::Builder.build_module 'Regress' assert_equal oldmodule, Regress end - it "does not replace existing Lib module" do + it 'does not replace existing Lib module' do oldmodule = Regress::Lib GirFFI::Builder.build_module 'Regress' assert_equal oldmodule, Regress::Lib diff --git a/test/gir_ffi/builders/argument_builder_test.rb b/test/gir_ffi/builders/argument_builder_test.rb index 101011506..cfa969a8e 100644 --- a/test/gir_ffi/builders/argument_builder_test.rb +++ b/test/gir_ffi/builders/argument_builder_test.rb @@ -4,176 +4,176 @@ let(:var_gen) { GirFFI::VariableNameGenerator.new } let(:builder) { GirFFI::Builders::ArgumentBuilder.new(var_gen, arg_info) } - describe "for an argument with direction :in" do - describe "for :callback" do + describe 'for an argument with direction :in' do + describe 'for :callback' do let(:arg_info) { get_introspection_data('Regress', 'test_callback_destroy_notify').args[0] } - it "has the correct value for #pre_conversion" do - builder.pre_conversion.must_equal ["_v1 = Regress::TestCallbackUserData.from(callback)"] + it 'has the correct value for #pre_conversion' do + builder.pre_conversion.must_equal ['_v1 = Regress::TestCallbackUserData.from(callback)'] end - it "has the correct value for #post_conversion" do + it 'has the correct value for #post_conversion' do builder.post_conversion.must_equal [] end end - describe "for :zero_terminated" do + describe 'for :zero_terminated' do let(:arg_info) { - get_introspection_data("GIMarshallingTests", - "array_in_len_zero_terminated").args[0] + get_introspection_data('GIMarshallingTests', + 'array_in_len_zero_terminated').args[0] } - it "has the correct value for #pre_conversion" do - builder.pre_conversion.must_equal ["_v1 = GirFFI::ZeroTerminated.from(:gint32, ints)"] + it 'has the correct value for #pre_conversion' do + builder.pre_conversion.must_equal ['_v1 = GirFFI::ZeroTerminated.from(:gint32, ints)'] end - it "has the correct value for #post_conversion" do + it 'has the correct value for #post_conversion' do builder.post_conversion.must_equal [] end end - describe "for :void" do - let(:arg_info) { get_introspection_data("Regress", "test_callback_user_data").args[1] } + describe 'for :void' do + let(:arg_info) { get_introspection_data('Regress', 'test_callback_user_data').args[1] } - describe "when it is a regular argument" do + describe 'when it is a regular argument' do before do builder.closure = false end - it "has the correct value for #pre_conversion" do - builder.pre_conversion.must_equal ["_v1 = GirFFI::InPointer.from(:void, user_data)"] + it 'has the correct value for #pre_conversion' do + builder.pre_conversion.must_equal ['_v1 = GirFFI::InPointer.from(:void, user_data)'] end - it "has the correct value for #post_conversion" do + it 'has the correct value for #post_conversion' do builder.post_conversion.must_equal [] end end - describe "when it is a closure" do + describe 'when it is a closure' do before do builder.closure = true end - it "has the correct value for #pre_conversion" do - builder.pre_conversion.must_equal ["_v1 = GirFFI::InPointer.from_closure_data(user_data)"] + it 'has the correct value for #pre_conversion' do + builder.pre_conversion.must_equal ['_v1 = GirFFI::InPointer.from_closure_data(user_data)'] end - it "has the correct value for #post_conversion" do + it 'has the correct value for #post_conversion' do builder.post_conversion.must_equal [] end end end end - describe "for an argument with direction :out" do - describe "for :enum" do - let(:arg_info) { get_introspection_data("GIMarshallingTests", "genum_out").args[0] } + describe 'for an argument with direction :out' do + describe 'for :enum' do + let(:arg_info) { get_introspection_data('GIMarshallingTests', 'genum_out').args[0] } - it "has the correct value for #pre_conversion" do - builder.pre_conversion.must_equal ["_v1 = GirFFI::InOutPointer.for GIMarshallingTests::GEnum"] + it 'has the correct value for #pre_conversion' do + builder.pre_conversion.must_equal ['_v1 = GirFFI::InOutPointer.for GIMarshallingTests::GEnum'] end - it "has the correct value for #post_conversion" do - builder.post_conversion.must_equal ["_v2 = _v1.to_value"] + it 'has the correct value for #post_conversion' do + builder.post_conversion.must_equal ['_v2 = _v1.to_value'] end end - describe "for :flags" do + describe 'for :flags' do let(:arg_info) { - get_introspection_data("GIMarshallingTests", "flags_out").args[0] + get_introspection_data('GIMarshallingTests', 'flags_out').args[0] } - it "has the correct value for #pre_conversion" do - builder.pre_conversion.must_equal ["_v1 = GirFFI::InOutPointer.for GIMarshallingTests::Flags"] + it 'has the correct value for #pre_conversion' do + builder.pre_conversion.must_equal ['_v1 = GirFFI::InOutPointer.for GIMarshallingTests::Flags'] end - it "has the correct value for #post_conversion" do - builder.post_conversion.must_equal ["_v2 = _v1.to_value"] + it 'has the correct value for #post_conversion' do + builder.post_conversion.must_equal ['_v2 = _v1.to_value'] end end - describe "for :object" do + describe 'for :object' do let(:arg_info) { - get_method_introspection_data("Regress", "TestObj", "null_out").args[0] + get_method_introspection_data('Regress', 'TestObj', 'null_out').args[0] } - it "has the correct value for #pre_conversion" do - builder.pre_conversion.must_equal ["_v1 = GirFFI::InOutPointer.for [:pointer, Regress::TestObj]"] + it 'has the correct value for #pre_conversion' do + builder.pre_conversion.must_equal ['_v1 = GirFFI::InOutPointer.for [:pointer, Regress::TestObj]'] end - it "has the correct value for #post_conversion" do - builder.post_conversion.must_equal ["_v2 = Regress::TestObj.wrap(_v1.to_value)"] + it 'has the correct value for #post_conversion' do + builder.post_conversion.must_equal ['_v2 = Regress::TestObj.wrap(_v1.to_value)'] end end - describe "for :struct" do + describe 'for :struct' do - describe "when not allocated by the caller" do + describe 'when not allocated by the caller' do let(:arg_info) { - get_introspection_data("GIMarshallingTests", "boxed_struct_out").args[0] + get_introspection_data('GIMarshallingTests', 'boxed_struct_out').args[0] } - it "has the correct value for #pre_conversion" do + it 'has the correct value for #pre_conversion' do builder.pre_conversion.must_equal [ - "_v1 = GirFFI::InOutPointer.for [:pointer, GIMarshallingTests::BoxedStruct]" + '_v1 = GirFFI::InOutPointer.for [:pointer, GIMarshallingTests::BoxedStruct]' ] end - it "has the correct value for #post_conversion" do - builder.post_conversion.must_equal ["_v2 = GIMarshallingTests::BoxedStruct.wrap(_v1.to_value)"] + it 'has the correct value for #post_conversion' do + builder.post_conversion.must_equal ['_v2 = GIMarshallingTests::BoxedStruct.wrap(_v1.to_value)'] end end - describe "when allocated by the caller" do + describe 'when allocated by the caller' do let(:arg_info) { - get_method_introspection_data("Regress", "TestStructA", "clone").args[0] + get_method_introspection_data('Regress', 'TestStructA', 'clone').args[0] } - it "has the correct value for #pre_conversion" do - builder.pre_conversion.must_equal ["_v1 = Regress::TestStructA.new"] + it 'has the correct value for #pre_conversion' do + builder.pre_conversion.must_equal ['_v1 = Regress::TestStructA.new'] end - it "has empty #post_conversion" do + it 'has empty #post_conversion' do builder.post_conversion.must_equal [] end end end - describe "for :strv" do + describe 'for :strv' do let(:arg_info) { - get_introspection_data("GIMarshallingTests", "gstrv_out").args[0] + get_introspection_data('GIMarshallingTests', 'gstrv_out').args[0] } - it "has the correct value for #pre_conversion" do - builder.pre_conversion.must_equal ["_v1 = GirFFI::InOutPointer.for [:pointer, :strv]"] + it 'has the correct value for #pre_conversion' do + builder.pre_conversion.must_equal ['_v1 = GirFFI::InOutPointer.for [:pointer, :strv]'] end - it "has the correct value for #post_conversion" do - builder.post_conversion.must_equal ["_v2 = GLib::Strv.wrap(_v1.to_value)"] + it 'has the correct value for #post_conversion' do + builder.post_conversion.must_equal ['_v2 = GLib::Strv.wrap(_v1.to_value)'] end end - describe "for :array" do + describe 'for :array' do - describe "when allocated by the callee" do + describe 'when allocated by the callee' do let(:arg_info) { - get_introspection_data("GIMarshallingTests", "garray_utf8_none_out").args[0] + get_introspection_data('GIMarshallingTests', 'garray_utf8_none_out').args[0] } - it "has the correct value for #pre_conversion" do - builder.pre_conversion.must_equal ["_v1 = GirFFI::InOutPointer.for [:pointer, :array]"] + it 'has the correct value for #pre_conversion' do + builder.pre_conversion.must_equal ['_v1 = GirFFI::InOutPointer.for [:pointer, :array]'] end - it "has the correct value for #post_conversion" do - builder.post_conversion.must_equal ["_v2 = GLib::Array.wrap(:utf8, _v1.to_value)"] + it 'has the correct value for #post_conversion' do + builder.post_conversion.must_equal ['_v2 = GLib::Array.wrap(:utf8, _v1.to_value)'] end end - describe "when allocated by the caller" do + describe 'when allocated by the caller' do let(:function_info) { - get_introspection_data("GIMarshallingTests", "garray_utf8_full_out_caller_allocated") + get_introspection_data('GIMarshallingTests', 'garray_utf8_full_out_caller_allocated') } let(:arg_info) { function_info.args[0] } @@ -182,175 +182,175 @@ skip unless function_info end - it "has the correct value for #pre_conversion" do - builder.pre_conversion.must_equal ["_v1 = GLib::Array.new :utf8"] + it 'has the correct value for #pre_conversion' do + builder.pre_conversion.must_equal ['_v1 = GLib::Array.new :utf8'] end - it "has empty #post_conversion" do + it 'has empty #post_conversion' do builder.post_conversion.must_equal [] end end end - describe "for :ptr_array" do + describe 'for :ptr_array' do let(:arg_info) { - get_introspection_data("GIMarshallingTests", "gptrarray_utf8_none_out").args[0] + get_introspection_data('GIMarshallingTests', 'gptrarray_utf8_none_out').args[0] } - it "has the correct value for #pre_conversion" do - builder.pre_conversion.must_equal ["_v1 = GirFFI::InOutPointer.for [:pointer, :ptr_array]"] + it 'has the correct value for #pre_conversion' do + builder.pre_conversion.must_equal ['_v1 = GirFFI::InOutPointer.for [:pointer, :ptr_array]'] end - it "has the correct value for #post_conversion" do - builder.post_conversion.must_equal ["_v2 = GLib::PtrArray.wrap(:utf8, _v1.to_value)"] + it 'has the correct value for #post_conversion' do + builder.post_conversion.must_equal ['_v2 = GLib::PtrArray.wrap(:utf8, _v1.to_value)'] end end - describe "for :error" do + describe 'for :error' do let(:arg_info) { - get_introspection_data("GIMarshallingTests", "gerror_out").args[0] + get_introspection_data('GIMarshallingTests', 'gerror_out').args[0] } - it "has the correct value for #pre_conversion" do - builder.pre_conversion.must_equal ["_v1 = GirFFI::InOutPointer.for [:pointer, :error]"] + it 'has the correct value for #pre_conversion' do + builder.pre_conversion.must_equal ['_v1 = GirFFI::InOutPointer.for [:pointer, :error]'] end - it "has the correct value for #post_conversion" do - builder.post_conversion.must_equal ["_v2 = GLib::Error.wrap(_v1.to_value)"] + it 'has the correct value for #post_conversion' do + builder.post_conversion.must_equal ['_v2 = GLib::Error.wrap(_v1.to_value)'] end end - describe "for :c" do + describe 'for :c' do - describe "with fixed size" do + describe 'with fixed size' do let(:arg_info) { - get_introspection_data("GIMarshallingTests", "array_fixed_out").args[0] + get_introspection_data('GIMarshallingTests', 'array_fixed_out').args[0] } - it "has the correct value for #pre_conversion" do - builder.pre_conversion.must_equal ["_v1 = GirFFI::InOutPointer.for [:pointer, :c]"] + it 'has the correct value for #pre_conversion' do + builder.pre_conversion.must_equal ['_v1 = GirFFI::InOutPointer.for [:pointer, :c]'] end - it "has the correct value for #post_conversion" do - builder.post_conversion.must_equal ["_v2 = GirFFI::SizedArray.wrap(:gint32, 4, _v1.to_value)"] + it 'has the correct value for #post_conversion' do + builder.post_conversion.must_equal ['_v2 = GirFFI::SizedArray.wrap(:gint32, 4, _v1.to_value)'] end end - describe "with separate size parameter" do + describe 'with separate size parameter' do let(:arg_info) { - get_introspection_data("GIMarshallingTests", "array_out").args[0] + get_introspection_data('GIMarshallingTests', 'array_out').args[0] } let(:length_argument) { Object.new } before do - stub(length_argument).post_converted_name { "bar" } + stub(length_argument).post_converted_name { 'bar' } builder.length_arg = length_argument end - it "has the correct value for #pre_conversion" do - builder.pre_conversion.must_equal ["_v1 = GirFFI::InOutPointer.for [:pointer, :c]"] + it 'has the correct value for #pre_conversion' do + builder.pre_conversion.must_equal ['_v1 = GirFFI::InOutPointer.for [:pointer, :c]'] end - it "has the correct value for #post_conversion" do - builder.post_conversion.must_equal ["_v2 = GirFFI::SizedArray.wrap(:gint32, bar, _v1.to_value)"] + it 'has the correct value for #post_conversion' do + builder.post_conversion.must_equal ['_v2 = GirFFI::SizedArray.wrap(:gint32, bar, _v1.to_value)'] end end end - describe "for :glist" do + describe 'for :glist' do let(:arg_info) { - get_introspection_data("GIMarshallingTests", "glist_utf8_none_out").args[0] + get_introspection_data('GIMarshallingTests', 'glist_utf8_none_out').args[0] } - it "has the correct value for #pre_conversion" do - builder.pre_conversion.must_equal ["_v1 = GirFFI::InOutPointer.for [:pointer, :glist]"] + it 'has the correct value for #pre_conversion' do + builder.pre_conversion.must_equal ['_v1 = GirFFI::InOutPointer.for [:pointer, :glist]'] end - it "has the correct value for #post_conversion" do - builder.post_conversion.must_equal ["_v2 = GLib::List.wrap(:utf8, _v1.to_value)"] + it 'has the correct value for #post_conversion' do + builder.post_conversion.must_equal ['_v2 = GLib::List.wrap(:utf8, _v1.to_value)'] end end - describe "for :gslist" do + describe 'for :gslist' do let(:arg_info) { - get_introspection_data("GIMarshallingTests", "gslist_utf8_none_out").args[0] + get_introspection_data('GIMarshallingTests', 'gslist_utf8_none_out').args[0] } - it "has the correct value for #pre_conversion" do - builder.pre_conversion.must_equal ["_v1 = GirFFI::InOutPointer.for [:pointer, :gslist]"] + it 'has the correct value for #pre_conversion' do + builder.pre_conversion.must_equal ['_v1 = GirFFI::InOutPointer.for [:pointer, :gslist]'] end - it "has the correct value for #post_conversion" do - builder.post_conversion.must_equal ["_v2 = GLib::SList.wrap(:utf8, _v1.to_value)"] + it 'has the correct value for #post_conversion' do + builder.post_conversion.must_equal ['_v2 = GLib::SList.wrap(:utf8, _v1.to_value)'] end end - describe "for :ghash" do + describe 'for :ghash' do let(:arg_info) { - get_introspection_data("GIMarshallingTests", "ghashtable_utf8_none_out").args[0] + get_introspection_data('GIMarshallingTests', 'ghashtable_utf8_none_out').args[0] } - it "has the correct value for #pre_conversion" do - builder.pre_conversion.must_equal ["_v1 = GirFFI::InOutPointer.for [:pointer, [:ghash, :utf8, :utf8]]"] + it 'has the correct value for #pre_conversion' do + builder.pre_conversion.must_equal ['_v1 = GirFFI::InOutPointer.for [:pointer, [:ghash, :utf8, :utf8]]'] end - it "has the correct value for #post_conversion" do - builder.post_conversion.must_equal ["_v2 = GLib::HashTable.wrap([:utf8, :utf8], _v1.to_value)"] + it 'has the correct value for #post_conversion' do + builder.post_conversion.must_equal ['_v2 = GLib::HashTable.wrap([:utf8, :utf8], _v1.to_value)'] end end end - describe "for an argument with direction :inout" do - describe "for :enum" do + describe 'for an argument with direction :inout' do + describe 'for :enum' do let(:arg_info) { - get_introspection_data("GIMarshallingTests", "enum_inout").args[0] + get_introspection_data('GIMarshallingTests', 'enum_inout').args[0] } - it "has the correct value for #pre_conversion" do - builder.pre_conversion.must_equal ["_v1 = GirFFI::InOutPointer.for GIMarshallingTests::Enum", + it 'has the correct value for #pre_conversion' do + builder.pre_conversion.must_equal ['_v1 = GirFFI::InOutPointer.for GIMarshallingTests::Enum', "_v1.set_value #{arg_info.name}"] end - it "has the correct value for #post_conversion" do - builder.post_conversion.must_equal ["_v2 = _v1.to_value"] + it 'has the correct value for #post_conversion' do + builder.post_conversion.must_equal ['_v2 = _v1.to_value'] end end - describe "for :flags" do + describe 'for :flags' do let(:arg_info) { - get_introspection_data("GIMarshallingTests", "no_type_flags_inout").args[0] + get_introspection_data('GIMarshallingTests', 'no_type_flags_inout').args[0] } - it "has the correct value for #pre_conversion" do - builder.pre_conversion.must_equal ["_v1 = GirFFI::InOutPointer.for GIMarshallingTests::NoTypeFlags", + it 'has the correct value for #pre_conversion' do + builder.pre_conversion.must_equal ['_v1 = GirFFI::InOutPointer.for GIMarshallingTests::NoTypeFlags', "_v1.set_value #{arg_info.name}"] end - it "has the correct value for #post_conversion" do - builder.post_conversion.must_equal ["_v2 = _v1.to_value"] + it 'has the correct value for #post_conversion' do + builder.post_conversion.must_equal ['_v2 = _v1.to_value'] end end - describe "for :gint32" do + describe 'for :gint32' do let(:arg_info) { - get_introspection_data("GIMarshallingTests", "int32_inout_min_max").args[0] + get_introspection_data('GIMarshallingTests', 'int32_inout_min_max').args[0] } - it "has the correct value for method_argument_name" do + it 'has the correct value for method_argument_name' do builder.method_argument_name.must_equal "#{arg_info.name}" end - it "has the correct value for #pre_conversion" do - builder.pre_conversion.must_equal ["_v1 = GirFFI::InOutPointer.for :gint32", + it 'has the correct value for #pre_conversion' do + builder.pre_conversion.must_equal ['_v1 = GirFFI::InOutPointer.for :gint32', "_v1.set_value #{arg_info.name}"] end - it "has the correct value for #post_conversion" do - builder.post_conversion.must_equal ["_v2 = _v1.to_value"] + it 'has the correct value for #post_conversion' do + builder.post_conversion.must_equal ['_v2 = _v1.to_value'] end end - describe "for an array length" do + describe 'for an array length' do let(:function_info) { get_introspection_data('Regress', 'test_array_int_inout') } @@ -364,82 +364,82 @@ builder.array_arg = array_arg_builder end - it "has the correct value for #pre_conversion" do - builder.pre_conversion.must_equal ["n_ints = ints.nil? ? 0 : ints.length", - "_v1 = GirFFI::InOutPointer.for :gint32", - "_v1.set_value n_ints"] + it 'has the correct value for #pre_conversion' do + builder.pre_conversion.must_equal ['n_ints = ints.nil? ? 0 : ints.length', + '_v1 = GirFFI::InOutPointer.for :gint32', + '_v1.set_value n_ints'] end - it "has the correct value for #post_conversion" do - builder.post_conversion.must_equal ["_v2 = _v1.to_value"] + it 'has the correct value for #post_conversion' do + builder.post_conversion.must_equal ['_v2 = _v1.to_value'] end end - describe "for :strv" do + describe 'for :strv' do let(:arg_info) { - get_introspection_data("GIMarshallingTests", "gstrv_inout").args[0] + get_introspection_data('GIMarshallingTests', 'gstrv_inout').args[0] } - it "has the correct value for #pre_conversion" do - builder.pre_conversion.must_equal ["_v1 = GirFFI::InOutPointer.for [:pointer, :strv]", - "_v1.set_value GLib::Strv.from(g_strv)"] + it 'has the correct value for #pre_conversion' do + builder.pre_conversion.must_equal ['_v1 = GirFFI::InOutPointer.for [:pointer, :strv]', + '_v1.set_value GLib::Strv.from(g_strv)'] end - it "has the correct value for #post_conversion" do - builder.post_conversion.must_equal ["_v2 = GLib::Strv.wrap(_v1.to_value)"] + it 'has the correct value for #post_conversion' do + builder.post_conversion.must_equal ['_v2 = GLib::Strv.wrap(_v1.to_value)'] end end - describe "for :ptr_array" do + describe 'for :ptr_array' do let(:arg_info) { - get_introspection_data("GIMarshallingTests", "gptrarray_utf8_none_inout").args[0] + get_introspection_data('GIMarshallingTests', 'gptrarray_utf8_none_inout').args[0] } - it "has the correct value for #pre_conversion" do - builder.pre_conversion.must_equal ["_v1 = GirFFI::InOutPointer.for [:pointer, :ptr_array]", - "_v1.set_value GLib::PtrArray.from(:utf8, parray_)"] + it 'has the correct value for #pre_conversion' do + builder.pre_conversion.must_equal ['_v1 = GirFFI::InOutPointer.for [:pointer, :ptr_array]', + '_v1.set_value GLib::PtrArray.from(:utf8, parray_)'] end - it "has the correct value for #post_conversion" do - builder.post_conversion.must_equal ["_v2 = GLib::PtrArray.wrap(:utf8, _v1.to_value)"] + it 'has the correct value for #post_conversion' do + builder.post_conversion.must_equal ['_v2 = GLib::PtrArray.wrap(:utf8, _v1.to_value)'] end end - describe "for :utf8" do + describe 'for :utf8' do let(:arg_info) { - get_introspection_data("GIMarshallingTests", "utf8_none_inout").args[0] + get_introspection_data('GIMarshallingTests', 'utf8_none_inout').args[0] } - it "has the correct value for #pre_conversion" do - builder.pre_conversion.must_equal ["_v1 = GirFFI::InOutPointer.for :utf8", - "_v1.set_value GirFFI::InPointer.from(:utf8, utf8)"] + it 'has the correct value for #pre_conversion' do + builder.pre_conversion.must_equal ['_v1 = GirFFI::InOutPointer.for :utf8', + '_v1.set_value GirFFI::InPointer.from(:utf8, utf8)'] end - it "has the correct value for #post_conversion" do - builder.post_conversion.must_equal ["_v2 = _v1.to_value.to_utf8"] + it 'has the correct value for #post_conversion' do + builder.post_conversion.must_equal ['_v2 = _v1.to_value.to_utf8'] end end - describe "for :c" do - describe "with fixed size" do + describe 'for :c' do + describe 'with fixed size' do let(:arg_info) { - get_introspection_data("GIMarshallingTests", "array_fixed_inout").args[0] + get_introspection_data('GIMarshallingTests', 'array_fixed_inout').args[0] } - it "has the correct value for #pre_conversion" do + it 'has the correct value for #pre_conversion' do builder.pre_conversion.must_equal [ "GirFFI::ArgHelper.check_fixed_array_size 4, ints, \"ints\"", - "_v1 = GirFFI::InOutPointer.for [:pointer, :c]", - "_v1.set_value GirFFI::SizedArray.from(:gint32, 4, ints)" + '_v1 = GirFFI::InOutPointer.for [:pointer, :c]', + '_v1.set_value GirFFI::SizedArray.from(:gint32, 4, ints)' ] end - it "has the correct value for #post_conversion" do - builder.post_conversion.must_equal ["_v2 = GirFFI::SizedArray.wrap(:gint32, 4, _v1.to_value)"] + it 'has the correct value for #post_conversion' do + builder.post_conversion.must_equal ['_v2 = GirFFI::SizedArray.wrap(:gint32, 4, _v1.to_value)'] end end - describe "with separate size parameter" do + describe 'with separate size parameter' do let(:function_info) { get_introspection_data('Regress', 'test_array_int_inout') } @@ -453,71 +453,71 @@ builder.length_arg = length_arg_builder end - it "has the correct value for #pre_conversion" do + it 'has the correct value for #pre_conversion' do builder.pre_conversion.must_equal [ - "_v1 = GirFFI::InOutPointer.for [:pointer, :c]", - "_v1.set_value GirFFI::SizedArray.from(:gint32, -1, ints)" + '_v1 = GirFFI::InOutPointer.for [:pointer, :c]', + '_v1.set_value GirFFI::SizedArray.from(:gint32, -1, ints)' ] end - it "has the correct value for #post_conversion" do - builder.post_conversion.must_equal ["_v3 = GirFFI::SizedArray.wrap(:gint32, _v2, _v1.to_value)"] + it 'has the correct value for #post_conversion' do + builder.post_conversion.must_equal ['_v3 = GirFFI::SizedArray.wrap(:gint32, _v2, _v1.to_value)'] end end end end - describe "for a skipped argument with direction :in" do + describe 'for a skipped argument with direction :in' do let(:arg_info) { - get_method_introspection_data("Regress", "TestObj", "skip_param").args[2] + get_method_introspection_data('Regress', 'TestObj', 'skip_param').args[2] } - it "has the correct value for method_argument_name" do + it 'has the correct value for method_argument_name' do builder.method_argument_name.must_be_nil end - it "has the correct value for #pre_conversion" do - builder.pre_conversion.must_equal ["_v1 = 0"] + it 'has the correct value for #pre_conversion' do + builder.pre_conversion.must_equal ['_v1 = 0'] end - it "has the correct value for #post_conversion" do + it 'has the correct value for #post_conversion' do builder.post_conversion.must_equal [] end end - describe "for a skipped argument with direction :inout" do + describe 'for a skipped argument with direction :inout' do let(:arg_info) { - get_method_introspection_data("Regress", "TestObj", "skip_inout_param").args[3] + get_method_introspection_data('Regress', 'TestObj', 'skip_inout_param').args[3] } - it "has the correct value for method_argument_name" do + it 'has the correct value for method_argument_name' do builder.method_argument_name.must_be_nil end - it "has the correct value for #pre_conversion" do - builder.pre_conversion.must_equal ["_v1 = GirFFI::InOutPointer.for :gint32", - "_v1.set_value 0"] + it 'has the correct value for #pre_conversion' do + builder.pre_conversion.must_equal ['_v1 = GirFFI::InOutPointer.for :gint32', + '_v1.set_value 0'] end - it "has the correct value for #post_conversion" do + it 'has the correct value for #post_conversion' do builder.post_conversion.must_equal [] end end - describe "for a skipped argument with direction :out" do + describe 'for a skipped argument with direction :out' do let(:arg_info) { - get_method_introspection_data("Regress", "TestObj", "skip_out_param").args[1] + get_method_introspection_data('Regress', 'TestObj', 'skip_out_param').args[1] } - it "has the correct value for method_argument_name" do + it 'has the correct value for method_argument_name' do builder.method_argument_name.must_be_nil end - it "has the correct value for #pre_conversion" do - builder.pre_conversion.must_equal ["_v1 = GirFFI::InOutPointer.for :gint32"] + it 'has the correct value for #pre_conversion' do + builder.pre_conversion.must_equal ['_v1 = GirFFI::InOutPointer.for :gint32'] end - it "has the correct value for #post_conversion" do + it 'has the correct value for #post_conversion' do builder.post_conversion.must_equal [] end end diff --git a/test/gir_ffi/builders/callback_argument_builder_test.rb b/test/gir_ffi/builders/callback_argument_builder_test.rb index 258b842e7..b5288054d 100644 --- a/test/gir_ffi/builders/callback_argument_builder_test.rb +++ b/test/gir_ffi/builders/callback_argument_builder_test.rb @@ -4,8 +4,8 @@ let(:var_gen) { GirFFI::VariableNameGenerator.new } let(:builder) { GirFFI::Builders::CallbackArgumentBuilder.new(var_gen, arg_info) } - describe "for an argument with direction :out" do - describe "for :zero_terminated" do + describe 'for an argument with direction :out' do + describe 'for :zero_terminated' do let(:vfunc_info) { get_vfunc_introspection_data('GIMarshallingTests', 'Object', 'vfunc_array_out_parameter') @@ -14,39 +14,39 @@ before { skip unless vfunc_info } - it "has the correct value for #pre_conversion" do - builder.pre_conversion.must_equal ["_v1 = GirFFI::InOutPointer.new([:pointer, :zero_terminated], a)"] + it 'has the correct value for #pre_conversion' do + builder.pre_conversion.must_equal ['_v1 = GirFFI::InOutPointer.new([:pointer, :zero_terminated], a)'] end - it "has the correct value for #post_conversion" do - builder.post_conversion.must_equal ["_v1.set_value GirFFI::ZeroTerminated.from(:gfloat, _v2)"] + it 'has the correct value for #post_conversion' do + builder.post_conversion.must_equal ['_v1.set_value GirFFI::ZeroTerminated.from(:gfloat, _v2)'] end end end - describe "for an argument with direction :error" do + describe 'for an argument with direction :error' do let(:arg_info) { GirFFI::ErrorArgumentInfo.new } - it "sets up a rescueing block in #pre_conversion" do + it 'sets up a rescueing block in #pre_conversion' do builder.pre_conversion.must_equal [ - "_v1 = GirFFI::InOutPointer.new([:pointer, :error], _error)", - "begin" + '_v1 = GirFFI::InOutPointer.new([:pointer, :error], _error)', + 'begin' ] end - it "converts any exceptions to GLib::Error in #post_conversion" do + it 'converts any exceptions to GLib::Error in #post_conversion' do builder.post_conversion.must_equal [ - "rescue => _v1", - "_v2.set_value GLib::Error.from(_v1)", - "end" + 'rescue => _v1', + '_v2.set_value GLib::Error.from(_v1)', + 'end' ] end end - describe "for an argument with direction :inout" do + describe 'for an argument with direction :inout' do let(:callback_info) { - get_introspection_data("Regress", - "TestCallbackArrayInOut") + get_introspection_data('Regress', + 'TestCallbackArrayInOut') } let(:array_arg_info) { callback_info.args[0] } let(:array_arg_builder) { @@ -63,47 +63,47 @@ array_arg_builder.length_arg = length_arg_builder end - describe "for arrays with a length argument" do - it "provides a call argument name" do - array_arg_builder.call_argument_name.must_equal "_v1" + describe 'for arrays with a length argument' do + it 'provides a call argument name' do + array_arg_builder.call_argument_name.must_equal '_v1' end - it "provides a capture variable name" do - array_arg_builder.capture_variable_name.must_equal "_v1" + it 'provides a capture variable name' do + array_arg_builder.capture_variable_name.must_equal '_v1' end - it "has the correct value for #pre_conversion" do + it 'has the correct value for #pre_conversion' do array_arg_builder.pre_conversion. - must_equal ["_v1 = GirFFI::InOutPointer.new([:pointer, :c], ints)", - "_v2 = GirFFI::SizedArray.wrap(:gint32, _v3, _v1.to_value)"] + must_equal ['_v1 = GirFFI::InOutPointer.new([:pointer, :c], ints)', + '_v2 = GirFFI::SizedArray.wrap(:gint32, _v3, _v1.to_value)'] end - it "has the correct value for #post_conversion" do + it 'has the correct value for #post_conversion' do array_arg_builder.pre_conversion array_arg_builder.post_conversion. - must_equal ["_v1.set_value GirFFI::SizedArray.from(:gint32, -1, _v4)"] + must_equal ['_v1.set_value GirFFI::SizedArray.from(:gint32, -1, _v4)'] end end - describe "for an array length argument" do - it "does not provide a call argument name" do + describe 'for an array length argument' do + it 'does not provide a call argument name' do length_arg_builder.call_argument_name.must_be_nil end - it "does not provide a capture variable name" do + it 'does not provide a capture variable name' do length_arg_builder.capture_variable_name.must_be_nil end - it "has the correct value for #pre_conversion" do + it 'has the correct value for #pre_conversion' do length_arg_builder.pre_conversion. - must_equal ["_v1 = GirFFI::InOutPointer.new(:gint32, length)", - "_v2 = _v1.to_value"] + must_equal ['_v1 = GirFFI::InOutPointer.new(:gint32, length)', + '_v2 = _v1.to_value'] end - it "has the correct value for #post_conversion" do + it 'has the correct value for #post_conversion' do length_arg_builder.pre_conversion length_arg_builder.post_conversion. - must_equal ["_v1.set_value _v3.length"] + must_equal ['_v1.set_value _v3.length'] end end end diff --git a/test/gir_ffi/builders/callback_builder_test.rb b/test/gir_ffi/builders/callback_builder_test.rb index f3ee650a5..87bbacc28 100644 --- a/test/gir_ffi/builders/callback_builder_test.rb +++ b/test/gir_ffi/builders/callback_builder_test.rb @@ -3,10 +3,10 @@ describe GirFFI::Builders::CallbackBuilder do let(:builder) { GirFFI::Builders::CallbackBuilder.new callback_info } - describe "#mapping_method_definition" do - describe "for a callback with arguments and return value" do - let(:callback_info) { get_introspection_data "Regress", "TestCallbackFull" } - it "returns a valid mapping method" do + describe '#mapping_method_definition' do + describe 'for a callback with arguments and return value' do + let(:callback_info) { get_introspection_data 'Regress', 'TestCallbackFull' } + it 'returns a valid mapping method' do expected = <<-CODE.reset_indentation def self.call_with_argument_mapping(_proc, foo, bar, path) _v1 = foo @@ -21,9 +21,9 @@ def self.call_with_argument_mapping(_proc, foo, bar, path) end end - describe "for a callback with no arguments or return value" do - let(:callback_info) { get_introspection_data "Regress", "TestSimpleCallback" } - it "returns a valid mapping method" do + describe 'for a callback with no arguments or return value' do + let(:callback_info) { get_introspection_data 'Regress', 'TestSimpleCallback' } + it 'returns a valid mapping method' do expected = <<-CODE.reset_indentation def self.call_with_argument_mapping(_proc) _proc.call() @@ -34,9 +34,9 @@ def self.call_with_argument_mapping(_proc) end end - describe "for a callback with a closure argument" do - let(:callback_info) { get_introspection_data "Regress", "TestCallbackUserData" } - it "returns a valid mapping method" do + describe 'for a callback with a closure argument' do + let(:callback_info) { get_introspection_data 'Regress', 'TestCallbackUserData' } + it 'returns a valid mapping method' do expected = <<-CODE.reset_indentation def self.call_with_argument_mapping(_proc, user_data) _v1 = GirFFI::ArgHelper::OBJECT_STORE.fetch(user_data) @@ -49,12 +49,12 @@ def self.call_with_argument_mapping(_proc, user_data) end end - describe "for a callback with one out argument" do + describe 'for a callback with one out argument' do let(:callback_info) { - get_introspection_data("GIMarshallingTests", - "CallbackOneOutParameter") + get_introspection_data('GIMarshallingTests', + 'CallbackOneOutParameter') } - it "returns a valid mapping method" do + it 'returns a valid mapping method' do expected = <<-CODE.reset_indentation def self.call_with_argument_mapping(_proc, a) _v1 = GirFFI::InOutPointer.new(:gfloat, a) @@ -67,12 +67,12 @@ def self.call_with_argument_mapping(_proc, a) end end - describe "for a callback with an inout array argument" do + describe 'for a callback with an inout array argument' do let(:callback_info) { - get_introspection_data("Regress", - "TestCallbackArrayInOut") + get_introspection_data('Regress', + 'TestCallbackArrayInOut') } - it "returns a valid mapping method" do + it 'returns a valid mapping method' do skip unless callback_info expected = <<-CODE.reset_indentation def self.call_with_argument_mapping(_proc, ints, length) diff --git a/test/gir_ffi/builders/callback_return_value_builder_test.rb b/test/gir_ffi/builders/callback_return_value_builder_test.rb index 7b6daea88..a37e771b2 100644 --- a/test/gir_ffi/builders/callback_return_value_builder_test.rb +++ b/test/gir_ffi/builders/callback_return_value_builder_test.rb @@ -13,70 +13,70 @@ skip unless callback_info end - describe "for :gint32" do - let(:callback_info) { get_introspection_data("GIMarshallingTests", "CallbackIntInt") } + describe 'for :gint32' do + let(:callback_info) { get_introspection_data('GIMarshallingTests', 'CallbackIntInt') } - it "has no statements in #post_conversion" do + it 'has no statements in #post_conversion' do builder.post_conversion.must_equal [] end - it "returns the result of the callback directly" do - builder.capture_variable_name.must_equal "_v1" - builder.return_value_name.must_equal "_v1" + it 'returns the result of the callback directly' do + builder.capture_variable_name.must_equal '_v1' + builder.return_value_name.must_equal '_v1' end end - describe "for :void" do + describe 'for :void' do let(:callback_info) { - get_introspection_data("GIMarshallingTests", - "CallbackMultipleOutParameters") + get_introspection_data('GIMarshallingTests', + 'CallbackMultipleOutParameters') } - it "has no statements in #post_conversion" do + it 'has no statements in #post_conversion' do builder.post_conversion.must_equal [] end - it "returns nothing" do + it 'returns nothing' do builder.capture_variable_name.must_be_nil builder.return_value_name.must_be_nil end end - describe "for :enum" do + describe 'for :enum' do let(:callback_info) { - get_vfunc_introspection_data("GIMarshallingTests", - "Object", - "vfunc_return_enum") + get_vfunc_introspection_data('GIMarshallingTests', + 'Object', + 'vfunc_return_enum') } - it "converts the result" do + it 'converts the result' do # Ensure variable names are generated in order - builder.capture_variable_name.must_equal "_v1" - builder.post_conversion.must_equal ["_v2 = GIMarshallingTests::Enum.from(_v1)"] + builder.capture_variable_name.must_equal '_v1' + builder.post_conversion.must_equal ['_v2 = GIMarshallingTests::Enum.from(_v1)'] end - it "returns the result of the conversion" do - builder.capture_variable_name.must_equal "_v1" - builder.return_value_name.must_equal "_v2" + it 'returns the result of the conversion' do + builder.capture_variable_name.must_equal '_v1' + builder.return_value_name.must_equal '_v2' end end - describe "for :object" do + describe 'for :object' do let(:callback_info) { - get_vfunc_introspection_data("GIMarshallingTests", - "Object", - "vfunc_return_object_transfer_full") + get_vfunc_introspection_data('GIMarshallingTests', + 'Object', + 'vfunc_return_object_transfer_full') } - it "converts the result to a pointer" do + it 'converts the result to a pointer' do # Ensure variable names are generated in order - builder.capture_variable_name.must_equal "_v1" - builder.post_conversion.must_equal ["_v2 = GObject::Object.from(_v1).to_ptr"] + builder.capture_variable_name.must_equal '_v1' + builder.post_conversion.must_equal ['_v2 = GObject::Object.from(_v1).to_ptr'] end - it "returns the result of the conversion" do - builder.capture_variable_name.must_equal "_v1" - builder.return_value_name.must_equal "_v2" + it 'returns the result of the conversion' do + builder.capture_variable_name.must_equal '_v1' + builder.return_value_name.must_equal '_v2' end end end diff --git a/test/gir_ffi/builders/enum_builder_test.rb b/test/gir_ffi/builders/enum_builder_test.rb index c1ef600a6..549c53594 100644 --- a/test/gir_ffi/builders/enum_builder_test.rb +++ b/test/gir_ffi/builders/enum_builder_test.rb @@ -1,16 +1,16 @@ require 'gir_ffi_test_helper' describe GirFFI::Builders::EnumBuilder do - describe "creating Regress::TestEnum" do + describe 'creating Regress::TestEnum' do before do save_module :Regress end - it "makes the created type know its proper name" do + it 'makes the created type know its proper name' do info = get_introspection_data 'Regress', 'TestEnum' builder = GirFFI::Builders::EnumBuilder.new info enum = builder.build_class - enum.inspect.must_equal "Regress::TestEnum" + enum.inspect.must_equal 'Regress::TestEnum' end after do diff --git a/test/gir_ffi/builders/field_builder_test.rb b/test/gir_ffi/builders/field_builder_test.rb index 3839dbce2..2ecad4089 100644 --- a/test/gir_ffi/builders/field_builder_test.rb +++ b/test/gir_ffi/builders/field_builder_test.rb @@ -3,9 +3,9 @@ describe GirFFI::Builders::FieldBuilder do let(:instance) { GirFFI::Builders::FieldBuilder.new field_info } - describe "for a field of type :gint8 with an offset" do - let(:field_info) { get_field_introspection_data "Regress", "TestSimpleBoxedA", "some_int8" } - it "creates the right getter method" do + describe 'for a field of type :gint8 with an offset' do + let(:field_info) { get_field_introspection_data 'Regress', 'TestSimpleBoxedA', 'some_int8' } + it 'creates the right getter method' do expected = <<-CODE.reset_indentation def some_int8 _v1 = @struct.to_ptr + #{field_info.offset} @@ -18,7 +18,7 @@ def some_int8 instance.getter_def.must_equal expected end - it "creates the right setter method" do + it 'creates the right setter method' do expected = <<-CODE.reset_indentation def some_int8= value _v1 = @struct.to_ptr + #{field_info.offset} @@ -31,9 +31,9 @@ def some_int8= value end end - describe "for a field of type :struct" do - let(:field_info) { get_field_introspection_data "Regress", "TestBoxed", "nested_a" } - it "creates the right getter method" do + describe 'for a field of type :struct' do + let(:field_info) { get_field_introspection_data 'Regress', 'TestBoxed', 'nested_a' } + it 'creates the right getter method' do expected = <<-CODE.reset_indentation def nested_a _v1 = @struct.to_ptr + #{field_info.offset} @@ -47,9 +47,9 @@ def nested_a end end - describe "for a field of type :enum" do - let(:field_info) { get_field_introspection_data "Regress", "TestStructA", "some_enum" } - it "creates the right getter method" do + describe 'for a field of type :enum' do + let(:field_info) { get_field_introspection_data 'Regress', 'TestStructA', 'some_enum' } + it 'creates the right getter method' do expected = <<-CODE.reset_indentation def some_enum _v1 = @struct.to_ptr + #{field_info.offset} @@ -63,9 +63,9 @@ def some_enum end end - describe "for an inline fixed-size array field" do - let(:field_info) { get_field_introspection_data "Regress", "TestStructE", "some_union" } - it "creates the right getter method" do + describe 'for an inline fixed-size array field' do + let(:field_info) { get_field_introspection_data 'Regress', 'TestStructE', 'some_union' } + it 'creates the right getter method' do expected = <<-CODE.reset_indentation def some_union _v1 = @struct.to_ptr + #{field_info.offset} @@ -78,7 +78,7 @@ def some_union instance.getter_def.must_equal expected end - it "creates the right setter method" do + it 'creates the right setter method' do expected = <<-CODE.reset_indentation def some_union= value _v1 = @struct.to_ptr + #{field_info.offset} @@ -92,9 +92,9 @@ def some_union= value end end - describe "for a field of type :callback" do - let(:field_info) { get_field_introspection_data "GObject", "TypeInfo", "class_init" } - it "creates the right setter method" do + describe 'for a field of type :callback' do + let(:field_info) { get_field_introspection_data 'GObject', 'TypeInfo', 'class_init' } + it 'creates the right setter method' do expected = <<-CODE.reset_indentation def class_init= value _v1 = @struct.to_ptr + #{field_info.offset} diff --git a/test/gir_ffi/builders/function_builder_test.rb b/test/gir_ffi/builders/function_builder_test.rb index 8b60b9b20..fe1cd2e91 100644 --- a/test/gir_ffi/builders/function_builder_test.rb +++ b/test/gir_ffi/builders/function_builder_test.rb @@ -1,7 +1,7 @@ require 'gir_ffi_test_helper' describe GirFFI::Builders::FunctionBuilder do - it "builds a correct definition of Regress:test_array_fixed_out_objects" do + it 'builds a correct definition of Regress:test_array_fixed_out_objects' do go = get_introspection_data 'Regress', 'test_array_fixed_out_objects' skip unless go fbuilder = GirFFI::Builders::FunctionBuilder.new go @@ -19,7 +19,7 @@ def self.test_array_fixed_out_objects assert_equal expected.reset_indentation, code end - it "builds a correct definition for functions having a linked length argument" do + it 'builds a correct definition for functions having a linked length argument' do go = get_introspection_data 'Regress', 'test_array_gint16_in' fbuilder = GirFFI::Builders::FunctionBuilder.new go code = fbuilder.generate @@ -37,7 +37,7 @@ def self.test_array_gint16_in(ints) assert_equal expected.reset_indentation, code end - it "builds a correct definition for functions with callbacks" do + it 'builds a correct definition for functions with callbacks' do go = get_introspection_data 'Regress', 'test_callback_destroy_notify' fbuilder = GirFFI::Builders::FunctionBuilder.new go code = fbuilder.generate @@ -55,7 +55,7 @@ def self.test_callback_destroy_notify(callback, user_data, notify) assert_equal expected.reset_indentation, code end - it "builds correct definition for constructors" do + it 'builds correct definition for constructors' do go = get_method_introspection_data 'Regress', 'TestObj', 'new_from_file' fbuilder = GirFFI::Builders::FunctionBuilder.new go code = fbuilder.generate @@ -74,7 +74,7 @@ def self.new_from_file(x) assert_equal expected.reset_indentation, code end - it "creates a call to GObject::Value#from for functions that take a GValue" do + it 'creates a call to GObject::Value#from for functions that take a GValue' do go = get_introspection_data 'GIMarshallingTests', 'gvalue_in' fbuilder = GirFFI::Builders::FunctionBuilder.new go code = fbuilder.generate @@ -89,7 +89,7 @@ def self.gvalue_in(value) assert_equal expected.reset_indentation, code end - it "builds correct definition for functions with a nullable input array" do + it 'builds correct definition for functions with a nullable input array' do go = get_introspection_data 'Regress', 'test_array_int_null_in' fbuilder = GirFFI::Builders::FunctionBuilder.new go code = fbuilder.generate @@ -106,7 +106,7 @@ def self.test_array_int_null_in(arr) assert_equal expected.reset_indentation, code end - it "builds correct definition for functions with a nullable output array" do + it 'builds correct definition for functions with a nullable output array' do go = get_introspection_data 'Regress', 'test_array_int_null_out' fbuilder = GirFFI::Builders::FunctionBuilder.new go code = fbuilder.generate @@ -125,7 +125,7 @@ def self.test_array_int_null_out assert_equal expected.reset_indentation, code end - it "builds the correct definition for a method with an inout array with size argument" do + it 'builds the correct definition for a method with an inout array with size argument' do go = get_method_introspection_data 'GIMarshallingTests', 'Object', 'method_array_inout' fbuilder = GirFFI::Builders::FunctionBuilder.new go code = fbuilder.generate @@ -147,7 +147,7 @@ def method_array_inout(ints) assert_equal expected.reset_indentation, code end - it "builds a correct definition for a simple method" do + it 'builds a correct definition for a simple method' do go = get_method_introspection_data 'Regress', 'TestObj', 'instance_method' fbuilder = GirFFI::Builders::FunctionBuilder.new go code = fbuilder.generate @@ -162,13 +162,13 @@ def instance_method assert_equal expected.reset_indentation, code end - describe "#generate" do + describe '#generate' do let(:builder) { GirFFI::Builders::FunctionBuilder.new function_info } let(:code) { builder.generate } - describe "for GLib::Variant.get_strv" do + describe 'for GLib::Variant.get_strv' do let(:function_info) { get_method_introspection_data 'GLib', 'Variant', 'get_strv' } - it "builds a correct definition" do + it 'builds a correct definition' do size_type = ":guint#{FFI.type_size(:size_t) * 8}" code.must_equal <<-CODE.reset_indentation def get_strv @@ -181,10 +181,10 @@ def get_strv end end - describe "for Regress.has_parameter_named_attrs" do + describe 'for Regress.has_parameter_named_attrs' do let(:function_info) { get_introspection_data 'Regress', 'has_parameter_named_attrs' } - it "builds a correct definition" do + it 'builds a correct definition' do skip unless function_info code.must_equal <<-CODE.reset_indentation def self.has_parameter_named_attrs(foo, attributes) @@ -197,13 +197,13 @@ def self.has_parameter_named_attrs(foo, attributes) end end - describe "for GIMarshallingTests::Object.method_int8_arg_and_out_callee" do + describe 'for GIMarshallingTests::Object.method_int8_arg_and_out_callee' do let(:function_info) { get_method_introspection_data('GIMarshallingTests', 'Object', 'method_int8_arg_and_out_callee') } - it "builds a correct definition" do + it 'builds a correct definition' do skip unless function_info code.must_equal <<-CODE.reset_indentation def method_int8_arg_and_out_callee(arg) diff --git a/test/gir_ffi/builders/interface_builder_test.rb b/test/gir_ffi/builders/interface_builder_test.rb index da19411c6..ca7c2290c 100644 --- a/test/gir_ffi/builders/interface_builder_test.rb +++ b/test/gir_ffi/builders/interface_builder_test.rb @@ -6,24 +6,24 @@ get_introspection_data('Regress', 'TestInterface')) } - describe "#build_class" do + describe '#build_class' do before do info = get_introspection_data 'GObject', 'TypePlugin' @bldr = GirFFI::Builders::InterfaceBuilder.new info @iface = @bldr.build_class end - it "builds an interface as a module" do + it 'builds an interface as a module' do assert_instance_of Module, @iface end - it "creates methods on the interface" do + it 'creates methods on the interface' do assert_defines_instance_method @iface, :complete_interface_info end end - describe "#interface_struct" do - it "returns the interface struct type" do + describe '#interface_struct' do + it 'returns the interface struct type' do interface_builder.interface_struct.must_equal Regress::TestInterfaceIface end end diff --git a/test/gir_ffi/builders/module_builder_test.rb b/test/gir_ffi/builders/module_builder_test.rb index 5c6dd64be..63d29e6e4 100644 --- a/test/gir_ffi/builders/module_builder_test.rb +++ b/test/gir_ffi/builders/module_builder_test.rb @@ -1,14 +1,14 @@ require 'gir_ffi_test_helper' describe GirFFI::Builders::ModuleBuilder do - describe "#build_namespaced_class" do - it "raises a clear error if the named class does not exist" do + describe '#build_namespaced_class' do + it 'raises a clear error if the named class does not exist' do gir = GObjectIntrospection::IRepository.default - stub(gir).require("Foo", nil) {} + stub(gir).require('Foo', nil) {} - builder = GirFFI::Builders::ModuleBuilder.new "Foo" + builder = GirFFI::Builders::ModuleBuilder.new 'Foo' - mock(gir).find_by_name("Foo", "Bar") { nil } + mock(gir).find_by_name('Foo', 'Bar') { nil } assert_raises NameError do builder.build_namespaced_class :Bar diff --git a/test/gir_ffi/builders/object_builder_test.rb b/test/gir_ffi/builders/object_builder_test.rb index d1d1e7bbc..a8eb57220 100644 --- a/test/gir_ffi/builders/object_builder_test.rb +++ b/test/gir_ffi/builders/object_builder_test.rb @@ -38,38 +38,38 @@ end end - describe "#find_property" do - it "finds a property specified on the class itself" do - prop = obj_builder.find_property("int") - prop.name.must_equal "int" + describe '#find_property' do + it 'finds a property specified on the class itself' do + prop = obj_builder.find_property('int') + prop.name.must_equal 'int' end - it "finds a property specified on the parent class" do - prop = sub_obj_builder.find_property("int") - prop.name.must_equal "int" + it 'finds a property specified on the parent class' do + prop = sub_obj_builder.find_property('int') + prop.name.must_equal 'int' end - it "raises an error if the property is not found" do + it 'raises an error if the property is not found' do proc { - sub_obj_builder.find_property("this-property-does-not-exist") + sub_obj_builder.find_property('this-property-does-not-exist') }.must_raise RuntimeError end end - describe "#function_definition" do + describe '#function_definition' do let(:method_info) { get_method_introspection_data 'Regress', 'TestObj', 'instance_method' } - it "delegates definition to FunctionBuilder" do + it 'delegates definition to FunctionBuilder' do code = obj_builder.send :function_definition, method_info expected = GirFFI::Builders::FunctionBuilder.new(method_info).generate code.must_equal expected end end - describe "#object_class_struct" do - it "returns the class struct type" do + describe '#object_class_struct' do + it 'returns the class struct type' do obj_builder.object_class_struct.must_equal Regress::TestObjClass end end diff --git a/test/gir_ffi/builders/property_builder_test.rb b/test/gir_ffi/builders/property_builder_test.rb index 6687c5a79..4bb27648f 100644 --- a/test/gir_ffi/builders/property_builder_test.rb +++ b/test/gir_ffi/builders/property_builder_test.rb @@ -3,9 +3,9 @@ describe GirFFI::Builders::PropertyBuilder do let(:builder) { GirFFI::Builders::PropertyBuilder.new property_info } - describe "for a property of type :glist" do - let(:property_info) { get_property_introspection_data("Regress", "TestObj", "list") } - it "generates the correct getter definition" do + describe 'for a property of type :glist' do + let(:property_info) { get_property_introspection_data('Regress', 'TestObj', 'list') } + it 'generates the correct getter definition' do expected = <<-CODE.reset_indentation def list _v1 = get_property("list").get_value_plain @@ -17,7 +17,7 @@ def list builder.getter_def.must_equal expected end - it "generates the correct setter definition" do + it 'generates the correct setter definition' do expected = <<-CODE.reset_indentation def list= value _v1 = GLib::List.from(:utf8, value) @@ -29,9 +29,9 @@ def list= value end end - describe "for a property of type :ghash" do - let(:property_info) { get_property_introspection_data("Regress", "TestObj", "hash-table") } - it "generates the correct getter definition" do + describe 'for a property of type :ghash' do + let(:property_info) { get_property_introspection_data('Regress', 'TestObj', 'hash-table') } + it 'generates the correct getter definition' do expected = <<-CODE.reset_indentation def hash_table _v1 = get_property("hash-table").get_value_plain @@ -43,7 +43,7 @@ def hash_table builder.getter_def.must_equal expected end - it "generates the correct setter definition" do + it 'generates the correct setter definition' do expected = <<-CODE.reset_indentation def hash_table= value _v1 = GLib::HashTable.from([:utf8, :gint8], value) @@ -55,17 +55,17 @@ def hash_table= value end end - describe "for a property of type :strv" do + describe 'for a property of type :strv' do let(:property_info) { - get_property_introspection_data("GIMarshallingTests", - "PropertiesObject", - "some-strv") + get_property_introspection_data('GIMarshallingTests', + 'PropertiesObject', + 'some-strv') } before do skip unless property_info end - it "generates the correct getter definition" do + it 'generates the correct getter definition' do expected = <<-CODE.reset_indentation def some_strv get_property("some-strv").get_value @@ -75,7 +75,7 @@ def some_strv builder.getter_def.must_equal expected end - it "generates the correct setter definition" do + it 'generates the correct setter definition' do expected = <<-CODE.reset_indentation def some_strv= value _v1 = GLib::Strv.from(value) @@ -87,9 +87,9 @@ def some_strv= value end end - describe "for a property of type :utf8" do - let(:property_info) { get_property_introspection_data("Regress", "TestObj", "string") } - it "generates the correct getter definition" do + describe 'for a property of type :utf8' do + let(:property_info) { get_property_introspection_data('Regress', 'TestObj', 'string') } + it 'generates the correct getter definition' do expected = <<-CODE.reset_indentation def string get_property("string").get_value @@ -99,7 +99,7 @@ def string builder.getter_def.must_equal expected end - it "generates the correct setter definition" do + it 'generates the correct setter definition' do expected = <<-CODE.reset_indentation def string= value set_property("string", value) @@ -110,17 +110,17 @@ def string= value end end - describe "#container_defines_getter_method?" do + describe '#container_defines_getter_method?' do let(:property_info) { Object.new.tap { |o| o.extend GirFFI::InfoExt::IPropertyInfo } } let(:container_info) { Object.new } before do stub(property_info).container { container_info } - stub(property_info).name { "foo-bar" } - stub(container_info).find_instance_method("foo_bar") { true } + stub(property_info).name { 'foo-bar' } + stub(container_info).find_instance_method('foo_bar') { true } end - it "finds methods with underscores for properties with dashes" do + it 'finds methods with underscores for properties with dashes' do builder.container_defines_getter_method?.must_equal true end end diff --git a/test/gir_ffi/builders/registered_type_builder_test.rb b/test/gir_ffi/builders/registered_type_builder_test.rb index beaa281cd..cc1c9f5f7 100644 --- a/test/gir_ffi/builders/registered_type_builder_test.rb +++ b/test/gir_ffi/builders/registered_type_builder_test.rb @@ -3,28 +3,28 @@ GirFFI.setup :Regress describe GirFFI::Builders::RegisteredTypeBuilder do - describe "#setup_instance_method" do - it "restores a method that was removed" do - Regress::TestObj.class_eval { remove_method "instance_method" } + describe '#setup_instance_method' do + it 'restores a method that was removed' do + Regress::TestObj.class_eval { remove_method 'instance_method' } builder = Regress::TestObj.gir_ffi_builder - builder.setup_instance_method "instance_method" + builder.setup_instance_method 'instance_method' obj = Regress::TestObj.constructor - obj.must_respond_to "instance_method" + obj.must_respond_to 'instance_method' end - it "returns the name of the generated method" do + it 'returns the name of the generated method' do builder = Regress::TestObj.gir_ffi_builder - result = builder.setup_instance_method "instance_method" - result.must_equal "instance_method" + result = builder.setup_instance_method 'instance_method' + result.must_equal 'instance_method' end - it "returns the name of the generated method if different from the info name" do + it 'returns the name of the generated method if different from the info name' do builder = GLib::IConv.gir_ffi_builder - result = builder.setup_instance_method "" - result.must_equal "_" + result = builder.setup_instance_method '' + result.must_equal '_' end end end diff --git a/test/gir_ffi/builders/return_value_builder_test.rb b/test/gir_ffi/builders/return_value_builder_test.rb index 03299f370..79f57d715 100644 --- a/test/gir_ffi/builders/return_value_builder_test.rb +++ b/test/gir_ffi/builders/return_value_builder_test.rb @@ -10,336 +10,336 @@ for_constructor) } - describe "for :gint32" do + describe 'for :gint32' do let(:type_info) { - get_introspection_data("GIMarshallingTests", - "int_return_min").return_type + get_introspection_data('GIMarshallingTests', + 'int_return_min').return_type } - it "has no statements in #post_conversion" do + it 'has no statements in #post_conversion' do builder.post_conversion.must_equal [] end - it "returns the result of the c function directly" do - builder.capture_variable_name.must_equal "_v1" - builder.return_value_name.must_equal "_v1" + it 'returns the result of the c function directly' do + builder.capture_variable_name.must_equal '_v1' + builder.return_value_name.must_equal '_v1' end end - describe "for :struct" do + describe 'for :struct' do let(:type_info) { - get_method_introspection_data("GIMarshallingTests", - "BoxedStruct", - "returnv").return_type + get_method_introspection_data('GIMarshallingTests', + 'BoxedStruct', + 'returnv').return_type } - it "wraps the result in #post_conversion" do - builder.capture_variable_name.must_equal "_v1" - builder.post_conversion.must_equal ["_v2 = GIMarshallingTests::BoxedStruct.wrap(_v1)"] + it 'wraps the result in #post_conversion' do + builder.capture_variable_name.must_equal '_v1' + builder.post_conversion.must_equal ['_v2 = GIMarshallingTests::BoxedStruct.wrap(_v1)'] end - it "returns the wrapped result" do - builder.capture_variable_name.must_equal "_v1" - builder.return_value_name.must_equal "_v2" + it 'returns the wrapped result' do + builder.capture_variable_name.must_equal '_v1' + builder.return_value_name.must_equal '_v2' end end - describe "for :union" do + describe 'for :union' do let(:type_info) { - get_method_introspection_data("GIMarshallingTests", - "Union", - "returnv").return_type + get_method_introspection_data('GIMarshallingTests', + 'Union', + 'returnv').return_type } - it "wraps the result in #post_conversion" do - builder.capture_variable_name.must_equal "_v1" - builder.post_conversion.must_equal ["_v2 = GIMarshallingTests::Union.wrap(_v1)"] + it 'wraps the result in #post_conversion' do + builder.capture_variable_name.must_equal '_v1' + builder.post_conversion.must_equal ['_v2 = GIMarshallingTests::Union.wrap(_v1)'] end - it "returns the wrapped result" do - builder.capture_variable_name.must_equal "_v1" - builder.return_value_name.must_equal "_v2" + it 'returns the wrapped result' do + builder.capture_variable_name.must_equal '_v1' + builder.return_value_name.must_equal '_v2' end end - describe "for :interface" do + describe 'for :interface' do let(:type_info) { - get_method_introspection_data("Gio", - "File", - "new_for_commandline_arg").return_type + get_method_introspection_data('Gio', + 'File', + 'new_for_commandline_arg').return_type } - it "wraps the result in #post_conversion" do - builder.capture_variable_name.must_equal "_v1" - builder.post_conversion.must_equal ["_v2 = Gio::File.wrap(_v1)"] + it 'wraps the result in #post_conversion' do + builder.capture_variable_name.must_equal '_v1' + builder.post_conversion.must_equal ['_v2 = Gio::File.wrap(_v1)'] end - it "returns the wrapped result" do - builder.capture_variable_name.must_equal "_v1" - builder.return_value_name.must_equal "_v2" + it 'returns the wrapped result' do + builder.capture_variable_name.must_equal '_v1' + builder.return_value_name.must_equal '_v2' end end - describe "for :object" do - describe "when the method is not a constructor" do + describe 'for :object' do + describe 'when the method is not a constructor' do let(:type_info) { - get_method_introspection_data("GIMarshallingTests", - "Object", - "full_return").return_type + get_method_introspection_data('GIMarshallingTests', + 'Object', + 'full_return').return_type } let(:for_constructor) { false } - it "wraps the result in #post_conversion" do - builder.capture_variable_name.must_equal "_v1" - builder.post_conversion.must_equal ["_v2 = GIMarshallingTests::Object.wrap(_v1)"] + it 'wraps the result in #post_conversion' do + builder.capture_variable_name.must_equal '_v1' + builder.post_conversion.must_equal ['_v2 = GIMarshallingTests::Object.wrap(_v1)'] end - it "returns the wrapped result" do - builder.capture_variable_name.must_equal "_v1" - builder.return_value_name.must_equal "_v2" + it 'returns the wrapped result' do + builder.capture_variable_name.must_equal '_v1' + builder.return_value_name.must_equal '_v2' end end - describe "when the method is a constructor" do + describe 'when the method is a constructor' do let(:type_info) { - get_method_introspection_data("GIMarshallingTests", - "Object", - "new").return_type + get_method_introspection_data('GIMarshallingTests', + 'Object', + 'new').return_type } let(:for_constructor) { true } - it "wraps the result in #post_conversion" do - builder.capture_variable_name.must_equal "_v1" - builder.post_conversion.must_equal ["_v2 = self.constructor_wrap(_v1)"] + it 'wraps the result in #post_conversion' do + builder.capture_variable_name.must_equal '_v1' + builder.post_conversion.must_equal ['_v2 = self.constructor_wrap(_v1)'] end - it "returns the wrapped result" do - builder.capture_variable_name.must_equal "_v1" - builder.return_value_name.must_equal "_v2" + it 'returns the wrapped result' do + builder.capture_variable_name.must_equal '_v1' + builder.return_value_name.must_equal '_v2' end end end - describe "for :strv" do + describe 'for :strv' do let(:type_info) { - get_method_introspection_data("GLib", - "KeyFile", - "get_locale_string_list").return_type + get_method_introspection_data('GLib', + 'KeyFile', + 'get_locale_string_list').return_type } - it "wraps the result in #post_conversion" do - builder.capture_variable_name.must_equal "_v1" - builder.post_conversion.must_equal ["_v2 = GLib::Strv.wrap(_v1)"] + it 'wraps the result in #post_conversion' do + builder.capture_variable_name.must_equal '_v1' + builder.post_conversion.must_equal ['_v2 = GLib::Strv.wrap(_v1)'] end - it "returns the wrapped result" do - builder.capture_variable_name.must_equal "_v1" - builder.return_value_name.must_equal "_v2" + it 'returns the wrapped result' do + builder.capture_variable_name.must_equal '_v1' + builder.return_value_name.must_equal '_v2' end end - describe "for :zero_terminated" do + describe 'for :zero_terminated' do let(:type_info) { - get_method_introspection_data("GLib", - "Variant", - "dup_bytestring").return_type + get_method_introspection_data('GLib', + 'Variant', + 'dup_bytestring').return_type } before do skip unless type_info.zero_terminated? end - it "wraps the result in #post_conversion" do - builder.capture_variable_name.must_equal "_v1" - builder.post_conversion.must_equal ["_v2 = GirFFI::ZeroTerminated.wrap(:guint8, _v1)"] + it 'wraps the result in #post_conversion' do + builder.capture_variable_name.must_equal '_v1' + builder.post_conversion.must_equal ['_v2 = GirFFI::ZeroTerminated.wrap(:guint8, _v1)'] end - it "returns the wrapped result" do - builder.capture_variable_name.must_equal "_v1" - builder.return_value_name.must_equal "_v2" + it 'returns the wrapped result' do + builder.capture_variable_name.must_equal '_v1' + builder.return_value_name.must_equal '_v2' end end - describe "for :byte_array" do + describe 'for :byte_array' do let(:type_info) { - get_introspection_data("GIMarshallingTests", - "bytearray_full_return").return_type + get_introspection_data('GIMarshallingTests', + 'bytearray_full_return').return_type } - it "wraps the result in #post_conversion" do - builder.capture_variable_name.must_equal "_v1" - builder.post_conversion.must_equal ["_v2 = GLib::ByteArray.wrap(_v1)"] + it 'wraps the result in #post_conversion' do + builder.capture_variable_name.must_equal '_v1' + builder.post_conversion.must_equal ['_v2 = GLib::ByteArray.wrap(_v1)'] end - it "returns the wrapped result" do - builder.capture_variable_name.must_equal "_v1" - builder.return_value_name.must_equal "_v2" + it 'returns the wrapped result' do + builder.capture_variable_name.must_equal '_v1' + builder.return_value_name.must_equal '_v2' end end - describe "for :ptr_array" do + describe 'for :ptr_array' do let(:type_info) { - get_introspection_data("GIMarshallingTests", - "gptrarray_utf8_none_return").return_type + get_introspection_data('GIMarshallingTests', + 'gptrarray_utf8_none_return').return_type } - it "wraps the result in #post_conversion" do - builder.capture_variable_name.must_equal "_v1" - builder.post_conversion.must_equal ["_v2 = GLib::PtrArray.wrap(:utf8, _v1)"] + it 'wraps the result in #post_conversion' do + builder.capture_variable_name.must_equal '_v1' + builder.post_conversion.must_equal ['_v2 = GLib::PtrArray.wrap(:utf8, _v1)'] end - it "returns the wrapped result" do - builder.capture_variable_name.must_equal "_v1" - builder.return_value_name.must_equal "_v2" + it 'returns the wrapped result' do + builder.capture_variable_name.must_equal '_v1' + builder.return_value_name.must_equal '_v2' end end - describe "for :glist" do + describe 'for :glist' do let(:type_info) { - get_introspection_data("GIMarshallingTests", - "glist_int_none_return").return_type + get_introspection_data('GIMarshallingTests', + 'glist_int_none_return').return_type } - it "wraps the result in #post_conversion" do - builder.capture_variable_name.must_equal "_v1" - builder.post_conversion.must_equal ["_v2 = GLib::List.wrap(:gint32, _v1)"] + it 'wraps the result in #post_conversion' do + builder.capture_variable_name.must_equal '_v1' + builder.post_conversion.must_equal ['_v2 = GLib::List.wrap(:gint32, _v1)'] end - it "returns the wrapped result" do - builder.capture_variable_name.must_equal "_v1" - builder.return_value_name.must_equal "_v2" + it 'returns the wrapped result' do + builder.capture_variable_name.must_equal '_v1' + builder.return_value_name.must_equal '_v2' end end - describe "for :gslist" do + describe 'for :gslist' do let(:type_info) { - get_introspection_data("GIMarshallingTests", - "gslist_int_none_return").return_type + get_introspection_data('GIMarshallingTests', + 'gslist_int_none_return').return_type } - it "wraps the result in #post_conversion" do - builder.capture_variable_name.must_equal "_v1" - builder.post_conversion.must_equal ["_v2 = GLib::SList.wrap(:gint32, _v1)"] + it 'wraps the result in #post_conversion' do + builder.capture_variable_name.must_equal '_v1' + builder.post_conversion.must_equal ['_v2 = GLib::SList.wrap(:gint32, _v1)'] end - it "returns the wrapped result" do - builder.capture_variable_name.must_equal "_v1" - builder.return_value_name.must_equal "_v2" + it 'returns the wrapped result' do + builder.capture_variable_name.must_equal '_v1' + builder.return_value_name.must_equal '_v2' end end - describe "for :ghash" do + describe 'for :ghash' do let(:type_info) { - get_introspection_data("GIMarshallingTests", - "ghashtable_int_none_return").return_type + get_introspection_data('GIMarshallingTests', + 'ghashtable_int_none_return').return_type } - it "wraps the result in #post_conversion" do - builder.capture_variable_name.must_equal "_v1" - builder.post_conversion.must_equal ["_v2 = GLib::HashTable.wrap([:gint32, :gint32], _v1)"] + it 'wraps the result in #post_conversion' do + builder.capture_variable_name.must_equal '_v1' + builder.post_conversion.must_equal ['_v2 = GLib::HashTable.wrap([:gint32, :gint32], _v1)'] end - it "returns the wrapped result" do - builder.capture_variable_name.must_equal "_v1" - builder.return_value_name.must_equal "_v2" + it 'returns the wrapped result' do + builder.capture_variable_name.must_equal '_v1' + builder.return_value_name.must_equal '_v2' end end - describe "for :array" do + describe 'for :array' do let(:type_info) { - get_introspection_data("GIMarshallingTests", - "garray_int_none_return").return_type + get_introspection_data('GIMarshallingTests', + 'garray_int_none_return').return_type } - it "wraps the result in #post_conversion" do - builder.capture_variable_name.must_equal "_v1" - builder.post_conversion.must_equal ["_v2 = GLib::Array.wrap(:gint32, _v1)"] + it 'wraps the result in #post_conversion' do + builder.capture_variable_name.must_equal '_v1' + builder.post_conversion.must_equal ['_v2 = GLib::Array.wrap(:gint32, _v1)'] end - it "returns the wrapped result" do - builder.capture_variable_name.must_equal "_v1" - builder.return_value_name.must_equal "_v2" + it 'returns the wrapped result' do + builder.capture_variable_name.must_equal '_v1' + builder.return_value_name.must_equal '_v2' end end - describe "for :error" do + describe 'for :error' do let(:type_info) { - get_introspection_data("GIMarshallingTests", - "gerror_return").return_type + get_introspection_data('GIMarshallingTests', + 'gerror_return').return_type } - it "wraps the result in #post_conversion" do - builder.capture_variable_name.must_equal "_v1" - builder.post_conversion.must_equal ["_v2 = GLib::Error.wrap(_v1)"] + it 'wraps the result in #post_conversion' do + builder.capture_variable_name.must_equal '_v1' + builder.post_conversion.must_equal ['_v2 = GLib::Error.wrap(_v1)'] end - it "returns the wrapped result" do - builder.capture_variable_name.must_equal "_v1" - builder.return_value_name.must_equal "_v2" + it 'returns the wrapped result' do + builder.capture_variable_name.must_equal '_v1' + builder.return_value_name.must_equal '_v2' end end - describe "for :c" do - describe "with fixed size" do + describe 'for :c' do + describe 'with fixed size' do let(:type_info) { - get_introspection_data("GIMarshallingTests", - "array_fixed_int_return").return_type + get_introspection_data('GIMarshallingTests', + 'array_fixed_int_return').return_type } - it "converts the result in #post_conversion" do - builder.capture_variable_name.must_equal "_v1" - builder.post_conversion.must_equal ["_v2 = GirFFI::SizedArray.wrap(:gint32, 4, _v1)"] + it 'converts the result in #post_conversion' do + builder.capture_variable_name.must_equal '_v1' + builder.post_conversion.must_equal ['_v2 = GirFFI::SizedArray.wrap(:gint32, 4, _v1)'] end - it "returns the wrapped result" do - builder.capture_variable_name.must_equal "_v1" - builder.return_value_name.must_equal "_v2" + it 'returns the wrapped result' do + builder.capture_variable_name.must_equal '_v1' + builder.return_value_name.must_equal '_v2' end end - describe "with separate size parameter" do + describe 'with separate size parameter' do let(:length_argument) { Object.new } let(:type_info) { - get_method_introspection_data("GIMarshallingTests", - "Object", - "method_array_return").return_type + get_method_introspection_data('GIMarshallingTests', + 'Object', + 'method_array_return').return_type } before do - stub(length_argument).post_converted_name { "bar" } + stub(length_argument).post_converted_name { 'bar' } builder.length_arg = length_argument end - it "converts the result in #post_conversion" do - builder.capture_variable_name.must_equal "_v1" - builder.post_conversion.must_equal ["_v2 = GirFFI::SizedArray.wrap(:gint32, bar, _v1)"] + it 'converts the result in #post_conversion' do + builder.capture_variable_name.must_equal '_v1' + builder.post_conversion.must_equal ['_v2 = GirFFI::SizedArray.wrap(:gint32, bar, _v1)'] end - it "returns the wrapped result" do - builder.capture_variable_name.must_equal "_v1" - builder.return_value_name.must_equal "_v2" + it 'returns the wrapped result' do + builder.capture_variable_name.must_equal '_v1' + builder.return_value_name.must_equal '_v2' end end end - describe "for :utf8" do + describe 'for :utf8' do let(:type_info) { - get_introspection_data("GIMarshallingTests", "utf8_full_return").return_type + get_introspection_data('GIMarshallingTests', 'utf8_full_return').return_type } - it "converts the result in #post_conversion" do - builder.capture_variable_name.must_equal "_v1" - builder.post_conversion.must_equal ["_v2 = _v1.to_utf8"] + it 'converts the result in #post_conversion' do + builder.capture_variable_name.must_equal '_v1' + builder.post_conversion.must_equal ['_v2 = _v1.to_utf8'] end - it "returns the converted result" do - builder.capture_variable_name.must_equal "_v1" - builder.return_value_name.must_equal "_v2" + it 'returns the converted result' do + builder.capture_variable_name.must_equal '_v1' + builder.return_value_name.must_equal '_v2' end end - describe "for :void pointer" do + describe 'for :void pointer' do let(:callback_info) { - get_introspection_data("GIMarshallingTests", "CallbackIntInt") + get_introspection_data('GIMarshallingTests', 'CallbackIntInt') } let(:type_info) { callback_info.args[1].argument_type } @@ -347,69 +347,69 @@ skip unless callback_info end - it "has no statements in #post_conversion" do + it 'has no statements in #post_conversion' do builder.post_conversion.must_equal [] end - it "returns the result of the c function directly" do - builder.capture_variable_name.must_equal "_v1" - builder.return_value_name.must_equal "_v1" + it 'returns the result of the c function directly' do + builder.capture_variable_name.must_equal '_v1' + builder.return_value_name.must_equal '_v1' end end - describe "for :void" do + describe 'for :void' do let(:type_info) { - get_method_introspection_data("Regress", "TestObj", "null_out").return_type + get_method_introspection_data('Regress', 'TestObj', 'null_out').return_type } - it "has no statements in #post_conversion" do + it 'has no statements in #post_conversion' do builder.post_conversion.must_equal [] end - it "marks itself as irrelevant" do + it 'marks itself as irrelevant' do builder.relevant?.must_equal false end - it "returns nothing" do + it 'returns nothing' do builder.return_value_name.must_be_nil end end - describe "for a closure argument" do + describe 'for a closure argument' do let(:type_info) { - get_introspection_data("Regress", "TestCallbackUserData").args[0].argument_type + get_introspection_data('Regress', 'TestCallbackUserData').args[0].argument_type } before do builder.closure = true end - it "fetches the stored object in #post_conversion" do - builder.capture_variable_name.must_equal "_v1" - builder.post_conversion.must_equal ["_v2 = GirFFI::ArgHelper::OBJECT_STORE.fetch(_v1)"] + it 'fetches the stored object in #post_conversion' do + builder.capture_variable_name.must_equal '_v1' + builder.post_conversion.must_equal ['_v2 = GirFFI::ArgHelper::OBJECT_STORE.fetch(_v1)'] end - it "returns the stored object" do - builder.capture_variable_name.must_equal "_v1" - builder.return_value_name.must_equal "_v2" + it 'returns the stored object' do + builder.capture_variable_name.must_equal '_v1' + builder.return_value_name.must_equal '_v2' end end - describe "for a skipped return value" do + describe 'for a skipped return value' do let(:type_info) { - get_method_introspection_data("Regress", "TestObj", "skip_return_val").return_type + get_method_introspection_data('Regress', 'TestObj', 'skip_return_val').return_type } let(:return_type_info) { GirFFI::ReturnValueInfo.new(type_info, true) } - it "has no statements in #post_conversion" do + it 'has no statements in #post_conversion' do builder.post_conversion.must_equal [] end - it "marks itself as irrelevant" do + it 'marks itself as irrelevant' do builder.relevant?.must_equal false end - it "returns nothing" do + it 'returns nothing' do builder.return_value_name.must_be_nil end end diff --git a/test/gir_ffi/builders/signal_closure_builder_test.rb b/test/gir_ffi/builders/signal_closure_builder_test.rb index 121199cde..4e22b0831 100644 --- a/test/gir_ffi/builders/signal_closure_builder_test.rb +++ b/test/gir_ffi/builders/signal_closure_builder_test.rb @@ -3,24 +3,24 @@ describe GirFFI::Builders::SignalClosureBuilder do let(:builder) { GirFFI::Builders::SignalClosureBuilder.new signal_info } - describe "#build_class" do + describe '#build_class' do let(:signal_info) { - get_signal_introspection_data "Regress", "TestObj", "test" + get_signal_introspection_data 'Regress', 'TestObj', 'test' } - it "builds a descendant of RubyClosure" do + it 'builds a descendant of RubyClosure' do klass = builder.build_class klass.ancestors.must_include GObject::RubyClosure end end - describe "#marshaller_definition" do - describe "for a signal with no arguments or return value" do + describe '#marshaller_definition' do + describe 'for a signal with no arguments or return value' do let(:signal_info) { - get_signal_introspection_data "Regress", "TestObj", "test" + get_signal_introspection_data 'Regress', 'TestObj', 'test' } - it "returns a valid marshaller converting only the receiver" do + it 'returns a valid marshaller converting only the receiver' do expected = <<-CODE.reset_indentation def self.marshaller(closure, return_value, param_values, _invocation_hint, _marshal_data) _instance = param_values.first.get_value_plain @@ -33,12 +33,12 @@ def self.marshaller(closure, return_value, param_values, _invocation_hint, _mars end end - describe "for a signal with an argument and a return value" do + describe 'for a signal with an argument and a return value' do let(:signal_info) { - get_signal_introspection_data "Regress", "TestObj", "sig-with-int64-prop" + get_signal_introspection_data 'Regress', 'TestObj', 'sig-with-int64-prop' } - it "returns a valid mapping method" do + it 'returns a valid mapping method' do skip unless signal_info expected = <<-CODE.reset_indentation @@ -55,12 +55,12 @@ def self.marshaller(closure, return_value, param_values, _invocation_hint, _mars end end - describe "for a signal with an enum argument" do + describe 'for a signal with an enum argument' do let(:signal_info) { - get_signal_introspection_data "Gio", "MountOperation", "reply" + get_signal_introspection_data 'Gio', 'MountOperation', 'reply' } - it "returns a valid mapping method" do + it 'returns a valid mapping method' do expected = <<-CODE.reset_indentation def self.marshaller(closure, return_value, param_values, _invocation_hint, _marshal_data) _instance, result = param_values.map(&:get_value_plain) @@ -74,12 +74,12 @@ def self.marshaller(closure, return_value, param_values, _invocation_hint, _mars end end - describe "for a signal with a array plus length arguments" do + describe 'for a signal with a array plus length arguments' do let(:signal_info) { - get_signal_introspection_data "Regress", "TestObj", "sig-with-array-len-prop" + get_signal_introspection_data 'Regress', 'TestObj', 'sig-with-array-len-prop' } - it "returns a valid mapping method" do + it 'returns a valid mapping method' do skip unless signal_info expected = <<-CODE.reset_indentation @@ -96,12 +96,12 @@ def self.marshaller(closure, return_value, param_values, _invocation_hint, _mars end end - describe "for a signal with a struct argument" do + describe 'for a signal with a struct argument' do let(:signal_info) { - get_signal_introspection_data "Regress", "TestObj", "test-with-static-scope-arg" + get_signal_introspection_data 'Regress', 'TestObj', 'test-with-static-scope-arg' } - it "returns a valid mapping method" do + it 'returns a valid mapping method' do skip unless signal_info expected = <<-CODE.reset_indentation @@ -117,12 +117,12 @@ def self.marshaller(closure, return_value, param_values, _invocation_hint, _mars end end - describe "for a signal returning an array of integers" do + describe 'for a signal returning an array of integers' do let(:signal_info) { - get_signal_introspection_data "Regress", "TestObj", "sig-with-intarray-ret" + get_signal_introspection_data 'Regress', 'TestObj', 'sig-with-intarray-ret' } - it "returns a valid mapping method" do + it 'returns a valid mapping method' do skip unless signal_info expected = <<-CODE.reset_indentation diff --git a/test/gir_ffi/builders/struct_builder_test.rb b/test/gir_ffi/builders/struct_builder_test.rb index 6ba96b13e..e8229f70c 100644 --- a/test/gir_ffi/builders/struct_builder_test.rb +++ b/test/gir_ffi/builders/struct_builder_test.rb @@ -1,8 +1,8 @@ require 'gir_ffi_test_helper' describe GirFFI::Builders::StructBuilder do - describe "#layout_specification" do - it "returns the correct layout for Regress::TestStructA" do + describe '#layout_specification' do + it 'returns the correct layout for Regress::TestStructA' do info = get_introspection_data 'Regress', 'TestStructA' builder = GirFFI::Builders::StructBuilder.new info builder.layout_specification.must_equal [:some_int, :int32, 0, @@ -12,7 +12,7 @@ end end - describe "for a struct with a simple layout" do + describe 'for a struct with a simple layout' do before do @field = Object.new @@ -24,15 +24,15 @@ @builder = GirFFI::Builders::StructBuilder.new @struct end - it "creates the correct layout specification" do + it 'creates the correct layout specification' do mock(@field).layout_specification { [:bar, :int32, 0] } spec = @builder.send :layout_specification assert_equal [:bar, :int32, 0], spec end end - describe "for a struct with a layout with a complex type" do - it "does not flatten the complex type specification" do + describe 'for a struct with a layout with a complex type' do + it 'does not flatten the complex type specification' do mock(simplefield = Object.new).layout_specification { [:bar, :foo, 0] } mock(complexfield = Object.new).layout_specification { [:baz, [:qux, 2], 0] } mock(struct = Object.new).fields { [simplefield, complexfield] } @@ -46,8 +46,8 @@ end end - describe "for a struct without defined fields" do - it "uses a single field of the parent struct type as the default layout" do + describe 'for a struct without defined fields' do + it 'uses a single field of the parent struct type as the default layout' do @gir = GObjectIntrospection::IRepository.default @gir.require 'GObject', nil diff --git a/test/gir_ffi/builders/unintrospectable_builder_test.rb b/test/gir_ffi/builders/unintrospectable_builder_test.rb index bb2ca4daa..284615228 100644 --- a/test/gir_ffi/builders/unintrospectable_builder_test.rb +++ b/test/gir_ffi/builders/unintrospectable_builder_test.rb @@ -1,12 +1,12 @@ require 'gir_ffi_test_helper' describe GirFFI::Builders::UnintrospectableBuilder do - describe "building the GLocalFile type" do + describe 'building the GLocalFile type' do before do # Ensure existence of GLocalFile type GirFFI.setup :Gio unless Gio::Lib.respond_to? :g_file_new_for_path - Gio.setup_method "file_new_for_path" + Gio.setup_method 'file_new_for_path' end ptr = GirFFI::InPointer.from :utf8, '/' Gio::Lib.g_file_new_for_path(ptr) @@ -17,30 +17,30 @@ @klass = @bldr.build_class end - it "builds a class" do + it 'builds a class' do assert_instance_of Class, @klass end - it "builds a class derived from GObject::Object" do + it 'builds a class derived from GObject::Object' do assert_includes @klass.ancestors, GObject::Object end - it "builds a class derived from Gio::File" do + it 'builds a class derived from Gio::File' do assert_includes @klass.ancestors, Gio::File end - it "returns the same class when built again" do + it 'returns the same class when built again' do other_bldr = GirFFI::Builders::UnintrospectableBuilder.new(@info) other_klass = other_bldr.build_class assert_equal @klass, other_klass end - describe "its #find_signal method" do + describe 'its #find_signal method' do it "raises correct error for a signal that doesn't exist" do msg = nil begin - @bldr.find_signal "foo" + @bldr.find_signal 'foo' rescue RuntimeError => e msg = e.message end diff --git a/test/gir_ffi/builders/union_builder_test.rb b/test/gir_ffi/builders/union_builder_test.rb index 163a41aae..115f42080 100644 --- a/test/gir_ffi/builders/union_builder_test.rb +++ b/test/gir_ffi/builders/union_builder_test.rb @@ -4,14 +4,14 @@ let(:union_info) { get_introspection_data('GObject', 'TypeCValue') } let(:builder) { GirFFI::Builders::UnionBuilder.new union_info } - describe "#setup_instance_method" do + describe '#setup_instance_method' do it "returns nil looking for a method that doesn't exist" do builder.setup_instance_method('blub').must_be_nil end end - describe "#layout_specification" do - it "returns the correct layout for GObject::TypeCValue" do + describe '#layout_specification' do + it 'returns the correct layout for GObject::TypeCValue' do long_type = FFI.type_size(:long) == 8 ? :int64 : :int32 builder.layout_specification.must_equal [:v_int, :int32, 0, :v_long, long_type, 0, @@ -21,8 +21,8 @@ end end - describe "#layout_superclass" do - it "returns FFI::Union" do + describe '#layout_superclass' do + it 'returns FFI::Union' do builder.layout_superclass.must_equal FFI::Union end end diff --git a/test/gir_ffi/builders/user_defined_builder_test.rb b/test/gir_ffi/builders/user_defined_builder_test.rb index a6e087511..2ab570c1b 100644 --- a/test/gir_ffi/builders/user_defined_builder_test.rb +++ b/test/gir_ffi/builders/user_defined_builder_test.rb @@ -10,65 +10,65 @@ let(:builder) { GirFFI::Builders::UserDefinedBuilder.new info } let(:info) { GirFFI::UserDefinedTypeInfo.new klass } - describe "#build_class" do + describe '#build_class' do before do builder.build_class end - describe "with type info containing one property" do + describe 'with type info containing one property' do let(:info) { GirFFI::UserDefinedTypeInfo.new klass do |info| - info.install_property GObject.param_spec_int("foo", "foo bar", - "The Foo Bar Property", + info.install_property GObject.param_spec_int('foo', 'foo bar', + 'The Foo Bar Property', 10, 20, 15, 3) end } - it "registers a type that is bigger than the parent" do + it 'registers a type that is bigger than the parent' do gtype = klass.get_gtype q = GObject.type_query gtype q.instance_size.must_be :>, GIMarshallingTests::Object::Struct.size end - it "gives the types Struct the fields :parent and :foo" do + it 'gives the types Struct the fields :parent and :foo' do klass::Struct.members.must_equal [:parent, :foo] end - it "creates accessor functions for the property" do + it 'creates accessor functions for the property' do obj = klass.new obj.foo = 13 obj.foo.must_equal 13 end - it "makes the property retrievable using #get_property" do + it 'makes the property retrievable using #get_property' do obj = klass.new obj.foo = 13 - obj.get_property("foo").get_value.must_equal 13 + obj.get_property('foo').get_value.must_equal 13 end - it "makes the property settable using #set_property" do + it 'makes the property settable using #set_property' do obj = klass.new - obj.set_property("foo", 20) + obj.set_property('foo', 20) obj.foo.must_equal 20 end end - describe "with type info containing an overridden g_name" do + describe 'with type info containing an overridden g_name' do let(:info) { GirFFI::UserDefinedTypeInfo.new klass do |info| info.g_name = "OtherName#{Sequence.next}" end } - it "registers a type under the overridden name" do + it 'registers a type under the overridden name' do registered_name = GObject.type_name(klass.get_gtype) registered_name.must_equal info.g_name registered_name.wont_equal klass.name end end - describe "with type info containing a vfunc" do + describe 'with type info containing a vfunc' do let(:info) { GirFFI::UserDefinedTypeInfo.new klass do |info| info.install_vfunc_implementation :method_int8_in, proc {|instance, in_| @@ -77,14 +77,14 @@ end } - it "allows the vfunc to be called through its invoker" do + it 'allows the vfunc to be called through its invoker' do obj = klass.new obj.method_int8_in 12 obj.int.must_equal 12 end end - describe "with type info containing a vfunc from an included Interface" do + describe 'with type info containing a vfunc from an included Interface' do let(:info) do klass.class_eval { include GIMarshallingTests::Interface } GirFFI::UserDefinedTypeInfo.new klass do |info| @@ -93,19 +93,19 @@ end end - it "marks the type as conforming to the included Interface" do + it 'marks the type as conforming to the included Interface' do iface_gtype = GIMarshallingTests::Interface.get_gtype GObject.type_interfaces(klass.get_gtype).to_a.must_equal [iface_gtype] end - it "allows the vfunc to be called through its invoker" do + it 'allows the vfunc to be called through its invoker' do obj = klass.new obj.test_int8_in 12 obj.int.must_equal 12 end end - it "does not attempt to register a registered class" do + it 'does not attempt to register a registered class' do gtype = klass.get_gtype other_builder = GirFFI::Builders::UserDefinedBuilder.new info other_builder.build_class diff --git a/test/gir_ffi/builders/vfunc_builder_test.rb b/test/gir_ffi/builders/vfunc_builder_test.rb index 42fdb2c76..70cc43a14 100644 --- a/test/gir_ffi/builders/vfunc_builder_test.rb +++ b/test/gir_ffi/builders/vfunc_builder_test.rb @@ -3,19 +3,19 @@ describe GirFFI::Builders::VFuncBuilder do let(:builder) { GirFFI::Builders::VFuncBuilder.new vfunc_info } - describe "#mapping_method_definition" do + describe '#mapping_method_definition' do let(:result) { builder.mapping_method_definition } before do skip unless vfunc_info end - describe "for a vfunc with only one argument" do + describe 'for a vfunc with only one argument' do let(:vfunc_info) { - get_vfunc_introspection_data "GIMarshallingTests", "Object", "method_int8_in" + get_vfunc_introspection_data 'GIMarshallingTests', 'Object', 'method_int8_in' } - it "returns a valid mapping method including receiver" do + it 'returns a valid mapping method including receiver' do expected = <<-CODE.reset_indentation def self.call_with_argument_mapping(_proc, _instance, in_) _v1 = GIMarshallingTests::Object.wrap(_instance) @@ -28,12 +28,12 @@ def self.call_with_argument_mapping(_proc, _instance, in_) end end - describe "for a vfunc returning an enum" do + describe 'for a vfunc returning an enum' do let(:vfunc_info) { - get_vfunc_introspection_data "GIMarshallingTests", "Object", "vfunc_return_enum" + get_vfunc_introspection_data 'GIMarshallingTests', 'Object', 'vfunc_return_enum' } - it "returns a valid mapping method including receiver" do + it 'returns a valid mapping method including receiver' do expected = <<-CODE.reset_indentation def self.call_with_argument_mapping(_proc, _instance) _v1 = GIMarshallingTests::Object.wrap(_instance) @@ -47,12 +47,12 @@ def self.call_with_argument_mapping(_proc, _instance) end end - describe "for a vfunc with a callback argument" do + describe 'for a vfunc with a callback argument' do let(:vfunc_info) { - get_vfunc_introspection_data "GIMarshallingTests", "Object", "vfunc_with_callback" + get_vfunc_introspection_data 'GIMarshallingTests', 'Object', 'vfunc_with_callback' } - it "returns a valid mapping method including receiver" do + it 'returns a valid mapping method including receiver' do expected = <<-CODE.reset_indentation def self.call_with_argument_mapping(_proc, _instance, callback, callback_data) _v1 = GIMarshallingTests::Object.wrap(_instance) @@ -66,13 +66,13 @@ def self.call_with_argument_mapping(_proc, _instance, callback, callback_data) end end - describe "for a vfunc with an out argument allocated by them, the caller" do + describe 'for a vfunc with an out argument allocated by them, the caller' do let(:vfunc_info) { - get_vfunc_introspection_data("GIMarshallingTests", "Object", - "method_int8_arg_and_out_caller") + get_vfunc_introspection_data('GIMarshallingTests', 'Object', + 'method_int8_arg_and_out_caller') } - it "returns a valid mapping method including receiver" do + it 'returns a valid mapping method including receiver' do expected = <<-CODE.reset_indentation def self.call_with_argument_mapping(_proc, _instance, arg, out) _v1 = GIMarshallingTests::Object.wrap(_instance) @@ -87,13 +87,13 @@ def self.call_with_argument_mapping(_proc, _instance, arg, out) end end - describe "for a vfunc with an out argument allocated by us, the callee" do + describe 'for a vfunc with an out argument allocated by us, the callee' do let(:vfunc_info) { - get_vfunc_introspection_data("GIMarshallingTests", "Object", - "method_int8_arg_and_out_callee") + get_vfunc_introspection_data('GIMarshallingTests', 'Object', + 'method_int8_arg_and_out_callee') } - it "returns a valid mapping method including receiver" do + it 'returns a valid mapping method including receiver' do expected = <<-CODE.reset_indentation def self.call_with_argument_mapping(_proc, _instance, arg, out) _v1 = GIMarshallingTests::Object.wrap(_instance) @@ -108,13 +108,13 @@ def self.call_with_argument_mapping(_proc, _instance, arg, out) end end - describe "for a vfunc with an error argument" do + describe 'for a vfunc with an error argument' do let(:vfunc_info) { - get_vfunc_introspection_data("GIMarshallingTests", "Object", - "vfunc_meth_with_err") + get_vfunc_introspection_data('GIMarshallingTests', 'Object', + 'vfunc_meth_with_err') } - it "returns a valid mapping method including receiver" do + it 'returns a valid mapping method including receiver' do expected = <<-CODE.reset_indentation def self.call_with_argument_mapping(_proc, _instance, x, _error) _v1 = GIMarshallingTests::Object.wrap(_instance) @@ -134,37 +134,37 @@ def self.call_with_argument_mapping(_proc, _instance, x, _error) end end - describe "#argument_ffi_types" do + describe '#argument_ffi_types' do let(:result) { builder.argument_ffi_types } before do skip unless vfunc_info end - describe "for a vfunc with only one argument" do + describe 'for a vfunc with only one argument' do let(:vfunc_info) { - get_vfunc_introspection_data "GIMarshallingTests", "Object", "method_int8_in" + get_vfunc_introspection_data 'GIMarshallingTests', 'Object', 'method_int8_in' } - it "returns the correct FFI types including :pointer for the receiver" do + it 'returns the correct FFI types including :pointer for the receiver' do result.must_equal [:pointer, :int8] end end end - describe "#return_ffi_type" do + describe '#return_ffi_type' do let(:result) { builder.return_ffi_type } before do skip unless vfunc_info end - describe "for a vfunc returning an object" do + describe 'for a vfunc returning an object' do let(:vfunc_info) { - get_vfunc_introspection_data "GIMarshallingTests", "Object", "vfunc_return_object_transfer_full" + get_vfunc_introspection_data 'GIMarshallingTests', 'Object', 'vfunc_return_object_transfer_full' } - it "returns :pointer" do + it 'returns :pointer' do result.must_equal :pointer end end diff --git a/test/gir_ffi/callback_base_test.rb b/test/gir_ffi/callback_base_test.rb index 45c1a0426..4edc1cdb2 100644 --- a/test/gir_ffi/callback_base_test.rb +++ b/test/gir_ffi/callback_base_test.rb @@ -1,10 +1,10 @@ require 'gir_ffi_test_helper' describe GirFFI::CallbackBase do - describe ".store_callback" do - it "stores the passed in proc in CALLBACKS" do - GirFFI::CallbackBase.store_callback "some-callback" - GirFFI::CallbackBase::CALLBACKS.last.must_equal "some-callback" + describe '.store_callback' do + it 'stores the passed in proc in CALLBACKS' do + GirFFI::CallbackBase.store_callback 'some-callback' + GirFFI::CallbackBase::CALLBACKS.last.must_equal 'some-callback' end end end diff --git a/test/gir_ffi/class_base_test.rb b/test/gir_ffi/class_base_test.rb index 957672842..7a9c70fe3 100644 --- a/test/gir_ffi/class_base_test.rb +++ b/test/gir_ffi/class_base_test.rb @@ -1,7 +1,7 @@ require 'gir_ffi_test_helper' describe GirFFI::ClassBase do - describe "a simple descendant" do + describe 'a simple descendant' do let(:klass) { Class.new(GirFFI::ClassBase) do self::Struct = Class.new(FFI::Struct) do @@ -11,20 +11,20 @@ } let(:object) { klass.wrap FFI::MemoryPointer.new(:int32) } - it "has #from as a pass-through method" do + it 'has #from as a pass-through method' do result = klass.from :foo result.must_equal :foo end - describe "#==" do - it "returns true when comparing to an object of the same class and pointer" do + describe '#==' do + it 'returns true when comparing to an object of the same class and pointer' do other = klass.wrap object.to_ptr object.must_be :==, other other.must_be :==, object end - it "returns true when comparing to an object of the same class and a pointer with the same address" do + it 'returns true when comparing to an object of the same class and a pointer with the same address' do ptr = FFI::Pointer.new object.to_ptr other = klass.wrap ptr @@ -32,7 +32,7 @@ other.must_be :==, object end - it "returns false when comparing to an object of a sub/superclass and the same pointer" do + it 'returns false when comparing to an object of a sub/superclass and the same pointer' do subclass = Class.new(klass) other = subclass.wrap object.to_ptr @@ -40,7 +40,7 @@ other.wont_be :==, object end - it "returns false when comparing to an object of the same class and different pointer" do + it 'returns false when comparing to an object of the same class and different pointer' do other = klass.wrap FFI::MemoryPointer.new(:int32) object.wont_be :==, other @@ -54,14 +54,14 @@ other.wont_be :==, object end - it "returns false when comparing to an object of a different class and same pointer" do + it 'returns false when comparing to an object of a different class and same pointer' do stub(other = Object.new).to_ptr { object.to_ptr } object.wont_be :==, other other.wont_be :==, object end - it "returns false when comparing to an object of a different class and different pointer" do + it 'returns false when comparing to an object of a different class and different pointer' do stub(other = Object.new).to_ptr { FFI::MemoryPointer.new(:int32) } object.wont_be :==, other @@ -70,13 +70,13 @@ end end - describe ".setup_and_call" do - it "looks up class methods in all builders" do - mock(builder = Object.new).setup_method("foo") { "foo" } + describe '.setup_and_call' do + it 'looks up class methods in all builders' do + mock(builder = Object.new).setup_method('foo') { 'foo' } klass = Class.new GirFFI::ClassBase klass.const_set :GIR_FFI_BUILDER, builder - mock(sub_builder = Object.new).setup_method("foo") { nil } + mock(sub_builder = Object.new).setup_method('foo') { nil } sub_klass = Class.new klass do def self.foo; end end @@ -85,11 +85,11 @@ def self.foo; end sub_klass.setup_and_call :foo, [] end - it "calls the method given by the result of .setup_method" do - mock(builder = Object.new).setup_method("foo") { "bar" } + it 'calls the method given by the result of .setup_method' do + mock(builder = Object.new).setup_method('foo') { 'bar' } klass = Class.new GirFFI::ClassBase do def self.bar - "correct-result" + 'correct-result' end def self.new _real_new @@ -98,17 +98,17 @@ def self.new klass.const_set :GIR_FFI_BUILDER, builder result = klass.setup_and_call :foo, [] - result.must_equal "correct-result" + result.must_equal 'correct-result' end end - describe "#setup_and_call" do - it "looks up instance methods in all builders" do - mock(builder = Object.new).setup_instance_method("foo") { "foo" } + describe '#setup_and_call' do + it 'looks up instance methods in all builders' do + mock(builder = Object.new).setup_instance_method('foo') { 'foo' } klass = Class.new GirFFI::ClassBase klass.const_set :GIR_FFI_BUILDER, builder - mock(sub_builder = Object.new).setup_instance_method("foo") { nil } + mock(sub_builder = Object.new).setup_instance_method('foo') { nil } sub_klass = Class.new klass do def foo; end @@ -124,11 +124,11 @@ def self.new obj.setup_and_call :foo, [] end - it "calls the method given by the result of .setup_instance_method" do - mock(builder = Object.new).setup_instance_method("foo") { "bar" } + it 'calls the method given by the result of .setup_instance_method' do + mock(builder = Object.new).setup_instance_method('foo') { 'bar' } klass = Class.new GirFFI::ClassBase do def bar - "correct-result" + 'correct-result' end def self.new _real_new @@ -139,7 +139,7 @@ def self.new obj = klass.new result = obj.setup_and_call :foo, [] - result.must_equal "correct-result" + result.must_equal 'correct-result' end end end diff --git a/test/gir_ffi/error_type_info_test.rb b/test/gir_ffi/error_type_info_test.rb index ec58ab656..7b2f36d50 100644 --- a/test/gir_ffi/error_type_info_test.rb +++ b/test/gir_ffi/error_type_info_test.rb @@ -4,44 +4,44 @@ describe GirFFI::ErrorTypeInfo do let(:instance) { GirFFI::ErrorTypeInfo.new } - describe "#array_length" do - it "returns the correct value" do + describe '#array_length' do + it 'returns the correct value' do instance.array_length.must_equal(-1) end end - describe "#tag_or_class" do - it "returns the correct value" do + describe '#tag_or_class' do + it 'returns the correct value' do instance.tag_or_class.must_equal [:pointer, :error] end end - describe "#pointer?" do - it "returns the correct value" do + describe '#pointer?' do + it 'returns the correct value' do instance.pointer?.must_equal true end end - describe "#flattened_tag" do - it "returns the correct value" do + describe '#flattened_tag' do + it 'returns the correct value' do instance.flattened_tag.must_equal :error end end - describe "#extra_conversion_arguments" do - it "returns the correct value" do + describe '#extra_conversion_arguments' do + it 'returns the correct value' do instance.extra_conversion_arguments.must_equal [] end end - describe "#argument_class_name" do - it "returns the correct value" do + describe '#argument_class_name' do + it 'returns the correct value' do instance.argument_class_name.must_equal 'GLib::Error' end end - describe "#needs_ruby_to_c_conversion_for_callbacks?" do - it "returns the correct value" do + describe '#needs_ruby_to_c_conversion_for_callbacks?' do + it 'returns the correct value' do instance.needs_ruby_to_c_conversion_for_callbacks?.must_equal true end end diff --git a/test/gir_ffi/ffi_ext/pointer_test.rb b/test/gir_ffi/ffi_ext/pointer_test.rb index 5d386b6fb..b28267daf 100644 --- a/test/gir_ffi/ffi_ext/pointer_test.rb +++ b/test/gir_ffi/ffi_ext/pointer_test.rb @@ -2,17 +2,17 @@ describe GirFFI::FFIExt::Pointer do let(:klass) { Class.new { include GirFFI::FFIExt::Pointer } } - describe "#to_object" do - it "finds the wrapping class by gtype and wraps the pointer in it" do + describe '#to_object' do + it 'finds the wrapping class by gtype and wraps the pointer in it' do ptr = klass.new mock(ptr).null? { false } object_class = Class.new mock(GObject).type_from_instance_pointer(ptr) { 0xdeadbeef } mock(GirFFI::Builder).build_by_gtype(0xdeadbeef) { object_class } - mock(object_class).direct_wrap(ptr) { "good-result" } + mock(object_class).direct_wrap(ptr) { 'good-result' } - ptr.to_object.must_equal "good-result" + ptr.to_object.must_equal 'good-result' end end end diff --git a/test/gir_ffi/g_type_test.rb b/test/gir_ffi/g_type_test.rb index f4236611a..8e2bec810 100644 --- a/test/gir_ffi/g_type_test.rb +++ b/test/gir_ffi/g_type_test.rb @@ -6,22 +6,22 @@ let(:gobject_gtype) { GObject::Object.get_gtype } let(:gobject_type_query) { GObject.type_query gobject_gtype } - describe "#to_i" do - it "returns the integer gtype" do + describe '#to_i' do + it 'returns the integer gtype' do gt = GirFFI::GType.new(gobject_gtype) gt.to_i.must_equal gobject_gtype end end - describe "#class_size" do - it "returns the class size for object types" do + describe '#class_size' do + it 'returns the class size for object types' do gt = GirFFI::GType.new(gobject_gtype) gt.class_size.must_equal gobject_type_query.class_size end end - describe "#instance_size" do - it "returns the instance size for object types" do + describe '#instance_size' do + it 'returns the instance size for object types' do gt = GirFFI::GType.new(gobject_gtype) gt.instance_size.must_equal gobject_type_query.instance_size end diff --git a/test/gir_ffi/in_out_pointer_test.rb b/test/gir_ffi/in_out_pointer_test.rb index b9808b6a4..b6fb2c8f2 100644 --- a/test/gir_ffi/in_out_pointer_test.rb +++ b/test/gir_ffi/in_out_pointer_test.rb @@ -1,8 +1,8 @@ require 'gir_ffi_test_helper' describe GirFFI::InOutPointer do - describe ".new" do - it "wraps an existing pointer and a type" do + describe '.new' do + it 'wraps an existing pointer and a type' do ptr = GirFFI::AllocationHelper.safe_malloc(FFI.type_size(:int32)) ptr.put_int32 0, 42 instance = GirFFI::InOutPointer.new :gint32, ptr @@ -10,89 +10,89 @@ end end - describe "an instance created with .from" do + describe 'an instance created with .from' do before do @result = GirFFI::InOutPointer.from :gint32, 23 end - it "holds a pointer to the given value" do + it 'holds a pointer to the given value' do assert_equal 23, @result.get_int32(0) end - it "is an instance of GirFFI::InOutPointer" do + it 'is an instance of GirFFI::InOutPointer' do assert_instance_of GirFFI::InOutPointer, @result end end - describe ".from" do - it "handles :gboolean false" do + describe '.from' do + it 'handles :gboolean false' do ptr = GirFFI::InOutPointer.from :gboolean, false ptr.read_int.must_equal 0 end - it "handles :gboolean true" do + it 'handles :gboolean true' do ptr = GirFFI::InOutPointer.from :gboolean, true ptr.read_int.must_equal(1) end - it "handles :utf8 pointers" do - str_ptr = GirFFI::InPointer.from :utf8, "Hello" + it 'handles :utf8 pointers' do + str_ptr = GirFFI::InPointer.from :utf8, 'Hello' GirFFI::InOutPointer.from :utf8, str_ptr end end - describe "in instance created with .for" do + describe 'in instance created with .for' do before do @result = GirFFI::InOutPointer.for :gint32 end - it "holds a pointer to a null value" do + it 'holds a pointer to a null value' do assert_equal 0, @result.get_int32(0) end - it "is an instance of GirFFI::InOutPointer" do + it 'is an instance of GirFFI::InOutPointer' do assert_instance_of GirFFI::InOutPointer, @result end end - describe ".for" do - it "handles :gboolean" do + describe '.for' do + it 'handles :gboolean' do GirFFI::InOutPointer.for :gboolean end - it "handles :utf8" do + it 'handles :utf8' do GirFFI::InOutPointer.for :utf8 end end - describe "#to_value" do - it "returns the held value" do + describe '#to_value' do + it 'returns the held value' do ptr = GirFFI::InOutPointer.from :gint32, 123 assert_equal 123, ptr.to_value end - describe "for :gboolean values" do - it "works when the value is false" do + describe 'for :gboolean values' do + it 'works when the value is false' do ptr = GirFFI::InOutPointer.from :gboolean, false ptr.to_value.must_equal false end - it "works when the value is true" do + it 'works when the value is true' do ptr = GirFFI::InOutPointer.from :gboolean, true ptr.to_value.must_equal true end end - describe "for :utf8 values" do - it "returns a pointer to the held value" do - str_ptr = GirFFI::InPointer.from :utf8, "Some value" + describe 'for :utf8 values' do + it 'returns a pointer to the held value' do + str_ptr = GirFFI::InPointer.from :utf8, 'Some value' ptr = GirFFI::InOutPointer.from :utf8, str_ptr - assert_equal "Some value", ptr.to_value.read_string + assert_equal 'Some value', ptr.to_value.read_string end end - describe "for struct values" do - it "returns a pointer to the held value" do + describe 'for struct values' do + it 'returns a pointer to the held value' do val = GObject::EnumValue.new val.value = 3 ptr = GirFFI::InOutPointer.from GObject::EnumValue, val diff --git a/test/gir_ffi/in_pointer_test.rb b/test/gir_ffi/in_pointer_test.rb index f782b6c44..e1e2e7fe5 100644 --- a/test/gir_ffi/in_pointer_test.rb +++ b/test/gir_ffi/in_pointer_test.rb @@ -3,17 +3,17 @@ require 'gir_ffi/in_pointer' describe GirFFI::InPointer do - describe ".from_array" do - it "returns nil when passed nil" do + describe '.from_array' do + it 'returns nil when passed nil' do result = GirFFI::InPointer.from_array :gint32, nil assert_nil result end - it "handles type tag :GType" do + it 'handles type tag :GType' do GirFFI::InPointer.from_array :GType, [2] end - it "handles enum types" do + it 'handles enum types' do e = Module.new do extend GirFFI::EnumBase self::Enum = FFI::Enum.new [:foo, :bar, :baz] @@ -22,7 +22,7 @@ ptr.read_array_of_int32(3).must_equal [1, 0, 2] end - it "handles struct types" do + it 'handles struct types' do e = Class.new(GirFFI::StructBase) do self::Struct = Class.new(FFI::Struct) do layout :foo, :int32, :bar, :int32 @@ -38,7 +38,7 @@ new_struct[:bar].must_equal 24 end - it "handles typed pointers" do + it 'handles typed pointers' do p1 = GirFFI::InPointer.from :gint32, 42 p2 = GirFFI::InPointer.from :gint32, 24 @@ -47,94 +47,94 @@ ptr.read_array_of_pointer(2).must_equal [p1, p2] end - it "handles pointer casting" do + it 'handles pointer casting' do ptr = GirFFI::InPointer.from_array [:pointer, :gint32], [42, 24] ptr.read_array_of_pointer(2).map(&:address).must_equal [42, 24] end end - describe "an instance created with .from_array :gint32" do + describe 'an instance created with .from_array :gint32' do before do @result = GirFFI::InPointer.from_array :gint32, [24, 13] end - it "holds a pointer to the correct input values" do + it 'holds a pointer to the correct input values' do assert_equal 24, @result.get_int(0) assert_equal 13, @result.get_int(4) end - it "is an instance of GirFFI::InPointer" do + it 'is an instance of GirFFI::InPointer' do assert_instance_of GirFFI::InPointer, @result end - it "is zero-terminated" do + it 'is zero-terminated' do assert_equal 0, @result.get_int(8) end end - describe "an instance created with .from_array :utf8" do + describe 'an instance created with .from_array :utf8' do before do @result = GirFFI::InPointer.from_array :utf8, %w(foo bar baz) end - it "returns an array of pointers to strings" do + it 'returns an array of pointers to strings' do ary = @result.read_array_of_pointer(3) assert_equal %w(foo bar baz), ary.map(&:read_string) end end - describe "an instance created with .from_array :filename" do + describe 'an instance created with .from_array :filename' do before do @result = GirFFI::InPointer.from_array :filename, %w(foo bar baz) end - it "returns an array of pointers to strings" do + it 'returns an array of pointers to strings' do ary = @result.read_array_of_pointer(3) assert_equal %w(foo bar baz), ary.map(&:read_string) end end - describe "an instance created with .from :utf8" do + describe 'an instance created with .from :utf8' do before do - @result = GirFFI::InPointer.from :utf8, "foo" + @result = GirFFI::InPointer.from :utf8, 'foo' end - it "returns a pointer to the given string" do - assert_equal "foo", @result.read_string + it 'returns a pointer to the given string' do + assert_equal 'foo', @result.read_string end - it "is an instance of GirFFI::InPointer" do + it 'is an instance of GirFFI::InPointer' do assert_instance_of GirFFI::InPointer, @result end end - describe "an instance created with .from :guint32" do + describe 'an instance created with .from :guint32' do before do @result = GirFFI::InPointer.from :guint32, 12_345 end - it "returns a pointer with an address equal to the given value" do + it 'returns a pointer with an address equal to the given value' do assert_equal 12_345, @result.address end - it "is an instance of GirFFI::InPointer" do + it 'is an instance of GirFFI::InPointer' do assert_instance_of GirFFI::InPointer, @result end end - describe "an instance created with .from :filename" do + describe 'an instance created with .from :filename' do before do - @result = GirFFI::InPointer.from :filename, "foo" + @result = GirFFI::InPointer.from :filename, 'foo' end - it "returns a pointer to the given string" do - assert_equal "foo", @result.read_string + it 'returns a pointer to the given string' do + assert_equal 'foo', @result.read_string end end - describe ".from" do - it "returns nil when passed nil" do + describe '.from' do + it 'returns nil when passed nil' do result = GirFFI::InPointer.from :foo, nil assert_nil result end @@ -144,7 +144,7 @@ assert_equal 23, result.address end - it "handles enum types" do + it 'handles enum types' do e = Module.new do self::Enum = FFI::Enum.new [:foo, :bar, :baz] def self.[] val @@ -155,8 +155,8 @@ def self.[] val ptr.address.must_equal 1 end - describe "for type :void" do - it "returns the result of to_ptr" do + describe 'for type :void' do + it 'returns the result of to_ptr' do obj = Object.new def obj.to_ptr :test_value @@ -164,13 +164,13 @@ def obj.to_ptr GirFFI::InPointer.from(:void, obj).must_equal :test_value end - it "returns nil when passed nil" do + it 'returns nil when passed nil' do GirFFI::InPointer.from(:void, nil).must_equal nil end end - describe "for types that are classes" do - it "returns the result of to_ptr" do + describe 'for types that are classes' do + it 'returns the result of to_ptr' do klass = Class.new obj = klass.new def obj.to_ptr @@ -181,16 +181,16 @@ def obj.to_ptr end end - describe ".from_closure_data" do - describe "when called with nil" do - it "returns a pointer pointing to nil.object_id" do + describe '.from_closure_data' do + describe 'when called with nil' do + it 'returns a pointer pointing to nil.object_id' do GirFFI::InPointer.from_closure_data(nil).address.must_equal nil.object_id end end - describe "when called with a string" do - it "stores the string in GirFFI::ArgHelper::OBJECT_STORE" do - str = "Foo" + describe 'when called with a string' do + it 'stores the string in GirFFI::ArgHelper::OBJECT_STORE' do + str = 'Foo' ptr = GirFFI::InPointer.from_closure_data(str) result = GirFFI::ArgHelper::OBJECT_STORE.fetch(ptr) result.must_equal str diff --git a/test/gir_ffi/info_ext/i_callable_info_test.rb b/test/gir_ffi/info_ext/i_callable_info_test.rb index 0dff3d57a..307f1a622 100644 --- a/test/gir_ffi/info_ext/i_callable_info_test.rb +++ b/test/gir_ffi/info_ext/i_callable_info_test.rb @@ -8,15 +8,15 @@ } let(:callable_info) { klass.new } - describe "#argument_ffi_types" do - describe "for a simple callable with several arguments" do + describe '#argument_ffi_types' do + describe 'for a simple callable with several arguments' do before do stub(arg_info1 = Object.new).to_ffitype { :type1 } stub(arg_info2 = Object.new).to_ffitype { :type2 } stub(callable_info).args { [arg_info1, arg_info2] } end - it "returns the ffi types of the arguments" do + it 'returns the ffi types of the arguments' do callable_info.argument_ffi_types.must_equal [:type1, :type2] end end diff --git a/test/gir_ffi/info_ext/i_callback_info_test.rb b/test/gir_ffi/info_ext/i_callback_info_test.rb index 5f83542a3..158152a33 100644 --- a/test/gir_ffi/info_ext/i_callback_info_test.rb +++ b/test/gir_ffi/info_ext/i_callback_info_test.rb @@ -8,8 +8,8 @@ } let(:callback_info) { klass.new } - describe "#return_ffi_type" do - it "returns the callback ffi type of the return type" do + describe '#return_ffi_type' do + it 'returns the callback ffi type of the return type' do stub(return_type_info = Object.new).to_callback_ffitype { :some_type } stub(callback_info).return_type { return_type_info } diff --git a/test/gir_ffi/info_ext/i_field_info_test.rb b/test/gir_ffi/info_ext/i_field_info_test.rb index 11d0036aa..b36df2261 100644 --- a/test/gir_ffi/info_ext/i_field_info_test.rb +++ b/test/gir_ffi/info_ext/i_field_info_test.rb @@ -7,11 +7,11 @@ end } let(:field_info) { klass.new } - describe "#layout_specification" do - it "returns an array of name, typespec and offset" do + describe '#layout_specification' do + it 'returns an array of name, typespec and offset' do mock(type = Object.new).to_ffitype { :bar } - mock(field_info).name { "foo" } + mock(field_info).name { 'foo' } mock(field_info).field_type { type } mock(field_info).offset { 0 } @@ -20,10 +20,10 @@ assert_equal [:foo, :bar, 0], result end - it "keeps a complex typespec intact" do + it 'keeps a complex typespec intact' do mock(type = Object.new).to_ffitype { [:bar, 2] } - mock(field_info).name { "foo" } + mock(field_info).name { 'foo' } mock(field_info).field_type { type } mock(field_info).offset { 0 } diff --git a/test/gir_ffi/info_ext/i_function_info_test.rb b/test/gir_ffi/info_ext/i_function_info_test.rb index 415830c12..d2fea0a48 100644 --- a/test/gir_ffi/info_ext/i_function_info_test.rb +++ b/test/gir_ffi/info_ext/i_function_info_test.rb @@ -9,60 +9,60 @@ } let(:function_info) { klass.new } - describe "#argument_ffi_types" do + describe '#argument_ffi_types' do before do stub(arg_info1 = Object.new).to_ffitype { :type1 } stub(arg_info2 = Object.new).to_ffitype { :type2 } stub(function_info).args { [arg_info1, arg_info2] } end - describe "for a simple function with several arguments" do + describe 'for a simple function with several arguments' do before do stub(function_info).method? { false } stub(function_info).throws? { false } end - it "returns the ffi types of the arguments" do + it 'returns the ffi types of the arguments' do function_info.argument_ffi_types.must_equal [:type1, :type2] end end - describe "for a throwing function with several arguments" do + describe 'for a throwing function with several arguments' do before do stub(function_info).method? { false } stub(function_info).throws? { true } end - it "appends :pointer to represent the error argument" do + it 'appends :pointer to represent the error argument' do function_info.argument_ffi_types.must_equal [:type1, :type2, :pointer] end end - describe "for a method with several arguments" do + describe 'for a method with several arguments' do before do stub(function_info).method? { true } stub(function_info).throws? { false } end - it "prepends :pointer to represent the method reciever" do + it 'prepends :pointer to represent the method reciever' do function_info.argument_ffi_types.must_equal [:pointer, :type1, :type2] end end - describe "for a throwing method with several arguments" do + describe 'for a throwing method with several arguments' do before do stub(function_info).method? { true } stub(function_info).throws? { true } end - it "adds :pointer for both the reciever and the error argument" do + it 'adds :pointer for both the reciever and the error argument' do function_info.argument_ffi_types.must_equal [:pointer, :type1, :type2, :pointer] end end end - describe "#return_ffi_type" do - it "returns the ffi type of the return type" do + describe '#return_ffi_type' do + it 'returns the ffi type of the return type' do stub(return_type_info = Object.new).to_ffitype { :some_type } stub(function_info).return_type { return_type_info } diff --git a/test/gir_ffi/info_ext/i_signal_info_test.rb b/test/gir_ffi/info_ext/i_signal_info_test.rb index d0ee84855..c98b15bca 100644 --- a/test/gir_ffi/info_ext/i_signal_info_test.rb +++ b/test/gir_ffi/info_ext/i_signal_info_test.rb @@ -11,17 +11,17 @@ } let(:signal_info) { klass.new } - describe "#arguments_to_gvalues" do + describe '#arguments_to_gvalues' do let(:object) { Regress::TestSubObj.new } let(:boxed) { Regress::TestSimpleBoxedA.const_return } - let(:signal_info) { Regress::TestSubObj.find_signal "test-with-static-scope-arg" } + let(:signal_info) { Regress::TestSubObj.find_signal 'test-with-static-scope-arg' } let(:result) { signal_info.arguments_to_gvalues(object, [boxed]) } - it "correctly wraps :object" do + it 'correctly wraps :object' do result[0].get_value.must_equal object end - it "correctly wraps :struct" do + it 'correctly wraps :struct' do result_boxed = result[1].get_value result_boxed.some_int8.must_equal boxed.some_int8 result_boxed.some_int.must_equal boxed.some_int diff --git a/test/gir_ffi/info_ext/i_type_info_test.rb b/test/gir_ffi/info_ext/i_type_info_test.rb index f6f719e55..c014b23eb 100644 --- a/test/gir_ffi/info_ext/i_type_info_test.rb +++ b/test/gir_ffi/info_ext/i_type_info_test.rb @@ -21,8 +21,8 @@ 'test_ghash_nested_everything_return').return_type } - describe "#to_ffitype" do - it "returns an array with elements subtype and size for type :array" do + describe '#to_ffitype' do + it 'returns an array with elements subtype and size for type :array' do mock(type_info).pointer? { false } stub(type_info).tag { :array } mock(type_info).array_fixed_size { 2 } @@ -34,7 +34,7 @@ assert_equal [:foo, 2], result end - describe "for an :interface type" do + describe 'for an :interface type' do before do stub(type_info).interface { iface_info } stub(type_info).tag { :interface } @@ -49,8 +49,8 @@ end end - describe "#element_type" do - it "returns the element type for lists" do + describe '#element_type' do + it 'returns the element type for lists' do stub(elmtype_info).tag { :foo } mock(elmtype_info).pointer? { false } @@ -61,7 +61,7 @@ result.must_equal :foo end - it "returns the key and value types for ghashes" do + it 'returns the key and value types for ghashes' do stub(keytype_info).tag { :foo } mock(keytype_info).pointer? { false } stub(valtype_info).tag { :bar } @@ -75,14 +75,14 @@ result.must_equal [:foo, :bar] end - it "returns nil for other types" do + it 'returns nil for other types' do mock(type_info).tag { :foo } result = type_info.element_type result.must_be_nil end - it "returns [:pointer, :void] if the element type is a pointer with tag :void" do + it 'returns [:pointer, :void] if the element type is a pointer with tag :void' do stub(elmtype_info).tag_or_class { [:pointer, :void] } mock(type_info).tag { :glist } @@ -92,24 +92,24 @@ end end - describe "#flattened_tag" do - describe "for a simple type" do - it "returns the type tag" do + describe '#flattened_tag' do + describe 'for a simple type' do + it 'returns the type tag' do stub(type_info).tag { :uint32 } type_info.flattened_tag.must_equal :uint32 end end - describe "for a zero-terminated array" do + describe 'for a zero-terminated array' do before do stub(type_info).tag { :array } stub(type_info).param_type(0) { elmtype_info } stub(type_info).zero_terminated? { true } end - describe "of utf8" do - it "returns :strv" do + describe 'of utf8' do + it 'returns :strv' do stub(elmtype_info).tag { :utf8 } stub(elmtype_info).pointer? { true } @@ -117,8 +117,8 @@ end end - describe "of filename" do - it "returns :strv" do + describe 'of filename' do + it 'returns :strv' do stub(elmtype_info).tag { :filename } stub(elmtype_info).pointer? { true } @@ -126,8 +126,8 @@ end end - describe "of another type" do - it "returns :zero_terminated" do + describe 'of another type' do + it 'returns :zero_terminated' do stub(elmtype_info).tag { :foo } stub(elmtype_info).pointer? { false } @@ -136,8 +136,8 @@ end end - describe "for a fixed length c-like array" do - it "returns :c" do + describe 'for a fixed length c-like array' do + it 'returns :c' do mock(type_info).tag { :array } mock(type_info).zero_terminated? { false } mock(type_info).array_type { :c } @@ -146,8 +146,8 @@ end end - describe "for a GLib array" do - it "returns :c" do + describe 'for a GLib array' do + it 'returns :c' do mock(type_info).tag { :array } mock(type_info).zero_terminated? { false } mock(type_info).array_type { :array } @@ -157,8 +157,8 @@ end end - describe "#tag_or_class" do - describe "for a simple type" do + describe '#tag_or_class' do + describe 'for a simple type' do it "returns the type's tag" do stub(type_info).tag { :foo } mock(type_info).pointer? { false } @@ -167,8 +167,8 @@ end end - describe "for utf8 strings" do - it "returns the tag :utf8" do + describe 'for utf8 strings' do + it 'returns the tag :utf8' do stub(type_info).tag { :utf8 } mock(type_info).pointer? { true } @@ -176,8 +176,8 @@ end end - describe "for filename strings" do - it "returns the tag :filename" do + describe 'for filename strings' do + it 'returns the tag :filename' do stub(type_info).tag { :filename } mock(type_info).pointer? { true } @@ -185,7 +185,7 @@ end end - describe "for an interface class" do + describe 'for an interface class' do let(:interface) { Object.new } before do @@ -196,24 +196,24 @@ mock(GirFFI::Builder).build_class(iface_info) { interface } end - describe "when the interface type is :enum" do - it "returns the built interface module" do + describe 'when the interface type is :enum' do + it 'returns the built interface module' do stub(iface_info).info_type { :enum } type_info.tag_or_class.must_equal interface end end - describe "when the interface type is :object" do - it "returns the built interface class" do + describe 'when the interface type is :object' do + it 'returns the built interface class' do stub(iface_info).info_type { :object } type_info.tag_or_class.must_equal interface end end - describe "when the interface type is :struct" do - it "returns the built interface class" do + describe 'when the interface type is :struct' do + it 'returns the built interface class' do stub(iface_info).info_type { :struct } type_info.tag_or_class.must_equal interface @@ -222,14 +222,14 @@ end - describe "for a callback" do + describe 'for a callback' do it "returns the callback's wrapper class" do callback_type_info.tag_or_class.must_equal Regress::TestCallback end end - describe "for a pointer to simple type :foo" do - it "returns [:pointer, :foo]" do + describe 'for a pointer to simple type :foo' do + it 'returns [:pointer, :foo]' do stub(type_info).tag { :foo } mock(type_info).pointer? { true } @@ -237,8 +237,8 @@ end end - describe "for a pointer to :void" do - it "returns [:pointer, :void]" do + describe 'for a pointer to :void' do + it 'returns [:pointer, :void]' do stub(type_info).tag { :void } stub(type_info).pointer? { true } @@ -246,8 +246,8 @@ end end - describe "for a complex nested hash type" do - it "returns a representeation of the nested structure" do + describe 'for a complex nested hash type' do + it 'returns a representeation of the nested structure' do ghash_type_info.tag_or_class.must_equal( [:pointer, [:ghash, @@ -258,21 +258,21 @@ end end - describe "#to_callback_ffitype" do - describe "for an :interface argument" do + describe '#to_callback_ffitype' do + describe 'for an :interface argument' do before do stub(type_info).interface { iface_info } stub(type_info).tag { :interface } stub(type_info).pointer? { false } end - it "correctly maps a :union argument to :pointer" do + it 'correctly maps a :union argument to :pointer' do stub(iface_info).info_type { :union } type_info.to_callback_ffitype.must_equal :pointer end - it "correctly maps a :flags argument to :int32" do + it 'correctly maps a :flags argument to :int32' do stub(iface_info).info_type { :flags } type_info.to_callback_ffitype.must_equal :int32 @@ -280,28 +280,28 @@ end end - describe "#extra_conversion_arguments" do - describe "for normal types" do + describe '#extra_conversion_arguments' do + describe 'for normal types' do before do stub(type_info).tag { :foo } end - it "returns an empty array" do + it 'returns an empty array' do type_info.extra_conversion_arguments.must_equal [] end end - describe "for a string" do + describe 'for a string' do before do stub(type_info).tag { :utf8 } end - it "returns an array containing :utf8" do + it 'returns an array containing :utf8' do type_info.extra_conversion_arguments.must_equal [:utf8] end end - describe "for a fixed-size array" do + describe 'for a fixed-size array' do before do stub(type_info).tag { :array } stub(type_info).zero_terminated? { false } @@ -312,12 +312,12 @@ stub(elmtype_info).tag_or_class { :foo } end - it "returns an array containing the element type" do + it 'returns an array containing the element type' do type_info.extra_conversion_arguments.must_equal [:foo, 3] end end - describe "for a zero-terminated array" do + describe 'for a zero-terminated array' do before do stub(type_info).tag { :array } stub(type_info).zero_terminated? { true } @@ -326,12 +326,12 @@ stub(elmtype_info).tag_or_class { :foo } end - it "returns an array containing the element type" do + it 'returns an array containing the element type' do type_info.extra_conversion_arguments.must_equal [:foo] end end - describe "for a GArray" do + describe 'for a GArray' do before do stub(type_info).tag { :array } stub(type_info).zero_terminated? { false } @@ -341,12 +341,12 @@ stub(elmtype_info).tag_or_class { :foo } end - it "returns an array containing the element type" do + it 'returns an array containing the element type' do type_info.extra_conversion_arguments.must_equal [:foo] end end - describe "for a GHashTable" do + describe 'for a GHashTable' do before do stub(type_info).tag { :ghash } stub(type_info).param_type(0) { keytype_info } @@ -356,12 +356,12 @@ stub(valtype_info).tag_or_class { :bar } end - it "returns an array containing the element type pair" do + it 'returns an array containing the element type pair' do type_info.extra_conversion_arguments.must_equal [[:foo, :bar]] end end - describe "for a GList" do + describe 'for a GList' do before do stub(type_info).tag { :glist } @@ -369,12 +369,12 @@ stub(elmtype_info).tag_or_class { :foo } end - it "returns an array containing the element type" do + it 'returns an array containing the element type' do type_info.extra_conversion_arguments.must_equal [:foo] end end - describe "for a GSList" do + describe 'for a GSList' do before do stub(type_info).tag { :gslist } @@ -382,12 +382,12 @@ stub(elmtype_info).tag_or_class { :foo } end - it "returns an array containing the element type" do + it 'returns an array containing the element type' do type_info.extra_conversion_arguments.must_equal [:foo] end end - describe "for a GPtrArray" do + describe 'for a GPtrArray' do before do stub(type_info).tag { :array } stub(type_info).zero_terminated? { false } @@ -397,40 +397,40 @@ stub(elmtype_info).tag_or_class { :foo } end - it "returns an array containing the element type" do + it 'returns an array containing the element type' do type_info.extra_conversion_arguments.must_equal [:foo] end end - describe "for a :callback" do + describe 'for a :callback' do before do - stub(interface_type_info = Object.new).namespace { "Bar" } - stub(interface_type_info).name { "Foo" } + stub(interface_type_info = Object.new).namespace { 'Bar' } + stub(interface_type_info).name { 'Foo' } stub(type_info).tag { :callback } stub(type_info).interface { interface_type_info } end - it "returns an empty array" do + it 'returns an empty array' do type_info.extra_conversion_arguments.must_equal [] end end end - describe "#argument_class_name" do + describe '#argument_class_name' do before do stub(type_info).tag { tag } end - describe "for :gint32" do + describe 'for :gint32' do let(:tag) { :gint32 } - it "is nil" do + it 'is nil' do type_info.argument_class_name.must_be_nil end end - describe "for interfaces" do + describe 'for interfaces' do let(:tag) { :interface } before do @@ -439,253 +439,253 @@ stub(iface_info).full_type_name { 'Bar::Foo' } end - describe "for :struct" do + describe 'for :struct' do let(:interface_type) { :struct } - it "equals the struct class name" do + it 'equals the struct class name' do type_info.argument_class_name.must_equal 'Bar::Foo' end end - describe "for :union" do + describe 'for :union' do let(:interface_type) { :union } - it "equals the union class name" do + it 'equals the union class name' do type_info.argument_class_name.must_equal 'Bar::Foo' end end - describe "for :interface" do + describe 'for :interface' do let(:interface_type) { :interface } - it "equals the interface module name" do + it 'equals the interface module name' do type_info.argument_class_name.must_equal 'Bar::Foo' end end - describe "for :object" do + describe 'for :object' do let(:interface_type) { :object } - it "equals the object class name" do + it 'equals the object class name' do type_info.argument_class_name.must_equal 'Bar::Foo' end end - describe "for :callback" do + describe 'for :callback' do let(:interface_type) { :callback } - it "equals the callback type name" do + it 'equals the callback type name' do type_info.argument_class_name.must_equal 'Bar::Foo' end end end - describe "for :strv" do + describe 'for :strv' do let(:tag) { :strv } - it "equals GLib::Strv" do + it 'equals GLib::Strv' do type_info.argument_class_name.must_equal 'GLib::Strv' end end - describe "for arrays" do + describe 'for arrays' do let(:tag) { :array } before do stub(type_info).param_type(0) { elmtype_info } stub(elmtype_info).tag_or_class { :foo } end - describe "for :zero_terminated" do + describe 'for :zero_terminated' do before do stub(type_info).zero_terminated? { true } end - it "equals GirFFI::ZeroTerminated" do - type_info.argument_class_name.must_equal "GirFFI::ZeroTerminated" + it 'equals GirFFI::ZeroTerminated' do + type_info.argument_class_name.must_equal 'GirFFI::ZeroTerminated' end end - describe "for :byte_array" do + describe 'for :byte_array' do before do stub(type_info).zero_terminated? { false } stub(type_info).array_type { :byte_array } end - it "equals GLib::ByteArray" do + it 'equals GLib::ByteArray' do type_info.argument_class_name.must_equal 'GLib::ByteArray' end end - describe "for :ptr_array" do + describe 'for :ptr_array' do before do stub(type_info).zero_terminated? { false } stub(type_info).array_type { :ptr_array } end - it "equals GLib::PtrArray" do + it 'equals GLib::PtrArray' do type_info.argument_class_name.must_equal 'GLib::PtrArray' end end - describe "for :array" do + describe 'for :array' do before do stub(type_info).zero_terminated? { false } stub(type_info).array_type { :array } end - it "equals GLib::Array" do + it 'equals GLib::Array' do type_info.argument_class_name.must_equal 'GLib::Array' end end end - describe "for :glist" do + describe 'for :glist' do let(:tag) { :glist } - it "equals GLib::List" do + it 'equals GLib::List' do type_info.argument_class_name.must_equal 'GLib::List' end end - describe "for :gslist" do + describe 'for :gslist' do let(:tag) { :gslist } - it "equals GLib::SList" do + it 'equals GLib::SList' do type_info.argument_class_name.must_equal 'GLib::SList' end end - describe "for :ghash" do + describe 'for :ghash' do let(:tag) { :ghash } - it "equals GLib::HashTable" do + it 'equals GLib::HashTable' do type_info.argument_class_name.must_equal 'GLib::HashTable' end end - describe "for :error" do + describe 'for :error' do let(:tag) { :error } - it "equals GLib::Error" do + it 'equals GLib::Error' do type_info.argument_class_name.must_equal 'GLib::Error' end end end - describe "#g_type" do + describe '#g_type' do before do stub(type_info).tag { tag } stub(type_info).pointer? { pointer? } end - describe "for :void" do + describe 'for :void' do let(:tag) { :void } let(:pointer?) { false } - it "equals the none type" do - GObject.type_name(type_info.g_type).must_equal "void" + it 'equals the none type' do + GObject.type_name(type_info.g_type).must_equal 'void' end end - describe "for :gboolean" do + describe 'for :gboolean' do let(:tag) { :gboolean } let(:pointer?) { false } - it "equals the gboolean type" do - GObject.type_name(type_info.g_type).must_equal "gboolean" + it 'equals the gboolean type' do + GObject.type_name(type_info.g_type).must_equal 'gboolean' end end - describe "for :gint32" do + describe 'for :gint32' do let(:tag) { :gint32 } let(:pointer?) { false } - it "equals the gint type" do - GObject.type_name(type_info.g_type).must_equal "gint" + it 'equals the gint type' do + GObject.type_name(type_info.g_type).must_equal 'gint' end end - describe "for :gint64" do + describe 'for :gint64' do let(:tag) { :gint64 } let(:pointer?) { false } - it "equals the gint64 type" do - GObject.type_name(type_info.g_type).must_equal "gint64" + it 'equals the gint64 type' do + GObject.type_name(type_info.g_type).must_equal 'gint64' end end - describe "for :guint64" do + describe 'for :guint64' do let(:tag) { :guint64 } let(:pointer?) { false } - it "equals the guint64 type" do - GObject.type_name(type_info.g_type).must_equal "guint64" + it 'equals the guint64 type' do + GObject.type_name(type_info.g_type).must_equal 'guint64' end end - describe "for pointer to :utf8" do + describe 'for pointer to :utf8' do let(:tag) { :utf8 } let(:pointer?) { true } - it "equals the gchararray type" do - GObject.type_name(type_info.g_type).must_equal "gchararray" + it 'equals the gchararray type' do + GObject.type_name(type_info.g_type).must_equal 'gchararray' end end - describe "for pointer to :ghash" do + describe 'for pointer to :ghash' do let(:tag) { :ghash } let(:pointer?) { true } - it "equals the GHashTable type" do - GObject.type_name(type_info.g_type).must_equal "GHashTable" + it 'equals the GHashTable type' do + GObject.type_name(type_info.g_type).must_equal 'GHashTable' end end - describe "for arrays" do + describe 'for arrays' do let(:tag) { :array } let(:pointer?) { true } - describe "for pointer to GArray" do + describe 'for pointer to GArray' do before do stub(type_info).zero_terminated? { false } stub(type_info).array_type { :array } end - it "equals the GArray type" do - GObject.type_name(type_info.g_type).must_equal "GArray" + it 'equals the GArray type' do + GObject.type_name(type_info.g_type).must_equal 'GArray' end end - describe "for a C array" do + describe 'for a C array' do before do stub(type_info).zero_terminated? { false } stub(type_info).array_type { :c } end - it "equals the gpointer type" do - GObject.type_name(type_info.g_type).must_equal "gpointer" + it 'equals the gpointer type' do + GObject.type_name(type_info.g_type).must_equal 'gpointer' end end - describe "for a zero-terminated array" do + describe 'for a zero-terminated array' do before do stub(type_info).param_type(0) { elmtype_info } stub(type_info).zero_terminated? { true } end - describe "of utf8" do - it "equals the GStrv type" do + describe 'of utf8' do + it 'equals the GStrv type' do stub(elmtype_info).tag { :utf8 } stub(elmtype_info).pointer? { true } - GObject.type_name(type_info.g_type).must_equal "GStrv" + GObject.type_name(type_info.g_type).must_equal 'GStrv' end end - describe "of filename" do - it "equals the GStrv type" do + describe 'of filename' do + it 'equals the GStrv type' do stub(elmtype_info).tag { :filename } stub(elmtype_info).pointer? { true } - GObject.type_name(type_info.g_type).must_equal "GStrv" + GObject.type_name(type_info.g_type).must_equal 'GStrv' end end end diff --git a/test/gir_ffi/info_ext/i_unresolved_info_test.rb b/test/gir_ffi/info_ext/i_unresolved_info_test.rb index 87cd93371..90f76a565 100644 --- a/test/gir_ffi/info_ext/i_unresolved_info_test.rb +++ b/test/gir_ffi/info_ext/i_unresolved_info_test.rb @@ -9,8 +9,8 @@ let(:unresolved_info) { klass.new } - describe "#to_ffitype" do - it "returns the most generic type" do + describe '#to_ffitype' do + it 'returns the most generic type' do unresolved_info.to_ffitype.must_equal :pointer end end diff --git a/test/gir_ffi/info_ext/safe_constant_name_test.rb b/test/gir_ffi/info_ext/safe_constant_name_test.rb index 53124e064..1c2251e3f 100644 --- a/test/gir_ffi/info_ext/safe_constant_name_test.rb +++ b/test/gir_ffi/info_ext/safe_constant_name_test.rb @@ -8,17 +8,17 @@ } let(:info) { klass.new } - describe "#safe_name" do - it "makes names starting with an underscore safe" do - mock(info).name { "_foo" } + describe '#safe_name' do + it 'makes names starting with an underscore safe' do + mock(info).name { '_foo' } - assert_equal "Private___foo", info.safe_name + assert_equal 'Private___foo', info.safe_name end - it "makes names with dashes safe" do - mock(info).name { "this-could-be-a-signal-name" } + it 'makes names with dashes safe' do + mock(info).name { 'this-could-be-a-signal-name' } - info.safe_name.must_equal "This_could_be_a_signal_name" + info.safe_name.must_equal 'This_could_be_a_signal_name' end end end diff --git a/test/gir_ffi/info_ext/safe_function_name_test.rb b/test/gir_ffi/info_ext/safe_function_name_test.rb index 01eb99c9a..6e20065ea 100644 --- a/test/gir_ffi/info_ext/safe_function_name_test.rb +++ b/test/gir_ffi/info_ext/safe_function_name_test.rb @@ -8,17 +8,17 @@ } let(:info) { klass.new } - describe "#safe_name" do - it "keeps lower case names lower case" do - mock(info).name { "foo" } + describe '#safe_name' do + it 'keeps lower case names lower case' do + mock(info).name { 'foo' } - assert_equal "foo", info.safe_name + assert_equal 'foo', info.safe_name end - it "returns a non-empty string if name is empty" do - mock(info).name { "" } + it 'returns a non-empty string if name is empty' do + mock(info).name { '' } - assert_equal "_", info.safe_name + assert_equal '_', info.safe_name end end end diff --git a/test/gir_ffi/interface_base_test.rb b/test/gir_ffi/interface_base_test.rb index 25fec2bc5..8b9f08499 100644 --- a/test/gir_ffi/interface_base_test.rb +++ b/test/gir_ffi/interface_base_test.rb @@ -3,15 +3,15 @@ describe GirFFI::InterfaceBase do let(:interface) { Module.new { extend GirFFI::InterfaceBase } } - describe "#wrap" do - it "delegates conversion to the wrapped pointer" do - mock(ptr = Object.new).to_object { "good-result" } - interface.wrap(ptr).must_equal "good-result" + describe '#wrap' do + it 'delegates conversion to the wrapped pointer' do + mock(ptr = Object.new).to_object { 'good-result' } + interface.wrap(ptr).must_equal 'good-result' end end - describe ".to_ffitype" do - it "returns :pointer" do + describe '.to_ffitype' do + it 'returns :pointer' do interface.to_ffitype.must_equal :pointer end end diff --git a/test/gir_ffi/method_stubber_test.rb b/test/gir_ffi/method_stubber_test.rb index 44f273d54..c10166a33 100644 --- a/test/gir_ffi/method_stubber_test.rb +++ b/test/gir_ffi/method_stubber_test.rb @@ -1,16 +1,16 @@ require 'gir_ffi_test_helper' describe GirFFI::MethodStubber do - describe "#method_stub" do + describe '#method_stub' do let(:stubber) { GirFFI::MethodStubber.new(method_info) } let(:result) { stubber.method_stub } - describe "for a regular method" do + describe 'for a regular method' do let(:method_info) { - get_method_introspection_data("Regress", "TestObj", "instance_method") + get_method_introspection_data('Regress', 'TestObj', 'instance_method') } - it "creates a method stub" do + it 'creates a method stub' do result.must_equal <<-STUB.reset_indentation def instance_method *args, &block setup_and_call "instance_method", args, &block @@ -19,12 +19,12 @@ def instance_method *args, &block end end - describe "for a static method" do + describe 'for a static method' do let(:method_info) { - get_method_introspection_data("Regress", "TestObj", "static_method") + get_method_introspection_data('Regress', 'TestObj', 'static_method') } - it "creates a class method stub" do + it 'creates a class method stub' do result.must_equal <<-STUB.reset_indentation def self.static_method *args, &block setup_and_call "static_method", args, &block @@ -33,12 +33,12 @@ def self.static_method *args, &block end end - describe "for a module function" do + describe 'for a module function' do let(:method_info) { - get_introspection_data("Regress", "test_int") + get_introspection_data('Regress', 'test_int') } - it "creates a module method stub" do + it 'creates a module method stub' do result.must_equal <<-STUB.reset_indentation def self.test_int *args, &block setup_and_call "test_int", args, &block @@ -47,10 +47,10 @@ def self.test_int *args, &block end end - describe "for a method with an empty name" do - let(:method_info) { get_method_introspection_data("GLib", "IConv", "") } + describe 'for a method with an empty name' do + let(:method_info) { get_method_introspection_data('GLib', 'IConv', '') } - it "creates a method stub with a safe name that sets up the unsafe method" do + it 'creates a method stub with a safe name that sets up the unsafe method' do result.must_equal <<-STUB.reset_indentation def _ *args, &block setup_and_call "", args, &block diff --git a/test/gir_ffi/object_base_test.rb b/test/gir_ffi/object_base_test.rb index c0cfc0c9e..282fbe149 100644 --- a/test/gir_ffi/object_base_test.rb +++ b/test/gir_ffi/object_base_test.rb @@ -3,15 +3,15 @@ describe GirFFI::ObjectBase do let(:derived_class) { Class.new GirFFI::ObjectBase } - describe ".wrap" do - it "delegates conversion to the wrapped pointer" do - mock(ptr = Object.new).to_object { "good-result" } - derived_class.wrap(ptr).must_equal "good-result" + describe '.wrap' do + it 'delegates conversion to the wrapped pointer' do + mock(ptr = Object.new).to_object { 'good-result' } + derived_class.wrap(ptr).must_equal 'good-result' end end - describe ".to_ffitype" do - it "returns :pointer" do + describe '.to_ffitype' do + it 'returns :pointer' do derived_class.to_ffitype.must_equal :pointer end end diff --git a/test/gir_ffi/sized_array_test.rb b/test/gir_ffi/sized_array_test.rb index b30431de1..0bf289f29 100644 --- a/test/gir_ffi/sized_array_test.rb +++ b/test/gir_ffi/sized_array_test.rb @@ -1,8 +1,8 @@ require 'gir_ffi_test_helper' describe GirFFI::SizedArray do - describe "::wrap" do - it "takes a type, size and pointer and returns a GirFFI::SizedArray wrapping them" do + describe '::wrap' do + it 'takes a type, size and pointer and returns a GirFFI::SizedArray wrapping them' do mock(ptr = Object.new).null? { false } sarr = GirFFI::SizedArray.wrap :gint32, 3, ptr assert_instance_of GirFFI::SizedArray, sarr @@ -11,15 +11,15 @@ assert_equal :gint32, sarr.element_type end - it "returns nil if the wrapped pointer is null" do + it 'returns nil if the wrapped pointer is null' do mock(ptr = Object.new).null? { true } sarr = GirFFI::SizedArray.wrap :gint32, 3, ptr sarr.must_be_nil end end - describe "#each" do - it "yields each element" do + describe '#each' do + it 'yields each element' do ary = %w(one two three) ptrs = ary.map { |a| FFI::MemoryPointer.from_string(a) } ptrs << nil @@ -35,15 +35,15 @@ end end - describe "::from" do - describe "from a Ruby array" do - it "creates a GirFFI::SizedArray with the same elements" do + describe '::from' do + describe 'from a Ruby array' do + it 'creates a GirFFI::SizedArray with the same elements' do arr = GirFFI::SizedArray.from :gint32, 3, [3, 2, 1] arr.must_be_instance_of GirFFI::SizedArray assert_equal [3, 2, 1], arr.to_a end - it "raises an error if the array has the wrong number of elements" do + it 'raises an error if the array has the wrong number of elements' do proc { GirFFI::SizedArray.from :gint32, 4, [3, 2, 1] }.must_raise ArgumentError end @@ -53,25 +53,25 @@ end end - describe "from a GirFFI::SizedArray" do - it "return its argument" do + describe 'from a GirFFI::SizedArray' do + it 'return its argument' do arr = GirFFI::SizedArray.from :gint32, 3, [3, 2, 1] arr2 = GirFFI::SizedArray.from :gint32, 3, arr assert_equal arr, arr2 end - it "raises an error if the argument has the wrong number of elements" do + it 'raises an error if the argument has the wrong number of elements' do arr = GirFFI::SizedArray.from :gint32, 3, [3, 2, 1] proc { GirFFI::SizedArray.from :gint32, 4, arr }.must_raise ArgumentError end end - it "returns nil when passed nil" do + it 'returns nil when passed nil' do arr = GirFFI::SizedArray.from :gint32, 0, nil arr.must_be_nil end - it "wraps its argument if given a pointer" do + it 'wraps its argument if given a pointer' do arr = GirFFI::SizedArray.from :gint32, 3, [3, 2, 1] arr2 = GirFFI::SizedArray.from :gint32, 3, arr.to_ptr assert_instance_of GirFFI::SizedArray, arr2 @@ -80,27 +80,27 @@ end end - describe "#==" do - it "returns true when comparing to an array with the same elements" do + describe '#==' do + it 'returns true when comparing to an array with the same elements' do sized = GirFFI::SizedArray.from :int32, 3, [1, 2, 3] sized.must_be :==, [1, 2, 3] end - it "returns false when comparing to an array with different elements" do + it 'returns false when comparing to an array with different elements' do sized = GirFFI::SizedArray.from :int32, 3, [1, 2, 3] sized.wont_be :==, [1, 2] end - it "returns true when comparing to a sized array with the same elements" do + it 'returns true when comparing to a sized array with the same elements' do sized = GirFFI::SizedArray.from :int32, 3, [1, 2, 3] other = GirFFI::SizedArray.from :int32, 3, [1, 2, 3] sized.must_be :==, other end - it "returns false when comparing to a sized array with different elements" do + it 'returns false when comparing to a sized array with different elements' do sized = GirFFI::SizedArray.from :int32, 3, [1, 2, 3] other = GirFFI::SizedArray.from :int32, 2, [1, 2] @@ -108,7 +108,7 @@ end end - it "includes Enumerable" do + it 'includes Enumerable' do GirFFI::SizedArray.must_include Enumerable end end diff --git a/test/gir_ffi/type_map_test.rb b/test/gir_ffi/type_map_test.rb index 02c8d1daf..b4ce5baff 100644 --- a/test/gir_ffi/type_map_test.rb +++ b/test/gir_ffi/type_map_test.rb @@ -1,13 +1,13 @@ require 'gir_ffi_test_helper' describe GirFFI::TypeMap do - describe ".type_specification_to_ffitype" do - it "returns the nested FFI::Enum for an Enum module" do + describe '.type_specification_to_ffitype' do + it 'returns the nested FFI::Enum for an Enum module' do GirFFI::TypeMap.type_specification_to_ffitype(GLib::DateMonth). must_equal GLib::DateMonth end - it "returns the class itself for a Struct class" do + it 'returns the class itself for a Struct class' do GirFFI::TypeMap.type_specification_to_ffitype(GObject::EnumValue). must_equal GObject::EnumValue end diff --git a/test/gir_ffi/unintrospectable_type_info_test.rb b/test/gir_ffi/unintrospectable_type_info_test.rb index 70af2ab8e..790c5b2d5 100644 --- a/test/gir_ffi/unintrospectable_type_info_test.rb +++ b/test/gir_ffi/unintrospectable_type_info_test.rb @@ -2,15 +2,15 @@ require 'gir_ffi/unintrospectable_type_info' describe GirFFI::UnintrospectableTypeInfo do - describe "#info_type" do - it "returns :unintrospectable" do + describe '#info_type' do + it 'returns :unintrospectable' do info = GirFFI::UnintrospectableTypeInfo.new :some_type info.info_type.must_equal :unintrospectable end end - describe "#parent" do - describe "when the GIR knows about the parent gtype" do + describe '#parent' do + describe 'when the GIR knows about the parent gtype' do it "finds the parent's info by gtype" do gobject = Object.new gir = Object.new @@ -24,8 +24,8 @@ end end - describe "when the GIR does not know about the parent gtype" do - it "creates a new UnintrospectableTypeInfo from the parent gtype" do + describe 'when the GIR does not know about the parent gtype' do + it 'creates a new UnintrospectableTypeInfo from the parent gtype' do gobject = Object.new gir = Object.new @@ -39,8 +39,8 @@ end end - describe "#interfaces" do - it "finds interface infos by gtype" do + describe '#interfaces' do + it 'finds interface infos by gtype' do gobject = Object.new gir = Object.new @@ -53,7 +53,7 @@ info.interfaces.must_equal [:foo_info, :bar_info] end - it "skips interfaces that have no introspection data" do + it 'skips interfaces that have no introspection data' do gobject = Object.new gir = Object.new @@ -67,21 +67,21 @@ end end - describe "#g_type" do - it "returns the passed-in gtype" do + describe '#g_type' do + it 'returns the passed-in gtype' do info = GirFFI::UnintrospectableTypeInfo.new(:some_type) info.g_type.must_equal :some_type end end - describe "#fields" do - it "returns an empty array" do + describe '#fields' do + it 'returns an empty array' do info = GirFFI::UnintrospectableTypeInfo.new(:some_type) info.fields.must_equal [] end end - describe "#namespace" do + describe '#namespace' do it "returns the parent class' namespace" do gobject = Object.new gir = Object.new @@ -97,8 +97,8 @@ end end - describe "#safe_name" do - it "finds the class name by gtype" do + describe '#safe_name' do + it 'finds the class name by gtype' do gobject = Object.new mock(gobject).type_name(:some_type) { 'GSomeType' } diff --git a/test/gir_ffi/user_defined_property_info_test.rb b/test/gir_ffi/user_defined_property_info_test.rb index dcc9d7955..6e4cf5c0a 100644 --- a/test/gir_ffi/user_defined_property_info_test.rb +++ b/test/gir_ffi/user_defined_property_info_test.rb @@ -2,15 +2,15 @@ require 'gir_ffi/user_defined_property_info' describe GirFFI::UserDefinedPropertyInfo do - describe "#param_spec" do - it "returns the passed in parameter specification" do + describe '#param_spec' do + it 'returns the passed in parameter specification' do info = GirFFI::UserDefinedPropertyInfo.new :some_param_spec info.param_spec.must_equal :some_param_spec end end - describe "#name" do - it "returns the name retrieved from the parameter specification" do + describe '#name' do + it 'returns the name retrieved from the parameter specification' do mock(param_spec = Object.new).get_name { :property_name } info = GirFFI::UserDefinedPropertyInfo.new param_spec info.name.must_equal :property_name diff --git a/test/gir_ffi/user_defined_type_info_test.rb b/test/gir_ffi/user_defined_type_info_test.rb index c450cb0e1..d3da37bf2 100644 --- a/test/gir_ffi/user_defined_type_info_test.rb +++ b/test/gir_ffi/user_defined_type_info_test.rb @@ -2,15 +2,15 @@ require 'gir_ffi/user_defined_type_info' describe GirFFI::UserDefinedTypeInfo do - describe "#described_class" do - it "returns the class passed to #initialize" do + describe '#described_class' do + it 'returns the class passed to #initialize' do info = GirFFI::UserDefinedTypeInfo.new :some_class info.described_class.must_equal :some_class end end - describe "#install_property" do - it "adds the passed in property to the list of properties" do + describe '#install_property' do + it 'adds the passed in property to the list of properties' do mock(foo_spec = Object.new).get_name { :foo } info = GirFFI::UserDefinedTypeInfo.new :some_class @@ -19,25 +19,25 @@ end end - describe "#install_vfunc_implementation" do + describe '#install_vfunc_implementation' do let(:info) { GirFFI::UserDefinedTypeInfo.new :some_class } let(:implementation) { Object.new } - it "adds to the list of vfunc implementations" do + it 'adds to the list of vfunc implementations' do info.vfunc_implementations.must_equal [] info.install_vfunc_implementation :foo, implementation info.vfunc_implementations.map(&:name).must_equal [:foo] end - it "stores the passed-in implementation in the implementation object" do + it 'stores the passed-in implementation in the implementation object' do info.install_vfunc_implementation :foo, implementation impl = info.vfunc_implementations.first impl.implementation.must_equal implementation end end - describe "#initialize" do - it "yields the new object to the block passed" do + describe '#initialize' do + it 'yields the new object to the block passed' do mock(foo_spec = Object.new).get_name { :foo } mock(bar_spec = Object.new).get_name { :bar } @@ -49,18 +49,18 @@ end end - describe "#g_name" do + describe '#g_name' do it "returns the described class' name by default" do - mock(klass = Object.new).name { "foo" } + mock(klass = Object.new).name { 'foo' } info = GirFFI::UserDefinedTypeInfo.new klass - info.g_name.must_equal "foo" + info.g_name.must_equal 'foo' end - it "returns the the name set by #g_name= if present" do - stub(klass = Object.new).name { "foo" } + it 'returns the the name set by #g_name= if present' do + stub(klass = Object.new).name { 'foo' } info = GirFFI::UserDefinedTypeInfo.new klass - info.g_name = "bar" - info.g_name.must_equal "bar" + info.g_name = 'bar' + info.g_name.must_equal 'bar' end end end diff --git a/test/gir_ffi/variable_name_generator_test.rb b/test/gir_ffi/variable_name_generator_test.rb index 9b145fc0e..479390c84 100644 --- a/test/gir_ffi/variable_name_generator_test.rb +++ b/test/gir_ffi/variable_name_generator_test.rb @@ -3,14 +3,14 @@ require 'gir_ffi/variable_name_generator' describe GirFFI::VariableNameGenerator do - describe "#new_var" do - it "generates a sequence of predictable variable names" do + describe '#new_var' do + it 'generates a sequence of predictable variable names' do gen = GirFFI::VariableNameGenerator.new - assert_equal "_v1", gen.new_var - assert_equal "_v2", gen.new_var - assert_equal "_v3", gen.new_var - assert_equal "_v4", gen.new_var + assert_equal '_v1', gen.new_var + assert_equal '_v2', gen.new_var + assert_equal '_v3', gen.new_var + assert_equal '_v4', gen.new_var end end end diff --git a/test/gir_ffi/version_test.rb b/test/gir_ffi/version_test.rb index d3dcc8ce8..b5be7ce05 100644 --- a/test/gir_ffi/version_test.rb +++ b/test/gir_ffi/version_test.rb @@ -1,7 +1,7 @@ require 'gir_ffi_test_helper' describe GirFFI::VERSION do - it "is set to a valid version number" do + it 'is set to a valid version number' do GirFFI::VERSION.must_match(/\d\.\d\.\d/) end end diff --git a/test/gir_ffi/zero_terminated_test.rb b/test/gir_ffi/zero_terminated_test.rb index c484d8cdb..bf99ea053 100644 --- a/test/gir_ffi/zero_terminated_test.rb +++ b/test/gir_ffi/zero_terminated_test.rb @@ -1,21 +1,21 @@ require 'gir_ffi_test_helper' describe GirFFI::ZeroTerminated do - describe ".from" do + describe '.from' do let(:result) { GirFFI::ZeroTerminated.from :int32, [1, 2, 3] } - it "converts the passed array into a zero-terminated c array" do + it 'converts the passed array into a zero-terminated c array' do ptr = result.to_ptr ptr.read_array_of_int32(4).must_equal [1, 2, 3, 0] end - it "returns a GirFFI::ZeroTerminated object" do + it 'returns a GirFFI::ZeroTerminated object' do result.must_be_instance_of GirFFI::ZeroTerminated end end - describe ".wrap" do - it "wraps the given type and pointer" do + describe '.wrap' do + it 'wraps the given type and pointer' do ptr = GirFFI::InPointer.from_array :int32, [1, 2, 3, 0] zt = GirFFI::ZeroTerminated.wrap :foo, ptr zt.element_type.must_equal :foo @@ -23,8 +23,8 @@ end end - describe "#each" do - it "yields each element" do + describe '#each' do + it 'yields each element' do zt = GirFFI::ZeroTerminated.from :int32, [1, 2, 3] arr = [] zt.each do |int| @@ -33,14 +33,14 @@ arr.must_equal [1, 2, 3] end - it "yields zero times for a ZeroTerminated wrapping a null pointer" do + it 'yields zero times for a ZeroTerminated wrapping a null pointer' do zt = GirFFI::ZeroTerminated.wrap :int32, FFI::Pointer.new(0) zt.each do |_str| flunk end end - it "works for :int8" do + it 'works for :int8' do zt = GirFFI::ZeroTerminated.from :int8, [1, 2, 3] arr = [] zt.each do |int| @@ -51,27 +51,27 @@ end - describe "#==" do - it "returns true when comparing to an array with the same elements" do + describe '#==' do + it 'returns true when comparing to an array with the same elements' do zero_terminated = GirFFI::ZeroTerminated.from :int32, [1, 2, 3] (zero_terminated == [1, 2, 3]).must_equal true end - it "returns false when comparing to an array with different elements" do + it 'returns false when comparing to an array with different elements' do zero_terminated = GirFFI::ZeroTerminated.from :int32, [1, 2, 3] (zero_terminated == [1, 2]).must_equal false end - it "returns true when comparing to a zero-terminated array with the same elements" do + it 'returns true when comparing to a zero-terminated array with the same elements' do zero_terminated = GirFFI::ZeroTerminated.from :int32, [1, 2, 3] other = GirFFI::ZeroTerminated.from :int32, [1, 2, 3] (zero_terminated == other).must_equal true end - it "returns false when comparing to a zero-terminated array with different elements" do + it 'returns false when comparing to a zero-terminated array with different elements' do zero_terminated = GirFFI::ZeroTerminated.from :int32, [1, 2, 3] other = GirFFI::ZeroTerminated.from :int32, [1, 2] @@ -79,7 +79,7 @@ end end - it "includes Enumerable" do + it 'includes Enumerable' do GirFFI::ZeroTerminated.must_include Enumerable end end diff --git a/test/gir_ffi_test.rb b/test/gir_ffi_test.rb index b60c2e07b..d706e1a72 100644 --- a/test/gir_ffi_test.rb +++ b/test/gir_ffi_test.rb @@ -3,19 +3,19 @@ GirFFI.setup :GIMarshallingTests describe GirFFI do - it "sets up cairo as Cairo" do + it 'sets up cairo as Cairo' do GirFFI.setup :cairo assert Object.const_defined?(:Cairo) end - it "sets up xlib, which has no shared library" do + it 'sets up xlib, which has no shared library' do gir = GObjectIntrospection::IRepository.default gir.require 'xlib' - assert_nil gir.shared_library('xlib'), "Precondition for test failed" + assert_nil gir.shared_library('xlib'), 'Precondition for test failed' GirFFI.setup :xlib end - it "sets up dependencies" do + it 'sets up dependencies' do save_module :GObject save_module :Regress GirFFI.setup :Regress @@ -24,67 +24,67 @@ restore_module :GObject end - describe "::define_type" do - describe "without a block" do + describe '::define_type' do + describe 'without a block' do before do @klass = Class.new GIMarshallingTests::OverridesObject Object.const_set "DerivedA#{Sequence.next}", @klass @gtype = GirFFI.define_type @klass end - it "returns a GType for the derived class" do + it 'returns a GType for the derived class' do parent_gtype = GIMarshallingTests::OverridesObject.get_gtype @gtype.wont_equal parent_gtype GObject.type_name(@gtype).must_equal @klass.name end - it "makes #get_gtype on the registered class return the new GType" do + it 'makes #get_gtype on the registered class return the new GType' do @klass.get_gtype.must_equal @gtype end - it "registers a type with the same size as the parent" do + it 'registers a type with the same size as the parent' do q = GObject.type_query @gtype q.instance_size.must_equal GIMarshallingTests::OverridesObject::Struct.size end - it "creates a struct class for the derived class with just one member" do + it 'creates a struct class for the derived class with just one member' do @klass::Struct.members.must_equal [:parent] end - it "allows the new class to be instantiated" do + it 'allows the new class to be instantiated' do obj = @klass.new type = GObject.type_from_instance obj type.must_equal @gtype end - it "makes GirFFI find the new class by GType" do + it 'makes GirFFI find the new class by GType' do klass = GirFFI::Builder.build_by_gtype @gtype klass.must_equal @klass end end - describe "with a block with a call to #install_property" do + describe 'with a block with a call to #install_property' do before do @klass = Class.new GIMarshallingTests::OverridesObject Object.const_set "DerivedB#{Sequence.next}", @klass @gtype = GirFFI.define_type @klass do |info| - info.install_property GObject.param_spec_int("foo", "foo bar", - "The Foo Bar Property", + info.install_property GObject.param_spec_int('foo', 'foo bar', + 'The Foo Bar Property', 10, 20, 15, 3) end end - it "registers a type that is bigger than the parent" do + it 'registers a type that is bigger than the parent' do q = GObject.type_query @gtype q.instance_size.must_be :>, GIMarshallingTests::OverridesObject::Struct.size end - it "gives the types Struct the fields :parent and :foo" do + it 'gives the types Struct the fields :parent and :foo' do @klass::Struct.members.must_equal [:parent, :foo] end - it "creates accessor functions for the property" do + it 'creates accessor functions for the property' do obj = @klass.new obj.foo = 13 obj.foo.must_equal 13 diff --git a/test/gir_ffi_test_helper.rb b/test/gir_ffi_test_helper.rb index d71862623..a54e8baa8 100644 --- a/test/gir_ffi_test_helper.rb +++ b/test/gir_ffi_test_helper.rb @@ -12,7 +12,7 @@ def self.next class Minitest::Test def cws code - code.gsub(/(^\s*|\s*$)/, "") + code.gsub(/(^\s*|\s*$)/, '') end def get_field_introspection_data namespace, klass, name diff --git a/test/integration/derived_classes_test.rb b/test/integration/derived_classes_test.rb index 686284541..4be54ed16 100644 --- a/test/integration/derived_classes_test.rb +++ b/test/integration/derived_classes_test.rb @@ -3,24 +3,24 @@ GirFFI.setup :Regress # Tests deriving Ruby classes from GObject classes. -describe "For derived classes" do - describe "setting up methods when first called" do +describe 'For derived classes' do + describe 'setting up methods when first called' do before do save_module :GIMarshallingTests GirFFI.setup :GIMarshallingTests end - describe "when an interface is mixed in" do + describe 'when an interface is mixed in' do before do @klass = Class.new GIMarshallingTests::OverridesObject @klass.send :include, GIMarshallingTests::Interface end - it "finds class methods in the superclass" do + it 'finds class methods in the superclass' do @klass.returnv end - it "finds instance methods in the superclass" do + it 'finds instance methods in the superclass' do obj = @klass.new result = obj.method result.must_equal 42 @@ -32,8 +32,8 @@ end end - describe "the initializer" do - it "does not have to call super" do + describe 'the initializer' do + it 'does not have to call super' do klass = Class.new Regress::TestSubObj do def initialize *_args end diff --git a/test/integration/generated_gimarshallingtests_test.rb b/test/integration/generated_gimarshallingtests_test.rb index af6947145..e59b2ae58 100644 --- a/test/integration/generated_gimarshallingtests_test.rb +++ b/test/integration/generated_gimarshallingtests_test.rb @@ -19,40 +19,40 @@ def make_derived_instance derived_klass.new end - describe "GIMarshallingTests::BoxedStruct" do + describe 'GIMarshallingTests::BoxedStruct' do let(:instance) { GIMarshallingTests::BoxedStruct.new } - it "has a writable field long_" do + it 'has a writable field long_' do instance.long_ = 42 assert_equal 42, instance.long_ instance.long_ = 43 assert_equal 43, instance.long_ end - it "has a writable field string_" do - skip unless get_field_introspection_data("GIMarshallingTests", "BoxedStruct", "string_") - instance.string_ = "foobar" - instance.string_.must_equal "foobar" + it 'has a writable field string_' do + skip unless get_field_introspection_data('GIMarshallingTests', 'BoxedStruct', 'string_') + instance.string_ = 'foobar' + instance.string_.must_equal 'foobar' end - it "has a writable field g_strv" do + it 'has a writable field g_strv' do instance.g_strv.must_be :==, [] instance.g_strv = %w(foo bar) instance.g_strv.must_be :==, %w(foo bar) end - it "creates an instance using #new" do + it 'creates an instance using #new' do bx = GIMarshallingTests::BoxedStruct.new assert_instance_of GIMarshallingTests::BoxedStruct, bx end - it "has a working method #inv" do + it 'has a working method #inv' do instance.long_ = 42 instance.inv pass end - it "has a working function #inout" do + it 'has a working function #inout' do bx = GIMarshallingTests::BoxedStruct.new bx.long_ = 42 @@ -64,139 +64,139 @@ def make_derived_instance assert_equal 0, res.long_ end - it "has a working function #out" do + it 'has a working function #out' do res = GIMarshallingTests::BoxedStruct.out assert_equal 42, res.long_ end - it "has a working function #returnv" do + it 'has a working function #returnv' do res = GIMarshallingTests::BoxedStruct.returnv assert_equal 42, res.long_ res.g_strv.must_be :==, %w(0 1 2) end end - it "has the constant CONSTANT_GERROR_CODE" do + it 'has the constant CONSTANT_GERROR_CODE' do assert_equal 5, GIMarshallingTests::CONSTANT_GERROR_CODE end - it "has the constant CONSTANT_GERROR_DEBUG_MESSAGE" do + it 'has the constant CONSTANT_GERROR_DEBUG_MESSAGE' do GIMarshallingTests::CONSTANT_GERROR_DEBUG_MESSAGE.must_equal( - "we got an error, life is shit") + 'we got an error, life is shit') end - it "has the constant CONSTANT_GERROR_DOMAIN" do - assert_equal "gi-marshalling-tests-gerror-domain", + it 'has the constant CONSTANT_GERROR_DOMAIN' do + assert_equal 'gi-marshalling-tests-gerror-domain', GIMarshallingTests::CONSTANT_GERROR_DOMAIN end - it "has the constant CONSTANT_GERROR_MESSAGE" do - assert_equal "gi-marshalling-tests-gerror-message", + it 'has the constant CONSTANT_GERROR_MESSAGE' do + assert_equal 'gi-marshalling-tests-gerror-message', GIMarshallingTests::CONSTANT_GERROR_MESSAGE end - it "has the constant CONSTANT_NUMBER" do + it 'has the constant CONSTANT_NUMBER' do assert_equal 42, GIMarshallingTests::CONSTANT_NUMBER end - it "has the constant CONSTANT_UTF8" do - assert_equal "const ♥ utf8", GIMarshallingTests::CONSTANT_UTF8 + it 'has the constant CONSTANT_UTF8' do + assert_equal 'const ♥ utf8', GIMarshallingTests::CONSTANT_UTF8 end - describe "GIMarshallingTests::Enum" do - it "has the member :value1" do + describe 'GIMarshallingTests::Enum' do + it 'has the member :value1' do assert_equal 0, GIMarshallingTests::Enum[:value1] end - it "has the member :value2" do + it 'has the member :value2' do assert_equal 1, GIMarshallingTests::Enum[:value2] end - it "has the member :value3" do + it 'has the member :value3' do assert_equal 42, GIMarshallingTests::Enum[:value3] end end - describe "GIMarshallingTests::Flags" do - it "has the member :value1" do + describe 'GIMarshallingTests::Flags' do + it 'has the member :value1' do assert_equal 1, GIMarshallingTests::Flags[:value1] end - it "has the member :value2" do + it 'has the member :value2' do assert_equal 2, GIMarshallingTests::Flags[:value2] end - it "has the member :value3" do + it 'has the member :value3' do assert_equal 4, GIMarshallingTests::Flags[:value3] end - it "has the member :mask" do + it 'has the member :mask' do assert_equal 3, GIMarshallingTests::Flags[:mask] end - it "has the member :mask2" do + it 'has the member :mask2' do assert_equal 3, GIMarshallingTests::Flags[:mask2] end - it "has a working function #in" do + it 'has a working function #in' do GIMarshallingTests::Flags.in :value2 end - it "has a working function #in_zero" do + it 'has a working function #in_zero' do GIMarshallingTests::Flags.in_zero 0 end - it "has a working function #inout" do + it 'has a working function #inout' do result = GIMarshallingTests::Flags.inout :value2 result.must_equal :value1 end - it "has a working function #out" do + it 'has a working function #out' do result = GIMarshallingTests::Flags.out result.must_equal :value2 end - it "has a working function #returnv" do + it 'has a working function #returnv' do result = GIMarshallingTests::Flags.returnv result.must_equal :value2 end end - describe "GIMarshallingTests::GEnum" do - it "has the member :value1" do + describe 'GIMarshallingTests::GEnum' do + it 'has the member :value1' do assert_equal 0, GIMarshallingTests::GEnum[:value1] end - it "has the member :value2" do + it 'has the member :value2' do assert_equal 1, GIMarshallingTests::GEnum[:value2] end - it "has the member :value3" do + it 'has the member :value3' do assert_equal 42, GIMarshallingTests::GEnum[:value3] end - it "has a working function #in" do + it 'has a working function #in' do GIMarshallingTests::GEnum.in :value3 end - it "has a working function #inout" do + it 'has a working function #inout' do result = GIMarshallingTests::GEnum.inout :value3 result.must_equal :value1 end - it "has a working function #out" do + it 'has a working function #out' do result = GIMarshallingTests::GEnum.out result.must_equal :value3 end - it "has a working function #returnv" do + it 'has a working function #returnv' do result = GIMarshallingTests::GEnum.returnv result.must_equal :value3 end end - describe "GIMarshallingTests::Interface" do - it "has a working method #test_int8_in" do + describe 'GIMarshallingTests::Interface' do + it 'has a working method #test_int8_in' do derived_klass.class_eval { include GIMarshallingTests::Interface } instance = make_derived_instance do |info| info.install_vfunc_implementation :test_int8_in, proc { |obj, in_| obj.int = in_ } @@ -206,14 +206,14 @@ def make_derived_instance end end - describe "GIMarshallingTests::Interface2" do - it "must be tested for clashes with Interface" do - skip "Needs more work to determine desired behavior" + describe 'GIMarshallingTests::Interface2' do + it 'must be tested for clashes with Interface' do + skip 'Needs more work to determine desired behavior' end end - describe "GIMarshallingTests::Interface3" do - it "has a working method #test_variant_array_in" do + describe 'GIMarshallingTests::Interface3' do + it 'has a working method #test_variant_array_in' do skip unless get_introspection_data 'GIMarshallingTests', 'Interface3' derived_klass.class_eval { include GIMarshallingTests::Interface3 } instance = make_derived_instance do |info| @@ -226,9 +226,9 @@ def make_derived_instance end end - describe "GIMarshallingTests::NestedStruct" do + describe 'GIMarshallingTests::NestedStruct' do let(:instance) { GIMarshallingTests::NestedStruct.new } - it "has a writable field simple_struct" do + it 'has a writable field simple_struct' do assert_instance_of GIMarshallingTests::SimpleStruct, instance.simple_struct new_struct = GIMarshallingTests::SimpleStruct.new @@ -238,28 +238,28 @@ def make_derived_instance end end - describe "GIMarshallingTests::NoTypeFlags" do - it "has the member :value1" do + describe 'GIMarshallingTests::NoTypeFlags' do + it 'has the member :value1' do assert_equal 1, GIMarshallingTests::NoTypeFlags[:value1] end - it "has the member :value2" do + it 'has the member :value2' do assert_equal 2, GIMarshallingTests::NoTypeFlags[:value2] end - it "has the member :value3" do + it 'has the member :value3' do assert_equal 4, GIMarshallingTests::NoTypeFlags[:value3] end - it "has the member :mask" do + it 'has the member :mask' do assert_equal 3, GIMarshallingTests::NoTypeFlags[:mask] end - it "has the member :mask2" do + it 'has the member :mask2' do assert_equal 3, GIMarshallingTests::NoTypeFlags[:mask2] end end - describe "GIMarshallingTests::NotSimpleStruct" do + describe 'GIMarshallingTests::NotSimpleStruct' do let(:instance) { GIMarshallingTests::NotSimpleStruct.new } - it "has a writable field pointer" do + it 'has a writable field pointer' do instance.pointer.must_be_nil nested = GIMarshallingTests::NestedStruct.new instance.pointer = nested @@ -267,18 +267,18 @@ def make_derived_instance end end - it "has the constant OVERRIDES_CONSTANT" do + it 'has the constant OVERRIDES_CONSTANT' do assert_equal 42, GIMarshallingTests::OVERRIDES_CONSTANT end - describe "GIMarshallingTests::Object" do - it "creates an instance using #new" do + describe 'GIMarshallingTests::Object' do + it 'creates an instance using #new' do ob = GIMarshallingTests::Object.new 42 assert_instance_of GIMarshallingTests::Object, ob assert_equal 42, ob.int end - it "has a working function #full_inout" do + it 'has a working function #full_inout' do ob = GIMarshallingTests::Object.new 42 res = GIMarshallingTests::Object.full_inout ob @@ -289,47 +289,47 @@ def make_derived_instance res.int.must_equal 0 end - it "has a working function #full_out" do + it 'has a working function #full_out' do res = GIMarshallingTests::Object.full_out assert_instance_of GIMarshallingTests::Object, res end - it "has a working function #full_return" do + it 'has a working function #full_return' do res = GIMarshallingTests::Object.full_return assert_instance_of GIMarshallingTests::Object, res end - it "has a working function #inout_same" do - skip "This function is defined in the header but not implemented" + it 'has a working function #inout_same' do + skip 'This function is defined in the header but not implemented' end - it "has a working function #none_inout" do + it 'has a working function #none_inout' do ob = GIMarshallingTests::Object.new 42 res = GIMarshallingTests::Object.none_inout ob assert_instance_of GIMarshallingTests::Object, res ob.wont_equal res end - it "has a working function #none_out" do + it 'has a working function #none_out' do res = GIMarshallingTests::Object.none_out assert_instance_of GIMarshallingTests::Object, res end - it "has a working function #none_return" do + it 'has a working function #none_return' do res = GIMarshallingTests::Object.none_return assert_instance_of GIMarshallingTests::Object, res end - it "has a working function #static_method" do + it 'has a working function #static_method' do GIMarshallingTests::Object.static_method pass end let(:instance) { GIMarshallingTests::Object.new 42 } - it "has a working method #call_vfunc_with_callback" do - skip unless get_method_introspection_data("GIMarshallingTests", "Object", - "call_vfunc_with_callback") + it 'has a working method #call_vfunc_with_callback' do + skip unless get_method_introspection_data('GIMarshallingTests', 'Object', + 'call_vfunc_with_callback') cb = nil user_data = nil result = nil @@ -350,13 +350,13 @@ def make_derived_instance result.must_equal 42 end - it "has a working method #full_in" do - skip "This function is defined in the header but not implemented" + it 'has a working method #full_in' do + skip 'This function is defined in the header but not implemented' end - it "has a working method #get_ref_info_for_vfunc_in_object_transfer_full" do - skip unless get_vfunc_introspection_data("GIMarshallingTests", "Object", - "vfunc_in_object_transfer_full") + it 'has a working method #get_ref_info_for_vfunc_in_object_transfer_full' do + skip unless get_vfunc_introspection_data('GIMarshallingTests', 'Object', + 'vfunc_in_object_transfer_full') obj = nil derived_instance = make_derived_instance do |info| info.install_vfunc_implementation :vfunc_in_object_transfer_full, proc {|_this, object| @@ -369,9 +369,9 @@ def make_derived_instance obj.must_be_instance_of GIMarshallingTests::Object end - it "has a working method #get_ref_info_for_vfunc_in_object_transfer_none" do - skip unless get_vfunc_introspection_data("GIMarshallingTests", "Object", - "vfunc_in_object_transfer_none") + it 'has a working method #get_ref_info_for_vfunc_in_object_transfer_none' do + skip unless get_vfunc_introspection_data('GIMarshallingTests', 'Object', + 'vfunc_in_object_transfer_none') klass = nil derived_instance = make_derived_instance do |info| info.install_vfunc_implementation :vfunc_in_object_transfer_none, proc {|_this, object| @@ -384,9 +384,9 @@ def make_derived_instance klass.must_equal GIMarshallingTests::Object end - it "has a working method #get_ref_info_for_vfunc_out_object_transfer_full" do - skip unless get_vfunc_introspection_data("GIMarshallingTests", "Object", - "vfunc_out_object_transfer_full") + it 'has a working method #get_ref_info_for_vfunc_out_object_transfer_full' do + skip unless get_vfunc_introspection_data('GIMarshallingTests', 'Object', + 'vfunc_out_object_transfer_full') derived_instance = make_derived_instance do |info| info.install_vfunc_implementation :vfunc_out_object_transfer_full, proc {|_obj| GIMarshallingTests::Object.new 42 @@ -396,9 +396,9 @@ def make_derived_instance result.must_equal [1, false] end - it "has a working method #get_ref_info_for_vfunc_out_object_transfer_none" do - skip unless get_vfunc_introspection_data("GIMarshallingTests", "Object", - "vfunc_out_object_transfer_none") + it 'has a working method #get_ref_info_for_vfunc_out_object_transfer_none' do + skip unless get_vfunc_introspection_data('GIMarshallingTests', 'Object', + 'vfunc_out_object_transfer_none') derived_instance = make_derived_instance do |info| info.install_vfunc_implementation :vfunc_out_object_transfer_none, proc {|_obj| GIMarshallingTests::Object.new 42 @@ -408,9 +408,9 @@ def make_derived_instance result.must_equal [1, false] end - it "has a working method #get_ref_info_for_vfunc_return_object_transfer_full" do - skip unless get_vfunc_introspection_data("GIMarshallingTests", "Object", - "vfunc_return_object_transfer_full") + it 'has a working method #get_ref_info_for_vfunc_return_object_transfer_full' do + skip unless get_vfunc_introspection_data('GIMarshallingTests', 'Object', + 'vfunc_return_object_transfer_full') derived_instance = make_derived_instance do |info| info.install_vfunc_implementation :vfunc_return_object_transfer_full, proc {|_obj| GIMarshallingTests::Object.new 42 @@ -420,9 +420,9 @@ def make_derived_instance result.must_equal [1, false] end - it "has a working method #get_ref_info_for_vfunc_return_object_transfer_none" do - skip unless get_vfunc_introspection_data("GIMarshallingTests", "Object", - "vfunc_return_object_transfer_none") + it 'has a working method #get_ref_info_for_vfunc_return_object_transfer_none' do + skip unless get_vfunc_introspection_data('GIMarshallingTests', 'Object', + 'vfunc_return_object_transfer_none') derived_instance = make_derived_instance do |info| info.install_vfunc_implementation :vfunc_return_object_transfer_none, proc {|_obj| GIMarshallingTests::Object.new 42 @@ -432,7 +432,7 @@ def make_derived_instance result.must_equal [1, false] end - it "has a working method #int8_in" do + it 'has a working method #int8_in' do derived_instance = make_derived_instance do |info| info.install_vfunc_implementation :method_int8_in, proc { |obj, in_| obj.int = in_ } end @@ -442,38 +442,38 @@ def make_derived_instance # TODO: Check if this is fixed # See https://bugzilla.gnome.org/show_bug.cgi?id=727665 - it "has a working method #int8_out" do - skip "Introspection data is not generated correctly" + it 'has a working method #int8_out' do + skip 'Introspection data is not generated correctly' end - it "has a working method #method" do + it 'has a working method #method' do instance.method pass end - it "has a working method #method_array_in" do + it 'has a working method #method_array_in' do instance.method_array_in [-1, 0, 1, 2] pass end - it "has a working method #method_array_inout" do + it 'has a working method #method_array_inout' do res = instance.method_array_inout [-1, 0, 1, 2] res.must_be :==, [-2, -1, 0, 1, 2] end - it "has a working method #method_array_out" do + it 'has a working method #method_array_out' do res = instance.method_array_out res.must_be :==, [-1, 0, 1, 2] end - it "has a working method #method_array_return" do + it 'has a working method #method_array_return' do res = instance.method_array_return res.must_be :==, [-1, 0, 1, 2] end - it "has a working method #method_int8_arg_and_out_callee" do - skip unless get_method_introspection_data("GIMarshallingTests", "Object", - "method_int8_arg_and_out_callee") + it 'has a working method #method_int8_arg_and_out_callee' do + skip unless get_method_introspection_data('GIMarshallingTests', 'Object', + 'method_int8_arg_and_out_callee') derived_instance = make_derived_instance do |info| info.install_vfunc_implementation :method_int8_arg_and_out_callee, proc { |_obj, arg| 2 * arg @@ -483,9 +483,9 @@ def make_derived_instance result.must_equal 64 end - it "has a working method #method_int8_arg_and_out_caller" do - skip unless get_method_introspection_data("GIMarshallingTests", "Object", - "method_int8_arg_and_out_caller") + it 'has a working method #method_int8_arg_and_out_caller' do + skip unless get_method_introspection_data('GIMarshallingTests', 'Object', + 'method_int8_arg_and_out_caller') derived_instance = make_derived_instance do |info| info.install_vfunc_implementation :method_int8_arg_and_out_caller, proc { |_obj, arg| 2 * arg @@ -495,7 +495,7 @@ def make_derived_instance result.must_equal 64 end - it "has a working method #method_int8_in" do + it 'has a working method #method_int8_in' do derived_instance = make_derived_instance do |info| info.install_vfunc_implementation :method_int8_in, proc { |obj, in_| obj.int = in_ } end @@ -503,45 +503,45 @@ def make_derived_instance derived_instance.int.must_equal 108 end - it "has a working method #method_int8_out" do + it 'has a working method #method_int8_out' do derived_instance = make_derived_instance do |info| info.install_vfunc_implementation :method_int8_out, proc { |_obj| 42 } end derived_instance.method_int8_out.must_equal 42 end - it "has a working method #method_str_arg_out_ret" do - skip unless get_vfunc_introspection_data("GIMarshallingTests", "Object", - "method_str_arg_out_ret") + it 'has a working method #method_str_arg_out_ret' do + skip unless get_vfunc_introspection_data('GIMarshallingTests', 'Object', + 'method_str_arg_out_ret') derived_instance = make_derived_instance do |info| info.install_vfunc_implementation :method_str_arg_out_ret, proc { |_obj, arg| [arg, 42] } end - derived_instance.method_str_arg_out_ret("foo").must_equal ["foo", 42] + derived_instance.method_str_arg_out_ret('foo').must_equal ['foo', 42] end - it "has a working method #method_variant_array_in" do - skip "This function is defined in the header but not implemented" + it 'has a working method #method_variant_array_in' do + skip 'This function is defined in the header but not implemented' end - it "has a working method #method_with_default_implementation" do + it 'has a working method #method_with_default_implementation' do instance.method_with_default_implementation 104 assert_equal 104, instance.int end - it "has a working method #none_in" do + it 'has a working method #none_in' do instance.none_in pass end - it "has a working method #overridden_method" do - instance.set_property("int", 0) + it 'has a working method #overridden_method' do + instance.set_property('int', 0) instance.overridden_method pass end - it "has a working method #vfunc_array_out_parameter" do - skip unless get_vfunc_introspection_data("GIMarshallingTests", "Object", - "vfunc_array_out_parameter") + it 'has a working method #vfunc_array_out_parameter' do + skip unless get_vfunc_introspection_data('GIMarshallingTests', 'Object', + 'vfunc_array_out_parameter') derived_instance = make_derived_instance do |info| info.install_vfunc_implementation :vfunc_array_out_parameter, proc {|_obj| [1.1, 2.2, 3.3] @@ -555,22 +555,22 @@ def make_derived_instance arr[2].must_be_close_to 3.3 end - it "has a working method #vfunc_caller_allocated_out_parameter" do - skip unless get_vfunc_introspection_data("GIMarshallingTests", "Object", - "vfunc_caller_allocated_out_parameter") + it 'has a working method #vfunc_caller_allocated_out_parameter' do + skip unless get_vfunc_introspection_data('GIMarshallingTests', 'Object', + 'vfunc_caller_allocated_out_parameter') derived_instance = make_derived_instance do |info| info.install_vfunc_implementation :vfunc_caller_allocated_out_parameter, proc {|_obj| - "Hello!" + 'Hello!' } end result = derived_instance.vfunc_caller_allocated_out_parameter - result.get_value.must_equal "Hello!" + result.get_value.must_equal 'Hello!' end - it "has a working method #vfunc_meth_with_error" do + it 'has a working method #vfunc_meth_with_error' do derived_instance = make_derived_instance do |info| info.install_vfunc_implementation :vfunc_meth_with_err, proc {|_object, x| - raise "This is not the answer!" unless x == 42 + raise 'This is not the answer!' unless x == 42 true } end @@ -579,12 +579,12 @@ def make_derived_instance err = proc { derived_instance.vfunc_meth_with_error(21) }. must_raise GirFFI::GLibError - err.message.must_equal "This is not the answer!" - err.domain.must_equal "gir_ffi" + err.message.must_equal 'This is not the answer!' + err.domain.must_equal 'gir_ffi' err.code.must_equal 0 end - it "has a working method #vfunc_multiple_out_parameters" do + it 'has a working method #vfunc_multiple_out_parameters' do derived_instance = make_derived_instance do |info| info.install_vfunc_implementation( :vfunc_multiple_out_parameters, @@ -595,7 +595,7 @@ def make_derived_instance result[1].must_be_close_to(-142.3) end - it "has a working method #vfunc_one_out_parameter" do + it 'has a working method #vfunc_one_out_parameter' do derived_instance = make_derived_instance do |info| info.install_vfunc_implementation( :vfunc_one_out_parameter, @@ -605,25 +605,25 @@ def make_derived_instance must_be_within_epsilon 23.4 end - it "has a working method #vfunc_out_enum" do - skip unless get_vfunc_introspection_data("GIMarshallingTests", "Object", - "vfunc_out_enum") + it 'has a working method #vfunc_out_enum' do + skip unless get_vfunc_introspection_data('GIMarshallingTests', 'Object', + 'vfunc_out_enum') derived_instance = make_derived_instance do |info| info.install_vfunc_implementation :vfunc_out_enum, proc { |_obj| :value2 } end derived_instance.vfunc_out_enum.must_equal :value2 end - it "has a working method #vfunc_return_enum" do - skip unless get_vfunc_introspection_data("GIMarshallingTests", "Object", - "vfunc_return_enum") + it 'has a working method #vfunc_return_enum' do + skip unless get_vfunc_introspection_data('GIMarshallingTests', 'Object', + 'vfunc_return_enum') derived_instance = make_derived_instance do |info| info.install_vfunc_implementation :vfunc_return_enum, proc { |_obj| :value2 } end derived_instance.vfunc_return_enum.must_equal :value2 end - it "has a working method #vfunc_return_value_and_multiple_out_parameters" do + it 'has a working method #vfunc_return_value_and_multiple_out_parameters' do derived_instance = make_derived_instance do |info| info.install_vfunc_implementation( :vfunc_return_value_and_multiple_out_parameters, @@ -633,7 +633,7 @@ def make_derived_instance must_equal [42, -142, 3] end - it "has a working method #vfunc_return_value_and_one_out_parameter" do + it 'has a working method #vfunc_return_value_and_one_out_parameter' do derived_instance = make_derived_instance do |info| info.install_vfunc_implementation( :vfunc_return_value_and_one_out_parameter, @@ -643,7 +643,7 @@ def make_derived_instance must_equal [42, -142] end - it "has a working method #vfunc_return_value_only" do + it 'has a working method #vfunc_return_value_only' do derived_instance = make_derived_instance do |info| info.install_vfunc_implementation :vfunc_return_value_only, proc { |_obj| 0x1234_5678 } end @@ -651,9 +651,9 @@ def make_derived_instance result.must_equal 0x1234_5678 end - it "has a working method #vfunc_with_callback" do - skip unless get_method_introspection_data("GIMarshallingTests", "Object", - "vfunc_with_callback") + it 'has a working method #vfunc_with_callback' do + skip unless get_method_introspection_data('GIMarshallingTests', 'Object', + 'vfunc_with_callback') result = 1 @@ -672,42 +672,42 @@ def make_derived_instance end describe "its 'int' property" do - it "can be retrieved with #get_property" do - assert_equal 42, instance.get_property("int").get_value + it 'can be retrieved with #get_property' do + assert_equal 42, instance.get_property('int').get_value end - it "can be retrieved with #int" do + it 'can be retrieved with #int' do assert_equal 42, instance.int end - it "can be set with #set_property" do - instance.set_property("int", 13) - assert_equal 13, instance.get_property("int").get_value + it 'can be set with #set_property' do + instance.set_property('int', 13) + assert_equal 13, instance.get_property('int').get_value end - it "can be set with #int=" do + it 'can be set with #int=' do instance.int = 1 assert_equal 1, instance.int end end end - describe "GIMarshallingTests::OverridesObject" do - it "creates an instance using #new" do + describe 'GIMarshallingTests::OverridesObject' do + it 'creates an instance using #new' do ob = GIMarshallingTests::OverridesObject.new assert_instance_of GIMarshallingTests::OverridesObject, ob end - it "has a working function #returnv" do + it 'has a working function #returnv' do ob = GIMarshallingTests::OverridesObject.returnv assert_instance_of GIMarshallingTests::OverridesObject, ob end let(:instance) { GIMarshallingTests::OverridesObject.new } - it "has a working method #method" do + it 'has a working method #method' do result = instance.method result.must_equal 42 end - it "does not have field accessor methods" do + it 'does not have field accessor methods' do assert_raises(NoMethodError) { instance.parent_instance } assert_raises(NoMethodError) { instance.parent_instance = nil } assert_raises(NoMethodError) { instance.long_ } @@ -715,57 +715,57 @@ def make_derived_instance end end - describe "GIMarshallingTests::OverridesStruct" do + describe 'GIMarshallingTests::OverridesStruct' do let(:instance) { GIMarshallingTests::OverridesStruct.new } - it "has a writable field long_" do + it 'has a writable field long_' do instance.long_ = 43 instance.long_.must_equal 43 end - it "creates an instance using #new" do + it 'creates an instance using #new' do ob = GIMarshallingTests::OverridesStruct.new assert_instance_of GIMarshallingTests::OverridesStruct, ob end - it "has a working method #method" do + it 'has a working method #method' do instance.method.must_equal 42 end - it "has a working function #returnv" do + it 'has a working function #returnv' do ob = GIMarshallingTests::OverridesStruct.returnv assert_instance_of GIMarshallingTests::OverridesStruct, ob end end - describe "GIMarshallingTests::PointerStruct" do - it "creates an instance using #new" do + describe 'GIMarshallingTests::PointerStruct' do + it 'creates an instance using #new' do ps = GIMarshallingTests::PointerStruct.new assert_instance_of GIMarshallingTests::PointerStruct, ps end let(:instance) { GIMarshallingTests::PointerStruct.new } - it "has a writable field long_" do + it 'has a writable field long_' do assert_equal 0, instance.long_ instance.long_ = 1056 assert_equal 1056, instance.long_ end - it "has a working method #inv" do + it 'has a working method #inv' do instance.long_ = 42 instance.inv pass end - it "has a working function #returnv" do + it 'has a working function #returnv' do ob = GIMarshallingTests::PointerStruct.returnv assert_instance_of GIMarshallingTests::PointerStruct, ob end end - describe "GIMarshallingTests::PropertiesObject" do - it "creates an instance using #new" do + describe 'GIMarshallingTests::PropertiesObject' do + it 'creates an instance using #new' do ob = GIMarshallingTests::PropertiesObject.new assert_instance_of GIMarshallingTests::PropertiesObject, ob end @@ -773,22 +773,22 @@ def make_derived_instance let(:instance) { GIMarshallingTests::PropertiesObject.new } describe "its 'some-boolean' property" do - it "can be retrieved with #get_property" do - instance.get_property("some-boolean").get_value.must_equal false + it 'can be retrieved with #get_property' do + instance.get_property('some-boolean').get_value.must_equal false end - it "can be retrieved with #some_boolean" do + it 'can be retrieved with #some_boolean' do instance.some_boolean.must_equal false end - it "can be set with #set_property" do - instance.set_property("some-boolean", true) - instance.get_property("some-boolean").get_value.must_equal true + it 'can be set with #set_property' do + instance.set_property('some-boolean', true) + instance.get_property('some-boolean').get_value.must_equal true end - it "can be set with #some_boolean=" do + it 'can be set with #some_boolean=' do instance.some_boolean = true - instance.get_property("some-boolean").get_value.must_equal true + instance.get_property('some-boolean').get_value.must_equal true end end @@ -799,23 +799,23 @@ def make_derived_instance 'some-boxed-glist') end - it "can be retrieved with #get_property" do - instance.get_property("some-boxed-glist").get_value.must_equal nil + it 'can be retrieved with #get_property' do + instance.get_property('some-boxed-glist').get_value.must_equal nil end - it "can be retrieved with #some_boxed_glist" do + it 'can be retrieved with #some_boxed_glist' do instance.some_boxed_glist.must_equal nil end - it "can be set with #set_property_extended" do - instance.set_property_extended("some-boxed-glist", [1, 2, 3]) + it 'can be set with #set_property_extended' do + instance.set_property_extended('some-boxed-glist', [1, 2, 3]) instance.some_boxed_glist.to_a.must_equal [1, 2, 3] end - it "can be set with #some_boxed_glist=" do + it 'can be set with #some_boxed_glist=' do instance.some_boxed_glist = [1, 2, 3] instance.some_boxed_glist.to_a.must_equal [1, 2, 3] - instance.get_property_extended("some-boxed-glist").to_a.must_equal [1, 2, 3] + instance.get_property_extended('some-boxed-glist').to_a.must_equal [1, 2, 3] end end @@ -826,22 +826,22 @@ def make_derived_instance 'some-boxed-struct') end - it "can be retrieved with #get_property" do - instance.get_property("some-boxed-struct").get_value.must_equal nil + it 'can be retrieved with #get_property' do + instance.get_property('some-boxed-struct').get_value.must_equal nil end - it "can be retrieved with #some_boxed_struct" do + it 'can be retrieved with #some_boxed_struct' do instance.some_boxed_struct.must_equal nil end - it "can be set with #set_property" do + it 'can be set with #set_property' do boxed = GIMarshallingTests::BoxedStruct.new boxed.long_ = 42 - instance.set_property("some-boxed-struct", boxed) - instance.get_property("some-boxed-struct").get_value.long_.must_equal 42 + instance.set_property('some-boxed-struct', boxed) + instance.get_property('some-boxed-struct').get_value.long_.must_equal 42 end - it "can be set with #some_boxed_struct=" do + it 'can be set with #some_boxed_struct=' do boxed = GIMarshallingTests::BoxedStruct.new boxed.long_ = 43 instance.some_boxed_struct = boxed @@ -850,120 +850,120 @@ def make_derived_instance end describe "its 'some-char' property" do - it "can be retrieved with #get_property" do - instance.get_property("some-char").get_value.must_equal 0 + it 'can be retrieved with #get_property' do + instance.get_property('some-char').get_value.must_equal 0 end - it "can be retrieved with #some_char" do + it 'can be retrieved with #some_char' do instance.some_char.must_equal 0 end - it "can be set with #set_property" do - instance.set_property "some-char", 42 - instance.get_property("some-char").get_value.must_equal 42 + it 'can be set with #set_property' do + instance.set_property 'some-char', 42 + instance.get_property('some-char').get_value.must_equal 42 end - it "can be set with #some_char=" do + it 'can be set with #some_char=' do instance.some_char = 43 instance.some_char.must_equal 43 end end describe "its 'some-double' property" do - it "can be retrieved with #get_property" do - instance.get_property("some-double").get_value.must_equal 0.0 + it 'can be retrieved with #get_property' do + instance.get_property('some-double').get_value.must_equal 0.0 end - it "can be retrieved with #some_double" do + it 'can be retrieved with #some_double' do instance.some_double.must_equal 0.0 end - it "can be set with #set_property" do - instance.set_property("some-double", 3.14) - instance.get_property("some-double").get_value.must_equal 3.14 + it 'can be set with #set_property' do + instance.set_property('some-double', 3.14) + instance.get_property('some-double').get_value.must_equal 3.14 end - it "can be set with #some_double=" do + it 'can be set with #some_double=' do instance.some_double = 3.14 instance.some_double.must_equal 3.14 end end describe "its 'some-float' property" do - it "can be retrieved with #get_property" do - instance.get_property("some-float").get_value.must_equal 0.0 + it 'can be retrieved with #get_property' do + instance.get_property('some-float').get_value.must_equal 0.0 end - it "can be retrieved with #some_float" do + it 'can be retrieved with #some_float' do instance.some_float.must_equal 0.0 end - it "can be set with #set_property" do - instance.set_property("some-float", 3.14) - instance.get_property("some-float").get_value.must_be_close_to 3.14 + it 'can be set with #set_property' do + instance.set_property('some-float', 3.14) + instance.get_property('some-float').get_value.must_be_close_to 3.14 end - it "can be set with #some_float=" do + it 'can be set with #some_float=' do instance.some_float = 3.14 instance.some_float.must_be_close_to 3.14 end end describe "its 'some-int' property" do - it "can be retrieved with #get_property" do - instance.get_property("some-int").get_value.must_equal 0 + it 'can be retrieved with #get_property' do + instance.get_property('some-int').get_value.must_equal 0 end - it "can be retrieved with #some_int" do + it 'can be retrieved with #some_int' do instance.some_int.must_equal 0 end - it "can be set with #set_property" do - instance.set_property "some-int", 4242 - instance.get_property("some-int").get_value.must_equal 4242 + it 'can be set with #set_property' do + instance.set_property 'some-int', 4242 + instance.get_property('some-int').get_value.must_equal 4242 end - it "can be set with #some_int=" do + it 'can be set with #some_int=' do instance.some_int = 4243 instance.some_int.must_equal 4243 end end describe "its 'some-int64' property" do - it "can be retrieved with #get_property" do - instance.get_property("some-int64").get_value.must_equal 0 + it 'can be retrieved with #get_property' do + instance.get_property('some-int64').get_value.must_equal 0 end - it "can be retrieved with #some_int64" do + it 'can be retrieved with #some_int64' do instance.some_int64.must_equal 0 end - it "can be set with #set_property" do - instance.set_property "some-int64", 42_000_000_000_000 - instance.get_property("some-int64").get_value.must_equal 42_000_000_000_000 + it 'can be set with #set_property' do + instance.set_property 'some-int64', 42_000_000_000_000 + instance.get_property('some-int64').get_value.must_equal 42_000_000_000_000 end - it "can be set with #some_int64=" do + it 'can be set with #some_int64=' do instance.some_int64 = 43_000_000_000_000 instance.some_int64.must_equal 43_000_000_000_000 end end describe "its 'some-long' property" do - it "can be retrieved with #get_property" do - instance.get_property("some-long").get_value.must_equal 0 + it 'can be retrieved with #get_property' do + instance.get_property('some-long').get_value.must_equal 0 end - it "can be retrieved with #some_long" do + it 'can be retrieved with #some_long' do instance.some_long.must_equal 0 end - it "can be set with #set_property" do - instance.set_property "some-long", 4242 - instance.get_property("some-long").get_value.must_equal 4242 + it 'can be set with #set_property' do + instance.set_property 'some-long', 4242 + instance.get_property('some-long').get_value.must_equal 4242 end - it "can be set with #some_long=" do + it 'can be set with #some_long=' do instance.some_long = 4243 instance.some_long.must_equal 4243 end @@ -976,21 +976,21 @@ def make_derived_instance 'some-object') end - it "can be retrieved with #get_property" do - instance.get_property("some-object").get_value.must_be_nil + it 'can be retrieved with #get_property' do + instance.get_property('some-object').get_value.must_be_nil end - it "can be retrieved with #some_object" do + it 'can be retrieved with #some_object' do instance.some_object.must_be_nil end - it "can be set with #set_property" do + it 'can be set with #set_property' do ob = GIMarshallingTests::Object.new 42 - instance.set_property "some-object", ob - instance.get_property("some-object").get_value.must_equal ob + instance.set_property 'some-object', ob + instance.get_property('some-object').get_value.must_equal ob end - it "can be set with #some_object=" do + it 'can be set with #some_object=' do ob = GIMarshallingTests::Object.new 42 instance.some_object = ob instance.some_object.must_equal ob @@ -1004,100 +1004,100 @@ def make_derived_instance 'some-strv') end - it "can be retrieved with #get_property" do - instance.get_property("some-strv").get_value.must_be :==, [] + it 'can be retrieved with #get_property' do + instance.get_property('some-strv').get_value.must_be :==, [] end - it "can be retrieved with #some_strv" do + it 'can be retrieved with #some_strv' do instance.some_strv.must_be :==, [] end - it "can be set with #set_property_extended" do - instance.set_property_extended("some-strv", %w(foo bar)) - instance.get_property("some-strv").get_value.must_be :==, %w(foo bar) + it 'can be set with #set_property_extended' do + instance.set_property_extended('some-strv', %w(foo bar)) + instance.get_property('some-strv').get_value.must_be :==, %w(foo bar) end - it "can be set with #some_strv=" do + it 'can be set with #some_strv=' do instance.some_strv = %w(foo bar) instance.some_strv.must_be :==, %w(foo bar) end end describe "its 'some-uchar' property" do - it "can be retrieved with #get_property" do - instance.get_property("some-uchar").get_value.must_equal 0 + it 'can be retrieved with #get_property' do + instance.get_property('some-uchar').get_value.must_equal 0 end - it "can be retrieved with #some_uchar" do + it 'can be retrieved with #some_uchar' do instance.some_uchar.must_equal 0 end - it "can be set with #set_property" do - instance.set_property "some-uchar", 42 - instance.get_property("some-uchar").get_value.must_equal 42 + it 'can be set with #set_property' do + instance.set_property 'some-uchar', 42 + instance.get_property('some-uchar').get_value.must_equal 42 end - it "can be set with #some_uchar=" do + it 'can be set with #some_uchar=' do instance.some_uchar = 43 instance.some_uchar.must_equal 43 end end describe "its 'some-uint' property" do - it "can be retrieved with #get_property" do - instance.get_property("some-uint").get_value.must_equal 0 + it 'can be retrieved with #get_property' do + instance.get_property('some-uint').get_value.must_equal 0 end - it "can be retrieved with #some_uint" do + it 'can be retrieved with #some_uint' do instance.some_uint.must_equal 0 end - it "can be set with #set_property" do - instance.set_property "some-uint", 4242 - instance.get_property("some-uint").get_value.must_equal 4242 + it 'can be set with #set_property' do + instance.set_property 'some-uint', 4242 + instance.get_property('some-uint').get_value.must_equal 4242 end - it "can be set with #some_uint=" do + it 'can be set with #some_uint=' do instance.some_uint = 4243 instance.some_uint.must_equal 4243 end end describe "its 'some-uint64' property" do - it "can be retrieved with #get_property" do - instance.get_property("some-uint64").get_value.must_equal 0 + it 'can be retrieved with #get_property' do + instance.get_property('some-uint64').get_value.must_equal 0 end - it "can be retrieved with #some_uint64" do + it 'can be retrieved with #some_uint64' do instance.some_uint64.must_equal 0 end - it "can be set with #set_property" do - instance.set_property "some-uint64", 42_000_000_000_000 - instance.get_property("some-uint64").get_value.must_equal 42_000_000_000_000 + it 'can be set with #set_property' do + instance.set_property 'some-uint64', 42_000_000_000_000 + instance.get_property('some-uint64').get_value.must_equal 42_000_000_000_000 end - it "can be set with #some_uint64=" do + it 'can be set with #some_uint64=' do instance.some_uint64 = 43_000_000_000_000 instance.some_uint64.must_equal 43_000_000_000_000 end end describe "its 'some-ulong' property" do - it "can be retrieved with #get_property" do - instance.get_property("some-ulong").get_value.must_equal 0 + it 'can be retrieved with #get_property' do + instance.get_property('some-ulong').get_value.must_equal 0 end - it "can be retrieved with #some_ulong" do + it 'can be retrieved with #some_ulong' do instance.some_ulong.must_equal 0 end - it "can be set with #set_property" do - instance.set_property "some-ulong", 4242 - instance.get_property("some-ulong").get_value.must_equal 4242 + it 'can be set with #set_property' do + instance.set_property 'some-ulong', 4242 + instance.get_property('some-ulong').get_value.must_equal 4242 end - it "can be set with #some_ulong=" do + it 'can be set with #some_ulong=' do instance.some_ulong = 4243 instance.some_ulong.must_equal 4243 end @@ -1110,313 +1110,313 @@ def make_derived_instance 'some-variant') end - it "can be retrieved with #get_property" do - instance.get_property("some-variant").get_value.must_be_nil + it 'can be retrieved with #get_property' do + instance.get_property('some-variant').get_value.must_be_nil end - it "can be retrieved with #some_variant" do + it 'can be retrieved with #some_variant' do instance.some_variant.must_be_nil end - it "can be set with #set_property" do - value = GLib::Variant.new_string("Foo") - instance.set_property "some-variant", value - instance.get_property("some-variant").get_value.must_equal value + it 'can be set with #set_property' do + value = GLib::Variant.new_string('Foo') + instance.set_property 'some-variant', value + instance.get_property('some-variant').get_value.must_equal value end - it "can be set with #some_variant=" do - value = GLib::Variant.new_string("Foo") + it 'can be set with #some_variant=' do + value = GLib::Variant.new_string('Foo') instance.some_variant = value instance.some_variant.must_equal value end end end - describe "GIMarshallingTests::SecondEnum" do - it "has the member :secondvalue1" do + describe 'GIMarshallingTests::SecondEnum' do + it 'has the member :secondvalue1' do assert_equal 0, GIMarshallingTests::SecondEnum[:secondvalue1] end - it "has the member :secondvalue2" do + it 'has the member :secondvalue2' do assert_equal 1, GIMarshallingTests::SecondEnum[:secondvalue2] end end - describe "GIMarshallingTests::SimpleStruct" do - it "creates an instance using #new" do + describe 'GIMarshallingTests::SimpleStruct' do + it 'creates an instance using #new' do ss = GIMarshallingTests::SimpleStruct.new assert_instance_of GIMarshallingTests::SimpleStruct, ss end let(:instance) { GIMarshallingTests::SimpleStruct.new } - it "has a writable field long_" do + it 'has a writable field long_' do instance.long_.must_equal 0 instance.long_ = 1056 instance.long_.must_equal 1056 end - it "has a writable field int8" do + it 'has a writable field int8' do instance.int8.must_equal 0 instance.int8 = -43 instance.int8.must_equal(-43) end - it "has a working method #inv" do + it 'has a working method #inv' do instance.long_ = 6 instance.int8 = 7 instance.inv pass end - it "has a working method #method" do + it 'has a working method #method' do instance.long_ = 6 instance.int8 = 7 instance.method pass end - it "has a working function #returnv" do + it 'has a working function #returnv' do ss = GIMarshallingTests::SimpleStruct.returnv assert_instance_of GIMarshallingTests::SimpleStruct, ss end end - describe "GIMarshallingTests::SubObject" do - it "creates an instance using #new" do + describe 'GIMarshallingTests::SubObject' do + it 'creates an instance using #new' do so = GIMarshallingTests::SubObject.new 42 assert_instance_of GIMarshallingTests::SubObject, so end let(:instance) { GIMarshallingTests::SubObject.new 0 } - it "has a working method #overwritten_method" do + it 'has a working method #overwritten_method' do instance.overwritten_method pass end - it "has a working method #sub_method" do + it 'has a working method #sub_method' do instance.sub_method pass end - it "does not have field accessors" do + it 'does not have field accessors' do assert_raises(NoMethodError) { instance.parent_instance } assert_raises(NoMethodError) { instance.parent_instance = nil } end end - describe "GIMarshallingTests::SubSubObject" do - it "creates an instance using #new" do + describe 'GIMarshallingTests::SubSubObject' do + it 'creates an instance using #new' do so = GIMarshallingTests::SubSubObject.new 42 assert_instance_of GIMarshallingTests::SubSubObject, so end let(:instance) { GIMarshallingTests::SubSubObject.new 0 } - it "does not have field accessors" do + it 'does not have field accessors' do assert_raises(NoMethodError) { instance.parent_instance } assert_raises(NoMethodError) { instance.parent_instance = nil } end end - describe "GIMarshallingTests::Union" do - it "creates an instance with #new" do + describe 'GIMarshallingTests::Union' do + it 'creates an instance with #new' do u = GIMarshallingTests::Union.new assert_instance_of GIMarshallingTests::Union, u end let(:instance) { GIMarshallingTests::Union.new } - it "has a writable field long_" do + it 'has a writable field long_' do assert_equal 0, instance.long_ instance.long_ = 1056 assert_equal 1056, instance.long_ end - it "has a working method #inv" do + it 'has a working method #inv' do instance.long_ = 42 instance.inv pass end - it "has a working method #method" do + it 'has a working method #method' do instance.long_ = 42 instance.method pass end - it "has a working function #inout" do - skip "This function is defined in the header but not implemented" + it 'has a working function #inout' do + skip 'This function is defined in the header but not implemented' end - it "has a working function #out" do - skip "This function is defined in the header but not implemented" + it 'has a working function #out' do + skip 'This function is defined in the header but not implemented' end - it "has a working function #returnv" do + it 'has a working function #returnv' do u = GIMarshallingTests::Union.returnv assert_instance_of GIMarshallingTests::Union, u end end - it "has a working function #array_enum_in" do + it 'has a working function #array_enum_in' do GIMarshallingTests.array_enum_in [:value1, :value2, :value3] end - it "has a working function #array_fixed_inout" do + it 'has a working function #array_fixed_inout' do res = GIMarshallingTests.array_fixed_inout [-1, 0, 1, 2] res.must_be :==, [2, 1, 0, -1] end - it "has a working function #array_fixed_int_in" do + it 'has a working function #array_fixed_int_in' do GIMarshallingTests.array_fixed_int_in [-1, 0, 1, 2] pass end - it "has a working function #array_fixed_int_return" do + it 'has a working function #array_fixed_int_return' do res = GIMarshallingTests.array_fixed_int_return res.must_be :==, [-1, 0, 1, 2] end - it "has a working function #array_fixed_out" do + it 'has a working function #array_fixed_out' do res = GIMarshallingTests.array_fixed_out res.must_be :==, [-1, 0, 1, 2] end - it "has a working function #array_fixed_out_struct" do + it 'has a working function #array_fixed_out_struct' do res = GIMarshallingTests.array_fixed_out_struct assert_equal [[7, 6], [6, 7]], res.map { |s| [s.long_, s.int8] } end - it "has a working function #array_fixed_short_in" do + it 'has a working function #array_fixed_short_in' do GIMarshallingTests.array_fixed_short_in [-1, 0, 1, 2] pass end - it "has a working function #array_fixed_short_return" do + it 'has a working function #array_fixed_short_return' do res = GIMarshallingTests.array_fixed_short_return res.must_be :==, [-1, 0, 1, 2] end - it "has a working function #array_gvariant_container_in" do + it 'has a working function #array_gvariant_container_in' do v1 = GLib::Variant.new_int32(27) - v2 = GLib::Variant.new_string("Hello") + v2 = GLib::Variant.new_string('Hello') result = GIMarshallingTests.array_gvariant_container_in [v1, v2] arr = result.to_a arr.size.must_equal 2 arr[0].get_int32.must_equal 27 - arr[1].get_string.must_equal "Hello" + arr[1].get_string.must_equal 'Hello' end - it "has a working function #array_gvariant_full_in" do + it 'has a working function #array_gvariant_full_in' do v1 = GLib::Variant.new_int32(27) - v2 = GLib::Variant.new_string("Hello") + v2 = GLib::Variant.new_string('Hello') result = GIMarshallingTests.array_gvariant_full_in [v1, v2] arr = result.to_a arr.size.must_equal 2 arr[0].get_int32.must_equal 27 - arr[1].get_string.must_equal "Hello" + arr[1].get_string.must_equal 'Hello' end - it "has a working function #array_gvariant_none_in" do + it 'has a working function #array_gvariant_none_in' do v1 = GLib::Variant.new_int32(27) - v2 = GLib::Variant.new_string("Hello") + v2 = GLib::Variant.new_string('Hello') result = GIMarshallingTests.array_gvariant_none_in [v1, v2] arr = result.to_a arr.size.must_equal 2 arr[0].get_int32.must_equal 27 - arr[1].get_string.must_equal "Hello" + arr[1].get_string.must_equal 'Hello' end - it "has a working function #array_in" do + it 'has a working function #array_in' do GIMarshallingTests.array_in [-1, 0, 1, 2] pass end - it "has a working function #array_in_guint64_len" do + it 'has a working function #array_in_guint64_len' do GIMarshallingTests.array_in_guint64_len [-1, 0, 1, 2] pass end - it "has a working function #array_in_guint8_len" do + it 'has a working function #array_in_guint8_len' do GIMarshallingTests.array_in_guint8_len [-1, 0, 1, 2] pass end - it "has a working function #array_in_len_before" do + it 'has a working function #array_in_len_before' do GIMarshallingTests.array_in_len_before [-1, 0, 1, 2] pass end - it "has a working function #array_in_len_zero_terminated" do + it 'has a working function #array_in_len_zero_terminated' do GIMarshallingTests.array_in_len_zero_terminated [-1, 0, 1, 2] pass end - it "has a working function #array_in_nonzero_nonlen" do + it 'has a working function #array_in_nonzero_nonlen' do skip unless get_introspection_data 'GIMarshallingTests', 'array_in_nonzero_nonlen' GIMarshallingTests.array_in_nonzero_nonlen 1, 'abcd'.bytes.to_a pass end - it "has a working function #array_in_utf8_two_in" do + it 'has a working function #array_in_utf8_two_in' do skip unless get_introspection_data 'GIMarshallingTests', 'array_in_utf8_two_in' - GIMarshallingTests.array_in_utf8_two_in [-1, 0, 1, 2], "1", "2" + GIMarshallingTests.array_in_utf8_two_in [-1, 0, 1, 2], '1', '2' pass end - it "has a working function #array_in_utf8_two_in_out_of_order" do + it 'has a working function #array_in_utf8_two_in_out_of_order' do skip unless get_introspection_data 'GIMarshallingTests', 'array_in_utf8_two_in_out_of_order' - GIMarshallingTests.array_in_utf8_two_in_out_of_order "1", [-1, 0, 1, 2], "2" + GIMarshallingTests.array_in_utf8_two_in_out_of_order '1', [-1, 0, 1, 2], '2' pass end - it "has a working function #array_inout" do + it 'has a working function #array_inout' do res = GIMarshallingTests.array_inout [-1, 0, 1, 2] res.must_be :==, [-2, -1, 0, 1, 2] end - it "has a working function #array_inout_etc" do + it 'has a working function #array_inout_etc' do arr, sum = GIMarshallingTests.array_inout_etc 42, [-1, 0, 1, 2], 24 arr.must_be :==, [42, -1, 0, 1, 24] sum.must_equal 42 + 24 end - it "has a working function #array_out" do + it 'has a working function #array_out' do res = GIMarshallingTests.array_out res.must_be :==, [-1, 0, 1, 2] end - it "has a working function #array_out_etc" do + it 'has a working function #array_out_etc' do arr, sum = GIMarshallingTests.array_out_etc 42, 24 arr.must_be :==, [42, 0, 1, 24] sum.must_equal 42 + 24 end - it "has a working function #array_return" do + it 'has a working function #array_return' do res = GIMarshallingTests.array_return res.must_be :==, [-1, 0, 1, 2] end - it "has a working function #array_return_etc" do + it 'has a working function #array_return_etc' do arr, sum = GIMarshallingTests.array_return_etc 42, 24 arr.must_be :==, [42, 0, 1, 24] sum.must_equal 42 + 24 end - it "has a working function #array_simple_struct_in" do + it 'has a working function #array_simple_struct_in' do arr = [1, 2, 3].map { |val| GIMarshallingTests::SimpleStruct.new.tap { |struct| struct.long_ = val } } GIMarshallingTests.array_simple_struct_in arr end - it "has a working function #array_string_in" do + it 'has a working function #array_string_in' do GIMarshallingTests.array_string_in %w(foo bar) pass end - it "has a working function #array_struct_in" do + it 'has a working function #array_struct_in' do arr = [1, 2, 3].map { |val| GIMarshallingTests::BoxedStruct.new.tap { |struct| struct.long_ = val } } @@ -1424,14 +1424,14 @@ def make_derived_instance end # NOTE: Should be run with valgrind. See gimarhallingtests.c. - it "has a working function #array_struct_take_in" do + it 'has a working function #array_struct_take_in' do arr = [1, 2, 3].map { |val| GIMarshallingTests::BoxedStruct.new.tap { |struct| struct.long_ = val } } GIMarshallingTests.array_struct_take_in arr end - it "has a working function #array_struct_value_in" do + it 'has a working function #array_struct_value_in' do skip unless get_introspection_data 'GIMarshallingTests', 'array_struct_value_in' arr = [1, 2, 3].map { |val| GIMarshallingTests::BoxedStruct.new.tap { |struct| struct.long_ = val } @@ -1439,109 +1439,109 @@ def make_derived_instance GIMarshallingTests.array_struct_value_in arr end - it "has a working function #array_uint8_in" do - arr = "abcd".bytes.to_a + it 'has a working function #array_uint8_in' do + arr = 'abcd'.bytes.to_a GIMarshallingTests.array_uint8_in arr pass end - it "has a working function #array_zero_terminated_in" do + it 'has a working function #array_zero_terminated_in' do GIMarshallingTests.array_zero_terminated_in %w(0 1 2) pass end - it "has a working function #array_zero_terminated_inout" do + it 'has a working function #array_zero_terminated_inout' do res = GIMarshallingTests.array_zero_terminated_inout %w(0 1 2) - res.must_be :==, ["-1", "0", "1", "2"] + res.must_be :==, ['-1', '0', '1', '2'] end - it "has a working function #array_zero_terminated_out" do + it 'has a working function #array_zero_terminated_out' do res = GIMarshallingTests.array_zero_terminated_out res.must_be :==, %w(0 1 2) end - it "has a working function #array_zero_terminated_return" do + it 'has a working function #array_zero_terminated_return' do res = GIMarshallingTests.array_zero_terminated_return res.must_be :==, %w(0 1 2) end - it "has a working function #array_zero_terminated_return_null" do + it 'has a working function #array_zero_terminated_return_null' do res = GIMarshallingTests.array_zero_terminated_return_null res.must_be :==, [] end - it "has a working function #array_zero_terminated_return_struct" do + it 'has a working function #array_zero_terminated_return_struct' do res = GIMarshallingTests.array_zero_terminated_return_struct res.to_a.map(&:long_).must_equal [42, 43, 44] end - it "has a working function #boolean_in_false" do + it 'has a working function #boolean_in_false' do GIMarshallingTests.boolean_in_false false pass end - it "has a working function #boolean_in_true" do + it 'has a working function #boolean_in_true' do GIMarshallingTests.boolean_in_true true pass end - it "has a working function #boolean_inout_false_true" do + it 'has a working function #boolean_inout_false_true' do res = GIMarshallingTests.boolean_inout_false_true false assert_equal true, res end - it "has a working function #boolean_inout_true_false" do + it 'has a working function #boolean_inout_true_false' do res = GIMarshallingTests.boolean_inout_true_false true assert_equal false, res end - it "has a working function #boolean_out_false" do + it 'has a working function #boolean_out_false' do res = GIMarshallingTests.boolean_out_false assert_equal false, res end - it "has a working function #boolean_out_true" do + it 'has a working function #boolean_out_true' do res = GIMarshallingTests.boolean_out_true assert_equal true, res end - it "has a working function #boolean_return_false" do + it 'has a working function #boolean_return_false' do res = GIMarshallingTests.boolean_return_false assert_equal false, res end - it "has a working function #boolean_return_true" do + it 'has a working function #boolean_return_true' do res = GIMarshallingTests.boolean_return_true assert_equal true, res end - it "has a working function #boxed_struct_inout" do + it 'has a working function #boxed_struct_inout' do bx = GIMarshallingTests::BoxedStruct.new bx.long_ = 42 res = GIMarshallingTests.boxed_struct_inout bx assert_equal 0, res.long_ end - it "has a working function #boxed_struct_out" do + it 'has a working function #boxed_struct_out' do res = GIMarshallingTests.boxed_struct_out assert_equal 42, res.long_ end - it "has a working function #boxed_struct_returnv" do + it 'has a working function #boxed_struct_returnv' do res = GIMarshallingTests.boxed_struct_returnv assert_equal 42, res.long_ res.g_strv.must_be :==, %w(0 1 2) end - it "has a working function #bytearray_full_return" do + it 'has a working function #bytearray_full_return' do ret = GIMarshallingTests.bytearray_full_return assert_instance_of GLib::ByteArray, ret assert_includes( - ["0123".bytes.to_a, "\x001\xFF3".bytes.to_a], + ['0123'.bytes.to_a, "\x001\xFF3".bytes.to_a], ret.to_string.bytes.to_a) end - it "has a working function #bytearray_none_in" do + it 'has a working function #bytearray_none_in' do val = GIMarshallingTests.bytearray_full_return.to_string ba = GLib::ByteArray.new ba = ba.append val @@ -1549,19 +1549,19 @@ def make_derived_instance pass end - it "has a working function #callback_multiple_out_parameters" do + it 'has a working function #callback_multiple_out_parameters' do result = GIMarshallingTests.callback_multiple_out_parameters proc { |*_args| [12.0, 13.0] } result.must_equal [12.0, 13.0] end - it "has a working function #callback_one_out_parameter" do + it 'has a working function #callback_one_out_parameter' do result = GIMarshallingTests.callback_one_out_parameter proc { 42.0 } result.must_equal 42.0 end - it "has a working function #callback_owned_boxed" do + it 'has a working function #callback_owned_boxed' do skip unless get_introspection_data 'GIMarshallingTests', 'callback_owned_boxed' a = nil @@ -1576,251 +1576,251 @@ def make_derived_instance a.must_equal 44 end - it "has a working function #callback_return_value_and_multiple_out_parameters" do + it 'has a working function #callback_return_value_and_multiple_out_parameters' do result = GIMarshallingTests.callback_return_value_and_multiple_out_parameters proc { |*_args| [42, -142, 3] } result.must_equal [42, -142, 3] end - it "has a working function #callback_return_value_and_one_out_parameter" do + it 'has a working function #callback_return_value_and_one_out_parameter' do result = GIMarshallingTests.callback_return_value_and_one_out_parameter proc { |*_args| [42, -142] } result.must_equal [42, -142] end - it "has a working function #callback_return_value_only" do + it 'has a working function #callback_return_value_only' do result = GIMarshallingTests.callback_return_value_only proc { 42 } result.must_equal 42 end - it "has a working function #double_in" do + it 'has a working function #double_in' do GIMarshallingTests.double_in Float::MAX pass end - it "has a working function #double_inout" do + it 'has a working function #double_inout' do ret = GIMarshallingTests.double_inout Float::MAX assert_in_epsilon 2.225e-308, ret end - it "has a working function #double_out" do + it 'has a working function #double_out' do ret = GIMarshallingTests.double_out assert_equal Float::MAX, ret end - it "has a working function #double_return" do + it 'has a working function #double_return' do ret = GIMarshallingTests.double_return assert_equal Float::MAX, ret end - it "has a working function #enum_in" do + it 'has a working function #enum_in' do GIMarshallingTests.enum_in :value3 pass end - it "has a working function #enum_inout" do + it 'has a working function #enum_inout' do e = GIMarshallingTests.enum_inout :value3 assert_equal :value1, e end - it "has a working function #enum_out" do + it 'has a working function #enum_out' do e = GIMarshallingTests.enum_out assert_equal :value3, e end - it "has a working function #enum_returnv" do + it 'has a working function #enum_returnv' do e = GIMarshallingTests.enum_returnv assert_equal :value3, e end - it "has a working function #filename_list_return" do + it 'has a working function #filename_list_return' do fl = GIMarshallingTests.filename_list_return assert_equal nil, fl end - it "has a working function #flags_in" do + it 'has a working function #flags_in' do GIMarshallingTests.flags_in :value2 pass end - it "has a working function #flags_in_zero" do + it 'has a working function #flags_in_zero' do GIMarshallingTests.flags_in_zero 0 pass end - it "has a working function #flags_inout" do + it 'has a working function #flags_inout' do res = GIMarshallingTests.flags_inout :value2 assert_equal :value1, res end - it "has a working function #flags_out" do + it 'has a working function #flags_out' do res = GIMarshallingTests.flags_out assert_equal :value2, res end - it "has a working function #flags_returnv" do + it 'has a working function #flags_returnv' do res = GIMarshallingTests.flags_returnv assert_equal :value2, res end - it "has a working function #float_in" do + it 'has a working function #float_in' do # float_return returns MAX_FLT flt = GIMarshallingTests.float_return GIMarshallingTests.float_in flt pass end - it "has a working function #float_inout" do + it 'has a working function #float_inout' do # float_return returns MAX_FLT flt = GIMarshallingTests.float_return res = GIMarshallingTests.float_inout flt assert_in_epsilon 1.175e-38, res end - it "has a working function #float_out" do + it 'has a working function #float_out' do flt = GIMarshallingTests.float_out assert_in_epsilon 3.402e+38, flt end - it "has a working function #float_return" do + it 'has a working function #float_return' do flt = GIMarshallingTests.float_return assert_in_epsilon 3.402e+38, flt end - it "has a working function #garray_int_none_in" do + it 'has a working function #garray_int_none_in' do arr = [-1, 0, 1, 2] GIMarshallingTests.garray_int_none_in arr pass end - it "has a working function #garray_int_none_return" do + it 'has a working function #garray_int_none_return' do arr = GIMarshallingTests.garray_int_none_return arr.must_be :==, [-1, 0, 1, 2] end - it "has a working function #garray_uint64_none_in" do + it 'has a working function #garray_uint64_none_in' do skip unless get_introspection_data 'GIMarshallingTests', 'garray_uint64_none_in' GIMarshallingTests.garray_uint64_none_in [0, 0xffff_ffff_ffff_ffff] pass end - it "has a working function #garray_uint64_none_return" do + it 'has a working function #garray_uint64_none_return' do skip unless get_introspection_data 'GIMarshallingTests', 'garray_uint64_none_return' res = GIMarshallingTests.garray_uint64_none_return res.must_be :==, [0, 0xffff_ffff_ffff_ffff] end - it "has a working function #garray_utf8_container_inout" do + it 'has a working function #garray_utf8_container_inout' do res = GIMarshallingTests.garray_utf8_container_inout %w(0 1 2) - res.must_be :==, ["-2", "-1", "0", "1"] + res.must_be :==, ['-2', '-1', '0', '1'] end - it "has a working function #garray_utf8_container_out" do + it 'has a working function #garray_utf8_container_out' do res = GIMarshallingTests.garray_utf8_container_out res.must_be :==, %w(0 1 2) end - it "has a working function #garray_utf8_container_return" do + it 'has a working function #garray_utf8_container_return' do res = GIMarshallingTests.garray_utf8_container_return res.must_be :==, %w(0 1 2) end - it "has a working function #garray_utf8_full_inout" do + it 'has a working function #garray_utf8_full_inout' do arr = %w(0 1 2) res = GIMarshallingTests.garray_utf8_full_inout arr - res.must_be :==, ["-2", "-1", "0", "1"] + res.must_be :==, ['-2', '-1', '0', '1'] end - it "has a working function #garray_utf8_full_out" do + it 'has a working function #garray_utf8_full_out' do res = GIMarshallingTests.garray_utf8_full_out res.must_be :==, %w(0 1 2) end - it "has a working function #garray_utf8_full_out_caller_allocated" do + it 'has a working function #garray_utf8_full_out_caller_allocated' do skip unless get_introspection_data 'GIMarshallingTests', 'garray_utf8_full_out_caller_allocated' res = GIMarshallingTests.garray_utf8_full_out_caller_allocated res.must_be :==, %w(0 1 2) end - it "has a working function #garray_utf8_full_return" do + it 'has a working function #garray_utf8_full_return' do res = GIMarshallingTests.garray_utf8_full_return res.must_be :==, %w(0 1 2) end - it "has a working function #garray_utf8_none_in" do + it 'has a working function #garray_utf8_none_in' do arr = %w(0 1 2) GIMarshallingTests.garray_utf8_none_in arr pass end - it "has a working function #garray_utf8_none_inout" do + it 'has a working function #garray_utf8_none_inout' do arr = %w(0 1 2) res = GIMarshallingTests.garray_utf8_none_inout arr - res.must_be :==, ["-2", "-1", "0", "1"] + res.must_be :==, ['-2', '-1', '0', '1'] end - it "has a working function #garray_utf8_none_out" do + it 'has a working function #garray_utf8_none_out' do res = GIMarshallingTests.garray_utf8_none_out res.must_be :==, %w(0 1 2) end - it "has a working function #garray_utf8_none_return" do + it 'has a working function #garray_utf8_none_return' do res = GIMarshallingTests.garray_utf8_none_return res.must_be :==, %w(0 1 2) end - it "has a working function #gbytes_full_return" do + it 'has a working function #gbytes_full_return' do skip unless get_introspection_data 'GIMarshallingTests', 'gbytes_full_return' res = GIMarshallingTests.gbytes_full_return res.to_a.must_equal [0, 49, 0xFF, 51] end - it "has a working function #gbytes_none_in" do + it 'has a working function #gbytes_none_in' do skip unless get_introspection_data 'GIMarshallingTests', 'gbytes_none_in' GIMarshallingTests.gbytes_none_in [0, 49, 0xFF, 51] pass end - it "has a working function #gclosure_in" do + it 'has a working function #gclosure_in' do cl = GObject::RubyClosure.new { 42 } GIMarshallingTests.gclosure_in cl pass end - it "has a working function #gclosure_return" do + it 'has a working function #gclosure_return' do cl = GIMarshallingTests.gclosure_return gv = GObject::Value.wrap_ruby_value 0 cl.invoke gv, nil, nil assert_equal 42, gv.get_value end - it "has a working function #genum_in" do + it 'has a working function #genum_in' do GIMarshallingTests.genum_in :value3 pass end - it "has a working function #genum_inout" do + it 'has a working function #genum_inout' do res = GIMarshallingTests.genum_inout :value3 assert_equal :value1, res end - it "has a working function #genum_out" do + it 'has a working function #genum_out' do res = GIMarshallingTests.genum_out assert_equal :value3, res end - it "has a working function #genum_returnv" do + it 'has a working function #genum_returnv' do res = GIMarshallingTests.genum_returnv assert_equal :value3, res end - it "has a working function #gerror" do + it 'has a working function #gerror' do begin GIMarshallingTests.gerror - flunk "Error should have been raised" + flunk 'Error should have been raised' rescue GirFFI::GLibError => e e.message.must_equal GIMarshallingTests::CONSTANT_GERROR_MESSAGE e.domain.must_equal GIMarshallingTests::CONSTANT_GERROR_DOMAIN @@ -1828,10 +1828,10 @@ def make_derived_instance end end - it "has a working function #gerror_array_in" do + it 'has a working function #gerror_array_in' do begin GIMarshallingTests.gerror_array_in [1, 2, 3] - flunk "Error should have been raised" + flunk 'Error should have been raised' rescue GirFFI::GLibError => e e.message.must_equal GIMarshallingTests::CONSTANT_GERROR_MESSAGE e.domain.must_equal GIMarshallingTests::CONSTANT_GERROR_DOMAIN @@ -1839,356 +1839,356 @@ def make_derived_instance end end - it "has a working function #gerror_out" do + it 'has a working function #gerror_out' do error, debug = GIMarshallingTests.gerror_out debug.must_equal GIMarshallingTests::CONSTANT_GERROR_DEBUG_MESSAGE error.message.must_equal GIMarshallingTests::CONSTANT_GERROR_MESSAGE end - it "has a working function #gerror_out_transfer_none" do + it 'has a working function #gerror_out_transfer_none' do error, debug = GIMarshallingTests.gerror_out_transfer_none debug.must_equal GIMarshallingTests::CONSTANT_GERROR_DEBUG_MESSAGE error.message.must_equal GIMarshallingTests::CONSTANT_GERROR_MESSAGE end - it "has a working function #gerror_return" do + it 'has a working function #gerror_return' do error = GIMarshallingTests.gerror_return error.message.must_equal GIMarshallingTests::CONSTANT_GERROR_MESSAGE end - it "has a working function #ghashtable_int_none_in" do + it 'has a working function #ghashtable_int_none_in' do GIMarshallingTests.ghashtable_int_none_in( -1 => 1, 0 => 0, 1 => -1, 2 => -2) end - it "has a working function #ghashtable_int_none_return" do + it 'has a working function #ghashtable_int_none_return' do gh = GIMarshallingTests.ghashtable_int_none_return assert_equal({ -1 => 1, 0 => 0, 1 => -1, 2 => -2 }, gh.to_hash) end - it "has a working function #ghashtable_utf8_container_in" do - skip "This function is defined in the header but not implemented" + it 'has a working function #ghashtable_utf8_container_in' do + skip 'This function is defined in the header but not implemented' end - it "has a working function #ghashtable_utf8_container_inout" do - hsh = { "-1" => "1", "0" => "0", "1" => "-1", "2" => "-2" } + it 'has a working function #ghashtable_utf8_container_inout' do + hsh = { '-1' => '1', '0' => '0', '1' => '-1', '2' => '-2' } res = GIMarshallingTests.ghashtable_utf8_container_inout hsh - assert_equal({ "-1" => "1", "0" => "0", "1" => "1" }, res.to_hash) + assert_equal({ '-1' => '1', '0' => '0', '1' => '1' }, res.to_hash) end - it "has a working function #ghashtable_utf8_container_out" do + it 'has a working function #ghashtable_utf8_container_out' do res = GIMarshallingTests.ghashtable_utf8_container_out - assert_equal({ "-1" => "1", "0" => "0", "1" => "-1", "2" => "-2" }, + assert_equal({ '-1' => '1', '0' => '0', '1' => '-1', '2' => '-2' }, res.to_hash) end - it "has a working function #ghashtable_utf8_container_return" do + it 'has a working function #ghashtable_utf8_container_return' do res = GIMarshallingTests.ghashtable_utf8_container_return - assert_equal({ "-1" => "1", "0" => "0", "1" => "-1", "2" => "-2" }, + assert_equal({ '-1' => '1', '0' => '0', '1' => '-1', '2' => '-2' }, res.to_hash) end - it "has a working function #ghashtable_utf8_full_in" do - skip "This function is defined in the header but not implemented" + it 'has a working function #ghashtable_utf8_full_in' do + skip 'This function is defined in the header but not implemented' end - it "has a working function #ghashtable_utf8_full_inout" do - hsh = { "-1" => "1", "0" => "0", "1" => "-1", "2" => "-2" } + it 'has a working function #ghashtable_utf8_full_inout' do + hsh = { '-1' => '1', '0' => '0', '1' => '-1', '2' => '-2' } res = GIMarshallingTests.ghashtable_utf8_full_inout hsh - assert_equal({ "-1" => "1", "0" => "0", "1" => "1" }, res.to_hash) + assert_equal({ '-1' => '1', '0' => '0', '1' => '1' }, res.to_hash) end - it "has a working function #ghashtable_utf8_full_out" do + it 'has a working function #ghashtable_utf8_full_out' do res = GIMarshallingTests.ghashtable_utf8_full_out - assert_equal({ "-1" => "1", "0" => "0", "1" => "-1", "2" => "-2" }, + assert_equal({ '-1' => '1', '0' => '0', '1' => '-1', '2' => '-2' }, res.to_hash) end - it "has a working function #ghashtable_utf8_full_return" do + it 'has a working function #ghashtable_utf8_full_return' do res = GIMarshallingTests.ghashtable_utf8_full_return - assert_equal({ "-1" => "1", "0" => "0", "1" => "-1", "2" => "-2" }, + assert_equal({ '-1' => '1', '0' => '0', '1' => '-1', '2' => '-2' }, res.to_hash) end - it "has a working function #ghashtable_utf8_none_in" do - hsh = { "-1" => "1", "0" => "0", "1" => "-1", "2" => "-2" } + it 'has a working function #ghashtable_utf8_none_in' do + hsh = { '-1' => '1', '0' => '0', '1' => '-1', '2' => '-2' } GIMarshallingTests.ghashtable_utf8_none_in hsh pass end - it "has a working function #ghashtable_utf8_none_inout" do - hsh = { "-1" => "1", "0" => "0", "1" => "-1", "2" => "-2" } + it 'has a working function #ghashtable_utf8_none_inout' do + hsh = { '-1' => '1', '0' => '0', '1' => '-1', '2' => '-2' } res = GIMarshallingTests.ghashtable_utf8_none_inout hsh - assert_equal({ "-1" => "1", "0" => "0", "1" => "1" }, res.to_hash) + assert_equal({ '-1' => '1', '0' => '0', '1' => '1' }, res.to_hash) end - it "has a working function #ghashtable_utf8_none_out" do + it 'has a working function #ghashtable_utf8_none_out' do res = GIMarshallingTests.ghashtable_utf8_none_out - assert_equal({ "-1" => "1", "0" => "0", "1" => "-1", "2" => "-2" }, + assert_equal({ '-1' => '1', '0' => '0', '1' => '-1', '2' => '-2' }, res.to_hash) end - it "has a working function #ghashtable_utf8_none_return" do + it 'has a working function #ghashtable_utf8_none_return' do res = GIMarshallingTests.ghashtable_utf8_none_return - assert_equal({ "-1" => "1", "0" => "0", "1" => "-1", "2" => "-2" }, + assert_equal({ '-1' => '1', '0' => '0', '1' => '-1', '2' => '-2' }, res.to_hash) end - it "has a working function #glist_int_none_in" do + it 'has a working function #glist_int_none_in' do GIMarshallingTests.glist_int_none_in [-1, 0, 1, 2] pass end - it "has a working function #glist_int_none_return" do + it 'has a working function #glist_int_none_return' do res = GIMarshallingTests.glist_int_none_return res.must_be :==, [-1, 0, 1, 2] end - it "has a working function #glist_uint32_none_in" do + it 'has a working function #glist_uint32_none_in' do skip unless get_introspection_data 'GIMarshallingTests', 'glist_uint32_none_in' GIMarshallingTests.glist_uint32_none_in [0, 0xffff_ffff] pass end - it "has a working function #glist_uint32_none_return" do + it 'has a working function #glist_uint32_none_return' do skip unless get_introspection_data 'GIMarshallingTests', 'glist_uint32_none_return' res = GIMarshallingTests.glist_uint32_none_return res.must_be :==, [0, 0xffff_ffff] end - it "has a working function #glist_utf8_container_inout" do + it 'has a working function #glist_utf8_container_inout' do res = GIMarshallingTests.glist_utf8_container_inout %w(0 1 2) - res.must_be :==, ["-2", "-1", "0", "1"] + res.must_be :==, ['-2', '-1', '0', '1'] end - it "has a working function #glist_utf8_container_out" do + it 'has a working function #glist_utf8_container_out' do res = GIMarshallingTests.glist_utf8_container_out res.must_be :==, %w(0 1 2) end - it "has a working function #glist_utf8_container_return" do + it 'has a working function #glist_utf8_container_return' do res = GIMarshallingTests.glist_utf8_container_return res.must_be :==, %w(0 1 2) end - it "has a working function #glist_utf8_full_inout" do + it 'has a working function #glist_utf8_full_inout' do res = GIMarshallingTests.glist_utf8_full_inout %w(0 1 2) - res.must_be :==, ["-2", "-1", "0", "1"] + res.must_be :==, ['-2', '-1', '0', '1'] end - it "has a working function #glist_utf8_full_out" do + it 'has a working function #glist_utf8_full_out' do res = GIMarshallingTests.glist_utf8_full_out res.must_be :==, %w(0 1 2) end - it "has a working function #glist_utf8_full_return" do + it 'has a working function #glist_utf8_full_return' do res = GIMarshallingTests.glist_utf8_full_return res.must_be :==, %w(0 1 2) end - it "has a working function #glist_utf8_none_in" do + it 'has a working function #glist_utf8_none_in' do GIMarshallingTests.glist_utf8_none_in %w(0 1 2) end - it "has a working function #glist_utf8_none_inout" do + it 'has a working function #glist_utf8_none_inout' do res = GIMarshallingTests.glist_utf8_none_inout %w(0 1 2) - res.must_be :==, ["-2", "-1", "0", "1"] + res.must_be :==, ['-2', '-1', '0', '1'] end - it "has a working function #glist_utf8_none_out" do + it 'has a working function #glist_utf8_none_out' do res = GIMarshallingTests.glist_utf8_none_out res.must_be :==, %w(0 1 2) end - it "has a working function #glist_utf8_none_return" do + it 'has a working function #glist_utf8_none_return' do res = GIMarshallingTests.glist_utf8_none_return res.must_be :==, %w(0 1 2) end - it "has a working function #gptrarray_utf8_container_inout" do + it 'has a working function #gptrarray_utf8_container_inout' do res = GIMarshallingTests.gptrarray_utf8_container_inout %w(0 1 2) - res.must_be :==, ["-2", "-1", "0", "1"] + res.must_be :==, ['-2', '-1', '0', '1'] end - it "has a working function #gptrarray_utf8_container_out" do + it 'has a working function #gptrarray_utf8_container_out' do res = GIMarshallingTests.gptrarray_utf8_container_out res.must_be :==, %w(0 1 2) end - it "has a working function #gptrarray_utf8_container_return" do + it 'has a working function #gptrarray_utf8_container_return' do res = GIMarshallingTests.gptrarray_utf8_container_return res.must_be :==, %w(0 1 2) end - it "has a working function #gptrarray_utf8_full_inout" do + it 'has a working function #gptrarray_utf8_full_inout' do res = GIMarshallingTests.gptrarray_utf8_full_inout %w(0 1 2) - res.must_be :==, ["-2", "-1", "0", "1"] + res.must_be :==, ['-2', '-1', '0', '1'] end - it "has a working function #gptrarray_utf8_full_out" do + it 'has a working function #gptrarray_utf8_full_out' do res = GIMarshallingTests.gptrarray_utf8_full_out res.must_be :==, %w(0 1 2) end - it "has a working function #gptrarray_utf8_full_return" do + it 'has a working function #gptrarray_utf8_full_return' do res = GIMarshallingTests.gptrarray_utf8_full_return res.must_be :==, %w(0 1 2) end - it "has a working function #gptrarray_utf8_none_in" do + it 'has a working function #gptrarray_utf8_none_in' do GIMarshallingTests.gptrarray_utf8_none_in %w(0 1 2) end - it "has a working function #gptrarray_utf8_none_inout" do + it 'has a working function #gptrarray_utf8_none_inout' do res = GIMarshallingTests.gptrarray_utf8_none_inout %w(0 1 2) - res.must_be :==, ["-2", "-1", "0", "1"] + res.must_be :==, ['-2', '-1', '0', '1'] end - it "has a working function #gptrarray_utf8_none_out" do + it 'has a working function #gptrarray_utf8_none_out' do res = GIMarshallingTests.gptrarray_utf8_none_out res.must_be :==, %w(0 1 2) end - it "has a working function #gptrarray_utf8_none_return" do + it 'has a working function #gptrarray_utf8_none_return' do res = GIMarshallingTests.gptrarray_utf8_none_return res.must_be :==, %w(0 1 2) end - it "has a working function #gslist_int_none_in" do + it 'has a working function #gslist_int_none_in' do GIMarshallingTests.gslist_int_none_in [-1, 0, 1, 2] pass end - it "has a working function #gslist_int_none_return" do + it 'has a working function #gslist_int_none_return' do res = GIMarshallingTests.gslist_int_none_return res.must_be :==, [-1, 0, 1, 2] end - it "has a working function #gslist_utf8_container_inout" do + it 'has a working function #gslist_utf8_container_inout' do res = GIMarshallingTests.gslist_utf8_container_inout %w(0 1 2) - res.must_be :==, ["-2", "-1", "0", "1"] + res.must_be :==, ['-2', '-1', '0', '1'] end - it "has a working function #gslist_utf8_container_out" do + it 'has a working function #gslist_utf8_container_out' do res = GIMarshallingTests.gslist_utf8_container_out res.must_be :==, %w(0 1 2) end - it "has a working function #gslist_utf8_container_return" do + it 'has a working function #gslist_utf8_container_return' do res = GIMarshallingTests.gslist_utf8_container_return res.must_be :==, %w(0 1 2) end - it "has a working function #gslist_utf8_full_inout" do + it 'has a working function #gslist_utf8_full_inout' do res = GIMarshallingTests.gslist_utf8_full_inout %w(0 1 2) - res.must_be :==, ["-2", "-1", "0", "1"] + res.must_be :==, ['-2', '-1', '0', '1'] end - it "has a working function #gslist_utf8_full_out" do + it 'has a working function #gslist_utf8_full_out' do res = GIMarshallingTests.gslist_utf8_full_out res.must_be :==, %w(0 1 2) end - it "has a working function #gslist_utf8_full_return" do + it 'has a working function #gslist_utf8_full_return' do res = GIMarshallingTests.gslist_utf8_full_return res.must_be :==, %w(0 1 2) end - it "has a working function #gslist_utf8_none_in" do + it 'has a working function #gslist_utf8_none_in' do GIMarshallingTests.gslist_utf8_none_in %w(0 1 2) pass end - it "has a working function #gslist_utf8_none_inout" do + it 'has a working function #gslist_utf8_none_inout' do res = GIMarshallingTests.gslist_utf8_none_inout %w(0 1 2) - res.must_be :==, ["-2", "-1", "0", "1"] + res.must_be :==, ['-2', '-1', '0', '1'] end - it "has a working function #gslist_utf8_none_out" do + it 'has a working function #gslist_utf8_none_out' do res = GIMarshallingTests.gslist_utf8_none_out res.must_be :==, %w(0 1 2) end - it "has a working function #gslist_utf8_none_return" do + it 'has a working function #gslist_utf8_none_return' do res = GIMarshallingTests.gslist_utf8_none_return res.must_be :==, %w(0 1 2) end - it "has a working function #gstrv_in" do + it 'has a working function #gstrv_in' do GIMarshallingTests.gstrv_in %w(0 1 2) pass end - it "has a working function #gstrv_inout" do + it 'has a working function #gstrv_inout' do res = GIMarshallingTests.gstrv_inout %w(0 1 2) - res.must_be :==, ["-1", "0", "1", "2"] + res.must_be :==, ['-1', '0', '1', '2'] end - it "has a working function #gstrv_out" do + it 'has a working function #gstrv_out' do res = GIMarshallingTests.gstrv_out res.must_be :==, %w(0 1 2) end - it "has a working function #gstrv_return" do + it 'has a working function #gstrv_return' do res = GIMarshallingTests.gstrv_return res.must_be :==, %w(0 1 2) end - it "has a working function #gtype_in" do + it 'has a working function #gtype_in' do GIMarshallingTests.gtype_in GObject::TYPE_NONE pass end - it "has a working function #gtype_inout" do + it 'has a working function #gtype_inout' do res = GIMarshallingTests.gtype_inout GObject::TYPE_NONE res.must_equal GObject::TYPE_INT end - it "has a working function #gtype_out" do + it 'has a working function #gtype_out' do res = GIMarshallingTests.gtype_out res.must_equal GObject::TYPE_NONE end - it "has a working function #gtype_return" do + it 'has a working function #gtype_return' do res = GIMarshallingTests.gtype_return res.must_equal GObject::TYPE_NONE end - it "has a working function #gtype_string_in" do + it 'has a working function #gtype_string_in' do GIMarshallingTests.gtype_string_in GObject::TYPE_STRING pass end - it "has a working function #gtype_string_out" do + it 'has a working function #gtype_string_out' do res = GIMarshallingTests.gtype_string_out res.must_equal GObject::TYPE_STRING end - it "has a working function #gtype_string_return" do + it 'has a working function #gtype_string_return' do res = GIMarshallingTests.gtype_string_return res.must_equal GObject::TYPE_STRING end - it "has a working function #gvalue_flat_array" do - GIMarshallingTests.gvalue_flat_array [42, "42", true] + it 'has a working function #gvalue_flat_array' do + GIMarshallingTests.gvalue_flat_array [42, '42', true] pass end - it "has a working function #gvalue_flat_array_round_trip" do - result = GIMarshallingTests.gvalue_flat_array_round_trip 42, "42", true + it 'has a working function #gvalue_flat_array_round_trip' do + result = GIMarshallingTests.gvalue_flat_array_round_trip 42, '42', true arr = result.to_a arr[0].get_value.must_equal 42 - arr[1].get_value.must_equal "42" + arr[1].get_value.must_equal '42' arr[2].get_value.must_equal true end - it "has a working function #gvalue_in" do + it 'has a working function #gvalue_in' do GIMarshallingTests.gvalue_in GObject::Value.wrap_ruby_value(42) GIMarshallingTests.gvalue_in 42 pass end - it "has a working function #gvalue_in_enum" do + it 'has a working function #gvalue_in_enum' do gv = GObject::Value.new gv.init GIMarshallingTests::GEnum.get_gtype gv.set_enum GIMarshallingTests::GEnum[:value3] @@ -2196,28 +2196,28 @@ def make_derived_instance pass end - it "has a working function #gvalue_in_with_modification" do + it 'has a working function #gvalue_in_with_modification' do skip unless get_introspection_data 'GIMarshallingTests', 'gvalue_in_with_modification' gv = GObject::Value.wrap_ruby_value(42) GIMarshallingTests.gvalue_in_with_modification gv gv.get_value.must_equal 24 end - it "has a working function #gvalue_in_with_type" do + it 'has a working function #gvalue_in_with_type' do gv = GObject::Value.new gv.init GIMarshallingTests::SubSubObject.get_gtype GIMarshallingTests.gvalue_in_with_type gv, GIMarshallingTests::Object.get_gtype end - it "has a working function #gvalue_inout" do + it 'has a working function #gvalue_inout' do res = GIMarshallingTests.gvalue_inout GObject::Value.wrap_ruby_value(42) - assert_equal "42", res.get_value + assert_equal '42', res.get_value res = GIMarshallingTests.gvalue_inout 42 - assert_equal "42", res.get_value + assert_equal '42', res.get_value end - it "has a working function #gvalue_int64_in" do + it 'has a working function #gvalue_int64_in' do skip unless get_introspection_data 'GIMarshallingTests', 'gvalue_int64_in' gv = GObject::Value.new gv.init GObject::TYPE_INT64 @@ -2226,496 +2226,496 @@ def make_derived_instance pass end - it "has a working function #gvalue_int64_out" do + it 'has a working function #gvalue_int64_out' do skip unless get_introspection_data 'GIMarshallingTests', 'gvalue_int64_out' gv = GIMarshallingTests.gvalue_int64_out gv.get_value.must_equal 0x7fff_ffff_ffff_ffff end - it "has a working function #gvalue_out" do + it 'has a working function #gvalue_out' do res = GIMarshallingTests.gvalue_out assert_equal 42, res.get_value end - it "has a working function #gvalue_out_caller_allocates" do + it 'has a working function #gvalue_out_caller_allocates' do skip unless get_introspection_data 'GIMarshallingTests', 'gvalue_out_caller_allocates' res = GIMarshallingTests.gvalue_out_caller_allocates res.get_value.must_equal 42 end - it "has a working function #gvalue_return" do + it 'has a working function #gvalue_return' do res = GIMarshallingTests.gvalue_return assert_equal 42, res.get_value end - it "has a working function #init_function" do + it 'has a working function #init_function' do res, arr = GIMarshallingTests.init_function %w(foo bar baz) res.must_equal true arr.must_be :==, %w(foo bar) end - it "has a working function #int16_in_max" do + it 'has a working function #int16_in_max' do GIMarshallingTests.int16_in_max 0x7fff pass end - it "has a working function #int16_in_min" do + it 'has a working function #int16_in_min' do GIMarshallingTests.int16_in_min(-0x8000) pass end - it "has a working function #int16_inout_max_min" do + it 'has a working function #int16_inout_max_min' do res = GIMarshallingTests.int16_inout_max_min 0x7fff assert_equal res, -0x8000 end - it "has a working function #int16_inout_min_max" do + it 'has a working function #int16_inout_min_max' do res = GIMarshallingTests.int16_inout_min_max(-0x8000) assert_equal 0x7fff, res end - it "has a working function #int16_out_max" do + it 'has a working function #int16_out_max' do res = GIMarshallingTests.int16_out_max assert_equal 0x7fff, res end - it "has a working function #int16_out_min" do + it 'has a working function #int16_out_min' do res = GIMarshallingTests.int16_out_min assert_equal(-0x8000, res) end - it "has a working function #int16_return_max" do + it 'has a working function #int16_return_max' do res = GIMarshallingTests.int16_return_max assert_equal 0x7fff, res end - it "has a working function #int16_return_min" do + it 'has a working function #int16_return_min' do res = GIMarshallingTests.int16_return_min assert_equal(-0x8000, res) end - it "has a working function #int32_in_max" do + it 'has a working function #int32_in_max' do GIMarshallingTests.int32_in_max 0x7fffffff pass end - it "has a working function #int32_in_min" do + it 'has a working function #int32_in_min' do GIMarshallingTests.int32_in_min(-0x80000000) pass end - it "has a working function #int32_inout_max_min" do + it 'has a working function #int32_inout_max_min' do res = GIMarshallingTests.int32_inout_max_min 0x7fffffff assert_equal(-0x80000000, res) end - it "has a working function #int32_inout_min_max" do + it 'has a working function #int32_inout_min_max' do res = GIMarshallingTests.int32_inout_min_max(-0x80000000) assert_equal 0x7fffffff, res end - it "has a working function #int32_out_max" do + it 'has a working function #int32_out_max' do res = GIMarshallingTests.int32_out_max assert_equal 0x7fffffff, res end - it "has a working function #int32_out_min" do + it 'has a working function #int32_out_min' do res = GIMarshallingTests.int32_out_min assert_equal(-0x80000000, res) end - it "has a working function #int32_return_max" do + it 'has a working function #int32_return_max' do res = GIMarshallingTests.int32_return_max assert_equal 0x7fffffff, res end - it "has a working function #int32_return_min" do + it 'has a working function #int32_return_min' do res = GIMarshallingTests.int32_return_min assert_equal(-0x80000000, res) end - it "has a working function #int64_in_max" do + it 'has a working function #int64_in_max' do GIMarshallingTests.int64_in_max 0x7fffffffffffffff pass end - it "has a working function #int64_in_min" do + it 'has a working function #int64_in_min' do GIMarshallingTests.int64_in_min(-0x8000000000000000) pass end - it "has a working function #int64_inout_max_min" do + it 'has a working function #int64_inout_max_min' do res = GIMarshallingTests.int64_inout_max_min 0x7fffffffffffffff assert_equal(-0x8000000000000000, res) end - it "has a working function #int64_inout_min_max" do + it 'has a working function #int64_inout_min_max' do res = GIMarshallingTests.int64_inout_min_max(-0x8000000000000000) assert_equal 0x7fffffffffffffff, res end - it "has a working function #int64_out_max" do + it 'has a working function #int64_out_max' do res = GIMarshallingTests.int64_out_max assert_equal 0x7fffffffffffffff, res end - it "has a working function #int64_out_min" do + it 'has a working function #int64_out_min' do res = GIMarshallingTests.int64_out_min assert_equal(-0x8000000000000000, res) end - it "has a working function #int64_return_max" do + it 'has a working function #int64_return_max' do res = GIMarshallingTests.int64_return_max assert_equal 0x7fffffffffffffff, res end - it "has a working function #int64_return_min" do + it 'has a working function #int64_return_min' do res = GIMarshallingTests.int64_return_min assert_equal(-0x8000000000000000, res) end - it "has a working function #int8_in_max" do + it 'has a working function #int8_in_max' do GIMarshallingTests.int8_in_max 0x7f pass end - it "has a working function #int8_in_min" do + it 'has a working function #int8_in_min' do GIMarshallingTests.int8_in_min(-0x80) pass end - it "has a working function #int8_inout_max_min" do + it 'has a working function #int8_inout_max_min' do res = GIMarshallingTests.int8_inout_max_min 0x7f assert_equal(-0x80, res) end - it "has a working function #int8_inout_min_max" do + it 'has a working function #int8_inout_min_max' do res = GIMarshallingTests.int8_inout_min_max(-0x80) assert_equal 0x7f, res end - it "has a working function #int8_out_max" do + it 'has a working function #int8_out_max' do res = GIMarshallingTests.int8_out_max assert_equal 0x7f, res end - it "has a working function #int8_out_min" do + it 'has a working function #int8_out_min' do res = GIMarshallingTests.int8_out_min assert_equal(-0x80, res) end - it "has a working function #int8_return_max" do + it 'has a working function #int8_return_max' do res = GIMarshallingTests.int8_return_max assert_equal 0x7f, res end - it "has a working function #int8_return_min" do + it 'has a working function #int8_return_min' do res = GIMarshallingTests.int8_return_min assert_equal(-0x80, res) end - it "has a working function #int_in_max" do + it 'has a working function #int_in_max' do GIMarshallingTests.int_in_max 0x7fffffff pass end - it "has a working function #int_in_min" do + it 'has a working function #int_in_min' do GIMarshallingTests.int_in_min(-0x80000000) pass end - it "has a working function #int_inout_max_min" do + it 'has a working function #int_inout_max_min' do res = GIMarshallingTests.int_inout_max_min 0x7fffffff assert_equal(-0x80000000, res) end - it "has a working function #int_inout_min_max" do + it 'has a working function #int_inout_min_max' do res = GIMarshallingTests.int_inout_min_max(-0x80000000) assert_equal 0x7fffffff, res end - it "has a working function #int_one_in_utf8_two_in_one_allows_none" do + it 'has a working function #int_one_in_utf8_two_in_one_allows_none' do skip unless get_introspection_data('GIMarshallingTests', 'int_one_in_utf8_two_in_one_allows_none') - GIMarshallingTests.int_one_in_utf8_two_in_one_allows_none 1, "2", "3" - GIMarshallingTests.int_one_in_utf8_two_in_one_allows_none 1, nil, "3" + GIMarshallingTests.int_one_in_utf8_two_in_one_allows_none 1, '2', '3' + GIMarshallingTests.int_one_in_utf8_two_in_one_allows_none 1, nil, '3' pass end - it "has a working function #int_out_max" do + it 'has a working function #int_out_max' do res = GIMarshallingTests.int_out_max assert_equal 0x7fffffff, res end - it "has a working function #int_out_min" do + it 'has a working function #int_out_min' do res = GIMarshallingTests.int_out_min assert_equal(-0x80000000, res) end - it "has a working function #int_out_out" do + it 'has a working function #int_out_out' do res = GIMarshallingTests.int_out_out assert_equal [6, 7], res end - it "has a working function #int_return_max" do + it 'has a working function #int_return_max' do res = GIMarshallingTests.int_return_max assert_equal 0x7fffffff, res end - it "has a working function #int_return_min" do + it 'has a working function #int_return_min' do res = GIMarshallingTests.int_return_min assert_equal(-0x80000000, res) end - it "has a working function #int_return_out" do + it 'has a working function #int_return_out' do res = GIMarshallingTests.int_return_out assert_equal [6, 7], res end - it "has a working function #int_three_in_three_out" do + it 'has a working function #int_three_in_three_out' do res = GIMarshallingTests.int_three_in_three_out 4, 5, 6 assert_equal [4, 5, 6], res end - it "has a working function #int_two_in_utf8_two_in_with_allow_none" do + it 'has a working function #int_two_in_utf8_two_in_with_allow_none' do skip unless get_introspection_data('GIMarshallingTests', 'int_two_in_utf8_two_in_with_allow_none') - GIMarshallingTests.int_two_in_utf8_two_in_with_allow_none 1, 2, "3", "4" + GIMarshallingTests.int_two_in_utf8_two_in_with_allow_none 1, 2, '3', '4' GIMarshallingTests.int_two_in_utf8_two_in_with_allow_none 1, 2, nil, nil pass end - it "has a working function #long_in_max" do + it 'has a working function #long_in_max' do GIMarshallingTests.long_in_max max_long pass end - it "has a working function #long_in_min" do + it 'has a working function #long_in_min' do GIMarshallingTests.long_in_min min_long pass end - it "has a working function #long_inout_max_min" do + it 'has a working function #long_inout_max_min' do res = GIMarshallingTests.long_inout_max_min max_long assert_equal min_long, res end - it "has a working function #long_inout_min_max" do + it 'has a working function #long_inout_min_max' do res = GIMarshallingTests.long_inout_min_max min_long assert_equal max_long, res end - it "has a working function #long_out_max" do + it 'has a working function #long_out_max' do res = GIMarshallingTests.long_out_max assert_equal max_long, res end - it "has a working function #long_out_min" do + it 'has a working function #long_out_min' do res = GIMarshallingTests.long_out_min assert_equal min_long, res end - it "has a working function #long_return_max" do + it 'has a working function #long_return_max' do res = GIMarshallingTests.long_return_max assert_equal max_long, res end - it "has a working function #long_return_min" do + it 'has a working function #long_return_min' do res = GIMarshallingTests.long_return_min assert_equal min_long, res end - it "has a working function #multi_array_key_value_in" do + it 'has a working function #multi_array_key_value_in' do keys = %w(one two three) values = [1, 2, 3].map { |val| GObject::Value.wrap_ruby_value val } GIMarshallingTests.multi_array_key_value_in keys, values end - it "has a working function #no_type_flags_in" do + it 'has a working function #no_type_flags_in' do GIMarshallingTests.no_type_flags_in :value2 pass end - it "has a working function #no_type_flags_in_zero" do + it 'has a working function #no_type_flags_in_zero' do GIMarshallingTests.no_type_flags_in_zero 0 pass end - it "has a working function #no_type_flags_inout" do + it 'has a working function #no_type_flags_inout' do res = GIMarshallingTests.no_type_flags_inout :value2 assert_equal :value1, res end - it "has a working function #no_type_flags_out" do + it 'has a working function #no_type_flags_out' do res = GIMarshallingTests.no_type_flags_out assert_equal :value2, res end - it "has a working function #no_type_flags_returnv" do + it 'has a working function #no_type_flags_returnv' do res = GIMarshallingTests.no_type_flags_returnv assert_equal :value2, res end - it "has a working function #overrides_struct_returnv" do + it 'has a working function #overrides_struct_returnv' do res = GIMarshallingTests.overrides_struct_returnv res.must_be_instance_of GIMarshallingTests::OverridesStruct end # TODO: Wait for fixed version of param_spec_in_bool to land in Debian/Ubuntu # See https://bugzilla.gnome.org/show_bug.cgi?id=728409 - it "has a working function #param_spec_in_bool" do - skip "param_spec_in_bool tests the wrong type" - ps = GObject.param_spec_boolean "mybool", "nick", "blurb", true, :readable + it 'has a working function #param_spec_in_bool' do + skip 'param_spec_in_bool tests the wrong type' + ps = GObject.param_spec_boolean 'mybool', 'nick', 'blurb', true, :readable GIMarshallingTests.param_spec_in_bool ps end - it "has a working function #param_spec_out" do + it 'has a working function #param_spec_out' do skip unless get_introspection_data 'GIMarshallingTests', 'param_spec_out' res = GIMarshallingTests.param_spec_out res.value_type.must_equal GObject::TYPE_STRING - res.get_name.must_equal "test-param" + res.get_name.must_equal 'test-param' end - it "has a working function #param_spec_return" do + it 'has a working function #param_spec_return' do skip unless get_introspection_data 'GIMarshallingTests', 'param_spec_return' res = GIMarshallingTests.param_spec_return res.value_type.must_equal GObject::TYPE_STRING - res.get_name.must_equal "test-param" + res.get_name.must_equal 'test-param' end - it "has a working function #pointer_in_return" do + it 'has a working function #pointer_in_return' do ptr = FFI::MemoryPointer.new 1 res = GIMarshallingTests.pointer_in_return ptr assert_equal ptr.address, res.address end - it "has a working function #pointer_struct_get_type" do + it 'has a working function #pointer_struct_get_type' do res = GIMarshallingTests.pointer_struct_get_type - gtype = GObject.type_from_name "GIMarshallingTestsPointerStruct" + gtype = GObject.type_from_name 'GIMarshallingTestsPointerStruct' assert_equal gtype, res end - it "has a working function #pointer_struct_returnv" do + it 'has a working function #pointer_struct_returnv' do res = GIMarshallingTests.pointer_struct_returnv assert_instance_of GIMarshallingTests::PointerStruct, res assert_equal 42, res.long_ end - it "has a working function #return_gvalue_flat_array" do + it 'has a working function #return_gvalue_flat_array' do result = GIMarshallingTests.return_gvalue_flat_array arr = result.to_a arr[0].get_value.must_equal 42 - arr[1].get_value.must_equal "42" + arr[1].get_value.must_equal '42' arr[2].get_value.must_equal true end - it "has a working function #short_in_max" do + it 'has a working function #short_in_max' do GIMarshallingTests.short_in_max 0x7fff pass end - it "has a working function #short_in_min" do + it 'has a working function #short_in_min' do GIMarshallingTests.short_in_min(-0x8000) pass end - it "has a working function #short_inout_max_min" do + it 'has a working function #short_inout_max_min' do res = GIMarshallingTests.short_inout_max_min 0x7fff assert_equal(-0x8000, res) end - it "has a working function #short_inout_min_max" do + it 'has a working function #short_inout_min_max' do res = GIMarshallingTests.short_inout_min_max(-0x8000) assert_equal 0x7fff, res end - it "has a working function #short_out_max" do + it 'has a working function #short_out_max' do res = GIMarshallingTests.short_out_max assert_equal 0x7fff, res end - it "has a working function #short_out_min" do + it 'has a working function #short_out_min' do res = GIMarshallingTests.short_out_min assert_equal(-0x8000, res) end - it "has a working function #short_return_max" do + it 'has a working function #short_return_max' do res = GIMarshallingTests.short_return_max assert_equal 0x7fff, res end - it "has a working function #short_return_min" do + it 'has a working function #short_return_min' do res = GIMarshallingTests.short_return_min assert_equal(-0x8000, res) end - it "has a working function #simple_struct_returnv" do + it 'has a working function #simple_struct_returnv' do res = GIMarshallingTests.simple_struct_returnv assert_instance_of GIMarshallingTests::SimpleStruct, res assert_equal 6, res.long_ assert_equal 7, res.int8 end - it "has a working function #size_in" do + it 'has a working function #size_in' do GIMarshallingTests.size_in max_size_t end - it "has a working function #size_inout" do + it 'has a working function #size_inout' do res = GIMarshallingTests.size_inout max_size_t assert_equal 0, res end - it "has a working function #size_out" do + it 'has a working function #size_out' do res = GIMarshallingTests.size_out assert_equal max_size_t, res end - it "has a working function #size_return" do + it 'has a working function #size_return' do res = GIMarshallingTests.size_return assert_equal max_size_t, res end - it "has a working function #ssize_in_max" do + it 'has a working function #ssize_in_max' do GIMarshallingTests.ssize_in_max max_ssize_t pass end - it "has a working function #ssize_in_min" do + it 'has a working function #ssize_in_min' do GIMarshallingTests.ssize_in_min min_ssize_t pass end - it "has a working function #ssize_inout_max_min" do + it 'has a working function #ssize_inout_max_min' do res = GIMarshallingTests.ssize_inout_max_min max_ssize_t assert_equal min_ssize_t, res end - it "has a working function #ssize_inout_min_max" do + it 'has a working function #ssize_inout_min_max' do res = GIMarshallingTests.ssize_inout_min_max min_ssize_t assert_equal max_ssize_t, res end - it "has a working function #ssize_out_max" do + it 'has a working function #ssize_out_max' do res = GIMarshallingTests.ssize_out_max assert_equal max_ssize_t, res end - it "has a working function #ssize_out_min" do + it 'has a working function #ssize_out_min' do res = GIMarshallingTests.ssize_out_min assert_equal min_ssize_t, res end - it "has a working function #ssize_return_max" do + it 'has a working function #ssize_return_max' do res = GIMarshallingTests.ssize_return_max assert_equal max_ssize_t, res end - it "has a working function #ssize_return_min" do + it 'has a working function #ssize_return_min' do res = GIMarshallingTests.ssize_return_min assert_equal min_ssize_t, res end - it "has a working function #test_interface_test_int8_in" do + it 'has a working function #test_interface_test_int8_in' do derived_klass.class_eval { include GIMarshallingTests::Interface } instance = make_derived_instance do |info| info.install_vfunc_implementation :test_int8_in, proc { |obj, in_| obj.int = in_ } @@ -2725,224 +2725,224 @@ def make_derived_instance instance.int.must_equal 8 end - it "has a working function #time_t_in" do + it 'has a working function #time_t_in' do GIMarshallingTests.time_t_in 1_234_567_890 pass end - it "has a working function #time_t_inout" do + it 'has a working function #time_t_inout' do res = GIMarshallingTests.time_t_inout 1_234_567_890 assert_equal 0, res end - it "has a working function #time_t_out" do + it 'has a working function #time_t_out' do res = GIMarshallingTests.time_t_out assert_equal 1_234_567_890, res end - it "has a working function #time_t_return" do + it 'has a working function #time_t_return' do res = GIMarshallingTests.time_t_return assert_equal 1_234_567_890, res end - it "has a working function #uint16_in" do + it 'has a working function #uint16_in' do GIMarshallingTests.uint16_in 0xffff pass end - it "has a working function #uint16_inout" do + it 'has a working function #uint16_inout' do res = GIMarshallingTests.uint16_inout 0xffff assert_equal 0, res end - it "has a working function #uint16_out" do + it 'has a working function #uint16_out' do res = GIMarshallingTests.uint16_out assert_equal 0xffff, res end - it "has a working function #uint16_return" do + it 'has a working function #uint16_return' do res = GIMarshallingTests.uint16_return assert_equal 0xffff, res end - it "has a working function #uint32_in" do + it 'has a working function #uint32_in' do GIMarshallingTests.uint32_in 0xffffffff end - it "has a working function #uint32_inout" do + it 'has a working function #uint32_inout' do res = GIMarshallingTests.uint32_inout 0xffffffff assert_equal 0, res end - it "has a working function #uint32_out" do + it 'has a working function #uint32_out' do res = GIMarshallingTests.uint32_out assert_equal 0xffffffff, res end - it "has a working function #uint32_return" do + it 'has a working function #uint32_return' do res = GIMarshallingTests.uint32_return assert_equal 0xffffffff, res end - it "has a working function #uint64_in" do + it 'has a working function #uint64_in' do GIMarshallingTests.uint64_in 0xffff_ffff_ffff_ffff pass end - it "has a working function #uint64_inout" do + it 'has a working function #uint64_inout' do res = GIMarshallingTests.uint64_inout 0xffff_ffff_ffff_ffff assert_equal 0, res end - it "has a working function #uint64_out" do + it 'has a working function #uint64_out' do res = GIMarshallingTests.uint64_out assert_equal 0xffff_ffff_ffff_ffff, res end - it "has a working function #uint64_return" do + it 'has a working function #uint64_return' do res = GIMarshallingTests.uint64_return assert_equal 0xffff_ffff_ffff_ffff, res end - it "has a working function #uint8_in" do + it 'has a working function #uint8_in' do GIMarshallingTests.uint8_in 0xff end - it "has a working function #uint8_inout" do + it 'has a working function #uint8_inout' do res = GIMarshallingTests.uint8_inout 0xff assert_equal 0, res end - it "has a working function #uint8_out" do + it 'has a working function #uint8_out' do res = GIMarshallingTests.uint8_out assert_equal 0xff, res end - it "has a working function #uint8_return" do + it 'has a working function #uint8_return' do res = GIMarshallingTests.uint8_return assert_equal 0xff, res end - it "has a working function #uint_in" do + it 'has a working function #uint_in' do GIMarshallingTests.uint_in max_uint pass end - it "has a working function #uint_inout" do + it 'has a working function #uint_inout' do res = GIMarshallingTests.uint_inout max_uint assert_equal 0, res end - it "has a working function #uint_out" do + it 'has a working function #uint_out' do res = GIMarshallingTests.uint_out assert_equal max_uint, res end - it "has a working function #uint_return" do + it 'has a working function #uint_return' do res = GIMarshallingTests.uint_return assert_equal max_uint, res end - it "has a working function #ulong_in" do + it 'has a working function #ulong_in' do GIMarshallingTests.ulong_in max_ulong end - it "has a working function #ulong_inout" do + it 'has a working function #ulong_inout' do res = GIMarshallingTests.ulong_inout max_ulong assert_equal 0, res end - it "has a working function #ulong_out" do + it 'has a working function #ulong_out' do res = GIMarshallingTests.ulong_out assert_equal max_ulong, res end - it "has a working function #ulong_return" do + it 'has a working function #ulong_return' do res = GIMarshallingTests.ulong_return assert_equal max_ulong, res end - it "has a working function #union_inout" do - skip "This function is defined in the header but not implemented" + it 'has a working function #union_inout' do + skip 'This function is defined in the header but not implemented' end - it "has a working function #union_out" do - skip "This function is defined in the header but not implemented" + it 'has a working function #union_out' do + skip 'This function is defined in the header but not implemented' end - it "has a working function #union_returnv" do + it 'has a working function #union_returnv' do res = GIMarshallingTests.union_returnv assert_instance_of GIMarshallingTests::Union, res assert_equal 42, res.long_ end - it "has a working function #ushort_in" do + it 'has a working function #ushort_in' do GIMarshallingTests.ushort_in max_ushort pass end - it "has a working function #ushort_inout" do + it 'has a working function #ushort_inout' do res = GIMarshallingTests.ushort_inout max_ushort assert_equal 0, res end - it "has a working function #ushort_out" do + it 'has a working function #ushort_out' do res = GIMarshallingTests.ushort_out assert_equal max_ushort, res end - it "has a working function #ushort_return" do + it 'has a working function #ushort_return' do res = GIMarshallingTests.ushort_return assert_equal max_ushort, res end - it "has a working function #utf8_as_uint8array_in" do + it 'has a working function #utf8_as_uint8array_in' do skip unless get_introspection_data 'GIMarshallingTests', 'utf8_as_uint8array_in' GIMarshallingTests.utf8_as_uint8array_in GIMarshallingTests::CONSTANT_UTF8.bytes.to_a pass end - it "has a working function #utf8_dangling_out" do + it 'has a working function #utf8_dangling_out' do res = GIMarshallingTests.utf8_dangling_out assert_nil res end - it "has a working function #utf8_full_in" do - skip "This function is defined in the header but not implemented" + it 'has a working function #utf8_full_in' do + skip 'This function is defined in the header but not implemented' end - it "has a working function #utf8_full_inout" do - res = GIMarshallingTests.utf8_full_inout "const ♥ utf8" - assert_equal "", res + it 'has a working function #utf8_full_inout' do + res = GIMarshallingTests.utf8_full_inout 'const ♥ utf8' + assert_equal '', res end - it "has a working function #utf8_full_out" do + it 'has a working function #utf8_full_out' do res = GIMarshallingTests.utf8_full_out - assert_equal "const ♥ utf8", res + assert_equal 'const ♥ utf8', res end - it "has a working function #utf8_full_return" do + it 'has a working function #utf8_full_return' do res = GIMarshallingTests.utf8_full_return - assert_equal "const ♥ utf8", res + assert_equal 'const ♥ utf8', res end - it "has a working function #utf8_none_in" do - GIMarshallingTests.utf8_none_in "const ♥ utf8" + it 'has a working function #utf8_none_in' do + GIMarshallingTests.utf8_none_in 'const ♥ utf8' pass end - it "has a working function #utf8_none_inout" do - res = GIMarshallingTests.utf8_none_inout "const ♥ utf8" - assert_equal "", res + it 'has a working function #utf8_none_inout' do + res = GIMarshallingTests.utf8_none_inout 'const ♥ utf8' + assert_equal '', res end - it "has a working function #utf8_none_out" do + it 'has a working function #utf8_none_out' do res = GIMarshallingTests.utf8_none_out - assert_equal "const ♥ utf8", res + assert_equal 'const ♥ utf8', res end - it "has a working function #utf8_none_return" do + it 'has a working function #utf8_none_return' do res = GIMarshallingTests.utf8_none_return - assert_equal "const ♥ utf8", res + assert_equal 'const ♥ utf8', res end end diff --git a/test/integration/generated_gio_test.rb b/test/integration/generated_gio_test.rb index 419d0daf8..bb5ddaf93 100644 --- a/test/integration/generated_gio_test.rb +++ b/test/integration/generated_gio_test.rb @@ -1,25 +1,25 @@ require 'gir_ffi_test_helper' # Tests generated methods and functions in the Gio namespace. -describe "The generated Gio module" do +describe 'The generated Gio module' do before do GirFFI.setup :Gio end - describe "#file_new_for_path, a method returning an interface," do - it "returns an object of a more specific class" do + describe '#file_new_for_path, a method returning an interface,' do + it 'returns an object of a more specific class' do file = Gio.file_new_for_path('/') refute_instance_of Gio::File, file assert_includes file.class.ancestors, Gio::File end end - describe "the result of #file_new_from_path" do + describe 'the result of #file_new_from_path' do before do @it = Gio.file_new_for_path('/') end - it "is able to set up a method in a class that is not the first ancestor" do + it 'is able to set up a method in a class that is not the first ancestor' do anc = @it.class.ancestors assert_equal [Gio::File, GObject::Object], anc[1, 2] @@ -29,72 +29,72 @@ @it.setup_and_call :get_qdata, 1 end - it "knows its GType" do + it 'knows its GType' do instance_gtype = GObject.type_from_instance @it @it.class.get_gtype.must_equal instance_gtype end end - describe "the FileInfo class" do - describe "an instance" do + describe 'the FileInfo class' do + describe 'an instance' do before do file = Gio.file_new_for_path('/') - @fileinfo = file.query_info "*", :none, nil + @fileinfo = file.query_info '*', :none, nil end - it "has a working #get_attribute_type method" do - type = @fileinfo.get_attribute_type "standard::display-name" + it 'has a working #get_attribute_type method' do + type = @fileinfo.get_attribute_type 'standard::display-name' assert_equal :string, type end end end - describe "the action-added signal" do + describe 'the action-added signal' do before do @grp = Gio::SimpleActionGroup.new end it "correctly passes on the string parameter 'action_name'" do a = nil - GObject.signal_connect @grp, "action-added" do |_grp, action_name, _user_data| + GObject.signal_connect @grp, 'action-added' do |_grp, action_name, _user_data| a = action_name end - GObject.signal_emit @grp, "action-added", "foo" - assert_equal "foo", a + GObject.signal_emit @grp, 'action-added', 'foo' + assert_equal 'foo', a end end - describe "the reply signal" do + describe 'the reply signal' do before do @mo = Gio::MountOperation.new end it "correctly passes on the enum parameter 'result'" do a = nil - GObject.signal_connect @mo, "reply" do |_mnt, result, _user_data| + GObject.signal_connect @mo, 'reply' do |_mnt, result, _user_data| a = result end - GObject.signal_emit @mo, "reply", 2 + GObject.signal_emit @mo, 'reply', 2 assert_equal :unhandled, a end end - describe "the CharsetConverter class" do - it "includes two interfaces" do + describe 'the CharsetConverter class' do + it 'includes two interfaces' do klass = Gio::CharsetConverter assert_includes klass.ancestors, Gio::Converter assert_includes klass.ancestors, Gio::Initable end - it "allows an instance to find the #reset method" do - cnv = Gio::CharsetConverter.new "utf8", "utf8" + it 'allows an instance to find the #reset method' do + cnv = Gio::CharsetConverter.new 'utf8', 'utf8' cnv.reset pass end end - describe "the SocketSourceFunc callback" do - it "can be cast to a native function" do + describe 'the SocketSourceFunc callback' do + it 'can be cast to a native function' do Gio::SocketSourceFunc.new { |*args| p args }.to_native end end diff --git a/test/integration/generated_glib_test.rb b/test/integration/generated_glib_test.rb index 8a09e7645..5e2c6aae2 100644 --- a/test/integration/generated_glib_test.rb +++ b/test/integration/generated_glib_test.rb @@ -1,14 +1,14 @@ require 'gir_ffi_test_helper' # Tests generated classes, methods and functions in the GLib namespace. -describe "The generated GLib module" do - it "can auto-generate the GLib::IConv class" do +describe 'The generated GLib module' do + it 'can auto-generate the GLib::IConv class' do klass = GLib::IConv klass.must_be_instance_of Class end - it "can auto-generate the GLib::SOURCE_REMOVE constant" do + it 'can auto-generate the GLib::SOURCE_REMOVE constant' do skip unless get_introspection_data 'GLib', 'SOURCE_REMOVE' GLib::SOURCE_REMOVE.must_equal false diff --git a/test/integration/generated_gobject_test.rb b/test/integration/generated_gobject_test.rb index 68b93fc4a..0e6894fb2 100644 --- a/test/integration/generated_gobject_test.rb +++ b/test/integration/generated_gobject_test.rb @@ -1,16 +1,16 @@ require 'gir_ffi_test_helper' describe GObject do - describe ".type_interfaces" do - it "works, showing that returning an array of GType works" do + describe '.type_interfaces' do + it 'works, showing that returning an array of GType works' do klass = GObject::TypeModule ifcs = GObject.type_interfaces klass.get_gtype assert_equal 1, ifcs.size end end - describe ".signal_set_va_marshaller" do - it "can be set up" do + describe '.signal_set_va_marshaller' do + it 'can be set up' do result = GObject.setup_method 'signal_set_va_marshaller' result.must_equal true end @@ -18,12 +18,12 @@ describe GObject::TypeInfo do let(:instance) { GObject::TypeInfo.new } - it "has a working field setter for class_init" do + it 'has a working field setter for class_init' do instance.class_init = proc do |_object_class, _data| end end - it "has a working field getter for class_init" do + it 'has a working field getter for class_init' do instance.class_init.must_be_nil instance.class_init = proc do |_object_class, _data| end @@ -34,7 +34,7 @@ end describe GObject::TypePlugin do - it "is implemented as a module" do + it 'is implemented as a module' do mod = GObject::TypePlugin assert_instance_of Module, mod refute_instance_of Class, mod @@ -42,14 +42,14 @@ end describe GObject::TypeModule do - it "has the GObject::TypePlugin module as an ancestor" do + it 'has the GObject::TypePlugin module as an ancestor' do klass = GObject::TypeModule assert_includes klass.ancestors, GObject::TypePlugin end end describe GObject::ValueArray do - it "uses the constructor provided by GObject" do + it 'uses the constructor provided by GObject' do instance = GObject::ValueArray.new 16 instance.n_prealloced.must_equal 16 instance.n_values.must_equal 0 diff --git a/test/integration/generated_pango_ft2_test.rb b/test/integration/generated_pango_ft2_test.rb index 573591f2a..1ca7a86de 100644 --- a/test/integration/generated_pango_ft2_test.rb +++ b/test/integration/generated_pango_ft2_test.rb @@ -6,7 +6,7 @@ # Tests generated methods and functions in the PangoFT2 namespace. describe PangoFT2 do describe PangoFT2::FontMap do - it "has a working method #load_font" do + it 'has a working method #load_font' do font_map = PangoFT2::FontMap.new context = font_map.create_context font_description = Pango::FontDescription.new diff --git a/test/integration/generated_pango_test.rb b/test/integration/generated_pango_test.rb index b47e8c0ce..9927e8961 100644 --- a/test/integration/generated_pango_test.rb +++ b/test/integration/generated_pango_test.rb @@ -6,7 +6,7 @@ # Tests generated methods and functions in the Pango namespace. describe Pango do describe Pango::Language do - it "has a working method #get_scripts" do + it 'has a working method #get_scripts' do lang = Pango::Language.from_string 'ja' result = lang.get_scripts diff --git a/test/integration/generated_regress_test.rb b/test/integration/generated_regress_test.rb index 8403f7e10..0a5d217fd 100644 --- a/test/integration/generated_regress_test.rb +++ b/test/integration/generated_regress_test.rb @@ -6,69 +6,69 @@ # Tests generated methods and functions in the Regress namespace. describe Regress do describe Regress::Lib do - it "extends FFI::Library" do + it 'extends FFI::Library' do class << Regress::Lib must_be :include?, FFI::Library end end end - describe "Regress::ATestError" do + describe 'Regress::ATestError' do before do skip unless get_introspection_data 'Regress', 'ATestError' end - it "has the member :code0" do + it 'has the member :code0' do Regress::ATestError[:code0].must_equal 0 end - it "has the member :code1" do + it 'has the member :code1' do Regress::ATestError[:code1].must_equal 1 end - it "has the member :code2" do + it 'has the member :code2' do Regress::ATestError[:code2].must_equal 2 end end - it "has the constant BOOL_CONSTANT" do + it 'has the constant BOOL_CONSTANT' do skip unless get_introspection_data 'Regress', 'BOOL_CONSTANT' Regress::BOOL_CONSTANT.must_equal true end - it "has the constant DOUBLE_CONSTANT" do + it 'has the constant DOUBLE_CONSTANT' do assert_equal 44.22, Regress::DOUBLE_CONSTANT end - it "has the constant GI_SCANNER_ELSE" do + it 'has the constant GI_SCANNER_ELSE' do skip unless get_introspection_data 'Regress', 'GI_SCANNER_ELSE' Regress::GI_SCANNER_ELSE.must_equal 3 end - it "has the constant GI_SCANNER_IFDEF" do + it 'has the constant GI_SCANNER_IFDEF' do skip unless get_introspection_data 'Regress', 'GI_SCANNER_IFDEF' Regress::GI_SCANNER_IFDEF.must_equal 3 end - it "has the constant GUINT64_CONSTANT" do + it 'has the constant GUINT64_CONSTANT' do skip unless get_introspection_data 'Regress', 'GUINT64_CONSTANT' Regress::GUINT64_CONSTANT.must_equal 18_446_744_073_709_551_615 end - it "has the constant GUINT64_CONSTANTA" do + it 'has the constant GUINT64_CONSTANTA' do skip unless get_introspection_data 'Regress', 'GUINT64_CONSTANTA' Regress::GUINT64_CONSTANTA.must_equal 18_446_744_073_709_551_615 end - it "has the constant G_GINT64_CONSTANT" do + it 'has the constant G_GINT64_CONSTANT' do skip unless get_introspection_data 'Regress', 'G_GINT64_CONSTANT' Regress::G_GINT64_CONSTANT.must_equal 1000 end - it "has the constant INT_CONSTANT" do + it 'has the constant INT_CONSTANT' do assert_equal 4422, Regress::INT_CONSTANT end - it "has the constant LONG_STRING_CONSTANT" do + it 'has the constant LONG_STRING_CONSTANT' do Regress::LONG_STRING_CONSTANT.must_equal %w(TYPE VALUE ENCODING CHARSET LANGUAGE DOM INTL POSTAL PARCEL HOME WORK PREF VOICE FAX MSG @@ -79,114 +79,114 @@ class << Regress::Lib CGM WMF BMP MET PMB DIB PICT TIFF PDF PS JPEG QTIME MPEG MPEG2 AVI WAVE AIFF PCM X509 - PGP).join(",") + PGP).join(',') end - describe "Regress::LikeGnomeKeyringPasswordSchema" do + describe 'Regress::LikeGnomeKeyringPasswordSchema' do before do skip unless get_introspection_data 'Regress', 'LikeGnomeKeyringPasswordSchema' end - it "creates an instance using #new" do + it 'creates an instance using #new' do obj = Regress::LikeGnomeKeyringPasswordSchema.new obj.must_be_instance_of Regress::LikeGnomeKeyringPasswordSchema end let(:instance) { Regress::LikeGnomeKeyringPasswordSchema.new } - it "has a writable field dummy" do + it 'has a writable field dummy' do instance.dummy.must_equal 0 instance.dummy = 42 instance.dummy.must_equal 42 end - it "has a writable field attributes" do - skip "Introspection data cannot deal with type of this field yet" + it 'has a writable field attributes' do + skip 'Introspection data cannot deal with type of this field yet' end - it "has a writable field dummy2" do + it 'has a writable field dummy2' do instance.dummy2.must_equal 0.0 instance.dummy2 = 42.42 instance.dummy2.must_equal 42.42 end end - describe "Regress::LikeXklConfigItem" do + describe 'Regress::LikeXklConfigItem' do before do skip unless get_introspection_data 'Regress', 'LikeXklConfigItem' end let(:instance) { Regress::LikeXklConfigItem.new } - let(:name_array) { "foo".bytes.to_a + [0] * 29 } + let(:name_array) { 'foo'.bytes.to_a + [0] * 29 } - it "has a writable field name" do + it 'has a writable field name' do # TODO: Should an array of gint8 be more string-like? instance.name.to_a.must_equal [0] * 32 instance.name = name_array instance.name.to_a.must_equal name_array end - it "has a working method #set_name" do - instance.set_name "foo" + it 'has a working method #set_name' do + instance.set_name 'foo' instance.name.to_a.must_equal name_array end end - it "has the constant MAXUINT64" do + it 'has the constant MAXUINT64' do skip unless get_introspection_data 'Regress', 'MAXUINT64' Regress::MAXUINT64.must_equal 0xffff_ffff_ffff_ffff end - it "has the constant MININT64" do + it 'has the constant MININT64' do skip unless get_introspection_data 'Regress', 'MININT64' Regress::MININT64.must_equal(-0x8000_0000_0000_0000) end - it "has the constant Mixed_Case_Constant" do + it 'has the constant Mixed_Case_Constant' do assert_equal 4423, Regress::Mixed_Case_Constant end - it "has the constant NEGATIVE_INT_CONSTANT" do + it 'has the constant NEGATIVE_INT_CONSTANT' do skip unless get_introspection_data 'Regress', 'NEGATIVE_INT_CONSTANT' Regress::NEGATIVE_INT_CONSTANT.must_equal(-42) end - it "has the constant STRING_CONSTANT" do - assert_equal "Some String", Regress::STRING_CONSTANT + it 'has the constant STRING_CONSTANT' do + assert_equal 'Some String', Regress::STRING_CONSTANT end - describe "Regress::TestABCError" do + describe 'Regress::TestABCError' do before do skip unless get_introspection_data 'Regress', 'TestABCError' end - it "has the member :code1" do + it 'has the member :code1' do Regress::TestABCError[:code1].must_equal 1 end - it "has the member :code2" do + it 'has the member :code2' do Regress::TestABCError[:code2].must_equal 2 end - it "has the member :code3" do + it 'has the member :code3' do Regress::TestABCError[:code3].must_equal 3 end - it "has a working function #quark" do + it 'has a working function #quark' do quark = Regress::TestABCError.quark - GLib.quark_to_string(quark).must_equal "regress-test-abc-error" + GLib.quark_to_string(quark).must_equal 'regress-test-abc-error' end end - describe "Regress::TestBoxed" do + describe 'Regress::TestBoxed' do let(:instance) { Regress::TestBoxed.new_alternative_constructor1 123 } - it "has a writable field some_int8" do + it 'has a writable field some_int8' do instance.some_int8.must_equal 123 instance.some_int8 = -43 instance.some_int8.must_equal(-43) end - it "has a writable field nested_a" do + it 'has a writable field nested_a' do instance.nested_a.some_int.must_equal 0 nested = Regress::TestSimpleBoxedA.new nested.some_int = 12_345 @@ -194,7 +194,7 @@ class << Regress::Lib instance.nested_a.some_int.must_equal 12_345 end - it "has a writable field priv" do + it 'has a writable field priv' do instance.priv.wont_be_nil other = Regress::TestBoxed.new instance.priv.wont_equal other.priv @@ -202,34 +202,34 @@ class << Regress::Lib instance.priv.must_equal other.priv end - it "creates an instance using #new" do + it 'creates an instance using #new' do tb = Regress::TestBoxed.new assert_instance_of Regress::TestBoxed, tb end - it "creates an instance using #new_alternative_constructor1" do + it 'creates an instance using #new_alternative_constructor1' do tb = Regress::TestBoxed.new_alternative_constructor1 1 assert_instance_of Regress::TestBoxed, tb assert_equal 1, tb.some_int8 end - it "creates an instance using #new_alternative_constructor2" do + it 'creates an instance using #new_alternative_constructor2' do tb = Regress::TestBoxed.new_alternative_constructor2 1, 2 assert_instance_of Regress::TestBoxed, tb assert_equal 1 + 2, tb.some_int8 end - it "creates an instance using #new_alternative_constructor3" do - tb = Regress::TestBoxed.new_alternative_constructor3 "54" + it 'creates an instance using #new_alternative_constructor3' do + tb = Regress::TestBoxed.new_alternative_constructor3 '54' assert_instance_of Regress::TestBoxed, tb assert_equal 54, tb.some_int8 end - it "has non-zero positive result for #get_gtype" do + it 'has non-zero positive result for #get_gtype' do assert Regress::TestBoxed.get_gtype > 0 end - it "has a working method #_not_a_method" do + it 'has a working method #_not_a_method' do skip unless get_method_introspection_data('Regress', 'TestBoxed', '_not_a_method') # FIXME: This method has been moved to a function. Should we still expose # it as a method? @@ -237,7 +237,7 @@ class << Regress::Lib pass end - it "has a working method #copy" do + it 'has a working method #copy' do tb2 = instance.copy assert_instance_of Regress::TestBoxed, tb2 assert_equal 123, tb2.some_int8 @@ -245,33 +245,33 @@ class << Regress::Lib assert_equal 123, tb2.some_int8 end - it "has a working method #equals" do + it 'has a working method #equals' do tb2 = Regress::TestBoxed.new_alternative_constructor2 120, 3 assert_equal true, instance.equals(tb2) end end - describe "Regress::TestBoxedB" do + describe 'Regress::TestBoxedB' do let(:instance) { Regress::TestBoxedB.new 8, 42 } - it "has a writable field some_int8" do + it 'has a writable field some_int8' do instance.some_int8.must_equal 8 instance.some_int8 = -43 instance.some_int8.must_equal(-43) end - it "has a writable field some_long" do + it 'has a writable field some_long' do instance.some_long.must_equal 42 instance.some_long = -4342 instance.some_long.must_equal(-4342) end - it "creates an instance using #new" do + it 'creates an instance using #new' do tb = Regress::TestBoxedB.new 8, 42 assert_instance_of Regress::TestBoxedB, tb end - it "has a working method #copy" do + it 'has a working method #copy' do cp = instance.copy cp.must_be_instance_of Regress::TestBoxedB cp.some_int8.must_equal 8 @@ -281,229 +281,229 @@ class << Regress::Lib end end - describe "Regress::TestBoxedC" do + describe 'Regress::TestBoxedC' do before do skip unless get_introspection_data 'Regress', 'TestBoxedC' end let(:instance) { Regress::TestBoxedC.new } - it "has a writable field refcount" do + it 'has a writable field refcount' do instance.refcount.must_equal 1 instance.refcount = 2 instance.refcount.must_equal 2 end - it "has a writable field another_thing" do + it 'has a writable field another_thing' do instance.another_thing.must_equal 42 instance.another_thing = 4342 instance.another_thing.must_equal 4342 end - it "creates an instance using #new" do + it 'creates an instance using #new' do tb = Regress::TestBoxedC.new assert_instance_of Regress::TestBoxedC, tb end end - describe "Regress::TestBoxedD" do + describe 'Regress::TestBoxedD' do before do skip unless get_introspection_data 'Regress', 'TestBoxedD' end - it "creates an instance using #new" do - instance = Regress::TestBoxedD.new "foo", 42 + it 'creates an instance using #new' do + instance = Regress::TestBoxedD.new 'foo', 42 instance.must_be_instance_of Regress::TestBoxedD end - it "has a working method #copy" do - instance = Regress::TestBoxedD.new "foo", 42 + it 'has a working method #copy' do + instance = Regress::TestBoxedD.new 'foo', 42 copy = instance.copy copy.must_be_instance_of Regress::TestBoxedD instance.get_magic.must_equal copy.get_magic instance.wont_equal copy end - it "has a working method #free" do - instance = Regress::TestBoxedD.new "foo", 42 + it 'has a working method #free' do + instance = Regress::TestBoxedD.new 'foo', 42 instance.free pass end - it "has a working method #get_magic" do - instance = Regress::TestBoxedD.new "foo", 42 - instance.get_magic.must_equal "foo".length + 42 + it 'has a working method #get_magic' do + instance = Regress::TestBoxedD.new 'foo', 42 + instance.get_magic.must_equal 'foo'.length + 42 end end - describe "Regress::TestDEFError" do + describe 'Regress::TestDEFError' do before do skip unless get_introspection_data 'Regress', 'TestDEFError' end - it "has the member :code0" do + it 'has the member :code0' do Regress::TestDEFError[:code0].must_equal 0 end - it "has the member :code1" do + it 'has the member :code1' do Regress::TestDEFError[:code1].must_equal 1 end - it "has the member :code2" do + it 'has the member :code2' do Regress::TestDEFError[:code2].must_equal 2 end end - describe "Regress::TestEnum" do - it "has the member :value1" do + describe 'Regress::TestEnum' do + it 'has the member :value1' do Regress::TestEnum[:value1].must_equal 0 end - it "has the member :value2" do + it 'has the member :value2' do Regress::TestEnum[:value2].must_equal 1 end - it "has the member :value3" do + it 'has the member :value3' do Regress::TestEnum[:value3].must_equal(-1) end - it "has the member :value4" do + it 'has the member :value4' do Regress::TestEnum[:value4].must_equal 48 end - it "has a working function #param" do - Regress::TestEnum.param(:value1).must_equal("value1") - Regress::TestEnum.param(:value2).must_equal("value2") - Regress::TestEnum.param(:value3).must_equal("value3") - Regress::TestEnum.param(:value4).must_equal("value4") - Regress::TestEnum.param(0).must_equal("value1") - Regress::TestEnum.param(1).must_equal("value2") - Regress::TestEnum.param(-1).must_equal("value3") - Regress::TestEnum.param(48).must_equal("value4") + it 'has a working function #param' do + Regress::TestEnum.param(:value1).must_equal('value1') + Regress::TestEnum.param(:value2).must_equal('value2') + Regress::TestEnum.param(:value3).must_equal('value3') + Regress::TestEnum.param(:value4).must_equal('value4') + Regress::TestEnum.param(0).must_equal('value1') + Regress::TestEnum.param(1).must_equal('value2') + Regress::TestEnum.param(-1).must_equal('value3') + Regress::TestEnum.param(48).must_equal('value4') end end - describe "Regress::TestEnumNoGEnum" do - it "has the member :evalue1" do + describe 'Regress::TestEnumNoGEnum' do + it 'has the member :evalue1' do Regress::TestEnumNoGEnum[:evalue1].must_equal 0 end - it "has the member :evalue2" do + it 'has the member :evalue2' do Regress::TestEnumNoGEnum[:evalue2].must_equal 42 end - it "has the member :evalue3" do + it 'has the member :evalue3' do Regress::TestEnumNoGEnum[:evalue3].must_equal 48 end end - describe "Regress::TestEnumUnsigned" do - it "has the member :value1" do + describe 'Regress::TestEnumUnsigned' do + it 'has the member :value1' do Regress::TestEnumUnsigned[:value1].must_equal 1 end # NOTE In c, the positive and negative values are not distinguished - it "has the member :value2" do + it 'has the member :value2' do Regress::TestEnumUnsigned[:value2].must_equal(-2_147_483_648) end end - describe "Regress::TestError" do + describe 'Regress::TestError' do before do skip unless get_introspection_data 'Regress', 'TestError' end - it "has the member :code1" do + it 'has the member :code1' do Regress::TestError[:code1].must_equal 1 end - it "has the member :code2" do + it 'has the member :code2' do Regress::TestError[:code2].must_equal 2 end - it "has the member :code3" do + it 'has the member :code3' do Regress::TestError[:code3].must_equal 3 end - it "has a working function #quark" do + it 'has a working function #quark' do quark = Regress::TestError.quark - GLib.quark_to_string(quark).must_equal "regress-test-error" + GLib.quark_to_string(quark).must_equal 'regress-test-error' end end - describe "Regress::TestFlags" do - it "has the member :flag1" do + describe 'Regress::TestFlags' do + it 'has the member :flag1' do assert_equal 1, Regress::TestFlags[:flag1] end - it "has the member :flag2" do + it 'has the member :flag2' do assert_equal 2, Regress::TestFlags[:flag2] end - it "has the member :flag3" do + it 'has the member :flag3' do assert_equal 4, Regress::TestFlags[:flag3] end end - describe "Regress::TestFloating" do - it "creates an instance using #new" do + describe 'Regress::TestFloating' do + it 'creates an instance using #new' do o = Regress::TestFloating.new o.must_be_instance_of Regress::TestFloating end - describe "an instance" do + describe 'an instance' do before do @o = Regress::TestFloating.new end - it "has a reference count of 1" do + it 'has a reference count of 1' do assert_equal 1, ref_count(@o) end - it "has been sunk" do + it 'has been sunk' do @o.wont_be :floating? end end end - describe "Regress::TestFundamentalObject" do - it "does not have GObject::Object as an ancestor" do + describe 'Regress::TestFundamentalObject' do + it 'does not have GObject::Object as an ancestor' do refute_includes Regress::TestFundamentalObject.ancestors, GObject::Object end - it "cannot be instantiated" do + it 'cannot be instantiated' do proc { Regress::TestFundamentalObject.new }.must_raise NoMethodError end # NOTE: Instance methods can only be tested on the subclass, since # TestFundamentalObject is an abstract class. - let(:instance) { Regress::TestFundamentalSubObject.new "foo" } + let(:instance) { Regress::TestFundamentalSubObject.new 'foo' } - it "has a working method #ref" do + it 'has a working method #ref' do instance.refcount.must_equal 1 instance.ref instance.refcount.must_equal 2 end - it "has a working method #unref" do + it 'has a working method #unref' do instance.refcount.must_equal 1 instance.unref instance.refcount.must_equal 0 end end - describe "Regress::TestFundamentalSubObject" do - it "creates an instance using #new" do - obj = Regress::TestFundamentalSubObject.new "foo" + describe 'Regress::TestFundamentalSubObject' do + it 'creates an instance using #new' do + obj = Regress::TestFundamentalSubObject.new 'foo' obj.must_be_instance_of Regress::TestFundamentalSubObject end - let(:instance) { Regress::TestFundamentalSubObject.new "foo" } + let(:instance) { Regress::TestFundamentalSubObject.new 'foo' } - it "is a subclass of TestFundamentalObject" do + it 'is a subclass of TestFundamentalObject' do assert_kind_of Regress::TestFundamentalObject, instance end - it "has a field :data storing the constructor parameter" do - assert_equal "foo", instance.data + it 'has a field :data storing the constructor parameter' do + assert_equal 'foo', instance.data end it "can access its parent class' fields directly" do @@ -511,34 +511,34 @@ class << Regress::Lib end end - describe "Regress::TestInterface" do - it "is a module" do + describe 'Regress::TestInterface' do + it 'is a module' do assert_instance_of Module, Regress::TestInterface end - it "extends InterfaceBase" do + it 'extends InterfaceBase' do metaclass = class << Regress::TestInterface; self; end assert_includes metaclass.ancestors, GirFFI::InterfaceBase end - it "has non-zero positive result for #get_gtype" do + it 'has non-zero positive result for #get_gtype' do Regress::TestInterface.get_gtype.must_be :>, 0 end end - describe "Regress::TestObj" do - it "creates an instance using #constructor" do + describe 'Regress::TestObj' do + it 'creates an instance using #constructor' do obj = Regress::TestObj.constructor obj.must_be_instance_of Regress::TestObj end - it "creates an instance using #new" do + it 'creates an instance using #new' do o1 = Regress::TestObj.constructor o2 = Regress::TestObj.new o1 o2.must_be_instance_of Regress::TestObj end - it "creates an instance using #new_callback" do + it 'creates an instance using #new_callback' do a = 1 o = Regress::TestObj.new_callback proc { a = 2 }, nil, nil assert_instance_of Regress::TestObj, o @@ -551,58 +551,58 @@ class << Regress::Lib result.must_equal 2 end - it "creates an instance using #new_from_file" do - o = Regress::TestObj.new_from_file("foo") + it 'creates an instance using #new_from_file' do + o = Regress::TestObj.new_from_file('foo') assert_instance_of Regress::TestObj, o end - it "has a working function #null_out" do + it 'has a working function #null_out' do obj = Regress::TestObj.null_out obj.must_be_nil end - it "has a working function #static_method" do + it 'has a working function #static_method' do rv = Regress::TestObj.static_method 623 assert_equal 623.0, rv end - it "has a working function #static_method_callback" do + it 'has a working function #static_method_callback' do a = 1 Regress::TestObj.static_method_callback proc { a = 2 } assert_equal 2, a end - let(:instance) { Regress::TestObj.new_from_file("foo") } + let(:instance) { Regress::TestObj.new_from_file('foo') } - describe "its gtype" do - it "can be found through get_gtype and GObject.type_from_instance" do + describe 'its gtype' do + it 'can be found through get_gtype and GObject.type_from_instance' do gtype = Regress::TestObj.get_gtype r = GObject.type_from_instance instance assert_equal gtype, r end end - it "has a reference count of 1" do + it 'has a reference count of 1' do assert_equal 1, ref_count(instance) end - it "does not float" do + it 'does not float' do instance.wont_be :floating? end - it "has a working method #matrix" do - instance.matrix("bar").must_equal 42 + it 'has a working method #matrix' do + instance.matrix('bar').must_equal 42 end - it "has a working method #do_matrix" do - instance.do_matrix("bar").must_equal 42 + it 'has a working method #do_matrix' do + instance.do_matrix('bar').must_equal 42 end - it "has a working method #emit_sig_with_foreign_struct" do + it 'has a working method #emit_sig_with_foreign_struct' do skip unless get_method_introspection_data('Regress', 'TestObj', 'emit_sig_with_foreign_struct') has_fired = false - instance.signal_connect "sig-with-foreign-struct" do |_obj, cr| + instance.signal_connect 'sig-with-foreign-struct' do |_obj, cr| has_fired = true cr.must_be_instance_of Cairo::Context end @@ -610,17 +610,17 @@ class << Regress::Lib assert has_fired end - it "has a working method #emit_sig_with_int64" do - skip unless get_signal_introspection_data "Regress", "TestObj", "sig-with-int64-prop" - instance.signal_connect "sig-with-int64-prop" do |_obj, i, _ud| + it 'has a working method #emit_sig_with_int64' do + skip unless get_signal_introspection_data 'Regress', 'TestObj', 'sig-with-int64-prop' + instance.signal_connect 'sig-with-int64-prop' do |_obj, i, _ud| i end instance.emit_sig_with_int64 end - it "has a working method #emit_sig_with_obj" do + it 'has a working method #emit_sig_with_obj' do has_fired = false - instance.signal_connect "sig-with-obj" do |_it, obj| + instance.signal_connect 'sig-with-obj' do |_it, obj| has_fired = true obj.int.must_equal 3 end @@ -628,31 +628,31 @@ class << Regress::Lib assert has_fired end - it "has a working method #emit_sig_with_uint64" do - skip unless get_signal_introspection_data "Regress", "TestObj", "sig-with-uint64-prop" - instance.signal_connect "sig-with-uint64-prop" do |_obj, i, _ud| + it 'has a working method #emit_sig_with_uint64' do + skip unless get_signal_introspection_data 'Regress', 'TestObj', 'sig-with-uint64-prop' + instance.signal_connect 'sig-with-uint64-prop' do |_obj, i, _ud| i end instance.emit_sig_with_uint64 end - it "has a working method #forced_method" do + it 'has a working method #forced_method' do instance.forced_method pass end - it "has a working method #instance_method" do + it 'has a working method #instance_method' do rv = instance.instance_method assert_equal(-1, rv) end - it "has a working method #instance_method_callback" do + it 'has a working method #instance_method_callback' do a = 1 instance.instance_method_callback proc { a = 2 } assert_equal 2, a end - it "has a working method #instance_method_full" do + it 'has a working method #instance_method_full' do skip unless get_method_introspection_data('Regress', 'TestObj', 'instance_method_full') instance.instance_method_full # FIXME: Is this the behavior we want, or do we want to increase the @@ -660,13 +660,13 @@ class << Regress::Lib ref_count(instance).must_equal 0 end - it "has a working method #set_bare" do - obj = Regress::TestObj.new_from_file("bar") + it 'has a working method #set_bare' do + obj = Regress::TestObj.new_from_file('bar') instance.set_bare obj instance.bare.must_equal obj end - it "has a working method #skip_inout_param" do + it 'has a working method #skip_inout_param' do a = 1 c = 2.0 num1 = 3 @@ -677,7 +677,7 @@ class << Regress::Lib sum.must_equal num1 + 10 * num2 end - it "has a working method #skip_out_param" do + it 'has a working method #skip_out_param' do a = 1 c = 2.0 d = 3 @@ -689,7 +689,7 @@ class << Regress::Lib sum.must_equal num1 + 10 * num2 end - it "has a working method #skip_param" do + it 'has a working method #skip_param' do a = 1 d = 3 num1 = 4 @@ -701,7 +701,7 @@ class << Regress::Lib sum.must_equal num1 + 10 * num2 end - it "has a working method #skip_return_val" do + it 'has a working method #skip_return_val' do a = 1 c = 2.0 d = 3 @@ -713,350 +713,350 @@ class << Regress::Lib out_sum.must_equal num1 + 10 * num2 end - it "has a working method #skip_return_val_no_out" do + it 'has a working method #skip_return_val_no_out' do result = instance.skip_return_val_no_out 1 result.must_be_nil proc { instance.skip_return_val_no_out 0 }.must_raise GirFFI::GLibError end - it "has a working method #torture_signature_0" do - y, z, q = instance.torture_signature_0(-21, "hello", 13) - assert_equal [-21, 2 * -21, "hello".length + 13], + it 'has a working method #torture_signature_0' do + y, z, q = instance.torture_signature_0(-21, 'hello', 13) + assert_equal [-21, 2 * -21, 'hello'.length + 13], [y, z, q] end - it "has a working method #torture_signature_1" do - ret, y, z, q = instance.torture_signature_1(-21, "hello", 12) - [ret, y, z, q].must_equal [true, -21, 2 * -21, "hello".length + 12] + it 'has a working method #torture_signature_1' do + ret, y, z, q = instance.torture_signature_1(-21, 'hello', 12) + [ret, y, z, q].must_equal [true, -21, 2 * -21, 'hello'.length + 12] - proc { instance.torture_signature_1(-21, "hello", 11) }. + proc { instance.torture_signature_1(-21, 'hello', 11) }. must_raise GirFFI::GLibError end describe "its 'bare' property" do - it "can be retrieved with #get_property" do - instance.get_property("bare").get_value.must_be_nil + it 'can be retrieved with #get_property' do + instance.get_property('bare').get_value.must_be_nil end - it "can be retrieved with #bare" do + it 'can be retrieved with #bare' do instance.bare.must_be_nil end - it "can be set with #set_property" do - obj = Regress::TestObj.new_from_file("bar") - instance.set_property "bare", obj - instance.get_property("bare").get_value.must_equal obj + it 'can be set with #set_property' do + obj = Regress::TestObj.new_from_file('bar') + instance.set_property 'bare', obj + instance.get_property('bare').get_value.must_equal obj end - it "can be set with #bare=" do - obj = Regress::TestObj.new_from_file("bar") + it 'can be set with #bare=' do + obj = Regress::TestObj.new_from_file('bar') instance.bare = obj instance.bare.must_equal obj - instance.get_property("bare").get_value.must_equal obj + instance.get_property('bare').get_value.must_equal obj end end describe "its 'boxed' property" do - it "can be retrieved with #get_property" do - instance.get_property("boxed").get_value.must_be_nil + it 'can be retrieved with #get_property' do + instance.get_property('boxed').get_value.must_be_nil end - it "can be retrieved with #boxed" do + it 'can be retrieved with #boxed' do instance.boxed.must_be_nil end - it "can be set with #set_property" do + it 'can be set with #set_property' do tb = Regress::TestBoxed.new_alternative_constructor1 75 - instance.set_property "boxed", tb - instance.get_property("boxed").get_value.some_int8.must_equal 75 + instance.set_property 'boxed', tb + instance.get_property('boxed').get_value.some_int8.must_equal 75 end - it "can be set with #boxed=" do + it 'can be set with #boxed=' do tb = Regress::TestBoxed.new_alternative_constructor1 75 instance.boxed = tb instance.boxed.some_int8.must_equal tb.some_int8 - instance.get_property("boxed").get_value.some_int8.must_equal tb.some_int8 + instance.get_property('boxed').get_value.some_int8.must_equal tb.some_int8 end end describe "its 'double' property" do - it "can be retrieved with #get_property" do - instance.get_property("double").get_value.must_equal 0.0 + it 'can be retrieved with #get_property' do + instance.get_property('double').get_value.must_equal 0.0 end - it "can be retrieved with #double" do + it 'can be retrieved with #double' do instance.double.must_equal 0.0 end - it "can be set with #set_property" do - instance.set_property "double", 3.14 - instance.get_property("double").get_value.must_equal 3.14 + it 'can be set with #set_property' do + instance.set_property 'double', 3.14 + instance.get_property('double').get_value.must_equal 3.14 end - it "can be set with #double=" do + it 'can be set with #double=' do instance.double = 3.14 instance.double.must_equal 3.14 - instance.get_property("double").get_value.must_equal 3.14 + instance.get_property('double').get_value.must_equal 3.14 end end describe "its 'float' property" do - it "can be retrieved with #get_property" do - instance.get_property("float").get_value.must_equal 0.0 + it 'can be retrieved with #get_property' do + instance.get_property('float').get_value.must_equal 0.0 end - it "can be retrieved with #float" do + it 'can be retrieved with #float' do instance.float.must_equal 0.0 end - it "can be set with #set_property" do - instance.set_property "float", 3.14 - instance.get_property("float").get_value.must_be_close_to 3.14 + it 'can be set with #set_property' do + instance.set_property 'float', 3.14 + instance.get_property('float').get_value.must_be_close_to 3.14 end - it "can be set with #float=" do + it 'can be set with #float=' do instance.float = 3.14 instance.float.must_be_close_to 3.14 - instance.get_property("float").get_value.must_be_close_to 3.14 + instance.get_property('float').get_value.must_be_close_to 3.14 end end describe "its 'gtype' property" do before do - skip unless get_property_introspection_data("Regress", "TestObj", "gtype") + skip unless get_property_introspection_data('Regress', 'TestObj', 'gtype') end - it "can be retrieved with #get_property" do - instance.get_property("gtype").get_value.must_equal 0 + it 'can be retrieved with #get_property' do + instance.get_property('gtype').get_value.must_equal 0 end - it "can be retrieved with #gtype" do + it 'can be retrieved with #gtype' do instance.gtype.must_equal 0 end - it "can be set with #set_property" do - instance.set_property "gtype", GObject::TYPE_INT64 - instance.get_property("gtype").get_value.must_equal GObject::TYPE_INT64 + it 'can be set with #set_property' do + instance.set_property 'gtype', GObject::TYPE_INT64 + instance.get_property('gtype').get_value.must_equal GObject::TYPE_INT64 end - it "can be set with #gtype=" do + it 'can be set with #gtype=' do instance.gtype = GObject::TYPE_STRING instance.gtype.must_equal GObject::TYPE_STRING - instance.get_property("gtype").get_value.must_equal GObject::TYPE_STRING + instance.get_property('gtype').get_value.must_equal GObject::TYPE_STRING end end describe "its 'hash-table' property" do - it "can be retrieved with #get_property" do - instance.get_property("hash-table").get_value.must_be_nil + it 'can be retrieved with #get_property' do + instance.get_property('hash-table').get_value.must_be_nil end - it "can be retrieved with #hash_table" do + it 'can be retrieved with #hash_table' do instance.hash_table.must_be_nil end - it "can be set with #set_property_extended" do - instance.set_property_extended "hash-table", "foo" => -4, "bar" => 83 - instance.hash_table.to_hash.must_equal("foo" => -4, "bar" => 83) + it 'can be set with #set_property_extended' do + instance.set_property_extended 'hash-table', 'foo' => -4, 'bar' => 83 + instance.hash_table.to_hash.must_equal('foo' => -4, 'bar' => 83) end - it "can be set with #hash_table=" do - instance.hash_table = { "foo" => -4, "bar" => 83 } - instance.hash_table.to_hash.must_equal("foo" => -4, "bar" => 83) - instance.get_property_extended("hash-table").to_hash.must_equal("foo" => -4, - "bar" => 83) + it 'can be set with #hash_table=' do + instance.hash_table = { 'foo' => -4, 'bar' => 83 } + instance.hash_table.to_hash.must_equal('foo' => -4, 'bar' => 83) + instance.get_property_extended('hash-table').to_hash.must_equal('foo' => -4, + 'bar' => 83) end end describe "its 'hash-table-old' property" do - it "can be retrieved with #get_property" do - instance.get_property("hash-table-old").get_value.must_be_nil + it 'can be retrieved with #get_property' do + instance.get_property('hash-table-old').get_value.must_be_nil end - it "can be retrieved with #hash_table_old" do + it 'can be retrieved with #hash_table_old' do instance.hash_table_old.must_be_nil end - it "can be set with #set_property_extended" do - instance.set_property_extended "hash-table-old", "foo" => 34, "bar" => -3 - instance.hash_table_old.to_hash.must_equal("foo" => 34, "bar" => -3) + it 'can be set with #set_property_extended' do + instance.set_property_extended 'hash-table-old', 'foo' => 34, 'bar' => -3 + instance.hash_table_old.to_hash.must_equal('foo' => 34, 'bar' => -3) end - it "can be set with #hash_table_old=" do - instance.hash_table_old = { "foo" => 34, "bar" => -3 } - instance.hash_table_old.to_hash.must_equal("foo" => 34, "bar" => -3) - instance.get_property_extended("hash-table-old").to_hash.must_equal("foo" => 34, - "bar" => -3) + it 'can be set with #hash_table_old=' do + instance.hash_table_old = { 'foo' => 34, 'bar' => -3 } + instance.hash_table_old.to_hash.must_equal('foo' => 34, 'bar' => -3) + instance.get_property_extended('hash-table-old').to_hash.must_equal('foo' => 34, + 'bar' => -3) end end describe "its 'int' property" do - it "can be retrieved with #get_property" do - assert_equal 0, instance.get_property("int").get_value + it 'can be retrieved with #get_property' do + assert_equal 0, instance.get_property('int').get_value end - it "can be retrieved with #int" do + it 'can be retrieved with #int' do assert_equal 0, instance.int end - it "can be set with #set_property" do - instance.set_property "int", 42 - assert_equal 42, instance.get_property("int").get_value + it 'can be set with #set_property' do + instance.set_property 'int', 42 + assert_equal 42, instance.get_property('int').get_value end - it "can be set with #int=" do + it 'can be set with #int=' do instance.int = 41 - assert_equal 41, instance.get_property("int").get_value + assert_equal 41, instance.get_property('int').get_value assert_equal 41, instance.int end end describe "its 'list' property" do - it "can be retrieved with #get_property_extended" do - instance.get_property_extended("list").must_be_nil + it 'can be retrieved with #get_property_extended' do + instance.get_property_extended('list').must_be_nil end - it "can be retrieved with #list" do + it 'can be retrieved with #list' do instance.list.must_be_nil end - it "can be set with #set_property_extended" do - instance.set_property_extended "list", %w(foo bar) + it 'can be set with #set_property_extended' do + instance.set_property_extended 'list', %w(foo bar) instance.list.to_a.must_equal %w(foo bar) end - it "can be set with #list=" do + it 'can be set with #list=' do instance.list = %w(foo bar) instance.list.to_a.must_equal %w(foo bar) - instance.get_property_extended("list").must_be :==, %w(foo bar) + instance.get_property_extended('list').must_be :==, %w(foo bar) end end describe "its 'list-old' property" do - it "can be retrieved with #get_property" do - instance.get_property_extended("list-old").must_be_nil + it 'can be retrieved with #get_property' do + instance.get_property_extended('list-old').must_be_nil end - it "can be retrieved with #list_old" do + it 'can be retrieved with #list_old' do instance.list_old.must_be_nil end - it "can be set with #set_property_extended" do - instance.set_property_extended "list-old", %w(foo bar) + it 'can be set with #set_property_extended' do + instance.set_property_extended 'list-old', %w(foo bar) instance.list_old.must_be :==, %w(foo bar) end - it "can be set with #list_old=" do + it 'can be set with #list_old=' do instance.list_old = %w(foo bar) instance.list_old.must_be :==, %w(foo bar) - instance.get_property_extended("list-old").must_be :==, %w(foo bar) + instance.get_property_extended('list-old').must_be :==, %w(foo bar) end end describe "its 'pptrarray' property" do - it "can be retrieved with #get_property" do + it 'can be retrieved with #get_property' do skip 'pptrarray is not implemented properly' - instance.get_property("pptrarray").must_be_nil + instance.get_property('pptrarray').must_be_nil end - it "can be retrieved with #pptrarray" do + it 'can be retrieved with #pptrarray' do skip 'pptrarray is not implemented properly' instance.pptrarray.must_be_nil end - it "can be set with #set_property" do + it 'can be set with #set_property' do skip 'pptrarray is not implemented properly' arr = Regress.test_garray_container_return instance.set_property 'pptrarray', arr instance.pptrarray.must_be :==, arr end - it "can be set with #pptrarray=" do + it 'can be set with #pptrarray=' do skip 'pptrarray is not implemented properly' arr = Regress.test_garray_container_return instance.pptrarray = arr instance.pptrarray.must_be :==, arr - instance.get_property("pptrarray").must_be :==, arr + instance.get_property('pptrarray').must_be :==, arr end end describe "its 'string' property" do - it "can be retrieved with #get_property" do - assert_nil instance.get_property("string").get_value + it 'can be retrieved with #get_property' do + assert_nil instance.get_property('string').get_value end - it "can be retrieved with #string" do + it 'can be retrieved with #string' do assert_nil instance.string end - it "can be set with #set_property" do - instance.set_property "string", "foobar" - assert_equal "foobar", instance.get_property("string").get_value + it 'can be set with #set_property' do + instance.set_property 'string', 'foobar' + assert_equal 'foobar', instance.get_property('string').get_value end - it "can be set with #string=" do - instance.string = "foobar" - assert_equal "foobar", instance.string - assert_equal "foobar", instance.get_property("string").get_value + it 'can be set with #string=' do + instance.string = 'foobar' + assert_equal 'foobar', instance.string + assert_equal 'foobar', instance.get_property('string').get_value end end it "handles the 'all' signal" do a = nil - GObject.signal_connect(instance, "all") { a = 4 } - GObject.signal_emit instance, "all" + GObject.signal_connect(instance, 'all') { a = 4 } + GObject.signal_emit instance, 'all' a.must_equal 4 end it "handles the 'cleanup' signal" do a = nil - GObject.signal_connect(instance, "cleanup") { a = 4 } - GObject.signal_emit instance, "cleanup" + GObject.signal_connect(instance, 'cleanup') { a = 4 } + GObject.signal_emit instance, 'cleanup' a.must_equal 4 end it "handles the 'first' signal" do a = nil - GObject.signal_connect(instance, "first") { a = 4 } - GObject.signal_emit instance, "first" + GObject.signal_connect(instance, 'first') { a = 4 } + GObject.signal_emit instance, 'first' a.must_equal 4 end it "handles the 'sig-with-array-len-prop' signal" do - skip unless get_signal_introspection_data "Regress", "TestObj", "sig-with-array-len-prop" + skip unless get_signal_introspection_data 'Regress', 'TestObj', 'sig-with-array-len-prop' a = nil - GObject.signal_connect(instance, "sig-with-array-len-prop") do |_obj, arr, _user_data| + GObject.signal_connect(instance, 'sig-with-array-len-prop') do |_obj, arr, _user_data| a = arr end arr = GirFFI::InPointer.from_array(:uint, [1, 2, 3]) - GObject.signal_emit instance, "sig-with-array-len-prop", arr, 3 + GObject.signal_emit instance, 'sig-with-array-len-prop', arr, 3 a.to_a.must_equal [1, 2, 3] end it "handles the 'sig-with-array-prop' signal" do a = nil - GObject.signal_connect(instance, "sig-with-array-prop") { |_, arr, _| a = arr } - GObject.signal_emit instance, "sig-with-array-prop", + GObject.signal_connect(instance, 'sig-with-array-prop') { |_, arr, _| a = arr } + GObject.signal_emit instance, 'sig-with-array-prop', GLib::Array.from(:uint, [1, 2, 3]) a.to_a.must_equal [1, 2, 3] end it "handles the 'sig-with-foreign-struct' signal" do - skip unless get_signal_introspection_data "Regress", "TestObj", "sig-with-foreign-struct" + skip unless get_signal_introspection_data 'Regress', 'TestObj', 'sig-with-foreign-struct' a = nil - instance.signal_connect "sig-with-foreign-struct" do |_obj, ct| + instance.signal_connect 'sig-with-foreign-struct' do |_obj, ct| a = ct end cairo_context = Regress.test_cairo_context_full_return - GObject.signal_emit instance, "sig-with-foreign-struct", cairo_context + GObject.signal_emit instance, 'sig-with-foreign-struct', cairo_context a.must_be_instance_of Cairo::Context a.must_equal cairo_context @@ -1065,45 +1065,45 @@ class << Regress::Lib it "handles the 'sig-with-hash-prop' signal" do a = nil - GObject.signal_connect(instance, "sig-with-hash-prop") do |_, ghash, _| + GObject.signal_connect(instance, 'sig-with-hash-prop') do |_, ghash, _| a = ghash.to_hash end g_hash_table = GLib::HashTable.from([:utf8, GObject::Value], - "foo" => GObject::Value.from("bar")) + 'foo' => GObject::Value.from('bar')) - GObject.signal_emit instance, "sig-with-hash-prop", g_hash_table + GObject.signal_emit instance, 'sig-with-hash-prop', g_hash_table - a["foo"].must_be_instance_of GObject::Value - a["foo"].get_value.must_equal "bar" + a['foo'].must_be_instance_of GObject::Value + a['foo'].get_value.must_equal 'bar' end it "handles the 'sig-with-int64-prop' signal" do - skip unless get_signal_introspection_data "Regress", "TestObj", "sig-with-int64-prop" + skip unless get_signal_introspection_data 'Regress', 'TestObj', 'sig-with-int64-prop' a = nil - GObject.signal_connect(instance, "sig-with-int64-prop") do |_obj, int64, _user_data| + GObject.signal_connect(instance, 'sig-with-int64-prop') do |_obj, int64, _user_data| a = int64 end - result = GObject.signal_emit instance, "sig-with-int64-prop", 0x7fff_ffff_ffff_ffff + result = GObject.signal_emit instance, 'sig-with-int64-prop', 0x7fff_ffff_ffff_ffff a.must_equal 0x7fff_ffff_ffff_ffff result.get_value.must_equal 0x7fff_ffff_ffff_ffff end it "handles the 'sig-with-intarray-ret' signal" do - skip unless get_signal_introspection_data "Regress", "TestObj", "sig-with-intarray-ret" + skip unless get_signal_introspection_data 'Regress', 'TestObj', 'sig-with-intarray-ret' a = nil - GObject.signal_connect(instance, "sig-with-intarray-ret") do |_, i, _| + GObject.signal_connect(instance, 'sig-with-intarray-ret') do |_, i, _| a = i [3, 2, 1] end - result = GObject.signal_emit instance, "sig-with-intarray-ret", 3 + result = GObject.signal_emit instance, 'sig-with-intarray-ret', 3 a.must_equal 3 @@ -1114,12 +1114,12 @@ class << Regress::Lib it "handles the 'sig-with-obj' signal" do a = nil - GObject.signal_connect(instance, "sig-with-obj") do |_, obj, _| + GObject.signal_connect(instance, 'sig-with-obj') do |_, obj, _| a = obj end object = Regress::TestObj.constructor - GObject.signal_emit instance, "sig-with-obj", object + GObject.signal_emit instance, 'sig-with-obj', object a.must_equal object end @@ -1127,25 +1127,25 @@ class << Regress::Lib it "handles the 'sig-with-strv' signal" do a = nil - GObject.signal_connect(instance, "sig-with-strv") do |_, strs, _| + GObject.signal_connect(instance, 'sig-with-strv') do |_, strs, _| a = strs end - GObject.signal_emit instance, "sig-with-strv", GLib::Strv.from(%w(foo bar)) + GObject.signal_emit instance, 'sig-with-strv', GLib::Strv.from(%w(foo bar)) a.to_a.must_equal %w(foo bar) end it "handles the 'sig-with-uint64-prop' signal" do - skip unless get_signal_introspection_data "Regress", "TestObj", "sig-with-uint64-prop" + skip unless get_signal_introspection_data 'Regress', 'TestObj', 'sig-with-uint64-prop' a = nil - GObject.signal_connect(instance, "sig-with-uint64-prop") do |_, uint64, _| + GObject.signal_connect(instance, 'sig-with-uint64-prop') do |_, uint64, _| a = uint64 end - result = GObject.signal_emit instance, "sig-with-uint64-prop", 0xffff_ffff_ffff_ffff + result = GObject.signal_emit instance, 'sig-with-uint64-prop', 0xffff_ffff_ffff_ffff a.must_equal 0xffff_ffff_ffff_ffff result.get_value.must_equal 0xffff_ffff_ffff_ffff @@ -1154,140 +1154,140 @@ class << Regress::Lib it "handles the 'test' signal" do a = b = nil o = Regress::TestSubObj.new - GObject.signal_connect(o, "test", 2) { |i, d| a = d; b = i } - GObject.signal_emit o, "test" + GObject.signal_connect(o, 'test', 2) { |i, d| a = d; b = i } + GObject.signal_emit o, 'test' assert_equal [2, o], [a, b] end it "handles the 'test-with-static-scope-arg' signal" do a = nil - GObject.signal_connect(instance, "test-with-static-scope-arg") do |_, obj, _| + GObject.signal_connect(instance, 'test-with-static-scope-arg') do |_, obj, _| a = obj end arg = Regress::TestSimpleBoxedA.new arg.some_int = 12_345 - GObject.signal_emit instance, "test-with-static-scope-arg", arg + GObject.signal_emit instance, 'test-with-static-scope-arg', arg a.some_int.must_equal 12_345 end end - describe "Regress::TestOtherError" do + describe 'Regress::TestOtherError' do before do skip unless get_introspection_data 'Regress', 'TestOtherError' end - it "has the member :code1" do + it 'has the member :code1' do Regress::TestOtherError[:code1].must_equal 1 end - it "has the member :code2" do + it 'has the member :code2' do Regress::TestOtherError[:code2].must_equal 2 end - it "has the member :code3" do + it 'has the member :code3' do Regress::TestOtherError[:code3].must_equal 3 end - it "has a working function #quark" do + it 'has a working function #quark' do quark = Regress::TestOtherError.quark - GLib.quark_to_string(quark).must_equal "regress-test-other-error" + GLib.quark_to_string(quark).must_equal 'regress-test-other-error' end end - describe "Regress::TestPrivateEnum" do - it "has the member :public_enum_before" do + describe 'Regress::TestPrivateEnum' do + it 'has the member :public_enum_before' do Regress::TestPrivateEnum[:public_enum_before].must_equal 1 end - it "does not have the member :private" do + it 'does not have the member :private' do Regress::TestPrivateEnum[:private].must_equal nil end - it "has the member :public_enum_after" do + it 'has the member :public_enum_after' do Regress::TestPrivateEnum[:public_enum_after].must_equal 4 end end - describe "Regress::TestPrivateStruct" do + describe 'Regress::TestPrivateStruct' do let(:instance) { Regress::TestPrivateStruct.new } - it "has a writable field this_is_public_before" do + it 'has a writable field this_is_public_before' do instance.this_is_public_before.must_equal 0 instance.this_is_public_before = 42 instance.this_is_public_before.must_equal 42 end - it "has a private field this_is_private" do - skip "This field is identified as readable in the typelib" + it 'has a private field this_is_private' do + skip 'This field is identified as readable in the typelib' proc { instance.this_is_private }.must_raise NoMethodError proc { instance.this_is_private = 42 }.must_raise NoMethodError end - it "has a writable field this_is_public_after" do + it 'has a writable field this_is_public_after' do instance.this_is_public_after.must_equal 0 instance.this_is_public_after = 42 instance.this_is_public_after.must_equal 42 end end - describe "Regress::TestReferenceEnum" do + describe 'Regress::TestReferenceEnum' do before do skip unless get_introspection_data 'Regress', 'TestReferenceEnum' end - it "has the member :0" do + it 'has the member :0' do Regress::TestReferenceEnum[:"0"].must_equal 4 end - it "has the member :1" do + it 'has the member :1' do Regress::TestReferenceEnum[:"1"].must_equal 2 end - it "has the member :2" do + it 'has the member :2' do Regress::TestReferenceEnum[:"2"].must_equal 54 end - it "has the member :3" do + it 'has the member :3' do Regress::TestReferenceEnum[:"3"].must_equal 4 end - it "has the member :4" do + it 'has the member :4' do Regress::TestReferenceEnum[:"4"].must_equal 216 end - it "has the member :5" do + it 'has the member :5' do Regress::TestReferenceEnum[:"5"].must_equal(-217) end end - describe "Regress::TestSimpleBoxedA" do - it "creates an instance using #new" do + describe 'Regress::TestSimpleBoxedA' do + it 'creates an instance using #new' do obj = Regress::TestSimpleBoxedA.new assert_instance_of Regress::TestSimpleBoxedA, obj end let(:instance) { Regress::TestSimpleBoxedA.new } - it "has a writable field some_int" do + it 'has a writable field some_int' do instance.some_int.must_equal 0 instance.some_int = 42 instance.some_int.must_equal 42 end - it "has a writable field some_int8" do + it 'has a writable field some_int8' do instance.some_int8.must_equal 0 instance.some_int8 = 42 instance.some_int8.must_equal 42 end - it "has a writable field some_double" do + it 'has a writable field some_double' do instance.some_double.must_equal 0.0 instance.some_double = 42.0 instance.some_double.must_equal 42.0 end - it "has a writable field some_enum" do + it 'has a writable field some_enum' do instance.some_enum.must_equal :value1 instance.some_enum = :value4 instance.some_enum.must_equal :value4 end - it "has a working method #copy" do + it 'has a working method #copy' do instance.some_int = 4236 obj2 = instance.copy @@ -1298,7 +1298,7 @@ class << Regress::Lib obj2.some_int.wont_equal instance.some_int end - it "has a working method #equals" do + it 'has a working method #equals' do instance.some_int = 4236 ob2 = Regress::TestSimpleBoxedA.new @@ -1310,27 +1310,27 @@ class << Regress::Lib ob2.equals(instance).wont_equal true end - it "has a working function #const_return" do + it 'has a working function #const_return' do result = Regress::TestSimpleBoxedA.const_return [result.some_int, result.some_int8, result.some_double].must_equal [5, 6, 7.0] end end - describe "Regress::TestSimpleBoxedB" do + describe 'Regress::TestSimpleBoxedB' do let(:instance) { Regress::TestSimpleBoxedB.new } - it "has a writable field some_int8" do + it 'has a writable field some_int8' do instance.some_int8.must_equal 0 instance.some_int8 = 42 instance.some_int8.must_equal 42 end - it "has a writable field nested_a" do + it 'has a writable field nested_a' do instance.nested_a.some_int.must_equal 0 instance.nested_a = Regress::TestSimpleBoxedA.const_return instance.nested_a.some_int.must_equal 5 end - it "has a working method #copy" do + it 'has a working method #copy' do instance.some_int8 = -42 instance.nested_a.some_int = 4242 @@ -1342,33 +1342,33 @@ class << Regress::Lib end end - describe "Regress::TestStructA" do + describe 'Regress::TestStructA' do let(:instance) { Regress::TestStructA.new } - it "has a writable field some_int" do + it 'has a writable field some_int' do instance.some_int.must_equal 0 instance.some_int = 2556 instance.some_int.must_equal 2556 end - it "has a writable field some_int8" do + it 'has a writable field some_int8' do instance.some_int8.must_equal 0 instance.some_int8 = -10 instance.some_int8.must_equal(-10) end - it "has a writable field some_double" do + it 'has a writable field some_double' do instance.some_double.must_equal 0.0 instance.some_double = 1.03455e20 instance.some_double.must_equal 1.03455e20 end - it "has a writable field some_enum" do + it 'has a writable field some_enum' do instance.some_enum.must_equal :value1 instance.some_enum = :value2 instance.some_enum.must_equal :value2 end - it "has a working method #clone" do + it 'has a working method #clone' do a = Regress::TestStructA.new a.some_int = 2556 a.some_int8 = -10 @@ -1383,22 +1383,22 @@ class << Regress::Lib assert_equal :value2, b.some_enum end - it "has a working function #parse" do + it 'has a working function #parse' do skip unless get_method_introspection_data 'Regress', 'TestStructA', 'parse' - a = Regress::TestStructA.parse("this string is actually ignored") + a = Regress::TestStructA.parse('this string is actually ignored') a.some_int.must_equal 23 end end - describe "Regress::TestStructB" do + describe 'Regress::TestStructB' do let(:instance) { Regress::TestStructB.new } - it "has a writable field some_int8" do + it 'has a writable field some_int8' do instance.some_int8.must_equal 0 instance.some_int8 = 42 instance.some_int8.must_equal 42 end - it "has a writable field nested_a" do + it 'has a writable field nested_a' do instance.nested_a.some_int.must_equal 0 nested = Regress::TestStructA.new @@ -1408,7 +1408,7 @@ class << Regress::Lib instance.nested_a.some_int.must_equal(-4321) end - it "has a working method #clone" do + it 'has a working method #clone' do a = Regress::TestStructB.new a.some_int8 = 42 a.nested_a.some_int = 2556 @@ -1426,15 +1426,15 @@ class << Regress::Lib end end - describe "Regress::TestStructC" do + describe 'Regress::TestStructC' do let(:instance) { Regress::TestStructC.new } - it "has a writable field another_int" do + it 'has a writable field another_int' do instance.another_int.must_equal 0 instance.another_int = 42 instance.another_int.must_equal 42 end - it "has a writable field obj" do + it 'has a writable field obj' do o = Regress::TestSubObj.new instance.obj.must_equal nil instance.obj = o @@ -1442,37 +1442,37 @@ class << Regress::Lib end end - describe "Regress::TestStructD" do + describe 'Regress::TestStructD' do let(:instance) { Regress::TestStructD.new } - it "has a writable field array1" do + it 'has a writable field array1' do instance.array1.must_be :==, [] struct = Regress::TestStructA.new instance.array1 = [struct] instance.array1.must_be :==, [struct] end - it "has a writable field array2" do + it 'has a writable field array2' do instance.array2.must_be :==, [] o = Regress::TestSubObj.new instance.array2 = [o] instance.array2.must_be :==, [o] end - it "has a writable field field" do + it 'has a writable field field' do instance.field.must_equal nil o = Regress::TestSubObj.new instance.field = o instance.field.must_equal o end - it "has a writable field list" do + it 'has a writable field list' do instance.list.must_be_nil o = Regress::TestSubObj.new instance.list = [o] instance.list.must_be :==, [o] end - it "has a writable field garray" do + it 'has a writable field garray' do instance.garray.must_be_nil o = Regress::TestSubObj.new instance.garray = [o] @@ -1480,15 +1480,15 @@ class << Regress::Lib end end - describe "Regress::TestStructE" do + describe 'Regress::TestStructE' do let(:instance) { Regress::TestStructE.new } - it "has a writable field some_type" do + it 'has a writable field some_type' do instance.some_type.must_equal 0 instance.some_type = GObject::TYPE_STRING instance.some_type.must_equal GObject::TYPE_STRING end - it "has a writable field some_union" do + it 'has a writable field some_union' do instance.some_union.map(&:v_int).must_equal [0, 0] union1 = Regress::TestStructE__some_union__union.new @@ -1501,114 +1501,114 @@ class << Regress::Lib instance.some_union.map(&:v_int).must_equal [42, 84] end end - describe "Regress::TestStructE__some_union__union" do + describe 'Regress::TestStructE__some_union__union' do let(:instance) { Regress::TestStructE__some_union__union.new } - it "has a writable field v_int" do + it 'has a writable field v_int' do instance.v_int.must_equal 0 instance.v_int = -54_321 instance.v_int.must_equal(-54_321) end - it "has a writable field v_uint" do + it 'has a writable field v_uint' do instance.v_uint.must_equal 0 instance.v_uint = 54_321 instance.v_uint.must_equal 54_321 end - it "has a writable field v_long" do + it 'has a writable field v_long' do instance.v_long.must_equal 0 instance.v_long = -54_321 instance.v_long.must_equal(-54_321) end - it "has a writable field v_ulong" do + it 'has a writable field v_ulong' do instance.v_long.must_equal 0 instance.v_long = 54_321 instance.v_long.must_equal 54_321 end - it "has a writable field v_int64" do + it 'has a writable field v_int64' do instance.v_int64.must_equal 0 instance.v_int64 = -54_321_000_000_000 instance.v_int64.must_equal(-54_321_000_000_000) end - it "has a writable field v_uint64" do + it 'has a writable field v_uint64' do instance.v_uint64.must_equal 0 instance.v_uint64 = 54_321_000_000_000 instance.v_uint64.must_equal 54_321_000_000_000 end - it "has a writable field v_float" do + it 'has a writable field v_float' do instance.v_float.must_equal 0 instance.v_float = 3.1415 instance.v_float.must_be_close_to 3.1415 end - it "has a writable field v_double" do + it 'has a writable field v_double' do instance.v_double.must_equal 0 instance.v_double = 3.1415 instance.v_double.must_equal 3.1415 end - it "has a writable field v_pointer" do + it 'has a writable field v_pointer' do instance.v_pointer.must_be :null? instance.v_pointer = FFI::Pointer.new 54_321 instance.v_pointer.address.must_equal 54_321 end end - describe "Regress::TestStructF" do + describe 'Regress::TestStructF' do before do skip unless get_introspection_data 'Regress', 'TestStructF' end let(:instance) { Regress::TestStructF.new } - it "has a writable field ref_count" do + it 'has a writable field ref_count' do instance.ref_count.must_equal 0 instance.ref_count = 1 instance.ref_count.must_equal 1 end - it "has a writable field data1" do + it 'has a writable field data1' do instance.data1.must_be :null? instance.data1 = GirFFI::InOutPointer.from(:gint32, 42) instance.data1.read_int.must_equal 42 end # TODO: Check what gobject-introspection should/will do with these fields. - it "has a writable field data2" do - skip "Introspection data cannot deal with type of this field yet" + it 'has a writable field data2' do + skip 'Introspection data cannot deal with type of this field yet' end - it "has a writable field data3" do - skip "Introspection data cannot deal with type of this field yet" + it 'has a writable field data3' do + skip 'Introspection data cannot deal with type of this field yet' end - it "has a writable field data4" do - skip "Introspection data cannot deal with type of this field yet" + it 'has a writable field data4' do + skip 'Introspection data cannot deal with type of this field yet' end - it "has a writable field data5" do - skip "Introspection data cannot deal with type of this field yet" + it 'has a writable field data5' do + skip 'Introspection data cannot deal with type of this field yet' end - it "has a writable field data6" do - skip "Introspection data cannot deal with type of this field yet" + it 'has a writable field data6' do + skip 'Introspection data cannot deal with type of this field yet' end end - describe "Regress::TestStructFixedArray" do + describe 'Regress::TestStructFixedArray' do let(:instance) { Regress::TestStructFixedArray.new } - it "has a writable field just_int" do + it 'has a writable field just_int' do instance.just_int.must_equal 0 instance.just_int = 42 instance.just_int.must_equal 42 end - it "has a writable field array" do + it 'has a writable field array' do instance.array.must_be :==, [0] * 10 instance.array = (1..10).to_a instance.array.must_be :==, (1..10).to_a end - it "has a working method #frob" do + it 'has a working method #frob' do instance.array = (0..9).to_a instance.frob instance.array.must_be :==, (42..42 + 9).to_a @@ -1616,46 +1616,46 @@ class << Regress::Lib end end - describe "Regress::TestSubObj" do - it "creates an instance using #new" do + describe 'Regress::TestSubObj' do + it 'creates an instance using #new' do tso = Regress::TestSubObj.new assert_instance_of Regress::TestSubObj, tso end let(:instance) { Regress::TestSubObj.new } - it "has a working method #instance_method" do + it 'has a working method #instance_method' do res = instance.instance_method assert_equal 0, res end - it "has a working method #unset_bare" do + it 'has a working method #unset_bare' do instance.unset_bare pass end - it "does not have a field parent_instance" do + it 'does not have a field parent_instance' do assert_raises(NoMethodError) { instance.parent_instance } end end - describe "Regress::TestWi8021x" do - it "creates an instance using #new" do + describe 'Regress::TestWi8021x' do + it 'creates an instance using #new' do o = Regress::TestWi8021x.new assert_instance_of Regress::TestWi8021x, o end - it "has a working function #static_method" do + it 'has a working function #static_method' do assert_equal(-84, Regress::TestWi8021x.static_method(-42)) end let(:instance) { Regress::TestWi8021x.new } - it "has a working method #get_testbool" do + it 'has a working method #get_testbool' do instance.get_testbool.must_equal true end - it "has a working method #set_testbool" do + it 'has a working method #set_testbool' do instance.set_testbool true instance.get_testbool.must_equal true instance.set_testbool false @@ -1663,89 +1663,89 @@ class << Regress::Lib end describe "its 'testbool' property" do - it "can be retrieved with #get_property" do - instance.get_property("testbool").get_value.must_equal true + it 'can be retrieved with #get_property' do + instance.get_property('testbool').get_value.must_equal true end - it "can be retrieved with #testbool" do + it 'can be retrieved with #testbool' do instance.testbool.must_equal true end - it "can be set with #set_property" do - instance.set_property "testbool", true + it 'can be set with #set_property' do + instance.set_property 'testbool', true instance.get_testbool.must_equal true - instance.get_property("testbool").get_value.must_equal true + instance.get_property('testbool').get_value.must_equal true - instance.set_property "testbool", false + instance.set_property 'testbool', false instance.get_testbool.must_equal false - instance.get_property("testbool").get_value.must_equal false + instance.get_property('testbool').get_value.must_equal false end - it "can be set with #testbool=" do + it 'can be set with #testbool=' do instance.testbool = true instance.testbool.must_equal true instance.get_testbool.must_equal true - instance.get_property("testbool").get_value.must_equal true + instance.get_property('testbool').get_value.must_equal true instance.testbool = false instance.testbool.must_equal false instance.get_testbool.must_equal false - instance.get_property("testbool").get_value.must_equal false + instance.get_property('testbool').get_value.must_equal false end end end - it "has the constant UTF8_CONSTANT" do - assert_equal "const ♥ utf8", Regress::UTF8_CONSTANT + it 'has the constant UTF8_CONSTANT' do + assert_equal 'const ♥ utf8', Regress::UTF8_CONSTANT end - it "has a working function #aliased_caller_alloc" do + it 'has a working function #aliased_caller_alloc' do result = Regress.aliased_caller_alloc result.must_be_instance_of Regress::TestBoxed end - it "has a working function #atest_error_quark" do + it 'has a working function #atest_error_quark' do skip unless get_introspection_data 'Regress', 'atest_error_quark' result = Regress.atest_error_quark - GLib.quark_to_string(result).must_equal "regress-atest-error" + GLib.quark_to_string(result).must_equal 'regress-atest-error' end - it "has a working function #func_obj_null_in" do + it 'has a working function #func_obj_null_in' do Regress.func_obj_null_in nil Regress.func_obj_null_in Regress::TestObj.constructor pass end - it "has a working function #global_get_flags_out" do + it 'has a working function #global_get_flags_out' do result = Regress.global_get_flags_out result.must_equal Regress::TestFlags[:flag1] | Regress::TestFlags[:flag3] end - it "has a working function #has_parameter_named_attrs" do + it 'has a working function #has_parameter_named_attrs' do skip unless get_introspection_data 'Regress', 'has_parameter_named_attrs' Regress.has_parameter_named_attrs 42, [23] * 32 pass end - it "has a working function #introspectable_via_alias" do + it 'has a working function #introspectable_via_alias' do Regress.introspectable_via_alias [] pass end - it "has a working function #set_abort_on_error" do + it 'has a working function #set_abort_on_error' do Regress.set_abort_on_error false Regress.set_abort_on_error true pass end - it "has a working function #test_abc_error_quark" do + it 'has a working function #test_abc_error_quark' do skip unless get_introspection_data 'Regress', 'test_abc_error_quark' quark = Regress.test_abc_error_quark - GLib.quark_to_string(quark).must_equal "regress-test-abc-error" + GLib.quark_to_string(quark).must_equal 'regress-test-abc-error' end - it "has a working function #test_array_callback" do + it 'has a working function #test_array_callback' do a = nil b = nil c = 95 @@ -1763,7 +1763,7 @@ class << Regress::Lib b.to_a.must_equal %w(one two three) end - it "has a working function #test_array_fixed_out_objects" do + it 'has a working function #test_array_fixed_out_objects' do result = Regress.test_array_fixed_out_objects gtype = Regress::TestObj.get_gtype @@ -1775,49 +1775,49 @@ class << Regress::Lib } end - it "has a working function #test_array_fixed_size_int_in" do + it 'has a working function #test_array_fixed_size_int_in' do assert_equal 5 + 4 + 3 + 2 + 1, Regress.test_array_fixed_size_int_in([5, 4, 3, 2, 1]) end - describe "#test_array_fixed_size_int_in" do - it "raises an error when called with the wrong number of arguments" do + describe '#test_array_fixed_size_int_in' do + it 'raises an error when called with the wrong number of arguments' do assert_raises ArgumentError do Regress.test_array_fixed_size_int_in [2] end end end - it "has a working function #test_array_fixed_size_int_out" do + it 'has a working function #test_array_fixed_size_int_out' do Regress.test_array_fixed_size_int_out.must_be :==, [0, 1, 2, 3, 4] end - it "has a working function #test_array_fixed_size_int_return" do + it 'has a working function #test_array_fixed_size_int_return' do Regress.test_array_fixed_size_int_return.must_be :==, [0, 1, 2, 3, 4] end - it "has a working function #test_array_gint16_in" do + it 'has a working function #test_array_gint16_in' do assert_equal 5 + 4 + 3, Regress.test_array_gint16_in([5, 4, 3]) end - it "has a working function #test_array_gint32_in" do + it 'has a working function #test_array_gint32_in' do assert_equal 5 + 4 + 3, Regress.test_array_gint32_in([5, 4, 3]) end - it "has a working function #test_array_gint64_in" do + it 'has a working function #test_array_gint64_in' do assert_equal 5 + 4 + 3, Regress.test_array_gint64_in([5, 4, 3]) end - it "has a working function #test_array_gint8_in" do + it 'has a working function #test_array_gint8_in' do assert_equal 5 + 4 + 3, Regress.test_array_gint8_in([5, 4, 3]) end - it "has a working function #test_array_gtype_in" do - t1 = GObject.type_from_name "gboolean" - t2 = GObject.type_from_name "gint64" - assert_equal "[gboolean,gint64,]", Regress.test_array_gtype_in([t1, t2]) + it 'has a working function #test_array_gtype_in' do + t1 = GObject.type_from_name 'gboolean' + t2 = GObject.type_from_name 'gint64' + assert_equal '[gboolean,gint64,]', Regress.test_array_gtype_in([t1, t2]) end - it "has a working function #test_array_inout_callback" do + it 'has a working function #test_array_inout_callback' do skip unless get_introspection_data 'Regress', 'test_array_inout_callback' Regress.test_array_inout_callback proc { |ints| arr = ints.to_a @@ -1827,36 +1827,36 @@ class << Regress::Lib pass end - it "has a working function #test_array_int_full_out" do + it 'has a working function #test_array_int_full_out' do Regress.test_array_int_full_out.must_be :==, [0, 1, 2, 3, 4] end - it "has a working function #test_array_int_in" do + it 'has a working function #test_array_int_in' do assert_equal 5 + 4 + 3, Regress.test_array_int_in([5, 4, 3]) end - it "has a working function #test_array_int_inout" do + it 'has a working function #test_array_int_inout' do Regress.test_array_int_inout([5, 2, 3]).must_be :==, [3, 4] end - it "has a working function #test_array_int_none_out" do + it 'has a working function #test_array_int_none_out' do Regress.test_array_int_none_out.must_be :==, [1, 2, 3, 4, 5] end - it "has a working function #test_array_int_null_in" do + it 'has a working function #test_array_int_null_in' do Regress.test_array_int_null_in nil pass end - it "has a working function #test_array_int_null_out" do + it 'has a working function #test_array_int_null_out' do assert_equal nil, Regress.test_array_int_null_out end - it "has a working function #test_array_int_out" do + it 'has a working function #test_array_int_out' do Regress.test_array_int_out.must_be :==, [0, 1, 2, 3, 4] end - it "has a working function #test_async_ready_callback" do + it 'has a working function #test_async_ready_callback' do main_loop = GLib::MainLoop.new nil, false a = 1 @@ -1870,68 +1870,68 @@ class << Regress::Lib assert_equal 2, a end - it "has a working function #test_boolean" do + it 'has a working function #test_boolean' do assert_equal false, Regress.test_boolean(false) assert_equal true, Regress.test_boolean(true) end - it "has a working function #test_boolean_false" do + it 'has a working function #test_boolean_false' do assert_equal false, Regress.test_boolean_false(false) end - it "has a working function #test_boolean_true" do + it 'has a working function #test_boolean_true' do assert_equal true, Regress.test_boolean_true(true) end - it "has a working function #test_boxeds_not_a_method" do + it 'has a working function #test_boxeds_not_a_method' do skip unless get_introspection_data 'Regress', 'test_boxeds_not_a_method' boxed = Regress::TestBoxed.new_alternative_constructor1 123 Regress.test_boxeds_not_a_method boxed pass end - it "has a working function #test_boxeds_not_a_static" do + it 'has a working function #test_boxeds_not_a_static' do skip unless get_introspection_data 'Regress', 'test_boxeds_not_a_static' Regress.test_boxeds_not_a_static pass end - it "has a working function #test_cairo_context_full_return" do + it 'has a working function #test_cairo_context_full_return' do ct = Regress.test_cairo_context_full_return assert_instance_of Cairo::Context, ct end - it "has a working function #test_cairo_context_none_in" do + it 'has a working function #test_cairo_context_none_in' do ct = Regress.test_cairo_context_full_return Regress.test_cairo_context_none_in ct end - it "has a working function #test_cairo_surface_full_out" do + it 'has a working function #test_cairo_surface_full_out' do cs = Regress.test_cairo_surface_full_out assert_instance_of Cairo::Surface, cs end - it "has a working function #test_cairo_surface_full_return" do + it 'has a working function #test_cairo_surface_full_return' do cs = Regress.test_cairo_surface_full_return assert_instance_of Cairo::Surface, cs end - it "has a working function #test_cairo_surface_none_in" do + it 'has a working function #test_cairo_surface_none_in' do cs = Regress.test_cairo_surface_full_return Regress.test_cairo_surface_none_in cs end - it "has a working function #test_cairo_surface_none_return" do + it 'has a working function #test_cairo_surface_none_return' do cs = Regress.test_cairo_surface_none_return assert_instance_of Cairo::Surface, cs end - it "has a working function #test_callback" do + it 'has a working function #test_callback' do result = Regress.test_callback proc { 5 } assert_equal 5, result end - it "has a working function #test_callback_async" do + it 'has a working function #test_callback_async' do a = 1 Regress.test_callback_async proc {|b| a = 2 @@ -1942,7 +1942,7 @@ class << Regress::Lib assert_equal 2, a end - it "has a working function #test_callback_destroy_notify" do + it 'has a working function #test_callback_destroy_notify' do a = 1 r1 = Regress.test_callback_destroy_notify proc {|b| a = 2 @@ -1955,7 +1955,7 @@ class << Regress::Lib assert_equal 42, r2 end - it "has a working function #test_callback_destroy_notify_no_user_data" do + it 'has a working function #test_callback_destroy_notify_no_user_data' do skip unless get_introspection_data 'Regress', 'test_callback_destroy_notify_no_user_data' callback_times_called = 0 @@ -1985,7 +1985,7 @@ class << Regress::Lib b.must_be_nil end - it "has a working function #test_callback_thaw_async" do + it 'has a working function #test_callback_thaw_async' do invoked = [] Regress.test_callback_async proc { invoked << 1; 1 }, nil Regress.test_callback_async proc { invoked << 2; 2 }, nil @@ -1995,7 +1995,7 @@ class << Regress::Lib result.must_equal 1 end - it "has a working function #test_callback_thaw_notifications" do + it 'has a working function #test_callback_thaw_notifications' do invoked = false Regress.test_callback_destroy_notify proc { 42 }, nil, nil Regress.test_callback_destroy_notify proc { 24 }, nil, proc { invoked = true } @@ -2004,18 +2004,18 @@ class << Regress::Lib invoked.must_equal true end - it "has a working function #test_callback_user_data" do - a = "old-value" + it 'has a working function #test_callback_user_data' do + a = 'old-value' result = Regress.test_callback_user_data proc {|u| a = u 5 - }, "new-value" - a.must_equal "new-value" + }, 'new-value' + a.must_equal 'new-value' result.must_equal 5 end - describe "the #test_callback_user_data function" do - it "handles boolean user_data" do + describe 'the #test_callback_user_data function' do + it 'handles boolean user_data' do a = false Regress.test_callback_user_data proc {|u| a = u @@ -2025,28 +2025,28 @@ class << Regress::Lib end end - it "has a working function #test_closure" do + it 'has a working function #test_closure' do c = GObject::RubyClosure.new { 5235 } r = Regress.test_closure c assert_equal 5235, r end - it "has a working function #test_closure_one_arg" do + it 'has a working function #test_closure_one_arg' do c = GObject::RubyClosure.new { |a| a * 2 } r = Regress.test_closure_one_arg c, 2 assert_equal 4, r end - it "has a working function #test_closure_variant" do - arg = GLib::Variant.new_string "foo" + it 'has a working function #test_closure_variant' do + arg = GLib::Variant.new_string 'foo' # TODO: Convert proc to RubyClosure automatically closure = GObject::RubyClosure.new do |variant| str = variant.get_string - if str == "foo" + if str == 'foo' GLib::Variant.new_int32 40 else - GLib::Variant.new_string "bar" + GLib::Variant.new_string 'bar' end end @@ -2055,7 +2055,7 @@ class << Regress::Lib result.get_int32.must_equal 40 end - it "has a working function #test_date_in_gvalue" do + it 'has a working function #test_date_in_gvalue' do r = Regress.test_date_in_gvalue date = r.get_value skip unless date.respond_to? :get_year @@ -2063,97 +2063,97 @@ class << Regress::Lib [date.get_year, date.get_month, date.get_day] end - it "has a working function #test_def_error_quark" do + it 'has a working function #test_def_error_quark' do skip unless get_introspection_data 'Regress', 'test_def_error_quark' quark = Regress.test_def_error_quark - GLib.quark_to_string(quark).must_equal "regress-test-def-error" + GLib.quark_to_string(quark).must_equal 'regress-test-def-error' end - it "has a working function #test_double" do + it 'has a working function #test_double' do r = Regress.test_double 5435.32 assert_equal 5435.32, r end - it "has a working function #test_enum_param" do + it 'has a working function #test_enum_param' do r = Regress.test_enum_param :value3 - assert_equal "value3", r + assert_equal 'value3', r end - it "has a working function #test_error_quark" do + it 'has a working function #test_error_quark' do skip unless get_introspection_data 'Regress', 'test_error_quark' quark = Regress.test_error_quark - GLib.quark_to_string(quark).must_equal "regress-test-error" + GLib.quark_to_string(quark).must_equal 'regress-test-error' end - it "has a working function #test_filename_return" do + it 'has a working function #test_filename_return' do arr = Regress.test_filename_return - arr.must_be :==, ["åäö", "/etc/fstab"] + arr.must_be :==, ['åäö', '/etc/fstab'] end - it "has a working function #test_float" do + it 'has a working function #test_float' do r = Regress.test_float 5435.32 assert_in_delta 5435.32, r, 0.001 end - it "has a working function #test_garray_container_return" do + it 'has a working function #test_garray_container_return' do arr = Regress.test_garray_container_return arr.must_be_instance_of GLib::PtrArray arr.len.must_equal 1 ptr = arr.pdata ptr2 = ptr.read_pointer - ptr2.read_string.must_be :==, "regress" + ptr2.read_string.must_be :==, 'regress' end - it "has a working function #test_garray_full_return" do + it 'has a working function #test_garray_full_return' do result = Regress.test_garray_full_return - result.to_a.must_equal ["regress"] + result.to_a.must_equal ['regress'] end - it "has a working function #test_gerror_callback" do + it 'has a working function #test_gerror_callback' do result = nil Regress.test_gerror_callback proc { |err| result = err.message } - result.must_equal "regression test error" + result.must_equal 'regression test error' end - it "has a working function #test_ghash_container_return" do + it 'has a working function #test_ghash_container_return' do hash = Regress.test_ghash_container_return hash.must_be_instance_of GLib::HashTable - hash.to_hash.must_equal("foo" => "bar", - "baz" => "bat", - "qux" => "quux") + hash.to_hash.must_equal('foo' => 'bar', + 'baz' => 'bat', + 'qux' => 'quux') end - it "has a working function #test_ghash_everything_return" do + it 'has a working function #test_ghash_everything_return' do ghash = Regress.test_ghash_everything_return - ghash.to_hash.must_be :==, "foo" => "bar", - "baz" => "bat", - "qux" => "quux" + ghash.to_hash.must_be :==, 'foo' => 'bar', + 'baz' => 'bat', + 'qux' => 'quux' end - it "has a working function #test_ghash_gvalue_in" do + it 'has a working function #test_ghash_gvalue_in' do skip unless get_introspection_data 'Regress', 'test_ghash_gvalue_in' skip unless get_introspection_data 'Regress', 'test_ghash_gvalue_return' hash_table = Regress.test_ghash_gvalue_return Regress.test_ghash_gvalue_in hash_table end - it "has a working function #test_ghash_gvalue_return" do + it 'has a working function #test_ghash_gvalue_return' do skip unless get_introspection_data 'Regress', 'test_ghash_gvalue_return' result = Regress.test_ghash_gvalue_return hash = result.to_hash - has_enum_and_flag_keys = hash.key?("flags") + has_enum_and_flag_keys = hash.key?('flags') - hash["integer"].get_value.must_equal 12 - hash["boolean"].get_value.must_equal true - hash["string"].get_value.must_equal "some text" - hash["strings"].get_value.to_a.must_equal %w(first second third) + hash['integer'].get_value.must_equal 12 + hash['boolean'].get_value.must_equal true + hash['string'].get_value.must_equal 'some text' + hash['strings'].get_value.to_a.must_equal %w(first second third) if has_enum_and_flag_keys - hash["flags"].get_value.must_equal Regress::TestFlags[:flag1] | Regress::TestFlags[:flag3] - hash["enum"].get_value.must_equal :value2 + hash['flags'].get_value.must_equal Regress::TestFlags[:flag1] | Regress::TestFlags[:flag3] + hash['enum'].get_value.must_equal :value2 end expected_keys = if has_enum_and_flag_keys @@ -2165,225 +2165,225 @@ class << Regress::Lib hash.keys.sort.must_equal expected_keys end - it "has a working function #test_ghash_nested_everything_return" do + it 'has a working function #test_ghash_nested_everything_return' do result = Regress.test_ghash_nested_everything_return hash = result.to_hash - hash.keys.must_equal ["wibble"] - hash["wibble"].to_hash.must_equal("foo" => "bar", - "baz" => "bat", - "qux" => "quux") + hash.keys.must_equal ['wibble'] + hash['wibble'].to_hash.must_equal('foo' => 'bar', + 'baz' => 'bat', + 'qux' => 'quux') end - it "has a working function #test_ghash_nested_everything_return2" do + it 'has a working function #test_ghash_nested_everything_return2' do result = Regress.test_ghash_nested_everything_return2 hash = result.to_hash - hash.keys.must_equal ["wibble"] - hash["wibble"].to_hash.must_equal("foo" => "bar", - "baz" => "bat", - "qux" => "quux") + hash.keys.must_equal ['wibble'] + hash['wibble'].to_hash.must_equal('foo' => 'bar', + 'baz' => 'bat', + 'qux' => 'quux') end - it "has a working function #test_ghash_nothing_in" do - Regress.test_ghash_nothing_in("foo" => "bar", - "baz" => "bat", - "qux" => "quux") + it 'has a working function #test_ghash_nothing_in' do + Regress.test_ghash_nothing_in('foo' => 'bar', + 'baz' => 'bat', + 'qux' => 'quux') end - it "has a working function #test_ghash_nothing_in2" do - Regress.test_ghash_nothing_in2("foo" => "bar", - "baz" => "bat", - "qux" => "quux") + it 'has a working function #test_ghash_nothing_in2' do + Regress.test_ghash_nothing_in2('foo' => 'bar', + 'baz' => 'bat', + 'qux' => 'quux') end - it "has a working function #test_ghash_nothing_return" do + it 'has a working function #test_ghash_nothing_return' do ghash = Regress.test_ghash_nothing_return - ghash.to_hash.must_be :==, "foo" => "bar", - "baz" => "bat", - "qux" => "quux" + ghash.to_hash.must_be :==, 'foo' => 'bar', + 'baz' => 'bat', + 'qux' => 'quux' end - it "has a working function #test_ghash_nothing_return2" do + it 'has a working function #test_ghash_nothing_return2' do ghash = Regress.test_ghash_nothing_return2 - ghash.to_hash.must_be :==, "foo" => "bar", - "baz" => "bat", - "qux" => "quux" + ghash.to_hash.must_be :==, 'foo' => 'bar', + 'baz' => 'bat', + 'qux' => 'quux' end - it "has a working function #test_ghash_null_in" do + it 'has a working function #test_ghash_null_in' do Regress.test_ghash_null_in(nil) end - it "has a working function #test_ghash_null_out" do + it 'has a working function #test_ghash_null_out' do ghash = Regress.test_ghash_null_out ghash.must_be_nil end - it "has a working function #test_ghash_null_return" do + it 'has a working function #test_ghash_null_return' do ghash = Regress.test_ghash_null_return ghash.must_be_nil end - it "has a working function #test_glist_container_return" do + it 'has a working function #test_glist_container_return' do list = Regress.test_glist_container_return assert_instance_of GLib::List, list list.must_be :==, %w(1 2 3) end - it "has a working function #test_glist_everything_return" do + it 'has a working function #test_glist_everything_return' do list = Regress.test_glist_everything_return list.must_be :==, %w(1 2 3) end - it "has a working function #test_glist_nothing_in" do + it 'has a working function #test_glist_nothing_in' do Regress.test_glist_nothing_in %w(1 2 3) pass end - it "has a working function #test_glist_nothing_in2" do + it 'has a working function #test_glist_nothing_in2' do Regress.test_glist_nothing_in2 %w(1 2 3) pass end - it "has a working function #test_glist_nothing_return" do + it 'has a working function #test_glist_nothing_return' do list = Regress.test_glist_nothing_return list.must_be :==, %w(1 2 3) end - it "has a working function #test_glist_nothing_return2" do + it 'has a working function #test_glist_nothing_return2' do list = Regress.test_glist_nothing_return2 list.must_be :==, %w(1 2 3) end - it "has a working function #test_glist_null_in" do + it 'has a working function #test_glist_null_in' do Regress.test_glist_null_in nil pass end - it "has a working function #test_glist_null_out" do + it 'has a working function #test_glist_null_out' do result = Regress.test_glist_null_out assert_equal nil, result end - it "has a working function #test_gslist_container_return" do + it 'has a working function #test_gslist_container_return' do slist = Regress.test_gslist_container_return assert_instance_of GLib::SList, slist slist.must_be :==, %w(1 2 3) end - it "has a working function #test_gslist_everything_return" do + it 'has a working function #test_gslist_everything_return' do slist = Regress.test_gslist_everything_return slist.must_be :==, %w(1 2 3) end - it "has a working function #test_gslist_nothing_in" do + it 'has a working function #test_gslist_nothing_in' do Regress.test_gslist_nothing_in %w(1 2 3) pass end - it "has a working function #test_gslist_nothing_in2" do + it 'has a working function #test_gslist_nothing_in2' do Regress.test_gslist_nothing_in2 %w(1 2 3) pass end - it "has a working function #test_gslist_nothing_return" do + it 'has a working function #test_gslist_nothing_return' do slist = Regress.test_gslist_nothing_return slist.must_be :==, %w(1 2 3) end - it "has a working function #test_gslist_nothing_return2" do + it 'has a working function #test_gslist_nothing_return2' do slist = Regress.test_gslist_nothing_return2 slist.must_be :==, %w(1 2 3) end - it "has a working function #test_gslist_null_in" do + it 'has a working function #test_gslist_null_in' do Regress.test_gslist_null_in nil pass end - it "has a working function #test_gslist_null_out" do + it 'has a working function #test_gslist_null_out' do result = Regress.test_gslist_null_out assert_equal nil, result end - it "has a working function #test_gtype" do + it 'has a working function #test_gtype' do result = Regress.test_gtype 23 assert_equal 23, result end - it "has a working function #test_gvariant_as" do + it 'has a working function #test_gvariant_as' do Regress.test_gvariant_as.get_strv.to_a.must_equal %w(one two three) end - it "has a working function #test_gvariant_asv" do + it 'has a working function #test_gvariant_asv' do result = Regress.test_gvariant_asv result.n_children.must_equal 2 - result.lookup_value("name", nil).get_string.must_equal "foo" - result.lookup_value("timeout", nil).get_int32.must_equal 10 + result.lookup_value('name', nil).get_string.must_equal 'foo' + result.lookup_value('timeout', nil).get_int32.must_equal 10 end - it "has a working function #test_gvariant_i" do + it 'has a working function #test_gvariant_i' do Regress.test_gvariant_i.get_int32.must_equal 1 end - it "has a working function #test_gvariant_s" do - Regress.test_gvariant_s.get_string.must_equal "one" + it 'has a working function #test_gvariant_s' do + Regress.test_gvariant_s.get_string.must_equal 'one' end - it "has a working function #test_gvariant_v" do - Regress.test_gvariant_v.get_variant.get_string.must_equal "contents" + it 'has a working function #test_gvariant_v' do + Regress.test_gvariant_v.get_variant.get_string.must_equal 'contents' end - it "has a working function #test_hash_table_callback" do + it 'has a working function #test_hash_table_callback' do value = nil - Regress.test_hash_table_callback({ "foo" => 42 }, proc { |hash| value = hash }) - value.to_hash.must_equal("foo" => 42) + Regress.test_hash_table_callback({ 'foo' => 42 }, proc { |hash| value = hash }) + value.to_hash.must_equal('foo' => 42) end - it "has a working function #test_int" do + it 'has a working function #test_int' do result = Regress.test_int 23 assert_equal 23, result end - it "has a working function #test_int16" do + it 'has a working function #test_int16' do result = Regress.test_int16 23 assert_equal 23, result end - it "has a working function #test_int32" do + it 'has a working function #test_int32' do result = Regress.test_int32 23 assert_equal 23, result end - it "has a working function #test_int64" do + it 'has a working function #test_int64' do result = Regress.test_int64 2_300_000_000_000 assert_equal 2_300_000_000_000, result end - it "has a working function #test_int8" do + it 'has a working function #test_int8' do result = Regress.test_int8 23 assert_equal 23, result end - it "has a working function #test_int_out_utf8" do - len = Regress.test_int_out_utf8 "How long?" + it 'has a working function #test_int_out_utf8' do + len = Regress.test_int_out_utf8 'How long?' assert_equal 9, len end - it "has a working function #test_int_value_arg" do + it 'has a working function #test_int_value_arg' do gv = GObject::Value.new - gv.init GObject.type_from_name "gint" + gv.init GObject.type_from_name 'gint' gv.set_int 343 result = Regress.test_int_value_arg gv assert_equal 343, result end - it "has a working function #test_long" do + it 'has a working function #test_long' do long_val = FFI.type_size(:long) == 8 ? 2_300_000_000_000 : 2_000_000_000 result = Regress.test_long long_val assert_equal long_val, result end - it "has a working function #test_multi_callback" do + it 'has a working function #test_multi_callback' do a = 1 result = Regress.test_multi_callback proc { a += 1 @@ -2393,221 +2393,221 @@ class << Regress::Lib assert_equal 3, a end - it "has a working function #test_multi_double_args" do + it 'has a working function #test_multi_double_args' do one, two = Regress.test_multi_double_args 23.1 assert_equal 2 * 23.1, one assert_equal 3 * 23.1, two end - it "has a working function #test_multiline_doc_comments" do + it 'has a working function #test_multiline_doc_comments' do Regress.test_multiline_doc_comments.must_be_nil end - it "has a working function #test_nested_parameter" do + it 'has a working function #test_nested_parameter' do Regress.test_nested_parameter(3).must_be_nil end - it "has a working function #test_null_gerror_callback" do + it 'has a working function #test_null_gerror_callback' do value = nil Regress.test_owned_gerror_callback proc { |err| value = err } - value.message.must_equal "regression test owned error" + value.message.must_equal 'regression test owned error' end - it "has a working function #test_owned_gerror_callback" do + it 'has a working function #test_owned_gerror_callback' do value = nil Regress.test_owned_gerror_callback proc { |err| value = err } - value.message.must_equal "regression test owned error" + value.message.must_equal 'regression test owned error' end - it "has a working function #test_short" do + it 'has a working function #test_short' do result = Regress.test_short 23 assert_equal 23, result end - it "has a working function #test_simple_boxed_a_const_return" do + it 'has a working function #test_simple_boxed_a_const_return' do result = Regress.test_simple_boxed_a_const_return assert_equal [5, 6, 7.0], [result.some_int, result.some_int8, result.some_double] end - it "has a working function #test_simple_callback" do + it 'has a working function #test_simple_callback' do a = 0 Regress.test_simple_callback proc { a = 1 } assert_equal 1, a end - it "has a working function #test_size" do + it 'has a working function #test_size' do assert_equal 2354, Regress.test_size(2354) end - it "has a working function #test_ssize" do + it 'has a working function #test_ssize' do assert_equal(-2_000_000, Regress.test_ssize(-2_000_000)) end - it "has a working function #test_struct_a_parse" do + it 'has a working function #test_struct_a_parse' do skip unless get_introspection_data 'Regress', 'test_struct_a_parse' - a = Regress.test_struct_a_parse("this string is actually ignored") + a = Regress.test_struct_a_parse('this string is actually ignored') a.must_be_instance_of Regress::TestStructA a.some_int.must_equal 23 end - it "has a working function #test_strv_in" do + it 'has a working function #test_strv_in' do assert_equal true, Regress.test_strv_in(%w(1 2 3)) end - it "has a working function #test_strv_in_gvalue" do + it 'has a working function #test_strv_in_gvalue' do gv = Regress.test_strv_in_gvalue gv.get_value.must_be :==, %w(one two three) end - it "has a working function #test_strv_out" do + it 'has a working function #test_strv_out' do arr = Regress.test_strv_out arr.must_be :==, %w(thanks for all the fish) end - it "has a working function #test_strv_out_c" do + it 'has a working function #test_strv_out_c' do arr = Regress.test_strv_out_c arr.must_be :==, %w(thanks for all the fish) end - it "has a working function #test_strv_out_container" do + it 'has a working function #test_strv_out_container' do arr = Regress.test_strv_out_container arr.must_be :==, %w(1 2 3) end - it "has a working function #test_strv_outarg" do + it 'has a working function #test_strv_outarg' do arr = Regress.test_strv_outarg arr.must_be :==, %w(1 2 3) end - it "has a working function #test_timet" do + it 'has a working function #test_timet' do # Time rounded to seconds. t = Time.at(Time.now.to_i) result = Regress.test_timet(t.to_i) assert_equal t, Time.at(result) end - it "has a working function #test_torture_signature_0" do - y, z, q = Regress.test_torture_signature_0 86, "foo", 2 + it 'has a working function #test_torture_signature_0' do + y, z, q = Regress.test_torture_signature_0 86, 'foo', 2 assert_equal [86, 2 * 86, 3 + 2], [y, z, q] end - it "has a working function #test_torture_signature_1" do - ret, y, z, q = Regress.test_torture_signature_1(-21, "hello", 12) - [ret, y, z, q].must_equal [true, -21, 2 * -21, "hello".length + 12] + it 'has a working function #test_torture_signature_1' do + ret, y, z, q = Regress.test_torture_signature_1(-21, 'hello', 12) + [ret, y, z, q].must_equal [true, -21, 2 * -21, 'hello'.length + 12] - proc { Regress.test_torture_signature_1(-21, "hello", 11) }. + proc { Regress.test_torture_signature_1(-21, 'hello', 11) }. must_raise GirFFI::GLibError end - it "has a working function #test_torture_signature_2" do + it 'has a working function #test_torture_signature_2' do a = 1 y, z, q = Regress.test_torture_signature_2 244, proc { |u| a = u }, 2, proc { a = 3 }, - "foofoo", 31 + 'foofoo', 31 assert_equal [244, 2 * 244, 6 + 31], [y, z, q] assert_equal 3, a end - it "has a working function #test_uint" do + it 'has a working function #test_uint' do assert_equal 31, Regress.test_uint(31) end - it "has a working function #test_uint16" do + it 'has a working function #test_uint16' do assert_equal 31, Regress.test_uint16(31) end - it "has a working function #test_uint32" do + it 'has a working function #test_uint32' do assert_equal 540_000, Regress.test_uint32(540_000) end - it "has a working function #test_uint64" do + it 'has a working function #test_uint64' do assert_equal 54_000_000_000_000, Regress.test_uint64(54_000_000_000_000) end - it "has a working function #test_uint8" do + it 'has a working function #test_uint8' do assert_equal 31, Regress.test_uint8(31) end - it "has a working function #test_ulong" do + it 'has a working function #test_ulong' do assert_equal 54_000_000_000_000, Regress.test_uint64(54_000_000_000_000) end - it "has a working function #test_unconventional_error_quark" do + it 'has a working function #test_unconventional_error_quark' do skip unless get_introspection_data 'Regress', 'test_unconventional_error_quark' result = Regress.test_unconventional_error_quark - GLib.quark_to_string(result).must_equal "regress-test-other-error" + GLib.quark_to_string(result).must_equal 'regress-test-other-error' end - it "has a working function #test_unichar" do + it 'has a working function #test_unichar' do assert_equal 120, Regress.test_unichar(120) assert_equal 540_000, Regress.test_unichar(540_000) end - it "has a working function #test_unsigned_enum_param" do - assert_equal "value1", Regress.test_unsigned_enum_param(:value1) - assert_equal "value2", Regress.test_unsigned_enum_param(:value2) + it 'has a working function #test_unsigned_enum_param' do + assert_equal 'value1', Regress.test_unsigned_enum_param(:value1) + assert_equal 'value2', Regress.test_unsigned_enum_param(:value2) end - it "has a working function #test_ushort" do + it 'has a working function #test_ushort' do assert_equal 54_000_000, Regress.test_uint64(54_000_000) end - it "has a working function #test_utf8_const_in" do + it 'has a working function #test_utf8_const_in' do Regress.test_utf8_const_in("const \xe2\x99\xa5 utf8") pass end - it "has a working function #test_utf8_const_return" do + it 'has a working function #test_utf8_const_return' do result = Regress.test_utf8_const_return assert_equal "const \xe2\x99\xa5 utf8", result end - it "has a working function #test_utf8_inout" do + it 'has a working function #test_utf8_inout' do result = Regress.test_utf8_inout "const \xe2\x99\xa5 utf8" assert_equal "nonconst \xe2\x99\xa5 utf8", result end - it "has a working function #test_utf8_nonconst_return" do + it 'has a working function #test_utf8_nonconst_return' do result = Regress.test_utf8_nonconst_return assert_equal "nonconst \xe2\x99\xa5 utf8", result end - it "has a working function #test_utf8_null_in" do + it 'has a working function #test_utf8_null_in' do Regress.test_utf8_null_in nil pass end - it "has a working function #test_utf8_null_out" do + it 'has a working function #test_utf8_null_out' do assert_equal nil, Regress.test_utf8_null_out end - it "has a working function #test_utf8_out" do + it 'has a working function #test_utf8_out' do result = Regress.test_utf8_out assert_equal "nonconst \xe2\x99\xa5 utf8", result end - it "has a working function #test_utf8_out_nonconst_return" do + it 'has a working function #test_utf8_out_nonconst_return' do r, out = Regress.test_utf8_out_nonconst_return assert_equal %w(first second), [r, out] end - it "has a working function #test_utf8_out_out" do + it 'has a working function #test_utf8_out_out' do out0, out1 = Regress.test_utf8_out_nonconst_return assert_equal %w(first second), [out0, out1] end - it "has a working function #test_value_return" do + it 'has a working function #test_value_return' do result = Regress.test_value_return 3423 assert_equal 3423, result.get_int end - it "has a working function #test_versioning" do + it 'has a working function #test_versioning' do skip unless get_introspection_data 'Regress', 'test_versioning' Regress.test_versioning pass end - it "raises an appropriate NoMethodError when a function is not found" do + it 'raises an appropriate NoMethodError when a function is not found' do begin Regress.this_method_does_not_exist rescue => e diff --git a/test/integration/generated_secret_test.rb b/test/integration/generated_secret_test.rb index 5e076c933..ac79a1e39 100644 --- a/test/integration/generated_secret_test.rb +++ b/test/integration/generated_secret_test.rb @@ -1,14 +1,14 @@ require 'gir_ffi_test_helper' -describe "The generated Secret module" do - describe "Secret::Schema" do - it "has a working constructor" do +describe 'The generated Secret module' do + describe 'Secret::Schema' do + it 'has a working constructor' do begin GirFFI.setup :Secret rescue - skip "No GIR data for Secret available" + skip 'No GIR data for Secret available' end - instance = Secret::Schema.new("foo", :none, "bar" => :string) + instance = Secret::Schema.new('foo', :none, 'bar' => :string) instance.must_be_instance_of Secret::Schema end end diff --git a/test/integration/method_lookup_test.rb b/test/integration/method_lookup_test.rb index 0f3569cf5..7bb1b7a2c 100644 --- a/test/integration/method_lookup_test.rb +++ b/test/integration/method_lookup_test.rb @@ -1,14 +1,14 @@ require 'gir_ffi_test_helper' # Tests how methods are looked up and generated on first use. -describe "Looking up methods" do +describe 'Looking up methods' do before do save_module :Regress GirFFI.setup :Regress end - describe "an instance method" do - it "is found from a subclass" do + describe 'an instance method' do + it 'is found from a subclass' do assert_defines_instance_method Regress::TestObj, :forced_method refute_defines_instance_method Regress::TestSubObj, :forced_method @@ -17,8 +17,8 @@ end end - describe "a class method" do - it "is found from a subclass" do + describe 'a class method' do + it 'is found from a subclass' do assert_defines_singleton_method Regress::TestObj, :static_method refute_defines_singleton_method Regress::TestSubObj, :static_method diff --git a/test/minitest/stats_plugin.rb b/test/minitest/stats_plugin.rb index cb5606440..0a55459a8 100644 --- a/test/minitest/stats_plugin.rb +++ b/test/minitest/stats_plugin.rb @@ -15,7 +15,7 @@ def record result def report slowest = @results.sort_by(&:time).reverse.first(10) slowest.each do |result| - puts format("%10.4f %s", result.time, result.location) + puts format('%10.4f %s', result.time, result.location) end end end