зеркало из https://github.com/github/ruby.git
eval.c: fix message as same as previous versions
* eval.c (rb_frozen_class_p): fix message for singleton class of class/module as same as previous versions. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@47568 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
Родитель
92c1d1a950
Коммит
0fa9553604
15
eval.c
15
eval.c
|
@ -412,8 +412,21 @@ rb_frozen_class_p(VALUE klass)
|
|||
if (OBJ_FROZEN(klass)) {
|
||||
const char *desc;
|
||||
|
||||
if (FL_TEST(klass, FL_SINGLETON))
|
||||
if (FL_TEST(klass, FL_SINGLETON)) {
|
||||
desc = "object";
|
||||
klass = rb_ivar_get(klass, id__attached__);
|
||||
if (!SPECIAL_CONST_P(klass)) {
|
||||
switch (BUILTIN_TYPE(klass)) {
|
||||
case T_MODULE:
|
||||
case T_ICLASS:
|
||||
desc = "Module";
|
||||
break;
|
||||
case T_CLASS:
|
||||
desc = "Class";
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
switch (BUILTIN_TYPE(klass)) {
|
||||
case T_MODULE:
|
||||
|
|
|
@ -389,8 +389,12 @@ class TestClass < Test::Unit::TestCase
|
|||
obj = Object.new
|
||||
c = obj.singleton_class
|
||||
obj.freeze
|
||||
assert_raise(RuntimeError, /frozen object/) {
|
||||
assert_raise_with_message(RuntimeError, /frozen object/) {
|
||||
c.class_eval {def f; end}
|
||||
}
|
||||
c = Class.new.freeze
|
||||
assert_raise_with_message(RuntimeError, /frozen Class/) {
|
||||
def c.f; end
|
||||
}
|
||||
end
|
||||
end
|
||||
|
|
Загрузка…
Ссылка в новой задаче