diff options
author | Richard Viney <richard.viney@gmail.com> | 2017-01-22 14:50:08 +1300 |
---|---|---|
committer | Nobuyoshi Nakada <nobu@ruby-lang.org> | 2019-12-16 23:43:49 +0900 |
commit | 6a75a460536a32fb62184dc5d8d66ddd737a9bad (patch) | |
tree | 1b977518ac32ecbdc987f87b487306485f0a136e /test/test_pp.rb | |
parent | 251f5d8226dbde06ba06e980e3b741b45ae3826d (diff) |
Make prettyprint’s cycle detection aware of Delegator instances
Fixes [Bug #13144]
Co-Authored-By: Nobuyoshi Nakada <nobu@ruby-lang.org>
Diffstat (limited to 'test/test_pp.rb')
-rw-r--r-- | test/test_pp.rb | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/test/test_pp.rb b/test/test_pp.rb index 4736bff149..3262417fba 100644 --- a/test/test_pp.rb +++ b/test/test_pp.rb @@ -184,6 +184,18 @@ class PPDelegateTest < Test::Unit::TestCase def test_delegate assert_equal("[]\n", A.new([]).pretty_inspect, "[ruby-core:25804]") end + + def test_delegate_cycle + a = HasPrettyPrint.new nil + + a.instance_eval {@a = a} + cycle_pretty_inspect = a.pretty_inspect + + a.instance_eval {@a = SimpleDelegator.new(a)} + delegator_cycle_pretty_inspect = a.pretty_inspect + + assert_equal(cycle_pretty_inspect, delegator_cycle_pretty_inspect) + end end class PPFileStatTest < Test::Unit::TestCase |