1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00

* test/ruby/test_require.rb (test_relative): tests for require_relative.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@24818 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
nobu 2009-09-09 07:21:49 +00:00
parent 31a6d50863
commit 481a6476ce

View file

@ -198,7 +198,7 @@ class TestRequire < Test::Unit::TestCase
def test_tainted_loadpath
t = Tempfile.new(["test_ruby_test_require", ".rb"])
abs_dir, file = File.dirname(t.path), File.basename(t.path)
abs_dir, file = File.split(t.path)
abs_dir = File.expand_path(abs_dir).untaint
assert_in_out_err([], <<-INPUT, %w(:ok), [])
@ -244,4 +244,22 @@ class TestRequire < Test::Unit::TestCase
p :ok
INPUT
end
def test_relative
require 'tmpdir'
Dir.mktmpdir do |tmp|
Dir.chdir(tmp) do
Dir.mkdir('x')
File.open('x/t.rb', 'wb') {}
File.open('x/a.rb', 'wb') {|f| f.puts("require_relative('t.rb')")}
assert require('./x/t.rb')
assert !require(File.expand_path('x/t.rb'))
assert_nothing_raised(LoadError) {require('./x/a.rb')}
assert_raise(LoadError) {require('x/t.rb')}
File.unlink(*Dir.glob('x/*'))
Dir.rmdir("#{tmp}/x")
assert(!require('tmpdir'))
end
end
end
end