From 9e10d51c40a1f662eec1d762d8fb9a09fad3ec05 Mon Sep 17 00:00:00 2001 From: akr Date: Mon, 15 Sep 2008 16:24:39 +0000 Subject: [PATCH] add assertion message for previous commit. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@19370 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- test/ruby/enc/test_utf16.rb | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/test/ruby/enc/test_utf16.rb b/test/ruby/enc/test_utf16.rb index 7f807476aa..463b076c99 100644 --- a/test/ruby/enc/test_utf16.rb +++ b/test/ruby/enc/test_utf16.rb @@ -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