From 5ad3d60d896ff0a7239272b1f4f1e149b534ba79 Mon Sep 17 00:00:00 2001 From: akr Date: Fri, 4 Jan 2008 05:01:58 +0000 Subject: * re.c (rb_reg_prepare_re): check string encoding. Oniguruma doesn't support invalid encoding. git-svn-id: http://svn.ruby-lang.org/repos/ruby/trunk@14880 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- test/ruby/test_m17n.rb | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) (limited to 'test/ruby') diff --git a/test/ruby/test_m17n.rb b/test/ruby/test_m17n.rb index 2292d5581..28db8377b 100644 --- a/test/ruby/test_m17n.rb +++ b/test/ruby/test_m17n.rb @@ -877,7 +877,10 @@ class TestM17N < Test::Unit::TestCase if t != nil assert(t.valid_encoding?) if s1.valid_encoding? && s2.valid_encoding? assert_equal(s2, t) - assert_match(/#{Regexp.escape(s2)}/, s1) + assert_match(/#{Regexp.escape(a(s2))}/, a(s1)) + if s1.valid_encoding? + assert_match(/#{Regexp.escape(s2)}/, s1) + end end else assert_raise(ArgumentError) { s1[s2] } @@ -1577,6 +1580,10 @@ class TestM17N < Test::Unit::TestCase assert_raise(ArgumentError) { s1.scan(s2) } next end + if !s1.valid_encoding? + assert_raise(ArgumentError) { s1.scan(s2) } + next + end r = s1.scan(s2) r.each {|t| assert_equal(s2, t) @@ -1633,6 +1640,10 @@ class TestM17N < Test::Unit::TestCase assert_raise(ArgumentError) { s1.split(s2) } next end + if !s1.valid_encoding? + assert_raise(ArgumentError) { s1.split(s2) } + next + end t = s1.split(s2) t.each {|r| assert(a(s1).include?(a(r))) @@ -1943,6 +1954,10 @@ class TestM17N < Test::Unit::TestCase lambda { s1.gsub(r2) { s3 } } ] ].each {|desc, doit| + if !s1.valid_encoding? + assert_raise(ArgumentError, desc) { doit.call } + next + end if !str_enc_compatible?(s1, s2) assert_raise(ArgumentError, desc) { doit.call } next @@ -1993,6 +2008,10 @@ class TestM17N < Test::Unit::TestCase lambda { t=s1.dup; [t, t.gsub!(r2) { s3 }] } ] ].each {|desc, doit| + if !s1.valid_encoding? + assert_raise(ArgumentError, desc) { doit.call } + next + end if !str_enc_compatible?(s1, s2) assert_raise(ArgumentError, desc) { doit.call } next -- cgit