diff options
Diffstat (limited to 'test/ruby/test_autoload.rb')
-rw-r--r-- | test/ruby/test_autoload.rb | 15 |
1 files changed, 9 insertions, 6 deletions
diff --git a/test/ruby/test_autoload.rb b/test/ruby/test_autoload.rb index 2e2e79dffd..98d513da87 100644 --- a/test/ruby/test_autoload.rb +++ b/test/ruby/test_autoload.rb @@ -428,15 +428,18 @@ p Foo::Bar 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) + File.write(path, "C::#{bug} = __FILE__\n") + assert_separately(%W[-I #{tmpdir}], "#{<<-"begin;"}\n#{<<-"end;"}") + begin; + class C; end + C.autoload(:Bug16764, #{path.dump}) + assert_equal [__FILE__, __LINE__-1], C.const_source_location(#{bug.dump}) + assert_equal #{path.dump}, C.const_get(#{bug.dump}) + assert_equal [#{path.dump}, 1], C.const_source_location(#{bug.dump}) + end; end end |