Skip to content

Commit

Permalink
Merge pull request #1064 from piotaixr/feature/refine-accepts-module-…
Browse files Browse the repository at this point in the history
…not-only-class

Fixing Module#refine type signature
  • Loading branch information
soutaro committed Aug 4, 2022
2 parents ac9f204 + cc51dd2 commit 058244a
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 2 deletions.
2 changes: 1 addition & 1 deletion core/module.rbs
Original file line number Diff line number Diff line change
Expand Up @@ -1401,7 +1401,7 @@ class Module < Object
#
# Returns a module, where refined methods are defined.
#
def refine: (Class arg0) { (untyped arg0) -> untyped } -> self
def refine: (Module mod) { () -> void } -> Refinement

# <!--
# rdoc-file=object.c
Expand Down
5 changes: 5 additions & 0 deletions test/stdlib/Module_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,11 @@ module Foo
BAR = 1
end

def test_refine
assert_send_type "(Module) { () -> void } -> Refinement",
Foo, :refine, String do nil end
end

def test_const_source_location
assert_send_type "(Symbol) -> [String, Integer]",
Foo, :const_source_location, :BAR
Expand Down
8 changes: 7 additions & 1 deletion test/stdlib/test_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,13 @@ def wrapped_object
end

begin
return_value = spy.object.__send__(spy.method_name, *args, &spy_block)
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
Expand Down

0 comments on commit 058244a

Please sign in to comment.