From 00b39be61f3af3bd34909db0de5a7367f6826f4b Mon Sep 17 00:00:00 2001 From: Nobuyoshi Nakada Date: Fri, 3 Mar 2023 11:34:01 +0900 Subject: [PATCH] Fix warnings because of `@context.main.delete` If the main object of the context has `#delete` method, the following warning is printed. ``` irb: warn: can't alias delete from irb_delete. ``` --- test/irb/test_context.rb | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/test/irb/test_context.rb b/test/irb/test_context.rb index 9b471202b..fd345f826 100644 --- a/test/irb/test_context.rb +++ b/test/irb/test_context.rb @@ -657,7 +657,8 @@ def test_eval_input_with_long_exception end def test_prompt_main_escape - irb = IRB::Irb.new(IRB::WorkSpace.new("main\a\t\r\n")) + main = Struct.new(:to_s).new("main\a\t\r\n") + irb = IRB::Irb.new(IRB::WorkSpace.new(main)) assert_equal("irb(main )>", irb.prompt('irb(%m)>', nil, 1, 1)) end @@ -668,7 +669,9 @@ def test_prompt_main_inspect_escape end def test_prompt_main_truncate - irb = IRB::Irb.new(IRB::WorkSpace.new("a" * 100)) + main = Struct.new(:to_s).new("a" * 100) + def main.inspect; to_s.inspect; end + irb = IRB::Irb.new(IRB::WorkSpace.new(main)) assert_equal('irb(aaaaaaaaaaaaaaaaaaaaaaaaaaaaa...)>', irb.prompt('irb(%m)>', nil, 1, 1)) assert_equal('irb("aaaaaaaaaaaaaaaaaaaaaaaaaaaa...)>', irb.prompt('irb(%M)>', nil, 1, 1)) end