summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNobuyoshi Nakada <nobu@ruby-lang.org>2025-10-05 10:25:23 +0900
committerNobuyoshi Nakada <nobu@ruby-lang.org>2025-10-05 15:14:00 +0900
commit1dd11fe8c8a238ea88f5abbdb673de313a82ede2 (patch)
tree859b72cc494b612f690c35a53bf51179ff95dd9a
parent252c253b7537d6f5ac9ab612afcf6d8938cbb529 (diff)
[ruby/pp] Suppress warnings in test on Ruby 2.7
TODO: Revert when dropping Ruby 2.7 support. https://github.com/ruby/pp/commit/feb417e152
-rw-r--r--test/test_pp.rb17
1 files changed, 15 insertions, 2 deletions
diff --git a/test/test_pp.rb b/test/test_pp.rb
index 8345e5e987..4a273e6edd 100644
--- a/test/test_pp.rb
+++ b/test/test_pp.rb
@@ -273,8 +273,21 @@ class PPSingleLineTest < Test::Unit::TestCase
def test_hash_in_array
omit if RUBY_ENGINE == "jruby"
- assert_equal("[{}]", PP.singleline_pp([->(*a){a.last.clear}.ruby2_keywords.call(a: 1)], ''.dup))
- assert_equal("[{}]", PP.singleline_pp([Hash.ruby2_keywords_hash({})], ''.dup))
+ assert_equal("[{}]", passing_keywords {PP.singleline_pp([->(*a){a.last.clear}.ruby2_keywords.call(a: 1)], ''.dup)})
+ assert_equal("[{}]", passing_keywords {PP.singleline_pp([Hash.ruby2_keywords_hash({})], ''.dup)})
+ end
+
+ if RUBY_VERSION >= "3.0"
+ def passing_keywords(&_)
+ yield
+ end
+ else
+ def passing_keywords(&_)
+ verbose, $VERBOSE = $VERBOSE, nil
+ yield
+ ensure
+ $VERBOSE = verbose
+ end
end
def test_direct_pp