[前][次][番号順一覧][スレッド一覧]

ruby-changes:13235

From: nobu <ko1@a...>
Date: Fri, 18 Sep 2009 11:21:07 +0900 (JST)
Subject: [ruby-changes:13235] Ruby:r24993 (trunk): * test/fileutils/test_fileutils.rb: fixed indent by splitting methods.

nobu	2009-09-18 11:20:39 +0900 (Fri, 18 Sep 2009)

  New Revision: 24993

  http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=rev&revision=24993

  Log:
    * test/fileutils/test_fileutils.rb: fixed indent by splitting methods.

  Modified files:
    trunk/test/fileutils/test_fileutils.rb

Index: test/fileutils/test_fileutils.rb
===================================================================
--- test/fileutils/test_fileutils.rb	(revision 24992)
+++ test/fileutils/test_fileutils.rb	(revision 24993)
@@ -173,17 +173,11 @@
     assert_equal Dir.pwd, pwd()
 
     cwd = Dir.pwd
-if have_drive_letter?
-    cd('C:/') {
-      assert_equal 'C:/', pwd()
+    root = have_drive_letter? ? 'C:/' : '/'
+    cd(root) {
+      assert_equal root, pwd()
     }
     assert_equal cwd, pwd()
-else
-    cd('/') {
-      assert_equal '/', pwd()
-    }
-    assert_equal cwd, pwd()
-end
   end
 
   def test_cmp
@@ -233,7 +227,10 @@
     assert_raise(ArgumentError) {
       cp 'tmp/cptmp', 'tmp/cptmp'
     }
-if have_symlink?
+  end
+
+  def test_cp_symlink
+    touch 'tmp/cptmp'
     # src==dest (2) symlink and its target
     File.symlink 'cptmp', 'tmp/cptmp_symlink'
     assert_raise(ArgumentError) {
@@ -247,9 +244,11 @@
     assert_raise(Errno::ELOOP) {
       cp 'tmp/symlink', 'tmp/symlink'
     }
-end
+  end if have_symlink?
 
+  def test_cp_pathname
     # pathname
+    touch 'tmp/cptmp'
     assert_nothing_raised {
       cp 'tmp/cptmp', Pathname.new('tmp/tmpdest')
       cp Pathname.new('tmp/cptmp'), 'tmp/tmpdest'
@@ -287,8 +286,9 @@
     assert_directory 'tmp/cpr_dest/d'
     my_rm_rf 'tmp/cpr_src'
     my_rm_rf 'tmp/cpr_dest'
+  end
 
-if have_symlink?
+  def test_cp_r_symlink
     # symlink in a directory
     mkdir 'tmp/cpr_src'
     ln_s 'SLdest', 'tmp/cpr_src/symlink'
@@ -304,8 +304,9 @@
     assert_symlink 'tmp/cpr_dest2'   # 2005-05-26: feature change
     assert_symlink 'tmp/cpr_dest2/symlink'
     assert_equal 'SLdest', File.readlink('tmp/cpr_dest2/symlink')
-end
+  end if have_symlink?
 
+  def test_cp_r_pathname
     # pathname
     touch 'tmp/cprtmp'
     assert_nothing_raised {
@@ -346,7 +347,10 @@
     assert_raise(ArgumentError) {
       mv 'tmp/cptmp', 'tmp/cptmp'
     }
-if have_symlink?
+  end
+
+  def test_mv_symlink
+    touch 'tmp/cptmp'
     # src==dest (2) symlink and its target
     File.symlink 'cptmp', 'tmp/cptmp_symlink'
     assert_raise(ArgumentError) {
@@ -360,8 +364,9 @@
     assert_raise(Errno::ELOOP) {
       mv 'tmp/symlink', 'tmp/symlink'
     }
-end
+  end if have_symlink?
 
+  def test_mv_pathname
     # pathname
     assert_nothing_raised {
       touch 'tmp/mvtmpsrc'
@@ -403,14 +408,14 @@
       rm_f 'tmp/rmsrc'
       assert_file_not_exist 'tmp/rmsrc'
     end
+  end
 
-if have_symlink?
+  def test_rm_symlink
     File.open('tmp/lnf_symlink_src', 'w') {|f| f.puts 'dummy' }
     File.symlink 'tmp/lnf_symlink_src', 'tmp/lnf_symlink_dest'
     rm_f 'tmp/lnf_symlink_dest'
     assert_file_not_exist 'tmp/lnf_symlink_dest'
     assert_file_exist     'tmp/lnf_symlink_src'
-end
 
     rm_f 'notexistdatafile'
     rm_f 'tmp/notexistdatafile'
@@ -418,7 +423,9 @@
     Dir.mkdir 'tmpdatadir'
     # rm_f 'tmpdatadir'
     Dir.rmdir 'tmpdatadir'
+  end if have_symlink?
 
+  def test_rm_f_2
     Dir.mkdir 'tmp/tmpdir'
     File.open('tmp/tmpdir/a', 'w') {|f| f.puts 'dummy' }
     File.open('tmp/tmpdir/c', 'w') {|f| f.puts 'dummy' }
@@ -426,7 +433,9 @@
     assert_file_not_exist 'tmp/tmpdir/a'
     assert_file_not_exist 'tmp/tmpdir/c'
     Dir.rmdir 'tmp/tmpdir'
+  end
 
+  def test_rm_pathname
     # pathname
     touch 'tmp/rmtmp1'
     touch 'tmp/rmtmp2'
@@ -485,16 +494,18 @@
     assert_file_not_exist 'tmp/tmpdir/a'
     assert_file_not_exist 'tmp/tmpdir/c'
     Dir.rmdir 'tmp/tmpdir'
+  end
 
-if have_symlink?
+  def test_rm_r_symlink
     # [ruby-talk:94635] a symlink to the directory
     Dir.mkdir 'tmp/tmpdir'
     File.symlink '..', 'tmp/tmpdir/symlink_to_dir'
     rm_r 'tmp/tmpdir'
     assert_file_not_exist 'tmp/tmpdir'
     assert_file_exist     'tmp'
-end
+  end if have_symlink?
 
+  def test_rm_r_pathname
     # pathname
     Dir.mkdir 'tmp/tmpdir1'; touch 'tmp/tmpdir1/tmp'
     Dir.mkdir 'tmp/tmpdir2'; touch 'tmp/tmpdir2/tmp'
@@ -548,16 +559,18 @@
     assert_file_not_exist 'tmp/tmpdir/a'
     assert_file_not_exist 'tmp/tmpdir/c'
     Dir.rmdir 'tmp/tmpdir'
+  end
 
-if have_symlink?
+  def test_remove_entry_secure_symlink
     # [ruby-talk:94635] a symlink to the directory
     Dir.mkdir 'tmp/tmpdir'
     File.symlink '..', 'tmp/tmpdir/symlink_to_dir'
     remove_entry_secure 'tmp/tmpdir'
     assert_file_not_exist 'tmp/tmpdir'
     assert_file_exist     'tmp'
-end
+  end if have_symlink?
 
+  def test_remove_entry_secure_pathname
     # pathname
     Dir.mkdir 'tmp/tmpdir1'; touch 'tmp/tmpdir1/tmp'
     assert_nothing_raised {
@@ -581,7 +594,6 @@
     assert_file_not_exist 'tmp/mvdest'
   end
 
-if have_hardlink?
   def test_ln
     TARGETS.each do |fname|
       ln fname, 'tmp/lndest'
@@ -602,7 +614,10 @@
     assert_raise(Errno::EEXIST) {
       ln 'tmp/cptmp', 'tmp/cptmp'
     }
-if have_symlink?
+  end if have_hardlink?
+
+  def test_ln_symlink
+    touch 'tmp/cptmp'
     # src==dest (2) symlink and its target
     File.symlink 'cptmp', 'tmp/symlink'
     assert_raise(Errno::EEXIST) {
@@ -618,8 +633,9 @@
     rescue => err
       assert_kind_of SystemCallError, err
     end
-end
+  end if have_symlink?
 
+  def test_ln_pathname
     # pathname
     touch 'tmp/lntmp'
     assert_nothing_raised {
@@ -627,10 +643,8 @@
       ln 'tmp/lntmp', Pathname.new('tmp/lndesttmp2')
       ln Pathname.new('tmp/lntmp'), Pathname.new('tmp/lndesttmp3')
     }
-  end
-end
+  end if have_hardlink?
 
-if have_symlink?
   def test_ln_s
     check_singleton :ln_s
 
@@ -652,10 +666,8 @@
       ln_s 'lnsdest', Pathname.new('tmp/symlink_tmp2')
       ln_s Pathname.new('lnsdest'), Pathname.new('tmp/symlink_tmp3')
     }
-  end
-end
+  end if have_symlink?
 
-if have_symlink?
   def test_ln_sf
     check_singleton :ln_sf
 
@@ -677,8 +689,7 @@
       ln_sf 'lns_dest', Pathname.new('tmp/symlink_tmp2')
       ln_sf Pathname.new('lns_dest'), Pathname.new('tmp/symlink_tmp3')
     }
-  end
-end
+  end if have_symlink?
 
   def test_mkdir
     check_singleton :mkdir
@@ -700,20 +711,22 @@
     assert_directory 'tmp/tmp'
     assert_equal 0700, (File.stat('tmp/tmp').mode & 0777) if have_file_perm?
     Dir.rmdir 'tmp/tmp'
+  end
 
-if have_file_perm?
+  def test_mkdir_file_perm
     mkdir 'tmp/tmp', :mode => 07777
     assert_directory 'tmp/tmp'
     assert_equal 07777, (File.stat('tmp/tmp').mode & 07777)
     Dir.rmdir 'tmp/tmp'
-end
+  end if have_file_perm?
 
-if lf_in_path_allowed?
+  def test_mkdir_lf_in_path
     mkdir "tmp-first-line\ntmp-second-line"
     assert_directory "tmp-first-line\ntmp-second-line"
     Dir.rmdir "tmp-first-line\ntmp-second-line"
-end
+  end if lf_in_path_allowed?
 
+    def test_mkdir_pathname
     # pathname
     assert_nothing_raised {
       mkdir Pathname.new('tmp/tmpdirtmp')
@@ -771,15 +784,17 @@
     # (rm(1) try to chdir to parent directory, it fails to remove directory.)
     Dir.rmdir 'tmp/tmp'
     Dir.rmdir 'tmp'
+  end
 
-if have_file_perm?
+  def test_mkdir_p_file_perm
     mkdir_p 'tmp/tmp/tmp', :mode => 07777
     assert_directory 'tmp/tmp/tmp'
     assert_equal 07777, (File.stat('tmp/tmp/tmp').mode & 07777)
     Dir.rmdir 'tmp/tmp/tmp'
     Dir.rmdir 'tmp/tmp'
-end
+  end if have_file_perm?
 
+  def test_mkdir_p_pathname
     # pathname
     assert_nothing_raised {
       mkdir_p Pathname.new('tmp/tmp/tmp')
@@ -809,7 +824,10 @@
     assert_raise(ArgumentError) {
       install 'tmp/cptmp', 'tmp/cptmp'
     }
-if have_symlink?
+  end
+
+  def test_install_symlink
+    touch 'tmp/cptmp'
     # src==dest (2) symlink and its target
     File.symlink 'cptmp', 'tmp/cptmp_symlink'
     assert_raise(ArgumentError) {
@@ -824,8 +842,9 @@
       # File#install invokes open(2), always ELOOP must be raised
       install 'tmp/symlink', 'tmp/symlink'
     }
-end
+  end if have_symlink?
 
+  def test_install_pathname
     # pathname
     assert_nothing_raised {
       rm_f 'tmp/a'; touch 'tmp/a'
@@ -845,7 +864,6 @@
     }
   end
 
-if have_file_perm?
   def test_chmod
     check_singleton :chmod
 
@@ -854,7 +872,7 @@
     assert_equal 0700, File.stat('tmp/a').mode & 0777
     chmod 0500, 'tmp/a'
     assert_equal 0500, File.stat('tmp/a').mode & 0777
-  end
+  end if have_file_perm?
 
   def test_chmod_R
     check_singleton :chmod_R
@@ -872,18 +890,17 @@
     assert_equal 0500, File.stat('tmp/dir/dir').mode & 0777
     assert_equal 0500, File.stat('tmp/dir/dir/file').mode & 0777
     chmod_R 0700, 'tmp/dir'   # to remove
-  end
+  end if have_file_perm?
 
   # FIXME: How can I test this method?
   def test_chown
     check_singleton :chown
-  end
+  end if have_file_perm?
 
   # FIXME: How can I test this method?
   def test_chown_R
     check_singleton :chown_R
-  end
-end
+  end if have_file_perm?
 
   def test_copy_entry
     check_singleton :copy_entry
@@ -893,7 +910,9 @@
       assert_same_file srcpath, destpath
       assert_equal File.stat(srcpath).ftype, File.stat(destpath).ftype
     end
-if have_symlink?
+  end
+
+  def test_copy_entry_symlink
     # root is a symlink
     File.symlink 'somewhere', 'tmp/symsrc'
     copy_entry 'tmp/symsrc', 'tmp/symdest'
@@ -908,8 +927,7 @@
     assert_not_symlink 'tmp/dirdest'
     assert_symlink 'tmp/dirdest/sym'
     assert_equal 'somewhere', File.readlink('tmp/dirdest/sym')
-end
-  end
+  end if have_symlink?
 
   def test_copy_file
     check_singleton :copy_file
@@ -950,13 +968,14 @@
     File.open('data/tmp', 'w') {|f| f.puts 'dummy' }
     remove_file 'data/tmp'
     assert_file_not_exist 'data/tmp'
-if have_file_perm?
+  end
+
+  def test_remove_file_file_perm
     File.open('data/tmp', 'w') {|f| f.puts 'dummy' }
     File.chmod 0, 'data/tmp'
     remove_file 'data/tmp'
     assert_file_not_exist 'data/tmp'
-end
-  end
+  end if have_file_perm?
 
   def test_remove_dir
     check_singleton :remove_dir
@@ -964,13 +983,14 @@
     File.open('data/tmpdir/a', 'w') {|f| f.puts 'dummy' }
     remove_dir 'data/tmpdir'
     assert_file_not_exist 'data/tmpdir'
-if have_file_perm?
+  end
+
+  def test_remove_dir_file_perm
     Dir.mkdir 'data/tmpdir'
     File.chmod 0555, 'data/tmpdir'
     remove_dir 'data/tmpdir'
     assert_file_not_exist 'data/tmpdir'
-end
-  end
+  end if have_file_perm?
 
   def test_compare_file
     check_singleton :compare_file

--
ML: ruby-changes@q...
Info: http://www.atdot.net/~ko1/quickml/

[前][次][番号順一覧][スレッド一覧]