1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00

Freeze Regexp literals

[Feature #8948] [Feature #16377]

Since Regexp literals always reference the same instance,
allowing to mutate them can lead to state leak.
This commit is contained in:
Jean Boussier 2019-11-27 11:40:18 +00:00 committed by Yusuke Endoh
parent 07aef4c99a
commit 98ef38ada4
Notes: git 2020-01-15 10:39:11 +09:00
8 changed files with 25 additions and 10 deletions

View file

@ -137,7 +137,7 @@ describe "String#match" do
end
it "calls match on the regular expression" do
regexp = /./
regexp = /./.dup
regexp.should_receive(:match).and_return(:foo)
'hello'.match(regexp).should == :foo
end