rename a() to b() and define a() for US-ASCII
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@42083 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
42bf899458
commit
f685b40129
@ -7,10 +7,11 @@ class TestM17NComb < Test::Unit::TestCase
|
|||||||
end
|
end
|
||||||
|
|
||||||
module AESU
|
module AESU
|
||||||
def a(str) str.dup.force_encoding("ASCII-8BIT") end
|
def a(str) str.dup.force_encoding(Encoding::US_ASCII) end
|
||||||
def e(str) str.dup.force_encoding("EUC-JP") end
|
def b(str) str.b end
|
||||||
def s(str) str.dup.force_encoding("Shift_JIS") end
|
def e(str) str.dup.force_encoding(Encoding::EUC_JP) end
|
||||||
def u(str) str.dup.force_encoding("UTF-8") end
|
def s(str) str.dup.force_encoding(Encoding::SJIS) end
|
||||||
|
def u(str) str.dup.force_encoding(Encoding::UTF_8) end
|
||||||
end
|
end
|
||||||
include AESU
|
include AESU
|
||||||
extend AESU
|
extend AESU
|
||||||
@ -19,16 +20,16 @@ class TestM17NComb < Test::Unit::TestCase
|
|||||||
assert_instance_of(String, actual, message)
|
assert_instance_of(String, actual, message)
|
||||||
enc = Encoding.find(enc) if String === enc
|
enc = Encoding.find(enc) if String === enc
|
||||||
assert_equal(enc, actual.encoding, message)
|
assert_equal(enc, actual.encoding, message)
|
||||||
assert_equal(a(bytes), a(actual), message)
|
assert_equal(b(bytes), b(actual), message)
|
||||||
end
|
end
|
||||||
|
|
||||||
STRINGS = [
|
STRINGS = [
|
||||||
a(""), e(""), s(""), u(""),
|
b(""), e(""), s(""), u(""),
|
||||||
a("a"), e("a"), s("a"), u("a"),
|
b("a"), e("a"), s("a"), u("a"),
|
||||||
a("."), e("."), s("."), u("."),
|
b("."), e("."), s("."), u("."),
|
||||||
|
|
||||||
# single character
|
# single character
|
||||||
a("\x80"), a("\xff"),
|
b("\x80"), b("\xff"),
|
||||||
e("\xa1\xa1"), e("\xfe\xfe"),
|
e("\xa1\xa1"), e("\xfe\xfe"),
|
||||||
e("\x8e\xa1"), e("\x8e\xfe"),
|
e("\x8e\xa1"), e("\x8e\xfe"),
|
||||||
e("\x8f\xa1\xa1"), e("\x8f\xfe\xfe"),
|
e("\x8f\xa1\xa1"), e("\x8f\xfe\xfe"),
|
||||||
@ -37,7 +38,7 @@ class TestM17NComb < Test::Unit::TestCase
|
|||||||
u("\xc2\x80"), u("\xf4\x8f\xbf\xbf"),
|
u("\xc2\x80"), u("\xf4\x8f\xbf\xbf"),
|
||||||
|
|
||||||
# same byte sequence
|
# same byte sequence
|
||||||
a("\xc2\xa1"), e("\xc2\xa1"), s("\xc2\xa1"), u("\xc2\xa1"),
|
b("\xc2\xa1"), e("\xc2\xa1"), s("\xc2\xa1"), u("\xc2\xa1"),
|
||||||
|
|
||||||
s("\x81A"), # mutibyte character which contains "A"
|
s("\x81A"), # mutibyte character which contains "A"
|
||||||
s("\x81a"), # mutibyte character which contains "a"
|
s("\x81a"), # mutibyte character which contains "a"
|
||||||
@ -49,7 +50,7 @@ class TestM17NComb < Test::Unit::TestCase
|
|||||||
|
|
||||||
# for transitivity test
|
# for transitivity test
|
||||||
u("\xe0\xa0\xa1"), e("\xe0\xa0\xa1"), s("\xe0\xa0\xa1"), # [ruby-dev:32693]
|
u("\xe0\xa0\xa1"), e("\xe0\xa0\xa1"), s("\xe0\xa0\xa1"), # [ruby-dev:32693]
|
||||||
e("\xa1\xa1"), a("\xa1\xa1"), s("\xa1\xa1"), # [ruby-dev:36484]
|
e("\xa1\xa1"), b("\xa1\xa1"), s("\xa1\xa1"), # [ruby-dev:36484]
|
||||||
]
|
]
|
||||||
|
|
||||||
WSTRINGS = [
|
WSTRINGS = [
|
||||||
@ -200,7 +201,7 @@ class TestM17NComb < Test::Unit::TestCase
|
|||||||
def test_str_new
|
def test_str_new
|
||||||
STRINGS.each {|s|
|
STRINGS.each {|s|
|
||||||
t = String.new(s)
|
t = String.new(s)
|
||||||
assert_strenc(a(s), s.encoding, t)
|
assert_strenc(b(s), s.encoding, t)
|
||||||
}
|
}
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -211,7 +212,7 @@ class TestM17NComb < Test::Unit::TestCase
|
|||||||
else
|
else
|
||||||
t = enccall(s1, :+, s2)
|
t = enccall(s1, :+, s2)
|
||||||
assert(t.valid_encoding?) if s1.valid_encoding? && s2.valid_encoding?
|
assert(t.valid_encoding?) if s1.valid_encoding? && s2.valid_encoding?
|
||||||
assert_equal(a(s1) + a(s2), a(t))
|
assert_equal(b(s1) + b(s2), b(t))
|
||||||
assert_str_enc_propagation(t, s1, s2)
|
assert_str_enc_propagation(t, s1, s2)
|
||||||
end
|
end
|
||||||
}
|
}
|
||||||
@ -222,17 +223,17 @@ class TestM17NComb < Test::Unit::TestCase
|
|||||||
[0,1,2].each {|n|
|
[0,1,2].each {|n|
|
||||||
t = s * n
|
t = s * n
|
||||||
assert(t.valid_encoding?) if s.valid_encoding?
|
assert(t.valid_encoding?) if s.valid_encoding?
|
||||||
assert_strenc(a(s) * n, s.encoding, t)
|
assert_strenc(b(s) * n, s.encoding, t)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_sprintf_s
|
def test_sprintf_s
|
||||||
STRINGS.each {|s|
|
STRINGS.each {|s|
|
||||||
assert_strenc(a(s), s.encoding, "%s".force_encoding(s.encoding) % s)
|
assert_strenc(b(s), s.encoding, "%s".force_encoding(s.encoding) % s)
|
||||||
if !s.empty? # xxx
|
if !s.empty? # xxx
|
||||||
t = enccall(a("%s"), :%, s)
|
t = enccall(b("%s"), :%, s)
|
||||||
assert_strenc(a(s), (a('')+s).encoding, t)
|
assert_strenc(b(s), (b('')+s).encoding, t)
|
||||||
end
|
end
|
||||||
}
|
}
|
||||||
end
|
end
|
||||||
@ -264,7 +265,7 @@ class TestM17NComb < Test::Unit::TestCase
|
|||||||
def test_str_eq
|
def test_str_eq
|
||||||
combination(STRINGS, STRINGS) {|s1, s2|
|
combination(STRINGS, STRINGS) {|s1, s2|
|
||||||
desc_eq = "#{encdump s1} == #{encdump s2}"
|
desc_eq = "#{encdump s1} == #{encdump s2}"
|
||||||
if a(s1) == a(s2) and
|
if b(s1) == b(s2) and
|
||||||
(s1.ascii_only? && s2.ascii_only? or
|
(s1.ascii_only? && s2.ascii_only? or
|
||||||
s1.encoding == s2.encoding) then
|
s1.encoding == s2.encoding) then
|
||||||
assert(s1 == s2, desc_eq)
|
assert(s1 == s2, desc_eq)
|
||||||
@ -286,7 +287,7 @@ class TestM17NComb < Test::Unit::TestCase
|
|||||||
if s1.ascii_only? || s2.ascii_only? || s1.encoding == s2.encoding
|
if s1.ascii_only? || s2.ascii_only? || s1.encoding == s2.encoding
|
||||||
s << s2
|
s << s2
|
||||||
assert(s.valid_encoding?) if s1.valid_encoding? && s2.valid_encoding?
|
assert(s.valid_encoding?) if s1.valid_encoding? && s2.valid_encoding?
|
||||||
assert_equal(a(s), a(s1) + a(s2))
|
assert_equal(b(s), b(s1) + b(s2))
|
||||||
assert_str_enc_propagation(s, s1, s2)
|
assert_str_enc_propagation(s, s1, s2)
|
||||||
else
|
else
|
||||||
assert_raise(Encoding::CompatibilityError) { s << s2 }
|
assert_raise(Encoding::CompatibilityError) { s << s2 }
|
||||||
@ -335,7 +336,7 @@ class TestM17NComb < Test::Unit::TestCase
|
|||||||
if t != nil
|
if t != nil
|
||||||
assert(t.valid_encoding?) if s1.valid_encoding? && s2.valid_encoding?
|
assert(t.valid_encoding?) if s1.valid_encoding? && s2.valid_encoding?
|
||||||
assert_equal(s2, t)
|
assert_equal(s2, t)
|
||||||
assert_match(/#{Regexp.escape(a(s2))}/, a(s1))
|
assert_match(/#{Regexp.escape(b(s2))}/, b(s1))
|
||||||
if s1.valid_encoding?
|
if s1.valid_encoding?
|
||||||
assert_match(/#{Regexp.escape(s2)}/, s1)
|
assert_match(/#{Regexp.escape(s2)}/, s1)
|
||||||
end
|
end
|
||||||
@ -412,7 +413,7 @@ class TestM17NComb < Test::Unit::TestCase
|
|||||||
else
|
else
|
||||||
t[i] = s2
|
t[i] = s2
|
||||||
assert(t.valid_encoding?) if s1.valid_encoding? && s2.valid_encoding?
|
assert(t.valid_encoding?) if s1.valid_encoding? && s2.valid_encoding?
|
||||||
assert(a(t).index(a(s2)))
|
assert(b(t).index(b(s2)))
|
||||||
if s1.valid_encoding? && s2.valid_encoding?
|
if s1.valid_encoding? && s2.valid_encoding?
|
||||||
if i == s1.length && s2.empty?
|
if i == s1.length && s2.empty?
|
||||||
assert_nil(t[i])
|
assert_nil(t[i])
|
||||||
@ -441,7 +442,7 @@ class TestM17NComb < Test::Unit::TestCase
|
|||||||
else
|
else
|
||||||
assert(t.valid_encoding?) if s1.valid_encoding? && s2.valid_encoding?
|
assert(t.valid_encoding?) if s1.valid_encoding? && s2.valid_encoding?
|
||||||
t[i,len] = s2
|
t[i,len] = s2
|
||||||
assert(a(t).index(a(s2)))
|
assert(b(t).index(b(s2)))
|
||||||
if s1.valid_encoding? && s2.valid_encoding?
|
if s1.valid_encoding? && s2.valid_encoding?
|
||||||
if i == s1.length && s2.empty?
|
if i == s1.length && s2.empty?
|
||||||
assert_nil(t[i])
|
assert_nil(t[i])
|
||||||
@ -500,7 +501,7 @@ class TestM17NComb < Test::Unit::TestCase
|
|||||||
else
|
else
|
||||||
enccall(t, :[]=, first..last, s2)
|
enccall(t, :[]=, first..last, s2)
|
||||||
assert(t.valid_encoding?) if s1.valid_encoding? && s2.valid_encoding?
|
assert(t.valid_encoding?) if s1.valid_encoding? && s2.valid_encoding?
|
||||||
assert(a(t).index(a(s2)))
|
assert(b(t).index(b(s2)))
|
||||||
if s1.valid_encoding? && s2.valid_encoding?
|
if s1.valid_encoding? && s2.valid_encoding?
|
||||||
if first < 0
|
if first < 0
|
||||||
assert_equal(s2, t[s1.length+first, s2.length])
|
assert_equal(s2, t[s1.length+first, s2.length])
|
||||||
@ -527,7 +528,7 @@ class TestM17NComb < Test::Unit::TestCase
|
|||||||
else
|
else
|
||||||
enccall(t, :[]=, first...last, s2)
|
enccall(t, :[]=, first...last, s2)
|
||||||
assert(t.valid_encoding?) if s1.valid_encoding? && s2.valid_encoding?
|
assert(t.valid_encoding?) if s1.valid_encoding? && s2.valid_encoding?
|
||||||
assert(a(t).index(a(s2)))
|
assert(b(t).index(b(s2)))
|
||||||
if s1.valid_encoding? && s2.valid_encoding?
|
if s1.valid_encoding? && s2.valid_encoding?
|
||||||
if first < 0
|
if first < 0
|
||||||
assert_equal(s2, t[s1.length+first, s2.length])
|
assert_equal(s2, t[s1.length+first, s2.length])
|
||||||
@ -571,7 +572,7 @@ class TestM17NComb < Test::Unit::TestCase
|
|||||||
t2.capitalize!
|
t2.capitalize!
|
||||||
assert_equal(t1, t2)
|
assert_equal(t1, t2)
|
||||||
r = s.downcase
|
r = s.downcase
|
||||||
r = enccall(r, :sub, /\A[a-z]/) {|ch| a(ch).upcase }
|
r = enccall(r, :sub, /\A[a-z]/) {|ch| b(ch).upcase }
|
||||||
assert_equal(r, t1)
|
assert_equal(r, t1)
|
||||||
}
|
}
|
||||||
end
|
end
|
||||||
@ -588,7 +589,7 @@ class TestM17NComb < Test::Unit::TestCase
|
|||||||
def test_str_center
|
def test_str_center
|
||||||
combination(STRINGS, [0,1,2,3,10]) {|s1, width|
|
combination(STRINGS, [0,1,2,3,10]) {|s1, width|
|
||||||
t = s1.center(width)
|
t = s1.center(width)
|
||||||
assert(a(t).index(a(s1)))
|
assert(b(t).index(b(s1)))
|
||||||
}
|
}
|
||||||
combination(STRINGS, [0,1,2,3,10], STRINGS) {|s1, width, s2|
|
combination(STRINGS, [0,1,2,3,10], STRINGS) {|s1, width, s2|
|
||||||
if s2.empty?
|
if s2.empty?
|
||||||
@ -601,7 +602,7 @@ class TestM17NComb < Test::Unit::TestCase
|
|||||||
end
|
end
|
||||||
t = enccall(s1, :center, width, s2)
|
t = enccall(s1, :center, width, s2)
|
||||||
assert(t.valid_encoding?) if s1.valid_encoding? && s2.valid_encoding?
|
assert(t.valid_encoding?) if s1.valid_encoding? && s2.valid_encoding?
|
||||||
assert(a(t).index(a(s1)))
|
assert(b(t).index(b(s1)))
|
||||||
assert_str_enc_propagation(t, s1, s2) if (t != s1)
|
assert_str_enc_propagation(t, s1, s2) if (t != s1)
|
||||||
}
|
}
|
||||||
end
|
end
|
||||||
@ -609,7 +610,7 @@ class TestM17NComb < Test::Unit::TestCase
|
|||||||
def test_str_ljust
|
def test_str_ljust
|
||||||
combination(STRINGS, [0,1,2,3,10]) {|s1, width|
|
combination(STRINGS, [0,1,2,3,10]) {|s1, width|
|
||||||
t = s1.ljust(width)
|
t = s1.ljust(width)
|
||||||
assert(a(t).index(a(s1)))
|
assert(b(t).index(b(s1)))
|
||||||
}
|
}
|
||||||
combination(STRINGS, [0,1,2,3,10], STRINGS) {|s1, width, s2|
|
combination(STRINGS, [0,1,2,3,10], STRINGS) {|s1, width, s2|
|
||||||
if s2.empty?
|
if s2.empty?
|
||||||
@ -622,7 +623,7 @@ class TestM17NComb < Test::Unit::TestCase
|
|||||||
end
|
end
|
||||||
t = enccall(s1, :ljust, width, s2)
|
t = enccall(s1, :ljust, width, s2)
|
||||||
assert(t.valid_encoding?) if s1.valid_encoding? && s2.valid_encoding?
|
assert(t.valid_encoding?) if s1.valid_encoding? && s2.valid_encoding?
|
||||||
assert(a(t).index(a(s1)))
|
assert(b(t).index(b(s1)))
|
||||||
assert_str_enc_propagation(t, s1, s2) if (t != s1)
|
assert_str_enc_propagation(t, s1, s2) if (t != s1)
|
||||||
}
|
}
|
||||||
end
|
end
|
||||||
@ -630,7 +631,7 @@ class TestM17NComb < Test::Unit::TestCase
|
|||||||
def test_str_rjust
|
def test_str_rjust
|
||||||
combination(STRINGS, [0,1,2,3,10]) {|s1, width|
|
combination(STRINGS, [0,1,2,3,10]) {|s1, width|
|
||||||
t = s1.rjust(width)
|
t = s1.rjust(width)
|
||||||
assert(a(t).index(a(s1)))
|
assert(b(t).index(b(s1)))
|
||||||
}
|
}
|
||||||
combination(STRINGS, [0,1,2,3,10], STRINGS) {|s1, width, s2|
|
combination(STRINGS, [0,1,2,3,10], STRINGS) {|s1, width, s2|
|
||||||
if s2.empty?
|
if s2.empty?
|
||||||
@ -643,7 +644,7 @@ class TestM17NComb < Test::Unit::TestCase
|
|||||||
end
|
end
|
||||||
t = enccall(s1, :rjust, width, s2)
|
t = enccall(s1, :rjust, width, s2)
|
||||||
assert(t.valid_encoding?) if s1.valid_encoding? && s2.valid_encoding?
|
assert(t.valid_encoding?) if s1.valid_encoding? && s2.valid_encoding?
|
||||||
assert(a(t).index(a(s1)))
|
assert(b(t).index(b(s1)))
|
||||||
assert_str_enc_propagation(t, s1, s2) if (t != s1)
|
assert_str_enc_propagation(t, s1, s2) if (t != s1)
|
||||||
}
|
}
|
||||||
end
|
end
|
||||||
@ -672,7 +673,7 @@ class TestM17NComb < Test::Unit::TestCase
|
|||||||
t = nil
|
t = nil
|
||||||
assert_nothing_raised(desc) { t = s.chop }
|
assert_nothing_raised(desc) { t = s.chop }
|
||||||
assert(t.valid_encoding?) if s.valid_encoding?
|
assert(t.valid_encoding?) if s.valid_encoding?
|
||||||
assert(a(s).index(a(t)))
|
assert(b(s).index(b(t)))
|
||||||
t2 = s.dup
|
t2 = s.dup
|
||||||
t2.chop!
|
t2.chop!
|
||||||
assert_equal(t, t2)
|
assert_equal(t, t2)
|
||||||
@ -693,7 +694,7 @@ class TestM17NComb < Test::Unit::TestCase
|
|||||||
t = s.clone
|
t = s.clone
|
||||||
assert_equal(s, t)
|
assert_equal(s, t)
|
||||||
assert_equal(s.encoding, t.encoding)
|
assert_equal(s.encoding, t.encoding)
|
||||||
assert_equal(a(s), a(t))
|
assert_equal(b(s), b(t))
|
||||||
}
|
}
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -702,7 +703,7 @@ class TestM17NComb < Test::Unit::TestCase
|
|||||||
t = s.dup
|
t = s.dup
|
||||||
assert_equal(s, t)
|
assert_equal(s, t)
|
||||||
assert_equal(s.encoding, t.encoding)
|
assert_equal(s.encoding, t.encoding)
|
||||||
assert_equal(a(s), a(t))
|
assert_equal(b(s), b(t))
|
||||||
}
|
}
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -717,7 +718,7 @@ class TestM17NComb < Test::Unit::TestCase
|
|||||||
next
|
next
|
||||||
end
|
end
|
||||||
n = enccall(s1, :count, s2)
|
n = enccall(s1, :count, s2)
|
||||||
n0 = a(s1).count(a(s2))
|
n0 = b(s1).count(b(s2))
|
||||||
assert_operator(n, :<=, n0)
|
assert_operator(n, :<=, n0)
|
||||||
}
|
}
|
||||||
end
|
end
|
||||||
@ -735,12 +736,12 @@ class TestM17NComb < Test::Unit::TestCase
|
|||||||
if strict_crypt
|
if strict_crypt
|
||||||
next unless salt.ascii_only? && /\A[0-9a-zA-Z.\/]+\z/ =~ salt
|
next unless salt.ascii_only? && /\A[0-9a-zA-Z.\/]+\z/ =~ salt
|
||||||
end
|
end
|
||||||
if a(salt).length < 2
|
if b(salt).length < 2
|
||||||
assert_raise(ArgumentError) { str.crypt(salt) }
|
assert_raise(ArgumentError) { str.crypt(salt) }
|
||||||
next
|
next
|
||||||
end
|
end
|
||||||
t = str.crypt(salt)
|
t = str.crypt(salt)
|
||||||
assert_equal(a(str).crypt(a(salt)), t, "#{encdump(str)}.crypt(#{encdump(salt)})")
|
assert_equal(b(str).crypt(b(salt)), t, "#{encdump(str)}.crypt(#{encdump(salt)})")
|
||||||
assert_encoding('ASCII-8BIT', t.encoding)
|
assert_encoding('ASCII-8BIT', t.encoding)
|
||||||
}
|
}
|
||||||
end
|
end
|
||||||
@ -791,7 +792,7 @@ class TestM17NComb < Test::Unit::TestCase
|
|||||||
assert(t.valid_encoding?)
|
assert(t.valid_encoding?)
|
||||||
assert(t.ascii_only?)
|
assert(t.ascii_only?)
|
||||||
u = eval(t)
|
u = eval(t)
|
||||||
assert_equal(a(s), a(u))
|
assert_equal(b(s), b(u))
|
||||||
}
|
}
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -824,7 +825,7 @@ class TestM17NComb < Test::Unit::TestCase
|
|||||||
s.each_byte {|b|
|
s.each_byte {|b|
|
||||||
bytes << b
|
bytes << b
|
||||||
}
|
}
|
||||||
a(s).split(//).each_with_index {|ch, i|
|
b(s).split(//).each_with_index {|ch, i|
|
||||||
assert_equal(ch.ord, bytes[i])
|
assert_equal(ch.ord, bytes[i])
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -843,7 +844,7 @@ class TestM17NComb < Test::Unit::TestCase
|
|||||||
def test_str_hex
|
def test_str_hex
|
||||||
STRINGS.each {|s|
|
STRINGS.each {|s|
|
||||||
t = s.hex
|
t = s.hex
|
||||||
t2 = a(s)[/\A[0-9a-fA-Fx]*/].hex
|
t2 = b(s)[/\A[0-9a-fA-Fx]*/].hex
|
||||||
assert_equal(t2, t)
|
assert_equal(t2, t)
|
||||||
}
|
}
|
||||||
end
|
end
|
||||||
@ -858,7 +859,7 @@ class TestM17NComb < Test::Unit::TestCase
|
|||||||
end
|
end
|
||||||
t = enccall(s1, :include?, s2)
|
t = enccall(s1, :include?, s2)
|
||||||
if t
|
if t
|
||||||
assert(a(s1).include?(a(s2)))
|
assert(b(s1).include?(b(s2)))
|
||||||
assert(s1.index(s2))
|
assert(s1.index(s2))
|
||||||
assert(s1.rindex(s2))
|
assert(s1.rindex(s2))
|
||||||
else
|
else
|
||||||
@ -939,7 +940,7 @@ class TestM17NComb < Test::Unit::TestCase
|
|||||||
end
|
end
|
||||||
if t
|
if t
|
||||||
#puts "#{encdump s1}.rindex(#{encdump s2}, #{pos}) => #{t}"
|
#puts "#{encdump s1}.rindex(#{encdump s2}, #{pos}) => #{t}"
|
||||||
assert(a(s1).index(a(s2)))
|
assert(b(s1).index(b(s2)))
|
||||||
pos2 = pos
|
pos2 = pos
|
||||||
pos2 += s1.length if pos < 0
|
pos2 += s1.length if pos < 0
|
||||||
re = /\A(.{0,#{pos2}})#{Regexp.escape(s2)}/m
|
re = /\A(.{0,#{pos2}})#{Regexp.escape(s2)}/m
|
||||||
@ -991,7 +992,7 @@ class TestM17NComb < Test::Unit::TestCase
|
|||||||
|
|
||||||
def test_str_intern
|
def test_str_intern
|
||||||
STRINGS.each {|s|
|
STRINGS.each {|s|
|
||||||
if /\0/ =~ a(s)
|
if /\0/ =~ b(s)
|
||||||
assert_raise(ArgumentError) { s.intern }
|
assert_raise(ArgumentError) { s.intern }
|
||||||
elsif s.valid_encoding?
|
elsif s.valid_encoding?
|
||||||
sym = s.intern
|
sym = s.intern
|
||||||
@ -1012,7 +1013,7 @@ class TestM17NComb < Test::Unit::TestCase
|
|||||||
def test_str_oct
|
def test_str_oct
|
||||||
STRINGS.each {|s|
|
STRINGS.each {|s|
|
||||||
t = s.oct
|
t = s.oct
|
||||||
t2 = a(s)[/\A[0-9a-fA-FxX]*/].oct
|
t2 = b(s)[/\A[0-9a-fA-FxX]*/].oct
|
||||||
assert_equal(t2, t)
|
assert_equal(t2, t)
|
||||||
}
|
}
|
||||||
end
|
end
|
||||||
@ -1120,10 +1121,10 @@ class TestM17NComb < Test::Unit::TestCase
|
|||||||
end
|
end
|
||||||
t = enccall(s1, :split, s2)
|
t = enccall(s1, :split, s2)
|
||||||
t.each {|r|
|
t.each {|r|
|
||||||
assert(a(s1).include?(a(r)))
|
assert(b(s1).include?(b(r)))
|
||||||
assert_equal(s1.encoding, r.encoding)
|
assert_equal(s1.encoding, r.encoding)
|
||||||
}
|
}
|
||||||
assert(a(s1).include?(t.map {|u| a(u) }.join(a(s2))))
|
assert(b(s1).include?(t.map {|u| b(u) }.join(b(s2))))
|
||||||
if s1.valid_encoding? && s2.valid_encoding?
|
if s1.valid_encoding? && s2.valid_encoding?
|
||||||
t.each {|r|
|
t.each {|r|
|
||||||
assert(r.valid_encoding?)
|
assert(r.valid_encoding?)
|
||||||
@ -1177,7 +1178,7 @@ class TestM17NComb < Test::Unit::TestCase
|
|||||||
|
|
||||||
def test_str_sum
|
def test_str_sum
|
||||||
STRINGS.each {|s|
|
STRINGS.each {|s|
|
||||||
assert_equal(a(s).sum, s.sum)
|
assert_equal(b(s).sum, s.sum)
|
||||||
}
|
}
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -1341,8 +1342,8 @@ class TestM17NComb < Test::Unit::TestCase
|
|||||||
end
|
end
|
||||||
|
|
||||||
def test_str_succ2
|
def test_str_succ2
|
||||||
assert_equal("\x01\x00".force_encoding("US-ASCII"), "\x7f".force_encoding("US-ASCII").succ)
|
assert_equal(a("\x01\x00"), a("\x7f").succ)
|
||||||
assert_equal("\x01\x00".b, "\xff".b.succ)
|
assert_equal(b("\x01\x00"), b("\xff").succ)
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_str_hash
|
def test_str_hash
|
||||||
|
Loading…
x
Reference in New Issue
Block a user