aboutsummaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
Diffstat (limited to 'test')
-rw-r--r--test/ruby/test_regexp.rb13
1 files changed, 13 insertions, 0 deletions
diff --git a/test/ruby/test_regexp.rb b/test/ruby/test_regexp.rb
index e16075ad38..cef21b99aa 100644
--- a/test/ruby/test_regexp.rb
+++ b/test/ruby/test_regexp.rb
@@ -545,6 +545,19 @@ class TestRegexp < Test::Unit::TestCase
assert_equal("foo", $&)
end
+ def test_match_without_regexp
+ bug10877 = '[ruby-core:68209] [Bug #10877]'
+ "abc".sub("a", "")
+ assert_raise_with_message(IndexError, /foo/, bug10877) {$~["foo"]}
+ key = "\u{3042}"
+ [Encoding::UTF_8, Encoding::Shift_JIS, Encoding::EUC_JP].each do |enc|
+ idx = key.encode(enc)
+ EnvUtil.with_default_external(enc) do
+ assert_raise_with_message(IndexError, /#{idx}/, bug10877) {$~[idx]}
+ end
+ end
+ end
+
def test_last_match
/(...)(...)(...)(...)?/.match("foobarbaz")
assert_equal("foobarbaz", Regexp.last_match(0))