aboutsummaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
authorakr <akr@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2008-01-04 05:01:58 +0000
committerakr <akr@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2008-01-04 05:01:58 +0000
commitf780cdec75b5f09a7afbd9b45fad1f0d709fe946 (patch)
tree918c67d130954840deab4486585a9aff3084ac79 /test
parent7d98c90ef2f7def3938a8eec825e314ab178e762 (diff)
downloadruby-f780cdec75b5f09a7afbd9b45fad1f0d709fe946.tar.gz
* re.c (rb_reg_prepare_re): check string encoding. Oniguruma doesn't
support invalid encoding. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@14880 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'test')
-rw-r--r--test/ruby/test_m17n.rb21
1 files changed, 20 insertions, 1 deletions
diff --git a/test/ruby/test_m17n.rb b/test/ruby/test_m17n.rb
index 2292d5581e..28db8377b9 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