summaryrefslogtreecommitdiff
path: root/test/ruby
diff options
context:
space:
mode:
authorU.Nakamura <usa@ruby-lang.org>2023-11-06 20:22:27 +0900
committerU.Nakamura <usa@ruby-lang.org>2023-11-06 20:22:27 +0900
commit881088e06f092d20a361c9528b2927cdc2b1616c (patch)
tree3e155b6a05ea2684c1fc5b2d67cdf54e313709c5 /test/ruby
parent4f7b595815bd75706c276b03c8d445748e869f2e (diff)
merge revision(s) 4329554f171fdb483cafa672df5f2a08741940c5: [Backport #19985]
[Bug #19985] Raise LoadError with the converted feature name `Kernel#require` converts feature name objects that have the `to_path` method such as `Pathname`, but had used the original object on error and had resulted in an unexpected `TypeError`. --- load.c | 14 +++++++++++--- test/ruby/test_require.rb | 26 +++++++++++++++++++++----- 2 files changed, 32 insertions(+), 8 deletions(-)
Diffstat (limited to 'test/ruby')
-rw-r--r--test/ruby/test_require.rb26
1 files changed, 21 insertions, 5 deletions
diff --git a/test/ruby/test_require.rb b/test/ruby/test_require.rb
index f53bd2ce5f..54165bc31c 100644
--- a/test/ruby/test_require.rb
+++ b/test/ruby/test_require.rb
@@ -6,11 +6,27 @@ require 'tmpdir'
class TestRequire < Test::Unit::TestCase
def test_load_error_path
- filename = "should_not_exist"
- error = assert_raise(LoadError) do
- require filename
- end
- assert_equal filename, error.path
+ Tempfile.create(["should_not_exist", ".rb"]) {|t|
+ filename = t.path
+ t.close
+ File.unlink(filename)
+
+ error = assert_raise(LoadError) do
+ require filename
+ end
+ assert_equal filename, error.path
+
+ # with --disable=gems
+ assert_separately(["-", filename], "#{<<~"begin;"}\n#{<<~'end;'}")
+ begin;
+ filename = ARGV[0]
+ path = Struct.new(:to_path).new(filename)
+ error = assert_raise(LoadError) do
+ require path
+ end
+ assert_equal filename, error.path
+ end;
+ }
end
def test_require_invalid_shared_object