mirror of
https://github.com/ruby/ruby.git
synced 2025-09-23 20:44:00 +02:00
* proc.c (rb_mod_define_method): now they return the symbols of the
defined methods, not the methods/procs themselves. [ruby-dev:42151] [Feature #3753] * NEWS: documents about above change and def-expr (see r42337). * test/ruby/test_module.rb: tests about above change. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@42551 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
d551b78d4a
commit
a28d1eff65
4 changed files with 39 additions and 3 deletions
|
@ -1749,6 +1749,26 @@ class TestModule < Test::Unit::TestCase
|
|||
RUBY
|
||||
end
|
||||
|
||||
def test_return_value_of_define_method
|
||||
retvals = []
|
||||
Class.new.class_eval do
|
||||
retvals << define_method(:foo){}
|
||||
retvals << define_method(:bar, instance_method(:foo))
|
||||
end
|
||||
assert_equal :foo, retvals[0]
|
||||
assert_equal :bar, retvals[1]
|
||||
end
|
||||
|
||||
def test_return_value_of_define_singleton_method
|
||||
retvals = []
|
||||
Class.new do
|
||||
retvals << define_singleton_method(:foo){}
|
||||
retvals << define_singleton_method(:bar, method(:foo))
|
||||
end
|
||||
assert_equal :foo, retvals[0]
|
||||
assert_equal :bar, retvals[1]
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def assert_top_method_is_private(method)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue