diff options
author | Nobuyoshi Nakada <[email protected]> | 2020-12-17 20:06:18 +0900 |
---|---|---|
committer | GitHub <[email protected]> | 2020-12-17 20:06:18 +0900 |
commit | 9908177857a28633d6279c43a1ad4dfedcb98596 (patch) | |
tree | 400f3c07584b9d87129ec24c42ccb436095f2803 /test/ruby/test_enum.rb | |
parent | d597d7a8b6e753cfe40b8470c770f744adde5d4f (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_enum.rb')
-rw-r--r-- | test/ruby/test_enum.rb | 9 |
1 files changed, 4 insertions, 5 deletions
diff --git a/test/ruby/test_enum.rb b/test/ruby/test_enum.rb index 3d0420972f..126b100b03 100644 --- a/test/ruby/test_enum.rb +++ b/test/ruby/test_enum.rb @@ -27,7 +27,6 @@ class TestEnumerable < Test::Unit::TestCase end end @verbose = $VERBOSE - $VERBOSE = nil end def teardown @@ -88,7 +87,7 @@ class TestEnumerable < Test::Unit::TestCase assert_equal(5, @obj.count) assert_equal(2, @obj.count(1)) assert_equal(3, @obj.count {|x| x % 2 == 1 }) - assert_equal(2, @obj.count(1) {|x| x % 2 == 1 }) + assert_equal(2, assert_warning(/given block not used/) {@obj.count(1) {|x| x % 2 == 1 }}) assert_raise(ArgumentError) { @obj.count(0, 1) } if RUBY_ENGINE == "ruby" @@ -116,7 +115,7 @@ class TestEnumerable < Test::Unit::TestCase assert_equal(1, @obj.find_index {|x| x % 2 == 0 }) assert_equal(nil, @obj.find_index {|x| false }) assert_raise(ArgumentError) { @obj.find_index(0, 1) } - assert_equal(1, @obj.find_index(2) {|x| x == 1 }) + assert_equal(1, assert_warning(/given block not used/) {@obj.find_index(2) {|x| x == 1 }}) end def test_find_all @@ -227,7 +226,7 @@ class TestEnumerable < Test::Unit::TestCase assert_equal(48, @obj.inject {|z, x| z * 2 + x }) assert_equal(12, @obj.inject(:*)) assert_equal(24, @obj.inject(2) {|z, x| z * x }) - assert_equal(24, @obj.inject(2, :*) {|z, x| z * x }) + assert_equal(24, assert_warning(/given block not used/) {@obj.inject(2, :*) {|z, x| z * x }}) assert_equal(nil, @empty.inject() {9}) end @@ -437,7 +436,7 @@ class TestEnumerable < Test::Unit::TestCase assert_equal(false, [true, true, false].all?) assert_equal(true, [].all?) assert_equal(true, @empty.all?) - assert_equal(true, @obj.all?(Fixnum)) + assert_equal(true, @obj.all?(Integer)) assert_equal(false, @obj.all?(1..2)) end |