Skip to content

Commit

Permalink
Prevent warning: possibly useless use of a literal in void context
Browse files Browse the repository at this point in the history
  • Loading branch information
mame committed Dec 12, 2023
1 parent 0c287df commit cfb8494
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions test/ruby/test_parse.rb
Expand Up @@ -483,7 +483,12 @@ def test_flip_flop
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
Expand Down Expand Up @@ -1081,7 +1086,12 @@ def test_named_capture_in_block
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
Expand Down

0 comments on commit cfb8494

Please sign in to comment.