diff --git a/Steepfile b/Steepfile index 10c321185..101c766a0 100644 --- a/Steepfile +++ b/Steepfile @@ -5,10 +5,10 @@ target :lib do check "lib" ignore( "lib/rbs/test", - "lib/rbs/test.rb" + # "lib/rbs/test.rb" ) - library "pathname", "json", "logger", "monitor", "tsort", "uri", 'dbm', 'pstore', 'singleton', 'shellwords', 'fileutils', 'find', 'digest', 'abbrev', 'prettyprint', 'yaml' + library "pathname", "json", "logger", "monitor", "tsort", "uri", 'dbm', 'pstore', 'singleton', 'shellwords', 'fileutils', 'find', 'digest', 'abbrev', 'prettyprint', 'yaml', "psych", "securerandom" signature "stdlib/strscan/0/" signature "stdlib/optparse/0/" signature "stdlib/rdoc/0/" diff --git a/lib/rbs/test.rb b/lib/rbs/test.rb index a69423b45..511e28d89 100644 --- a/lib/rbs/test.rb +++ b/lib/rbs/test.rb @@ -3,7 +3,6 @@ require "securerandom" require "rbs/test/guaranteed" require "rbs/test/observer" -require "rbs/test/spy" require "rbs/test/errors" require "rbs/test/type_check" require "rbs/test/tester" @@ -85,11 +84,11 @@ def reset_suffix if ::UnboundMethod.instance_methods.include?(:bind_call) def self.call(receiver, method, *args, &block) - method.bind_call(receiver, *args, &block) + __skip__ = method.bind_call(receiver, *args, &block) end else def self.call(receiver, method, *args, &block) - method.bind(receiver).call(*args, &block) + __skip__ = method.bind(receiver).call(*args, &block) end end end diff --git a/lib/rbs/test/spy.rb b/lib/rbs/test/spy.rb deleted file mode 100644 index 766b02bc9..000000000 --- a/lib/rbs/test/spy.rb +++ /dev/null @@ -1,6 +0,0 @@ -# frozen_string_literal: true - -module RBS - module Test - end -end diff --git a/lib/rbs/unit_test.rb b/lib/rbs/unit_test.rb new file mode 100644 index 000000000..bb6145de0 --- /dev/null +++ b/lib/rbs/unit_test.rb @@ -0,0 +1,4 @@ +# frozen_string_literal: true +require "rbs/test" +require "rbs/unit_test/spy" +require "rbs/unit_test/type_assertion" diff --git a/lib/rbs/unit_test/spy.rb b/lib/rbs/unit_test/spy.rb new file mode 100644 index 000000000..a0240fe68 --- /dev/null +++ b/lib/rbs/unit_test/spy.rb @@ -0,0 +1,136 @@ +# frozen_string_literal: true + +module RBS + module UnitTest + module Spy + def self.wrap(object, method_name) + spy = WrapSpy.new(object: object, method_name: method_name) + + if block_given? + begin + yield spy, spy.wrapped_object + end + else + spy + end + end + + class WrapSpy + attr_accessor :callback + attr_reader :object + attr_reader :method_name + + def initialize(object:, method_name:) + @callback = -> (_) { } + @object = object + @method_name = method_name + end + + def wrapped_object + spy = self #: WrapSpy[untyped] + + Class.new(BasicObject) do + # @type self: Class + + define_method(:method_missing) do |name, *args, &block| + spy.object.__send__(name, *args, &block) + end + + define_method( + spy.method_name, + _ = -> (*args, &block) do + return_value = nil + exception = nil + block_calls = [] #: Array[Test::ArgumentsReturn] + + spy_block = if block + Object.new.instance_eval do |fresh| + proc = -> (*block_args) do + block_exn = nil + block_return = nil + + begin + block_return = if self.equal?(fresh) + # no instance eval + block.call(*block_args) + else + self.instance_exec(*block_args, &block) + end + rescue Exception => exn + block_exn = exn + end + + if block_exn + block_calls << Test::ArgumentsReturn.exception( + arguments: block_args, + exception: block_exn + ) + else + block_calls << Test::ArgumentsReturn.return( + arguments: block_args, + value: block_return + ) + end + + if block_exn + raise block_exn + else + block_return + end + end #: Proc + + proc.ruby2_keywords + end + end + + begin + if spy_block + return_value = spy.object.__send__(spy.method_name, *args) do |*a, **k, &b| + spy_block.call(*a, **k, &b) + end + else + return_value = spy.object.__send__(spy.method_name, *args, &spy_block) + end + rescue ::Exception => exn + exception = exn + end + + return_value + + ensure + call = + case + when exception + Test::ArgumentsReturn.exception( + arguments: args, + exception: exception + ) + when return_value + Test::ArgumentsReturn.return( + arguments: args, + value: return_value + ) + else + # break + Test::ArgumentsReturn.break(arguments: args) + end + trace = RBS::Test::CallTrace.new( + method_name: spy.method_name, + method_call: call, + block_calls: block_calls, + block_given: block != nil + ) + + spy.callback.call(trace) + + if exception + spy.object.__send__(:raise, exception) + end + end.ruby2_keywords + ) + end.new() + end + end + end + end +end diff --git a/lib/rbs/unit_test/type_assertion.rb b/lib/rbs/unit_test/type_assertion.rb new file mode 100644 index 000000000..a998cda5a --- /dev/null +++ b/lib/rbs/unit_test/type_assertion.rb @@ -0,0 +1,337 @@ +# frozen_string_literal: true +module RBS + module UnitTest + module TypeAssertions + module ClassMethods + attr_reader :target + + def library(*libs) + if @libs + raise "Multiple #library calls are not allowed" + end + + @libs = libs + @env = nil + @target = nil + end + + @@env_cache = {} + + def env + @env = @@env_cache[@libs] ||= + begin + loader = RBS::EnvironmentLoader.new + (@libs || []).each do |lib| + loader.add(library: lib, version: nil) + end + + RBS::Environment.from_loader(loader).resolve_type_names + end + end + + def builder + @builder ||= RBS::DefinitionBuilder.new(env: env) + end + + def testing(type_or_string) + type = case type_or_string + when String + RBS::Parser.parse_type(type_or_string, variables: []) || raise + else + type_or_string + end + + definition = case type + when RBS::Types::ClassInstance + builder.build_instance(type.name) + when RBS::Types::ClassSingleton + builder.build_singleton(type.name) + else + raise "Test target should be class instance or class singleton: #{type}" + end + + @target = [type, definition] #: [target_type, Definition] + end + end + + def self.included(base) + base.extend ClassMethods + end + + def env + (_ = self.class).env + end + + def builder + (_ = self.class).builder + end + + def targets + @targets ||= [] + end + + def target + targets.last || (_ = self.class).target + end + + def testing(type_or_string) + type = case type_or_string + when String + RBS::Parser.parse_type(type_or_string, variables: []) + else + type_or_string + end + + definition = case type + when RBS::Types::ClassInstance + builder.build_instance(type.name) + when RBS::Types::ClassSingleton + builder.build_singleton(type.name) + else + raise "Test target should be class instance or class singleton: #{type}" + end + + targets.push( + [ + type, #: target_type + definition + ] + ) + + if block_given? + begin + yield + ensure + targets.pop + end + else + [type, definition] + end + end + + def instance_class + type, _ = target + + case type + when RBS::Types::ClassSingleton, RBS::Types::ClassInstance + Object.const_get(type.name.to_s) + end + end + + def class_class + type, _ = target + + case type + when RBS::Types::ClassSingleton, RBS::Types::ClassInstance + Object.const_get(type.name.to_s).singleton_class + end + end + + def send_setup(method_type, receiver, method, args, proc) + mt = + case method_type + when String + RBS::Parser.parse_method_type(method_type, variables: []) || raise + when RBS::MethodType + method_type + end + + validate_simple_method_type(mt) + + trace = [] #: Array[Test::CallTrace] + spy = Spy.wrap(receiver, method) + spy.callback = -> (result) { trace << result } + + result = nil #: untyped + exception = nil #: Exception? + non_jump_exit = true + + begin + result = catch do |tag| + @break_tag = tag + spy.wrapped_object.__send__(method, *args, &proc) + ensure + @break_tag = nil + end + + non_jump_exit = false + rescue Exception => exn + exception = exn + ensure + if non_jump_exit && !exception + raise "`break` nor `return` from blocks given to `assert_send_type` are prohibited. Use `#break_from_block` instead." + end + end + + last_trace = trace.last or raise + + yield(mt, last_trace, result, exception) + end + + ruby2_keywords def assert_send_type(method_type, receiver, method, *args, &block) + send_setup(method_type, receiver, method, args, block) do |method_type, trace, result, exception| + typecheck = RBS::Test::TypeCheck.new( + self_class: receiver.class, + builder: builder, + sample_size: 100, + unchecked_classes: [], + instance_class: instance_class, + class_class: class_class + ) + errors = typecheck.method_call(method, method_type, trace, errors: []) + + assert_empty errors.map {|x| RBS::Test::Errors.to_string(x) }, "Call trace does not match with given method type: #{trace.inspect}" + + method_types = method_types(method) + all_errors = method_types.map {|t| typecheck.method_call(method, t, trace, errors: []) } + assert all_errors.any? {|es| es.empty? }, "Call trace does not match one of method definitions:\n #{trace.inspect}\n #{method_types.join(" | ")}" + + raise exception if exception + + result + end + end + + ruby2_keywords def refute_send_type(method_type, receiver, method, *args, &block) + send_setup(method_type, receiver, method, args, block) do |method_type, trace, result, exception| + method_type = method_type.update( + block: + if method_type.block + RBS::Types::Block.new( + type: method_type.block.type.with_return_type(RBS::Types::Bases::Any.new(location: nil)), + required: method_type.block.required, + self_type: nil + ) + end, + type: method_type.type.with_return_type(RBS::Types::Bases::Any.new(location: nil)) + ) + + typecheck = RBS::Test::TypeCheck.new( + self_class: receiver.class, + instance_class: instance_class, + class_class: class_class, + builder: builder, + sample_size: 100, + unchecked_classes: [] + ) + errors = typecheck.method_call(method, method_type, trace, errors: []) + + assert_operator exception, :is_a?, ::Exception + assert_empty errors.map {|x| RBS::Test::Errors.to_string(x) } + + method_types = method_types(method) + all_errors = method_types.map {|t| typecheck.method_call(method, t, trace, errors: []) } + assert all_errors.all? {|es| es.size > 0 }, "Call trace unexpectedly matches one of method definitions:\n #{trace.inspect}\n #{method_types.join(" | ")}" + + result + end + end + + def method_types(method) + type, definition = target + + case type + when Types::ClassInstance + subst = RBS::Substitution.build(definition.type_params, type.args) + definition.methods[method].method_types.map do |method_type| + method_type.sub(subst) + end + when Types::ClassSingleton + definition.methods[method].method_types + else + raise + end + end + + def allows_error(*errors) + yield + rescue *errors => exn + notify "Error allowed: #{exn.inspect}" + end + + def assert_const_type(type, constant_name) + constant = Object.const_get(constant_name) + + typecheck = RBS::Test::TypeCheck.new( + self_class: constant.class, + instance_class: instance_class, + class_class: class_class, + builder: builder, + sample_size: 100, + unchecked_classes: [] + ) + + value_type = + case type + when String + RBS::Parser.parse_type(type, variables: []) || raise + else + type + end + + assert typecheck.value(constant, value_type), "`#{constant_name}` (#{constant.inspect}) must be compatible with given type `#{value_type}`" + + type_name = TypeName(constant_name).absolute! + definition = env.constant_entry(type_name) + assert definition, "Cannot find RBS type definition of `#{constant_name}`" + + case definition + when RBS::Environment::ClassEntry, RBS::Environment::ModuleEntry + definition_type = RBS::Types::ClassSingleton.new(name: type_name, location: nil) + when RBS::Environment::ClassAliasEntry, RBS::Environment::ModuleAliasEntry + type_name = env.normalize_type_name!(type_name) + definition_type = RBS::Types::ClassSingleton.new(name: type_name, location: nil) + when RBS::Environment::ConstantEntry + definition_type = definition.decl.type + end + + assert definition_type, "Cannot find RBS entry for `#{constant_name}`" + definition_type or raise + assert typecheck.value(constant, definition_type), "`#{constant_name}` (#{constant.inspect}) must be compatible with RBS type definition `#{definition_type}`" + end + + def assert_type(type, value) + typecheck = RBS::Test::TypeCheck.new( + self_class: value.class, + instance_class: _ = "No `instance` class allowed", + class_class: _ = "No `class` class allowed", + builder: builder, + sample_size: 100, + unchecked_classes: [] + ) + + type = + case type + when String + RBS::Parser.parse_type(type, variables: []) or raise + else + type + end + + assert typecheck.value(value, type), "`#{value.inspect}` must be compatible with given type `#{type}`" + end + + def allow_non_simple_method_type() + begin + @allows_non_simple_method_type = true + yield + rescue + @allows_non_simple_method_type = false + end + end + + def validate_simple_method_type(type) + return if @allows_non_simple_method_type + + refute_predicate type, :has_self_type?, "`self` types is prohibited in method type: `#{type}`" + refute_predicate type, :has_classish_type?, "`instance` and `class` types is prohibited in method type: `#{type}`" + refute_predicate type, :with_nonreturn_void?, "`void` is only allowed at return type or generics parameters: `#{type}`" + end + + def break_from_block(value = nil) + raise "Cannot break without `@break_tag`" unless @break_tag + throw @break_tag, value + end + end + end +end diff --git a/sig/test.rbs b/sig/test.rbs new file mode 100644 index 000000000..f9a6fbfeb --- /dev/null +++ b/sig/test.rbs @@ -0,0 +1,79 @@ +module RBS + module Test + # Object#class + CLASS: UnboundMethod + + # Module#define_method + DEFINE_METHOD: UnboundMethod + + # Kernel#inspect + INSPECT: UnboundMethod + + # BasicObject#instance_eval + INSTANCE_EVAL: UnboundMethod + + # BasicObject#instance_exec + INSTANCE_EXEC: UnboundMethod + + # Kernel#is_a? + IS_AP: UnboundMethod + + # Kernel#method + METHOD: UnboundMethod + + # Kernel#methods + METHODS: UnboundMethod + + # Kernel#pp + PP: UnboundMethod + + # Kernel#singleton_class + SINGLETON_CLASS: UnboundMethod + + class ArgumentsReturn + type exit_type = :return | :exception | :break + + attr_reader arguments: Array[untyped] + + attr_reader exit_value: untyped + + attr_reader exit_type: exit_type + + def initialize: (arguments: Array[untyped], exit_value: untyped, exit_type: exit_type) -> void + + def self.return: (arguments: Array[untyped], value: untyped) -> ArgumentsReturn + + def self.exception: (arguments: Array[untyped], exception: untyped) -> ArgumentsReturn + + def self.break: (arguments: Array[untyped]) -> ArgumentsReturn + + def return_value: () -> untyped + + def exception: () -> untyped + + def return?: () -> bool + + def exception?: () -> bool + + def break?: () -> bool + end + + class CallTrace + attr_reader method_name: Symbol + + attr_reader method_call: ArgumentsReturn + + attr_reader block_calls: Array[ArgumentsReturn] + + attr_reader block_given: bool + + def initialize: (method_name: Symbol, method_call: ArgumentsReturn, block_calls: Array[ArgumentsReturn], block_given: bool) -> void + end + + attr_accessor self.suffix: String + + def self.reset_suffix: () -> String + + def self.call: (untyped receiver, UnboundMethod, *untyped) ?{ () -> void } -> void + end +end diff --git a/sig/test/errors.rbs b/sig/test/errors.rbs new file mode 100644 index 000000000..1490d0306 --- /dev/null +++ b/sig/test/errors.rbs @@ -0,0 +1,52 @@ +module RBS + module Test + module Errors + type t = ArgumentTypeError | BlockArgumentError | ArgumentError | BlockArgumentError | ReturnTypeError | BlockReturnTypeError + | UnexpectedBlockError | MissingBlockError | UnresolvedOverloadingError + + # Type of a argument value given to a method call is not compatible with the type from method type + class ArgumentTypeError + end + + # Type of a argument value given to a block yield is not compatible with the type from method type + class BlockArgumentTypeError + end + + # Incompatible number of args/keyword args is given to a method call + class ArgumentError + end + + # Incompatible number of args is given to a block yield + class BlockArgumentError + end + + # Type of return value from a method call is incompatible + class ReturnTypeError + end + + # Type of return value from a block yield is incompatible + class BlockReturnTypeError + end + + # Unexpected block is given + class UnexpectedBlockError + end + + # Required block is missing + class MissingBlockError + end + + # Any other error + class UnresolvedOverloadingError + end + + def self.format_param: (Types::Function::Param) -> String + + RESPOND_TO: UnboundMethod + + def self.inspect_: (untyped) -> String + + def self.to_string: (t) -> String + end + end +end diff --git a/sig/test/guranteed.rbs b/sig/test/guranteed.rbs new file mode 100644 index 000000000..70cca999f --- /dev/null +++ b/sig/test/guranteed.rbs @@ -0,0 +1,9 @@ +module RBS + module Test + module Guaranteed + module Inspect + def self?.guaranteed_inspect: (untyped) -> String + end + end + end +end diff --git a/sig/test/type_check.rbs b/sig/test/type_check.rbs new file mode 100644 index 000000000..1a503dd43 --- /dev/null +++ b/sig/test/type_check.rbs @@ -0,0 +1,19 @@ +module RBS + module Test + class TypeCheck + def initialize: (self_class: Module, builder: DefinitionBuilder, sample_size: Integer, unchecked_classes: Array[Module], instance_class: Module, class_class: Module) -> void + + # Confirm if given `CallTrace` is compatible with `MethodType` + # + # Returns an array with detected errors. + # + def method_call: (Symbol, MethodType, CallTrace, errors: Array[Errors::t]) -> Array[Errors::t] + + # Test if given `value` is compatible to type + # + # Returns `true` if the value has the type. + # + def value: (untyped value, Types::t) -> bool + end + end +end diff --git a/sig/unit_test/spy.rbs b/sig/unit_test/spy.rbs new file mode 100644 index 000000000..a7ae59ed6 --- /dev/null +++ b/sig/unit_test/spy.rbs @@ -0,0 +1,28 @@ +module RBS + module UnitTest + module Spy + def self.wrap: [T] (untyped object, Symbol method_name) -> WrapSpy[T] + | [T, S] (untyped object, Symbol method_name) { (WrapSpy[T], T) -> S } -> S + + class WrapSpy[T] + attr_accessor callback: ^(Test::CallTrace) -> void + + attr_reader object: T + + attr_reader method_name: Symbol + + def initialize: (object: T, method_name: Symbol) -> void + + def wrapped_object: () -> untyped + end + end + end +end + +class Proc + def ruby2_keywords: () -> self +end + +class Module + def ruby2_keywords: (*Symbol) -> void +end diff --git a/sig/unit_test/type_assertions.rbs b/sig/unit_test/type_assertions.rbs new file mode 100644 index 000000000..074e6bde2 --- /dev/null +++ b/sig/unit_test/type_assertions.rbs @@ -0,0 +1,192 @@ +module RBS + module UnitTest + # TypeAssertions provides assertions to test RBS type definitions in unit test + # + # ```ruby + # class FooInstanceTest < Test::Unit::TestCase + # include RBS::UnitTest::TypeAssertions + # + # testing "::Foo" + # + # def test_foo + # assert_send_type( + # "(String) -> Integer", + # Foo.new, :foo, "hello" + # ) + # end + # end + # ``` + # + # The module provides four assertions: + # + # * `assert_send_type` to confirm if a method call has the expected method type + # * `refute_send_type` to confirm if a method call doesn't have the method type + # * `assert_const_type` to confirm if a constant has an expected type + # * `assert_type` to confirm a Ruby value has a RBS type + # + # See `.testing` and `.library` methods to set up RBS type testing. + # + module TypeAssertions : _BaseAssertions + type target_type = Types::ClassInstance | Types::ClassSingleton + + interface _BaseAssertions + def assert: (untyped, ?String) -> void + + def refute: (untyped, ?String) -> void + + def assert_empty: (untyped, ?String) -> void + + def assert_operator: (untyped, Symbol, *untyped) -> void + + def notify: (untyped) -> void + + def assert_predicate: (untyped, Symbol, ?String) -> void + + def refute_predicate: (untyped, Symbol, ?String) -> void + end + + module ClassMethods + attr_reader target: [target_type, Definition]? + + @libs: Array[String] + + @env: Environment? + + @@env_cache: Hash[Array[String], Environment] + + # `testing` is to tell the framework which class is being tested + # + # ```ruby + # testing "::String" + # testing "::Array[Integer]" + # + # testing "singleton(::Integer)" + # ``` + # + def testing: (String | target_type) -> void + + # `library` is to load RBS type definition of dependencies + # + # The test or implementation already `require` dependencies, but the RBS type definition of the dependencies are also required for testing. + # + # ```ruby + # library "pathname", "securerandom" + # ``` + # + def library: (*String) -> void + + def env: () -> Environment + + @builder: DefinitionBuilder + + def builder: () -> DefinitionBuilder + end + + def self.included: (Module) -> void + + def env: () -> Environment + + def builder: () -> DefinitionBuilder + + @targets: Array[[target_type, Definition]] + + def targets: () -> Array[[target_type, Definition]] + + def target: () -> [target_type, Definition] + + def testing: (String | target_type) ?{ () -> void } -> void + + # The class object that is associated to the `instance` type of the testing type + # + def instance_class: () -> Class + + # The singleton class object that is associated to the `class` type of the testing type + # + def class_class: () -> Class + + def method_types: (Symbol) -> Array[MethodType] + + def allows_error: (*Exception) { () -> void } -> void + + # Calls a method `method_name` and validates if it's compatible with RBS type definition + # + # 1. It calls `method_name` with `receiver` passing `args` and given block, + # 2. Validates if it's compatible with given `method_type`, and + # 3. Validates if it's also compatible with one of the overloads defined in RBS type definition + # + # ```ruby + # assert_send_type( + # "(::Integer) -> ::Integer", + # [], :sum, 8 + # ) + # ``` + # + # To test methods that takes a block, pass a block to `assert_send_type`. + # We recommend using `&proc { ... }` syntax for textual representation and prevent from using `break` from the block. + # + # ```ruby + # assert_send_type( + # "() { () -> void } -> void", + # self, :loop, &proc { break_from_block } + # ) + # ``` + # + # Exiting from the block using `break` and `return` skips assertions. + # Use `break_from_block` instead. + # + # `method_type` must be _simple_. + # It raises an exception if it's not _simple_. + # When you really need _non-simple_ `method_type`, wrap the calls inside `allow_non_simple_method_type`. + # See `docs/stdlib.md` for the details. + # + def assert_send_type: (String | MethodType method_type, untyped receiver, Symbol method_name, *untyped args) ?{ () -> untyped } -> void + + # Calls a method `method_name` and validates if it's **not** compatible with RBS type definition + # + # 1. It calls `method_name` with `receiver` passing `args` and given block, + # 2. Validates if it's compatible with given `method_type`, and + # 3. Validates if it's not compatible with **none** of the overloads defined in RBS type definition + # + # See `assert_send_type` for the details. + # + def refute_send_type: (String | MethodType method_type, untyped receiver, Symbol method_name, *untyped args) ?{ () -> untyped } -> void + + # Asserts if the constant `constant_name` has `constant_type`, and the RBS definition has compatible type + # + # ```ruby + # assert_const_type("Array[String]", "::Foo::Bar") + # ``` + # + # The assertion above succeeds if `::Foo::Bar` is `["foo"]` and RBS contains `::Foo::Bar: [untyped]`. + # It fails if `::Foo::Bar` is `[2]`, or the RBS definition is `::Foo::Bar: String`. + # + def assert_const_type: (String | Types::t constant_type, String constant_name) -> void + + # Asserts if given `value` has a type of `value_type` + # + def assert_type: (String | Types::t value_type, untyped value) -> void + + # Allow non _simple-type_ method types given to `assert_send_type` and `refute_send_type` + # + # ```ruby + # allow_non_simple_method_type do + # assert_send_type("() -> self", ...) + # end + # ``` + # + def allow_non_simple_method_type: () { () -> void } -> void + + @allows_non_simple_method_type: boolish + + def validate_simple_method_type: (MethodType) -> void + + # Break from `assert_send_type` or `refute_send_type` + # + def break_from_block: (?untyped value) -> void + + @break_tag: untyped + + def send_setup: [T] (String | RBS::MethodType method_type, untyped receiver, Symbol method_name, Array[untyped] args, Proc?) { (RBS::MethodType, Test::CallTrace, untyped, Exception?) -> T } -> T + end + end +end diff --git a/stdlib/openssl/0/openssl.rbs b/stdlib/openssl/0/openssl.rbs index f91075565..2d805591c 100644 --- a/stdlib/openssl/0/openssl.rbs +++ b/stdlib/openssl/0/openssl.rbs @@ -812,7 +812,7 @@ module OpenSSL # puts "Header length: #{header_len} Tag: #{tag} Tag class: #{tag_class} Constructed: #{constructed}" # end # - def self.traverse: (String | _ToDer der) { (::Integer, ::Integer, ::Integer, ::Integer, bool, tag_class, ::Integer) -> void } -> void + def self.traverse: (String | _ToDer der) { ([::Integer, ::Integer, ::Integer, ::Integer, bool, tag_class, ::Integer]) -> void } -> void BIT_STRING: Integer diff --git a/test/rbs/cli_test.rb b/test/rbs/cli_test.rb index 292cc42ab..b59291237 100644 --- a/test/rbs/cli_test.rb +++ b/test/rbs/cli_test.rb @@ -653,10 +653,10 @@ def test_version def test_paths with_cli do |cli| - cli.run(%w(-r pathname -I sig/test paths)) + cli.run(%w(-r pathname -I no-such-dir paths)) assert_match %r{/rbs/core \(dir, core\)$}, stdout.string assert_match %r{/rbs/stdlib/pathname/0 \(dir, library, name=pathname\)$}, stdout.string - assert_match %r{^sig/test \(absent\)$}, stdout.string + assert_match %r{^no-such-dir \(absent\)$}, stdout.string end end diff --git a/test/stdlib/ARGF_test.rb b/test/stdlib/ARGF_test.rb index fe7c454cd..bc9f2a92a 100644 --- a/test/stdlib/ARGF_test.rb +++ b/test/stdlib/ARGF_test.rb @@ -9,7 +9,7 @@ module Unnamed end class ARGFTest < Test::Unit::TestCase - include TypeAssertions + include TestHelper testing "::RBS::Unnamed::ARGFClass" def argf_for_write @@ -96,7 +96,7 @@ def test_argv end def test_binmode - assert_send_type "() -> self", + assert_send_type "() -> RBS::Unnamed::ARGFClass", ARGF.class.new(__FILE__), :binmode end @@ -106,7 +106,7 @@ def test_binmode? end def test_close - assert_send_type "() -> self", + assert_send_type "() -> RBS::Unnamed::ARGFClass", ARGF.class.new(__FILE__), :close end @@ -116,55 +116,55 @@ def test_closed? end def test_each - assert_send_type "() { (::String line) -> untyped } -> self", + assert_send_type "() { (::String line) -> untyped } -> RBS::Unnamed::ARGFClass", ARGF.class.new(__FILE__), :each do |line| line end - assert_send_type "(::String sep) { (::String line) -> untyped } -> self", + assert_send_type "(::String sep) { (::String line) -> untyped } -> RBS::Unnamed::ARGFClass", ARGF.class.new(__FILE__), :each, "\n" do |line| line end - assert_send_type "(::String sep, ::Integer limit) { (::String line) -> untyped } -> self", + assert_send_type "(::String sep, ::Integer limit) { (::String line) -> untyped } -> RBS::Unnamed::ARGFClass", ARGF.class.new(__FILE__), :each, "\n", 1 do |line| line end - assert_send_type "() -> ::Enumerator[::String, self]", + assert_send_type "() -> ::Enumerator[::String, RBS::Unnamed::ARGFClass]", ARGF.class.new(__FILE__), :each - assert_send_type "(::String sep) -> ::Enumerator[::String, self]", + assert_send_type "(::String sep) -> ::Enumerator[::String, RBS::Unnamed::ARGFClass]", ARGF.class.new(__FILE__), :each, "\n" - assert_send_type "(::String sep, ::Integer limit) -> ::Enumerator[::String, self]", + assert_send_type "(::String sep, ::Integer limit) -> ::Enumerator[::String, RBS::Unnamed::ARGFClass]", ARGF.class.new(__FILE__), :each, "\n", 1 end def test_each_byte - assert_send_type "() { (::Integer byte) -> untyped } -> self", + assert_send_type "() { (::Integer byte) -> untyped } -> RBS::Unnamed::ARGFClass", ARGF.class.new(__FILE__), :each_byte do |byte| byte end - assert_send_type "() -> ::Enumerator[::Integer, self]", + assert_send_type "() -> ::Enumerator[::Integer, RBS::Unnamed::ARGFClass]", ARGF.class.new(__FILE__), :each_byte end def test_each_char - assert_send_type "() { (::String char) -> untyped } -> self", + assert_send_type "() { (::String char) -> untyped } -> RBS::Unnamed::ARGFClass", ARGF.class.new(__FILE__), :each_char do |char| char end - assert_send_type "() -> ::Enumerator[::String, self]", + assert_send_type "() -> ::Enumerator[::String, RBS::Unnamed::ARGFClass]", ARGF.class.new(__FILE__), :each_char end def test_each_codepoint - assert_send_type "() { (::Integer codepoint) -> untyped } -> self", + assert_send_type "() { (::Integer codepoint) -> untyped } -> RBS::Unnamed::ARGFClass", ARGF.class.new(__FILE__), :each_codepoint do |codepoint| end - assert_send_type "() -> ::Enumerator[::Integer, self]", + assert_send_type "() -> ::Enumerator[::Integer, RBS::Unnamed::ARGFClass]", ARGF.class.new(__FILE__), :each_codepoint end def test_each_line - assert_send_type "() { (::String line) -> untyped } -> self", + assert_send_type "() { (::String line) -> untyped } -> RBS::Unnamed::ARGFClass", ARGF.class.new(__FILE__), :each_line do |line| line end - assert_send_type "(::String sep) { (::String line) -> untyped } -> self", + assert_send_type "(::String sep) { (::String line) -> untyped } -> RBS::Unnamed::ARGFClass", ARGF.class.new(__FILE__), :each_line, "\n" do |line| line end - assert_send_type "(::String sep, ::Integer limit) { (::String line) -> untyped } -> self", + assert_send_type "(::String sep, ::Integer limit) { (::String line) -> untyped } -> RBS::Unnamed::ARGFClass", ARGF.class.new(__FILE__), :each_line, "\n", 1 do |line| line end - assert_send_type "() -> ::Enumerator[::String, self]", + assert_send_type "() -> ::Enumerator[::String, RBS::Unnamed::ARGFClass]", ARGF.class.new(__FILE__), :each_line - assert_send_type "(::String sep) -> ::Enumerator[::String, self]", + assert_send_type "(::String sep) -> ::Enumerator[::String, RBS::Unnamed::ARGFClass]", ARGF.class.new(__FILE__), :each_line, "\n" - assert_send_type "(::String sep, ::Integer limit) -> ::Enumerator[::String, self]", + assert_send_type "(::String sep, ::Integer limit) -> ::Enumerator[::String, RBS::Unnamed::ARGFClass]", ARGF.class.new(__FILE__), :each_line, "\n", 1 end @@ -223,7 +223,7 @@ def test_inplace_mode end def test_inplace_mode=() - assert_send_type "(::String) -> self", + assert_send_type "(::String) -> RBS::Unnamed::ARGFClass", ARGF.class.new(__FILE__), :inplace_mode=, ".bak" end @@ -305,18 +305,18 @@ def test_seek end def test_set_encoding - assert_send_type "(::String) -> self", + assert_send_type "(::String) -> RBS::Unnamed::ARGFClass", ARGF.class.new(__FILE__), :set_encoding, "utf-8" - assert_send_type "(::Encoding) -> self", + assert_send_type "(::Encoding) -> RBS::Unnamed::ARGFClass", ARGF.class.new(__FILE__), :set_encoding, Encoding::UTF_8 - assert_send_type "(::String, ::String) -> self", + assert_send_type "(::String, ::String) -> RBS::Unnamed::ARGFClass", ARGF.class.new(__FILE__), :set_encoding, "utf-8", "utf-8" - assert_send_type "(::Encoding, ::Encoding) -> self", + assert_send_type "(::Encoding, ::Encoding) -> RBS::Unnamed::ARGFClass", ARGF.class.new(__FILE__), :set_encoding, Encoding::UTF_8, Encoding::UTF_8 end def test_skip - assert_send_type "() -> self", + assert_send_type "() -> RBS::Unnamed::ARGFClass", ARGF.class.new(__FILE__), :skip end diff --git a/test/stdlib/Array_test.rb b/test/stdlib/Array_test.rb index 590fc31f8..0dbc7abc2 100644 --- a/test/stdlib/Array_test.rb +++ b/test/stdlib/Array_test.rb @@ -1,7 +1,7 @@ require_relative "test_helper" class ArraySingletonTest < Test::Unit::TestCase - include TypeAssertions + include TestHelper testing "singleton(::Array)" @@ -36,7 +36,7 @@ def test_try_convert end class ArrayInstanceTest < Test::Unit::TestCase - include TypeAssertions + include TestHelper testing "::Array[::Integer]" @@ -226,7 +226,7 @@ def test_compact def test_concat assert_send_type "(Array[Integer], Array[Integer]) -> Array[Integer]", [1,2,3], :concat, [4,5,6], [7,8,9] - assert_send_type "(Array[Integer], Array[Integer]) -> self", + assert_send_type "(Array[Integer], Array[Integer]) -> Array[Integer]", Class.new(Array).new, :concat, [4,5,6], [7,8,9] end @@ -240,8 +240,11 @@ def test_count end def test_cycle - assert_send_type "() { (Integer) -> void } -> nil", - [1,2,3], :cycle do break end + assert_send_type( + "() { (Integer) -> void } -> nil", + [1,2,3], :cycle, &proc { break_from_block } + ) + assert_send_type "(Integer) { (Integer) -> void } -> nil", [1,2,3], :cycle, 3 do end assert_send_type "(ToInt) { (Integer) -> void } -> nil", diff --git a/test/stdlib/BasicObject_test.rb b/test/stdlib/BasicObject_test.rb index 283b39ecb..fa97ec41a 100644 --- a/test/stdlib/BasicObject_test.rb +++ b/test/stdlib/BasicObject_test.rb @@ -2,7 +2,7 @@ class BasicObjectSingletonTest < Test::Unit::TestCase - include TypeAssertions + include TestHelper testing 'BasicObject' @@ -62,12 +62,12 @@ def test_instance_eval end end - assert_send_type '() { (self) [self: self] -> Integer } -> Integer', + assert_send_type '() { (BasicObject) [self: BasicObject] -> Integer } -> Integer', BOBJ, :instance_eval do _1.__id__ end end def test_instance_exec - assert_send_type '(*String) { (*String) [self: self] -> Integer } -> Integer', + assert_send_type '(*String) { (*String) [self: BasicObject] -> Integer } -> Integer', BOBJ, :instance_exec, '1', '2' do |*x| x.join.to_i end end end diff --git a/test/stdlib/BigDecimal_test.rb b/test/stdlib/BigDecimal_test.rb index 60c9d62c5..caa0a3bbc 100644 --- a/test/stdlib/BigDecimal_test.rb +++ b/test/stdlib/BigDecimal_test.rb @@ -3,7 +3,7 @@ require "bigdecimal/util" class BigDecimalSingletonTest < Test::Unit::TestCase - include TypeAssertions + include TestHelper library "bigdecimal" testing "singleton(::BigDecimal)" @@ -76,7 +76,7 @@ def test_kernel end class BigDecimalTest < Test::Unit::TestCase - include TypeAssertions + include TestHelper library "bigdecimal" testing "::BigDecimal" @@ -96,12 +96,12 @@ def test_triple_equal end def test_clone - assert_send_type "() -> self", + assert_send_type "() -> BigDecimal", BigDecimal("1.23"), :clone end def test_dup - assert_send_type "() -> self", + assert_send_type "() -> BigDecimal", BigDecimal("1.23"), :dup end @@ -216,7 +216,7 @@ def test_modulo end def test_nonzero? - assert_send_type "() -> self?", + assert_send_type "() -> BigDecimal", BigDecimal("1.23"), :nonzero? end @@ -365,7 +365,7 @@ def test_to_r end class IntegerToBigDecimalTest < Test::Unit::TestCase - include TypeAssertions + include TestHelper library "bigdecimal" testing "::Integer" @@ -396,7 +396,7 @@ def test_multiply_with_integer end class FloatToBigDecimalTest < Test::Unit::TestCase - include TypeAssertions + include TestHelper library "bigdecimal" testing "::Float" @@ -427,7 +427,7 @@ def test_multiply_with_float end class StringToBigDecimalTest < Test::Unit::TestCase - include TypeAssertions + include TestHelper library "bigdecimal" testing "::String" @@ -438,7 +438,7 @@ def test_to_d_with_string end class RationalToBigDecimalTest < Test::Unit::TestCase - include TypeAssertions + include TestHelper library "bigdecimal" testing "::Rational" @@ -469,7 +469,7 @@ def test_multiply_with_rational end class ComplexToBigDecimalTest < Test::Unit::TestCase - include TypeAssertions + include TestHelper library "bigdecimal" testing "::Complex" @@ -500,7 +500,7 @@ def test_multiply_with_complex end class NilToBigDecimalTest < Test::Unit::TestCase - include TypeAssertions + include TestHelper library "bigdecimal" testing "::NilClass" diff --git a/test/stdlib/BigMath_test.rb b/test/stdlib/BigMath_test.rb index fe5e67735..9ad3493f8 100644 --- a/test/stdlib/BigMath_test.rb +++ b/test/stdlib/BigMath_test.rb @@ -3,7 +3,7 @@ require "bigdecimal/math" class BigMathSingletonTest < Test::Unit::TestCase - include TypeAssertions + include TestHelper library "bigdecimal", "bigdecimal-math" testing "singleton(::BigMath)" @@ -49,7 +49,7 @@ def test_sqrt end class BigMathTest < Test::Unit::TestCase - include TypeAssertions + include TestHelper library "bigdecimal", "bigdecimal-math" testing "::BigMath" diff --git a/test/stdlib/Binding_test.rb b/test/stdlib/Binding_test.rb index c8f1255a1..5075f1a1a 100644 --- a/test/stdlib/Binding_test.rb +++ b/test/stdlib/Binding_test.rb @@ -1,7 +1,7 @@ require_relative "test_helper" class BindingInstanceTest < Test::Unit::TestCase - include TypeAssertions + include TestHelper testing 'Binding' diff --git a/test/stdlib/CGI_test.rb b/test/stdlib/CGI_test.rb index dc3ad4d3b..d35bb97d2 100644 --- a/test/stdlib/CGI_test.rb +++ b/test/stdlib/CGI_test.rb @@ -2,7 +2,7 @@ require "cgi" class CGISingletonTest < Test::Unit::TestCase - include TypeAssertions + include TestHelper library "cgi" testing "singleton(::CGI)" @@ -60,7 +60,7 @@ def test_unescapeURIComponent end class CGITest < Test::Unit::TestCase - include TypeAssertions + include TestHelper library "cgi" testing "::CGI" diff --git a/test/stdlib/Comparable_test.rb b/test/stdlib/Comparable_test.rb index b3dc796d2..6284cc9ff 100644 --- a/test/stdlib/Comparable_test.rb +++ b/test/stdlib/Comparable_test.rb @@ -1,7 +1,7 @@ require_relative "test_helper" class ComparableTest < Test::Unit::TestCase - include TypeAssertions + include TestHelper class Test include Comparable diff --git a/test/stdlib/DBM_test.rb b/test/stdlib/DBM_test.rb index 99e868a39..392c1cd40 100644 --- a/test/stdlib/DBM_test.rb +++ b/test/stdlib/DBM_test.rb @@ -2,7 +2,7 @@ require "dbm" class DBMSingletonTest < Test::Unit::TestCase - include TypeAssertions + include TestHelper library "dbm" testing "singleton(::DBM)" @@ -19,7 +19,7 @@ def test_open end class DBMTest < Test::Unit::TestCase - include TypeAssertions + include TestHelper library "dbm" testing "::DBM" @@ -38,7 +38,7 @@ def teardown end def test_clear - assert_send_type "() -> self", @dbm, :clear + assert_send_type "() -> DBM", @dbm, :clear end def test_closed? diff --git a/test/stdlib/Data_test.rb b/test/stdlib/Data_test.rb index 579582572..e25241f05 100644 --- a/test/stdlib/Data_test.rb +++ b/test/stdlib/Data_test.rb @@ -1,7 +1,7 @@ require_relative "test_helper" class DataSingletonTest < Test::Unit::TestCase - include TypeAssertions + include TestHelper testing "singleton(::Data)" def test_define @@ -18,7 +18,7 @@ def test_define end class DataInstanceTest < Test::Unit::TestCase - include TypeAssertions + include TestHelper testing "::Data" D = Data.define(:email, :name) diff --git a/test/stdlib/DateTime_test.rb b/test/stdlib/DateTime_test.rb index 129800441..0e57eaaf5 100644 --- a/test/stdlib/DateTime_test.rb +++ b/test/stdlib/DateTime_test.rb @@ -2,7 +2,7 @@ require "date" class DateTimeSingletonTest < Test::Unit::TestCase - include TypeAssertions + include TestHelper library "date" testing "singleton(::DateTime)" @@ -191,7 +191,7 @@ def test_now end class DateTimeTest < Test::Unit::TestCase - include TypeAssertions + include TestHelper library "date" testing "::DateTime" diff --git a/test/stdlib/Date_test.rb b/test/stdlib/Date_test.rb index 934b41a67..c61eb6bbb 100644 --- a/test/stdlib/Date_test.rb +++ b/test/stdlib/Date_test.rb @@ -2,7 +2,7 @@ require "date" class DateSingletonTest < Test::Unit::TestCase - include TypeAssertions + include TestHelper library "date" testing "singleton(::Date)" @@ -239,7 +239,7 @@ def test_xmlschema end class DateTest < Test::Unit::TestCase - include TypeAssertions + include TestHelper library "date" testing "::Date" diff --git a/test/stdlib/Dir_test.rb b/test/stdlib/Dir_test.rb index 6c956ac8c..bac7487cb 100644 --- a/test/stdlib/Dir_test.rb +++ b/test/stdlib/Dir_test.rb @@ -1,7 +1,7 @@ require_relative "test_helper" class DirSingletonTest < Test::Unit::TestCase - include TypeAssertions + include TestHelper testing "singleton(::Dir)" @@ -163,7 +163,7 @@ def test_pwd end class DirInstanceTest < Test::Unit::TestCase - include TypeAssertions + include TestHelper testing "::Dir" diff --git a/test/stdlib/ENV_test.rb b/test/stdlib/ENV_test.rb index 5f5a32f55..ff83a36f7 100644 --- a/test/stdlib/ENV_test.rb +++ b/test/stdlib/ENV_test.rb @@ -8,7 +8,7 @@ module Unnamed end class ENVTest < Test::Unit::TestCase - include TypeAssertions + include TestHelper testing "::RBS::Unnamed::ENVClass" diff --git a/test/stdlib/ERB_test.rb b/test/stdlib/ERB_test.rb index bff41b2f8..e3c96a468 100644 --- a/test/stdlib/ERB_test.rb +++ b/test/stdlib/ERB_test.rb @@ -93,7 +93,7 @@ def template end class ERBUtilSingletonTest < Test::Unit::TestCase - include TypeAssertions + include TestHelper library "erb" testing "singleton(::ERB::Util)" @@ -114,7 +114,7 @@ def test_url_encode end class ERBUtilTest < Test::Unit::TestCase - include TypeAssertions + include TestHelper class Mock include ERB::Util end @@ -138,7 +138,7 @@ def test_url_encode end class ERBDefMethodSingletonTest < Test::Unit::TestCase - include TypeAssertions + include TestHelper library "erb" testing "singleton(::ERB::DefMethod)" diff --git a/test/stdlib/Encoding_Converter_test.rb b/test/stdlib/Encoding_Converter_test.rb index a47d2e12b..00b203457 100644 --- a/test/stdlib/Encoding_Converter_test.rb +++ b/test/stdlib/Encoding_Converter_test.rb @@ -1,7 +1,7 @@ require_relative "test_helper" class Encoding::ConverterSingletonTest < Test::Unit::TestCase - include TypeAssertions + include TestHelper testing "singleton(::Encoding::Converter)" @@ -175,7 +175,7 @@ def test_search_convpath end class Encoding::ConverterTest < Test::Unit::TestCase - include TypeAssertions + include TestHelper testing "::Encoding::Converter" diff --git a/test/stdlib/Encoding_test.rb b/test/stdlib/Encoding_test.rb index 2f150a043..030dc2f29 100644 --- a/test/stdlib/Encoding_test.rb +++ b/test/stdlib/Encoding_test.rb @@ -1,7 +1,7 @@ require_relative 'test_helper' class EncodingSingletonTest < Test::Unit::TestCase - include TypeAssertions + include TestHelper testing 'singleton(::Encoding)' @@ -36,7 +36,7 @@ def test_default_external_and_default_external= assert_send_type '() -> Encoding', Encoding, :default_external - + assert_send_type '(Encoding) -> Encoding', Encoding, :default_external=, Encoding::UTF_8 @@ -57,7 +57,7 @@ def test_default_internal_and_default_internal= Encoding, :default_internal=, nil assert_send_type '() -> Encoding?', Encoding, :default_internal - + assert_send_type '(Encoding) -> Encoding', Encoding, :default_internal=, Encoding::UTF_8 @@ -86,7 +86,7 @@ def test_find Encoding, :find, enc end ensure - Encoding.default_internal = old_enc + Encoding.default_internal = old_enc end end @@ -102,7 +102,7 @@ def test_name_list end class EncodingInstanceTest < Test::Unit::TestCase - include TypeAssertions + include TestHelper testing '::Encoding' @@ -177,19 +177,19 @@ def test_encoding_constants end class Encoding_CompatibilityErrorInstanceTest < Test::Unit::TestCase - include TypeAssertions + include TestHelper testing '::Encoding::CompatibilityError' end class Encoding_ConverterNotFoundErrorInstanceTest < Test::Unit::TestCase - include TypeAssertions + include TestHelper testing '::Encoding::ConverterNotFoundError' end class Encoding_InvalidByteSequenceErrorInstanceTest < Test::Unit::TestCase - include TypeAssertions + include TestHelper testing '::Encoding::InvalidByteSequenceError' @@ -238,7 +238,7 @@ def error_object end class Encoding_UndefinedConversionErrorTest < Test::Unit::TestCase - include TypeAssertions + include TestHelper testing '::Encoding::UndefinedConversionError' diff --git a/test/stdlib/Enumerable_test.rb b/test/stdlib/Enumerable_test.rb index a622c9e91..76d1d8520 100644 --- a/test/stdlib/Enumerable_test.rb +++ b/test/stdlib/Enumerable_test.rb @@ -127,7 +127,7 @@ def each end class EnumerableTest2 < Test::Unit::TestCase - include TypeAssertions + include TestHelper class TestEnumerable include Enumerable diff --git a/test/stdlib/Enumerator_test.rb b/test/stdlib/Enumerator_test.rb index 70446278e..edf0a327f 100644 --- a/test/stdlib/Enumerator_test.rb +++ b/test/stdlib/Enumerator_test.rb @@ -1,7 +1,7 @@ require_relative "test_helper" class EnumeratorTest < Test::Unit::TestCase - include TypeAssertions + include TestHelper testing "::Enumerator[::Integer, Array[::Integer]]" @@ -21,7 +21,7 @@ def test_with_object end class EnumeratorSingletonTest < Test::Unit::TestCase - include TypeAssertions + include TestHelper testing "singleton(::Enumerator)" @@ -41,7 +41,7 @@ def test_product end class EnumeratorYielderTest < Test::Unit::TestCase - include TypeAssertions + include TestHelper testing "::Enumerator::Yielder" diff --git a/test/stdlib/Etc_test.rb b/test/stdlib/Etc_test.rb index 324bdf8da..a5d73377c 100644 --- a/test/stdlib/Etc_test.rb +++ b/test/stdlib/Etc_test.rb @@ -3,7 +3,7 @@ require "etc" class EtcSingletonTest < Test::Unit::TestCase - include TypeAssertions + include TestHelper library "etc" testing "singleton(::Etc)" diff --git a/test/stdlib/Exception_test.rb b/test/stdlib/Exception_test.rb index 2507e6beb..c1f7ad29e 100644 --- a/test/stdlib/Exception_test.rb +++ b/test/stdlib/Exception_test.rb @@ -1,7 +1,7 @@ require_relative 'test_helper' class ExceptionSingletonTest < Test::Unit::TestCase - include TypeAssertions + include TestHelper testing 'singleton(::Exception)' @@ -24,7 +24,7 @@ def test_exception end class ExceptionInstanceTest < Test::Unit::TestCase - include TypeAssertions + include TestHelper testing '::Exception' @@ -41,7 +41,7 @@ def test_backtrace assert_send_type '() -> nil', exception, :backtrace - + exception.set_backtrace caller assert_send_type '() -> Array[String]', exception, :backtrace @@ -64,7 +64,7 @@ def test_backtrace_locations def test_cause assert_send_type '() -> nil', INSTANCE, :cause - + exception = begin raise "oops" rescue @@ -94,9 +94,9 @@ def test_detailed_message class MyException < Exception; end def test_exception - assert_send_type '() -> self', + assert_send_type '() -> Exception', INSTANCE, :exception - assert_send_type '(self) -> self', + assert_send_type '(Exception) -> Exception', INSTANCE, :exception, INSTANCE with_string.and(Object.new, 1r) do |message| @@ -107,7 +107,7 @@ def test_exception def test_initialize with_string.and(Object.new, 1r) do |message| - assert_send_type '(string | _ToS) -> self', + assert_send_type '(string | _ToS) -> Exception', Exception.allocate, :initialize, message end end @@ -147,7 +147,7 @@ def test_full_message with_bool.and_nil do |highlight| assert_send_type '(highlight: bool?) -> String', INSTANCE, :full_message, highlight: highlight - + with_string('top').and(nil, with_string('bottom'), :top, :bottom) do |order| assert_send_type '(highlight: bool?, order: (:top | :bottom | string)?) -> String', INSTANCE, :full_message, highlight: highlight, order: order diff --git a/test/stdlib/FalseClass_test.rb b/test/stdlib/FalseClass_test.rb index 7a706c8db..d1fdc62a1 100644 --- a/test/stdlib/FalseClass_test.rb +++ b/test/stdlib/FalseClass_test.rb @@ -1,7 +1,7 @@ require_relative "test_helper" class FalseClassInstanceTest < Test::Unit::TestCase - include TypeAssertions + include TestHelper testing '::FalseClass' diff --git a/test/stdlib/Fiber_test.rb b/test/stdlib/Fiber_test.rb index 2cdadf03d..3a6db25fc 100644 --- a/test/stdlib/Fiber_test.rb +++ b/test/stdlib/Fiber_test.rb @@ -1,7 +1,7 @@ require_relative "test_helper" class FiberSingletonTest < Test::Unit::TestCase - include TypeAssertions + include TestHelper testing "singleton(::Fiber)" @@ -69,7 +69,7 @@ def test_new end class FiberTest < Test::Unit::TestCase - include TypeAssertions + include TestHelper testing "::Fiber" diff --git a/test/stdlib/FileTest_test.rb b/test/stdlib/FileTest_test.rb index 619de510b..77b8f3873 100644 --- a/test/stdlib/FileTest_test.rb +++ b/test/stdlib/FileTest_test.rb @@ -1,7 +1,7 @@ require_relative "test_helper" class FileTestSingletonTest < Test::Unit::TestCase - include TypeAssertions + include TestHelper testing "singleton(::FileTest)" diff --git a/test/stdlib/FileUtils_test.rb b/test/stdlib/FileUtils_test.rb index 1a74546a9..20b1a9bc2 100644 --- a/test/stdlib/FileUtils_test.rb +++ b/test/stdlib/FileUtils_test.rb @@ -12,7 +12,7 @@ def in_tmpdir(&block) end class FileUtilsSingletonTest < Test::Unit::TestCase - include TypeAssertions + include TestHelper include TmpdirHelper library "fileutils" @@ -618,7 +618,7 @@ def test_uptodate? end class FileUtilsInstanceTest < Test::Unit::TestCase - include TypeAssertions + include TestHelper include TmpdirHelper library "fileutils" diff --git a/test/stdlib/File_Stat_test.rb b/test/stdlib/File_Stat_test.rb index e71f8838e..cdd6b2d1b 100644 --- a/test/stdlib/File_Stat_test.rb +++ b/test/stdlib/File_Stat_test.rb @@ -1,7 +1,7 @@ require_relative "test_helper" class FileStatSingletonTest < Test::Unit::TestCase - include TypeAssertions + include TestHelper testing "singleton(::File::Stat)" @@ -12,7 +12,7 @@ def test_new end class FileStatInstanceTest < Test::Unit::TestCase - include TypeAssertions + include TestHelper testing "::File::Stat" diff --git a/test/stdlib/File_test.rb b/test/stdlib/File_test.rb index 4fa396549..8fc0304b1 100644 --- a/test/stdlib/File_test.rb +++ b/test/stdlib/File_test.rb @@ -2,7 +2,7 @@ require "socket" class FileSingletonTest < Test::Unit::TestCase - include TypeAssertions + include TestHelper testing "singleton(::File)" @@ -839,7 +839,7 @@ def test_zero? end class FileInstanceTest < Test::Unit::TestCase - include TypeAssertions + include TestHelper testing "::File" diff --git a/test/stdlib/Float_test.rb b/test/stdlib/Float_test.rb index 92020eee7..b5ef4b79e 100644 --- a/test/stdlib/Float_test.rb +++ b/test/stdlib/Float_test.rb @@ -195,7 +195,7 @@ def test_truncate end class FloatConstantTest < Test::Unit::TestCase - include TypeAssertions + include TestHelper def test_constant assert_const_type "Float", "Float::INFINITY" diff --git a/test/stdlib/Forwardable_test.rb b/test/stdlib/Forwardable_test.rb index a25422ef1..755e8c843 100644 --- a/test/stdlib/Forwardable_test.rb +++ b/test/stdlib/Forwardable_test.rb @@ -2,7 +2,7 @@ require "forwardable" class ForwardableTest < Test::Unit::TestCase - include TypeAssertions + include TestHelper library "forwardable" testing "::Forwardable" @@ -65,7 +65,7 @@ def test_def_delegator end class SingleForwardableTest < Test::Unit::TestCase - include TypeAssertions + include TestHelper library "forwardable" testing "::SingleForwardable" diff --git a/test/stdlib/GC_test.rb b/test/stdlib/GC_test.rb index ff308a8a2..df631eca9 100644 --- a/test/stdlib/GC_test.rb +++ b/test/stdlib/GC_test.rb @@ -52,7 +52,7 @@ def test_set_stress class GCSingletonTest < Test::Unit::TestCase - include TypeAssertions + include TestHelper testing "singleton(::GC)" diff --git a/test/stdlib/Hash_test.rb b/test/stdlib/Hash_test.rb index 0053f8024..1306330be 100644 --- a/test/stdlib/Hash_test.rb +++ b/test/stdlib/Hash_test.rb @@ -393,7 +393,7 @@ def test_initialize end class HashInstanceTest < Test::Unit::TestCase - include TypeAssertions + include TestHelper testing "::Hash[::Symbol, ::Integer]" diff --git a/test/stdlib/IO_console_test.rb b/test/stdlib/IO_console_test.rb index cc77ffade..9737a4adb 100644 --- a/test/stdlib/IO_console_test.rb +++ b/test/stdlib/IO_console_test.rb @@ -4,7 +4,7 @@ require 'pty' class IOConsoleSingletonTest < Test::Unit::TestCase - include TypeAssertions + include TestHelper library 'io-console' testing "singleton(::IO)" @@ -28,7 +28,7 @@ def test_io_default_console_size end class IOConsoleTest < Test::Unit::TestCase - include TypeAssertions + include TestHelper library 'io-console' testing "::IO" @@ -60,7 +60,7 @@ def test_io_console_mode_set def test_io_cooked helper { |m, s| - assert_send_type "() { (self) -> void } -> void", + assert_send_type "() { (IO) -> void } -> void", s, :cooked do end } end @@ -74,14 +74,14 @@ def test_io_echo_p def test_io_noecho helper { |m, s| - assert_send_type "() { (self) -> void } -> void", + assert_send_type "() { (IO) -> void } -> void", s, :noecho do end } end def test_io_raw helper { |m, s| - assert_send_type "() { (self) -> void } -> void", + assert_send_type "() { (IO) -> void } -> void", s, :raw do end } end diff --git a/test/stdlib/IO_test.rb b/test/stdlib/IO_test.rb index 35a3c33da..2047861c8 100644 --- a/test/stdlib/IO_test.rb +++ b/test/stdlib/IO_test.rb @@ -4,7 +4,7 @@ require "io/wait" class IOSingletonTest < Test::Unit::TestCase - include TypeAssertions + include TestHelper testing "singleton(::IO)" @@ -148,16 +148,16 @@ def test_select end class IOInstanceTest < Test::Unit::TestCase - include TypeAssertions + include TestHelper testing "::IO" def test_append_symbol Dir.mktmpdir do |dir| File.open(File.join(dir, "some_file"), "w") do |io| - assert_send_type "(String) -> self", + assert_send_type "(String) -> File", io, :<<, "foo" - assert_send_type "(Object) -> self", + assert_send_type "(Object) -> File", io, :<<, Object.new end end @@ -358,7 +358,7 @@ def test_gets end class IOWaitTest < Test::Unit::TestCase - include TypeAssertions + include TestHelper testing "::IO" diff --git a/test/stdlib/Integer_test.rb b/test/stdlib/Integer_test.rb index 971b82532..b4661c2d7 100644 --- a/test/stdlib/Integer_test.rb +++ b/test/stdlib/Integer_test.rb @@ -350,7 +350,7 @@ def test_upto class IntegerSingletonTest < Test::Unit::TestCase - include TypeAssertions + include TestHelper testing "singleton(::Integer)" diff --git a/test/stdlib/Kernel_test.rb b/test/stdlib/Kernel_test.rb index 626f62dc6..7b033d1ca 100644 --- a/test/stdlib/Kernel_test.rb +++ b/test/stdlib/Kernel_test.rb @@ -3,7 +3,7 @@ require "securerandom" class KernelSingletonTest < Test::Unit::TestCase - include TypeAssertions + include TestHelper testing "singleton(::Kernel)" @@ -912,7 +912,7 @@ def test_yield_self end class KernelInstanceTest < Test::Unit::TestCase - include TypeAssertions + include TestHelper testing "::Kernel" @@ -976,26 +976,26 @@ def test_pp def test_initialize_copy assert_send_type( - "(self) -> self", + "(Object) -> Object", Object.new, :initialize_copy, Object.new ) end def test_initialize_clone assert_send_type( - "(self) -> self", + "(Object) -> Object", Object.new, :initialize_clone, Object.new ) assert_send_type( - "(self, freeze: bool) -> self", + "(Object, freeze: bool) -> Object", Object.new, :initialize_clone, Object.new, freeze: true ) end def test_initialize_dup assert_send_type( - "(self) -> self", + "(Object) -> Object", Object.new, :initialize_dup, Object.new ) end diff --git a/test/stdlib/Logger_test.rb b/test/stdlib/Logger_test.rb index 6a1c99aea..4c384fa92 100644 --- a/test/stdlib/Logger_test.rb +++ b/test/stdlib/Logger_test.rb @@ -4,7 +4,7 @@ require 'stringio' class LoggerSingletonTest < Test::Unit::TestCase - include TypeAssertions + include TestHelper library 'logger' testing "singleton(::Logger)" @@ -34,7 +34,7 @@ def test_new end class LoggerTest < Test::Unit::TestCase - include TypeAssertions + include TestHelper library 'logger' testing "::Logger" @@ -236,11 +236,11 @@ def test_progname= end def test_reopen - assert_send_type "() -> self", + assert_send_type "() -> Logger", logger, :reopen - assert_send_type "(nil) -> self", + assert_send_type "(nil) -> Logger", logger, :reopen, nil - assert_send_type "(LoggerTest::WriteCloser) -> self", + assert_send_type "(LoggerTest::WriteCloser) -> Logger", logger, :reopen, WriteCloser.new end diff --git a/test/stdlib/Marshal_test.rb b/test/stdlib/Marshal_test.rb index fbb6fe01c..945ffa78a 100644 --- a/test/stdlib/Marshal_test.rb +++ b/test/stdlib/Marshal_test.rb @@ -3,7 +3,7 @@ require "tmpdir" class MarshalSingletonTest < Test::Unit::TestCase - include TypeAssertions + include TestHelper testing "singleton(::Marshal)" def test_MAJOR_VERSION @@ -87,7 +87,7 @@ def test_restore end class MarshalIncludeTest < Test::Unit::TestCase - include TypeAssertions + include TestHelper testing "::Marshal" def test_dump diff --git a/test/stdlib/MatchData_test.rb b/test/stdlib/MatchData_test.rb index 6d11265f3..45c72c601 100644 --- a/test/stdlib/MatchData_test.rb +++ b/test/stdlib/MatchData_test.rb @@ -1,7 +1,7 @@ require_relative 'test_helper' class MatchDataInstanceTest < Test::Unit::TestCase - include TypeAssertions + include TestHelper testing '::MatchData' @@ -17,7 +17,7 @@ def with_backref(name: 'a', idx: 1, &block) def test_initalize_copy instance = /./.match('&') - assert_send_type '(MatchData) -> self', + assert_send_type '(MatchData) -> MatchData', instance, :initialize_copy, INSTANCE end diff --git a/test/stdlib/Math_test.rb b/test/stdlib/Math_test.rb index 92a0c0ac6..f9f3a8c0e 100644 --- a/test/stdlib/Math_test.rb +++ b/test/stdlib/Math_test.rb @@ -1,7 +1,7 @@ require_relative 'test_helper' class MathSingletonTest < Test::Unit::TestCase - include TypeAssertions + include TestHelper testing 'singleton(::Math)' @@ -32,7 +32,7 @@ def test_acos assert_send_type '(Math::double) -> Float', Math, :acos, double end - + refute_send_type '(_ToF) -> Float', Math, :acos, ToF.new(0.0) end @@ -222,7 +222,7 @@ def test_log with_double 0.0 do |double| assert_send_type '(Math::double) -> Float', Math, :log, double - + with_double 0.0 do |base| assert_send_type '(Math::double, Math::double) -> Float', Math, :log, double, base diff --git a/test/stdlib/Minitest_test.rb b/test/stdlib/Minitest_test.rb index 85132b931..99208a720 100644 --- a/test/stdlib/Minitest_test.rb +++ b/test/stdlib/Minitest_test.rb @@ -7,7 +7,7 @@ require 'minitest' class MinitestSingletonTest < Test::Unit::TestCase - include TypeAssertions + include TestHelper library "minitest" testing "singleton(::Minitest)" diff --git a/test/stdlib/Module_test.rb b/test/stdlib/Module_test.rb index b10a49eab..81baf730f 100644 --- a/test/stdlib/Module_test.rb +++ b/test/stdlib/Module_test.rb @@ -1,7 +1,7 @@ require_relative "test_helper" class ModuleSingletonTest < Test::Unit::TestCase - include TypeAssertions + include TestHelper testing "singleton(::Module)" @@ -19,7 +19,7 @@ def test_used_refinements end class ModuleInstanceTest < Test::Unit::TestCase - include TypeAssertions + include TestHelper testing "::Module" diff --git a/test/stdlib/Monitor_test.rb b/test/stdlib/Monitor_test.rb index c6ecdc132..0a55dd3ac 100644 --- a/test/stdlib/Monitor_test.rb +++ b/test/stdlib/Monitor_test.rb @@ -2,7 +2,7 @@ require 'monitor' class MonitorInstanceTest < Test::Unit::TestCase - include TypeAssertions + include TestHelper library 'monitor' testing "::Monitor" @@ -39,7 +39,7 @@ def test_try_enter end class MonitorMixinInstanceTest < Test::Unit::TestCase - include TypeAssertions + include TestHelper library 'monitor' testing "::MonitorMixin" @@ -93,7 +93,7 @@ def test_new_cond end class MonitorMixinConditionVariableInstanceTest < Test::Unit::TestCase - include TypeAssertions + include TestHelper library 'monitor' testing "::MonitorMixin::ConditionVariable" diff --git a/test/stdlib/Mutex_m_test.rb b/test/stdlib/Mutex_m_test.rb index 268a898fb..a7ce77586 100644 --- a/test/stdlib/Mutex_m_test.rb +++ b/test/stdlib/Mutex_m_test.rb @@ -2,7 +2,7 @@ require 'mutex_m' class Mutex_mInstanceTest < Test::Unit::TestCase - include TypeAssertions + include TestHelper library 'mutex_m' testing "::Mutex_m" diff --git a/test/stdlib/NKF_test.rb b/test/stdlib/NKF_test.rb index 15c933c61..e90139740 100644 --- a/test/stdlib/NKF_test.rb +++ b/test/stdlib/NKF_test.rb @@ -2,7 +2,7 @@ require "nkf" class NKFSingletonTest < Test::Unit::TestCase - include TypeAssertions + include TestHelper library "nkf" testing "singleton(::NKF)" diff --git a/test/stdlib/Net_HTTP_test.rb b/test/stdlib/Net_HTTP_test.rb index 94a308068..362929cf9 100644 --- a/test/stdlib/Net_HTTP_test.rb +++ b/test/stdlib/Net_HTTP_test.rb @@ -3,7 +3,7 @@ require "uri" class NetSingletonTest < Test::Unit::TestCase - include TypeAssertions + include TestHelper library "net-http", "uri" testing "singleton(::Net::HTTP)" @@ -46,7 +46,7 @@ def test_new end class NetInstanceTest < Test::Unit::TestCase - include TypeAssertions + include TestHelper library "net-http", "uri" testing "::Net::HTTP" @@ -308,7 +308,7 @@ def test_request end class TestHTTPRequest < Test::Unit::TestCase - include TypeAssertions + include TestHelper library "net-http", "uri" testing "::Net::HTTPRequest" @@ -454,7 +454,7 @@ def test_iteration_on_headers end class TestSingletonNetHTTPResponse < Test::Unit::TestCase - include TypeAssertions + include TestHelper library "net-http", "uri" testing "singleton(::Net::HTTPResponse)" @@ -466,7 +466,7 @@ def test_body_permitted_? end class TestInstanceNetHTTPResponse < Test::Unit::TestCase - include TypeAssertions + include TestHelper library "net-http", "uri" testing "::Net::HTTPResponse" diff --git a/test/stdlib/NilClass_test.rb b/test/stdlib/NilClass_test.rb index fce4c2574..aa203cc10 100644 --- a/test/stdlib/NilClass_test.rb +++ b/test/stdlib/NilClass_test.rb @@ -1,7 +1,7 @@ require_relative "test_helper" class NilClassInstanceTest < Test::Unit::TestCase - include TypeAssertions + include TestHelper testing '::NilClass' diff --git a/test/stdlib/NoMatchingPatternKeyError_test.rb b/test/stdlib/NoMatchingPatternKeyError_test.rb index a41e3f941..928392986 100644 --- a/test/stdlib/NoMatchingPatternKeyError_test.rb +++ b/test/stdlib/NoMatchingPatternKeyError_test.rb @@ -1,7 +1,7 @@ require_relative "test_helper" class NoMatchingPatternKeyErrorSingletonTest < Test::Unit::TestCase - include TypeAssertions + include TestHelper testing "singleton(::NoMatchingPatternKeyError)" @@ -13,7 +13,7 @@ def test_new end class NoMatchingPatternKeyErrorTest < Test::Unit::TestCase - include TypeAssertions + include TestHelper testing "::NoMatchingPatternKeyError[Hash[Symbol, untyped], Symbol]" diff --git a/test/stdlib/ObjectSpace_test.rb b/test/stdlib/ObjectSpace_test.rb index 7666fd431..5903e03d9 100644 --- a/test/stdlib/ObjectSpace_test.rb +++ b/test/stdlib/ObjectSpace_test.rb @@ -2,7 +2,7 @@ require 'objspace' class ObjectSpaceTest < Test::Unit::TestCase - include TypeAssertions + include TestHelper library "objspace" testing "singleton(::ObjectSpace)" diff --git a/test/stdlib/OpenSSL_test.rb b/test/stdlib/OpenSSL_test.rb index b481e3842..76645ccf7 100644 --- a/test/stdlib/OpenSSL_test.rb +++ b/test/stdlib/OpenSSL_test.rb @@ -14,7 +14,7 @@ def openssl?(major = nil, minor = nil, fix = nil, patch = 0) end class OpenSSLSingletonTest < Test::Unit::TestCase - include TypeAssertions + include TestHelper library "openssl" testing "singleton(::OpenSSL)" @@ -51,7 +51,7 @@ def test_secure_compare class OpenSSLASN1SingletonTest < Test::Unit::TestCase - include TypeAssertions + include TestHelper library "openssl" testing "singleton(::OpenSSL::ASN1)" @@ -179,14 +179,16 @@ def test_decode_all end def test_traverse - der = "\x05\x00\x05\x00".b - assert_send_type "(String) { (::Integer, ::Integer, ::Integer, ::Integer, bool, Symbol, ::Integer) -> void } -> void", - OpenSSL::ASN1, :traverse, der do |a, b, c, d, e, f, g| return a, b, c, d, e, f, g end + der = "\x05\x00".b + assert_send_type( + "(String) { ([::Integer, ::Integer, ::Integer, ::Integer, bool, Symbol, ::Integer]) -> void } -> void", + OpenSSL::ASN1, :traverse, der, &proc { } + ) end end class OpenSSLASN1ASN1DataTest < Test::Unit::TestCase - include TypeAssertions + include TestHelper library "openssl" testing "::OpenSSL::ASN1::ASN1Data" @@ -222,7 +224,7 @@ def test_to_der end class OpenSSLBNSingletonTest < Test::Unit::TestCase - include TypeAssertions + include TestHelper library "openssl" testing "singleton(::OpenSSL::BN)" @@ -235,7 +237,7 @@ def test_generate_prime end class OpenSSLBNTest < Test::Unit::TestCase - include TypeAssertions + include TestHelper library "openssl" testing "::OpenSSL::BN" @@ -260,7 +262,7 @@ def test_operations end class OpenSSLCipherSingletonTest < Test::Unit::TestCase - include TypeAssertions + include TestHelper library "openssl" testing "singleton(::OpenSSL::Cipher)" @@ -273,7 +275,7 @@ def test_ciphers class OpenSSLCipherTest < Test::Unit::TestCase - include TypeAssertions + include TestHelper library "openssl" testing "::OpenSSL::Cipher" @@ -368,7 +370,7 @@ def new_decryptor(algo, **kwargs) end class OpenSSLConfigSingletonTest < Test::Unit::TestCase - include TypeAssertions + include TestHelper library "openssl" testing "singleton(::OpenSSL::Config)" @@ -393,7 +395,7 @@ def test_parse_config end class OpenSSLConfigTest < Test::Unit::TestCase - include TypeAssertions + include TestHelper library "openssl" testing "::OpenSSL::Config" @@ -410,8 +412,10 @@ def test_lookup_and_set end def test_each - assert_send_type "() { (String, String, String) -> void } -> OpenSSL::Config", - config, :each do |*k| return k; end + assert_send_type( + "() { ([String, String, String]) -> void } -> OpenSSL::Config", + config, :each, &proc { } + ) end private @@ -422,7 +426,7 @@ def config end class OpenSSLDigestSingletonTest < Test::Unit::TestCase - include TypeAssertions + include TestHelper library "openssl" testing "singleton(::OpenSSL::Digest)" @@ -433,7 +437,7 @@ def test_digest end class OpenSSLDigestTest < Test::Unit::TestCase - include TypeAssertions + include TestHelper library "openssl" testing "::OpenSSL::Digest" @@ -470,7 +474,7 @@ def digest end class OpenSSLEngineSingletonTest < Test::Unit::TestCase - include TypeAssertions + include TestHelper library "openssl" testing "singleton(::OpenSSL::Engine)" @@ -486,7 +490,7 @@ def test_engines end if defined?(OpenSSL::Engine) class OpenSSLEngineTest < Test::Unit::TestCase - include TypeAssertions + include TestHelper library "openssl" testing "::OpenSSL::Engine" @@ -508,7 +512,7 @@ def engine end if defined?(OpenSSL::Engine) class OpenSSLHMACSingletonTest < Test::Unit::TestCase - include TypeAssertions + include TestHelper library "openssl" testing "singleton(::OpenSSL::HMAC)" @@ -524,7 +528,7 @@ def test_hexdigest end class OpenSSLHMACTest < Test::Unit::TestCase - include TypeAssertions + include TestHelper library "openssl" testing "::OpenSSL::HMAC" @@ -557,7 +561,7 @@ def hmac end class OpenSSLKDFSingletonTest < Test::Unit::TestCase - include TypeAssertions + include TestHelper library "openssl" testing "singleton(::OpenSSL::KDF)" @@ -597,7 +601,7 @@ def test_scrypt end class OpenSSLNetscapePKITest < Test::Unit::TestCase - include TypeAssertions + include TestHelper library "openssl" testing "::OpenSSL::Netscape::SPKI" @@ -626,7 +630,7 @@ def test_sign end class OpenSSLOCSPBasicResponsePKITest < Test::Unit::TestCase - include TypeAssertions + include TestHelper library "openssl" testing "::OpenSSL::OCSP::BasicResponse" @@ -643,7 +647,7 @@ def basic_response end class OpenSSLPKeySingletonTest < Test::Unit::TestCase - include TypeAssertions + include TestHelper library "openssl" testing "singleton(::OpenSSL::PKey)" @@ -670,7 +674,7 @@ def pem class OpenSSLDHTest < Test::Unit::TestCase - include TypeAssertions + include TestHelper library "openssl" testing "::OpenSSL::PKey::DH" @@ -720,7 +724,7 @@ def pkey end class OpenSSLDSATest < Test::Unit::TestCase - include TypeAssertions + include TestHelper library "openssl" testing "::OpenSSL::PKey::DSA" @@ -791,7 +795,7 @@ def pkey end class OpenSSLECSingletonTest < Test::Unit::TestCase - include TypeAssertions + include TestHelper library "openssl" testing "singleton(::OpenSSL::PKey::EC)" @@ -807,7 +811,7 @@ def test_generate end class OpenSSLECTest < Test::Unit::TestCase - include TypeAssertions + include TestHelper library "openssl" testing "::OpenSSL::PKey::EC" @@ -863,7 +867,7 @@ def pkey end class OpenSSLRSATest < Test::Unit::TestCase - include TypeAssertions + include TestHelper library "openssl" testing "::OpenSSL::PKey::RSA" @@ -910,7 +914,7 @@ def pkey end class OpenSSLRandomSingletonTest < Test::Unit::TestCase - include TypeAssertions + include TestHelper library "openssl" testing "singleton(::OpenSSL::Random)" @@ -922,7 +926,7 @@ def test_random_bytes class OpenSSLSSLSingletonTest < Test::Unit::TestCase - include TypeAssertions + include TestHelper library "openssl" testing "singleton(::OpenSSL::SSL)" @@ -938,7 +942,7 @@ def test_verify_wildcard end class OpenSSLTimestampFactoryTest < Test::Unit::TestCase - include TypeAssertions + include TestHelper library "openssl" testing "::OpenSSL::Timestamp::Factory" @@ -974,7 +978,7 @@ def cert end if OpenSSL.const_defined?(:Timestamp) class OpenSSLX509AttributeTest < Test::Unit::TestCase - include TypeAssertions + include TestHelper library "openssl" testing "::OpenSSL::X509::Attribute" @@ -1003,7 +1007,7 @@ def attribute class OpenSSLX509CertificateTest < Test::Unit::TestCase - include TypeAssertions + include TestHelper library "openssl" testing "::OpenSSL::X509::Certificate" @@ -1034,7 +1038,7 @@ def cert class OpenSSLX509ExtensionTest < Test::Unit::TestCase - include TypeAssertions + include TestHelper library "openssl" testing "::OpenSSL::X509::Extension" @@ -1069,7 +1073,7 @@ def extension end class OpenSSLX509NameSingletonTest < Test::Unit::TestCase - include TypeAssertions + include TestHelper library "openssl" testing "singleton(::OpenSSL::X509::Name)" @@ -1081,7 +1085,7 @@ def test_parse end class OpenSSLX509NameTest < Test::Unit::TestCase - include TypeAssertions + include TestHelper library "openssl" testing "::OpenSSL::X509::Name" diff --git a/test/stdlib/OptionParser_test.rb b/test/stdlib/OptionParser_test.rb index 08bb9a684..290c15d15 100644 --- a/test/stdlib/OptionParser_test.rb +++ b/test/stdlib/OptionParser_test.rb @@ -2,7 +2,7 @@ require "optparse" class OptionParserSingletonTest < Test::Unit::TestCase - include TypeAssertions + include TestHelper library "optparse" testing "singleton(::OptionParser)" @@ -42,7 +42,7 @@ def test_new end class OptionParserTest < Test::Unit::TestCase - include TypeAssertions + include TestHelper library "optparse" testing "::OptionParser" @@ -117,45 +117,45 @@ def test_help end def test_on - assert_send_type "(*String) -> self", opt, :on, '-a' - assert_send_type "(String, Class) -> self", opt, :on, '-a', Array - assert_send_type "(String, Class, String) -> self", opt, :on, '-a', Array, 'description' - assert_send_type "(String, String, Class, String) -> self", opt, :on, '-a', '--all', Array, 'description' - assert_send_type "(String, Array[String]) -> self", opt, :on, '-a', ['foo', 'bar'] - assert_send_type "(String, String, Array[String]) -> self", opt, :on, '-a', '--all', ['foo', 'bar'] - assert_send_type "(String, Hash[Symbol, untyped]) -> self", opt, :on, '-a', {foo: 1, bar: 2} - assert_send_type "(String, String, Hash[Symbol, untyped]) -> self", opt, :on, '-a', '--all', {foo: 1, bar: 2} - assert_send_type "(String, Regexp) -> self", opt, :on, '-a', /foo/ - assert_send_type "(String, String, Regexp) -> self", opt, :on, '-a', '--all', /foo/ - assert_send_type "(*String, Proc) -> self", opt, :on, '-a', proc {} + assert_send_type "(*String) -> OptionParser", opt, :on, '-a' + assert_send_type "(String, Class) -> OptionParser", opt, :on, '-a', Array + assert_send_type "(String, Class, String) -> OptionParser", opt, :on, '-a', Array, 'description' + assert_send_type "(String, String, Class, String) -> OptionParser", opt, :on, '-a', '--all', Array, 'description' + assert_send_type "(String, Array[String]) -> OptionParser", opt, :on, '-a', ['foo', 'bar'] + assert_send_type "(String, String, Array[String]) -> OptionParser", opt, :on, '-a', '--all', ['foo', 'bar'] + assert_send_type "(String, Hash[Symbol, untyped]) -> OptionParser", opt, :on, '-a', {foo: 1, bar: 2} + assert_send_type "(String, String, Hash[Symbol, untyped]) -> OptionParser", opt, :on, '-a', '--all', {foo: 1, bar: 2} + assert_send_type "(String, Regexp) -> OptionParser", opt, :on, '-a', /foo/ + assert_send_type "(String, String, Regexp) -> OptionParser", opt, :on, '-a', '--all', /foo/ + assert_send_type "(*String, Proc) -> OptionParser", opt, :on, '-a', proc {} end def test_on_head - assert_send_type "(*String) -> self", opt, :on_head, '-a' - assert_send_type "(String, Class) -> self", opt, :on_head, '-a', Array - assert_send_type "(String, Class, String) -> self", opt, :on_head, '-a', Array, 'description' - assert_send_type "(String, String, Class, String) -> self", opt, :on_head, '-a', '--all', Array, 'description' - assert_send_type "(String, Array[String]) -> self", opt, :on_head, '-a', ['foo', 'bar'] - assert_send_type "(String, String, Array[String]) -> self", opt, :on_head, '-a', '--all', ['foo', 'bar'] - assert_send_type "(String, Hash[Symbol, untyped]) -> self", opt, :on_head, '-a', {foo: 1, bar: 2} - assert_send_type "(String, String, Hash[Symbol, untyped]) -> self", opt, :on_head, '-a', '--all', {foo: 1, bar: 2} - assert_send_type "(String, Regexp) -> self", opt, :on_head, '-a', /foo/ - assert_send_type "(String, String, Regexp) -> self", opt, :on_head, '-a', '--all', /foo/ - assert_send_type "(*String, Proc) -> self", opt, :on_head, '-a', proc {} + assert_send_type "(*String) -> OptionParser", opt, :on_head, '-a' + assert_send_type "(String, Class) -> OptionParser", opt, :on_head, '-a', Array + assert_send_type "(String, Class, String) -> OptionParser", opt, :on_head, '-a', Array, 'description' + assert_send_type "(String, String, Class, String) -> OptionParser", opt, :on_head, '-a', '--all', Array, 'description' + assert_send_type "(String, Array[String]) -> OptionParser", opt, :on_head, '-a', ['foo', 'bar'] + assert_send_type "(String, String, Array[String]) -> OptionParser", opt, :on_head, '-a', '--all', ['foo', 'bar'] + assert_send_type "(String, Hash[Symbol, untyped]) -> OptionParser", opt, :on_head, '-a', {foo: 1, bar: 2} + assert_send_type "(String, String, Hash[Symbol, untyped]) -> OptionParser", opt, :on_head, '-a', '--all', {foo: 1, bar: 2} + assert_send_type "(String, Regexp) -> OptionParser", opt, :on_head, '-a', /foo/ + assert_send_type "(String, String, Regexp) -> OptionParser", opt, :on_head, '-a', '--all', /foo/ + assert_send_type "(*String, Proc) -> OptionParser", opt, :on_head, '-a', proc {} end def test_on_tail - assert_send_type "(*String) -> self", opt, :on_tail, '-a' - assert_send_type "(String, Class) -> self", opt, :on_tail, '-a', Array - assert_send_type "(String, Class, String) -> self", opt, :on_tail, '-a', Array, 'description' - assert_send_type "(String, String, Class, String) -> self", opt, :on_tail, '-a', '--all', Array, 'description' - assert_send_type "(String, Array[String]) -> self", opt, :on_tail, '-a', ['foo', 'bar'] - assert_send_type "(String, String, Array[String]) -> self", opt, :on_tail, '-a', '--all', ['foo', 'bar'] - assert_send_type "(String, Hash[Symbol, untyped]) -> self", opt, :on_tail, '-a', {foo: 1, bar: 2} - assert_send_type "(String, String, Hash[Symbol, untyped]) -> self", opt, :on_tail, '-a', '--all', {foo: 1, bar: 2} - assert_send_type "(String, Regexp) -> self", opt, :on_tail, '-a', /foo/ - assert_send_type "(String, String, Regexp) -> self", opt, :on_tail, '-a', '--all', /foo/ - assert_send_type "(*String, Proc) -> self", opt, :on_tail, '-a', proc {} + assert_send_type "(*String) -> OptionParser", opt, :on_tail, '-a' + assert_send_type "(String, Class) -> OptionParser", opt, :on_tail, '-a', Array + assert_send_type "(String, Class, String) -> OptionParser", opt, :on_tail, '-a', Array, 'description' + assert_send_type "(String, String, Class, String) -> OptionParser", opt, :on_tail, '-a', '--all', Array, 'description' + assert_send_type "(String, Array[String]) -> OptionParser", opt, :on_tail, '-a', ['foo', 'bar'] + assert_send_type "(String, String, Array[String]) -> OptionParser", opt, :on_tail, '-a', '--all', ['foo', 'bar'] + assert_send_type "(String, Hash[Symbol, untyped]) -> OptionParser", opt, :on_tail, '-a', {foo: 1, bar: 2} + assert_send_type "(String, String, Hash[Symbol, untyped]) -> OptionParser", opt, :on_tail, '-a', '--all', {foo: 1, bar: 2} + assert_send_type "(String, Regexp) -> OptionParser", opt, :on_tail, '-a', /foo/ + assert_send_type "(String, String, Regexp) -> OptionParser", opt, :on_tail, '-a', '--all', /foo/ + assert_send_type "(*String, Proc) -> OptionParser", opt, :on_tail, '-a', proc {} end def test_order @@ -234,7 +234,7 @@ class Target < Array include OptionParser::Arguable end - include TypeAssertions + include TestHelper library "optparse" testing "::OptionParser::Arguable" diff --git a/test/stdlib/PP_test.rb b/test/stdlib/PP_test.rb index 7750ab744..f3dcebe64 100644 --- a/test/stdlib/PP_test.rb +++ b/test/stdlib/PP_test.rb @@ -2,7 +2,7 @@ require "pp" class PPSingletonTest < Test::Unit::TestCase - include TypeAssertions + include TestHelper library "pp" testing "singleton(::PP)" @@ -42,7 +42,7 @@ def test_mcall end class PP::PPMethodsTest < Test::Unit::TestCase - include TypeAssertions + include TestHelper library "pp" testing "::PP::PPMethods" @@ -90,9 +90,9 @@ def test_comma_breakable def test_seplist assert_send_type "(untyped list) { (*untyped, **untyped) -> void } -> void", PP.new, :seplist, [] do end - assert_send_type "(untyped list, ^() -> void? sep) { (*untyped, **untyped) -> void } -> void", + assert_send_type "(untyped list, ^() -> void sep) { (*untyped, **untyped) -> void } -> void", PP.new, :seplist, [], lambda {} do end - assert_send_type "(untyped list, ^() -> void? sep, ::interned iter_method) { (*untyped, **untyped) -> void } -> void", + assert_send_type "(untyped list, ^() -> void sep, ::interned iter_method) { (*untyped, **untyped) -> void } -> void", PP.new, :seplist, [], lambda {}, :each do end end @@ -108,7 +108,7 @@ def test_pp_hash end class PP::ObjectMixinTest < Test::Unit::TestCase - include TypeAssertions + include TestHelper library "pp" testing "::PP::ObjectMixin" diff --git a/test/stdlib/PStore_test.rb b/test/stdlib/PStore_test.rb index fe43c7139..b7400d035 100644 --- a/test/stdlib/PStore_test.rb +++ b/test/stdlib/PStore_test.rb @@ -2,7 +2,7 @@ require "pstore" class PStoreSingletonTest < Test::Unit::TestCase - include TypeAssertions + include TestHelper library "pstore" testing "singleton(::PStore)" diff --git a/test/stdlib/PTY_test.rb b/test/stdlib/PTY_test.rb index 942584465..c63b5462c 100644 --- a/test/stdlib/PTY_test.rb +++ b/test/stdlib/PTY_test.rb @@ -2,7 +2,7 @@ require "pty" class PTYSingletonTest < Test::Unit::TestCase - include TypeAssertions + include TestHelper library "pty" testing "singleton(::PTY)" diff --git a/test/stdlib/Pathname_test.rb b/test/stdlib/Pathname_test.rb index e2433508a..b5d2f402e 100644 --- a/test/stdlib/Pathname_test.rb +++ b/test/stdlib/Pathname_test.rb @@ -2,7 +2,7 @@ require 'pathname' class PathnameSingletonTest < Test::Unit::TestCase - include TypeAssertions + include TestHelper library 'pathname' testing 'singleton(::Pathname)' @@ -38,7 +38,7 @@ def test_initialize end class PathnameInstanceTest < Test::Unit::TestCase - include TypeAssertions + include TestHelper library 'pathname' testing '::Pathname' diff --git a/test/stdlib/PrettyPrint_test.rb b/test/stdlib/PrettyPrint_test.rb index 8cf463880..abf1626dc 100644 --- a/test/stdlib/PrettyPrint_test.rb +++ b/test/stdlib/PrettyPrint_test.rb @@ -2,7 +2,7 @@ require "prettyprint" class PrettyPrintSingletonTest < Test::Unit::TestCase - include TypeAssertions + include TestHelper library "prettyprint" testing "singleton(::PrettyPrint)" @@ -48,7 +48,7 @@ def test_singleline_format end class PrettyPrintTest < Test::Unit::TestCase - include TypeAssertions + include TestHelper library "prettyprint" testing "::PrettyPrint" diff --git a/test/stdlib/Proc_test.rb b/test/stdlib/Proc_test.rb index daa45f8ac..d9c6564e7 100644 --- a/test/stdlib/Proc_test.rb +++ b/test/stdlib/Proc_test.rb @@ -63,7 +63,7 @@ def test_inspect end class ProcInstanceTest < Test::Unit::TestCase - include TypeAssertions + include TestHelper testing '::Proc' diff --git a/test/stdlib/Ractor_test.rb b/test/stdlib/Ractor_test.rb index 883c06a99..b5f996681 100644 --- a/test/stdlib/Ractor_test.rb +++ b/test/stdlib/Ractor_test.rb @@ -6,7 +6,7 @@ end class RactorSingletonTest < Test::Unit::TestCase - include TypeAssertions + include TestHelper testing "singleton(::Ractor)" @@ -101,7 +101,7 @@ def test_yield end class RactorInstanceTest < Test::Unit::TestCase - include TypeAssertions + include TestHelper testing "::Ractor" diff --git a/test/stdlib/Random_test.rb b/test/stdlib/Random_test.rb index 3ace61268..526f68d55 100644 --- a/test/stdlib/Random_test.rb +++ b/test/stdlib/Random_test.rb @@ -1,7 +1,7 @@ require_relative "test_helper" class RandomSingletonTest < Test::Unit::TestCase - include TypeAssertions + include TestHelper testing "singleton(::Random)" @@ -41,7 +41,7 @@ def test_urandom end class RandomTest < Test::Unit::TestCase - include TypeAssertions + include TestHelper testing "::Random" diff --git a/test/stdlib/Rational_test.rb b/test/stdlib/Rational_test.rb index df59eab5e..94573e14a 100644 --- a/test/stdlib/Rational_test.rb +++ b/test/stdlib/Rational_test.rb @@ -181,7 +181,7 @@ def test_truncate end class RationalInstanceTest < Test::Unit::TestCase - include TypeAssertions + include TestHelper testing "::Rational" diff --git a/test/stdlib/RbConfig_test.rb b/test/stdlib/RbConfig_test.rb index 65bb5e0c3..851665e11 100644 --- a/test/stdlib/RbConfig_test.rb +++ b/test/stdlib/RbConfig_test.rb @@ -1,7 +1,7 @@ require_relative 'test_helper' class RbConfigSingletonTest < Test::Unit::TestCase - include TypeAssertions + include TestHelper testing 'singleton(::RbConfig)' diff --git a/test/stdlib/Resolv_test.rb b/test/stdlib/Resolv_test.rb index e2be1073b..3fbf0374d 100644 --- a/test/stdlib/Resolv_test.rb +++ b/test/stdlib/Resolv_test.rb @@ -2,7 +2,7 @@ require "resolv" class ResolvSingletonTest < Test::Unit::TestCase - include TypeAssertions + include TestHelper library "resolv" testing "singleton(::Resolv)" @@ -39,7 +39,7 @@ def test_getnames end class ResolvInstanceTest < Test::Unit::TestCase - include TypeAssertions + include TestHelper library "resolv" testing "::Resolv" diff --git a/test/stdlib/Ripper_test.rb b/test/stdlib/Ripper_test.rb index e5d4c1b6c..9e9b255cf 100644 --- a/test/stdlib/Ripper_test.rb +++ b/test/stdlib/Ripper_test.rb @@ -1,7 +1,7 @@ require_relative "test_helper" class RipperSingletonTest < Test::Unit::TestCase - include TypeAssertions + include TestHelper library "ripper" testing "singleton(::Ripper)" @@ -58,7 +58,7 @@ def test_tokenize end class RipperTest < Test::Unit::TestCase - include TypeAssertions + include TestHelper library "ripper" testing "::Ripper" @@ -190,7 +190,7 @@ def test_warning end class Ripper::FilterSingletonTest < Test::Unit::TestCase - include TypeAssertions + include TestHelper library "ripper" testing "singleton(::Ripper::Filter)" @@ -202,7 +202,7 @@ def test_new end class Ripper::FilterTest < Test::Unit::TestCase - include TypeAssertions + include TestHelper library "ripper" testing "::Ripper::Filter" diff --git a/test/stdlib/RubyVM_test.rb b/test/stdlib/RubyVM_test.rb index ea48fe52b..73090f05a 100644 --- a/test/stdlib/RubyVM_test.rb +++ b/test/stdlib/RubyVM_test.rb @@ -1,7 +1,7 @@ require_relative "test_helper" class RubyVM::AbstractSyntaxTreeSingletonTest < Test::Unit::TestCase - include TypeAssertions + include TestHelper testing "singleton(::RubyVM::AbstractSyntaxTree)" @@ -29,7 +29,7 @@ def test_node_id_for_backtrace_location end class RubyVM::AbstractSyntaxTree::NodeTest < Test::Unit::TestCase - include TypeAssertions + include TestHelper testing "::RubyVM::AbstractSyntaxTree::Node" diff --git a/test/stdlib/Set_test.rb b/test/stdlib/Set_test.rb index 12d7dc07a..8c1a50f14 100644 --- a/test/stdlib/Set_test.rb +++ b/test/stdlib/Set_test.rb @@ -1,7 +1,7 @@ require_relative "test_helper" class SetTest < Test::Unit::TestCase - include TypeAssertions + include TestHelper testing "::Set[::Integer]" diff --git a/test/stdlib/Shellwords_test.rb b/test/stdlib/Shellwords_test.rb index 5e0dbbd3e..df593caaa 100644 --- a/test/stdlib/Shellwords_test.rb +++ b/test/stdlib/Shellwords_test.rb @@ -2,7 +2,7 @@ require "shellwords" class ShellwordsSingletonTest < Test::Unit::TestCase - include TypeAssertions + include TestHelper library "shellwords" testing "singleton(::Shellwords)" @@ -44,7 +44,7 @@ def test_split end class ShellwordsTest < Test::Unit::TestCase - include TypeAssertions + include TestHelper library "shellwords" testing "::Shellwords" @@ -75,7 +75,7 @@ def test_shellwords end class ShellwordsArrayTest < Test::Unit::TestCase - include TypeAssertions + include TestHelper library "shellwords" testing "::Array[String]" @@ -87,7 +87,7 @@ def test_shelljoin end class ShellwordsStringTest < Test::Unit::TestCase - include TypeAssertions + include TestHelper library "shellwords" testing "::String" diff --git a/test/stdlib/Signal_test.rb b/test/stdlib/Signal_test.rb index 054c84ba7..21a9d85dd 100644 --- a/test/stdlib/Signal_test.rb +++ b/test/stdlib/Signal_test.rb @@ -1,7 +1,7 @@ require_relative 'test_helper' class SignalSingletonTest < Test::Unit::TestCase - include TypeAssertions + include TestHelper testing 'singleton(::Signal)' diff --git a/test/stdlib/StringIO_test.rb b/test/stdlib/StringIO_test.rb index 5e6791ef5..72881bfab 100644 --- a/test/stdlib/StringIO_test.rb +++ b/test/stdlib/StringIO_test.rb @@ -40,7 +40,7 @@ def test_gets end class StringIOTypeTest < Test::Unit::TestCase - include TypeAssertions + include TestHelper testing '::StringIO' diff --git a/test/stdlib/String_test.rb b/test/stdlib/String_test.rb index b8b83373c..f390cd9c6 100644 --- a/test/stdlib/String_test.rb +++ b/test/stdlib/String_test.rb @@ -1,7 +1,7 @@ require_relative "test_helper" class StringSingletonTest < Test::Unit::TestCase - include TypeAssertions + include TestHelper testing "singleton(::String)" @@ -35,7 +35,7 @@ def test_try_convert end class StringInstanceTest < Test::Unit::TestCase - include TypeAssertions + include TestHelper testing "::String" @@ -576,71 +576,71 @@ def test_dump end def test_each_byte - assert_send_type "() -> Enumerator[Integer, self]", + assert_send_type "() -> Enumerator[Integer, String]", "hello", :each_byte - assert_send_type "() { (Integer) -> void } -> self", + assert_send_type "() { (Integer) -> void } -> String", "hello", :each_byte do |c| c end end def test_each_char - assert_send_type "() -> Enumerator[String, self]", + assert_send_type "() -> Enumerator[String, String]", "hello", :each_char - assert_send_type "() { (String) -> void } -> self", + assert_send_type "() { (String) -> void } -> String", "hello", :each_char do |c| c end end def test_each_codepoint - assert_send_type "() -> Enumerator[Integer, self]", + assert_send_type "() -> Enumerator[Integer, String]", "hello", :each_codepoint - assert_send_type "() { (Integer) -> void } -> self", + assert_send_type "() { (Integer) -> void } -> String", "hello", :each_codepoint do |c| c end end def test_each_grapheme_cluster - assert_send_type "() -> Enumerator[String, self]", + assert_send_type "() -> Enumerator[String, String]", "hello", :each_grapheme_cluster - assert_send_type "() { (String) -> void } -> self", + assert_send_type "() { (String) -> void } -> String", "hello", :each_grapheme_cluster do |c| c end end def test_each_line - assert_send_type "() -> Enumerator[String, self]", + assert_send_type "() -> Enumerator[String, String]", "hello", :each_line - assert_send_type "() { (String) -> void } -> self", + assert_send_type "() { (String) -> void } -> String", "hello", :each_line do |line| line end - assert_send_type "(String) -> Enumerator[String, self]", + assert_send_type "(String) -> Enumerator[String, String]", "hello", :each_line, "l" - assert_send_type "(ToStr) -> Enumerator[String, self]", + assert_send_type "(ToStr) -> Enumerator[String, String]", "hello", :each_line, ToStr.new("l") - assert_send_type "(String) { (String) -> void } -> self", + assert_send_type "(String) { (String) -> void } -> String", "hello", :each_line, "l" do |line| line end - assert_send_type "(ToStr) { (String) -> void } -> self", + assert_send_type "(ToStr) { (String) -> void } -> String", "hello", :each_line, ToStr.new("l") do |line| line end - assert_send_type "(chomp: true) -> Enumerator[String, self]", + assert_send_type "(chomp: true) -> Enumerator[String, String]", "hello", :each_line, chomp: true - assert_send_type "(chomp: false) -> Enumerator[String, self]", + assert_send_type "(chomp: false) -> Enumerator[String, String]", "hello", :each_line, chomp: false - assert_send_type "(chomp: true) { (String) -> void } -> self", + assert_send_type "(chomp: true) { (String) -> void } -> String", "hello", :each_line, chomp: true do |line| line end - assert_send_type "(chomp: false){ (String) -> void } -> self", + assert_send_type "(chomp: false){ (String) -> void } -> String", "hello", :each_line, chomp: false do |line| line end - assert_send_type "(String, chomp: true) -> Enumerator[String, self]", + assert_send_type "(String, chomp: true) -> Enumerator[String, String]", "hello", :each_line, "l", chomp: true - assert_send_type "(ToStr, chomp: true) -> Enumerator[String, self]", + assert_send_type "(ToStr, chomp: true) -> Enumerator[String, String]", "hello", :each_line, ToStr.new("l"), chomp: true - assert_send_type "(String, chomp: false) -> Enumerator[String, self]", + assert_send_type "(String, chomp: false) -> Enumerator[String, String]", "hello", :each_line, "l", chomp: false - assert_send_type "(ToStr, chomp: false) -> Enumerator[String, self]", + assert_send_type "(ToStr, chomp: false) -> Enumerator[String, String]", "hello", :each_line, ToStr.new("l"), chomp: false - assert_send_type "(String, chomp: true) { (String) -> void } -> self", + assert_send_type "(String, chomp: true) { (String) -> void } -> String", "hello", :each_line, "l", chomp: true do |line| line end - assert_send_type "(ToStr, chomp: true) { (String) -> void } -> self", + assert_send_type "(ToStr, chomp: true) { (String) -> void } -> String", "hello", :each_line, ToStr.new("l"), chomp: true do |line| line end - assert_send_type "(ToStr, chomp: Symbol) { (String) -> void } -> self", + assert_send_type "(ToStr, chomp: Symbol) { (String) -> void } -> String", "hello", :each_line, ToStr.new("l"), chomp: :true do |line| line end - assert_send_type "(String, chomp: false) { (String) -> void } -> self", + assert_send_type "(String, chomp: false) { (String) -> void } -> String", "hello", :each_line, "l", chomp: false do |line| line end - assert_send_type "(ToStr, chomp: false) { (String) -> void } -> self", + assert_send_type "(ToStr, chomp: false) { (String) -> void } -> String", "hello", :each_line, ToStr.new("l"), chomp: false do |line| line end end @@ -692,17 +692,17 @@ def test_encode end def test_encode! - assert_send_type "(String) -> self", + assert_send_type "(String) -> String", "string", :encode!, "ascii" - assert_send_type "(String, Encoding) -> self", + assert_send_type "(String, Encoding) -> String", "string", :encode!, "ascii", Encoding::ASCII_8BIT - assert_send_type "(Encoding, String) -> self", + assert_send_type "(Encoding, String) -> String", "string", :encode!, Encoding::ASCII_8BIT, "ascii" - assert_send_type "(String, invalid: :replace) -> self", + assert_send_type "(String, invalid: :replace) -> String", "string", :encode!, "ascii", invalid: :replace - assert_send_type "(Encoding, Encoding, undef: nil) -> self", + assert_send_type "(Encoding, Encoding, undef: nil) -> String", "string", :encode!, Encoding::ASCII_8BIT, Encoding::ASCII_8BIT, undef: nil - assert_send_type "(invalid: nil, undef: :replace, replace: String, fallback: Hash[String, String], xml: :text, universal_newline: true) -> self", + assert_send_type "(invalid: nil, undef: :replace, replace: String, fallback: Hash[String, String], xml: :text, universal_newline: true) -> String", "string", :encode!, invalid: nil, undef: :replace, @@ -710,19 +710,19 @@ def test_encode! fallback: {"a" => "a"}, xml: :text, universal_newline: true - assert_send_type "(xml: :attr) -> self", + assert_send_type "(xml: :attr) -> String", "string", :encode!, xml: :attr - assert_send_type "(fallback: Proc) -> self", + assert_send_type "(fallback: Proc) -> String", "string", :encode!, fallback: proc { |s| s } - assert_send_type "(fallback: Method) -> self", + assert_send_type "(fallback: Method) -> String", "string", :encode!, fallback: "test".method(:+) assert_send_type "(fallback: ArefFromStringToString) -> String", "string", :encode, fallback: ArefFromStringToString.new - assert_send_type "(cr_newline: true) -> self", + assert_send_type "(cr_newline: true) -> String", "string", :encode!, cr_newline: true - assert_send_type "(crlf_newline: true) -> self", + assert_send_type "(crlf_newline: true) -> String", "string", :encode!, crlf_newline: true - assert_send_type "(ToStr, ToStr) -> self", + assert_send_type "(ToStr, ToStr) -> String", "string", :encode!, ToStr.new("ascii"), ToStr.new("ascii") end @@ -751,16 +751,16 @@ def test_eql? end def test_force_encoding - assert_send_type "(String) -> self", + assert_send_type "(String) -> String", "", :force_encoding, "ASCII-8BIT" - assert_send_type "(Encoding) -> self", + assert_send_type "(Encoding) -> String", "", :force_encoding, Encoding::ASCII_8BIT - assert_send_type "(ToStr) -> self", + assert_send_type "(ToStr) -> String", "", :force_encoding, ToStr.new("ASCII-8BIT") end def test_freeze - assert_send_type "() -> self", + assert_send_type "() -> String", "test", :freeze end @@ -791,9 +791,9 @@ def test_gsub "string", :gsub, /./ do |x| ToS.new("") end assert_send_type "(Regexp, Hash[String, String]) -> String", "string", :gsub, /./, {"foo" => "bar"} - assert_send_type "(Regexp) -> Enumerator[String, self]", + assert_send_type "(Regexp) -> Enumerator[String, String]", "string", :gsub, /./ - assert_send_type "(String) -> Enumerator[String, self]", + assert_send_type "(String) -> Enumerator[String, String]", "string", :gsub, "" assert_send_type "(ToStr, ToStr) -> String", "string", :gsub, ToStr.new("a"), ToStr.new("b") @@ -802,21 +802,21 @@ def test_gsub def test_gsub! assert_send_type "(Regexp, String) -> nil", "string", :gsub!, /z/, "s" - assert_send_type "(Regexp, String) -> self", + assert_send_type "(Regexp, String) -> String", "string", :gsub!, /s/, "s" assert_send_type "(String, String) -> nil", "string", :gsub!, "z", "s" - assert_send_type "(String, String) -> self", + assert_send_type "(String, String) -> String", "string", :gsub!, "s", "s" assert_send_type "(Regexp) { (String) -> String } -> nil", "string", :gsub!, /z/ do |x| "s" end - assert_send_type "(Regexp) { (String) -> String } -> self", + assert_send_type "(Regexp) { (String) -> String } -> String", "string", :gsub!, /s/ do |x| "s" end - assert_send_type "(Regexp) { (String) -> ToS } -> self", + assert_send_type "(Regexp) { (String) -> ToS } -> String", "string", :gsub!, /s/ do |x| ToS.new("s") end assert_send_type "(Regexp, Hash[String, String]) -> nil", "string", :gsub!, /z/, {"z" => "s"} - assert_send_type "(Regexp, Hash[String, String]) -> self", + assert_send_type "(Regexp, Hash[String, String]) -> String", "string", :gsub!, /s/, {"s" => "s"} # assert_send_type "(Regexp) -> Enumerator[String, self]", # "string", :gsub!, /s/ @@ -922,7 +922,7 @@ def test_lstrip def test_lstrip! assert_send_type "() -> nil", "", :lstrip! - assert_send_type "() -> self", + assert_send_type "() -> String", " test ", :lstrip! end @@ -1012,7 +1012,7 @@ def test_next end def test_next! - assert_send_type "() -> self", + assert_send_type "() -> String", "a", :next! end @@ -1061,7 +1061,7 @@ def test_reverse end def test_reverse! - assert_send_type "() -> self", + assert_send_type "() -> String", "test", :reverse! end @@ -1108,7 +1108,7 @@ def test_rstrip end def test_rstrip! - assert_send_type "() -> self", + assert_send_type "() -> String", " hello ", :rstrip! assert_send_type "() -> nil", "", :rstrip! @@ -1123,13 +1123,13 @@ def test_scan "a", :scan, "a" assert_send_type "(ToStr) -> Array[String]", "a", :scan, ToStr.new("a") - assert_send_type "(Regexp) { (String) -> void } -> self", + assert_send_type "(Regexp) { (String) -> void } -> String", "a", :scan, /a/ do |arg| arg end - assert_send_type "(Regexp) { (Array[String]) -> void } -> self", + assert_send_type "(Regexp) { (Array[String]) -> void } -> String", "a", :scan, /(a)/ do |arg| arg end - assert_send_type "(String) { (String) -> void } -> self", + assert_send_type "(String) { (String) -> void } -> String", "a", :scan, "a" do |arg| arg end - assert_send_type "(ToStr) { (String) -> void } -> self", + assert_send_type "(ToStr) { (String) -> void } -> String", "a", :scan, ToStr.new("a") do |arg| arg end end @@ -1147,15 +1147,15 @@ def test_scrub end def test_scrub! - assert_send_type "() -> self", + assert_send_type "() -> String", "\x81", :scrub! - assert_send_type "(String) -> self", + assert_send_type "(String) -> String", "\x81", :scrub!, "*" - assert_send_type "(ToStr) -> self", + assert_send_type "(ToStr) -> String", "\x81", :scrub!, ToStr.new("*") - assert_send_type "() { (String) -> String } -> self", + assert_send_type "() { (String) -> String } -> String", "\x81", :scrub! do |s| "*" end - assert_send_type "() { (String) -> ToStr } -> self", + assert_send_type "() { (String) -> ToStr } -> String", "\x81", :scrub! do |s| ToStr.new("*") end end @@ -1228,25 +1228,25 @@ def test_split "a b c", :split, ToStr.new(" "), ToInt.new(2) assert_send_type "(Regexp, ToInt) -> Array[String]", "a b c", :split, / /, ToInt.new(2) - assert_send_type "() { (String) -> void } -> self", + assert_send_type "() { (String) -> void } -> String", "a b c", :split do |str| str end - assert_send_type "(String) { (String) -> void } -> self", + assert_send_type "(String) { (String) -> void } -> String", "a b c", :split, " " do |str| str end - assert_send_type "(ToStr) { (String) -> void } -> self", + assert_send_type "(ToStr) { (String) -> void } -> String", "a b c", :split, ToStr.new(" ") do |str| str end - assert_send_type "(Regexp) { (String) -> void } -> self", + assert_send_type "(Regexp) { (String) -> void } -> String", "a b c", :split, / / do |str| str end - assert_send_type "(String, Integer) { (String) -> void } -> self", + assert_send_type "(String, Integer) { (String) -> void } -> String", "a b c", :split, " ", 2 do |str| str end - assert_send_type "(ToStr, Integer) { (String) -> void } -> self", + assert_send_type "(ToStr, Integer) { (String) -> void } -> String", "a b c", :split, ToStr.new(" "), 2 do |str| str end - assert_send_type "(Regexp, Integer) { (String) -> void } -> self", + assert_send_type "(Regexp, Integer) { (String) -> void } -> String", "a b c", :split, / /, 2 do |str| str end - assert_send_type "(String, ToInt) { (String) -> void } -> self", + assert_send_type "(String, ToInt) { (String) -> void } -> String", "a b c", :split, " ", ToInt.new(2) do |str| str end - assert_send_type "(ToStr, ToInt) { (String) -> void } -> self", + assert_send_type "(ToStr, ToInt) { (String) -> void } -> String", "a b c", :split, ToStr.new(" "), ToInt.new(2) do |str| str end - assert_send_type "(Regexp, ToInt) { (String) -> void } -> self", + assert_send_type "(Regexp, ToInt) { (String) -> void } -> String", "a b c", :split, / /, ToInt.new(2) do |str| str end end @@ -1264,15 +1264,15 @@ def test_squeeze end def test_squeeze! - assert_send_type "() -> self", + assert_send_type "() -> String", "aa bb cc", :squeeze! - assert_send_type "(String) -> self", + assert_send_type "(String) -> String", "aa bb cc", :squeeze!, " " - assert_send_type "(ToStr) -> self", + assert_send_type "(ToStr) -> String", "aa bb cc", :squeeze!, ToStr.new(" ") - assert_send_type "(String, String) -> self", + assert_send_type "(String, String) -> String", "aa bb cc", :squeeze!, "a-z", "b" - assert_send_type "(ToStr, ToStr) -> self", + assert_send_type "(ToStr, ToStr) -> String", "aa bb cc", :squeeze!, ToStr.new("a-z"), ToStr.new("b") assert_send_type "() -> nil", "", :squeeze! @@ -1309,7 +1309,7 @@ def test_strip end def test_strip! - assert_send_type "() -> self", + assert_send_type "() -> String", " a ", :strip! assert_send_type "() -> nil", "a", :strip! @@ -1344,29 +1344,29 @@ def test_sub def test_sub! - assert_send_type "(Regexp, String) -> self", + assert_send_type "(Regexp, String) -> String", "a", :sub!, /a/, "a" - assert_send_type "(String, String) -> self", + assert_send_type "(String, String) -> String", "a", :sub!, "a", "a" - assert_send_type "(ToStr, String) -> self", + assert_send_type "(ToStr, String) -> String", "a", :sub!, ToStr.new("a"), "a" - assert_send_type "(Regexp, ToStr) -> self", + assert_send_type "(Regexp, ToStr) -> String", "a", :sub!, /a/, ToStr.new("a") - assert_send_type "(String, ToStr) -> self", + assert_send_type "(String, ToStr) -> String", "a", :sub!, "a", ToStr.new("a") - assert_send_type "(ToStr, ToStr) -> self", + assert_send_type "(ToStr, ToStr) -> String", "a", :sub!, ToStr.new("a"), ToStr.new("a") - assert_send_type "(Regexp, Hash[String, String]) -> self", + assert_send_type "(Regexp, Hash[String, String]) -> String", "a", :sub!, /a/, { "a" => "a" } - assert_send_type "(String, Hash[String, String]) -> self", + assert_send_type "(String, Hash[String, String]) -> String", "a", :sub!, "a", { "a" => "a" } - assert_send_type "(ToStr, Hash[String, String]) -> self", + assert_send_type "(ToStr, Hash[String, String]) -> String", "a", :sub!, ToStr.new("a"), { "a" => "a" } - assert_send_type "(Regexp) { (String) -> ToS } -> self", + assert_send_type "(Regexp) { (String) -> ToS } -> String", "a", :sub!, /a/ do |str| ToS.new(str) end - assert_send_type "(String) { (String) -> ToS } -> self", + assert_send_type "(String) { (String) -> ToS } -> String", "a", :sub!, "a" do |str| ToS.new(str) end - assert_send_type "(ToStr) { (String) -> ToS } -> self", + assert_send_type "(ToStr) { (String) -> ToS } -> String", "a", :sub!, ToStr.new("a") do |str| ToS.new(str) end assert_send_type "(Regexp, String) -> nil", "a", :sub!, /b/, "a" @@ -1400,7 +1400,7 @@ def test_succ end def test_succ! - assert_send_type "() -> self", + assert_send_type "() -> String", "", :succ! end @@ -1429,17 +1429,17 @@ def test_swapcase end def test_swapcase! - assert_send_type "() -> self", + assert_send_type "() -> String", "a", :swapcase! - assert_send_type "(Symbol) -> self", + assert_send_type "(Symbol) -> String", "a", :swapcase!, :ascii - assert_send_type "(Symbol) -> self", + assert_send_type "(Symbol) -> String", "a", :swapcase!, :lithuanian - assert_send_type "(Symbol) -> self", + assert_send_type "(Symbol) -> String", "a", :swapcase!, :turkic - assert_send_type "(Symbol, Symbol) -> self", + assert_send_type "(Symbol, Symbol) -> String", "a", :swapcase!, :lithuanian, :turkic - assert_send_type "(Symbol, Symbol) -> self", + assert_send_type "(Symbol, Symbol) -> String", "a", :swapcase!, :turkic, :lithuanian assert_send_type "() -> nil", "", :swapcase! @@ -1502,9 +1502,9 @@ def test_tr end def test_tr! - assert_send_type "(String, String) -> self", + assert_send_type "(String, String) -> String", "ruby", :tr!, "r", "j" - assert_send_type "(ToStr, ToStr) -> self", + assert_send_type "(ToStr, ToStr) -> String", "ruby", :tr!, ToStr.new("r"), ToStr.new("j") assert_send_type "(String, String) -> nil", "", :tr!, "r", "j" @@ -1520,9 +1520,9 @@ def test_tr_s end def test_tr_s! - assert_send_type "(String, String) -> self", + assert_send_type "(String, String) -> String", "ruby", :tr_s!, "r", "j" - assert_send_type "(ToStr, ToStr) -> self", + assert_send_type "(ToStr, ToStr) -> String", "ruby", :tr_s!, ToStr.new("r"), ToStr.new("j") assert_send_type "(String, String) -> nil", "", :tr_s!, "r", "j" @@ -1657,21 +1657,21 @@ def test_upcase! end def test_upto - assert_send_type "(String) -> Enumerator[String, self]", + assert_send_type "(String) -> Enumerator[String, String]", "1", :upto, "2" - assert_send_type "(String, true) -> Enumerator[String, self]", + assert_send_type "(String, true) -> Enumerator[String, String]", "1", :upto, "2", true - assert_send_type "(String, false) -> Enumerator[String, self]", + assert_send_type "(String, false) -> Enumerator[String, String]", "1", :upto, "2", false - assert_send_type "(String) { (String) -> void } -> self", + assert_send_type "(String) { (String) -> void } -> String", "1", :upto, "2" do |s| s end - assert_send_type "(String, true) { (String) -> void } -> self", + assert_send_type "(String, true) { (String) -> void } -> String", "1", :upto, "2", true do |s| s end - assert_send_type "(String, false) { (String) -> void } -> self", + assert_send_type "(String, false) { (String) -> void } -> String", "1", :upto, "2", false do |s| s end - assert_send_type "(ToStr) -> Enumerator[String, self]", + assert_send_type "(ToStr) -> Enumerator[String, String]", "1", :upto, ToStr.new("2") - assert_send_type "(ToStr) { (String) -> void } -> self", + assert_send_type "(ToStr) { (String) -> void } -> String", "1", :upto, ToStr.new("2") do |s| s end end diff --git a/test/stdlib/Struct_test.rb b/test/stdlib/Struct_test.rb index 3af71167c..1da97a631 100644 --- a/test/stdlib/Struct_test.rb +++ b/test/stdlib/Struct_test.rb @@ -1,7 +1,7 @@ require_relative "test_helper" class StructSingletonTest < Test::Unit::TestCase - include TypeAssertions + include TestHelper testing "singleton(::Struct)" @@ -16,26 +16,26 @@ def test_new with_interned :field2 do |field2| assert_send_type "(::string?, *::interned) -> singleton(Struct)", Struct, :new, classname, field1, field2 - assert_send_type "(::string?, *::interned) { (self) -> void } -> singleton(Struct)", + assert_send_type "(::string?, *::interned) { (untyped) -> void } -> singleton(Struct)", Struct, :new, classname, field1, field2 do end if Symbol === field1 # can't use `.is_a?` since `ToStr` doesn't define it. assert_send_type "(Symbol, *::interned) -> singleton(Struct)", Struct, :new, field1, field2 - assert_send_type "(Symbol, *::interned) { (self) -> void } -> singleton(Struct)", + assert_send_type "(Symbol, *::interned) { (untyped) -> void } -> singleton(Struct)", Struct, :new, field1, field2 do end end ['yes', false, nil].each do |kwinit| - assert_send_type "(::string?, *::interned, keyword_init: ::boolish?) ?{ (self) -> void } -> singleton(Struct)", + assert_send_type "(::string?, *::interned, keyword_init: ::boolish?) ?{ (untyped) -> void } -> singleton(Struct)", Struct, :new, classname, field1, field2, keyword_init: kwinit - assert_send_type "(::string?, *::interned, keyword_init: ::boolish?) ?{ (self) -> void } -> singleton(Struct)", + assert_send_type "(::string?, *::interned, keyword_init: ::boolish?) ?{ (untyped) -> void } -> singleton(Struct)", Struct, :new, classname, field1, field2, keyword_init: kwinit do end - + if Symbol === field1 # can't use `.is_a?` since `ToStr` doesn't define it. assert_send_type "(Symbol, *::interned, keyword_init: ::boolish?) -> singleton(Struct)", Struct, :new, field1, field2, keyword_init: kwinit - assert_send_type "(Symbol, *::interned, keyword_init: ::boolish?) { (self) -> void } -> singleton(Struct)", + assert_send_type "(Symbol, *::interned, keyword_init: ::boolish?) { (untyped) -> void } -> singleton(Struct)", Struct, :new, field1, field2, keyword_init: kwinit do end end end @@ -64,14 +64,13 @@ def test_keyword_init? end class StructInstanceTest < Test::Unit::TestCase - include TypeAssertions + include TestHelper testing "::Struct[Rational]" MyStruct = Struct.new(:foo, :bar) Instance = MyStruct.new(1r, 2r) - def with_index(int=1, str=:bar, &block) block.call str.to_s block.call str.to_sym @@ -131,16 +130,16 @@ def test_length end def test_each - assert_send_type "() -> Enumerator[Rational, self]", + assert_send_type "() -> Enumerator[Rational, untyped]", Instance, :each - assert_send_type "() { (Rational) -> void } -> self", + assert_send_type "() { (Rational) -> void } -> untyped", Instance, :each do end end def test_each_pair - assert_send_type "() -> Enumerator[[Symbol, Rational], self]", + assert_send_type "() -> Enumerator[[Symbol, Rational], untyped]", Instance, :each_pair - assert_send_type "() { ([Symbol, Rational]) -> void } -> self", + assert_send_type "() { ([Symbol, Rational]) -> void } -> untyped", Instance, :each_pair do end end @@ -176,7 +175,7 @@ def test_filter def test_values_at assert_send_type "() -> Array[Rational]", Instance, :values_at - + with_int 1 do |idx| assert_send_type "(*::int | ::range[::int?]) -> Array[Rational]", Instance, :values_at, idx, idx..nil @@ -210,7 +209,7 @@ def test_deconstruct_keys with_index do |idx| # Ensure that the `ToInt` variants have `hash` and `eql?` defined. def idx.hash = 0 unless defined? idx.hash - def idx.eql?(r) = false unless defined? idx.eql? + def idx.eql?(r) = false unless defined? idx.eql? assert_send_type "(Array[Struct::index & Hash::_Key]) -> Hash[Struct::index & Hash::_Key, Rational]", Instance, :deconstruct_keys, [idx] diff --git a/test/stdlib/Symbol_test.rb b/test/stdlib/Symbol_test.rb index 5b226fe65..6122ef173 100644 --- a/test/stdlib/Symbol_test.rb +++ b/test/stdlib/Symbol_test.rb @@ -1,7 +1,7 @@ require_relative "test_helper" class SymbolSingletonTest < Test::Unit::TestCase - include TypeAssertions + include TestHelper testing "singleton(::Symbol)" @@ -12,7 +12,7 @@ def test_all_symbols end class SymbolInstanceTest < Test::Unit::TestCase - include TypeAssertions + include TestHelper testing "::Symbol" diff --git a/test/stdlib/TSort_test.rb b/test/stdlib/TSort_test.rb index 5c18a9c10..277de4ccf 100644 --- a/test/stdlib/TSort_test.rb +++ b/test/stdlib/TSort_test.rb @@ -3,7 +3,7 @@ require "tsort" class TSortSingletonTest < Test::Unit::TestCase - include TypeAssertions + include TestHelper library 'tsort' testing "singleton(::TSort)" @@ -80,7 +80,7 @@ def test_tsort_each end class TSortInstanceTest < Test::Unit::TestCase - include TypeAssertions + include TestHelper library 'tsort' testing "::TSort[::Integer]" diff --git a/test/stdlib/ThreadGroup_test.rb b/test/stdlib/ThreadGroup_test.rb index 1ae914094..2fa1db293 100644 --- a/test/stdlib/ThreadGroup_test.rb +++ b/test/stdlib/ThreadGroup_test.rb @@ -1,7 +1,7 @@ require_relative "test_helper" class ThreadGroupInstanceTest < Test::Unit::TestCase - include TypeAssertions + include TestHelper testing "::ThreadGroup" @@ -11,14 +11,14 @@ def test_Default def test_add thr = Thread.new{} - assert_send_type '(Thread) -> self', + assert_send_type '(Thread) -> ::ThreadGroup', ThreadGroup.new, :add, thr ensure thr.kill end def test_enclose - assert_send_type '() -> self', + assert_send_type '() -> ::ThreadGroup', ThreadGroup.new, :enclose end diff --git a/test/stdlib/Thread_Backtrace_Location_test.rb b/test/stdlib/Thread_Backtrace_Location_test.rb index 79cc6edd2..d3a78f77e 100644 --- a/test/stdlib/Thread_Backtrace_Location_test.rb +++ b/test/stdlib/Thread_Backtrace_Location_test.rb @@ -1,7 +1,7 @@ require_relative "test_helper" class Thread::Backtrace::LocationTest < Test::Unit::TestCase - include TypeAssertions + include TestHelper testing "::Thread::Backtrace::Location" diff --git a/test/stdlib/Thread_Backtrace_test.rb b/test/stdlib/Thread_Backtrace_test.rb index 57224b5a7..f9210514d 100644 --- a/test/stdlib/Thread_Backtrace_test.rb +++ b/test/stdlib/Thread_Backtrace_test.rb @@ -1,7 +1,7 @@ require_relative "test_helper" class Thread::BacktraceSingletonTest < Test::Unit::TestCase - include TypeAssertions + include TestHelper testing "singleton(::Thread::Backtrace)" diff --git a/test/stdlib/Thread_test.rb b/test/stdlib/Thread_test.rb index ac9bd6bfd..677f0c343 100644 --- a/test/stdlib/Thread_test.rb +++ b/test/stdlib/Thread_test.rb @@ -1,7 +1,7 @@ require_relative "test_helper" class ThreadSingletonTest < Test::Unit::TestCase - include TypeAssertions + include TestHelper testing "singleton(::Thread)" @@ -33,7 +33,7 @@ def test_each_caller_location end class ThreadTest < Test::Unit::TestCase - include TypeAssertions + include TestHelper testing "::Thread" diff --git a/test/stdlib/TimeExtension_test.rb b/test/stdlib/TimeExtension_test.rb index 29139096e..4eabb593b 100644 --- a/test/stdlib/TimeExtension_test.rb +++ b/test/stdlib/TimeExtension_test.rb @@ -2,7 +2,7 @@ require "time" class TimeExtensionSingletonTest < Test::Unit::TestCase - include TypeAssertions + include TestHelper library "time" testing "singleton(::Time)" @@ -83,7 +83,7 @@ def test_iso8601 end class TimeExtensionInstanceTest < Test::Unit::TestCase - include TypeAssertions + include TestHelper library "time" testing "::Time" diff --git a/test/stdlib/Time_test.rb b/test/stdlib/Time_test.rb index fc608937b..9dcda2094 100644 --- a/test/stdlib/Time_test.rb +++ b/test/stdlib/Time_test.rb @@ -270,7 +270,7 @@ def test_ceil end class TimeSingletonTest < Test::Unit::TestCase - include TypeAssertions + include TestHelper testing "singleton(::Time)" def test_now @@ -344,7 +344,7 @@ def test_new end class TimeInDateTest < Test::Unit::TestCase - include TypeAssertions + include TestHelper require "date" diff --git a/test/stdlib/Timeout_test.rb b/test/stdlib/Timeout_test.rb index 9294d4c18..b8a8ddb2f 100644 --- a/test/stdlib/Timeout_test.rb +++ b/test/stdlib/Timeout_test.rb @@ -3,7 +3,7 @@ require "bigdecimal" class TimeoutSingletonTest < Test::Unit::TestCase - include TypeAssertions + include TestHelper library "timeout" testing "singleton(::Timeout)" diff --git a/test/stdlib/TracePoint_test.rb b/test/stdlib/TracePoint_test.rb index db1ca0956..7bd813c16 100644 --- a/test/stdlib/TracePoint_test.rb +++ b/test/stdlib/TracePoint_test.rb @@ -1,7 +1,7 @@ require_relative "test_helper" class TracePointSingletonTest < Test::Unit::TestCase - include TypeAssertions + include TestHelper testing "singleton(::TracePoint)" @@ -28,7 +28,7 @@ def test_trace end class TracePointTest < Test::Unit::TestCase - include TypeAssertions + include TestHelper testing "::TracePoint" diff --git a/test/stdlib/TrueClass_test.rb b/test/stdlib/TrueClass_test.rb index 16f469347..5d84fac17 100644 --- a/test/stdlib/TrueClass_test.rb +++ b/test/stdlib/TrueClass_test.rb @@ -1,7 +1,7 @@ require_relative "test_helper" class TrueClassInstanceTest < Test::Unit::TestCase - include TypeAssertions + include TestHelper testing '::TrueClass' diff --git a/test/stdlib/URI_test.rb b/test/stdlib/URI_test.rb index fc2131b08..6c967431c 100644 --- a/test/stdlib/URI_test.rb +++ b/test/stdlib/URI_test.rb @@ -2,7 +2,7 @@ require "uri" class URISingletonTest < Test::Unit::TestCase - include TypeAssertions + include TestHelper library "uri" testing "singleton(::URI)" @@ -119,7 +119,7 @@ def test_kernel end class URIInstanceTest < Test::Unit::TestCase - include TypeAssertions + include TestHelper library "uri" testing "::URI::Generic" diff --git a/test/stdlib/UnboundMethod_test.rb b/test/stdlib/UnboundMethod_test.rb index 4b2ad2c2b..69d4e1417 100644 --- a/test/stdlib/UnboundMethod_test.rb +++ b/test/stdlib/UnboundMethod_test.rb @@ -1,7 +1,7 @@ require_relative 'test_helper' class UnboundMethodInstanceTest < Test::Unit::TestCase - include TypeAssertions + include TestHelper testing '::UnboundMethod' @@ -36,7 +36,7 @@ def test_hash end def test_clone - assert_send_type '() -> instance', + assert_send_type '() -> ::UnboundMethod', UMETH, :clone end @@ -83,7 +83,7 @@ def test_parameters ParamMeths.instance_method(:tailing_ddd), :parameters assert_send_type '() -> ::Method::param_types', ParamMeths.instance_method(:no_kwargs), :parameters - + omit_if(RUBY_VERSION < '3.1') assert_send_type '() -> ::Method::param_types', diff --git a/test/stdlib/Warning_test.rb b/test/stdlib/Warning_test.rb index a5483fabd..901a8e197 100644 --- a/test/stdlib/Warning_test.rb +++ b/test/stdlib/Warning_test.rb @@ -4,7 +4,7 @@ WARNING_CATEGORIES << :performance if RUBY_VERSION >= '3.3' class WarningSingletonTest < Test::Unit::TestCase - include TypeAssertions + include TestHelper testing "singleton(::Warning)" @@ -36,7 +36,7 @@ def test_aset end class WarningTest < Test::Unit::TestCase - include TypeAssertions + include TestHelper testing "::Warning" diff --git a/test/stdlib/Zlib_test.rb b/test/stdlib/Zlib_test.rb index 0484b49e0..d7b35277d 100644 --- a/test/stdlib/Zlib_test.rb +++ b/test/stdlib/Zlib_test.rb @@ -2,7 +2,7 @@ require "zlib" class ZlibSingletonTest < Test::Unit::TestCase - include TypeAssertions + include TestHelper library "zlib" testing "singleton(::Zlib)" diff --git a/test/stdlib/constants_test.rb b/test/stdlib/constants_test.rb index 097731502..5a9ec1ae1 100644 --- a/test/stdlib/constants_test.rb +++ b/test/stdlib/constants_test.rb @@ -8,7 +8,7 @@ module Unnamed end class ConstantsTest < Test::Unit::TestCase - include TypeAssertions + include TestHelper testing 'singleton(Object)' diff --git a/test/stdlib/did_you_mean/DidYouMean_test.rb b/test/stdlib/did_you_mean/DidYouMean_test.rb index ef36094b3..a727b7510 100644 --- a/test/stdlib/did_you_mean/DidYouMean_test.rb +++ b/test/stdlib/did_you_mean/DidYouMean_test.rb @@ -1,7 +1,7 @@ require_relative "../test_helper" class DidYouMean::CorrectableTest < Test::Unit::TestCase - include TypeAssertions + include TestHelper library "did_you_mean" testing "::DidYouMean::Correctable" @@ -14,7 +14,7 @@ def test_corrections end class DidYouMean::FormatterSingletonTest < Test::Unit::TestCase - include TypeAssertions + include TestHelper library "did_you_mean" testing "singleton(::DidYouMean::Formatter)" @@ -26,7 +26,7 @@ def test_message_for end class DidYouMean::JaroSingletonTest < Test::Unit::TestCase - include TypeAssertions + include TestHelper library "did_you_mean" testing "singleton(::DidYouMean::Jaro)" @@ -38,7 +38,7 @@ def test_distance end class DidYouMean::JaroTest < Test::Unit::TestCase - include TypeAssertions + include TestHelper library "did_you_mean" testing "::DidYouMean::Jaro" @@ -51,7 +51,7 @@ def test_distance end class DidYouMean::JaroWinklerSingletonTest < Test::Unit::TestCase - include TypeAssertions + include TestHelper library "did_you_mean" testing "singleton(::DidYouMean::JaroWinkler)" @@ -63,7 +63,7 @@ def test_distance end class DidYouMean::JaroWinklerTest < Test::Unit::TestCase - include TypeAssertions + include TestHelper library "did_you_mean" testing "::DidYouMean::JaroWinkler" @@ -76,7 +76,7 @@ def test_distance end class DidYouMean::KeyErrorCheckerSingletonTest < Test::Unit::TestCase - include TypeAssertions + include TestHelper library "did_you_mean" testing "singleton(::DidYouMean::KeyErrorChecker)" @@ -88,7 +88,7 @@ def test_initialize end class DidYouMean::KeyErrorCheckerTest < Test::Unit::TestCase - include TypeAssertions + include TestHelper library "did_you_mean" testing "::DidYouMean::KeyErrorChecker" @@ -100,7 +100,7 @@ def test_corrections end class DidYouMean::LevenshteinSingletonTest < Test::Unit::TestCase - include TypeAssertions + include TestHelper library "did_you_mean" testing "singleton(::DidYouMean::Levenshtein)" @@ -112,7 +112,7 @@ def test_distance end class DidYouMean::LevenshteinTest < Test::Unit::TestCase - include TypeAssertions + include TestHelper library "did_you_mean" testing "::DidYouMean::Levenshtein" @@ -125,7 +125,7 @@ def test_distance end class DidYouMean::MethodNameCheckerSingletonTest < Test::Unit::TestCase - include TypeAssertions + include TestHelper library "did_you_mean" testing "singleton(::DidYouMean::MethodNameChecker)" @@ -137,7 +137,7 @@ def test_new end class DidYouMean::MethodNameCheckerTest < Test::Unit::TestCase - include TypeAssertions + include TestHelper library "did_you_mean" testing "::DidYouMean::MethodNameChecker" @@ -149,7 +149,7 @@ def test_corrections end class DidYouMean::NullCheckerSingletonTest < Test::Unit::TestCase - include TypeAssertions + include TestHelper library "did_you_mean" testing "singleton(::DidYouMean::NullChecker)" @@ -161,7 +161,7 @@ def test_new end class DidYouMean::NullCheckerTest < Test::Unit::TestCase - include TypeAssertions + include TestHelper library "did_you_mean" testing "::DidYouMean::NullChecker" @@ -173,7 +173,7 @@ def test_corrections end class DidYouMean::PatternKeyNameCheckerSingletonTest < Test::Unit::TestCase - include TypeAssertions + include TestHelper library "did_you_mean" testing "singleton(::DidYouMean::PatternKeyNameChecker)" @@ -186,7 +186,7 @@ def test_new end class DidYouMean::PatternKeyNameCheckerTest < Test::Unit::TestCase - include TypeAssertions + include TestHelper library "did_you_mean" testing "::DidYouMean::PatternKeyNameChecker" @@ -199,7 +199,7 @@ def test_corrections end class DidYouMean::RequirePathCheckerSingletonTest < Test::Unit::TestCase - include TypeAssertions + include TestHelper library "did_you_mean" testing "singleton(::DidYouMean::RequirePathChecker)" @@ -217,7 +217,7 @@ def test_requireables end class DidYouMean::RequirePathCheckerTest < Test::Unit::TestCase - include TypeAssertions + include TestHelper library "did_you_mean" testing "::DidYouMean::RequirePathChecker" @@ -230,7 +230,7 @@ def test_corrections end class DidYouMean::SpellCheckerSingletonTest < Test::Unit::TestCase - include TypeAssertions + include TestHelper library "did_you_mean" testing "singleton(::DidYouMean::SpellChecker)" @@ -242,7 +242,7 @@ def test_new end class DidYouMean::SpellCheckerTest < Test::Unit::TestCase - include TypeAssertions + include TestHelper library "did_you_mean" testing "::DidYouMean::SpellChecker" @@ -254,7 +254,7 @@ def test_correct end class DidYouMean::TreeSpellCheckerSingletonTest < Test::Unit::TestCase - include TypeAssertions + include TestHelper library "did_you_mean" testing "singleton(::DidYouMean::TreeSpellChecker)" @@ -266,7 +266,7 @@ def test_new end class DidYouMean::TreeSpellCheckerTest < Test::Unit::TestCase - include TypeAssertions + include TestHelper library "did_you_mean" testing "::DidYouMean::TreeSpellChecker" @@ -278,7 +278,7 @@ def test_correct end class DidYouMean::VariableNameCheckerSingletonTest < Test::Unit::TestCase - include TypeAssertions + include TestHelper library "did_you_mean" testing "singleton(::DidYouMean::VariableNameChecker)" @@ -290,7 +290,7 @@ def test_new end class DidYouMean::VariableNameCheckerTest < Test::Unit::TestCase - include TypeAssertions + include TestHelper library "did_you_mean" testing "::DidYouMean::VariableNameChecker" diff --git a/test/stdlib/digest/DigestMD5_test.rb b/test/stdlib/digest/DigestMD5_test.rb index d1057bbe6..1e6e54c48 100644 --- a/test/stdlib/digest/DigestMD5_test.rb +++ b/test/stdlib/digest/DigestMD5_test.rb @@ -3,7 +3,7 @@ require 'digest/bubblebabble' class DigestMD5SingletonTest < Test::Unit::TestCase - include TypeAssertions + include TestHelper library 'digest' testing 'singleton(::Digest::MD5)' @@ -35,13 +35,13 @@ def test_hexdigest end class DigestMD5InstanceTest < Test::Unit::TestCase - include TypeAssertions + include TestHelper library 'digest' testing '::Digest::MD5' def test_left_shift - assert_send_type '(::String) -> self', + assert_send_type '(::String) -> Digest::MD5', ::Digest::MD5.new, :<<, '_binary_left_shift_' end @@ -56,12 +56,12 @@ def test_digest_length end def test_reset - assert_send_type '() -> self', + assert_send_type '() -> Digest::MD5', ::Digest::MD5.new, :reset end def test_update - assert_send_type '(::String) -> self', + assert_send_type '(::String) -> Digest::MD5', ::Digest::MD5.new, :update, '_update_' end @@ -71,7 +71,7 @@ def test_finish end def test_initialize_copy - assert_send_type '(::Digest::Base) -> self', + assert_send_type '(::Digest::Base) -> Digest::MD5', ::Digest::MD5.new, :initialize_copy, ::Digest::MD5.new end @@ -118,7 +118,7 @@ def test_digest_bang end def test_file - assert_send_type '(::String) -> self', + assert_send_type '(::String) -> Digest::MD5', ::Digest::MD5.new, :file, 'README.md' end diff --git a/test/stdlib/digest/DigestRMD160_test.rb b/test/stdlib/digest/DigestRMD160_test.rb index 276fef368..7ab85a8b1 100644 --- a/test/stdlib/digest/DigestRMD160_test.rb +++ b/test/stdlib/digest/DigestRMD160_test.rb @@ -3,7 +3,7 @@ require 'digest/bubblebabble' class DigestRMD160SingletonTest < Test::Unit::TestCase - include TypeAssertions + include TestHelper library 'digest' testing 'singleton(::Digest::RMD160)' @@ -35,13 +35,13 @@ def test_hexdigest end class DigestRMD160InstanceTest < Test::Unit::TestCase - include TypeAssertions + include TestHelper library 'digest' testing '::Digest::RMD160' def test_left_shift - assert_send_type '(::String) -> self', + assert_send_type '(::String) -> Digest::RMD160', ::Digest::RMD160.new, :<<, '_binary_left_shift_' end @@ -56,12 +56,12 @@ def test_digest_length end def test_reset - assert_send_type '() -> self', + assert_send_type '() -> Digest::RMD160', ::Digest::RMD160.new, :reset end def test_update - assert_send_type '(::String) -> self', + assert_send_type '(::String) -> Digest::RMD160', ::Digest::RMD160.new, :update, '_update_' end @@ -71,7 +71,7 @@ def test_finish end def test_initialize_copy - assert_send_type '(::Digest::Base) -> self', + assert_send_type '(::Digest::Base) -> Digest::RMD160', ::Digest::RMD160.new, :initialize_copy, ::Digest::RMD160.new end @@ -118,7 +118,7 @@ def test_digest_bang end def test_file - assert_send_type '(::String) -> self', + assert_send_type '(::String) -> Digest::RMD160', ::Digest::RMD160.new, :file, 'README.md' end diff --git a/test/stdlib/digest/DigestSHA1_test.rb b/test/stdlib/digest/DigestSHA1_test.rb index 7d8af8024..979166a6b 100644 --- a/test/stdlib/digest/DigestSHA1_test.rb +++ b/test/stdlib/digest/DigestSHA1_test.rb @@ -3,7 +3,7 @@ require 'digest/bubblebabble' class DigestSHA1SingletonTest < Test::Unit::TestCase - include TypeAssertions + include TestHelper library 'digest' testing 'singleton(::Digest::SHA1)' @@ -35,13 +35,13 @@ def test_hexdigest end class DigestSHA1InstanceTest < Test::Unit::TestCase - include TypeAssertions + include TestHelper library 'digest' testing '::Digest::SHA1' def test_left_shift - assert_send_type '(::String) -> self', + assert_send_type '(::String) -> Digest::SHA1', ::Digest::SHA1.new, :<<, '_binary_left_shift_' end @@ -56,12 +56,12 @@ def test_digest_length end def test_reset - assert_send_type '() -> self', + assert_send_type '() -> Digest::SHA1', ::Digest::SHA1.new, :reset end def test_update - assert_send_type '(::String) -> self', + assert_send_type '(::String) -> Digest::SHA1', ::Digest::SHA1.new, :update, '_update_' end @@ -71,7 +71,7 @@ def test_finish end def test_initialize_copy - assert_send_type '(::Digest::Base) -> self', + assert_send_type '(::Digest::Base) -> Digest::SHA1', ::Digest::SHA1.new, :initialize_copy, ::Digest::SHA1.new end @@ -118,7 +118,7 @@ def test_digest_bang end def test_file - assert_send_type '(::String) -> self', + assert_send_type '(::String) -> Digest::SHA1', ::Digest::SHA1.new, :file, 'README.md' end diff --git a/test/stdlib/digest/DigestSHA256_test.rb b/test/stdlib/digest/DigestSHA256_test.rb index 75eb24a3d..1d0a15eba 100644 --- a/test/stdlib/digest/DigestSHA256_test.rb +++ b/test/stdlib/digest/DigestSHA256_test.rb @@ -3,7 +3,7 @@ require 'digest/bubblebabble' class DigestSHA256SingletonTest < Test::Unit::TestCase - include TypeAssertions + include TestHelper library 'digest' testing 'singleton(::Digest::SHA256)' @@ -35,13 +35,13 @@ def test_hexdigest end class DigestSHA256InstanceTest < Test::Unit::TestCase - include TypeAssertions + include TestHelper library 'digest' testing '::Digest::SHA256' def test_left_shift - assert_send_type '(::String) -> self', + assert_send_type '(::String) -> Digest::SHA256', ::Digest::SHA256.new, :<<, '_binary_left_shift_' end @@ -56,12 +56,12 @@ def test_digest_length end def test_reset - assert_send_type '() -> self', + assert_send_type '() -> Digest::SHA256', ::Digest::SHA256.new, :reset end def test_update - assert_send_type '(::String) -> self', + assert_send_type '(::String) -> Digest::SHA256', ::Digest::SHA256.new, :update, '_update_' end @@ -71,7 +71,7 @@ def test_finish end def test_initialize_copy - assert_send_type '(::Digest::Base) -> self', + assert_send_type '(::Digest::Base) -> Digest::SHA256', ::Digest::SHA256.new, :initialize_copy, ::Digest::SHA256.new end @@ -118,7 +118,7 @@ def test_digest_bang end def test_file - assert_send_type '(::String) -> self', + assert_send_type '(::String) -> Digest::SHA256', ::Digest::SHA256.new, :file, 'README.md' end diff --git a/test/stdlib/digest/DigestSHA384_test.rb b/test/stdlib/digest/DigestSHA384_test.rb index 922b6b89e..894572230 100644 --- a/test/stdlib/digest/DigestSHA384_test.rb +++ b/test/stdlib/digest/DigestSHA384_test.rb @@ -3,7 +3,7 @@ require 'digest/bubblebabble' class DigestSHA384SingletonTest < Test::Unit::TestCase - include TypeAssertions + include TestHelper library 'digest' testing 'singleton(::Digest::SHA384)' @@ -35,13 +35,13 @@ def test_hexdigest end class DigestSHA384InstanceTest < Test::Unit::TestCase - include TypeAssertions + include TestHelper library 'digest' testing '::Digest::SHA384' def test_left_shift - assert_send_type '(::String) -> self', + assert_send_type '(::String) -> Digest::SHA384', ::Digest::SHA384.new, :<<, '_binary_left_shift_' end @@ -56,12 +56,12 @@ def test_digest_length end def test_reset - assert_send_type '() -> self', + assert_send_type '() -> Digest::SHA384', ::Digest::SHA384.new, :reset end def test_update - assert_send_type '(::String) -> self', + assert_send_type '(::String) -> Digest::SHA384', ::Digest::SHA384.new, :update, '_update_' end @@ -71,7 +71,7 @@ def test_finish end def test_initialize_copy - assert_send_type '(::Digest::Base) -> self', + assert_send_type '(::Digest::Base) -> Digest::SHA384', ::Digest::SHA384.new, :initialize_copy, ::Digest::SHA384.new end @@ -118,7 +118,7 @@ def test_digest_bang end def test_file - assert_send_type '(::String) -> self', + assert_send_type '(::String) -> Digest::SHA384', ::Digest::SHA384.new, :file, 'README.md' end diff --git a/test/stdlib/digest/DigestSHA512_test.rb b/test/stdlib/digest/DigestSHA512_test.rb index da33f449e..97c287fb6 100644 --- a/test/stdlib/digest/DigestSHA512_test.rb +++ b/test/stdlib/digest/DigestSHA512_test.rb @@ -3,7 +3,7 @@ require 'digest/bubblebabble' class DigestSHA512SingletonTest < Test::Unit::TestCase - include TypeAssertions + include TestHelper library 'digest' testing 'singleton(::Digest::SHA512)' @@ -35,13 +35,13 @@ def test_hexdigest end class DigestSHA512InstanceTest < Test::Unit::TestCase - include TypeAssertions + include TestHelper library 'digest' testing '::Digest::SHA512' def test_left_shift - assert_send_type '(::String) -> self', + assert_send_type '(::String) -> Digest::SHA512', ::Digest::SHA512.new, :<<, '_binary_left_shift_' end @@ -56,12 +56,12 @@ def test_digest_length end def test_reset - assert_send_type '() -> self', + assert_send_type '() -> Digest::SHA512', ::Digest::SHA512.new, :reset end def test_update - assert_send_type '(::String) -> self', + assert_send_type '(::String) -> Digest::SHA512', ::Digest::SHA512.new, :update, '_update_' end @@ -71,7 +71,7 @@ def test_finish end def test_initialize_copy - assert_send_type '(::Digest::Base) -> self', + assert_send_type '(::Digest::Base) -> Digest::SHA512', ::Digest::SHA512.new, :initialize_copy, ::Digest::SHA512.new end @@ -118,7 +118,7 @@ def test_digest_bang end def test_file - assert_send_type '(::String) -> self', + assert_send_type '(::String) -> Digest::SHA512', ::Digest::SHA512.new, :file, 'README.md' end diff --git a/test/stdlib/digest/Digest_test.rb b/test/stdlib/digest/Digest_test.rb index af3e21d76..20b114611 100644 --- a/test/stdlib/digest/Digest_test.rb +++ b/test/stdlib/digest/Digest_test.rb @@ -3,7 +3,7 @@ require 'digest/bubblebabble' class DigestSingletonTest < Test::Unit::TestCase - include TypeAssertions + include TestHelper library 'digest' testing 'singleton(::Digest)' @@ -41,7 +41,7 @@ def test_hexencode end class DigestInstanceTest < Test::Unit::TestCase - include TypeAssertions + include TestHelper library 'digest' testing '::Digest' @@ -60,7 +60,7 @@ def test_hexencode end class DigestRootTest < Test::Unit::TestCase - include TypeAssertions + include TestHelper library 'digest' testing '::Object' diff --git a/test/stdlib/enumerator/Product_test.rb b/test/stdlib/enumerator/Product_test.rb index b8430d5f0..f2ab279e8 100644 --- a/test/stdlib/enumerator/Product_test.rb +++ b/test/stdlib/enumerator/Product_test.rb @@ -1,7 +1,7 @@ require_relative "../test_helper" class EnumeratorProductInstanceTest < Test::Unit::TestCase - include TypeAssertions + include TestHelper testing "::Enumerator::Product[::Integer | ::String]" @@ -34,7 +34,7 @@ def test_size end class EnumeratorProductSingletonTest < Test::Unit::TestCase - include TypeAssertions + include TestHelper testing "singleton(::Enumerator::Product)" diff --git a/test/stdlib/io/Buffer_test.rb b/test/stdlib/io/Buffer_test.rb index c0fffd092..c40af2013 100644 --- a/test/stdlib/io/Buffer_test.rb +++ b/test/stdlib/io/Buffer_test.rb @@ -1,7 +1,7 @@ require_relative "../test_helper" class IO_Buffer_SingletonTest < Test::Unit::TestCase - include TypeAssertions + include TestHelper testing "singleton(::IO::Buffer)" def test_for @@ -36,7 +36,7 @@ def test_new end class IO_Buffer_InstanceTest < Test::Unit::TestCase - include TypeAssertions + include TestHelper testing "::IO::Buffer" def test_spaceship diff --git a/test/stdlib/json/JSONBigDecimal_test.rb b/test/stdlib/json/JSONBigDecimal_test.rb index 325c5888d..35a1564d5 100644 --- a/test/stdlib/json/JSONBigDecimal_test.rb +++ b/test/stdlib/json/JSONBigDecimal_test.rb @@ -3,7 +3,7 @@ require "json/add/bigdecimal" class JSONBigDecimalSingletonTest < Test::Unit::TestCase - include TypeAssertions + include TestHelper library "json" testing "singleton(::BigDecimal)" @@ -15,7 +15,7 @@ def test_json_create end class JSONBigDecimalInstanceTest < Test::Unit::TestCase - include TypeAssertions + include TestHelper library "json" testing "::BigDecimal" diff --git a/test/stdlib/json/JSONComplex_test.rb b/test/stdlib/json/JSONComplex_test.rb index 0f8d8b80f..b29ed8881 100644 --- a/test/stdlib/json/JSONComplex_test.rb +++ b/test/stdlib/json/JSONComplex_test.rb @@ -3,7 +3,7 @@ require "json/add/complex" class JSONComplexSingletonTest < Test::Unit::TestCase - include TypeAssertions + include TestHelper library "json" testing "singleton(::Complex)" @@ -15,7 +15,7 @@ def test_json_create end class JSONComplexInstanceTest < Test::Unit::TestCase - include TypeAssertions + include TestHelper library "json" testing "::Complex" diff --git a/test/stdlib/json/JSONDateTime_test.rb b/test/stdlib/json/JSONDateTime_test.rb index 4f18ddb00..bc5fd22e6 100644 --- a/test/stdlib/json/JSONDateTime_test.rb +++ b/test/stdlib/json/JSONDateTime_test.rb @@ -3,7 +3,7 @@ require "json/add/date_time" class JSONDateTimeSingletonTest < Test::Unit::TestCase - include TypeAssertions + include TestHelper library "json" testing "singleton(::DateTime)" @@ -15,7 +15,7 @@ def test_json_create end class JSONDateTimeInstanceTest < Test::Unit::TestCase - include TypeAssertions + include TestHelper library "json" testing "::DateTime" diff --git a/test/stdlib/json/JSONDate_test.rb b/test/stdlib/json/JSONDate_test.rb index 6f99ee272..d656c12b4 100644 --- a/test/stdlib/json/JSONDate_test.rb +++ b/test/stdlib/json/JSONDate_test.rb @@ -3,7 +3,7 @@ require "json/add/date" class JSONDateSingletonTest < Test::Unit::TestCase - include TypeAssertions + include TestHelper library "json" testing "singleton(::Date)" @@ -15,7 +15,7 @@ def test_json_create end class JSONDateInstanceTest < Test::Unit::TestCase - include TypeAssertions + include TestHelper library "json" testing "::Date" diff --git a/test/stdlib/json/JSONException_test.rb b/test/stdlib/json/JSONException_test.rb index 5680a6b92..40198aefb 100644 --- a/test/stdlib/json/JSONException_test.rb +++ b/test/stdlib/json/JSONException_test.rb @@ -3,7 +3,7 @@ require "json/add/exception" class JSONExceptionSingletonTest < Test::Unit::TestCase - include TypeAssertions + include TestHelper library "json" testing "singleton(::Exception)" @@ -22,7 +22,7 @@ def test_json_create_with_backtrace end class JSONExceptionInstanceTest < Test::Unit::TestCase - include TypeAssertions + include TestHelper library "json" testing "::Exception" diff --git a/test/stdlib/json/JSONKernel_test.rb b/test/stdlib/json/JSONKernel_test.rb index b1686fb76..d5ac73aa3 100644 --- a/test/stdlib/json/JSONKernel_test.rb +++ b/test/stdlib/json/JSONKernel_test.rb @@ -2,7 +2,7 @@ require "json" class JSONKernelInstanceTest < Test::Unit::TestCase - include TypeAssertions + include TestHelper library "json" testing "::Kernel" diff --git a/test/stdlib/json/JSONOpenStruct_test.rb b/test/stdlib/json/JSONOpenStruct_test.rb index cb61df906..a594dd265 100644 --- a/test/stdlib/json/JSONOpenStruct_test.rb +++ b/test/stdlib/json/JSONOpenStruct_test.rb @@ -3,7 +3,7 @@ require "json/add/ostruct" class JSONOpenStructSingletonTest < Test::Unit::TestCase - include TypeAssertions + include TestHelper library "json" testing "singleton(::OpenStruct)" @@ -15,7 +15,7 @@ def test_json_create end class JSONOpenStructInstanceTest < Test::Unit::TestCase - include TypeAssertions + include TestHelper library "json" testing "::OpenStruct" diff --git a/test/stdlib/json/JSONRange_test.rb b/test/stdlib/json/JSONRange_test.rb index 7210b7d14..d3a5d580b 100644 --- a/test/stdlib/json/JSONRange_test.rb +++ b/test/stdlib/json/JSONRange_test.rb @@ -3,7 +3,7 @@ require "json/add/range" class JSONRangeSingletonTest < Test::Unit::TestCase - include TypeAssertions + include TestHelper library "json" testing "singleton(::Range)" @@ -15,7 +15,7 @@ def test_json_create end class JSONRangeInstanceTest < Test::Unit::TestCase - include TypeAssertions + include TestHelper library "json" testing "::Range[Integer]" diff --git a/test/stdlib/json/JSONRational_test.rb b/test/stdlib/json/JSONRational_test.rb index ea4768f69..105dffa64 100644 --- a/test/stdlib/json/JSONRational_test.rb +++ b/test/stdlib/json/JSONRational_test.rb @@ -3,7 +3,7 @@ require "json/add/rational" class JSONRationalSingletonTest < Test::Unit::TestCase - include TypeAssertions + include TestHelper library "json" testing "singleton(::Rational)" @@ -15,7 +15,7 @@ def test_json_create end class JSONRationalInstanceTest < Test::Unit::TestCase - include TypeAssertions + include TestHelper library "json" testing "::Rational" diff --git a/test/stdlib/json/JSONRegexp_test.rb b/test/stdlib/json/JSONRegexp_test.rb index 7ada2ad70..f95e358bb 100644 --- a/test/stdlib/json/JSONRegexp_test.rb +++ b/test/stdlib/json/JSONRegexp_test.rb @@ -3,7 +3,7 @@ require "json/add/regexp" class JSONRegexpSingletonTest < Test::Unit::TestCase - include TypeAssertions + include TestHelper library "json" testing "singleton(::Regexp)" @@ -15,7 +15,7 @@ def test_json_create end class JSONRegexpInstanceTest < Test::Unit::TestCase - include TypeAssertions + include TestHelper library "json" testing "::Regexp" diff --git a/test/stdlib/json/JSONSet_test.rb b/test/stdlib/json/JSONSet_test.rb index f80de09c1..d24110b12 100644 --- a/test/stdlib/json/JSONSet_test.rb +++ b/test/stdlib/json/JSONSet_test.rb @@ -3,7 +3,7 @@ require "json/add/set" class JSONSetSingletonTest < Test::Unit::TestCase - include TypeAssertions + include TestHelper library "json" testing "singleton(::Set)" @@ -15,7 +15,7 @@ def test_json_create end class JSONSetInstanceTest < Test::Unit::TestCase - include TypeAssertions + include TestHelper library "json" testing "::Set[Integer]" diff --git a/test/stdlib/json/JSONStruct_test.rb b/test/stdlib/json/JSONStruct_test.rb index f21e858ca..3df06de45 100644 --- a/test/stdlib/json/JSONStruct_test.rb +++ b/test/stdlib/json/JSONStruct_test.rb @@ -3,7 +3,7 @@ require "json/add/struct" class JSONStructSingletonTest < Test::Unit::TestCase - include TypeAssertions + include TestHelper Foo = Struct.new(:a) @@ -17,7 +17,7 @@ def test_json_create end class JSONStructInstanceTest < Test::Unit::TestCase - include TypeAssertions + include TestHelper Foo = Struct.new(:a) diff --git a/test/stdlib/json/JSONSymbol_test.rb b/test/stdlib/json/JSONSymbol_test.rb index 311e3bf7b..c05afc67f 100644 --- a/test/stdlib/json/JSONSymbol_test.rb +++ b/test/stdlib/json/JSONSymbol_test.rb @@ -3,7 +3,7 @@ require "json/add/symbol" class JSONSymbolSingletonTest < Test::Unit::TestCase - include TypeAssertions + include TestHelper library "json" testing "singleton(::Symbol)" @@ -15,7 +15,7 @@ def test_json_create end class JSONSymbolInstanceTest < Test::Unit::TestCase - include TypeAssertions + include TestHelper library "json" testing "::Symbol" diff --git a/test/stdlib/json/JSONTime_test.rb b/test/stdlib/json/JSONTime_test.rb index 6d87b6411..829364e2c 100644 --- a/test/stdlib/json/JSONTime_test.rb +++ b/test/stdlib/json/JSONTime_test.rb @@ -3,7 +3,7 @@ require "json/add/time" class JSONTimeSingletonTest < Test::Unit::TestCase - include TypeAssertions + include TestHelper library "json" testing "singleton(::Time)" @@ -15,7 +15,7 @@ def test_json_create end class JSONTimeInstanceTest < Test::Unit::TestCase - include TypeAssertions + include TestHelper library "json" testing "::Time" diff --git a/test/stdlib/json/JSON_test.rb b/test/stdlib/json/JSON_test.rb index 66504f8d4..f76c56cfe 100644 --- a/test/stdlib/json/JSON_test.rb +++ b/test/stdlib/json/JSON_test.rb @@ -22,7 +22,7 @@ def to_s end class JSONSingletonTest < Test::Unit::TestCase - include TypeAssertions + include TestHelper library "json" testing "singleton(::JSON)" @@ -174,7 +174,7 @@ def test_unparse end class JSONInstanceTest < Test::Unit::TestCase - include TypeAssertions + include TestHelper class MyJSON include JSON diff --git a/test/stdlib/open-uri_test.rb b/test/stdlib/open-uri_test.rb index acc9f03c9..6387ee1d2 100644 --- a/test/stdlib/open-uri_test.rb +++ b/test/stdlib/open-uri_test.rb @@ -2,7 +2,7 @@ require "open-uri" class OpenURISingletonTest < Test::Unit::TestCase - include TypeAssertions + include TestHelper library "open-uri" testing "singleton(::URI)" diff --git a/test/stdlib/psych_test.rb b/test/stdlib/psych_test.rb index ef2c9f1a2..a7da2804d 100644 --- a/test/stdlib/psych_test.rb +++ b/test/stdlib/psych_test.rb @@ -4,7 +4,7 @@ require "tmpdir" class PsychSingletonTest < Test::Unit::TestCase - include TypeAssertions + include TestHelper library "psych" testing "singleton(::Psych)" diff --git a/test/stdlib/resolv/DNS_test.rb b/test/stdlib/resolv/DNS_test.rb index 35bb76305..e79b62b9e 100644 --- a/test/stdlib/resolv/DNS_test.rb +++ b/test/stdlib/resolv/DNS_test.rb @@ -2,7 +2,7 @@ require 'resolv' class ResolvDNSSingletonTest < Test::Unit::TestCase - include TypeAssertions + include TestHelper library 'resolv' testing 'singleton(::Resolv::DNS)' @@ -39,7 +39,7 @@ def test_random end class ResolvDNSinstanceTest < Test::Unit::TestCase - include TypeAssertions + include TestHelper library 'resolv' testing '::Resolv::DNS' @@ -158,7 +158,7 @@ def test_timeouts= end class ResolvDNSConfigSingletonTest < Test::Unit::TestCase - include TypeAssertions + include TestHelper library 'resolv' testing 'singleton(::Resolv::DNS::Config)' @@ -176,7 +176,7 @@ def test_parse_resolv_conf end class ResolvDNSConfigInstanceTest < Test::Unit::TestCase - include TypeAssertions + include TestHelper library 'resolv' testing '::Resolv::DNS::Config' @@ -221,7 +221,7 @@ def test_timeouts= end # class ResolvDNSMessageSingletonTest < Test::Unit::TestCase -# include TypeAssertions +# include TestHelper # library 'resolv' # testing 'singleton(::Resolv::DNS::Message)' @@ -232,7 +232,7 @@ def test_timeouts= # end class ResolvDNSMessageInstanceTest < Test::Unit::TestCase - include TypeAssertions + include TestHelper library 'resolv' testing '::Resolv::DNS::Message' @@ -302,7 +302,7 @@ def test_encode end class ResolvDNSMessageEncoderInstanceTest < Test::Unit::TestCase - include TypeAssertions + include TestHelper library 'resolv' testing '::Resolv::DNS::Message::MessageEncoder' @@ -352,7 +352,7 @@ def test_put_string_list end class ResolvDNSMessageDecoderInstanceTest < Test::Unit::TestCase - include TypeAssertions + include TestHelper library 'resolv' testing '::Resolv::DNS::Message::MessageDecoder' @@ -404,7 +404,7 @@ def test_get_string_list end class ResolvDNSNameInstanceTest < Test::Unit::TestCase - include TypeAssertions + include TestHelper library 'resolv' testing '::Resolv::DNS::Name' @@ -446,7 +446,7 @@ def test_subdomain_of? end class ResolvDNSLabelStrInstanceTest < Test::Unit::TestCase - include TypeAssertions + include TestHelper library 'resolv' testing '::Resolv::DNS::Label::Str' @@ -477,7 +477,7 @@ def test_hash class ResolvDNSRequesterInstanceTest < Test::Unit::TestCase - include TypeAssertions + include TestHelper library 'resolv' testing '::Resolv::DNS::Requester' @@ -492,7 +492,7 @@ def test_close end class ResolvDNSResourceGenericSigletonTest < Test::Unit::TestCase - include TypeAssertions + include TestHelper library 'resolv' testing 'singleton(::Resolv::DNS::Resource::Generic)' diff --git a/test/stdlib/resolv/Hosts_test.rb b/test/stdlib/resolv/Hosts_test.rb index b56cf5072..949f14d85 100644 --- a/test/stdlib/resolv/Hosts_test.rb +++ b/test/stdlib/resolv/Hosts_test.rb @@ -2,7 +2,7 @@ require 'resolv' class ResolvHostsInstanceTest < Test::Unit::TestCase - include TypeAssertions + include TestHelper library 'resolv' testing '::Resolv::Hosts' diff --git a/test/stdlib/resolv/IPv4_test.rb b/test/stdlib/resolv/IPv4_test.rb index a3e288bd2..7d4d5ff13 100644 --- a/test/stdlib/resolv/IPv4_test.rb +++ b/test/stdlib/resolv/IPv4_test.rb @@ -3,7 +3,7 @@ class ResolvIPv4SingletonTest < Test::Unit::TestCase - include TypeAssertions + include TestHelper library 'resolv' testing 'singleton(::Resolv::IPv4)' @@ -19,7 +19,7 @@ def test_create end class ResolvIPv4InstanceTest < Test::Unit::TestCase - include TypeAssertions + include TestHelper library 'resolv' testing '::Resolv::IPv4' diff --git a/test/stdlib/resolv/IPv6_test.rb b/test/stdlib/resolv/IPv6_test.rb index 380e9a1c5..5eedf777f 100644 --- a/test/stdlib/resolv/IPv6_test.rb +++ b/test/stdlib/resolv/IPv6_test.rb @@ -3,7 +3,7 @@ class ResolvIPv6SingletonTest < Test::Unit::TestCase - include TypeAssertions + include TestHelper library 'resolv' testing 'singleton(::Resolv::IPv6)' @@ -18,7 +18,7 @@ def test_create end class ResolvIPv6InstanceTest < Test::Unit::TestCase - include TypeAssertions + include TestHelper library 'resolv' testing '::Resolv::IPv6' diff --git a/test/stdlib/rubygems/GemRequirement_test.rb b/test/stdlib/rubygems/GemRequirement_test.rb index 50ec7c700..272578a77 100644 --- a/test/stdlib/rubygems/GemRequirement_test.rb +++ b/test/stdlib/rubygems/GemRequirement_test.rb @@ -1,7 +1,7 @@ require_relative "../test_helper" class GemRequirementSingletonTest < Test::Unit::TestCase - include TypeAssertions + include TestHelper testing "singleton(::Gem::Requirement)" @@ -40,7 +40,7 @@ def test_new end class GemRequirementInstanceTest < Test::Unit::TestCase - include TypeAssertions + include TestHelper testing "::Gem::Requirement" diff --git a/test/stdlib/rubygems/GemVersion_test.rb b/test/stdlib/rubygems/GemVersion_test.rb index 1db502253..79b0258da 100644 --- a/test/stdlib/rubygems/GemVersion_test.rb +++ b/test/stdlib/rubygems/GemVersion_test.rb @@ -1,7 +1,7 @@ require_relative "../test_helper" class GemVersionSingletonTest < Test::Unit::TestCase - include TypeAssertions + include TestHelper testing "singleton(::Gem::Version)" @@ -30,7 +30,7 @@ def test_new end class GemVersionInstanceTest < Test::Unit::TestCase - include TypeAssertions + include TestHelper testing "::Gem::Version" diff --git a/test/stdlib/rubygems/Gem_test.rb b/test/stdlib/rubygems/Gem_test.rb index 2326cee0c..82bb764f7 100644 --- a/test/stdlib/rubygems/Gem_test.rb +++ b/test/stdlib/rubygems/Gem_test.rb @@ -1,7 +1,7 @@ require_relative "../test_helper" class GemSingletonTest < Test::Unit::TestCase - include TypeAssertions + include TestHelper class HashLike def initialize(pairs) diff --git a/test/stdlib/singleton_test.rb b/test/stdlib/singleton_test.rb index 55ecb411e..961a395ad 100644 --- a/test/stdlib/singleton_test.rb +++ b/test/stdlib/singleton_test.rb @@ -2,7 +2,8 @@ require 'singleton' class SingletonSingletonTest < Test::Unit::TestCase - include TypeAssertions + include TestHelper + library 'singleton' testing 'singleton(::Singleton)' diff --git a/test/stdlib/tempfile/TempfileRemover_test.rb b/test/stdlib/tempfile/TempfileRemover_test.rb index 24f5033b2..e60d27870 100644 --- a/test/stdlib/tempfile/TempfileRemover_test.rb +++ b/test/stdlib/tempfile/TempfileRemover_test.rb @@ -2,7 +2,7 @@ require 'tempfile' class TempfileRemoverSingletonTest < Test::Unit::TestCase - include TypeAssertions + include TestHelper library "tempfile" testing "singleton(::Tempfile::Remover)" @@ -14,7 +14,7 @@ def test_initialize end class TempfileRemoverTest < Test::Unit::TestCase - include TypeAssertions + include TestHelper library "tempfile" testing "::Tempfile::Remover" diff --git a/test/stdlib/tempfile/Tempfile_test.rb b/test/stdlib/tempfile/Tempfile_test.rb index cc2bf86ab..17cb47075 100644 --- a/test/stdlib/tempfile/Tempfile_test.rb +++ b/test/stdlib/tempfile/Tempfile_test.rb @@ -2,7 +2,7 @@ require 'tempfile' class TempfileSingletonTest < Test::Unit::TestCase - include TypeAssertions + include TestHelper library "tempfile" testing "singleton(::Tempfile)" @@ -43,7 +43,7 @@ def test_initialize end class TempfileTest < Test::Unit::TestCase - include TypeAssertions + include TestHelper library "tempfile" testing "::Tempfile" diff --git a/test/stdlib/test_helper.rb b/test/stdlib/test_helper.rb index 1d37e25df..aa159b0a1 100644 --- a/test/stdlib/test_helper.rb +++ b/test/stdlib/test_helper.rb @@ -1,5 +1,6 @@ require "rbs" require "rbs/test" +require "rbs/unit_test" require "test/unit" require "tmpdir" require "stringio" @@ -21,124 +22,6 @@ def setup # prepend Printer end -module Spy - def self.wrap(object, method_name) - spy = WrapSpy.new(object: object, method_name: method_name) - - if block_given? - begin - yield spy, spy.wrapped_object - end - else - spy - end - end - - class WrapSpy - attr_accessor :callback - attr_reader :object - attr_reader :method_name - - def initialize(object:, method_name:) - @callback = -> (_) { } - @object = object - @method_name = method_name - end - - def wrapped_object - spy = self - - Class.new(BasicObject) do - define_method(:method_missing) do |name, *args, &block| - spy.object.__send__(name, *args, &block) - end - - define_method(spy.method_name, -> (*args, &block) { - return_value = nil - exception = nil - block_calls = [] - - spy_block = if block - Object.new.instance_eval do |fresh| - -> (*block_args) do - block_exn = nil - block_return = nil - - begin - block_return = if self.equal?(fresh) - # no instance eval - block.call(*block_args) - else - self.instance_exec(*block_args, &block) - end - rescue Exception => exn - block_exn = exn - end - - if block_exn - block_calls << RBS::Test::ArgumentsReturn.exception( - arguments: block_args, - exception: block_exn - ) - else - block_calls << RBS::Test::ArgumentsReturn.return( - arguments: block_args, - value: block_return - ) - end - - if block_exn - raise block_exn - else - block_return - end - end.ruby2_keywords - end - end - - begin - if spy_block - return_value = spy.object.__send__(spy.method_name, *args) do |*a, **k, &b| - spy_block.call(*a, **k, &b) - end - else - return_value = spy.object.__send__(spy.method_name, *args, &spy_block) - end - rescue ::Exception => exn - exception = exn - end - - call = if exception - RBS::Test::ArgumentsReturn.exception( - arguments: args, - exception: exception - ) - else - RBS::Test::ArgumentsReturn.return( - arguments: args, - value: return_value - ) - end - trace = RBS::Test::CallTrace.new( - method_name: spy.method_name, - method_call: call, - block_calls: block_calls, - block_given: block != nil - ) - - spy.callback.call(trace) - - if exception - spy.object.__send__(:raise, exception) - else - return_value - end - }.ruby2_keywords) - end.new() - end - end -end - module VersionHelper def if_ruby(range) r = Range.new( @@ -303,303 +186,6 @@ def lower.<=>(rhs) = :not_nil unless defined? lower.<=> end end -module TypeAssertions - module ClassMethods - attr_reader :target - - def library(*libs) - if @libs - raise "Multiple #library calls are not allowed" - end - - @libs = libs - @env = nil - @target = nil - end - - @@env_cache = {} - - def env - @env = @@env_cache[@libs] ||= - begin - loader = RBS::EnvironmentLoader.new - (@libs || []).each do |lib| - loader.add library: lib - end - - RBS::Environment.from_loader(loader).resolve_type_names - end - end - - def builder - @builder ||= RBS::DefinitionBuilder.new(env: env) - end - - def testing(type_or_string) - type = case type_or_string - when String - RBS::Parser.parse_type(type_or_string, variables: []) - else - type_or_string - end - - definition = case type - when RBS::Types::ClassInstance - builder.build_instance(type.name) - when RBS::Types::ClassSingleton - builder.build_singleton(type.name) - else - raise "Test target should be class instance or class singleton: #{type}" - end - - @target = [type, definition] - end - end - - def self.included(base) - base.extend ClassMethods - end - - def env - self.class.env - end - - def builder - self.class.builder - end - - def targets - @targets ||= [] - end - - def target - targets.last || self.class.target - end - - def testing(type_or_string) - type = case type_or_string - when String - RBS::Parser.parse_type(type_or_string, variables: []) - else - type_or_string - end - - definition = case type - when RBS::Types::ClassInstance - builder.build_instance(type.name) - when RBS::Types::ClassSingleton - builder.build_singleton(type.name) - else - raise "Test target should be class instance or class singleton: #{type}" - end - - targets.push [type, definition] - - if block_given? - begin - yield - ensure - targets.pop - end - else - [type, definition] - end - end - - def instance_class - type, _ = target - - case type - when RBS::Types::ClassSingleton, RBS::Types::ClassInstance - Object.const_get(type.name.to_s) - end - end - - def class_class - type, _ = target - - case type - when RBS::Types::ClassSingleton, RBS::Types::ClassInstance - Object.const_get(type.name.to_s).singleton_class - end - end - - ruby2_keywords def assert_send_type(method_type, receiver, method, *args, &block) - trace = [] - spy = Spy.wrap(receiver, method) - spy.callback = -> (result) { trace << result } - - result = nil - exception = nil - - begin - result = spy.wrapped_object.__send__(method, *args, &block) - rescue Exception => exn - exception = exn - end - - mt = case method_type - when String - RBS::Parser.parse_method_type(method_type, variables: []) - when RBS::MethodType - method_type - end - - typecheck = RBS::Test::TypeCheck.new( - self_class: receiver.class, - builder: builder, - sample_size: 100, - unchecked_classes: [], - instance_class: instance_class, - class_class: class_class - ) - errors = typecheck.method_call(method, mt, trace.last, errors: []) - - assert_empty errors.map {|x| RBS::Test::Errors.to_string(x) }, "Call trace does not match with given method type: #{trace.last.inspect}" - - method_types = method_types(method) - all_errors = method_types.map {|t| typecheck.method_call(method, t, trace.last, errors: []) } - assert all_errors.any? {|es| es.empty? }, "Call trace does not match one of method definitions:\n #{trace.last.inspect}\n #{method_types.join(" | ")}" - - raise exception if exception - - result - end - - ruby2_keywords def refute_send_type(method_type, receiver, method, *args, &block) - trace = [] - spy = Spy.wrap(receiver, method) - spy.callback = -> (result) { trace << result } - - result = nil - exception = nil - - begin - result = spy.wrapped_object.__send__(method, *args, &block) - rescue Exception => exn - exception = exn - end - - mt = case method_type - when String - RBS::Parser.parse_method_type(method_type, variables: []) - when RBS::MethodType - method_type - end - - mt = mt.update(block: if mt.block - RBS::Types::Block.new( - type: mt.block.type.with_return_type(RBS::Types::Bases::Any.new(location: nil)), - required: mt.block.required, - self_type: nil - ) - end, - type: mt.type.with_return_type(RBS::Types::Bases::Any.new(location: nil))) - - typecheck = RBS::Test::TypeCheck.new( - self_class: receiver.class, - instance_class: instance_class, - class_class: class_class, - builder: builder, - sample_size: 100, - unchecked_classes: [] - ) - errors = typecheck.method_call(method, mt, trace.last, errors: []) - - assert_operator exception, :is_a?, ::Exception - assert_empty errors.map {|x| RBS::Test::Errors.to_string(x) } - - method_types = method_types(method) - all_errors = method_types.map {|t| typecheck.method_call(method, t, trace.last, errors: []) } - assert all_errors.all? {|es| es.size > 0 }, "Call trace unexpectedly matches one of method definitions:\n #{trace.last.inspect}\n #{method_types.join(" | ")}" - - result - end - - def method_types(method) - type, definition = target - - case - when definition.instance_type? - subst = RBS::Substitution.build(definition.type_params, type.args) - definition.methods[method].method_types.map do |method_type| - method_type.sub(subst) - end - when definition.class_type? - definition.methods[method].method_types - end - end - - def allows_error(*errors) - yield - rescue *errors => exn - notify "Error allowed: #{exn.inspect}" - end - - include VersionHelper - include WithAliases - - def assert_const_type(type, constant_name) - constant = Object.const_get(constant_name) - - typecheck = RBS::Test::TypeCheck.new( - self_class: constant.class, - instance_class: instance_class, - class_class: class_class, - builder: builder, - sample_size: 100, - unchecked_classes: [] - ) - - value_type = - case type - when String - RBS::Parser.parse_type(type, variables: []) - else - type - end - - assert typecheck.value(constant, value_type), "`#{constant_name}` (#{constant.inspect}) must be compatible with given type `#{value_type}`" - - type_name = TypeName(constant_name).absolute! - definition = env.constant_entry(type_name) - assert definition, "Cannot find RBS type definition of `#{constant_name}`" - - case definition - when RBS::Environment::ClassEntry, RBS::Environment::ModuleEntry - definition_type = RBS::Types::ClassSingleton.new(name: type_name, location: nil) - when RBS::Environment::ClassAliasEntry, RBS::Environment::ModuleAliasEntry - type_name = env.normalize_type_name!(type_name) - definition_type = RBS::Types::ClassSingleton.new(name: type_name, location: nil) - when RBS::Environment::ConstantEntry - definition_type = definition.decl.type - end - - assert typecheck.value(constant, definition_type), "`#{constant_name}` (#{constant.inspect}) must be compatible with RBS type definition `#{definition_type}`" - end - - def assert_type(type, value) - typecheck = RBS::Test::TypeCheck.new( - self_class: value.class, - instance_class: "No `instance` class allowed", - class_class: "No `class` class allowed", - builder: builder, - sample_size: 100, - unchecked_classes: [] - ) - - type = - case type - when String - RBS::Parser.parse_type(type, variables: []) - else - type - end - - assert typecheck.value(value, type), "`#{value.inspect}` must be compatible with given type `#{type}`" - end -end - class BlankSlate < BasicObject instance_methods.each do |im| next if %i[__send__ __id__].include? im @@ -831,6 +417,16 @@ def [](str) end end +module TestHelper + include RBS::UnitTest::TypeAssertions + include WithAliases + include VersionHelper + + def self.included(base) + base.extend RBS::UnitTest::TypeAssertions::ClassMethods + end +end + class StdlibTest < Test::Unit::TestCase RBS.logger_level = ENV["RBS_TEST_LOGLEVEL"] || "info" diff --git a/test/stdlib/uri/file_test.rb b/test/stdlib/uri/file_test.rb index b75d4bc2d..bd01fb663 100644 --- a/test/stdlib/uri/file_test.rb +++ b/test/stdlib/uri/file_test.rb @@ -2,7 +2,7 @@ require 'uri' class URIFileSingletonTest < Test::Unit::TestCase - include TypeAssertions + include TestHelper library 'uri' testing 'singleton(::URI::File)' @@ -27,7 +27,7 @@ def test_build end class URIFileInstanceTest < Test::Unit::TestCase - include TypeAssertions + include TestHelper library 'uri' testing '::URI::File' diff --git a/test/stdlib/uri/generic_test.rb b/test/stdlib/uri/generic_test.rb index bc302fc66..729686ca6 100644 --- a/test/stdlib/uri/generic_test.rb +++ b/test/stdlib/uri/generic_test.rb @@ -2,7 +2,7 @@ require 'uri' class URIGenericSingletonTest < Test::Unit::TestCase - include TypeAssertions + include TestHelper library 'uri' testing 'singleton(::URI::Generic)' @@ -97,7 +97,7 @@ def test_use_proxy? end class URIGenericInstanceTest < Test::Unit::TestCase - include TypeAssertions + include TestHelper library 'uri' testing '::URI::Generic' diff --git a/test/stdlib/uri/http_test.rb b/test/stdlib/uri/http_test.rb index 040a1fb56..9b811483c 100644 --- a/test/stdlib/uri/http_test.rb +++ b/test/stdlib/uri/http_test.rb @@ -2,7 +2,7 @@ require 'uri' class URIHTTPSingletonTest < Test::Unit::TestCase - include TypeAssertions + include TestHelper library 'uri' testing 'singleton(::URI::HTTP)' @@ -43,7 +43,7 @@ def test_build end class URIHTTPInstanceTest < Test::Unit::TestCase - include TypeAssertions + include TestHelper library 'uri' testing '::URI::HTTP' diff --git a/test/stdlib/uri/ldap_test.rb b/test/stdlib/uri/ldap_test.rb index e2f54a279..9a4bf25c3 100644 --- a/test/stdlib/uri/ldap_test.rb +++ b/test/stdlib/uri/ldap_test.rb @@ -2,7 +2,7 @@ require 'uri' class URILDAPSingletonTest < Test::Unit::TestCase - include TypeAssertions + include TestHelper library 'uri' testing 'singleton(::URI::LDAP)' @@ -58,7 +58,7 @@ def test_new end class URILDAPInstanceTest < Test::Unit::TestCase - include TypeAssertions + include TestHelper library 'uri' testing '::URI::LDAP' diff --git a/test/stdlib/uri/rfc2396_parser_test.rb b/test/stdlib/uri/rfc2396_parser_test.rb index 1ef248918..3e6f35a05 100644 --- a/test/stdlib/uri/rfc2396_parser_test.rb +++ b/test/stdlib/uri/rfc2396_parser_test.rb @@ -2,7 +2,7 @@ require "uri" class URIRFC2396_ParserSingletonTest < Test::Unit::TestCase - include TypeAssertions + include TestHelper library "uri" testing "singleton(::URI::RFC2396_Parser)" @@ -14,7 +14,7 @@ def test_new end class URIRFC2396_ParserInstanceTest < Test::Unit::TestCase - include TypeAssertions + include TestHelper library "uri" testing "::URI::RFC2396_Parser" diff --git a/test/stdlib/yaml_test.rb b/test/stdlib/yaml_test.rb index 0084bd18a..00034ef04 100644 --- a/test/stdlib/yaml_test.rb +++ b/test/stdlib/yaml_test.rb @@ -4,7 +4,7 @@ require "tmpdir" class YAMLSingletonTest < Test::Unit::TestCase - include TypeAssertions + include TestHelper library "yaml" testing "singleton(::YAML)"