summaryrefslogtreecommitdiff
path: root/test/ruby/test_module.rb
diff options
context:
space:
mode:
authorNobuyoshi Nakada <[email protected]>2020-08-31 14:58:31 +0900
committerNobuyoshi Nakada <[email protected]>2020-09-25 09:50:33 +0900
commit996af2ce086249e904b2ce95ab2fcd1de7d757be (patch)
tree1b70f747a0eefc32be13f05bdb037275d1e664a1 /test/ruby/test_module.rb
parent83ff0f74bf69650754cac020bcd4ff9adbba877e (diff)
Disable deprecation warning by the default [Feature #16345]
And `-w` option turns it on.
Notes
Notes: Merged: https://github.com/ruby/ruby/pull/3481
Diffstat (limited to 'test/ruby/test_module.rb')
-rw-r--r--test/ruby/test_module.rb40
1 files changed, 24 insertions, 16 deletions
diff --git a/test/ruby/test_module.rb b/test/ruby/test_module.rb
index 94e415b08c..3003a743d1 100644
--- a/test/ruby/test_module.rb
+++ b/test/ruby/test_module.rb
@@ -1755,23 +1755,31 @@ class TestModule < Test::Unit::TestCase
c = Class.new
c.const_set(:FOO, "foo")
c.deprecate_constant(:FOO)
- assert_warn(/deprecated/) {c::FOO}
- assert_warn(/#{c}::FOO is deprecated/) {Class.new(c)::FOO}
+ assert_warn(/deprecated/) do
+ Warning[:deprecated] = true
+ c::FOO
+ end
+ assert_warn(/#{c}::FOO is deprecated/) do
+ Warning[:deprecated] = true
+ Class.new(c)::FOO
+ end
bug12382 = '[ruby-core:75505] [Bug #12382]'
- assert_warn(/deprecated/, bug12382) {c.class_eval "FOO"}
- Warning[:deprecated] = false
- assert_warn('') {c::FOO}
- end
-
- NIL = nil
- FALSE = false
- deprecate_constant(:NIL, :FALSE)
-
- def test_deprecate_nil_constant
- w = EnvUtil.verbose_warning {2.times {FALSE}}
- assert_equal(1, w.scan("::FALSE").size, w)
- w = EnvUtil.verbose_warning {2.times {NIL}}
- assert_equal(1, w.scan("::NIL").size, w)
+ assert_warn(/deprecated/, bug12382) do
+ Warning[:deprecated] = true
+ c.class_eval "FOO"
+ end
+ assert_warn('') do
+ Warning[:deprecated] = false
+ c::FOO
+ end
+ assert_warn('') do
+ Warning[:deprecated] = false
+ Class.new(c)::FOO
+ end
+ assert_warn('') do
+ Warning[:deprecated] = false
+ c.class_eval "FOO"
+ end
end
def test_constants_with_private_constant