diff options
Diffstat (limited to 'spec/ruby/core/string/tr_s_spec.rb')
-rw-r--r-- | spec/ruby/core/string/tr_s_spec.rb | 72 |
1 files changed, 35 insertions, 37 deletions
diff --git a/spec/ruby/core/string/tr_s_spec.rb b/spec/ruby/core/string/tr_s_spec.rb index 87635acf2c..b05211abc4 100644 --- a/spec/ruby/core/string/tr_s_spec.rb +++ b/spec/ruby/core/string/tr_s_spec.rb @@ -60,49 +60,47 @@ describe "String#tr_s" do end end - with_feature :encoding do - # http://redmine.ruby-lang.org/issues/show/1839 - it "can replace a 7-bit ASCII character with a multibyte one" do - a = "uber" - a.encoding.should == Encoding::UTF_8 - b = a.tr_s("u","ü") - b.should == "über" - b.encoding.should == Encoding::UTF_8 - end - - it "can replace multiple 7-bit ASCII characters with a multibyte one" do - a = "uuuber" - a.encoding.should == Encoding::UTF_8 - b = a.tr_s("u","ü") - b.should == "über" - b.encoding.should == Encoding::UTF_8 - end + # http://redmine.ruby-lang.org/issues/show/1839 + it "can replace a 7-bit ASCII character with a multibyte one" do + a = "uber" + a.encoding.should == Encoding::UTF_8 + b = a.tr_s("u","ü") + b.should == "über" + b.encoding.should == Encoding::UTF_8 + end - it "can replace a multibyte character with a single byte one" do - a = "über" - a.encoding.should == Encoding::UTF_8 - b = a.tr_s("ü","u") - b.should == "uber" - b.encoding.should == Encoding::UTF_8 - end + it "can replace multiple 7-bit ASCII characters with a multibyte one" do + a = "uuuber" + a.encoding.should == Encoding::UTF_8 + b = a.tr_s("u","ü") + b.should == "über" + b.encoding.should == Encoding::UTF_8 + end - it "can replace multiple multibyte characters with a single byte one" do - a = "üüüber" - a.encoding.should == Encoding::UTF_8 - b = a.tr_s("ü","u") - b.should == "uber" - b.encoding.should == Encoding::UTF_8 - end + it "can replace a multibyte character with a single byte one" do + a = "über" + a.encoding.should == Encoding::UTF_8 + b = a.tr_s("ü","u") + b.should == "uber" + b.encoding.should == Encoding::UTF_8 + end - it "does not replace a multibyte character where part of the bytes match the tr string" do - str = "椎名深夏" - a = "\u0080\u0082\u0083\u0084\u0085\u0086\u0087\u0088\u0089\u008A\u008B\u008C\u008E\u0091\u0092\u0093\u0094\u0095\u0096\u0097\u0098\u0099\u009A\u009B\u009C\u009E\u009F" - b = "€‚ƒ„…†‡ˆ‰Š‹ŒŽ‘’“”•–—˜™š›œžŸ" - str.tr_s(a, b).should == "椎名深夏" - end + it "can replace multiple multibyte characters with a single byte one" do + a = "üüüber" + a.encoding.should == Encoding::UTF_8 + b = a.tr_s("ü","u") + b.should == "uber" + b.encoding.should == Encoding::UTF_8 + end + it "does not replace a multibyte character where part of the bytes match the tr string" do + str = "椎名深夏" + a = "\u0080\u0082\u0083\u0084\u0085\u0086\u0087\u0088\u0089\u008A\u008B\u008C\u008E\u0091\u0092\u0093\u0094\u0095\u0096\u0097\u0098\u0099\u009A\u009B\u009C\u009E\u009F" + b = "€‚ƒ„…†‡ˆ‰Š‹ŒŽ‘’“”•–—˜™š›œžŸ" + str.tr_s(a, b).should == "椎名深夏" end + end describe "String#tr_s!" do |