From a10fdc92707f479961ef65de12736d8cdb852bfa Mon Sep 17 00:00:00 2001 From: nobu Date: Mon, 23 Feb 2015 06:26:42 +0000 Subject: string.c: proper exception * string.c (rb_str_split_m): raise ArgumentError at broken string not RegexpError, as Regexp is not involved in. [ruby-core:68229] [Bug #10886] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@49695 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- test/ruby/test_string.rb | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) (limited to 'test') diff --git a/test/ruby/test_string.rb b/test/ruby/test_string.rb index bb24f508d3..4cd6afdd80 100644 --- a/test/ruby/test_string.rb +++ b/test/ruby/test_string.rb @@ -1345,14 +1345,18 @@ class TestString < Test::Unit::TestCase assert_equal([], "".split(//, 1)) assert_equal("[2, 3]", [1,2,3].slice!(1,10000).inspect, "moved from btest/knownbug") + end + def test_split_encoding bug6206 = '[ruby-dev:45441]' Encoding.list.each do |enc| next unless enc.ascii_compatible? s = S("a:".force_encoding(enc)) assert_equal([enc]*2, s.split(":", 2).map(&:encoding), bug6206) end + end + def test_split_wchar bug8642 = '[ruby-core:56036] [Bug #8642]' [ Encoding::UTF_16BE, Encoding::UTF_16LE, @@ -1365,6 +1369,20 @@ class TestString < Test::Unit::TestCase end end + def test_split_invalid_sequence + bug10886 = '[ruby-core:68229] [Bug #10886]' + broken = S("\xa1".force_encoding("utf-8")) + assert_raise(ArgumentError, bug10886) { + S("a,b").split(broken) + } + end + + def test_split_invalid_argument + assert_raise(TypeError) { + S("a,b").split(BasicObject.new) + } + end + def test_squeeze assert_equal(S("abc"), S("aaabbbbccc").squeeze) assert_equal(S("aa bb cc"), S("aa bb cc").squeeze(S(" "))) -- cgit v1.2.3