summaryrefslogtreecommitdiff
path: root/test/ruby/test_enum.rb
diff options
context:
space:
mode:
authorNobuyoshi Nakada <nobu@ruby-lang.org>2020-12-17 20:06:18 +0900
committerGitHub <noreply@github.com>2020-12-17 20:06:18 +0900
commit9908177857a28633d6279c43a1ad4dfedcb98596 (patch)
tree400f3c07584b9d87129ec24c42ccb436095f2803 /test/ruby/test_enum.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 <nobu@ruby-lang.org>
Diffstat (limited to 'test/ruby/test_enum.rb')
-rw-r--r--test/ruby/test_enum.rb9
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