ruby-changes:2420
From: ko1@a...
Date: 14 Nov 2007 00:04:02 +0900
Subject: [ruby-changes:2420] akr - Ruby:r13911 (ruby_1_8): pathname test backported.
akr 2007-11-14 00:03:43 +0900 (Wed, 14 Nov 2007) New Revision: 13911 Modified files: branches/ruby_1_8/test/pathname/test_pathname.rb Log: pathname test backported. http://svn.ruby-lang.org/cgi-bin/viewvc.cgi/branches/ruby_1_8/test/pathname/test_pathname.rb?r1=13911&r2=13910 Index: ruby_1_8/test/pathname/test_pathname.rb =================================================================== --- ruby_1_8/test/pathname/test_pathname.rb (revision 13910) +++ ruby_1_8/test/pathname/test_pathname.rb (revision 13911) @@ -8,13 +8,6 @@ require 'enumerator' class TestPathname < Test::Unit::TestCase - - if RUBY_VERSION < "1.9" - FUNCALL = :__send__ - else - FUNCALL = :funcall - end - def self.define_assertion(name, &block) @defassert_num ||= {} @defassert_num[name] ||= 0 @@ -123,7 +116,7 @@ # has_trailing_separator?(path) -> bool def has_trailing_separator?(path) - Pathname.allocate.send(FUNCALL, :has_trailing_separator?, path) + Pathname.allocate.__send__(:has_trailing_separator?, path) end defassert(:has_trailing_separator?, false, "/") @@ -132,11 +125,11 @@ defassert(:has_trailing_separator?, true, "a/") def add_trailing_separator(path) - Pathname.allocate.send(FUNCALL, :add_trailing_separator, path) + Pathname.allocate.__send__(:add_trailing_separator, path) end def del_trailing_separator(path) - Pathname.allocate.send(FUNCALL, :del_trailing_separator, path) + Pathname.allocate.__send__(:del_trailing_separator, path) end defassert(:del_trailing_separator, "/", "/") @@ -174,7 +167,10 @@ if DOSISH defassert(:del_trailing_separator, "a", "a\\") - defassert(:del_trailing_separator, "\225\\", "\225\\\\") # SJIS + require 'Win32API' + if Win32API.new('kernel32', 'GetACP', nil, 'L').call == 932 + defassert(:del_trailing_separator, "\225\\", "\225\\\\") # SJIS + end end def plus(path1, path2) # -> path @@ -284,16 +280,12 @@ return rescue TypeError end - dir = "#{Dir.tmpdir}/tst-pathname-#$$" - Dir.mkdir(dir) - begin + Dir.mktmpdir('rubytest-pathname') {|dir| File.symlink("not-exist-target", "#{dir}/not-exist") assert_raise(Errno::ENOENT) { realpath("#{dir}/not-exist") } File.symlink("loop", "#{dir}/loop") assert_raise(Errno::ELOOP) { realpath("#{dir}/loop") } - ensure - FileUtils.rmtree(dir) - end + } end def descend(path) -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml