summaryrefslogtreecommitdiff
path: root/spec/ruby/language/string_spec.rb
diff options
context:
space:
mode:
authorBenoit Daloze <eregontp@gmail.com>2024-03-14 21:44:53 +0100
committerBenoit Daloze <eregontp@gmail.com>2024-03-14 21:44:53 +0100
commited2f68525302413a676d81821b949a21d46407e9 (patch)
treeabfde129320df80dc37e98fcbb13581e3ac6f97b /spec/ruby/language/string_spec.rb
parent1d9f99144bb5239de303c51b86ccde3a33782e8d (diff)
Update to ruby/spec@89175b2
Diffstat (limited to 'spec/ruby/language/string_spec.rb')
-rw-r--r--spec/ruby/language/string_spec.rb9
1 files changed, 5 insertions, 4 deletions
diff --git a/spec/ruby/language/string_spec.rb b/spec/ruby/language/string_spec.rb
index 418dc2ca7d..f2764eada0 100644
--- a/spec/ruby/language/string_spec.rb
+++ b/spec/ruby/language/string_spec.rb
@@ -232,7 +232,8 @@ describe "Ruby String literals" do
end
it "produce different objects for literals with the same content in different files if the other file doesn't have the comment" do
- ruby_exe(fixture(__FILE__, "freeze_magic_comment_across_files_no_comment.rb")).chomp.should == "true"
+ frozen_literals_by_default = eval("'test'").frozen?
+ ruby_exe(fixture(__FILE__, "freeze_magic_comment_across_files_no_comment.rb")).chomp.should == (!frozen_literals_by_default).to_s
end
it "produce different objects for literals with the same content in different files if they have different encodings" do
@@ -251,12 +252,12 @@ describe "Ruby String interpolation" do
it "returns a string with the source encoding by default" do
"a#{"b"}c".encoding.should == Encoding::BINARY
- eval('"a#{"b"}c"'.force_encoding("us-ascii")).encoding.should == Encoding::US_ASCII
+ eval('"a#{"b"}c"'.dup.force_encoding("us-ascii")).encoding.should == Encoding::US_ASCII
eval("# coding: US-ASCII \n 'a#{"b"}c'").encoding.should == Encoding::US_ASCII
end
it "returns a string with the source encoding, even if the components have another encoding" do
- a = "abc".force_encoding("euc-jp")
+ a = "abc".dup.force_encoding("euc-jp")
"#{a}".encoding.should == Encoding::BINARY
b = "abc".encode("utf-8")
@@ -265,7 +266,7 @@ describe "Ruby String interpolation" do
it "raises an Encoding::CompatibilityError if the Encodings are not compatible" do
a = "\u3042"
- b = "\xff".force_encoding "binary"
+ b = "\xff".dup.force_encoding "binary"
-> { "#{a} #{b}" }.should raise_error(Encoding::CompatibilityError)
end