[macruby-changes] [MacRuby/MacRuby] fdc3e9: Module#define_method will accept an UnboundMethod'...
noreply at github.com
noreply at github.com
Mon Jul 18 23:32:33 PDT 2011
Branch: refs/heads/master
Home: https://github.com/MacRuby/MacRuby
Commit: fdc3e9e2d25383b95eab5c55bd6fbece79185253
https://github.com/MacRuby/MacRuby/commit/fdc3e9e2d25383b95eab5c55bd6fbece79185253
Author: Watson <watson1978 at gmail.com>
Date: 2011-07-18 (Mon, 18 Jul 2011)
Changed paths:
M proc.c
M spec/frozen/tags/macruby/core/kernel/define_singleton_method_tags.txt
M spec/frozen/tags/macruby/core/module/define_method_tags.txt
Log Message:
-----------
Module#define_method will accept an UnboundMethod's object into 2nd argument.
Test Script:
{{{
require 'test/unit/assertions.rb'
include Test::Unit::Assertions
# should accept an UnboundMethod's object
class Bar
def foo
"foo"
end
define_method(:foo, instance_method(:foo))
end
assert_equal("foo", Bar.new.foo)
# should not accept an other object's singleton method
foo = Module.new
class << foo
def singleton_method
:single
end
end
um = foo.method(:singleton_method).unbind
other = Module.new
assert_raise(TypeError) {
other.send :define_method, :other_singleton_method, um
}
puts :ok
}}}
More information about the macruby-changes
mailing list