File tree Expand file tree Collapse file tree 1 file changed +12
-2
lines changed
spec/ruby/core/string/shared Expand file tree Collapse file tree 1 file changed +12
-2
lines changed Original file line number Diff line number Diff line change 375
375
"hello there" . send ( @method , /(what?)/ , 1 ) . should == nil
376
376
end
377
377
378
+ it "returns nil if the index is larger than the number of captures" do
379
+ "hello there" . send ( @method , /hello (.)/ , 2 ) . should == nil
380
+ # You can't refer to 0 using negative indices
381
+ "hello there" . send ( @method , /hello (.)/ , -2 ) . should == nil
382
+ end
383
+
378
384
it "returns nil if there is no capture for the given index" do
379
385
"hello there" . send ( @method , /[aeiou](.)\1 / , 2 ) . should == nil
380
- # You can't refer to 0 using negative indices
381
- "hello there" . send ( @method , /[aeiou](.)\1 / , -2 ) . should == nil
386
+ end
387
+
388
+ it "returns nil if the given capture group was not matched but still sets $~" do
389
+ "test" . send ( @method , /te(z)?/ , 1 ) . should == nil
390
+ $~[ 0 ] . should == "te"
391
+ $~[ 1 ] . should == nil
382
392
end
383
393
384
394
it "calls to_int on the given index" do
You can’t perform that action at this time.
0 commit comments