1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@61504 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
eregon 2017-12-27 16:12:47 +00:00
parent 0f989b87a0
commit a34db218ad
162 changed files with 1267 additions and 621 deletions

View file

@ -61,10 +61,10 @@ describe "String#capitalize!" do
"H".capitalize!.should == nil
end
it "raises a RuntimeError when self is frozen" do
it "raises a #{frozen_error_class} when self is frozen" do
["", "Hello", "hello"].each do |a|
a.freeze
lambda { a.capitalize! }.should raise_error(RuntimeError)
lambda { a.capitalize! }.should raise_error(frozen_error_class)
end
end
end

View file

@ -180,5 +180,17 @@ ruby_version_is "2.4" do
end
end
end
ruby_version_is "2.4" ... "2.5" do
it "raises a TypeError if other can't be converted to a string" do
lambda { "abc".casecmp?(mock('abc')) }.should raise_error(TypeError)
end
end
ruby_version_is "2.5" do
it "returns nil if other can't be converted to a string" do
"abc".casecmp?(mock('abc')).should be_nil
end
end
end
end

View file

@ -310,19 +310,19 @@ describe "String#chomp!" do
end
end
it "raises a RuntimeError on a frozen instance when it is modified" do
it "raises a #{frozen_error_class} on a frozen instance when it is modified" do
a = "string\n\r"
a.freeze
lambda { a.chomp! }.should raise_error(RuntimeError)
lambda { a.chomp! }.should raise_error(frozen_error_class)
end
# see [ruby-core:23666]
it "raises a RuntimeError on a frozen instance when it would not be modified" do
it "raises a #{frozen_error_class} on a frozen instance when it would not be modified" do
a = "string\n\r"
a.freeze
lambda { a.chomp!(nil) }.should raise_error(RuntimeError)
lambda { a.chomp!("x") }.should raise_error(RuntimeError)
lambda { a.chomp!(nil) }.should raise_error(frozen_error_class)
lambda { a.chomp!("x") }.should raise_error(frozen_error_class)
end
end

View file

@ -115,14 +115,14 @@ describe "String#chop!" do
"".chop!.should be_nil
end
it "raises a RuntimeError on a frozen instance that is modified" do
lambda { "string\n\r".freeze.chop! }.should raise_error(RuntimeError)
it "raises a #{frozen_error_class} on a frozen instance that is modified" do
lambda { "string\n\r".freeze.chop! }.should raise_error(frozen_error_class)
end
# see [ruby-core:23666]
it "raises a RuntimeError on a frozen instance that would not be modified" do
it "raises a #{frozen_error_class} on a frozen instance that would not be modified" do
a = ""
a.freeze
lambda { a.chop! }.should raise_error(RuntimeError)
lambda { a.chop! }.should raise_error(frozen_error_class)
end
end

View file

@ -30,10 +30,10 @@ with_feature :encoding do
s.should == ""
end
it "raises a RuntimeError if self is frozen" do
it "raises a #{frozen_error_class} if self is frozen" do
@s.freeze
lambda { @s.clear }.should raise_error(RuntimeError)
lambda { "".freeze.clear }.should raise_error(RuntimeError)
lambda { @s.clear }.should raise_error(frozen_error_class)
lambda { "".freeze.clear }.should raise_error(frozen_error_class)
end
end
end

View file

@ -72,10 +72,10 @@ ruby_version_is '2.5' do
'hello'.delete_prefix!(o).should == 'o'
end
it "raises a RuntimeError when self is frozen" do
lambda { 'hello'.freeze.delete_prefix!('hell') }.should raise_error(RuntimeError)
lambda { 'hello'.freeze.delete_prefix!('') }.should raise_error(RuntimeError)
lambda { ''.freeze.delete_prefix!('') }.should raise_error(RuntimeError)
it "raises a #{frozen_error_class} when self is frozen" do
lambda { 'hello'.freeze.delete_prefix!('hell') }.should raise_error(frozen_error_class)
lambda { 'hello'.freeze.delete_prefix!('') }.should raise_error(frozen_error_class)
lambda { ''.freeze.delete_prefix!('') }.should raise_error(frozen_error_class)
end
end
end

View file

@ -109,11 +109,11 @@ describe "String#delete!" do
a.should == "hello"
end
it "raises a RuntimeError when self is frozen" do
it "raises a #{frozen_error_class} when self is frozen" do
a = "hello"
a.freeze
lambda { a.delete!("") }.should raise_error(RuntimeError)
lambda { a.delete!("aeiou", "^e") }.should raise_error(RuntimeError)
lambda { a.delete!("") }.should raise_error(frozen_error_class)
lambda { a.delete!("aeiou", "^e") }.should raise_error(frozen_error_class)
end
end

View file

@ -72,10 +72,10 @@ ruby_version_is '2.5' do
'hello'.delete_suffix!(o).should == 'h'
end
it "raises a RuntimeError when self is frozen" do
lambda { 'hello'.freeze.delete_suffix!('ello') }.should raise_error(RuntimeError)
lambda { 'hello'.freeze.delete_suffix!('') }.should raise_error(RuntimeError)
lambda { ''.freeze.delete_suffix!('') }.should raise_error(RuntimeError)
it "raises a #{frozen_error_class} when self is frozen" do
lambda { 'hello'.freeze.delete_suffix!('ello') }.should raise_error(frozen_error_class)
lambda { 'hello'.freeze.delete_suffix!('') }.should raise_error(frozen_error_class)
lambda { ''.freeze.delete_suffix!('') }.should raise_error(frozen_error_class)
end
end
end

View file

@ -60,9 +60,9 @@ describe "String#downcase!" do
a.should == "hello"
end
it "raises a RuntimeError when self is frozen" do
lambda { "HeLlo".freeze.downcase! }.should raise_error(RuntimeError)
lambda { "hello".freeze.downcase! }.should raise_error(RuntimeError)
it "raises a #{frozen_error_class} when self is frozen" do
lambda { "HeLlo".freeze.downcase! }.should raise_error(frozen_error_class)
lambda { "hello".freeze.downcase! }.should raise_error(frozen_error_class)
end
with_feature :encoding do

View file

@ -50,11 +50,11 @@ describe "String#[]= with Fixnum index" do
str.should == "hello"
end
it "raises a RuntimeError when self is frozen" do
it "raises a #{frozen_error_class} when self is frozen" do
a = "hello"
a.freeze
lambda { a[0] = "bam" }.should raise_error(RuntimeError)
lambda { a[0] = "bam" }.should raise_error(frozen_error_class)
end
it "calls to_int on index" do

View file

@ -107,13 +107,13 @@ with_feature :encoding do
it_behaves_like :string_encode, :encode!
it "raises a RuntimeError when called on a frozen String" do
lambda { "foo".freeze.encode!("euc-jp") }.should raise_error(RuntimeError)
it "raises a #{frozen_error_class} when called on a frozen String" do
lambda { "foo".freeze.encode!("euc-jp") }.should raise_error(frozen_error_class)
end
# http://redmine.ruby-lang.org/issues/show/1836
it "raises a RuntimeError when called on a frozen String when it's a no-op" do
lambda { "foo".freeze.encode!("utf-8") }.should raise_error(RuntimeError)
it "raises a #{frozen_error_class} when called on a frozen String when it's a no-op" do
lambda { "foo".freeze.encode!("utf-8") }.should raise_error(frozen_error_class)
end
describe "when passed no options" do

View file

@ -45,9 +45,9 @@ with_feature :encoding do
str.dup.force_encoding('utf-16le').should_not == str.encode('utf-16le')
end
it "raises a RuntimeError if self is frozen" do
it "raises a #{frozen_error_class} if self is frozen" do
str = "abcd".freeze
lambda { str.force_encoding(str.encoding) }.should raise_error(RuntimeError)
lambda { str.force_encoding(str.encoding) }.should raise_error(frozen_error_class)
end
end
end

View file

@ -603,13 +603,13 @@ describe "String#gsub! with pattern and replacement" do
end
# See [ruby-core:23666]
it "raises a RuntimeError when self is frozen" do
it "raises a #{frozen_error_class} when self is frozen" do
s = "hello"
s.freeze
lambda { s.gsub!(/ROAR/, "x") }.should raise_error(RuntimeError)
lambda { s.gsub!(/e/, "e") }.should raise_error(RuntimeError)
lambda { s.gsub!(/[aeiou]/, '*') }.should raise_error(RuntimeError)
lambda { s.gsub!(/ROAR/, "x") }.should raise_error(frozen_error_class)
lambda { s.gsub!(/e/, "e") }.should raise_error(frozen_error_class)
lambda { s.gsub!(/[aeiou]/, '*') }.should raise_error(frozen_error_class)
end
end
@ -640,13 +640,13 @@ describe "String#gsub! with pattern and block" do
end
# See [ruby-core:23663]
it "raises a RuntimeError when self is frozen" do
it "raises a #{frozen_error_class} when self is frozen" do
s = "hello"
s.freeze
lambda { s.gsub!(/ROAR/) { "x" } }.should raise_error(RuntimeError)
lambda { s.gsub!(/e/) { "e" } }.should raise_error(RuntimeError)
lambda { s.gsub!(/[aeiou]/) { '*' } }.should raise_error(RuntimeError)
lambda { s.gsub!(/ROAR/) { "x" } }.should raise_error(frozen_error_class)
lambda { s.gsub!(/e/) { "e" } }.should raise_error(frozen_error_class)
lambda { s.gsub!(/[aeiou]/) { '*' } }.should raise_error(frozen_error_class)
end
it "uses the compatible encoding if they are compatible" do

View file

@ -57,10 +57,10 @@ describe "String#insert with index, other" do
lambda { "abcd".insert(-6, mock('x')) }.should raise_error(TypeError)
end
it "raises a RuntimeError if self is frozen" do
it "raises a #{frozen_error_class} if self is frozen" do
str = "abcd".freeze
lambda { str.insert(4, '') }.should raise_error(RuntimeError)
lambda { str.insert(4, 'X') }.should raise_error(RuntimeError)
lambda { str.insert(4, '') }.should raise_error(frozen_error_class)
lambda { str.insert(4, 'X') }.should raise_error(frozen_error_class)
end
with_feature :encoding do

View file

@ -38,13 +38,13 @@ describe "String#lstrip!" do
a.should == "hello"
end
it "raises a RuntimeError on a frozen instance that is modified" do
lambda { " hello ".freeze.lstrip! }.should raise_error(RuntimeError)
it "raises a #{frozen_error_class} on a frozen instance that is modified" do
lambda { " hello ".freeze.lstrip! }.should raise_error(frozen_error_class)
end
# see [ruby-core:23657]
it "raises a RuntimeError on a frozen instance that would not be modified" do
lambda { "hello".freeze.lstrip! }.should raise_error(RuntimeError)
lambda { "".freeze.lstrip! }.should raise_error(RuntimeError)
it "raises a #{frozen_error_class} on a frozen instance that would not be modified" do
lambda { "hello".freeze.lstrip! }.should raise_error(frozen_error_class)
lambda { "".freeze.lstrip! }.should raise_error(frozen_error_class)
end
end

View file

@ -20,12 +20,12 @@ describe "String#prepend" do
lambda { 'hello '.prepend mock('x') }.should raise_error(TypeError)
end
it "raises a RuntimeError when self is frozen" do
it "raises a #{frozen_error_class} when self is frozen" do
a = "hello"
a.freeze
lambda { a.prepend "" }.should raise_error(RuntimeError)
lambda { a.prepend "test" }.should raise_error(RuntimeError)
lambda { a.prepend "" }.should raise_error(frozen_error_class)
lambda { a.prepend "test" }.should raise_error(frozen_error_class)
end
it "works when given a subclass instance" do

View file

@ -32,14 +32,14 @@ describe "String#reverse!" do
"".reverse!.should == ""
end
it "raises a RuntimeError on a frozen instance that is modified" do
lambda { "anna".freeze.reverse! }.should raise_error(RuntimeError)
lambda { "hello".freeze.reverse! }.should raise_error(RuntimeError)
it "raises a #{frozen_error_class} on a frozen instance that is modified" do
lambda { "anna".freeze.reverse! }.should raise_error(frozen_error_class)
lambda { "hello".freeze.reverse! }.should raise_error(frozen_error_class)
end
# see [ruby-core:23666]
it "raises a RuntimeError on a frozen instance that would not be modified" do
lambda { "".freeze.reverse! }.should raise_error(RuntimeError)
it "raises a #{frozen_error_class} on a frozen instance that would not be modified" do
lambda { "".freeze.reverse! }.should raise_error(frozen_error_class)
end
with_feature :encoding do

View file

@ -40,13 +40,13 @@ describe "String#rstrip!" do
a.should == "hello"
end
it "raises a RuntimeError on a frozen instance that is modified" do
lambda { " hello ".freeze.rstrip! }.should raise_error(RuntimeError)
it "raises a #{frozen_error_class} on a frozen instance that is modified" do
lambda { " hello ".freeze.rstrip! }.should raise_error(frozen_error_class)
end
# see [ruby-core:23666]
it "raises a RuntimeError on a frozen instance that would not be modified" do
lambda { "hello".freeze.rstrip! }.should raise_error(RuntimeError)
lambda { "".freeze.rstrip! }.should raise_error(RuntimeError)
it "raises a #{frozen_error_class} on a frozen instance that would not be modified" do
lambda { "hello".freeze.rstrip! }.should raise_error(frozen_error_class)
lambda { "".freeze.rstrip! }.should raise_error(frozen_error_class)
end
end

View file

@ -75,10 +75,10 @@ describe "String#setbyte" do
str1.should_not == "ledgehog"
end
it "raises a RuntimeError if self is frozen" do
it "raises a #{frozen_error_class} if self is frozen" do
str = "cold".freeze
str.frozen?.should be_true
lambda { str.setbyte(3,96) }.should raise_error(RuntimeError)
lambda { str.setbyte(3,96) }.should raise_error(frozen_error_class)
end
it "raises a TypeError unless the second argument is an Integer" do

View file

@ -17,12 +17,12 @@ describe :string_concat, shared: true do
lambda { 'hello '.send(@method, mock('x')) }.should raise_error(TypeError)
end
it "raises a RuntimeError when self is frozen" do
it "raises a #{frozen_error_class} when self is frozen" do
a = "hello"
a.freeze
lambda { a.send(@method, "") }.should raise_error(RuntimeError)
lambda { a.send(@method, "test") }.should raise_error(RuntimeError)
lambda { a.send(@method, "") }.should raise_error(frozen_error_class)
lambda { a.send(@method, "test") }.should raise_error(frozen_error_class)
end
it "returns a String when given a subclass instance" do
@ -87,12 +87,12 @@ describe :string_concat, shared: true do
lambda { "".send(@method, x) }.should raise_error(TypeError)
end
it "raises a RuntimeError when self is frozen" do
it "raises a #{frozen_error_class} when self is frozen" do
a = "hello"
a.freeze
lambda { a.send(@method, 0) }.should raise_error(RuntimeError)
lambda { a.send(@method, 33) }.should raise_error(RuntimeError)
lambda { a.send(@method, 0) }.should raise_error(frozen_error_class)
lambda { a.send(@method, 33) }.should raise_error(frozen_error_class)
end
end
end

View file

@ -62,14 +62,14 @@ describe :string_replace, shared: true do
lambda { "hello".send(@method, mock('x')) }.should raise_error(TypeError)
end
it "raises a RuntimeError on a frozen instance that is modified" do
it "raises a #{frozen_error_class} on a frozen instance that is modified" do
a = "hello".freeze
lambda { a.send(@method, "world") }.should raise_error(RuntimeError)
lambda { a.send(@method, "world") }.should raise_error(frozen_error_class)
end
# see [ruby-core:23666]
it "raises a RuntimeError on a frozen instance when self-replacing" do
it "raises a #{frozen_error_class} on a frozen instance when self-replacing" do
a = "hello".freeze
lambda { a.send(@method, a) }.should raise_error(RuntimeError)
lambda { a.send(@method, a) }.should raise_error(frozen_error_class)
end
end

View file

@ -81,8 +81,8 @@ describe :string_succ_bang, shared: true do
end
end
it "raises a RuntimeError if self is frozen" do
lambda { "".freeze.send(@method) }.should raise_error(RuntimeError)
lambda { "abcd".freeze.send(@method) }.should raise_error(RuntimeError)
it "raises a #{frozen_error_class} if self is frozen" do
lambda { "".freeze.send(@method) }.should raise_error(frozen_error_class)
lambda { "abcd".freeze.send(@method) }.should raise_error(frozen_error_class)
end
end

View file

@ -53,10 +53,10 @@ describe "String#slice! with index" do
a.should == "hello"
end
it "raises a RuntimeError if self is frozen" do
lambda { "hello".freeze.slice!(1) }.should raise_error(RuntimeError)
lambda { "hello".freeze.slice!(10) }.should raise_error(RuntimeError)
lambda { "".freeze.slice!(0) }.should raise_error(RuntimeError)
it "raises a #{frozen_error_class} if self is frozen" do
lambda { "hello".freeze.slice!(1) }.should raise_error(frozen_error_class)
lambda { "hello".freeze.slice!(10) }.should raise_error(frozen_error_class)
lambda { "".freeze.slice!(0) }.should raise_error(frozen_error_class)
end
it "calls to_int on index" do
@ -119,14 +119,14 @@ describe "String#slice! with index, length" do
a.should == "hello"
end
it "raises a RuntimeError if self is frozen" do
lambda { "hello".freeze.slice!(1, 2) }.should raise_error(RuntimeError)
lambda { "hello".freeze.slice!(10, 3) }.should raise_error(RuntimeError)
lambda { "hello".freeze.slice!(-10, 3)}.should raise_error(RuntimeError)
lambda { "hello".freeze.slice!(4, -3) }.should raise_error(RuntimeError)
lambda { "hello".freeze.slice!(10, 3) }.should raise_error(RuntimeError)
lambda { "hello".freeze.slice!(-10, 3)}.should raise_error(RuntimeError)
lambda { "hello".freeze.slice!(4, -3) }.should raise_error(RuntimeError)
it "raises a #{frozen_error_class} if self is frozen" do
lambda { "hello".freeze.slice!(1, 2) }.should raise_error(frozen_error_class)
lambda { "hello".freeze.slice!(10, 3) }.should raise_error(frozen_error_class)
lambda { "hello".freeze.slice!(-10, 3)}.should raise_error(frozen_error_class)
lambda { "hello".freeze.slice!(4, -3) }.should raise_error(frozen_error_class)
lambda { "hello".freeze.slice!(10, 3) }.should raise_error(frozen_error_class)
lambda { "hello".freeze.slice!(-10, 3)}.should raise_error(frozen_error_class)
lambda { "hello".freeze.slice!(4, -3) }.should raise_error(frozen_error_class)
end
it "calls to_int on idx and length" do
@ -250,13 +250,13 @@ describe "String#slice! Range" do
end
it "raises a RuntimeError on a frozen instance that is modified" do
lambda { "hello".freeze.slice!(1..3) }.should raise_error(RuntimeError)
it "raises a #{frozen_error_class} on a frozen instance that is modified" do
lambda { "hello".freeze.slice!(1..3) }.should raise_error(frozen_error_class)
end
# see redmine #1551
it "raises a RuntimeError on a frozen instance that would not be modified" do
lambda { "hello".freeze.slice!(10..20)}.should raise_error(RuntimeError)
it "raises a #{frozen_error_class} on a frozen instance that would not be modified" do
lambda { "hello".freeze.slice!(10..20)}.should raise_error(frozen_error_class)
end
end
@ -320,12 +320,12 @@ describe "String#slice! with Regexp" do
$~.should == nil
end
it "raises a RuntimeError on a frozen instance that is modified" do
lambda { "this is a string".freeze.slice!(/s.*t/) }.should raise_error(RuntimeError)
it "raises a #{frozen_error_class} on a frozen instance that is modified" do
lambda { "this is a string".freeze.slice!(/s.*t/) }.should raise_error(frozen_error_class)
end
it "raises a RuntimeError on a frozen instance that would not be modified" do
lambda { "this is a string".freeze.slice!(/zzz/) }.should raise_error(RuntimeError)
it "raises a #{frozen_error_class} on a frozen instance that would not be modified" do
lambda { "this is a string".freeze.slice!(/zzz/) }.should raise_error(frozen_error_class)
end
end
@ -412,10 +412,10 @@ describe "String#slice! with Regexp, index" do
$~.should == nil
end
it "raises a RuntimeError if self is frozen" do
lambda { "this is a string".freeze.slice!(/s.*t/) }.should raise_error(RuntimeError)
lambda { "this is a string".freeze.slice!(/zzz/, 0)}.should raise_error(RuntimeError)
lambda { "this is a string".freeze.slice!(/(.)/, 2)}.should raise_error(RuntimeError)
it "raises a #{frozen_error_class} if self is frozen" do
lambda { "this is a string".freeze.slice!(/s.*t/) }.should raise_error(frozen_error_class)
lambda { "this is a string".freeze.slice!(/zzz/, 0)}.should raise_error(frozen_error_class)
lambda { "this is a string".freeze.slice!(/(.)/, 2)}.should raise_error(frozen_error_class)
end
end
@ -468,9 +468,9 @@ describe "String#slice! with String" do
r.should be_an_instance_of(StringSpecs::MyString)
end
it "raises a RuntimeError if self is frozen" do
lambda { "hello hello".freeze.slice!('llo') }.should raise_error(RuntimeError)
lambda { "this is a string".freeze.slice!('zzz')}.should raise_error(RuntimeError)
lambda { "this is a string".freeze.slice!('zzz')}.should raise_error(RuntimeError)
it "raises a #{frozen_error_class} if self is frozen" do
lambda { "hello hello".freeze.slice!('llo') }.should raise_error(frozen_error_class)
lambda { "this is a string".freeze.slice!('zzz')}.should raise_error(frozen_error_class)
lambda { "this is a string".freeze.slice!('zzz')}.should raise_error(frozen_error_class)
end
end

View file

@ -103,11 +103,11 @@ describe "String#squeeze!" do
lambda { s.squeeze!("^e-b") }.should raise_error(ArgumentError)
end
it "raises a RuntimeError when self is frozen" do
it "raises a #{frozen_error_class} when self is frozen" do
a = "yellow moon"
a.freeze
lambda { a.squeeze!("") }.should raise_error(RuntimeError)
lambda { a.squeeze! }.should raise_error(RuntimeError)
lambda { a.squeeze!("") }.should raise_error(frozen_error_class)
lambda { a.squeeze! }.should raise_error(frozen_error_class)
end
end

View file

@ -48,13 +48,13 @@ describe "String#strip!" do
a.should == "\x00 goodbye"
end
it "raises a RuntimeError on a frozen instance that is modified" do
lambda { " hello ".freeze.strip! }.should raise_error(RuntimeError)
it "raises a #{frozen_error_class} on a frozen instance that is modified" do
lambda { " hello ".freeze.strip! }.should raise_error(frozen_error_class)
end
# see #1552
it "raises a RuntimeError on a frozen instance that would not be modified" do
lambda {"hello".freeze.strip! }.should raise_error(RuntimeError)
lambda {"".freeze.strip! }.should raise_error(RuntimeError)
it "raises a #{frozen_error_class} on a frozen instance that would not be modified" do
lambda {"hello".freeze.strip! }.should raise_error(frozen_error_class)
lambda {"".freeze.strip! }.should raise_error(frozen_error_class)
end
end

View file

@ -326,13 +326,13 @@ describe "String#sub! with pattern, replacement" do
a.should == "hello"
end
it "raises a RuntimeError when self is frozen" do
it "raises a #{frozen_error_class} when self is frozen" do
s = "hello"
s.freeze
lambda { s.sub!(/ROAR/, "x") }.should raise_error(RuntimeError)
lambda { s.sub!(/e/, "e") }.should raise_error(RuntimeError)
lambda { s.sub!(/[aeiou]/, '*') }.should raise_error(RuntimeError)
lambda { s.sub!(/ROAR/, "x") }.should raise_error(frozen_error_class)
lambda { s.sub!(/e/, "e") }.should raise_error(frozen_error_class)
lambda { s.sub!(/[aeiou]/, '*') }.should raise_error(frozen_error_class)
end
end
@ -379,13 +379,13 @@ describe "String#sub! with pattern and block" do
lambda { str.sub!(//) { str << 'x' } }.should raise_error(RuntimeError)
end
it "raises a RuntimeError when self is frozen" do
it "raises a #{frozen_error_class} when self is frozen" do
s = "hello"
s.freeze
lambda { s.sub!(/ROAR/) { "x" } }.should raise_error(RuntimeError)
lambda { s.sub!(/e/) { "e" } }.should raise_error(RuntimeError)
lambda { s.sub!(/[aeiou]/) { '*' } }.should raise_error(RuntimeError)
lambda { s.sub!(/ROAR/) { "x" } }.should raise_error(frozen_error_class)
lambda { s.sub!(/e/) { "e" } }.should raise_error(frozen_error_class)
lambda { s.sub!(/[aeiou]/) { '*' } }.should raise_error(frozen_error_class)
end
end

View file

@ -57,10 +57,10 @@ describe "String#swapcase!" do
"".swapcase!.should == nil
end
it "raises a RuntimeError when self is frozen" do
it "raises a #{frozen_error_class} when self is frozen" do
["", "hello"].each do |a|
a.freeze
lambda { a.swapcase! }.should raise_error(RuntimeError)
lambda { a.swapcase! }.should raise_error(frozen_error_class)
end
end
end

View file

@ -127,10 +127,10 @@ describe "String#tr_s!" do
s.should == "hello"
end
it "raises a RuntimeError if self is frozen" do
it "raises a #{frozen_error_class} if self is frozen" do
s = "hello".freeze
lambda { s.tr_s!("el", "ar") }.should raise_error(RuntimeError)
lambda { s.tr_s!("l", "r") }.should raise_error(RuntimeError)
lambda { s.tr_s!("", "") }.should raise_error(RuntimeError)
lambda { s.tr_s!("el", "ar") }.should raise_error(frozen_error_class)
lambda { s.tr_s!("l", "r") }.should raise_error(frozen_error_class)
lambda { s.tr_s!("", "") }.should raise_error(frozen_error_class)
end
end

View file

@ -122,10 +122,10 @@ describe "String#tr!" do
s.should == "hello"
end
it "raises a RuntimeError if self is frozen" do
it "raises a #{frozen_error_class} if self is frozen" do
s = "abcdefghijklmnopqR".freeze
lambda { s.tr!("cdefg", "12") }.should raise_error(RuntimeError)
lambda { s.tr!("R", "S") }.should raise_error(RuntimeError)
lambda { s.tr!("", "") }.should raise_error(RuntimeError)
lambda { s.tr!("cdefg", "12") }.should raise_error(frozen_error_class)
lambda { s.tr!("R", "S") }.should raise_error(frozen_error_class)
lambda { s.tr!("", "") }.should raise_error(frozen_error_class)
end
end

View file

@ -4,10 +4,7 @@ require File.expand_path('../shared/basic', __FILE__)
require File.expand_path('../shared/integer', __FILE__)
ruby_version_is '2.3' do
# To handle the special case of x64-mingw32
pointer_size = RUBY_PLATFORM =~ /\bx64\b/ ? 64 : 1.size * 8
if pointer_size == 64 then
platform_is pointer_size: 64 do
little_endian do
describe "String#unpack with format 'J'" do
describe "with modifier '_'" do
@ -141,7 +138,7 @@ ruby_version_is '2.3' do
end
end
if pointer_size == 32 then
platform_is pointer_size: 32 do
little_endian do
describe "String#unpack with format 'J'" do
describe "with modifier '_'" do

View file

@ -61,8 +61,8 @@ describe "String#upcase!" do
a.should == "HELLO"
end
it "raises a RuntimeError when self is frozen" do
lambda { "HeLlo".freeze.upcase! }.should raise_error(RuntimeError)
lambda { "HELLO".freeze.upcase! }.should raise_error(RuntimeError)
it "raises a #{frozen_error_class} when self is frozen" do
lambda { "HeLlo".freeze.upcase! }.should raise_error(frozen_error_class)
lambda { "HELLO".freeze.upcase! }.should raise_error(frozen_error_class)
end
end