1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00
This commit is contained in:
Benoit Daloze 2019-10-26 20:53:01 +02:00
parent 3eb0d50c0b
commit 664e96b1de
42 changed files with 484 additions and 117 deletions

View file

@ -10,4 +10,9 @@ describe "MatchData#regexp" do
m = 'haystack'.match(/hay/)
m.regexp.should == /hay/
end
it "returns a Regexp for the result of gsub(String)" do
'he[[o'.gsub('[', ']')
$~.regexp.should == /\[/
end
end

View file

@ -11,4 +11,15 @@ describe "MatchData#string" do
str.should == "THX1138."
str.frozen?.should == true
end
it "returns the same frozen string for every call" do
md = /(.)(.)(\d+)(\d)/.match("THX1138.")
md.string.should equal(md.string)
end
it "returns a frozen copy of the matched string for gsub(String)" do
'he[[o'.gsub!('[', ']')
$~.string.should == 'he[[o'
$~.string.frozen?.should == true
end
end