diff options
author | nagachika <nagachika@ruby-lang.org> | 2020-07-23 17:47:12 +0900 |
---|---|---|
committer | nagachika <nagachika@ruby-lang.org> | 2020-07-23 17:47:12 +0900 |
commit | c65aae118ccff86096b9983641b371491bc23434 (patch) | |
tree | dce07e720618676232977726e352430712db6140 /test | |
parent | 4437f9eb0bf8369bcf12bd7cd324e11b5d885e07 (diff) | |
download | ruby-c65aae118ccff86096b9983641b371491bc23434.tar.gz |
merge revision(s) 927308108cced69cae478798004524b9a5d2f252: [Backport #16764]
Fix source location of autoloaded constant [Bug #16764]
Diffstat (limited to 'test')
-rw-r--r-- | test/ruby/test_autoload.rb | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/test/ruby/test_autoload.rb b/test/ruby/test_autoload.rb index 2e53c9203d..171dbb6293 100644 --- a/test/ruby/test_autoload.rb +++ b/test/ruby/test_autoload.rb @@ -425,6 +425,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| |