diff options
author | Nobuhiro IMAI <nov@yo.rim.or.jp> | 2021-01-07 19:21:06 +0900 |
---|---|---|
committer | aycabta <aycabta@gmail.com> | 2021-01-08 13:25:18 +0900 |
commit | ed3264d37abc54e3aade229751a9165ffd37ca2e (patch) | |
tree | d0f34e7a313031841a53765120fb542faeaaeae9 /test/irb/test_context.rb | |
parent | f59477523053b67eac409b6595bfe5db962aab3d (diff) | |
download | ruby-ed3264d37abc54e3aade229751a9165ffd37ca2e.tar.gz |
[ruby/irb] refactoring an error handling in `IRB::Inspector`
* moved rescue clause to `#inspect_value` to catch all failures in inspectors
* test with all (currently five kind of) inspect modes
- tweaked the input due to only `Marshal` can inspect(dump) a `BasicObject`
https://github.com/ruby/irb/commit/9d112fab8e
Diffstat (limited to 'test/irb/test_context.rb')
-rw-r--r-- | test/irb/test_context.rb | 23 |
1 files changed, 15 insertions, 8 deletions
diff --git a/test/irb/test_context.rb b/test/irb/test_context.rb index a8ff64067b..d1c3ec67ac 100644 --- a/test/irb/test_context.rb +++ b/test/irb/test_context.rb @@ -106,15 +106,22 @@ module TestIRB def test_eval_object_without_inspect_method verbose, $VERBOSE = $VERBOSE, nil - input = TestInputMethod.new([ - "BasicObject.new\n", - ]) - irb = IRB::Irb.new(IRB::WorkSpace.new(Object.new), input) - out, err = capture_output do - irb.eval_input + all_assertions do |all| + IRB::Inspector::INSPECTORS.invert.each_value do |mode| + all.for(mode) do + input = TestInputMethod.new([ + "[BasicObject.new, Class.new]\n", + ]) + irb = IRB::Irb.new(IRB::WorkSpace.new(Object.new), input) + irb.context.inspect_mode = mode + out, err = capture_output do + irb.eval_input + end + assert_empty err + assert_match(/\(Object doesn't support #inspect\)\n(=> )?\n/, out) + end + end end - assert_empty err - assert(/\(Object doesn't support #inspect\)\n(=> )?\n/, out) ensure $VERBOSE = verbose end |