summaryrefslogtreecommitdiff
path: root/test/ruby/test_rubyoptions.rb
diff options
context:
space:
mode:
authorJean Boussier <[email protected]>2024-06-24 11:57:26 +0200
committerJean Boussier <[email protected]>2024-06-24 12:43:39 +0200
commit95ffcd3f9ff20c3e9b0556672758cf8724542b0c (patch)
treef49f32fd7c0308fbc7ee2ccf4c2266dc1ba1f704 /test/ruby/test_rubyoptions.rb
parent9cfc1362aa6f42f2c654ee155b1cffb9063879f6 (diff)
Fix `--debug-frozen-string-literal` to not apply `--disable-frozen-string-literal`
[Feature #20205] This was an undesired side effect. Now that this value is a triplet, we can't assume it's disabled by default.
Diffstat (limited to 'test/ruby/test_rubyoptions.rb')
-rw-r--r--test/ruby/test_rubyoptions.rb11
1 files changed, 11 insertions, 0 deletions
diff --git a/test/ruby/test_rubyoptions.rb b/test/ruby/test_rubyoptions.rb
index 22663ed007..0c27172701 100644
--- a/test/ruby/test_rubyoptions.rb
+++ b/test/ruby/test_rubyoptions.rb
@@ -1233,6 +1233,17 @@ class TestRubyOptions < Test::Unit::TestCase
end
end
+ def test_frozen_string_literal_debug_chilled_strings
+ code = <<~RUBY
+ "foo" << "bar"
+ RUBY
+ warning = ["-:1: warning: literal string will be frozen in the future"]
+ assert_in_out_err(["-W:deprecated"], code, [], warning)
+ assert_in_out_err(["-W:deprecated", "--debug-frozen-string-literal"], code, [], warning)
+ assert_in_out_err(["-W:deprecated", "--disable-frozen-string-literal", "--debug-frozen-string-literal"], code, [], [])
+ assert_in_out_err(["-W:deprecated", "--enable-frozen-string-literal", "--debug-frozen-string-literal"], code, [], ["-:1:in '<main>': can't modify frozen String: \"foo\", created at -:1 (FrozenError)"])
+ end
+
def test___dir__encoding
lang = {"LC_ALL"=>ENV["LC_ALL"]||ENV["LANG"]}
with_tmpchdir do