diff --git a/test/irb/helper.rb b/test/irb/helper.rb index ea2c6ef16..17e463e2a 100644 --- a/test/irb/helper.rb +++ b/test/irb/helper.rb @@ -91,6 +91,25 @@ def without_rdoc(&block) ::Kernel.undef_method :irb_original_require } end + + def execute_lines(*lines, conf: {}, main: self, irb_path: nil) + # To suppress irb_info measure ambiguous_width with escape sequences + Reline.core.instance_variable_set(:@ambiguous_width, 1) + + IRB.init_config(nil) + IRB.conf[:VERBOSE] = false + IRB.conf[:PROMPT_MODE] = :SIMPLE + IRB.conf.merge!(conf) + input = TestInputMethod.new(lines) + irb = IRB::Irb.new(IRB::WorkSpace.new(main), input) + irb.context.return_format = "=> %s\n" + irb.context.irb_path = irb_path if irb_path + IRB.conf[:MAIN_CONTEXT] = irb.context + IRB.conf[:USE_PAGER] = false + capture_output do + irb.eval_input + end + end end class IntegrationTestCase < TestCase diff --git a/test/irb/test_command.rb b/test/irb/test_command.rb index ec2d1f92d..fd98a5a1b 100644 --- a/test/irb/test_command.rb +++ b/test/irb/test_command.rb @@ -37,22 +37,6 @@ def teardown FileUtils.rm_rf(@tmpdir) restore_encodings end - - def execute_lines(*lines, conf: {}, main: self, irb_path: nil) - capture_output do - IRB.init_config(nil) - IRB.conf[:VERBOSE] = false - IRB.conf[:PROMPT_MODE] = :SIMPLE - IRB.conf[:USE_PAGER] = false - IRB.conf.merge!(conf) - input = TestInputMethod.new(lines) - irb = IRB::Irb.new(IRB::WorkSpace.new(main), input) - irb.context.return_format = "=> %s\n" - irb.context.irb_path = irb_path if irb_path - IRB.conf[:MAIN_CONTEXT] = irb.context - irb.eval_input - end - end end class FrozenObjectTest < CommandTestCase diff --git a/test/irb/test_eval_history.rb b/test/irb/test_eval_history.rb index 54913ceff..685ad679a 100644 --- a/test/irb/test_eval_history.rb +++ b/test/irb/test_eval_history.rb @@ -14,22 +14,6 @@ def teardown restore_encodings end - def execute_lines(*lines, conf: {}, main: self, irb_path: nil) - IRB.init_config(nil) - IRB.conf[:VERBOSE] = false - IRB.conf[:PROMPT_MODE] = :SIMPLE - IRB.conf[:USE_PAGER] = false - IRB.conf.merge!(conf) - input = TestInputMethod.new(lines) - irb = IRB::Irb.new(IRB::WorkSpace.new(main), input) - irb.context.return_format = "=> %s\n" - irb.context.irb_path = irb_path if irb_path - IRB.conf[:MAIN_CONTEXT] = irb.context - capture_output do - irb.eval_input - end - end - def test_eval_history_is_disabled_by_default out, err = execute_lines( "a = 1", diff --git a/test/irb/test_helper_method.rb b/test/irb/test_helper_method.rb index a3e2c43b2..4b61397b7 100644 --- a/test/irb/test_helper_method.rb +++ b/test/irb/test_helper_method.rb @@ -16,22 +16,6 @@ def teardown $VERBOSE = @verbosity restore_encodings end - - def execute_lines(*lines, conf: {}, main: self, irb_path: nil) - IRB.init_config(nil) - IRB.conf[:VERBOSE] = false - IRB.conf[:PROMPT_MODE] = :SIMPLE - IRB.conf.merge!(conf) - input = TestInputMethod.new(lines) - irb = IRB::Irb.new(IRB::WorkSpace.new(main), input) - irb.context.return_format = "=> %s\n" - irb.context.irb_path = irb_path if irb_path - IRB.conf[:MAIN_CONTEXT] = irb.context - IRB.conf[:USE_PAGER] = false - capture_output do - irb.eval_input - end - end end module TestHelperMethod