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

add assertion message for previous commit.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@19370 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
akr 2008-09-15 16:24:39 +00:00
parent 2e0a116dd5
commit 9e10d51c40

View file

@ -1,12 +1,19 @@
require 'test/unit'
class TestUTF16 < Test::Unit::TestCase
def encdump(str)
d = str.dump
if /\.force_encoding\("[A-Za-z0-9.:_+-]*"\)\z/ =~ d
d
def encdump(obj)
case obj
when String
d = obj.dump
if /\.force_encoding\("[A-Za-z0-9.:_+-]*"\)\z/ =~ d
d
else
"#{d}.force_encoding(#{obj.encoding.name.dump})"
end
when Regexp
"Regexp.new(#{encdump(obj.source)}, #{obj.options})"
else
"#{d}.force_encoding(#{str.encoding.name.dump})"
raise Argument, "unexpected: #{obj.inspect}"
end
end
@ -359,6 +366,6 @@ EOT
def test_regexp_escape
s = "\0*".force_encoding("UTF-16BE")
r = Regexp.new(Regexp.escape(s))
assert(r =~ s)
assert(r =~ s, "#{encdump(r)} =~ #{encdump(s)}")
end
end