diff options
author | yugui <yugui@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2009-10-31 13:05:04 +0000 |
---|---|---|
committer | yugui <yugui@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2009-10-31 13:05:04 +0000 |
commit | cf4c2318951820bb3bf19fd708d139a819e56a85 (patch) | |
tree | 7a329f5524939bb2647d558f7a32071862f8e781 /test | |
parent | 34ffc19c66e9c0fc1e8a8c70fab552090bb21df4 (diff) |
merges r24818 from trunk into ruby_1_9_1, with small modification.
--
* test/ruby/test_require.rb (test_relative): tests for require_relative.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_9_1@25593 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'test')
-rw-r--r-- | test/ruby/test_require.rb | 20 |
1 files changed, 19 insertions, 1 deletions
diff --git a/test/ruby/test_require.rb b/test/ruby/test_require.rb index 4bc44eff04..827cb228d5 100644 --- a/test/ruby/test_require.rb +++ b/test/ruby/test_require.rb @@ -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), []) @@ -241,4 +241,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('x/t.rb') + assert !require(File.expand_path('x/t.rb')) + assert_nothing_raised(LoadError) {require('./x/a.rb')} + File.unlink(*Dir.glob('x/*')) + Dir.rmdir("#{tmp}/x") + assert(!require('tmpdir')) + end + end + end end |