[ruby/irb] Fix test runner exit bug

(https://github.com/ruby/irb/pull/728)

* Remove useless test setup and teardown that sets MAIN_CONTEXT to nil

* Avoid adding command methods to main object in test

https://github.com/ruby/irb/commit/f204829a08
This commit is contained in:
tomoya ishida 2023-10-12 22:55:41 +09:00 committed by git
parent e029375a7d
commit cf21c72cdb
3 changed files with 6 additions and 11 deletions

View File

@ -22,7 +22,7 @@ module IRB # :nodoc:
#
# Same as <code>IRB.CurrentContext.exit</code>.
def irb_exit(ret = 0)
irb_context&.exit(ret)
irb_context.exit(ret)
end
# Displays current configuration.

View File

@ -6,15 +6,6 @@ require_relative "helper"
module TestIRB
class CompletionTest < TestCase
def setup
# make sure require completion candidates are not cached
IRB::BaseCompletor.class_variable_set(:@@files_from_load_path, nil)
end
def teardown
IRB.conf[:MAIN_CONTEXT] = nil
end
def completion_candidates(target, bind)
IRB::RegexpCompletor.new.completion_candidates('', target, '', bind: bind)
end

View File

@ -733,9 +733,13 @@ module TestIRB
private
def build_binding
Object.new.instance_eval { binding }
end
def build_irb
IRB.init_config(nil)
workspace = IRB::WorkSpace.new(TOPLEVEL_BINDING.dup)
workspace = IRB::WorkSpace.new(build_binding)
IRB.conf[:VERBOSE] = false
IRB::Irb.new(workspace, TestInputMethod.new)