summaryrefslogtreecommitdiff
path: root/test/ruby/test_require.rb
diff options
context:
space:
mode:
Diffstat (limited to 'test/ruby/test_require.rb')
-rw-r--r--test/ruby/test_require.rb46
1 files changed, 45 insertions, 1 deletions
diff --git a/test/ruby/test_require.rb b/test/ruby/test_require.rb
index 13e7076391..0067a49700 100644
--- a/test/ruby/test_require.rb
+++ b/test/ruby/test_require.rb
@@ -840,6 +840,36 @@ class TestRequire < Test::Unit::TestCase
p :ok
end;
}
+
+ # [Bug #21567]
+ assert_ruby_status(%w[-rtempfile], "#{<<~"begin;"}\n#{<<~"end;"}")
+ begin;
+ class MyString
+ def initialize(path)
+ @path = path
+ end
+
+ def to_str
+ $LOADED_FEATURES.clear
+ @path
+ end
+
+ def to_path = @path
+ end
+
+ FILES = []
+
+ def create_ruby_file
+ file = Tempfile.open(["test", ".rb"])
+ FILES << file
+ file.path
+ end
+
+ require MyString.new(create_ruby_file)
+ $LOADED_FEATURES.unshift(create_ruby_file)
+ $LOADED_FEATURES << MyString.new(create_ruby_file)
+ require create_ruby_file
+ end;
end
def test_loading_fifo_threading_raise
@@ -999,7 +1029,7 @@ class TestRequire < Test::Unit::TestCase
def test_require_with_public_method_missing
# [Bug #19793]
- assert_separately(["-W0", "-rtempfile"], __FILE__, __LINE__, <<~RUBY, timeout: 60)
+ assert_ruby_status(["-W0", "-rtempfile"], <<~RUBY, timeout: 60)
GC.stress = true
class Object
@@ -1011,4 +1041,18 @@ class TestRequire < Test::Unit::TestCase
end
RUBY
end
+
+ def test_bug_21568
+ load_path = $LOAD_PATH.dup
+ loaded_featrures = $LOADED_FEATURES.dup
+
+ $LOAD_PATH.clear
+ $LOADED_FEATURES.replace(["foo.so", "a/foo.rb", "b/foo.rb"])
+
+ assert_nothing_raised(LoadError) { require "foo" }
+
+ ensure
+ $LOAD_PATH.replace(load_path) if load_path
+ $LOADED_FEATURES.replace loaded_featrures
+ end
end