* test/ruby/test_{proc,method}.rb: updated tests.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@22278 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
nobu 2009-02-13 09:10:28 +00:00
Родитель 8a5746bf34
Коммит e4917c6dcb
2 изменённых файлов: 25 добавлений и 25 удалений

Просмотреть файл

@ -256,13 +256,13 @@ class TestMethod < Test::Unit::TestCase
assert_equal([], method(:m0).parameters) assert_equal([], method(:m0).parameters)
assert_equal([[:req, :a]], method(:m1).parameters) assert_equal([[:req, :a]], method(:m1).parameters)
assert_equal([[:req, :a], [:req, :b]], method(:m2).parameters) assert_equal([[:req, :a], [:req, :b]], method(:m2).parameters)
assert_equal([[:opt, :a, nil], [:block, :b]], method(:mo1).parameters) assert_equal([[:opt, :a], [:block, :b]], method(:mo1).parameters)
assert_equal([[:req, :a], [:opt, :b, nil]], method(:mo2).parameters) assert_equal([[:req, :a], [:opt, :b]], method(:mo2).parameters)
assert_equal([[:rest, :a]], method(:mo3).parameters) assert_equal([[:rest, :a]], method(:mo3).parameters)
assert_equal([[:req, :a], [:rest, :b], [:block, :c]], method(:mo4).parameters) assert_equal([[:req, :a], [:rest, :b], [:block, :c]], method(:mo4).parameters)
assert_equal([[:req, :a], [:rest, :b], [:req, :c]], method(:mo5).parameters) assert_equal([[:req, :a], [:rest, :b], [:req, :c]], method(:mo5).parameters)
assert_equal([[:req, :a], [:rest, :b], [:req, :c], [:block, :d]], method(:mo6).parameters) assert_equal([[:req, :a], [:rest, :b], [:req, :c], [:block, :d]], method(:mo6).parameters)
assert_equal([[:req, :a], [:opt, :b, nil], [:rest, :c], [:req, :d], [:block, :e]], method(:mo7).parameters) assert_equal([[:req, :a], [:opt, :b], [:rest, :c], [:req, :d], [:block, :e]], method(:mo7).parameters)
assert_equal([[:req], [:block, :b]], method(:ma1).parameters) assert_equal([[:req], [:block, :b]], method(:ma1).parameters)
end end
@ -270,13 +270,13 @@ class TestMethod < Test::Unit::TestCase
assert_equal([], self.class.instance_method(:m0).parameters) assert_equal([], self.class.instance_method(:m0).parameters)
assert_equal([[:req, :a]], self.class.instance_method(:m1).parameters) assert_equal([[:req, :a]], self.class.instance_method(:m1).parameters)
assert_equal([[:req, :a], [:req, :b]], self.class.instance_method(:m2).parameters) assert_equal([[:req, :a], [:req, :b]], self.class.instance_method(:m2).parameters)
assert_equal([[:opt, :a, nil], [:block, :b]], self.class.instance_method(:mo1).parameters) assert_equal([[:opt, :a], [:block, :b]], self.class.instance_method(:mo1).parameters)
assert_equal([[:req, :a], [:opt, :b, nil]], self.class.instance_method(:mo2).parameters) assert_equal([[:req, :a], [:opt, :b]], self.class.instance_method(:mo2).parameters)
assert_equal([[:rest, :a]], self.class.instance_method(:mo3).parameters) assert_equal([[:rest, :a]], self.class.instance_method(:mo3).parameters)
assert_equal([[:req, :a], [:rest, :b], [:block, :c]], self.class.instance_method(:mo4).parameters) assert_equal([[:req, :a], [:rest, :b], [:block, :c]], self.class.instance_method(:mo4).parameters)
assert_equal([[:req, :a], [:rest, :b], [:req, :c]], self.class.instance_method(:mo5).parameters) assert_equal([[:req, :a], [:rest, :b], [:req, :c]], self.class.instance_method(:mo5).parameters)
assert_equal([[:req, :a], [:rest, :b], [:req, :c], [:block, :d]], self.class.instance_method(:mo6).parameters) assert_equal([[:req, :a], [:rest, :b], [:req, :c], [:block, :d]], self.class.instance_method(:mo6).parameters)
assert_equal([[:req, :a], [:opt, :b, nil], [:rest, :c], [:req, :d], [:block, :e]], self.class.instance_method(:mo7).parameters) assert_equal([[:req, :a], [:opt, :b], [:rest, :c], [:req, :d], [:block, :e]], self.class.instance_method(:mo7).parameters)
assert_equal([[:req], [:block, :b]], self.class.instance_method(:ma1).parameters) assert_equal([[:req], [:block, :b]], self.class.instance_method(:ma1).parameters)
end end
@ -284,13 +284,13 @@ class TestMethod < Test::Unit::TestCase
assert_equal([], method(:pm0).parameters) assert_equal([], method(:pm0).parameters)
assert_equal([[:req, :a]], method(:pm1).parameters) assert_equal([[:req, :a]], method(:pm1).parameters)
assert_equal([[:req, :a], [:req, :b]], method(:pm2).parameters) assert_equal([[:req, :a], [:req, :b]], method(:pm2).parameters)
assert_equal([[:opt, :a, nil], [:block, :b]], method(:pmo1).parameters) assert_equal([[:opt, :a], [:block, :b]], method(:pmo1).parameters)
assert_equal([[:req, :a], [:opt, :b, nil]], method(:pmo2).parameters) assert_equal([[:req, :a], [:opt, :b]], method(:pmo2).parameters)
assert_equal([[:rest, :a]], method(:pmo3).parameters) assert_equal([[:rest, :a]], method(:pmo3).parameters)
assert_equal([[:req, :a], [:rest, :b], [:block, :c]], method(:pmo4).parameters) assert_equal([[:req, :a], [:rest, :b], [:block, :c]], method(:pmo4).parameters)
assert_equal([[:req, :a], [:rest, :b], [:req, :c]], method(:pmo5).parameters) assert_equal([[:req, :a], [:rest, :b], [:req, :c]], method(:pmo5).parameters)
assert_equal([[:req, :a], [:rest, :b], [:req, :c], [:block, :d]], method(:pmo6).parameters) assert_equal([[:req, :a], [:rest, :b], [:req, :c], [:block, :d]], method(:pmo6).parameters)
assert_equal([[:req, :a], [:opt, :b, nil], [:rest, :c], [:req, :d], [:block, :e]], method(:pmo7).parameters) assert_equal([[:req, :a], [:opt, :b], [:rest, :c], [:req, :d], [:block, :e]], method(:pmo7).parameters)
assert_equal([[:req], [:block, :b]], method(:pma1).parameters) assert_equal([[:req], [:block, :b]], method(:pma1).parameters)
end end
@ -298,13 +298,13 @@ class TestMethod < Test::Unit::TestCase
assert_equal([], self.class.instance_method(:pm0).parameters) assert_equal([], self.class.instance_method(:pm0).parameters)
assert_equal([[:req, :a]], self.class.instance_method(:pm1).parameters) assert_equal([[:req, :a]], self.class.instance_method(:pm1).parameters)
assert_equal([[:req, :a], [:req, :b]], self.class.instance_method(:pm2).parameters) assert_equal([[:req, :a], [:req, :b]], self.class.instance_method(:pm2).parameters)
assert_equal([[:opt, :a, nil], [:block, :b]], self.class.instance_method(:pmo1).parameters) assert_equal([[:opt, :a], [:block, :b]], self.class.instance_method(:pmo1).parameters)
assert_equal([[:req, :a], [:opt, :b, nil]], self.class.instance_method(:pmo2).parameters) assert_equal([[:req, :a], [:opt, :b]], self.class.instance_method(:pmo2).parameters)
assert_equal([[:rest, :a]], self.class.instance_method(:pmo3).parameters) assert_equal([[:rest, :a]], self.class.instance_method(:pmo3).parameters)
assert_equal([[:req, :a], [:rest, :b], [:block, :c]], self.class.instance_method(:pmo4).parameters) assert_equal([[:req, :a], [:rest, :b], [:block, :c]], self.class.instance_method(:pmo4).parameters)
assert_equal([[:req, :a], [:rest, :b], [:req, :c]], self.class.instance_method(:pmo5).parameters) assert_equal([[:req, :a], [:rest, :b], [:req, :c]], self.class.instance_method(:pmo5).parameters)
assert_equal([[:req, :a], [:rest, :b], [:req, :c], [:block, :d]], self.class.instance_method(:pmo6).parameters) assert_equal([[:req, :a], [:rest, :b], [:req, :c], [:block, :d]], self.class.instance_method(:pmo6).parameters)
assert_equal([[:req, :a], [:opt, :b, nil], [:rest, :c], [:req, :d], [:block, :e]], self.class.instance_method(:pmo7).parameters) assert_equal([[:req, :a], [:opt, :b], [:rest, :c], [:req, :d], [:block, :e]], self.class.instance_method(:pmo7).parameters)
assert_equal([[:req], [:block, :b]], self.class.instance_method(:pma1).parameters) assert_equal([[:req], [:block, :b]], self.class.instance_method(:pma1).parameters)
end end
end end

Просмотреть файл

@ -677,17 +677,17 @@ class TestProc < Test::Unit::TestCase
def test_parameters def test_parameters
assert_equal([], proc {}.parameters) assert_equal([], proc {}.parameters)
assert_equal([], proc {||}.parameters) assert_equal([], proc {||}.parameters)
assert_equal([[:opt, :a, nil]], proc {|a|}.parameters) assert_equal([[:opt, :a]], proc {|a|}.parameters)
assert_equal([[:opt, :a, nil], [:opt, :b, nil]], proc {|a, b|}.parameters) assert_equal([[:opt, :a], [:opt, :b]], proc {|a, b|}.parameters)
assert_equal([[:opt, :a, :a], [:block, :b]], proc {|a=:a, &b|}.parameters) assert_equal([[:opt, :a], [:block, :b]], proc {|a=:a, &b|}.parameters)
assert_equal([[:opt, :a, nil], [:opt, :b, :b]], proc {|a, b=:b|}.parameters) assert_equal([[:opt, :a], [:opt, :b]], proc {|a, b=:b|}.parameters)
assert_equal([[:rest, :a]], proc {|*a|}.parameters) assert_equal([[:rest, :a]], proc {|*a|}.parameters)
assert_equal([[:opt, :a, nil], [:rest, :b], [:block, :c]], proc {|a, *b, &c|}.parameters) assert_equal([[:opt, :a], [:rest, :b], [:block, :c]], proc {|a, *b, &c|}.parameters)
assert_equal([[:opt, :a, nil], [:rest, :b], [:opt, :c, nil]], proc {|a, *b, c|}.parameters) assert_equal([[:opt, :a], [:rest, :b], [:opt, :c]], proc {|a, *b, c|}.parameters)
assert_equal([[:opt, :a, nil], [:rest, :b], [:opt, :c, nil], [:block, :d]], proc {|a, *b, c, &d|}.parameters) assert_equal([[:opt, :a], [:rest, :b], [:opt, :c], [:block, :d]], proc {|a, *b, c, &d|}.parameters)
assert_equal([[:opt, :a, nil], [:opt, :b, :b], [:rest, :c], [:opt, :d, nil], [:block, :e]], proc {|a, b=:b, *c, d, &e|}.parameters) assert_equal([[:opt, :a], [:opt, :b], [:rest, :c], [:opt, :d], [:block, :e]], proc {|a, b=:b, *c, d, &e|}.parameters)
assert_equal([[:opt, nil, nil], [:block, :b]], proc {|(a), &b|}.parameters) assert_equal([[:opt, nil], [:block, :b]], proc {|(a), &b|}.parameters)
assert_equal([[:opt, :a, nil], [:opt, :b, nil], [:opt, :c, :c], [:opt, :d, :d], [:rest, :e], [:opt, :f, nil], [:opt, :g, nil], [:block, :h]], proc {|a,b,c=:c,d=:d,*e,f,g,&h|}.parameters) assert_equal([[:opt, :a], [:opt, :b], [:opt, :c], [:opt, :d], [:rest, :e], [:opt, :f], [:opt, :g], [:block, :h]], proc {|a,b,c=:c,d=:d,*e,f,g,&h|}.parameters)
end end
def pm0() end def pm0() end
@ -707,13 +707,13 @@ class TestProc < Test::Unit::TestCase
assert_equal([], method(:pm0).to_proc.parameters) assert_equal([], method(:pm0).to_proc.parameters)
assert_equal([[:req, :a]], method(:pm1).to_proc.parameters) assert_equal([[:req, :a]], method(:pm1).to_proc.parameters)
assert_equal([[:req, :a], [:req, :b]], method(:pm2).to_proc.parameters) assert_equal([[:req, :a], [:req, :b]], method(:pm2).to_proc.parameters)
assert_equal([[:opt, :a, :a], [:block, :b]], method(:pmo1).to_proc.parameters) assert_equal([[:opt, :a], [:block, :b]], method(:pmo1).to_proc.parameters)
assert_equal([[:req, :a], [:opt, :b, :b]], method(:pmo2).to_proc.parameters) assert_equal([[:req, :a], [:opt, :b]], method(:pmo2).to_proc.parameters)
assert_equal([[:rest, :a]], method(:pmo3).to_proc.parameters) assert_equal([[:rest, :a]], method(:pmo3).to_proc.parameters)
assert_equal([[:req, :a], [:rest, :b], [:block, :c]], method(:pmo4).to_proc.parameters) assert_equal([[:req, :a], [:rest, :b], [:block, :c]], method(:pmo4).to_proc.parameters)
assert_equal([[:req, :a], [:rest, :b], [:req, :c]], method(:pmo5).to_proc.parameters) assert_equal([[:req, :a], [:rest, :b], [:req, :c]], method(:pmo5).to_proc.parameters)
assert_equal([[:req, :a], [:rest, :b], [:req, :c], [:block, :d]], method(:pmo6).to_proc.parameters) assert_equal([[:req, :a], [:rest, :b], [:req, :c], [:block, :d]], method(:pmo6).to_proc.parameters)
assert_equal([[:req, :a], [:opt, :b, :b], [:rest, :c], [:req, :d], [:block, :e]], method(:pmo7).to_proc.parameters) assert_equal([[:req, :a], [:opt, :b], [:rest, :c], [:req, :d], [:block, :e]], method(:pmo7).to_proc.parameters)
assert_equal([[:req], [:block, :b]], method(:pma1).to_proc.parameters) assert_equal([[:req], [:block, :b]], method(:pma1).to_proc.parameters)
end end
end end