diff options
Diffstat (limited to 'spec/ruby/shared/string')
| -rw-r--r-- | spec/ruby/shared/string/end_with.rb | 4 | ||||
| -rw-r--r-- | spec/ruby/shared/string/start_with.rb | 12 | ||||
| -rw-r--r-- | spec/ruby/shared/string/times.rb | 24 |
3 files changed, 19 insertions, 21 deletions
diff --git a/spec/ruby/shared/string/end_with.rb b/spec/ruby/shared/string/end_with.rb index 0e4c1386e8..08f43c1bce 100644 --- a/spec/ruby/shared/string/end_with.rb +++ b/spec/ruby/shared/string/end_with.rb @@ -55,7 +55,7 @@ describe :end_with, shared: true do it "checks that we are starting to match at the head of a character" do "\xC3\xA9".send(@method).should_not.end_with?("\xA9") "\xe3\x81\x82".send(@method).should_not.end_with?("\x82") - "ab".force_encoding("UTF-16BE").send(@method).should_not.end_with?( - "b".force_encoding("UTF-16BE")) + "\xd8\x00\xdc\x00".dup.force_encoding("UTF-16BE").send(@method).should_not.end_with?( + "\xdc\x00".dup.force_encoding("UTF-16BE")) end end diff --git a/spec/ruby/shared/string/start_with.rb b/spec/ruby/shared/string/start_with.rb index 6932a017b6..4b947a3bbf 100644 --- a/spec/ruby/shared/string/start_with.rb +++ b/spec/ruby/shared/string/start_with.rb @@ -70,7 +70,15 @@ describe :start_with, shared: true do $1.should be_nil end - it "does not check that we are not matching part of a character" do - "\xC3\xA9".send(@method).should.start_with?("\xC3") + ruby_version_is ""..."3.3" do + it "does not check that we are not matching part of a character" do + "\xC3\xA9".send(@method).should.start_with?("\xC3") + end + end + + ruby_version_is "3.3" do # #19784 + it "checks that we are not matching part of a character" do + "\xC3\xA9".send(@method).should_not.start_with?("\xC3") + end end end diff --git a/spec/ruby/shared/string/times.rb b/spec/ruby/shared/string/times.rb index 8ca9507570..4814f894cf 100644 --- a/spec/ruby/shared/string/times.rb +++ b/spec/ruby/shared/string/times.rb @@ -32,35 +32,25 @@ describe :string_times, shared: true do @object.call("", max_long).should == "" end - ruby_version_is ''...'3.0' do - it "returns subclass instances" do - @object.call(MyString.new("cool"), 0).should be_an_instance_of(MyString) - @object.call(MyString.new("cool"), 1).should be_an_instance_of(MyString) - @object.call(MyString.new("cool"), 2).should be_an_instance_of(MyString) - end - end - - ruby_version_is '3.0' do - it "returns String instances" do - @object.call(MyString.new("cool"), 0).should be_an_instance_of(String) - @object.call(MyString.new("cool"), 1).should be_an_instance_of(String) - @object.call(MyString.new("cool"), 2).should be_an_instance_of(String) - end + it "returns String instances" do + @object.call(MyString.new("cool"), 0).should be_an_instance_of(String) + @object.call(MyString.new("cool"), 1).should be_an_instance_of(String) + @object.call(MyString.new("cool"), 2).should be_an_instance_of(String) end it "returns a String in the same encoding as self" do - str = "\xE3\x81\x82".force_encoding Encoding::UTF_8 + str = "\xE3\x81\x82".dup.force_encoding Encoding::UTF_8 result = @object.call(str, 2) result.encoding.should equal(Encoding::UTF_8) end - platform_is wordsize: 32 do + platform_is c_long_size: 32 do it "raises an ArgumentError if the length of the resulting string doesn't fit into a long" do -> { @object.call("abc", (2 ** 31) - 1) }.should raise_error(ArgumentError) end end - platform_is wordsize: 64 do + platform_is c_long_size: 64 do it "raises an ArgumentError if the length of the resulting string doesn't fit into a long" do -> { @object.call("abc", (2 ** 63) - 1) }.should raise_error(ArgumentError) end |
