summaryrefslogtreecommitdiff
path: root/spec/ruby/core/matchdata/regexp_spec.rb
diff options
context:
space:
mode:
Diffstat (limited to 'spec/ruby/core/matchdata/regexp_spec.rb')
-rw-r--r--spec/ruby/core/matchdata/regexp_spec.rb6
1 files changed, 6 insertions, 0 deletions
diff --git a/spec/ruby/core/matchdata/regexp_spec.rb b/spec/ruby/core/matchdata/regexp_spec.rb
index 7a4783434c..099b59c559 100644
--- a/spec/ruby/core/matchdata/regexp_spec.rb
+++ b/spec/ruby/core/matchdata/regexp_spec.rb
@@ -11,6 +11,12 @@ describe "MatchData#regexp" do
m.regexp.should == /hay/
end
+ it "returns the same Regexp used to match" do
+ r = /hay/
+ m = 'haystack'.match(r)
+ m.regexp.object_id.should == r.object_id
+ end
+
it "returns a Regexp for the result of gsub(String)" do
'he[[o'.gsub('[', ']')
$~.regexp.should == /\[/