diff options
Diffstat (limited to 'spec/ruby/core/string/element_set_spec.rb')
-rw-r--r-- | spec/ruby/core/string/element_set_spec.rb | 35 |
1 files changed, 9 insertions, 26 deletions
diff --git a/spec/ruby/core/string/element_set_spec.rb b/spec/ruby/core/string/element_set_spec.rb index c9e02a7381..e7599f832c 100644 --- a/spec/ruby/core/string/element_set_spec.rb +++ b/spec/ruby/core/string/element_set_spec.rb @@ -1,4 +1,5 @@ # -*- encoding: utf-8 -*- +# frozen_string_literal: false require_relative '../../spec_helper' require_relative 'fixtures/classes' @@ -14,18 +15,6 @@ describe "String#[]= with Integer index" do a.should == "bamelo" end - ruby_version_is ''...'2.7' do - it "taints self if other_str is tainted" do - a = "hello" - a[0] = "".taint - a.should.tainted? - - a = "hello" - a[0] = "x".taint - a.should.tainted? - end - end - it "raises an IndexError without changing self if idx is outside of self" do str = "hello" @@ -141,6 +130,12 @@ describe "String#[]= with Integer index" do str.encoding.should equal(Encoding::BINARY) end + it "updates the string to a compatible encoding" do + str = " " + str[1] = [0xB9].pack("C*") + str.encoding.should == Encoding::ASCII_8BIT + end + it "raises an Encoding::CompatibilityError if the replacement encoding is incompatible" do str = "あれ" rep = "が".encode Encoding::EUC_JP @@ -363,11 +358,11 @@ describe "String#[]= with a Range index" do end it "raises a RangeError if negative Range begin is out of range" do - -> { "abc"[-4..-2] = "x" }.should raise_error(RangeError) + -> { "abc"[-4..-2] = "x" }.should raise_error(RangeError, "-4..-2 out of range") end it "raises a RangeError if positive Range begin is greater than String size" do - -> { "abc"[4..2] = "x" }.should raise_error(RangeError) + -> { "abc"[4..2] = "x" }.should raise_error(RangeError, "4..2 out of range") end it "uses the Range end as an index rather than a count" do @@ -487,18 +482,6 @@ describe "String#[]= with Integer index, count" do a.should == "hellobob" end - ruby_version_is ''...'2.7' do - it "taints self if other_str is tainted" do - a = "hello" - a[0, 0] = "".taint - a.should.tainted? - - a = "hello" - a[1, 4] = "x".taint - a.should.tainted? - end - end - it "calls #to_int to convert the index and count objects" do index = mock("string element set index") index.should_receive(:to_int).and_return(-4) |