diff options
Diffstat (limited to 'spec/ruby/core/matchdata/string_spec.rb')
| -rw-r--r-- | spec/ruby/core/matchdata/string_spec.rb | 14 |
1 files changed, 13 insertions, 1 deletions
diff --git a/spec/ruby/core/matchdata/string_spec.rb b/spec/ruby/core/matchdata/string_spec.rb index ff1b4eab5b..952e953318 100644 --- a/spec/ruby/core/matchdata/string_spec.rb +++ b/spec/ruby/core/matchdata/string_spec.rb @@ -9,6 +9,18 @@ describe "MatchData#string" do it "returns a frozen copy of the match string" do str = /(.)(.)(\d+)(\d)/.match("THX1138.").string str.should == "THX1138." - str.frozen?.should == true + str.should.frozen? + 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 + s = +'he[[o' + s.gsub!('[', ']') + $~.string.should == 'he[[o' + $~.string.should.frozen? end end |
