File tree Expand file tree Collapse file tree 1 file changed +11
-0
lines changed
Expand file tree Collapse file tree 1 file changed +11
-0
lines changed Original file line number Diff line number Diff line change @@ -485,6 +485,13 @@ def test_initialize
485485 p2 = Pathname . new ( p1 )
486486 assert_equal ( p1 , p2 )
487487
488+ obj = Object . new
489+ assert_raise ( TypeError ) { Pathname . new ( obj ) }
490+
491+ obj = Object . new
492+ def obj . to_path ; "a/path" ; end
493+ assert_equal ( "a/path" , Pathname . new ( obj ) . to_s )
494+
488495 obj = Object . new
489496 def obj . to_str ; "a/b" ; end
490497 assert_equal ( "a/b" , Pathname . new ( obj ) . to_s )
@@ -494,6 +501,10 @@ def test_initialize_nul
494501 assert_raise ( ArgumentError ) { Pathname . new ( "a\0 " ) }
495502 end
496503
504+ def test_initialize_encoding
505+ assert_raise ( Encoding ::CompatibilityError ) { Pathname . new ( "a" . encode ( Encoding ::UTF_32BE ) ) }
506+ end
507+
497508 def test_global_constructor
498509 p = Pathname . new ( 'a' )
499510 assert_equal ( p , Pathname ( 'a' ) )
You can’t perform that action at this time.
0 commit comments