diff options
author | Jean Boussier <[email protected]> | 2024-05-09 11:56:51 +0200 |
---|---|---|
committer | Benoit Daloze <[email protected]> | 2024-05-09 12:37:25 +0200 |
commit | 74c911dfa99e173756e7382982e8eaa0a90a2491 (patch) | |
tree | fee0c99432c17e2199106bd21dca4e18ba91b347 /spec/ruby/core/string | |
parent | e82138e48a7ff152e358ce37fdae07e989fe5ee3 (diff) |
Add a ruby_bug spec for String#index clearing $~
[Bug #20421]
The bug was fixed in Ruby 3.3 via 9dcdffb8bf8a3654fd78bf1a58b30c8e13888a7a
Diffstat (limited to 'spec/ruby/core/string')
-rw-r--r-- | spec/ruby/core/string/index_spec.rb | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/spec/ruby/core/string/index_spec.rb b/spec/ruby/core/string/index_spec.rb index be79708045..835263a2cd 100644 --- a/spec/ruby/core/string/index_spec.rb +++ b/spec/ruby/core/string/index_spec.rb @@ -231,6 +231,17 @@ describe "String#index with Regexp" do $~.should == nil end + ruby_bug "#20421", ""..."3.3" do + it "always clear $~" do + "a".index(/a/) + $~.should_not == nil + + string = "blablabla" + string.index(/bla/, string.length + 1) + $~.should == nil + end + end + it "starts the search at the given offset" do "blablabla".index(/.{0}/, 5).should == 5 "blablabla".index(/.{1}/, 5).should == 5 |