diff options
author | Benoit Daloze <[email protected]> | 2020-03-28 00:22:51 +0100 |
---|---|---|
committer | Benoit Daloze <[email protected]> | 2020-03-28 00:22:51 +0100 |
commit | f234d51eaba861edea925eabb564a0bee41b96a0 (patch) | |
tree | 3334f36a91fe81ec704f2980ab169231f52c41d0 /spec/ruby/language/string_spec.rb | |
parent | 296f68816cf575b3ff920f92aec8a4109a7d81d4 (diff) |
Update to ruby/spec@ec84479
Diffstat (limited to 'spec/ruby/language/string_spec.rb')
-rw-r--r-- | spec/ruby/language/string_spec.rb | 22 |
1 files changed, 8 insertions, 14 deletions
diff --git a/spec/ruby/language/string_spec.rb b/spec/ruby/language/string_spec.rb index d0f62ff3c9..68c5fd221b 100644 --- a/spec/ruby/language/string_spec.rb +++ b/spec/ruby/language/string_spec.rb @@ -260,24 +260,18 @@ describe "Ruby String literals" do end describe "Ruby String interpolation" do - it "creates a String having an Encoding compatible with all components" do - a = "\u3042" - b = "abc".encode("binary") - - str = "#{a} x #{b}" - - str.should == "\xe3\x81\x82\x20\x78\x20\x61\x62\x63".force_encoding("utf-8") - str.encoding.should == Encoding::UTF_8 + 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("# coding: US-ASCII \n 'a#{"b"}c'").encoding.should == Encoding::US_ASCII end - it "creates a String having the Encoding of the components when all are the same Encoding" do + it "returns a string with the source encoding, even if the components have another encoding" do a = "abc".force_encoding("euc-jp") - b = "def".force_encoding("euc-jp") - str = '"#{a} x #{b}"'.force_encoding("euc-jp") + "#{a}".encoding.should == Encoding::BINARY - result = eval(str) - result.should == "\x61\x62\x63\x20\x78\x20\x64\x65\x66".force_encoding("euc-jp") - result.encoding.should == Encoding::EUC_JP + b = "abc".encode("utf-8") + "#{b}".encoding.should == Encoding::BINARY end it "raises an Encoding::CompatibilityError if the Encodings are not compatible" do |