summaryrefslogtreecommitdiff
path: root/test/ruby/test_autoload.rb
diff options
context:
space:
mode:
authorNobuyoshi Nakada <[email protected]>2020-04-07 21:35:28 +0900
committerNobuyoshi Nakada <[email protected]>2020-04-07 21:35:28 +0900
commit927308108cced69cae478798004524b9a5d2f252 (patch)
tree4ea06b5df2a5a59aa1dec8ec732a593484233fb9 /test/ruby/test_autoload.rb
parentce608213872d4efe80708f872ee2e32c547dd734 (diff)
Fix source location of autoloaded constant [Bug #16764]
Notes
Notes: Merged: https://github.com/ruby/ruby/pull/3009
Diffstat (limited to 'test/ruby/test_autoload.rb')
-rw-r--r--test/ruby/test_autoload.rb13
1 files changed, 13 insertions, 0 deletions
diff --git a/test/ruby/test_autoload.rb b/test/ruby/test_autoload.rb
index b3ccf183ec..d3470d59d4 100644
--- a/test/ruby/test_autoload.rb
+++ b/test/ruby/test_autoload.rb
@@ -427,6 +427,19 @@ p Foo::Bar
end
end
+ def test_source_location
+ klass = self.class
+ bug = "Bug16764"
+ Dir.mktmpdir('autoload') do |tmpdir|
+ path = "#{tmpdir}/test-#{bug}.rb"
+ File.write(path, "#{klass}::#{bug} = __FILE__\n")
+ klass.autoload(:Bug16764, path)
+ assert_equal [__FILE__, __LINE__-1], klass.const_source_location(bug)
+ assert_equal path, klass.const_get(bug)
+ assert_equal [path, 1], klass.const_source_location(bug)
+ end
+ end
+
def test_no_leak
assert_no_memory_leak([], '', <<~'end;', 'many autoloads', timeout: 60)
200000.times do |i|