Skip to content

Commit

Permalink
add tests for each kind of argument
Browse files Browse the repository at this point in the history
  • Loading branch information
lxxxvi committed Oct 8, 2020
1 parent 2f87f61 commit ca705a4
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 2 deletions.
4 changes: 4 additions & 0 deletions core/method/fixtures/classes.rb
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,8 @@ def zero; end
def one_req(a); end
def two_req(a, b); end

def one_req_named(a:); end

def zero_with_block(&blk); end
def one_req_with_block(a, &blk); end
def two_req_with_block(a, b, &blk); end
Expand All @@ -71,6 +73,8 @@ def one_req_one_opt_with_splat(a, b=nil, *c); end
def two_req_one_opt_with_splat(a, b, c=nil, *d); end
def one_req_two_opt_with_splat(a, b=nil, c=nil, *d); end

def zero_with_double_splat(**a); end

def zero_with_splat_and_block(*a, &blk); end
def one_req_with_splat_and_block(a, *b, &blk); end
def two_req_with_splat_and_block(a, b, *c, &blk); end
Expand Down
11 changes: 9 additions & 2 deletions core/method/shared/to_s.rb
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,15 @@

ruby_version_is "2.7" do
it "returns a String containing method arguments" do
m = MethodSpecs::Methods.new.method :two_req
m.send(@method).should =~ /\#two_req\(a, b\)/
obj = MethodSpecs::Methods.new
obj.method(:zero).send(@method).should.include?("()")
obj.method(:one_req).send(@method).should.include?("(a)")
obj.method(:one_req_named).send(@method).should.include?("(a:)")
obj.method(:zero_with_block).send(@method).should.include?("(&blk)")
obj.method(:one_opt).send(@method).should.include?("(a=...)")
obj.method(:zero_with_splat).send(@method).should.include?("(*a)")
obj.method(:zero_with_double_splat).send(@method).should.include?("(**a)")
obj.method(:one_req_one_opt_with_splat_and_block).send(@method).should.include?("(a, b=..., *c, &blk)")
end
end

Expand Down

0 comments on commit ca705a4

Please sign in to comment.