From 1dd11fe8c8a238ea88f5abbdb673de313a82ede2 Mon Sep 17 00:00:00 2001 From: Nobuyoshi Nakada Date: Sun, 5 Oct 2025 10:25:23 +0900 Subject: [PATCH] [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 --- test/test_pp.rb | 17 +++++++++++++++-- 1 file 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