diff options
author | Benoit Daloze <eregontp@gmail.com> | 2023-01-05 19:05:29 +0100 |
---|---|---|
committer | Benoit Daloze <eregontp@gmail.com> | 2023-01-05 19:05:29 +0100 |
commit | bbf54ec334fe2edd7669a944d88d17efde49a412 (patch) | |
tree | 2941c7b711319b295aa3664b6a2b984e70a523b7 /spec/ruby/core/string/dump_spec.rb | |
parent | cd5e6cc0ea48353c88d921b885b552dc76da255c (diff) |
Update to ruby/spec@9d69b95
Diffstat (limited to 'spec/ruby/core/string/dump_spec.rb')
-rw-r--r-- | spec/ruby/core/string/dump_spec.rb | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/spec/ruby/core/string/dump_spec.rb b/spec/ruby/core/string/dump_spec.rb index 79a8b55e6d..81de0cfae4 100644 --- a/spec/ruby/core/string/dump_spec.rb +++ b/spec/ruby/core/string/dump_spec.rb @@ -350,7 +350,7 @@ describe "String#dump" do ].should be_computed_by(:dump) end - it "returns a string with multi-byte UTF-8 characters replaced by \\u{} notation with upper-case hex digits" do + it "returns a string with multi-byte UTF-8 characters less than or equal 0xFFFF replaced by \\uXXXX notation with upper-case hex digits" do [ [0200.chr('utf-8'), '"\u0080"'], [0201.chr('utf-8'), '"\u0081"'], [0202.chr('utf-8'), '"\u0082"'], @@ -382,15 +382,21 @@ describe "String#dump" do [0235.chr('utf-8'), '"\u009D"'], [0236.chr('utf-8'), '"\u009E"'], [0237.chr('utf-8'), '"\u009F"'], + [0177777.chr('utf-8'), '"\uFFFF"'], ].should be_computed_by(:dump) end + it "returns a string with multi-byte UTF-8 characters greater than 0xFFFF replaced by \\u{XXXXXX} notation with upper-case hex digits" do + 0x10000.chr('utf-8').dump.should == '"\u{10000}"' + 0x10FFFF.chr('utf-8').dump.should == '"\u{10FFFF}"' + end + it "includes .force_encoding(name) if the encoding isn't ASCII compatible" do "\u{876}".encode('utf-16be').dump.should.end_with?(".force_encoding(\"UTF-16BE\")") "\u{876}".encode('utf-16le').dump.should.end_with?(".force_encoding(\"UTF-16LE\")") end - it "keeps origin encoding" do + it "returns a String in the same encoding as self" do "foo".encode("ISO-8859-1").dump.encoding.should == Encoding::ISO_8859_1 "foo".encode('windows-1251').dump.encoding.should == Encoding::Windows_1251 1.chr.dump.encoding.should == Encoding::US_ASCII |