diff options
| author | tomoya ishida <tomoyapenguin@gmail.com> | 2024-11-19 22:17:07 +0900 |
|---|---|---|
| committer | git <svn-admin@ruby-lang.org> | 2024-11-19 13:17:11 +0000 |
| commit | bc9237966412c87d0a2d64b2787d2a39a04eca65 (patch) | |
| tree | ba8fa77916ffcdf4d543fc38aaa742f2ba109a01 /test | |
| parent | edf5a738a36fccd07ea79d825bda0f8bd56224a2 (diff) | |
[ruby/irb] Don't use delegator to install helper methods to main
object
(https://github.com/ruby/irb/pull/1031)
IRB used delegator to install command as a method of frozen main object.
Command is not a method now. We can drop it.
https://github.com/ruby/irb/commit/2f1c593801
Diffstat (limited to 'test')
| -rw-r--r-- | test/irb/command/test_cd.rb | 19 | ||||
| -rw-r--r-- | test/irb/test_context.rb | 7 |
2 files changed, 26 insertions, 0 deletions
diff --git a/test/irb/command/test_cd.rb b/test/irb/command/test_cd.rb index 4537286f73..10f77f6691 100644 --- a/test/irb/command/test_cd.rb +++ b/test/irb/command/test_cd.rb @@ -19,6 +19,12 @@ module TestIRB end end + class BO < BasicObject + def baz + "this is baz" + end + end + binding.irb RUBY end @@ -40,6 +46,19 @@ module TestIRB assert_match(/irb\(Foo\):006>/, out) end + def test_cd_basic_object_or_frozen + out = run_ruby_file do + type "cd BO.new" + type "cd 1" + type "cd Object.new.freeze" + type "exit" + end + + assert_match(/irb\(#<BO:.+\):002>/, out) + assert_match(/irb\(1\):003>/, out) + assert_match(/irb\(#<Object:.+\):004>/, out) + end + def test_cd_moves_top_level_with_no_args out = run_ruby_file do type "cd Foo" diff --git a/test/irb/test_context.rb b/test/irb/test_context.rb index d2c007af34..b02d8dbe09 100644 --- a/test/irb/test_context.rb +++ b/test/irb/test_context.rb @@ -652,6 +652,13 @@ module TestIRB assert_equal('irb("aaaaaaaaaaaaaaaaaaaaaaaaaaaa...)>', irb.send(:format_prompt, 'irb(%M)>', nil, 1, 1)) end + def test_prompt_main_basic_object + main = BasicObject.new + irb = IRB::Irb.new(IRB::WorkSpace.new(main), TestInputMethod.new) + assert_match(/irb\(#<BasicObject:.+\)/, irb.send(:format_prompt, 'irb(%m)>', nil, 1, 1)) + assert_match(/irb\(#<BasicObject:.+\)/, irb.send(:format_prompt, 'irb(%M)>', nil, 1, 1)) + end + def test_prompt_main_raise main = Object.new def main.to_s; raise TypeError; end |
