diff options
Diffstat (limited to 'spec/ruby/core/string/chomp_spec.rb')
-rw-r--r-- | spec/ruby/core/string/chomp_spec.rb | 78 |
1 files changed, 6 insertions, 72 deletions
diff --git a/spec/ruby/core/string/chomp_spec.rb b/spec/ruby/core/string/chomp_spec.rb index 3d6207f876..d27c84c6f6 100644 --- a/spec/ruby/core/string/chomp_spec.rb +++ b/spec/ruby/core/string/chomp_spec.rb @@ -1,4 +1,5 @@ # -*- encoding: utf-8 -*- +# frozen_string_literal: false require_relative '../../spec_helper' require_relative 'fixtures/classes' @@ -40,24 +41,13 @@ describe "String#chomp" do "".chomp.should == "" end - ruby_version_is ''...'2.7' do - it "taints the result if self is tainted" do - "abc".taint.chomp.tainted?.should be_true - end + it "returns a String in the same encoding as self" do + "abc\n\n".encode("US-ASCII").chomp.encoding.should == Encoding::US_ASCII end - ruby_version_is ''...'3.0' do - it "returns subclass instances when called on a subclass" do - str = StringSpecs::MyString.new("hello\n").chomp - str.should be_an_instance_of(StringSpecs::MyString) - end - end - - ruby_version_is '3.0' do - it "returns String instances when called on a subclass" do - str = StringSpecs::MyString.new("hello\n").chomp - str.should be_an_instance_of(String) - end + it "returns String instances when called on a subclass" do + str = StringSpecs::MyString.new("hello\n").chomp + str.should be_an_instance_of(String) end it "removes trailing characters that match $/ when it has been assigned a value" do @@ -80,12 +70,6 @@ describe "String#chomp" do str.chomp(nil).should_not equal(str) end - ruby_version_is ''...'2.7' do - it "taints the result if self is tainted" do - "abc".taint.chomp(nil).tainted?.should be_true - end - end - it "returns an empty String when self is empty" do "".chomp(nil).should == "" end @@ -112,12 +96,6 @@ describe "String#chomp" do "abc\r\n\r\n\r\n".chomp("").should == "abc" end - ruby_version_is ''...'2.7' do - it "taints the result if self is tainted" do - "abc".taint.chomp("").tainted?.should be_true - end - end - it "returns an empty String when self is empty" do "".chomp("").should == "" end @@ -140,12 +118,6 @@ describe "String#chomp" do "abc\r\n\r\n".chomp("\n").should == "abc\r\n" end - ruby_version_is ''...'2.7' do - it "taints the result if self is tainted" do - "abc".taint.chomp("\n").tainted?.should be_true - end - end - it "returns an empty String when self is empty" do "".chomp("\n").should == "" end @@ -178,16 +150,6 @@ describe "String#chomp" do "".chomp("abc").should == "" end - ruby_version_is ''...'2.7' do - it "taints the result if self is tainted" do - "abc".taint.chomp("abc").tainted?.should be_true - end - - it "does not taint the result when the argument is tainted" do - "abc".chomp("abc".taint).tainted?.should be_false - end - end - it "returns an empty String when the argument equals self" do "abc".chomp("abc").should == "" end @@ -232,12 +194,6 @@ describe "String#chomp!" do "".chomp!.should be_nil end - ruby_version_is ''...'2.7' do - it "taints the result if self is tainted" do - "abc\n".taint.chomp!.tainted?.should be_true - end - end - it "returns subclass instances when called on a subclass" do str = StringSpecs::MyString.new("hello\n").chomp! str.should be_an_instance_of(StringSpecs::MyString) @@ -280,12 +236,6 @@ describe "String#chomp!" do "abc\r\n\r\n\r\n".chomp!("").should == "abc" end - ruby_version_is ''...'2.7' do - it "taints the result if self is tainted" do - "abc\n".taint.chomp!("").tainted?.should be_true - end - end - it "returns nil when self is empty" do "".chomp!("").should be_nil end @@ -304,12 +254,6 @@ describe "String#chomp!" do "abc\r\n\r\n".chomp!("\n").should == "abc\r\n" end - ruby_version_is ''...'2.7' do - it "taints the result if self is tainted" do - "abc\n".taint.chomp!("\n").tainted?.should be_true - end - end - it "returns nil when self is empty" do "".chomp!("\n").should be_nil end @@ -341,16 +285,6 @@ describe "String#chomp!" do it "returns nil when self is empty" do "".chomp!("abc").should be_nil end - - ruby_version_is ''...'2.7' do - it "taints the result if self is tainted" do - "abc".taint.chomp!("abc").tainted?.should be_true - end - - it "does not taint the result when the argument is tainted" do - "abc".chomp!("abc".taint).tainted?.should be_false - end - end end it "raises a FrozenError on a frozen instance when it is modified" do |