From 1758ff03819ce2c699345a4299f6fecdd25f8c0b Mon Sep 17 00:00:00 2001 From: nobu Date: Wed, 24 Jul 2013 08:38:01 +0000 Subject: file.c: exception message encoding * file.c (rb_file_expand_path_internal): preserve the file name encoding in an exception message. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@42150 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- test/ruby/test_file_exhaustive.rb | 13 +++++++++++++ 1 file changed, 13 insertions(+) (limited to 'test') diff --git a/test/ruby/test_file_exhaustive.rb b/test/ruby/test_file_exhaustive.rb index 3394d12372..219d357cf2 100644 --- a/test/ruby/test_file_exhaustive.rb +++ b/test/ruby/test_file_exhaustive.rb @@ -669,6 +669,19 @@ class TestFileExhaustive < Test::Unit::TestCase assert_raise(ArgumentError, bug) { File.expand_path("~anything") } end if DRIVE + def test_expand_path_error_for_nonexistent_username + user = "\u{3086 3046 3066 3044}:\u{307F 3084 304A 3046}" + assert_raise_with_message(ArgumentError, /#{user}/) {File.expand_path("~#{user}")} + end unless DRIVE + + def test_expand_path_error_for_non_absolute_home + old_home = ENV["HOME"] + ENV["HOME"] = "./UserHome" + assert_raise_with_message(ArgumentError, /non-absolute home/) {File.expand_path("~")} + ensure + ENV["HOME"] = old_home + end + def test_expand_path_raises_a_type_error_if_not_passed_a_string_type assert_raise(TypeError) { File.expand_path(1) } assert_raise(TypeError) { File.expand_path(nil) } -- cgit v1.2.3