From 594dd8bfd4c2b380dc7185d421d71b29c379356b Mon Sep 17 00:00:00 2001 From: Takashi Sakaguchi Date: Fri, 26 Dec 2025 12:37:46 +0900 Subject: [ruby/pp] Support private instance_variables_to_inspect (https://github.com/ruby/pp/pull/70) * Support private instance_variables_to_inspect in pp Ruby supports calling instance_variables_to_inspect even when it is defined as a private method (ruby/ruby#13555). This change aligns pp with Ruby's behavior. https://github.com/ruby/pp/commit/8450e76db6 --- test/test_pp.rb | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'test') diff --git a/test/test_pp.rb b/test/test_pp.rb index 4a273e6edd..922ed371af 100644 --- a/test/test_pp.rb +++ b/test/test_pp.rb @@ -146,7 +146,9 @@ class PPInspectTest < Test::Unit::TestCase def test_iv_hiding_via_ruby a = Object.new - def a.instance_variables_to_inspect() [:@b] end + a.singleton_class.class_eval do + private def instance_variables_to_inspect() [:@b] end + end a.instance_eval { @a = "aaa"; @b = "bbb" } assert_match(/\A#\n\z/, PP.pp(a, ''.dup)) end -- cgit v1.2.3