summaryrefslogtreecommitdiff
path: root/spec/ruby/command_line
diff options
context:
space:
mode:
authorBenoit Daloze <eregontp@gmail.com>2026-01-04 14:53:24 +0100
committerBenoit Daloze <eregontp@gmail.com>2026-01-04 14:53:24 +0100
commit1b3382cbab83f0dbf21b0d3683d4ab5335f6c342 (patch)
tree4837fe96c9c4cffbcfed9d9af2fcde010ebb424d /spec/ruby/command_line
parent18672b392b7164c783381979ad34d550955d0416 (diff)
Update to ruby/spec@f54296d
Diffstat (limited to 'spec/ruby/command_line')
-rw-r--r--spec/ruby/command_line/frozen_strings_spec.rb24
1 files changed, 22 insertions, 2 deletions
diff --git a/spec/ruby/command_line/frozen_strings_spec.rb b/spec/ruby/command_line/frozen_strings_spec.rb
index 014153e0b4..8acab5bc1d 100644
--- a/spec/ruby/command_line/frozen_strings_spec.rb
+++ b/spec/ruby/command_line/frozen_strings_spec.rb
@@ -42,8 +42,28 @@ describe "With neither --enable-frozen-string-literal nor --disable-frozen-strin
ruby_exe(fixture(__FILE__, "freeze_flag_one_literal.rb")).chomp.should == "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"
+ context "if file has no frozen_string_literal comment" do
+ it "produce different mutable strings each time" do
+ ruby_exe(fixture(__FILE__, "string_literal_raw.rb")).chomp.should == "frozen:false interned:false"
+ end
+
+ guard -> { ruby_version_is "3.4" and !"test".frozen? } do
+ it "complain about modification of produced mutable strings" do
+ -> { eval(<<~RUBY) }.should complain(/warning: literal string will be frozen in the future \(run with --debug-frozen-string-literal for more information\)/)
+ "test" << "!"
+ RUBY
+ end
+
+ it "does not complain about modification if Warning[:deprecated] is false" do
+ deprecated = Warning[:deprecated]
+ Warning[:deprecated] = false
+ -> { eval(<<~RUBY) }.should_not complain
+ "test" << "!"
+ RUBY
+ ensure
+ Warning[:deprecated] = deprecated
+ end
+ end
end
it "if file has frozen_string_literal:true comment produce same frozen strings each time" do