diff options
author | akr <akr@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2008-01-04 05:01:58 +0000 |
---|---|---|
committer | akr <akr@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2008-01-04 05:01:58 +0000 |
commit | 5ad3d60d896ff0a7239272b1f4f1e149b534ba79 (patch) | |
tree | 918c67d130954840deab4486585a9aff3084ac79 /test/ruby/test_m17n.rb | |
parent | 1aa062e285ee3e08a5e27f99d2a05612b62de9f6 (diff) | |
download | ruby-5ad3d60d896ff0a7239272b1f4f1e149b534ba79.tar.gz ruby-5ad3d60d896ff0a7239272b1f4f1e149b534ba79.tar.xz ruby-5ad3d60d896ff0a7239272b1f4f1e149b534ba79.zip |
* 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
Diffstat (limited to 'test/ruby/test_m17n.rb')
-rw-r--r-- | test/ruby/test_m17n.rb | 21 |
1 files changed, 20 insertions, 1 deletions
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 |