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

ruby-changes:39933

From: nobu <ko1@a...>
Date: Sun, 4 Oct 2015 11:19:06 +0900 (JST)
Subject: [ruby-changes:39933] nobu:r52014 (trunk): test_dir_m17n.rb: fix test

nobu	2015-10-04 11:18:58 +0900 (Sun, 04 Oct 2015)

  New Revision: 52014

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

  Log:
    test_dir_m17n.rb: fix test
    
    * test/ruby/test_dir_m17n.rb (test_pwd): fix test on some
      platforms.

  Modified files:
    trunk/test/ruby/test_dir_m17n.rb
Index: test/ruby/test_dir_m17n.rb
===================================================================
--- test/ruby/test_dir_m17n.rb	(revision 52013)
+++ test/ruby/test_dir_m17n.rb	(revision 52014)
@@ -371,20 +371,20 @@ class TestDir_M17N < Test::Unit::TestCas https://github.com/ruby/ruby/blob/trunk/test/ruby/test_dir_m17n.rb#L371
     end
   end
 
+  PP = Object.new.extend(Test::Unit::Assertions)
+  def PP.mu_pp(ary) #:nodoc:
+    '[' << ary.map {|str| "#{str.dump}(#{str.encoding})"}.join(', ') << ']'
+  end
+
   def test_entries_compose
     bug7267 = '[ruby-core:48745] [Bug #7267]'
 
-    pp = Object.new.extend(Test::Unit::Assertions)
-    def pp.mu_pp(ary) #:nodoc:
-      '[' << ary.map {|str| "#{str.dump}(#{str.encoding})"}.join(', ') << ']'
-    end
-
     with_tmpdir {|d|
       orig = %W"d\u{e9}tente x\u{304c 304e 3050 3052 3054}"
       orig.each {|n| open(n, "w") {}}
       if /mswin|mingw/ =~ RUBY_PLATFORM
         opts = {:encoding => Encoding.default_external}
-        orig.map! {|o| o.encode(Encoding.find("filesystem")) rescue o.tr("^a-z", "?")}
+        orig.map! {|o| o.encode("filesystem") rescue o.tr("^a-z", "?")}
       else
         enc = Encoding.find("filesystem")
         enc = Encoding::ASCII_8BIT if enc == Encoding::US_ASCII
@@ -392,17 +392,28 @@ class TestDir_M17N < Test::Unit::TestCas https://github.com/ruby/ruby/blob/trunk/test/ruby/test_dir_m17n.rb#L392
       end
       ents = Dir.entries(".", opts).reject {|n| /\A\./ =~ n}
       ents.sort!
-      pp.assert_equal(orig, ents, bug7267)
+      PP.assert_equal(orig, ents, bug7267)
     }
   end
 
   def test_pwd
-    with_tmpdir {|d|
-      orig = %W"d\u{e9}tente x\u{304c 304e 3050 3052 3054}"
-      orig.each do |n|
-        Dir.mkdir(n)
-        assert_equal(n, File.basename(Dir.chdir(n) {Dir.pwd}))
+    orig = %W"d\u{e9}tente x\u{304c 304e 3050 3052 3054}"
+    expected = []
+    results = []
+    orig.each {|o|
+      if /mswin|mingw/ =~ RUBY_PLATFORM
+        n = (o.encode("filesystem") rescue next)
+      else
+        enc = Encoding.find("filesystem")
+        enc = Encoding::ASCII_8BIT if enc == Encoding::US_ASCII
+        n = o.dup.force_encoding(enc)
       end
+      expected << n
+      with_tmpdir {
+        Dir.mkdir(o)
+        results << File.basename(Dir.chdir(o) {Dir.pwd})
+      }
     }
+    PP.assert_equal(expected, results)
   end
 end

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

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