Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions lib/irb/command/load.rb
Original file line number Diff line number Diff line change
Expand Up @@ -58,15 +58,15 @@ def execute_internal(file_name = nil)
rescue LoadError
end
when /\.(so|o|sl)$/
return ruby_require(file_name)
return require(file_name)
end

begin
irb_load(f = file_name + ".rb")
$".push f
return true
true
rescue LoadError
return ruby_require(file_name)
require(file_name)
end
end
end
Expand Down
3 changes: 0 additions & 3 deletions lib/irb/ext/loader.rb
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,6 @@ class LoadAbort < Exception;end
# See ExtendCommandBundle for more information.
module IrbLoader

alias ruby_load load
alias ruby_require require

# Loads the given file similarly to Kernel#load
def irb_load(fn, priv = nil)
path = search_file_from_ruby_path(fn)
Expand Down
17 changes: 17 additions & 0 deletions test/irb/test_command.rb
Original file line number Diff line number Diff line change
Expand Up @@ -494,6 +494,22 @@ def test_irb_require_skips_file_already_loaded_by_require
assert_match(/probe_loaded/, out)
assert_match(/prefix_loaded/, out)
end

def test_irb_require_falls_back_to_kernel_require_when_not_in_load_path
code = <<~RUBY
p 'fallback_loaded'
'fallback_path_should_not_print_return_value'.itself
RUBY
File.write("#{@tmpdir}/irb_require_fallback.rb", code)

out, err = execute_lines(
"irb_require './irb_require_fallback'\n",
)

assert_empty(err)
assert_include(out, 'fallback_loaded')
assert_not_include(out, 'fallback_path_should_not_print_return_value')
end
end

class WorkspaceCommandTestCase < CommandTestCase
Expand Down Expand Up @@ -592,6 +608,7 @@ def test_workspaces_various_truncation
'1234567891234567891...',
'aaaaaaaaaaaaaaaaaaa...'
]
assert_empty(err)
assert_include(out, "[#{expected_truncations.join(", ")}]")
end
end
Expand Down
Loading