From f234d51eaba861edea925eabb564a0bee41b96a0 Mon Sep 17 00:00:00 2001 From: Benoit Daloze Date: Sat, 28 Mar 2020 00:22:51 +0100 Subject: Update to ruby/spec@ec84479 --- spec/ruby/language/string_spec.rb | 22 ++++++++-------------- 1 file changed, 8 insertions(+), 14 deletions(-) (limited to 'spec/ruby/language/string_spec.rb') 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 -- cgit v1.2.3