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:
parent
07aef4c99a
commit
98ef38ada4
Notes:
git
2020-01-15 10:39:11 +09:00
8 changed files with 25 additions and 10 deletions
|
|
@ -18,6 +18,12 @@ describe "Literal Regexps" do
|
|||
/Hello/.should be_kind_of(Regexp)
|
||||
end
|
||||
|
||||
ruby_version_is "2.7" do
|
||||
it "is frozen" do
|
||||
/Hello/.frozen?.should == true
|
||||
end
|
||||
end
|
||||
|
||||
it "caches the Regexp object" do
|
||||
rs = []
|
||||
2.times do |i|
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue