Skip to content

Commit

Permalink
Add tests of argument forwarding's parameters and inspect
Browse files Browse the repository at this point in the history
  • Loading branch information
znz committed Nov 20, 2019
1 parent 633625a commit 7779730
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions test/ruby/test_method.rb
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ def mk6(a, b = nil, c, **o) nil && o end
def mk7(a, b = nil, *c, d, **o) nil && o end
def mk8(a, b = nil, *c, d, e:, f: nil, **o) nil && o end
def mnk(**nil) end
def mf(...) end

class Base
def foo() :base end
Expand Down Expand Up @@ -554,6 +555,7 @@ def test_bound_parameters
assert_equal([[:req, :a], [:opt, :b], [:rest, :c], [:req, :d], [:keyrest, :o]], method(:mk7).parameters)
assert_equal([[:req, :a], [:opt, :b], [:rest, :c], [:req, :d], [:keyreq, :e], [:key, :f], [:keyrest, :o]], method(:mk8).parameters)
assert_equal([[:nokey]], method(:mnk).parameters)
assert_equal([[:rest, :*], [:block, :&]], method(:mf).parameters)
end

def test_unbound_parameters
Expand All @@ -578,6 +580,7 @@ def test_unbound_parameters
assert_equal([[:req, :a], [:opt, :b], [:rest, :c], [:req, :d], [:keyrest, :o]], self.class.instance_method(:mk7).parameters)
assert_equal([[:req, :a], [:opt, :b], [:rest, :c], [:req, :d], [:keyreq, :e], [:key, :f], [:keyrest, :o]], self.class.instance_method(:mk8).parameters)
assert_equal([[:nokey]], self.class.instance_method(:mnk).parameters)
assert_equal([[:rest, :*], [:block, :&]], self.class.instance_method(:mf).parameters)
end

def test_bmethod_bound_parameters
Expand Down Expand Up @@ -654,6 +657,7 @@ def test_method_parameters_inspect
assert_include(method(:mk7).inspect, "(a, b=..., *c, d, **o)")
assert_include(method(:mk8).inspect, "(a, b=..., *c, d, e:, f: ..., **o)")
assert_include(method(:mnk).inspect, "(**nil)")
assert_include(method(:mf).inspect, "(**, &&)")
end

def test_unbound_method_parameters_inspect
Expand All @@ -678,6 +682,7 @@ def test_unbound_method_parameters_inspect
assert_include(self.class.instance_method(:mk7).inspect, "(a, b=..., *c, d, **o)")
assert_include(self.class.instance_method(:mk8).inspect, "(a, b=..., *c, d, e:, f: ..., **o)")
assert_include(self.class.instance_method(:mnk).inspect, "(**nil)")
assert_include(self.class.instance_method(:mf).inspect, "(**, &&)")
end

def test_public_method_with_zsuper_method
Expand Down

0 comments on commit 7779730

Please sign in to comment.