diff options
author | eregon <eregon@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2018-06-13 21:41:45 +0000 |
---|---|---|
committer | eregon <eregon@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2018-06-13 21:41:45 +0000 |
commit | 67078e81f57523fdf65ba7a9d919a146763363a5 (patch) | |
tree | 795ec86c6a90842d9168b0900d058c46244249f3 /spec/ruby/core/string/dump_spec.rb | |
parent | 78890babe74e87aea79d1022ab455aeddf8a3310 (diff) | |
download | ruby-67078e81f57523fdf65ba7a9d919a146763363a5.tar.gz |
Update to ruby/spec@4bc7a2b
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@63652 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'spec/ruby/core/string/dump_spec.rb')
-rw-r--r-- | spec/ruby/core/string/dump_spec.rb | 25 |
1 files changed, 20 insertions, 5 deletions
diff --git a/spec/ruby/core/string/dump_spec.rb b/spec/ruby/core/string/dump_spec.rb index cfe7bea6f0..e67367b5b0 100644 --- a/spec/ruby/core/string/dump_spec.rb +++ b/spec/ruby/core/string/dump_spec.rb @@ -13,10 +13,18 @@ describe "String#dump" do "foo\n".untrust.dump.untrusted?.should == true end + it "does not take into account if a string is frozen" do + "foo".freeze.dump.frozen?.should == false + end + it "returns a subclass instance" do StringSpecs::MyString.new.dump.should be_an_instance_of(StringSpecs::MyString) end + it "wraps string with \"" do + "foo".dump.should == '"foo"' + end + it "returns a string with special characters replaced with \\<char> notation" do [ ["\a", '"\\a"'], ["\b", '"\\b"'], @@ -35,10 +43,11 @@ describe "String#dump" do ].should be_computed_by(:dump) end - it "returns a string with \\#<char> when # is followed by $, @, {" do - [ ["\#$", '"\\#$"'], - ["\#@", '"\\#@"'], - ["\#{", '"\\#{"'] + it "returns a string with \\#<char> when # is followed by $, @, @@, {" do + [ ["\#$PATH", '"\\#$PATH"'], + ["\#@a", '"\\#@a"'], + ["\#@@a", '"\\#@@a"'], + ["\#{a}", '"\\#{a}"'] ].should be_computed_by(:dump) end @@ -381,7 +390,7 @@ describe "String#dump" do end ruby_version_is '2.4' do - it "returns a string with multi-byte UTF-8 characters replaced by \\u{} notation with lower-case hex digits" do + it "returns a string with multi-byte UTF-8 characters replaced by \\u{} notation with upper-case hex digits" do [ [0200.chr('utf-8'), '"\u0080"'], [0201.chr('utf-8'), '"\u0081"'], [0202.chr('utf-8'), '"\u0082"'], @@ -421,4 +430,10 @@ describe "String#dump" do "\u{876}".encode('utf-16be').dump.end_with?(".force_encoding(\"UTF-16BE\")").should be_true "\u{876}".encode('utf-16le').dump.end_with?(".force_encoding(\"UTF-16LE\")").should be_true end + + it "keeps origin encoding" 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 + end end |