summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--test/pathname/test_pathname.rb11
1 files changed, 11 insertions, 0 deletions
diff --git a/test/pathname/test_pathname.rb b/test/pathname/test_pathname.rb
index e2d6a09fb2..10ab154220 100644
--- a/test/pathname/test_pathname.rb
+++ b/test/pathname/test_pathname.rb
@@ -486,6 +486,13 @@ class TestPathname < Test::Unit::TestCase
assert_equal(p1, p2)
obj = Object.new
+ assert_raise(TypeError) { Pathname.new(obj) }
+
+ obj = Object.new
+ def obj.to_path; "a/path"; end
+ assert_equal("a/path", Pathname.new(obj).to_s)
+
+ obj = Object.new
def obj.to_str; "a/b"; end
assert_equal("a/b", Pathname.new(obj).to_s)
end
@@ -494,6 +501,10 @@ class TestPathname < Test::Unit::TestCase
assert_raise(ArgumentError) { Pathname.new("a\0") }
end
+ def test_initialize_encoding
+ assert_raise(Encoding::CompatibilityError) { Pathname.new("a".encode(Encoding::UTF_32BE)) }
+ end
+
def test_global_constructor
p = Pathname.new('a')
assert_equal(p, Pathname('a'))