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

ruby-changes:54204

From: nobu <ko1@a...>
Date: Mon, 17 Dec 2018 13:58:54 +0900 (JST)
Subject: [ruby-changes:54204] nobu:r66425 (trunk): Split test_expand_path, test_basename, test_dirname

nobu	2018-12-17 13:58:49 +0900 (Mon, 17 Dec 2018)

  New Revision: 66425

  https://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=revision&revision=66425

  Log:
    Split test_expand_path, test_basename, test_dirname

  Modified files:
    trunk/test/ruby/test_file_exhaustive.rb
Index: test/ruby/test_file_exhaustive.rb
===================================================================
--- test/ruby/test_file_exhaustive.rb	(revision 66424)
+++ test/ruby/test_file_exhaustive.rb	(revision 66425)
@@ -781,7 +781,10 @@ class TestFileExhaustive < Test::Unit::T https://github.com/ruby/ruby/blob/trunk/test/ruby/test_file_exhaustive.rb#L781
   def test_expand_path
     assert_equal(regular_file, File.expand_path(File.basename(regular_file), File.dirname(regular_file)))
     assert_equal(utf8_file, File.expand_path(File.basename(utf8_file), File.dirname(utf8_file)))
-    if NTFS
+  end
+
+  if NTFS
+    def test_expand_path_ntfs
       [regular_file, utf8_file].each do |file|
         assert_equal(file, File.expand_path(file + " "))
         assert_equal(file, File.expand_path(file + "."))
@@ -792,8 +795,11 @@ class TestFileExhaustive < Test::Unit::T https://github.com/ruby/ruby/blob/trunk/test/ruby/test_file_exhaustive.rb#L795
       assert_match(/\Ae:\//i, File.expand_path('e:foo', 'd:/bar'))
       assert_match(%r'\Ac:/bar/foo\z'i, File.expand_path('c:foo', 'c:/bar'))
     end
-    case RUBY_PLATFORM
-    when /darwin/
+  end
+
+  case RUBY_PLATFORM
+  when /darwin/
+    def test_expand_path_hfs
       ["\u{feff}", *"\u{2000}"..."\u{2100}"].each do |c|
         file = regular_file + c
         full_path = File.expand_path(file)
@@ -809,11 +815,16 @@ class TestFileExhaustive < Test::Unit::T https://github.com/ruby/ruby/blob/trunk/test/ruby/test_file_exhaustive.rb#L815
         end
       end
     end
-    if DRIVE
+  end
+
+  if DRIVE
+    def test_expand_path_absolute
       assert_match(%r"\Az:/foo\z"i, File.expand_path('/foo', "z:/bar"))
       assert_match(%r"\A//host/share/foo\z"i, File.expand_path('/foo', "//host/share/bar"))
       assert_match(%r"\A#{DRIVE}/foo\z"i, File.expand_path('/foo'))
-    else
+    end
+  else
+    def test_expand_path_absolute
       assert_equal("/foo", File.expand_path('/foo'))
     end
   end
@@ -1183,7 +1194,10 @@ class TestFileExhaustive < Test::Unit::T https://github.com/ruby/ruby/blob/trunk/test/ruby/test_file_exhaustive.rb#L1194
     assert_equal("foo", File.basename("foo", ".ext"))
     assert_equal("foo", File.basename("foo.ext", ".ext"))
     assert_equal("foo", File.basename("foo.ext", ".*"))
-    if NTFS
+  end
+
+  if NTFS
+    def test_basename_strip
       [regular_file, utf8_file].each do |file|
         basename = File.basename(file)
         assert_equal(basename, File.basename(file + " "))
@@ -1197,7 +1211,9 @@ class TestFileExhaustive < Test::Unit::T https://github.com/ruby/ruby/blob/trunk/test/ruby/test_file_exhaustive.rb#L1211
         assert_equal(basename, File.basename(file + ".", ".*"))
         assert_equal(basename, File.basename(file + "::$DATA", ".*"))
       end
-    else
+    end
+  else
+    def test_basename_strip
       [regular_file, utf8_file].each do |file|
         basename = File.basename(file)
         assert_equal(basename + " ", File.basename(file + " "))
@@ -1212,13 +1228,18 @@ class TestFileExhaustive < Test::Unit::T https://github.com/ruby/ruby/blob/trunk/test/ruby/test_file_exhaustive.rb#L1228
         assert_equal(basename, File.basename(file + "::$DATA", ".*"))
       end
     end
-    if File::ALT_SEPARATOR == '\\'
+  end
+
+  if File::ALT_SEPARATOR == '\\'
+    def test_basename_backslash
       a = "foo/\225\\\\"
       [%W"cp437 \225", %W"cp932 \225\\"].each do |cp, expected|
         assert_equal(expected.force_encoding(cp), File.basename(a.dup.force_encoding(cp)), cp)
       end
     end
+  end
 
+  def test_basename_encoding
     assert_incompatible_encoding {|d| File.basename(d)}
     assert_incompatible_encoding {|d| File.basename(d, ".*")}
     assert_raise(Encoding::CompatibilityError) {File.basename("foo.ext", ".*".encode("utf-16le"))}
@@ -1234,8 +1255,14 @@ class TestFileExhaustive < Test::Unit::T https://github.com/ruby/ruby/blob/trunk/test/ruby/test_file_exhaustive.rb#L1255
     assert_equal(@dir, File.dirname(regular_file))
     assert_equal(@dir, File.dirname(utf8_file))
     assert_equal(".", File.dirname(""))
+  end
+
+  def test_dirname_encoding
     assert_incompatible_encoding {|d| File.dirname(d)}
-    if File::ALT_SEPARATOR == '\\'
+  end
+
+  if File::ALT_SEPARATOR == '\\'
+    def test_dirname_backslash
       a = "\225\\\\foo"
       [%W"cp437 \225", %W"cp932 \225\\"].each do |cp, expected|
         assert_equal(expected.force_encoding(cp), File.dirname(a.dup.force_encoding(cp)), cp)

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

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