diff options
-rw-r--r-- | ext/pathname/pathname.c | 2 | ||||
-rw-r--r-- | test/pathname/test_pathname.rb | 15 |
2 files changed, 16 insertions, 1 deletions
diff --git a/ext/pathname/pathname.c b/ext/pathname/pathname.c index 55577d7da7..1d4ed2814b 100644 --- a/ext/pathname/pathname.c +++ b/ext/pathname/pathname.c @@ -834,7 +834,7 @@ path_split(VALUE self) VALUE str = get_strpath(self); VALUE ary, dirname, basename; ary = rb_funcall(rb_cFile, id_split, 1, str); - ary = rb_check_array_type(ary); + Check_Type(ary, T_ARRAY); dirname = rb_ary_entry(ary, 0); basename = rb_ary_entry(ary, 1); dirname = rb_class_new_instance(1, &dirname, rb_obj_class(self)); diff --git a/test/pathname/test_pathname.rb b/test/pathname/test_pathname.rb index 46a04ee2b6..8a0f3cbb66 100644 --- a/test/pathname/test_pathname.rb +++ b/test/pathname/test_pathname.rb @@ -1067,6 +1067,21 @@ class TestPathname < Test::Unit::TestCase def test_split assert_equal([Pathname("dirname"), Pathname("basename")], Pathname("dirname/basename").split) + + assert_separately([], <<-'end;') + require 'pathname' + + mod = Module.new do + def split(_arg) + end + end + + File.singleton_class.prepend(mod) + + assert_raise(TypeError) do + Pathname('/').split + end + end; end def test_blockdev? |