diff options
author | shyouhei <shyouhei@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2007-08-29 04:06:12 +0000 |
---|---|---|
committer | shyouhei <shyouhei@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2007-08-29 04:06:12 +0000 |
commit | 11dbedfaad4a9a9521ece2198a8dc491678b1902 (patch) | |
tree | 4806dc0ff0c3827ecc40921838c4507340cfdb3a /ruby_1_8_6/test/ruby/test_method.rb | |
parent | 29e8d8b439b34c2a394407dc598fc01d14be0c20 (diff) |
add tag v1_8_6_5001v1_8_6_5001
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/tags/v1_8_6_5001@13304 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'ruby_1_8_6/test/ruby/test_method.rb')
-rw-r--r-- | ruby_1_8_6/test/ruby/test_method.rb | 53 |
1 files changed, 53 insertions, 0 deletions
diff --git a/ruby_1_8_6/test/ruby/test_method.rb b/ruby_1_8_6/test/ruby/test_method.rb new file mode 100644 index 0000000000..ef28098dce --- /dev/null +++ b/ruby_1_8_6/test/ruby/test_method.rb @@ -0,0 +1,53 @@ +require 'test/unit' + +class TestMethod < Test::Unit::TestCase + def m0() end + def m1(a) end + def m2(a, b) end + def mo1(a = nil, &b) end + def mo2(a, b = nil) end + def mo3(*a) end + def mo4(a, *b, &c) end + + class Base + def foo() :base end + def bar() :bar end + end + module SuperBar + def bar() super end + end + class Derived < Base + include SuperBar + def foo() :derived end + end + + def test_arity + assert_equal(0, method(:m0).arity) + assert_equal(1, method(:m1).arity) + assert_equal(2, method(:m2).arity) + assert_equal(-1, method(:mo1).arity) + assert_equal(-2, method(:mo2).arity) + assert_equal(-1, method(:mo3).arity) + assert_equal(-2, method(:mo4).arity) + end + + def test_unbind + assert_equal(:derived, Derived.new.foo) + um = Derived.new.method(:foo).unbind + assert_instance_of(UnboundMethod, um) + Derived.class_eval do + def foo() :changed end + end + assert_equal(:changed, Derived.new.foo) + assert_equal(:derived, um.bind(Derived.new).call) + assert_raise(TypeError) do + um.bind(Base.new) + end + end + + def test_method_super + assert_nothing_raised do + assert_equal(:bar, Derived.new.method(:bar).call) + end + end +end |