summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authornagachika <nagachika@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2020-03-07 09:38:30 +0000
committernagachika <nagachika@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2020-03-07 09:38:30 +0000
commitca74f62a3abfa13c353737c74624d3ef00777036 (patch)
treece40bef5c24f7b02a6f1a094aff0a989bde46235 /test
parent12c7321d758c736d42dbbd36c74628f7a243851e (diff)
merge revision(s) 4f19666e8b144600e959e4673f79d63f98bd637d: [Backport #16508]
`Regexp` in `MatchData` can be `nil` `String#sub` with a string pattern defers creating a `Regexp` until `MatchData#regexp` creates a `Regexp` from the matched string. `Regexp#last_match(group_name)` accessed its content without creating the `Regexp` though. [Bug #16508] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_2_6@67838 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'test')
-rw-r--r--test/ruby/test_regexp.rb4
1 files changed, 4 insertions, 0 deletions
diff --git a/test/ruby/test_regexp.rb b/test/ruby/test_regexp.rb
index aafad0b6df..38147c7446 100644
--- a/test/ruby/test_regexp.rb
+++ b/test/ruby/test_regexp.rb
@@ -161,6 +161,10 @@ class TestRegexp < Test::Unit::TestCase
s = "foo"
s[/(?<bar>o)/, "bar"] = "baz"
assert_equal("fbazo", s)
+
+ /.*/ =~ "abc"
+ "a".sub("a", "")
+ assert_raise(IndexError) {Regexp.last_match(:_id)}
end
def test_named_capture_with_nul