summaryrefslogtreecommitdiff
path: root/test/ruby/test_module.rb
diff options
context:
space:
mode:
authorNobuyoshi Nakada <[email protected]>2020-12-17 20:06:18 +0900
committerGitHub <[email protected]>2020-12-17 20:06:18 +0900
commit9908177857a28633d6279c43a1ad4dfedcb98596 (patch)
tree400f3c07584b9d87129ec24c42ccb436095f2803 /test/ruby/test_module.rb
parentd597d7a8b6e753cfe40b8470c770f744adde5d4f (diff)
test/ruby: Check warning messages at a finer granularity
Instead of suppressing all warnings wholly in each test scripts by setting `$VERBOSE` to `nil` in `setup` methods.
Notes
Notes: Merged: https://github.com/ruby/ruby/pull/3925 Merged-By: nobu <[email protected]>
Diffstat (limited to 'test/ruby/test_module.rb')
-rw-r--r--test/ruby/test_module.rb15
1 files changed, 10 insertions, 5 deletions
diff --git a/test/ruby/test_module.rb b/test/ruby/test_module.rb
index b676145ba7..55755a61a6 100644
--- a/test/ruby/test_module.rb
+++ b/test/ruby/test_module.rb
@@ -27,7 +27,6 @@ class TestModule < Test::Unit::TestCase
def setup
@verbose = $VERBOSE
- $VERBOSE = nil
@deprecated = Warning[:deprecated]
Warning[:deprecated] = true
end
@@ -487,6 +486,7 @@ class TestModule < Test::Unit::TestCase
end
a2 = a.dup.new
a.class_eval do
+ alias _b b
def b; 1 end
end
assert_equal(2, a2.b)
@@ -900,14 +900,18 @@ class TestModule < Test::Unit::TestCase
end
def test_attr_obsoleted_flag
- c = Class.new
- c.class_eval do
+ c = Class.new do
+ extend Test::Unit::Assertions
def initialize
@foo = :foo
@bar = :bar
end
- attr :foo, true
- attr :bar, false
+ assert_warning(/optional boolean argument/) do
+ attr :foo, true
+ end
+ assert_warning(/optional boolean argument/) do
+ attr :bar, false
+ end
end
o = c.new
assert_equal(true, o.respond_to?(:foo))
@@ -952,6 +956,7 @@ class TestModule < Test::Unit::TestCase
assert_equal(:foo, c2.const_get(:Foo))
assert_raise(NameError) { c2.const_get(:Foo, false) }
+ c1.__send__(:remove_const, :Foo)
eval("c1::Foo = :foo")
assert_raise(NameError) { c1::Bar }
assert_raise(NameError) { c2::Bar }