diff options
author | naruse <naruse@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2012-07-03 15:38:58 +0000 |
---|---|---|
committer | naruse <naruse@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2012-07-03 15:38:58 +0000 |
commit | 4e273f76763d783852a01e58feb81e6e074d671f (patch) | |
tree | 58c936f7ac27659d101e0ac9a2266a56475c385c /test | |
parent | fdde6957f7d1cff1fc550ab5d4be141aae443eb9 (diff) |
Revert r36279; it breaks C API compatibility.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_9_3@36291 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'test')
-rw-r--r-- | test/pathname/test_pathname.rb | 8 | ||||
-rw-r--r-- | test/ruby/test_file_exhaustive.rb | 44 |
2 files changed, 8 insertions, 44 deletions
diff --git a/test/pathname/test_pathname.rb b/test/pathname/test_pathname.rb index 61d288d68d..8a8c0d9844 100644 --- a/test/pathname/test_pathname.rb +++ b/test/pathname/test_pathname.rb @@ -1,3 +1,5 @@ +#!/usr/bin/env ruby + require 'test/unit' require 'pathname' @@ -183,8 +185,10 @@ class TestPathname < Test::Unit::TestCase if DOSISH defassert(:del_trailing_separator, "a", "a\\") - defassert(:del_trailing_separator, "\225\\".force_encoding("cp932"), "\225\\\\".force_encoding("cp932")) - defassert(:del_trailing_separator, "\225".force_encoding("cp437"), "\225\\\\".force_encoding("cp437")) + require 'Win32API' + if Win32API.new('kernel32', 'GetACP', nil, 'L').call == 932 + defassert(:del_trailing_separator, "\225\\", "\225\\\\") # SJIS + end end def test_plus diff --git a/test/ruby/test_file_exhaustive.rb b/test/ruby/test_file_exhaustive.rb index 260610e572..c10b05a86b 100644 --- a/test/ruby/test_file_exhaustive.rb +++ b/test/ruby/test_file_exhaustive.rb @@ -3,8 +3,6 @@ require "fileutils" require "tmpdir" class TestFileExhaustive < Test::Unit::TestCase - DRIVE = Dir.pwd[%r'\A(?:[a-z]:|//[^/]+/[^/]+)'i] - def assert_incompatible_encoding d = "\u{3042}\u{3044}".encode("utf-16le") assert_raise(Encoding::CompatibilityError) {yield d} @@ -402,29 +400,13 @@ class TestFileExhaustive < Test::Unit::TestCase assert_match(/\Ac:\//i, File.expand_path('c:foo', 'd:/bar')) assert_match(%r'\Ac:/bar/foo\z'i, File.expand_path('c:foo', 'c:/bar')) end - if DRIVE + if drive = Dir.pwd[%r'\A(?:[a-z]:|//[^/]+/[^/]+)'i] 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')) + assert_match(%r"\A#{drive}/foo\z"i, File.expand_path('/foo')) else assert_equal("/foo", File.expand_path('/foo')) end - drive = (DRIVE ? 'C:' : '') - if Encoding.find("filesystem") == Encoding::CP1251 - a = "#{drive}/\u3042\u3044\u3046\u3048\u304a".encode("cp932") - else - a = "#{drive}/\u043f\u0440\u0438\u0432\u0435\u0442".encode("cp1251") - end - assert_equal(a, File.expand_path(a)) - a = "#{drive}/\225\\\\" - if File::ALT_SEPARATOR == '\\' - [%W"cp437 #{drive}/\225", %W"cp932 #{drive}/\225\\"] - else - [["cp437", a], ["cp932", a]] - end.each do |cp, expected| - assert_equal(expected.force_encoding(cp), File.expand_path(a.dup.force_encoding(cp)), cp) - end - assert_kind_of(String, File.expand_path("~")) if ENV["HOME"] assert_raise(ArgumentError) { File.expand_path("~foo_bar_baz_unknown_user_wahaha") } assert_raise(ArgumentError) { File.expand_path("~foo_bar_baz_unknown_user_wahaha", "/") } @@ -465,31 +447,16 @@ class TestFileExhaustive < Test::Unit::TestCase assert_equal(basename, File.basename(@file + ".", ".*")) assert_equal(basename, File.basename(@file + "::$DATA", ".*")) end - if File::ALT_SEPARATOR == '\\' - 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 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"))} - - s = "foo\x93_a".force_encoding("cp932") - assert_equal(s, File.basename(s, "_a")) end def test_dirname assert(@file.start_with?(File.dirname(@file))) assert_equal(".", File.dirname("")) assert_incompatible_encoding {|d| File.dirname(d)} - if File::ALT_SEPARATOR == '\\' - 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) - end - end end def test_extname @@ -533,13 +500,6 @@ class TestFileExhaustive < Test::Unit::TestCase def o.to_path; "foo"; end assert_equal(s, File.join(o, "bar", "baz")) assert_equal(s, File.join("foo" + File::SEPARATOR, "bar", File::SEPARATOR + "baz")) - if File::ALT_SEPARATOR == '\\' - a = "\225\\" - b = "foo" - [%W"cp437 \225\\foo", %W"cp932 \225\\/foo"].each do |cp, expected| - assert_equal(expected.force_encoding(cp), File.join(a.dup.force_encoding(cp), b.dup.force_encoding(cp)), cp) - end - end end def test_truncate |