summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authornobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2015-02-23 06:26:42 +0000
committernobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2015-02-23 06:26:42 +0000
commita10fdc92707f479961ef65de12736d8cdb852bfa (patch)
treef660652265e57d8fe81ff2de69398158fcc87a39 /test
parent8c13c9cb0ef310587682f108f9379c9c43c58e5c (diff)
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
Diffstat (limited to 'test')
-rw-r--r--test/ruby/test_string.rb18
1 files changed, 18 insertions, 0 deletions
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(" ")))