diff options
author | eregon <eregon@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2017-12-27 16:12:47 +0000 |
---|---|---|
committer | eregon <eregon@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2017-12-27 16:12:47 +0000 |
commit | a34db218ade33b79e7404488db5a15bad2841c25 (patch) | |
tree | 2ed22ad149cd75e36d9aabbe29b32e96c27fa3a6 /spec/ruby/core/string | |
parent | 0f989b87a06563add3fdeb9cda983492e8a420af (diff) | |
download | ruby-a34db218ade33b79e7404488db5a15bad2841c25.tar.gz |
Update to ruby/spec@0fe33ac
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@61504 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'spec/ruby/core/string')
31 files changed, 151 insertions, 142 deletions
diff --git a/spec/ruby/core/string/capitalize_spec.rb b/spec/ruby/core/string/capitalize_spec.rb index 497e1453cd..971b06281e 100644 --- a/spec/ruby/core/string/capitalize_spec.rb +++ b/spec/ruby/core/string/capitalize_spec.rb @@ -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 diff --git a/spec/ruby/core/string/casecmp_spec.rb b/spec/ruby/core/string/casecmp_spec.rb index c77d97815c..f556c79346 100644 --- a/spec/ruby/core/string/casecmp_spec.rb +++ b/spec/ruby/core/string/casecmp_spec.rb @@ -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 diff --git a/spec/ruby/core/string/chomp_spec.rb b/spec/ruby/core/string/chomp_spec.rb index 5daa8c5a40..4f7486b0f7 100644 --- a/spec/ruby/core/string/chomp_spec.rb +++ b/spec/ruby/core/string/chomp_spec.rb @@ -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 diff --git a/spec/ruby/core/string/chop_spec.rb b/spec/ruby/core/string/chop_spec.rb index 4e9a39f866..6afee99685 100644 --- a/spec/ruby/core/string/chop_spec.rb +++ b/spec/ruby/core/string/chop_spec.rb @@ -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 diff --git a/spec/ruby/core/string/clear_spec.rb b/spec/ruby/core/string/clear_spec.rb index 6a8b6018d0..c1bab8f39e 100644 --- a/spec/ruby/core/string/clear_spec.rb +++ b/spec/ruby/core/string/clear_spec.rb @@ -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 diff --git a/spec/ruby/core/string/delete_prefix_spec.rb b/spec/ruby/core/string/delete_prefix_spec.rb index 94d486eace..973fc951cb 100644 --- a/spec/ruby/core/string/delete_prefix_spec.rb +++ b/spec/ruby/core/string/delete_prefix_spec.rb @@ -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 diff --git a/spec/ruby/core/string/delete_spec.rb b/spec/ruby/core/string/delete_spec.rb index 536d4a95af..049f56e926 100644 --- a/spec/ruby/core/string/delete_spec.rb +++ b/spec/ruby/core/string/delete_spec.rb @@ -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 diff --git a/spec/ruby/core/string/delete_suffix_spec.rb b/spec/ruby/core/string/delete_suffix_spec.rb index 49689a8da1..72adcacc55 100644 --- a/spec/ruby/core/string/delete_suffix_spec.rb +++ b/spec/ruby/core/string/delete_suffix_spec.rb @@ -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 diff --git a/spec/ruby/core/string/downcase_spec.rb b/spec/ruby/core/string/downcase_spec.rb index f591c0fa09..adb5f83cfa 100644 --- a/spec/ruby/core/string/downcase_spec.rb +++ b/spec/ruby/core/string/downcase_spec.rb @@ -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 diff --git a/spec/ruby/core/string/element_set_spec.rb b/spec/ruby/core/string/element_set_spec.rb index fea03607f2..9c02afed8d 100644 --- a/spec/ruby/core/string/element_set_spec.rb +++ b/spec/ruby/core/string/element_set_spec.rb @@ -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 diff --git a/spec/ruby/core/string/encode_spec.rb b/spec/ruby/core/string/encode_spec.rb index d051dd58c9..5b6fa7e50c 100644 --- a/spec/ruby/core/string/encode_spec.rb +++ b/spec/ruby/core/string/encode_spec.rb @@ -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 diff --git a/spec/ruby/core/string/force_encoding_spec.rb b/spec/ruby/core/string/force_encoding_spec.rb index d163c75ac3..a2464dc904 100644 --- a/spec/ruby/core/string/force_encoding_spec.rb +++ b/spec/ruby/core/string/force_encoding_spec.rb @@ -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 diff --git a/spec/ruby/core/string/gsub_spec.rb b/spec/ruby/core/string/gsub_spec.rb index 026b037b6c..319dc2e3e1 100644 --- a/spec/ruby/core/string/gsub_spec.rb +++ b/spec/ruby/core/string/gsub_spec.rb @@ -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 diff --git a/spec/ruby/core/string/insert_spec.rb b/spec/ruby/core/string/insert_spec.rb index c207fcc13b..8bae38f074 100644 --- a/spec/ruby/core/string/insert_spec.rb +++ b/spec/ruby/core/string/insert_spec.rb @@ -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 diff --git a/spec/ruby/core/string/lstrip_spec.rb b/spec/ruby/core/string/lstrip_spec.rb index 7ef94be567..b35e359928 100644 --- a/spec/ruby/core/string/lstrip_spec.rb +++ b/spec/ruby/core/string/lstrip_spec.rb @@ -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 diff --git a/spec/ruby/core/string/prepend_spec.rb b/spec/ruby/core/string/prepend_spec.rb index 17e97fd844..81618a4d7c 100644 --- a/spec/ruby/core/string/prepend_spec.rb +++ b/spec/ruby/core/string/prepend_spec.rb @@ -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 diff --git a/spec/ruby/core/string/reverse_spec.rb b/spec/ruby/core/string/reverse_spec.rb index c37e815ba3..5b183fef4f 100644 --- a/spec/ruby/core/string/reverse_spec.rb +++ b/spec/ruby/core/string/reverse_spec.rb @@ -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 diff --git a/spec/ruby/core/string/rstrip_spec.rb b/spec/ruby/core/string/rstrip_spec.rb index 9dd686ce55..aa3f70a166 100644 --- a/spec/ruby/core/string/rstrip_spec.rb +++ b/spec/ruby/core/string/rstrip_spec.rb @@ -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 diff --git a/spec/ruby/core/string/setbyte_spec.rb b/spec/ruby/core/string/setbyte_spec.rb index 6373d74be1..e27ab38d67 100644 --- a/spec/ruby/core/string/setbyte_spec.rb +++ b/spec/ruby/core/string/setbyte_spec.rb @@ -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 diff --git a/spec/ruby/core/string/shared/concat.rb b/spec/ruby/core/string/shared/concat.rb index 7da995fdc7..d7b9cdfec3 100644 --- a/spec/ruby/core/string/shared/concat.rb +++ b/spec/ruby/core/string/shared/concat.rb @@ -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 diff --git a/spec/ruby/core/string/shared/replace.rb b/spec/ruby/core/string/shared/replace.rb index 9f5446fbbe..a583b88b5a 100644 --- a/spec/ruby/core/string/shared/replace.rb +++ b/spec/ruby/core/string/shared/replace.rb @@ -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 diff --git a/spec/ruby/core/string/shared/succ.rb b/spec/ruby/core/string/shared/succ.rb index 4854cb7146..0ab659864d 100644 --- a/spec/ruby/core/string/shared/succ.rb +++ b/spec/ruby/core/string/shared/succ.rb @@ -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 diff --git a/spec/ruby/core/string/slice_spec.rb b/spec/ruby/core/string/slice_spec.rb index 8018cc2140..fce64bd382 100644 --- a/spec/ruby/core/string/slice_spec.rb +++ b/spec/ruby/core/string/slice_spec.rb @@ -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 diff --git a/spec/ruby/core/string/squeeze_spec.rb b/spec/ruby/core/string/squeeze_spec.rb index d6b3fb6de6..01b9fe72ff 100644 --- a/spec/ruby/core/string/squeeze_spec.rb +++ b/spec/ruby/core/string/squeeze_spec.rb @@ -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 diff --git a/spec/ruby/core/string/strip_spec.rb b/spec/ruby/core/string/strip_spec.rb index 747fd8cdf2..36eb38e4e4 100644 --- a/spec/ruby/core/string/strip_spec.rb +++ b/spec/ruby/core/string/strip_spec.rb @@ -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 diff --git a/spec/ruby/core/string/sub_spec.rb b/spec/ruby/core/string/sub_spec.rb index deaa7e27f1..ceda4ec794 100644 --- a/spec/ruby/core/string/sub_spec.rb +++ b/spec/ruby/core/string/sub_spec.rb @@ -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 diff --git a/spec/ruby/core/string/swapcase_spec.rb b/spec/ruby/core/string/swapcase_spec.rb index c2b583acab..d9127856d3 100644 --- a/spec/ruby/core/string/swapcase_spec.rb +++ b/spec/ruby/core/string/swapcase_spec.rb @@ -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 diff --git a/spec/ruby/core/string/tr_s_spec.rb b/spec/ruby/core/string/tr_s_spec.rb index ea2ffa71b9..e387ea2356 100644 --- a/spec/ruby/core/string/tr_s_spec.rb +++ b/spec/ruby/core/string/tr_s_spec.rb @@ -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 diff --git a/spec/ruby/core/string/tr_spec.rb b/spec/ruby/core/string/tr_spec.rb index 16d2d318e1..55556c6e4f 100644 --- a/spec/ruby/core/string/tr_spec.rb +++ b/spec/ruby/core/string/tr_spec.rb @@ -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 diff --git a/spec/ruby/core/string/unpack/j_spec.rb b/spec/ruby/core/string/unpack/j_spec.rb index 49c460aeb3..23d26d896e 100644 --- a/spec/ruby/core/string/unpack/j_spec.rb +++ b/spec/ruby/core/string/unpack/j_spec.rb @@ -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 diff --git a/spec/ruby/core/string/upcase_spec.rb b/spec/ruby/core/string/upcase_spec.rb index 0094380664..31fd7fb8da 100644 --- a/spec/ruby/core/string/upcase_spec.rb +++ b/spec/ruby/core/string/upcase_spec.rb @@ -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 |