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 )
@@ -495,6 +502,10 @@ def test_initialize_nul
495502 assert_raise ( ArgumentError ) { Pathname . new ( "a\0 " ) }
496503 end
497504
505+ def test_initialize_encoding
506+ assert_raise ( Encoding ::CompatibilityError ) { Pathname . new ( "a" . encode ( Encoding ::UTF_32BE ) ) }
507+ end
508+
498509 def test_global_constructor
499510 p = Pathname . new ( 'a' )
500511 assert_equal ( p , Pathname ( 'a' ) )
You can’t perform that action at this time.
0 commit comments