diff options
| author | Jean Boussier <jean.boussier@gmail.com> | 2024-07-12 12:23:24 +0200 |
|---|---|---|
| committer | git <svn-admin@ruby-lang.org> | 2024-11-12 02:13:15 +0000 |
| commit | 83702f7157a8c74dd4d7d6d79dea78d90a7b6570 (patch) | |
| tree | 80253f40b7f8bb32858673d93cf3cefe9ccb2d5f /include/ruby | |
| parent | 107a4da122126e6d0e0ad12898d7511e472709a3 (diff) | |
[ruby/pp] Handle BasicObject
Right now attempting to pretty print a BasicObject or any other
object lacking a few core Object methods will result in an error
```
Error: test_basic_object(PPTestModule::PPInspectTest): NoMethodError: undefined method `is_a?' for an instance of BasicObject
lib/pp.rb:192:in `pp'
lib/pp.rb:97:in `block in pp'
lib/pp.rb:158:in `guard_inspect_key'
lib/pp.rb:97:in `pp'
test/test_pp.rb:131:in `test_basic_object'
128:
129: def test_basic_object
130: a = BasicObject.new
=> 131: assert_match(/\A#<BasicObject:0x[\da-f]+>\n\z/, PP.pp(a, ''.dup))
132: end
133: end
134:
```
With some fairly small changes we can fallback to `Object#inspect`
which is better than an error.
https://github.com/ruby/pp/commit/4e9f6c2de0
Diffstat (limited to 'include/ruby')
0 files changed, 0 insertions, 0 deletions
