summaryrefslogtreecommitdiff
path: root/spec/ruby
diff options
context:
space:
mode:
authorÉtienne Barrié <[email protected]>2024-05-27 11:22:39 +0200
committerJean Boussier <[email protected]>2024-05-28 07:32:33 +0200
commit1376881e9afe6ff673f64afa791cf30f57147ee2 (patch)
treea5ad297473381ac00c593ca2ca1ef93381fd3a00 /spec/ruby
parent2114d0af1e5790da365584a38ea7ee58670dc11b (diff)
Stop marking chilled strings as frozen
They were initially made frozen to avoid false positives for cases such as: str = str.dup if str.frozen? But this may cause bugs and is generally confusing for users. [Feature #20205] Co-authored-by: Jean Boussier <[email protected]>
Diffstat (limited to 'spec/ruby')
-rw-r--r--spec/ruby/command_line/frozen_strings_spec.rb12
-rw-r--r--spec/ruby/core/string/chilled_string_spec.rb12
2 files changed, 9 insertions, 15 deletions
diff --git a/spec/ruby/command_line/frozen_strings_spec.rb b/spec/ruby/command_line/frozen_strings_spec.rb
index 334b98273b..06889755d2 100644
--- a/spec/ruby/command_line/frozen_strings_spec.rb
+++ b/spec/ruby/command_line/frozen_strings_spec.rb
@@ -42,16 +42,8 @@ describe "With neither --enable-frozen-string-literal nor --disable-frozen-strin
ruby_exe(fixture(__FILE__, "freeze_flag_one_literal.rb")).chomp.should == "false"
end
- ruby_version_is "3.4" do
- it "if file has no frozen_string_literal comment produce different frozen strings each time" do
- ruby_exe(fixture(__FILE__, "string_literal_raw.rb")).chomp.should == "frozen:true interned:false"
- end
- end
-
- ruby_version_is ""..."3.4" do
- it "if file has no frozen_string_literal comment produce different mutable strings each time" do
- ruby_exe(fixture(__FILE__, "string_literal_raw.rb")).chomp.should == "frozen:false interned:false"
- end
+ it "if file has no frozen_string_literal comment produce different mutable strings each time" do
+ ruby_exe(fixture(__FILE__, "string_literal_raw.rb")).chomp.should == "frozen:false interned:false"
end
it "if file has frozen_string_literal:true comment produce same frozen strings each time" do
diff --git a/spec/ruby/core/string/chilled_string_spec.rb b/spec/ruby/core/string/chilled_string_spec.rb
index 8de4fc421b..9f81b1af6d 100644
--- a/spec/ruby/core/string/chilled_string_spec.rb
+++ b/spec/ruby/core/string/chilled_string_spec.rb
@@ -3,8 +3,8 @@ require_relative '../../spec_helper'
describe "chilled String" do
guard -> { ruby_version_is "3.4" and !"test".equal?("test") } do
describe "#frozen?" do
- it "returns true" do
- "chilled".frozen?.should == true
+ it "returns false" do
+ "chilled".frozen?.should == false
end
end
@@ -45,7 +45,7 @@ describe "chilled String" do
input.should == "chilled-mutated"
end
- it "emits a warning on singleton_class creaation" do
+ it "emits a warning on singleton_class creation" do
-> {
"chilled".singleton_class
}.should complain(/literal string will be frozen in the future/)
@@ -57,12 +57,14 @@ describe "chilled String" do
}.should complain(/literal string will be frozen in the future/)
end
- it "raises FrozenError after the string was explictly frozen" do
+ it "raises FrozenError after the string was explicitly frozen" do
input = "chilled"
input.freeze
-> {
+ -> {
input << "mutated"
- }.should raise_error(FrozenError)
+ }.should raise_error(FrozenError)
+ }.should_not complain(/literal string will be frozen in the future/)
end
end
end