diff options
Diffstat (limited to 'spec/ruby/core/string/tr_spec.rb')
-rw-r--r-- | spec/ruby/core/string/tr_spec.rb | 35 |
1 files changed, 12 insertions, 23 deletions
diff --git a/spec/ruby/core/string/tr_spec.rb b/spec/ruby/core/string/tr_spec.rb index 06be1e6641..75841a974f 100644 --- a/spec/ruby/core/string/tr_spec.rb +++ b/spec/ruby/core/string/tr_spec.rb @@ -1,4 +1,5 @@ # -*- encoding: utf-8 -*- +# frozen_string_literal: false require_relative '../../spec_helper' require_relative 'fixtures/classes' @@ -16,6 +17,15 @@ describe "String#tr" do "hello ^-^".tr("---", "_").should == "hello ^_^" end + ruby_bug "#19769", ""..."3.3" do + it "accepts c1-c1 notation to denote range of one character" do + "hello".tr('e-e', 'x').should == "hxllo" + "123456789".tr("2-23","xy").should == "1xy456789" + "hello ^-^".tr("e-", "a-a_").should == "hallo ^_^" + "hello ^-^".tr("---o", "_a").should == "hella ^_^" + end + end + it "pads to_str with its last char if it is shorter than from_string" do "this".tr("this", "x").should == "xxxx" "hello".tr("a-z", "A-H.").should == "HE..." @@ -57,29 +67,8 @@ describe "String#tr" do "bla".tr(from_str, to_str).should == "BlA" end - ruby_version_is ''...'3.0' do - it "returns subclass instances when called on a subclass" do - StringSpecs::MyString.new("hello").tr("e", "a").should be_an_instance_of(StringSpecs::MyString) - end - end - - ruby_version_is '3.0' do - it "returns Stringinstances when called on a subclass" do - StringSpecs::MyString.new("hello").tr("e", "a").should be_an_instance_of(String) - end - end - - ruby_version_is ''...'2.7' do - it "taints the result when self is tainted" do - ["h", "hello"].each do |str| - tainted_str = str.dup.taint - - tainted_str.tr("e", "a").should.tainted? - - str.tr("e".taint, "a").should_not.tainted? - str.tr("e", "a".taint).should_not.tainted? - end - end + it "returns Stringinstances when called on a subclass" do + StringSpecs::MyString.new("hello").tr("e", "a").should be_an_instance_of(String) end # http://redmine.ruby-lang.org/issues/show/1839 |