diff options
-rw-r--r-- | ChangeLog | 7 | ||||
-rw-r--r-- | object.c | 2 | ||||
-rw-r--r-- | test/ruby/test_method.rb | 20 | ||||
-rw-r--r-- | version.h | 2 |
4 files changed, 29 insertions, 2 deletions
@@ -1,3 +1,10 @@ +Thu Sep 12 01:34:07 2013 Charlie Somerville <charliesome@ruby-lang.org> + + * object.c (rb_class_inherited_p): allow iclasses to be tested for + inheritance. [Bug #8686] [ruby-core:56174] + + * test/ruby/test_method.rb: add test + Thu Sep 12 01:18:44 2013 Michal Rokos <michal@rokos.cz> * configure.in (sys/pstat.h): fix missing header check for @@ -1482,7 +1482,7 @@ rb_class_inherited_p(VALUE mod, VALUE arg) VALUE start = mod; if (mod == arg) return Qtrue; - if (!CLASS_OR_MODULE_P(arg)) { + if (!CLASS_OR_MODULE_P(arg) && !RB_TYPE_P(arg, T_ICLASS)) { rb_raise(rb_eTypeError, "compared with non class/module"); } arg = RCLASS_ORIGIN(arg); diff --git a/test/ruby/test_method.rb b/test/ruby/test_method.rb index 1935bf2ad8..6d0f6acf35 100644 --- a/test/ruby/test_method.rb +++ b/test/ruby/test_method.rb @@ -232,7 +232,9 @@ class TestMethod < Test::Unit::TestCase assert_raise(TypeError) do Class.new.class_eval { define_method(:bar, o.method(:bar)) } end + end + def test_define_singleton_method o = Object.new def o.foo(c) c.class_eval { define_method(:foo) } @@ -252,7 +254,25 @@ class TestMethod < Test::Unit::TestCase assert_raise(TypeError) do Module.new.module_eval {define_method(:foo, Base.instance_method(:foo))} end + end + + def test_define_singleton_method_with_extended_method + bug8686 = "[ruby-core:56174]" + + m = Module.new do + extend self + + def a + "a" + end + end + + assert_nothing_raised do + m.define_singleton_method(:a, m.method(:a)) + end + end + def test_define_method_transplating feature4254 = '[ruby-core:34267]' m = Module.new {define_method(:meth, M.instance_method(:meth))} assert_equal(:meth, Object.new.extend(m).meth, feature4254) @@ -1,6 +1,6 @@ #define RUBY_VERSION "2.0.0" #define RUBY_RELEASE_DATE "2013-09-12" -#define RUBY_PATCHLEVEL 302 +#define RUBY_PATCHLEVEL 303 #define RUBY_RELEASE_YEAR 2013 #define RUBY_RELEASE_MONTH 9 |