diff options
Diffstat (limited to 'spec/ruby/shared/string/times.rb')
| -rw-r--r-- | spec/ruby/shared/string/times.rb | 40 |
1 files changed, 17 insertions, 23 deletions
diff --git a/spec/ruby/shared/string/times.rb b/spec/ruby/shared/string/times.rb index 6b45f7aa1e..0a16ba8b82 100644 --- a/spec/ruby/shared/string/times.rb +++ b/spec/ruby/shared/string/times.rb @@ -18,47 +18,41 @@ describe :string_times, shared: true do end it "raises an ArgumentError when given integer is negative" do - -> { @object.call("cool", -3) }.should raise_error(ArgumentError) - -> { @object.call("cool", -3.14) }.should raise_error(ArgumentError) + -> { @object.call("cool", -3) }.should.raise(ArgumentError) + -> { @object.call("cool", -3.14) }.should.raise(ArgumentError) + -> { @object.call("cool", min_long) }.should.raise(ArgumentError) end it "raises a RangeError when given integer is a Bignum" do - -> { @object.call("cool", 999999999999999999999) }.should raise_error(RangeError) + -> { @object.call("cool", 999999999999999999999) }.should.raise(RangeError) + -> { @object.call("", 999999999999999999999) }.should.raise(RangeError) end - 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) + it "works with huge long values when string is empty" do + @object.call("", max_long).should == "" end - ruby_version_is ''...'2.7' do - it "always taints the result when self is tainted" do - ["", "OK", MyString.new(""), MyString.new("OK")].each do |str| - str.taint - - [0, 1, 2].each do |arg| - @object.call(str, arg).tainted?.should == true - end - end - end + it "returns String instances" do + @object.call(MyString.new("cool"), 0).should.instance_of?(String) + @object.call(MyString.new("cool"), 1).should.instance_of?(String) + @object.call(MyString.new("cool"), 2).should.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) + 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) + -> { @object.call("abc", (2 ** 31) - 1) }.should.raise(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) + -> { @object.call("abc", (2 ** 63) - 1) }.should.raise(ArgumentError) end end end |
