[Bug #20900] Warn deprecated constant when removing
This commit is contained in:
parent
727b2a2999
commit
9c777f282f
Notes:
git
2024-11-19 04:16:38 +00:00
@ -44,6 +44,15 @@ describe "Module#deprecate_constant" do
|
||||
end
|
||||
end
|
||||
|
||||
ruby_bug '#20900', ''...'3.4' do
|
||||
describe "when removing the deprecated module" do
|
||||
it "warns with a message" do
|
||||
@module.deprecate_constant :PUBLIC1
|
||||
-> { @module.module_eval {remove_const :PUBLIC1} }.should complain(/warning: constant .+::PUBLIC1 is deprecated/)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
it "accepts multiple symbols and strings as constant names" do
|
||||
@module.deprecate_constant "PUBLIC1", :PUBLIC2
|
||||
|
||||
|
@ -2148,9 +2148,8 @@ class TestModule < Test::Unit::TestCase
|
||||
Warning[:deprecated] = false
|
||||
Class.new(c)::FOO
|
||||
end
|
||||
assert_warn('') do
|
||||
Warning[:deprecated] = false
|
||||
c.class_eval "FOO"
|
||||
assert_warn(/deprecated/) do
|
||||
c.class_eval {remove_const "FOO"}
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -3280,6 +3280,7 @@ rb_const_remove(VALUE mod, ID id)
|
||||
undefined_constant(mod, ID2SYM(id));
|
||||
}
|
||||
|
||||
rb_const_warn_if_deprecated(ce, mod, id);
|
||||
rb_clear_constant_cache_for_id(id);
|
||||
|
||||
val = ce->value;
|
||||
|
Loading…
x
Reference in New Issue
Block a user