diff options
| author | Yusuke Endoh <mame@ruby-lang.org> | 2023-12-12 10:29:26 +0900 |
|---|---|---|
| committer | Yusuke Endoh <mame@ruby-lang.org> | 2023-12-12 10:31:37 +0900 |
| commit | cfb8494d5473b3695ac40aa6a9891284603bfc89 (patch) | |
| tree | b913a26836d66dd55ca3372ddf3031bf5fce8b1c /test/ruby | |
| parent | 0c287df3bc4c1a7aed3279e20590ecf628722b4d (diff) | |
Prevent warning: possibly useless use of a literal in void context
Diffstat (limited to 'test/ruby')
| -rw-r--r-- | test/ruby/test_parse.rb | 14 |
1 files changed, 12 insertions, 2 deletions
diff --git a/test/ruby/test_parse.rb b/test/ruby/test_parse.rb index 565dc2e302..c2f02ff809 100644 --- a/test/ruby/test_parse.rb +++ b/test/ruby/test_parse.rb @@ -483,7 +483,12 @@ class TestParse < Test::Unit::TestCase assert_equal([4,5], eval("(1..9).select {|n| true if #{code}}")) else assert_raise_with_message(ArgumentError, /bad value for range/, code) { - eval("[4].each {|n| true if #{code}}") + verbose_bak, $VERBOSE = $VERBOSE, nil # disable "warning: possibly useless use of a literal in void context" + begin + eval("[4].each {|n| true if #{code}}") + ensure + $VERBOSE = verbose_bak + end } end end @@ -1081,7 +1086,12 @@ x = __ENCODING__ if pass assert_equal(token, eval("#{code} =~ #{token.dump}; a")) else - assert_nil(eval("#{code} =~ #{token.dump}; defined?(a)"), code) + verbose_bak, $VERBOSE = $VERBOSE, nil # disable "warning: possibly useless use of a literal in void context" + begin + assert_nil(eval("#{code} =~ #{token.dump}; defined?(a)"), code) + ensure + $VERBOSE = verbose_bak + end end end end |
