diff options
Diffstat (limited to 'test/ruby')
| -rw-r--r-- | test/ruby/test_file_exhaustive.rb | 21 |
1 files changed, 19 insertions, 2 deletions
diff --git a/test/ruby/test_file_exhaustive.rb b/test/ruby/test_file_exhaustive.rb index 360a1c7cce..8a33258759 100644 --- a/test/ruby/test_file_exhaustive.rb +++ b/test/ruby/test_file_exhaustive.rb @@ -475,10 +475,12 @@ class TestFileExhaustive < Test::Unit::TestCase ENV["HOME"] = home end + UnknownUserHome = "~foo_bar_baz_unknown_user_wahaha".freeze + def test_expand_path_home assert_kind_of(String, File.expand_path("~")) if ENV["HOME"] - assert_raise(ArgumentError) { File.expand_path("~foo_bar_baz_unknown_user_wahaha") } - assert_raise(ArgumentError) { File.expand_path("~foo_bar_baz_unknown_user_wahaha", "/") } + assert_raise(ArgumentError) { File.expand_path(UnknownUserHome) } + assert_raise(ArgumentError) { File.expand_path(UnknownUserHome, "/") } begin bug3630 = '[ruby-core:31537]' home = ENV["HOME"] @@ -502,6 +504,21 @@ class TestFileExhaustive < Test::Unit::TestCase end end + def test_expand_path_home_dir_string + home = ENV["HOME"] + new_home = "#{DRIVE}/UserHome" + ENV["HOME"] = new_home + bug8034 = "[ruby-core:53168]" + + assert_equal File.join(new_home, "foo"), File.expand_path("foo", "~"), bug8034 + assert_equal File.join(new_home, "bar", "foo"), File.expand_path("foo", "~/bar"), bug8034 + + assert_raise(ArgumentError) { File.expand_path(".", UnknownUserHome) } + assert_nothing_raised(ArgumentError) { File.expand_path("#{DRIVE}/", UnknownUserHome) } + ensure + ENV["HOME"] = home + end + def test_expand_path_remove_trailing_alternative_data assert_equal File.join(@rootdir, "aaa"), File.expand_path("#{@rootdir}/aaa::$DATA") assert_equal File.join(@rootdir, "aa:a"), File.expand_path("#{@rootdir}/aa:a:$DATA") |
