1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00

* test/ruby/test_m17n.rb: follow EncodingCompatibilityError.

* test/ruby/test_mixed_unicode_escapes.rb: ditto.

* test/ruby/enc/test_utf16.rb: ditto.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@18567 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
naruse 2008-08-13 07:14:56 +00:00
parent 090004886d
commit 55c141c624
4 changed files with 34 additions and 26 deletions

View file

@ -1,3 +1,11 @@
Wed Aug 13 16:13:58 2008 NARUSE, Yui <naruse@ruby-lang.org>
* test/ruby/test_m17n.rb: follow EncodingCompatibilityError.
* test/ruby/test_mixed_unicode_escapes.rb: ditto.
* test/ruby/enc/test_utf16.rb: ditto.
Wed Aug 13 16:05:50 2008 Yukihiro Matsumoto <matz@ruby-lang.org> Wed Aug 13 16:05:50 2008 Yukihiro Matsumoto <matz@ruby-lang.org>
* time.c (time_cmp): retry with right hand operand if its not a * time.c (time_cmp): retry with right hand operand if its not a

View file

@ -137,19 +137,19 @@ EOT
end end
def test_hex def test_hex
assert_raise(ArgumentError) { assert_raise(EncodingCompatibilityError) {
"ff".encode("utf-16le").hex "ff".encode("utf-16le").hex
} }
assert_raise(ArgumentError) { assert_raise(EncodingCompatibilityError) {
"ff".encode("utf-16be").hex "ff".encode("utf-16be").hex
} }
end end
def test_oct def test_oct
assert_raise(ArgumentError) { assert_raise(EncodingCompatibilityError) {
"77".encode("utf-16le").oct "77".encode("utf-16le").oct
} }
assert_raise(ArgumentError) { assert_raise(EncodingCompatibilityError) {
"77".encode("utf-16be").oct "77".encode("utf-16be").oct
} }
end end
@ -157,7 +157,7 @@ EOT
def test_count def test_count
s1 = "aa".force_encoding("utf-16be") s1 = "aa".force_encoding("utf-16be")
s2 = "aa" s2 = "aa"
assert_raise(ArgumentError, "#{encdump s1}.count(#{encdump s2})") { assert_raise(EncodingCompatibilityError, "#{encdump s1}.count(#{encdump s2})") {
s1.count(s2) s1.count(s2)
} }
end end
@ -165,7 +165,7 @@ EOT
def test_plus def test_plus
s1 = "a".force_encoding("us-ascii") s1 = "a".force_encoding("us-ascii")
s2 = "aa".force_encoding("utf-16be") s2 = "aa".force_encoding("utf-16be")
assert_raise(ArgumentError, "#{encdump s1} + #{encdump s2}") { assert_raise(EncodingCompatibilityError, "#{encdump s1} + #{encdump s2}") {
s1 + s2 s1 + s2
} }
end end
@ -178,7 +178,7 @@ EOT
def test_interpolation def test_interpolation
s = "aa".force_encoding("utf-16be") s = "aa".force_encoding("utf-16be")
assert_raise(ArgumentError, "\"a\#{#{encdump s}}\"") { assert_raise(EncodingCompatibilityError, "\"a\#{#{encdump s}}\"") {
"a#{s}" "a#{s}"
} }
end end
@ -206,7 +206,7 @@ EOT
def test_plus_nonempty def test_plus_nonempty
s1 = "aa" s1 = "aa"
s2 = "bb".force_encoding("utf-16be") s2 = "bb".force_encoding("utf-16be")
assert_raise(ArgumentError, "#{encdump s1} << #{encdump s2}") { assert_raise(EncodingCompatibilityError, "#{encdump s1} << #{encdump s2}") {
s1 + s2 s1 + s2
} }
end end
@ -230,7 +230,7 @@ EOT
def test_concat_nonempty def test_concat_nonempty
s1 = "aa" s1 = "aa"
s2 = "bb".force_encoding("utf-16be") s2 = "bb".force_encoding("utf-16be")
assert_raise(ArgumentError, "#{encdump s1} << #{encdump s2}") { assert_raise(EncodingCompatibilityError, "#{encdump s1} << #{encdump s2}") {
s1 << s2 s1 << s2
} }
end end
@ -272,7 +272,7 @@ EOT
s.gsub(Regexp.new(".".encode("utf-16be")), "xy") s.gsub(Regexp.new(".".encode("utf-16be")), "xy")
} }
s = "ab\0\ncd".force_encoding("utf-16be") s = "ab\0\ncd".force_encoding("utf-16be")
assert_raise(ArgumentError) { assert_raise(EncodingCompatibilityError) {
s.gsub(Regexp.new(".".encode("utf-16be")), "xy") s.gsub(Regexp.new(".".encode("utf-16be")), "xy")
} }
end end

View file

@ -746,7 +746,7 @@ class TestM17N < Test::Unit::TestCase
#assert_raise(ArgumentError) { s("%c") % 0xc2a1 } #assert_raise(ArgumentError) { s("%c") % 0xc2a1 }
assert_strenc("\u{c2a1}", 'UTF-8', u("%c") % 0xc2a1) assert_strenc("\u{c2a1}", 'UTF-8', u("%c") % 0xc2a1)
assert_strenc("\u{c2}", 'UTF-8', u("%c") % 0xc2) assert_strenc("\u{c2}", 'UTF-8', u("%c") % 0xc2)
assert_raise(ArgumentError) { assert_raise(EncodingCompatibilityError) {
"%s%s" % [s("\xc2\xa1"), e("\xc2\xa1")] "%s%s" % [s("\xc2\xa1"), e("\xc2\xa1")]
} }
end end
@ -866,22 +866,22 @@ class TestM17N < Test::Unit::TestCase
def test_str_aref_substr def test_str_aref_substr
assert_equal(a("\xa1\xc2"), a("\xc2\xa1\xc2\xa2\xc2\xa3")[a("\xa1\xc2")]) assert_equal(a("\xa1\xc2"), a("\xc2\xa1\xc2\xa2\xc2\xa3")[a("\xa1\xc2")])
assert_raise(ArgumentError) { a("\xc2\xa1\xc2\xa2\xc2\xa3")[e("\xa1\xc2")] } assert_raise(EncodingCompatibilityError) { a("\xc2\xa1\xc2\xa2\xc2\xa3")[e("\xa1\xc2")] }
assert_equal(nil, e("\xc2\xa1\xc2\xa2\xc2\xa3")[e("\xa1\xc2")]) assert_equal(nil, e("\xc2\xa1\xc2\xa2\xc2\xa3")[e("\xa1\xc2")])
assert_raise(ArgumentError) { e("\xc2\xa1\xc2\xa2\xc2\xa3")[s("\xa1\xc2")] } assert_raise(EncodingCompatibilityError) { e("\xc2\xa1\xc2\xa2\xc2\xa3")[s("\xa1\xc2")] }
assert_equal(s("\xa1\xc2"), s("\xc2\xa1\xc2\xa2\xc2\xa3")[s("\xa1\xc2")]) assert_equal(s("\xa1\xc2"), s("\xc2\xa1\xc2\xa2\xc2\xa3")[s("\xa1\xc2")])
assert_raise(ArgumentError) { s("\xc2\xa1\xc2\xa2\xc2\xa3")[u("\xa1\xc2")] } assert_raise(EncodingCompatibilityError) { s("\xc2\xa1\xc2\xa2\xc2\xa3")[u("\xa1\xc2")] }
assert_equal(nil, u("\xc2\xa1\xc2\xa2\xc2\xa3")[u("\xa1\xc2")]) assert_equal(nil, u("\xc2\xa1\xc2\xa2\xc2\xa3")[u("\xa1\xc2")])
assert_raise(ArgumentError) { u("\xc2\xa1\xc2\xa2\xc2\xa3")[a("\xa1\xc2")] } assert_raise(EncodingCompatibilityError) { u("\xc2\xa1\xc2\xa2\xc2\xa3")[a("\xa1\xc2")] }
assert_nil(e("\xa1\xa2\xa3\xa4")[e("\xa2\xa3")]) assert_nil(e("\xa1\xa2\xa3\xa4")[e("\xa2\xa3")])
end end
def test_aset def test_aset
s = e("\xa3\xb0\xa3\xb1\xa3\xb2\xa3\xb3\xa3\xb4") s = e("\xa3\xb0\xa3\xb1\xa3\xb2\xa3\xb3\xa3\xb4")
assert_raise(ArgumentError){s["\xb0\xa3"] = "foo"} assert_raise(EncodingCompatibilityError){s["\xb0\xa3"] = "foo"}
end end
def test_str_center def test_str_center
@ -917,13 +917,13 @@ class TestM17N < Test::Unit::TestCase
def test_count def test_count
assert_equal(0, e("\xa1\xa2").count("z")) assert_equal(0, e("\xa1\xa2").count("z"))
s = e("\xa3\xb0\xa3\xb1\xa3\xb2\xa3\xb3\xa3\xb4") s = e("\xa3\xb0\xa3\xb1\xa3\xb2\xa3\xb3\xa3\xb4")
assert_raise(ArgumentError){s.count(a("\xa3\xb0"))} assert_raise(EncodingCompatibilityError){s.count(a("\xa3\xb0"))}
end end
def test_delete def test_delete
assert_equal(1, e("\xa1\xa2").delete("z").length) assert_equal(1, e("\xa1\xa2").delete("z").length)
s = e("\xa3\xb0\xa3\xb1\xa3\xb2\xa3\xb3\xa3\xb4") s = e("\xa3\xb0\xa3\xb1\xa3\xb2\xa3\xb3\xa3\xb4")
assert_raise(ArgumentError){s.delete(a("\xa3\xb2"))} assert_raise(EncodingCompatibilityError){s.delete(a("\xa3\xb2"))}
a = "\u3042\u3044\u3046\u3042\u3044\u3046" a = "\u3042\u3044\u3046\u3042\u3044\u3046"
a.delete!("\u3042\u3044", "^\u3044") a.delete!("\u3042\u3044", "^\u3044")
@ -942,7 +942,7 @@ class TestM17N < Test::Unit::TestCase
assert_nil(e("\xa1\xa2\xa3\xa4").index(e("\xa3"))) assert_nil(e("\xa1\xa2\xa3\xa4").index(e("\xa3")))
assert_nil(e("\xa1\xa2\xa3\xa4").rindex(e("\xa3"))) assert_nil(e("\xa1\xa2\xa3\xa4").rindex(e("\xa3")))
s = e("\xa3\xb0\xa3\xb1\xa3\xb2\xa3\xb3\xa3\xb4") s = e("\xa3\xb0\xa3\xb1\xa3\xb2\xa3\xb3\xa3\xb4")
assert_raise(ArgumentError){s.rindex(a("\xb1\xa3"))} assert_raise(EncodingCompatibilityError){s.rindex(a("\xb1\xa3"))}
end end
def test_next def test_next
@ -985,7 +985,7 @@ class TestM17N < Test::Unit::TestCase
def test_upto def test_upto
s1 = e("\xa1\xa2") s1 = e("\xa1\xa2")
s2 = s("\xa1\xa2") s2 = s("\xa1\xa2")
assert_raise(ArgumentError){s1.upto(s2) {|x| break }} assert_raise(EncodingCompatibilityError){s1.upto(s2) {|x| break }}
end end
def test_casecmp def test_casecmp
@ -1005,12 +1005,12 @@ class TestM17N < Test::Unit::TestCase
end end
def test_plus def test_plus
assert_raise(ArgumentError){u("\xe3\x81\x82") + a("\xa1")} assert_raise(EncodingCompatibilityError){u("\xe3\x81\x82") + a("\xa1")}
end end
def test_chomp def test_chomp
s = e("\xa3\xb0\xa3\xb1\xa3\xb2\xa3\xb3\xa3\xb4") s = e("\xa3\xb0\xa3\xb1\xa3\xb2\xa3\xb3\xa3\xb4")
assert_raise(ArgumentError){s.chomp(s("\xa3\xb4"))} assert_raise(EncodingCompatibilityError){s.chomp(s("\xa3\xb4"))}
end end
def test_gsub def test_gsub
@ -1023,7 +1023,7 @@ class TestM17N < Test::Unit::TestCase
t = s.gsub(/b/, "\xa1\xa1".force_encoding("euc-jp")) t = s.gsub(/b/, "\xa1\xa1".force_encoding("euc-jp"))
assert_equal(Encoding::ASCII_8BIT, s.encoding) assert_equal(Encoding::ASCII_8BIT, s.encoding)
assert_raise(ArgumentError) { assert_raise(EncodingCompatibilityError) {
"abc".gsub(/[ac]/) { "abc".gsub(/[ac]/) {
$& == "a" ? "\xc2\xa1".force_encoding("euc-jp") : $& == "a" ? "\xc2\xa1".force_encoding("euc-jp") :
"\xc2\xa1".force_encoding("utf-8") "\xc2\xa1".force_encoding("utf-8")
@ -1044,7 +1044,7 @@ class TestM17N < Test::Unit::TestCase
def test_each_line def test_each_line
s = e("\xa3\xb0\xa3\xb1\xa3\xb2\xa3\xb3\xa3\xb4") s = e("\xa3\xb0\xa3\xb1\xa3\xb2\xa3\xb3\xa3\xb4")
assert_raise(ArgumentError){s.each_line(a("\xa3\xb1")) {|l| }} assert_raise(EncodingCompatibilityError){s.each_line(a("\xa3\xb1")) {|l| }}
s = e("\xa4\xa2\nfoo") s = e("\xa4\xa2\nfoo")
actual = [] actual = []

View file

@ -18,8 +18,8 @@ class TestMixedUnicodeEscape < Test::Unit::TestCase
# String interpolation turns into an expression and we get # String interpolation turns into an expression and we get
# a different kind of error, but we still can't mix these # a different kind of error, but we still can't mix these
assert_raise(ArgumentError) { eval %q("\u{1234}#{nil}é<>")} assert_raise(EncodingCompatibilityError) { eval %q("\u{1234}#{nil}é<>")}
assert_raise(ArgumentError) { eval %q(<>#{nil}\u1234")} assert_raise(EncodingCompatibilityError) { eval %q(<>#{nil}\u1234")}
end end
end end