From 3a8f7f1d7f3f1b66f47c37b230bc9c53cbdae250 Mon Sep 17 00:00:00 2001 From: akr Date: Sun, 9 Dec 2007 05:12:31 +0000 Subject: * include/ruby/ruby.h (FilePathStringValue): defined. similar to FilePathValue but no taint check. * file.c (rb_get_path_no_checksafe): implementation of FilePathStringValue. (rb_file_s_basename): use FilePathStringValue. (rb_file_s_dirname): ditto. (rb_file_s_extname): ditto. (rb_file_s_split): ditto. (rb_file_join): ditto. * dir.c (file_s_fnmatch): ditto. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@14155 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- test/pathname/test_pathname.rb | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) (limited to 'test/pathname') diff --git a/test/pathname/test_pathname.rb b/test/pathname/test_pathname.rb index 9b0b9c01e8..246b69f0e3 100644 --- a/test/pathname/test_pathname.rb +++ b/test/pathname/test_pathname.rb @@ -475,4 +475,32 @@ class TestPathname < Test::Unit::TestCase def test_kernel_pathname assert_equal(Pathname.new("a"), Pathname("a")) end + + def test_file_basename + assert_equal("bar", File.basename(Pathname.new("foo/bar"))) + end + + def test_file_dirname + assert_equal("foo", File.dirname(Pathname.new("foo/bar"))) + end + + def test_file_split + assert_equal(["foo", "bar"], File.split(Pathname.new("foo/bar"))) + end + + def test_file_extname + assert_equal(".baz", File.extname(Pathname.new("bar.baz"))) + end + + def test_file_fnmatch + assert(File.fnmatch("*.*", Pathname.new("bar.baz"))) + end + + def test_file_join + assert_equal("foo/bar", File.join(Pathname.new("foo"), Pathname.new("bar"))) + lambda { + $SAFE = 1 + assert_equal("foo/bar", File.join(Pathname.new("foo"), Pathname.new("bar").taint)) + }.call + end end -- cgit v1.2.3