test_str_slice! refactored.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@17891 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
akr 2008-07-05 12:33:55 +00:00
parent b89bf3f05a
commit 2ca7298386

View File

@ -1122,6 +1122,8 @@ class TestM17NComb < Test::Unit::TestCase
def test_str_slice! def test_str_slice!
each_slice_call {|s, *args| each_slice_call {|s, *args|
desc_slice = "#{encdump s}.slice#{encdumpargs args}"
desc_slice_bang = "#{encdump s}.slice!#{encdumpargs args}"
t = s.dup t = s.dup
begin begin
r = t.slice!(*args) r = t.slice!(*args)
@ -1129,14 +1131,14 @@ class TestM17NComb < Test::Unit::TestCase
e = $! e = $!
end end
if e if e
assert_raise(e.class, "#{encdump s}.slice#{encdumpargs args}") { s.slice(*args) } assert_raise(e.class, desc_slice) { s.slice(*args) }
next next
end end
if !r if !r
assert_nil(s.slice(*args)) assert_nil(s.slice(*args), desc_slice)
next next
end end
assert_equal(s.slice(*args), r) assert_equal(s.slice(*args), r, desc_slice_bang)
assert_equal(s.bytesize, r.bytesize + t.bytesize) assert_equal(s.bytesize, r.bytesize + t.bytesize)
if args.length == 1 && String === args[0] if args.length == 1 && String === args[0]
assert_equal(args[0].encoding, r.encoding, assert_equal(args[0].encoding, r.encoding,