summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--ChangeLog7
-rw-r--r--object.c2
-rw-r--r--test/ruby/test_method.rb20
-rw-r--r--version.h2
4 files changed, 29 insertions, 2 deletions
diff --git a/ChangeLog b/ChangeLog
index 124786491c..647e41d981 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -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
diff --git a/object.c b/object.c
index a782075b85..dc606db067 100644
--- a/object.c
+++ b/object.c
@@ -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)
diff --git a/version.h b/version.h
index 5d6b3bbb1b..2af36803d3 100644
--- a/version.h
+++ b/version.h
@@ -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