summaryrefslogtreecommitdiff
path: root/test/ruby
diff options
context:
space:
mode:
authorNobuyoshi Nakada <nobu@ruby-lang.org>2023-07-09 01:38:33 +0900
committerNobuyoshi Nakada <nobu@ruby-lang.org>2023-07-09 16:21:02 +0900
commite2257831ab20915b839eeaff79c6ec45b498de77 (patch)
tree5b6f516ef614b00751328c81fc50f1b03a7515f9 /test/ruby
parent4e2f98be3907b85c6f470c41e7c00f53653b6e68 (diff)
[Bug #19763] Raise same message exception for regexp
Notes
Notes: Merged: https://github.com/ruby/ruby/pull/8045
Diffstat (limited to 'test/ruby')
-rw-r--r--test/ruby/test_m17n.rb18
1 files changed, 17 insertions, 1 deletions
diff --git a/test/ruby/test_m17n.rb b/test/ruby/test_m17n.rb
index 28293ffffc..907360b3a6 100644
--- a/test/ruby/test_m17n.rb
+++ b/test/ruby/test_m17n.rb
@@ -1090,7 +1090,23 @@ class TestM17N < Test::Unit::TestCase
assert_nil(e("\xa1\xa2\xa3\xa4").index(e("\xa3")))
assert_nil(e("\xa1\xa2\xa3\xa4").rindex(e("\xa3")))
s = e("\xa3\xb0\xa3\xb1\xa3\xb2\xa3\xb3\xa3\xb4")
- assert_raise(Encoding::CompatibilityError){s.rindex(a("\xb1\xa3"))}
+
+ a_with_e = /EUC-JP and ASCII-8BIT/
+ assert_raise_with_message(Encoding::CompatibilityError, a_with_e) do
+ s.index(a("\xb1\xa3"))
+ end
+ assert_raise_with_message(Encoding::CompatibilityError, a_with_e) do
+ s.rindex(a("\xb1\xa3"))
+ end
+
+ a_with_e = /ASCII-8BIT regexp with EUC-JP string/
+ assert_raise_with_message(Encoding::CompatibilityError, a_with_e) do
+ s.index(Regexp.new(a("\xb1\xa3")))
+ end
+ assert_raise_with_message(Encoding::CompatibilityError, a_with_e) do
+ s.rindex(Regexp.new(a("\xb1\xa3")))
+ end
+
bug11488 = '[ruby-core:70592] [Bug #11488]'
each_encoding("abcdef", "def") do |str, substr|
assert_equal(3, str.index(substr), bug11488)