diff options
Diffstat (limited to 'test/irb/test_workspace.rb')
-rw-r--r-- | test/irb/test_workspace.rb | 26 |
1 files changed, 21 insertions, 5 deletions
diff --git a/test/irb/test_workspace.rb b/test/irb/test_workspace.rb index f028fc3aa2..199ce95a37 100644 --- a/test/irb/test_workspace.rb +++ b/test/irb/test_workspace.rb @@ -1,13 +1,13 @@ # frozen_string_literal: false -require 'test/unit' require 'tempfile' -require 'rubygems' require 'irb' require 'irb/workspace' require 'irb/color' +require_relative "helper" + module TestIRB - class TestWorkSpace < Test::Unit::TestCase + class WorkSpaceTest < TestCase def test_code_around_binding IRB.conf[:USE_COLORIZE] = false Tempfile.create('irb') do |f| @@ -39,8 +39,8 @@ module TestIRB end def test_code_around_binding_with_existing_unreadable_file - skip 'chmod cannot make file unreadable on windows' if windows? - skip 'skipped in root privilege' if Process.uid == 0 + pend 'chmod cannot make file unreadable on windows' if windows? + pend 'skipped in root privilege' if Process.uid == 0 Tempfile.create('irb') do |f| code = "IRB::WorkSpace.new(binding)\n" @@ -80,6 +80,22 @@ module TestIRB assert_equal(nil, workspace.code_around_binding) end + + def test_toplevel_binding_local_variables + bug17623 = '[ruby-core:102468]' + bundle_exec = ENV.key?('BUNDLE_GEMFILE') ? ['-rbundler/setup'] : [] + top_srcdir = "#{__dir__}/../.." + irb_path = nil + %w[exe libexec].find do |dir| + irb_path = "#{top_srcdir}/#{dir}/irb" + File.exist?(irb_path) + end or omit 'irb command not found' + assert_in_out_err(bundle_exec + ['-W0', "-C#{top_srcdir}", '-e', <<~RUBY, '--', '-f', '--'], 'binding.local_variables', /\[:_\]/, [], bug17623) + version = 'xyz' # typical rubygems loading file + load('#{irb_path}') + RUBY + end + private def with_script_lines |