summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorusa <usa@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2012-11-08 05:43:25 +0000
committerusa <usa@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2012-11-08 05:43:25 +0000
commit73c6469a00a5fadf26c35689231656a02092f594 (patch)
treebc1c2744ac3145953380ab9c1be87ec1b1a4ebfb
parent58396030b3fa36ee82effbd46682d1991521523f (diff)
merge revision(s) 36509,36514: [Backport #7294]
* test/ruby/test_dir_m17n.rb (create_and_check_raw_file_name): add new helper method to ease encoding testing. Patch by Oleg Sukhodolsky. [ruby-core:46589][Bug #6765] * test/ruby/test_dir_m17n.rb (test_filename_extutf8): use filesystem encoding when reading entries and comparing. * test/ruby/test_dir_m17n.rb (test_filename_utf8_raw_name): removed. * test/ruby/test_dir_m17n.rb (test_filename_utf8_raw_jp_name): split test. * test/ruby/test_dir_m17n.rb: refactoring. RE should be in the left side of the =~ operator, and compare the result with nil is meaningless. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_9_3@37554 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
-rw-r--r--ChangeLog18
-rw-r--r--test/ruby/test_dir_m17n.rb79
-rw-r--r--version.h2
3 files changed, 72 insertions, 27 deletions
diff --git a/ChangeLog b/ChangeLog
index 2e2510fb74..fcec971139 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,21 @@
+Thu Nov 8 14:43:17 2012 NAKAMURA Usaku <usa@ruby-lang.org>
+
+ * test/ruby/test_dir_m17n.rb: refactoring. RE should be in the left side
+ of the =~ operator, and compare the result with nil is meaningless.
+
+Thu Nov 8 14:43:17 2012 Luis Lavena <luislavena@gmail.com>
+
+ * test/ruby/test_dir_m17n.rb (create_and_check_raw_file_name): add new
+ helper method to ease encoding testing. Patch by Oleg Sukhodolsky.
+ [ruby-core:46589][Bug #6765]
+
+ * test/ruby/test_dir_m17n.rb (test_filename_extutf8): use filesystem
+ encoding when reading entries and comparing.
+
+ * test/ruby/test_dir_m17n.rb (test_filename_utf8_raw_name): removed.
+
+ * test/ruby/test_dir_m17n.rb (test_filename_utf8_raw_jp_name): split test.
+
Thu Nov 8 14:16:53 2012 Nobuyoshi Nakada <nobu@ruby-lang.org>
* lib/mkmf.rb (MakeMakefile#timestamp_file): use .-. instead of !, a
diff --git a/test/ruby/test_dir_m17n.rb b/test/ruby/test_dir_m17n.rb
index b376393abf..d9ff711435 100644
--- a/test/ruby/test_dir_m17n.rb
+++ b/test/ruby/test_dir_m17n.rb
@@ -11,6 +11,33 @@ class TestDir_M17N < Test::Unit::TestCase
}
end
+ def create_and_check_raw_file_name(code, encoding)
+ with_tmpdir { |dir|
+ create_file_program = %Q[
+ filename = #{code}.chr('UTF-8').force_encoding("#{encoding}")
+ File.open(filename, "w") {}
+ opts = {:encoding => Encoding.default_external} if /mswin|mingw/ =~ RUBY_PLATFORM
+ ents = Dir.entries(".", opts)
+ exit ents.include?(filename)
+ ]
+ assert_ruby_status(["-E#{encoding}"], create_file_program, nil, :chdir=>dir)
+
+ test_file_program = %Q[
+ filename = #{code}.chr('UTF-8').force_encoding("ASCII-8BIT")
+ opts = {:encoding => Encoding.default_external} if /mswin|mingw/ =~ RUBY_PLATFORM
+ ents = Dir.entries(".", opts)
+ expected_filename = #{code}.chr('UTF-8').encode(Encoding.find("filesystem")) rescue expected_filename = "?"
+ expected_filename = expected_filename.force_encoding("ASCII-8BIT")
+ result = ents.include?(filename) || (/mswin|mingw/ =~ RUBY_PLATFORM && ents.include?(expected_filename))
+ if !result && /mswin|mingw/ =~ RUBY_PLATFORM
+ exit Dir.entries(".", {:encoding => Encoding.find("filesystem")}).include?(expected_filename)
+ end
+ exit result
+ ]
+ assert_ruby_status(%w[-EASCII-8BIT], test_file_program, nil, :chdir=>dir)
+ }
+ end
+
## UTF-8 default_external, no default_internal
def test_filename_extutf8
@@ -32,14 +59,14 @@ class TestDir_M17N < Test::Unit::TestCase
File.open(filename, "w") {}
opts = {:encoding => Encoding.default_external} if /mswin|mingw/ =~ RUBY_PLATFORM
ents = Dir.entries(".", opts)
- exit ents.include?(filename) || ((RUBY_PLATFORM =~ /darwin/) != nil && ents.include?("%FF"))
+ exit ents.include?(filename) || (/darwin/ =~ RUBY_PLATFORM && ents.include?("%FF"))
EOS
assert_ruby_status(%w[-EUTF-8], <<-'EOS', nil, :chdir=>d)
filename = "\xff".force_encoding("UTF-8") # invalid byte sequence as UTF-8
File.open(filename, "w") {}
opts = {:encoding => Encoding.default_external} if /mswin|mingw/ =~ RUBY_PLATFORM
ents = Dir.entries(".", opts)
- exit ents.include?(filename) || ((RUBY_PLATFORM =~ /darwin/) != nil && ents.include?("%FF"))
+ exit ents.include?(filename) || (/darwin/ =~ RUBY_PLATFORM && ents.include?("%FF"))
EOS
}
end unless /mswin|mingw/ =~ RUBY_PLATFORM
@@ -153,7 +180,7 @@ class TestDir_M17N < Test::Unit::TestCase
ents = Dir.entries(".", opts)
ents.each {|e| e.force_encoding("ASCII-8BIT") }
exit ents.include?(filename.force_encoding("ASCII-8BIT")) ||
- ((RUBY_PLATFORM =~ /darwin/) != nil && ents.include?("%A4%A2".force_encoding("ASCII-8BIT")))
+ (/darwin/ =~ RUBY_PLATFORM && ents.include?("%A4%A2".force_encoding("ASCII-8BIT")))
EOS
}
end
@@ -165,35 +192,35 @@ class TestDir_M17N < Test::Unit::TestCase
File.open(filename, "w") {}
opts = {:encoding => Encoding.default_external} if /mswin|mingw/ =~ RUBY_PLATFORM
ents = Dir.entries(".", opts)
- exit ents.include?(filename) || ((RUBY_PLATFORM =~ /darwin/) != nil && ents.include?("%A4%A2".force_encoding("euc-jp")))
+ exit ents.include?(filename) || (/darwin/ =~ RUBY_PLATFORM && ents.include?("%A4%A2".force_encoding("euc-jp")))
EOS
assert_ruby_status(%w[-EASCII-8BIT], <<-'EOS', nil, :chdir=>d)
- filename = "\xA4\xA2"
+ filename = "\xA4\xA2".force_encoding('ASCII-8BIT')
+ win_expected_filename = filename.encode(Encoding.find("filesystem")) rescue "?"
opts = {:encoding => Encoding.default_external} if /mswin|mingw/ =~ RUBY_PLATFORM
ents = Dir.entries(".", opts)
- exit ents.include?(filename) ||
- ((RUBY_PLATFORM =~ /darwin/) != nil && ents.include?("%A4%A2".force_encoding("ASCII-8BIT"))) ||
- ((RUBY_PLATFORM =~ /mswin|mingw/) != nil && ents.include?("\x82\xA0".force_encoding("ASCII-8BIT")))
+ p ents
+ result = ents.include?(filename) ||
+ (/darwin/ =~ RUBY_PLATFORM =~ /darwin/ && ents.include?("%A4%A2".force_encoding("ASCII-8BIT"))) ||
+ (/mswin|mingw/ =~ RUBY_PLATFORM && ents.include?(win_expected_filename.force_encoding("ASCII-8BIT")))
+ if !result && /mswin|mingw/ =~ RUBY_PLATFORM
+ exit Dir.entries(".", {:encoding => Encoding.find("filesystem")}).include?(win_expected_filename)
+ end
+ exit result
EOS
}
end
- def test_filename_utf8_raw_name
- with_tmpdir {|d|
- assert_ruby_status(%w[-EUTF-8], <<-'EOS', nil, :chdir=>d)
- filename = "\u3042".force_encoding("utf-8")
- File.open(filename, "w") {}
- opts = {:encoding => Encoding.default_external} if /mswin|mingw/ =~ RUBY_PLATFORM
- ents = Dir.entries(".", opts)
- exit ents.include?(filename)
- EOS
- assert_ruby_status(%w[-EASCII-8BIT], <<-'EOS', nil, :chdir=>d)
- filename = "\u3042".force_encoding("ASCII-8BIT")
- opts = {:encoding => Encoding.default_external} if /mswin|mingw/ =~ RUBY_PLATFORM
- ents = Dir.entries(".", opts)
- exit ents.include?(filename) || ((RUBY_PLATFORM =~ /mswin|mingw/) != nil && ents.include?("\x82\xA0".force_encoding("ASCII-8BIT")))
- EOS
- }
+ def test_filename_utf8_raw_jp_name
+ create_and_check_raw_file_name(0x3042, "UTF-8")
+ end
+
+ def test_filename_utf8_raw_windows_1251_name
+ create_and_check_raw_file_name(0x0424, "UTF-8")
+ end
+
+ def test_filename_utf8_raw_windows_1252_name
+ create_and_check_raw_file_name(0x00c7, "UTF-8")
end
def test_filename_ext_euc_jp_and_int_utf_8
@@ -203,13 +230,13 @@ class TestDir_M17N < Test::Unit::TestCase
File.open(filename, "w") {}
opts = {:encoding => Encoding.default_external} if /mswin|mingw/ =~ RUBY_PLATFORM
ents = Dir.entries(".", opts)
- exit ents.include?(filename) || ((RUBY_PLATFORM =~ /darwin/) != nil && ents.include?("%A4%A2".force_encoding("euc-jp")))
+ exit ents.include?(filename) || (/darwin/ =~ RUBY_PLATFORM && ents.include?("%A4%A2".force_encoding("euc-jp")))
EOS
assert_ruby_status(%w[-EEUC-JP:UTF-8], <<-'EOS', nil, :chdir=>d)
filename = "\u3042"
opts = {:encoding => Encoding.default_external} if /mswin|mingw/ =~ RUBY_PLATFORM
ents = Dir.entries(".", opts)
- exit ents.include?(filename) || ((RUBY_PLATFORM =~ /darwin/) != nil && ents.include?("%A4%A2"))
+ exit ents.include?(filename) || (/darwin/ =~ RUBY_PLATFORM && ents.include?("%A4%A2"))
EOS
}
end
diff --git a/version.h b/version.h
index aa93aec515..0e37133775 100644
--- a/version.h
+++ b/version.h
@@ -1,5 +1,5 @@
#define RUBY_VERSION "1.9.3"
-#define RUBY_PATCHLEVEL 310
+#define RUBY_PATCHLEVEL 311
#define RUBY_RELEASE_DATE "2012-11-08"
#define RUBY_RELEASE_YEAR 2012